123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567 |
- <template>
- <app-layout>
- <view>
- <view class="scan-head dir-top-nowrap main-center">
- <view class="order-name">订单金额</view>
- <view class="scan-price dir-left-nowrap cross-bottom" @click="openPriceModel">
- <view class="order-key">¥</view>
- <view class="order-value">{{list.price}}</view>
- </view>
- <view class="scan-line"></view>
- <!-- 优惠 -->
- <view class="dir-left-nowrap cross-center scan-offer">
- <view class="box-grow-1">订单优惠</view>
- <view class="box-grow-0">
- <view v-if="list.preferential_money > 0" class="red">
- -¥{{list.preferential_money}}
- </view>
- <view v-else-if="list.price > 0" class="gray">暂无优惠</view>
- </view>
- </view>
- <!-- 优惠券 -->
- <view class="dir-left-nowrap cross-center scan-offer">
- <view class="box-grow-1">优惠劵</view>
- <view class="box-grow-0 coupon-right">
- <view v-if="list.coupon_id" @click="setCoupon" class="red">
- -¥{{list.coupon_preferential_money}}
- </view>
- <view v-else-if="list.price > 0 && list.can_coupon_num > 0" class="gray"
- @click="setCoupon">选择优惠券
- </view>
- <view v-else-if="list.price > 0" class="gray">暂无可用优惠券</view>
- </view>
- <view class="box-grow-0 cross-center">
- <icon class="icon-right"></icon>
- </view>
- </view>
- <!-- 积分抵扣 -->
- <view v-if="list.price > 0 && activity && integral.user_integral_num >= integral.member_integral && list.integral_deduction > 0"
- class="dir-left-nowrap cross-center scan-offer">
- <view class="box-grow-1 cross-center dir-left-nowrap">
- <view>
- <text>使用{{list.use_integral_num}}积分抵扣</text>
- <text class="red">{{list.integral_deduction}}</text>
- <text>元</text>
- </view>
- <view @click="getIntegralInfo" class="main-center cross-center">
- <icon class="scan-integral-icon"></icon>
- </view>
- </view>
- <view class="box-grow-0" @click="handleUseIntegral">
- <icon v-if="list.use_integral == 1" class="scan-integral-switch check"></icon>
- <icon v-else class="scan-integral-switch uncheck"></icon>
- </view>
- </view>
- <!-- 备注 -->
- <view class="dir-left-nowrap scan-offer">
- <input @input="bindTextBlur" :value="remark" class="scan-input" placeholder="添加备注"/>
- </view>
- <view class="scan-line"></view>
- <view class="scan-remark cross-center dir-left-nowrap main-center">
- <view class="key">应付金额</view>
- <view class="value">¥{{list.pay_price}}</view>
- </view>
- </view>
- <view class="main-center cross-center scan-btn">
- <app-button @click="submit"
- color="#ffffff"
- font-size="32"
- height="88"
- width="702"
- :background="list.price > 0 ? '#ff4544': '#cdcdcd'"
- :disabled="list.price <= 0"
- round>已与店员确认,立即买单
- </app-button>
- </view>
- <view class="scan-end" v-if="activity.rules">
- <view class="dir-left-nowrap cross-center">
- <view class="icon"></view>
- <view>规则说明</view>
- </view>
- <text space="nbsp">{{activity.rules}}</text>
- </view>
- </view>
- <!-- MODEL -->
- <view v-if="price_modal" class="scan-modal show bt">
- <view class="scan-modal-bg"></view>
- <view class="scan-modal-pic main-center">
- <view class="info-model cross-center dir-top-nowrap">
- <view class="order-title">订单金额</view>
- <view class="info-box dir-left-nowrap cross-center">
- <input focus class="info-input" @input="setTempInput" :value="tmp_price" type="digit"
- placeholder-class="place" placeholder="输入支付金额"/>
- <view>元</view>
- </view>
- <view class="info-end dir-left-nowrap cross-center">
- <view @click="closePriceModel" class="box-grow-1 main-center cross-center">取消</view>
- <view class="box-grow-0 info-line"></view>
- <view @click="calcPrice" class="box-grow-1 red main-center cross-center">确认</view>
- </view>
- </view>
- </view>
- </view>
- </app-layout>
- </template>
- <script>
- export default {
- name: "index",
- components: {},
- data() {
- return {
- page_loading: true,
- tmp_price: '',
- edit_status: true,
- price_modal: false,
- activity: null,
- remark: '',
- integral: {
- user_integral_num: '0',
- },
- list: {
- price: '',
- pay_price: 0.00,
- use_integral: 0,
- activity_id: 0,
- coupon_id: 0,
- can_coupon_num: 0,
- integral_explain: [],
- },
- clear: false,
- }
- },
- onShow: function () {
- const self = this;
- const userCoupon = self.$store.state.scanCode.userCoupon;
- if (userCoupon) {
- if (userCoupon == -1) {
- self.list.coupon_id = 0
- } else {
- self.list.coupon_id = userCoupon.id;
- }
- self.calcPrice();
- } else {
- self.list.coupon_id = 0
- }
- if (self.clear) {
- [
- self.edit_status,
- self.clear,
- self.remark,
- self.tmp_price,
- self.list,
- ] = [
- true,
- false,
- '',
- '',
- {
- price: '',
- pay_price: 0.00,
- use_integral: 0,
- activity_id: 0,
- coupon_id: 0,
- can_coupon_num: 0,
- integral_explain: [],
- }
- ]
- }
- },
- onLoad: function (options) {
- const self = this;
- self.$store.commit('scanCode/mutSetUserCoupon', 0);
- self.clear = true;
- if (options.price) {
- [self.edit_status, self.tmp_price] = [false, options.price];
- self.calcPrice();
- }
- self.$showLoading({text: '加载中'});
- self.$request({
- url: self.$api.scan_code_pay.index
- }).then(info => {
- self.$hideLoading();
- if (info.code === 0) {
- [
- self.activity,
- self.goods,
- self.integral,
- self.setting
- ] = [
- info.data.activity,
- info.data.goods,
- info.data.integral,
- info.data.setting
- ];
- }
- }).catch(info => {
- self.$hideLoading();
- })
- },
- methods: {
- openPriceModel() {
- if (!this.edit_status) return;
- this.price_modal = true;
- },
- closePriceModel() {
- this.price_modal = false;
- },
- setTempInput: function (e) {
- this.tmp_price = e.detail.value;
- },
- //总价
- calcPrice: function () {
- const self = this;
- self.price_modal = false;
- self.$showLoading({text: '加载中'});
- self.$request({
- url: self.$api.scan_code_pay.preview,
- data: {
- price: self.tmp_price,
- coupon_id: self.list.coupon_id,
- use_integral: self.list.use_integral,
- },
- method: 'POST',
- }).then(info => {
- self.$hideLoading();
- if (info.code === 0) {
- [self.list, self.tmp_price] = [info.data, info.data.price];
- } else {
- uni.showToast({icon: 'none', title: info.msg});
- }
- }).catch(info => {
- self.$hideLoading();
- })
- },
- //UseIntegral
- handleUseIntegral() {
- const self = this;
- let list = self.list;
- list.use_integral = list.use_integral == 1 ? 0 : 1;
- self.calcPrice();
- },
- //Remark
- bindTextBlur: function (e) {
- this.remark = e.detail.value;
- },
- //Integral
- getIntegralInfo: function (e) {
- let content = '';
- this.list.integral_explain.map(v => {
- content += '消费满' + v.consume_money + '元,';
- content += '积分最多可抵' + v.integral_deduction + '元';
- content += '\r\n';
- });
- uni.showModal({
- title: '积分抵扣说明',
- content: content.trim(),
- showCancel: false
- })
- },
- //navigate
- setCoupon: function (e) {
- this.clear = false;
- uni.navigateTo({
- url: '/plugins/scan_code/index/coupon?price=' + this.list.price + '&coupon_id=' + this.list.coupon_id,
- });
- },
- submit: function (e) {
- const self = this;
- if (!self.list.price) return
- self.$showLoading({text: '正在提交'});
- self.$request({
- url: self.$api.scan_code_pay.submit,
- method: 'post',
- data: {
- price: self.list.price,
- coupon_id: self.list.coupon_id,
- use_integral: self.list.use_integral,
- remark: self.remark,
- },
- }).then(e => {
- self.$hideLoading();
- if (e.code === 0) {
- self.$payment.pay(e.data.pay_id).then(payMsg => {
- self.$store.commit('scanCode/mutSetUserCoupon', '');
- // 支付成功
- uni.showModal({
- title: '提示',
- content: "支付成功",
- showCancel: false,
- success() {
- uni.navigateTo({
- url: '/pages/order-submit/pay-result?payment_order_union_id=' + e.data.pay_id + '&plugin=scan_code_pay'
- })
- self.clear = true;
- },
- });
- }).catch(payMsg => {
- // 支付失败
- self.$showLoading({text: '取消中'});
- self.$request({
- url: self.$api.scan_code_pay.cancel,
- data: {
- pay_id: e.data.pay_id,
- },
- method: 'POST',
- }).then(info => {
- self.$hideLoading();
- }).catch(info => {
- self.$hideLoading();
- uni.showModal({title: '提示', content: info.msg});
- })
- });
- } else {
- uni.showModal({title: '提示', content: info.msg});
- }
- }).catch(e => {
- self.$hideLoading();
- });
- },
- }
- }
- </script>
- <style scoped lang="scss">
- .red {
- color: #ff4544;
- }
- .gray {
- color: #999999;
- }
- .scan-head {
- margin: #{20rpx} #{24rpx} 0 #{24rpx};
- background: #fff;
- border-radius: #{16rpx};
- padding: #{48rpx} #{40rpx} 0 #{40rpx};
- font-size: #{28rpx};
- color: #353535;
- .scan-line {
- height: 1px;
- margin-top: #{38rpx};
- background: #e2e2e2;
- }
- .scan-price {
- margin-top: #{32rpx};
- .order-key {
- font-size: #{50rpx};
- }
- .order-value {
- font-size: #{80rpx};
- padding-left: #{28rpx};
- height: #{98rpx};
- }
- }
- }
- .scan-offer {
- color: #666666;
- font-size: #{28rpx};
- margin-top: #{40rpx};
- .coupon-right {
- padding-right: #{12rpx};
- }
- .icon-right {
- background-size: 100% auto;
- background-repeat: no-repeat;
- background-image: url("../../../static/image/icon/arrow-right.png");
- width: #{12rpx};
- height: #{22rpx};
- }
- }
- .scan-integral-icon {
- height: #{36rpx};
- width: #{36rpx};
- background-image: url("../../../static/image/icon/warning.png");
- background-repeat: no-repeat;
- background-size: 100% auto;
- margin-left: #{20rpx};
- }
- .scan-integral-switch {
- width: #{44rpx};
- height: #{44rpx};
- background-size: 100% auto;
- background-repeat: no-repeat;
- float: left;
- }
- .scan-integral-switch.check {
- margin-left: #{5rpx};
- background-image: url("../../../static/image/icon/icon-checkbox-checked-a.png");
- }
- .scan-integral-switch.uncheck {
- margin-left: #{5rpx};
- background-image: url("../../../static/image/icon/icon-uncheck.png");
- }
- .scan-input {
- width: 100%;
- font-size: #{28rpx};
- color: #666;
- }
- .scan-remark {
- height: #{106rpx};
- .key {
- margin-left: auto;
- color: #353535;
- font-size: #{28rpx};
- }
- .value {
- margin-left: #{10rpx};
- color: #ff4544;
- font-size: #{36rpx};
- }
- }
- .scan-end {
- color: #666;
- background: #fff;
- margin: 0 #{24rpx};
- font-size: #{28rpx};
- border-radius: #{16rpx};
- padding: #{40rpx};
- text {
- word-break: break-all;
- text-align: justify;
- }
- }
- .scan-end > view {
- margin-bottom: #{12rpx};
- }
- .scan-end .icon {
- height: #{26rpx};
- width: #{8rpx};
- border-radius: #{4rpx};
- background: #ff4544;
- margin-right: #{16rpx};
- }
- .scan-btn {
- margin: #{40rpx} auto;
- }
- .scan-modal {
- position: fixed;
- left: 0;
- top: 0;
- width: 100%;
- height: 100%;
- z-index: 2001;
- transition: 200ms;
- }
- .scan-modal.show {
- visibility: visible;
- opacity: 1;
- }
- .scan-modal.bt {
- -webkit-animation-name: fadeIn; /*动画名称*/
- -webkit-animation-duration: 0.25s; /*动画持续时间*/
- -webkit-animation-iteration-count: 1; /*动画次数*/
- -webkit-animation-delay: 0s; /*延迟时间*/
- }
- .scan-modal .scan-modal-bg {
- background: rgba(0, 0, 0, 0.8);
- position: fixed;
- left: 0;
- top: 0;
- width: 100%;
- height: 100%;
- z-index: 1;
- }
- .scan-modal .scan-modal-pic {
- position: fixed;
- left: 0;
- top: #{188rpx};
- width: 100%;
- height: 100%;
- z-index: 1;
- }
- .scan-modal .scan-modal-close image {
- width: #{50rpx};
- height: #{50rpx};
- margin-top: #{50rpx};
- }
- .scan-modal .info-model {
- height: #{360rpx};
- width: #{620rpx};
- background: #fff;
- border-radius: #{16rpx};
- }
- .scan-modal .order-title {
- margin: #{48rpx} 0
- }
- .scan-modal .place {
- color: #cdcdcd
- }
- .scan-modal .info-box {
- height: #{88rpx};
- width: #{400rpx};
- margin-bottom: #{48rpx};
- border-radius: #{8rpx};
- padding: 0 #{24rpx};
- border: 1px solid #e2e2e2;
- }
- .scan-modal .info-input {
- font-size: #{32rpx};
- color: #353535;
- }
- .scan-modal .info-line {
- height: #{32rpx} !important;
- width: 1px !important;
- background: #e2e2e2;
- }
- .scan-modal .info-end {
- color: #666666;
- height: #{88rpx};
- font-size: #{32rpx};
- border-top: #{1rpx} solid #e2e2e2;
- width: 100%;
- }
- .scan-modal .info-end view {
- height: 100%;
- width: 100%;
- }
- </style>
|