|
@@ -6,28 +6,29 @@ import { mapState } from 'vuex';
|
|
|
import fuiToast from '@/components/fui-toast/fui-toast.vue';
|
|
|
import { initWxJsSdkConfig } from '@/utils/login';
|
|
|
import { getPlatform } from '@/utils';
|
|
|
+import { paperCoupon } from '@/api/parking'
|
|
|
|
|
|
export default {
|
|
|
components: {
|
|
|
fuiToast,
|
|
|
},
|
|
|
created() {
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- parkFee: {}, // 停车规则相关信息
|
|
|
- // parkPaperCouponRemark: '', // 纸质优惠券说明
|
|
|
- servicefee: 0, // 应缴金额
|
|
|
- paperDiscountFee: 0, // 纸质优惠券减免金额
|
|
|
- paperDiscountTime: 0, // 纸质优惠券减免时长
|
|
|
- parkDiscountTotal: {}, // 总停车优惠
|
|
|
+ // parkFee: {}, // 停车规则相关信息
|
|
|
+ // // parkPaperCouponRemark: '', // 纸质优惠券说明
|
|
|
+ // servicefee: 0, // 应缴金额
|
|
|
+ // paperDiscountFee: 0, // 纸质优惠券减免金额
|
|
|
+ // paperDiscountTime: 0, // 纸质优惠券减免时长
|
|
|
+ // parkDiscountTotal: {}, // 总停车优惠
|
|
|
paperCouponList: [], // 纸质券list
|
|
|
- paperCouponInfo: {}, // 页面缓存
|
|
|
- maxonetimediscountFee: 0, // 每次优惠上限金额
|
|
|
- maxonedaydiscountFee: 0, // 每天优惠上限金额
|
|
|
- parkMallCode: 1, // 0静安 1浦东 2杭州 3北京 4沈阳 5深圳
|
|
|
- parkInfo: {},
|
|
|
+ // paperCouponInfo: {}, // 页面缓存
|
|
|
+ // maxonetimediscountFee: 0, // 每次优惠上限金额
|
|
|
+ // maxonedaydiscountFee: 0, // 每天优惠上限金额
|
|
|
+ // parkMallCode: 1, // 0静安 1浦东 2杭州 3北京 4沈阳 5深圳
|
|
|
+ // parkInfo: {},
|
|
|
};
|
|
|
},
|
|
|
async mounted() {
|
|
@@ -35,80 +36,58 @@ export default {
|
|
|
uni.setNavigationBarTitle({
|
|
|
title: '纸质优惠券减免',
|
|
|
});
|
|
|
- }, 300);
|
|
|
+ },300);
|
|
|
const platform = getPlatform();
|
|
|
- if (platform === 'micromessenger') {
|
|
|
+ if ( platform === 'micromessenger' ) {
|
|
|
// this.getTicket();
|
|
|
- await initWxJsSdkConfig(['checkJsApi', 'scanQRCode']);
|
|
|
+ await initWxJsSdkConfig(['checkJsApi','scanQRCode']);
|
|
|
// await initWxJsSdkConfig(['checkJsApi', 'scanQRCode']);
|
|
|
// if (window.wxJsSdkConfigInitPromise) {
|
|
|
// await window.wxJsSdkConfigInitPromise;
|
|
|
// }
|
|
|
}
|
|
|
+ this.pageInit()
|
|
|
setTimeout(() => {
|
|
|
uni.setNavigationBarTitle({
|
|
|
title: '优惠券',
|
|
|
});
|
|
|
- }, 300);
|
|
|
+ },300);
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState({
|
|
|
- custTypeId: (state) => state.custTypeId,
|
|
|
- mallid: (state) => state.mallId,
|
|
|
- openId: (state) => state.openid,
|
|
|
- member: (state) => state.member,
|
|
|
- groupId: (state) => state.groupId,
|
|
|
- orderDetail: (state) => state.order.orderDetail
|
|
|
+ custTypeId: ( state ) => state.custTypeId,
|
|
|
+ mallid: ( state ) => state.mallId,
|
|
|
+ openId: ( state ) => state.openid,
|
|
|
+ member: ( state ) => state.member,
|
|
|
+ groupId: ( state ) => state.groupId,
|
|
|
+ orderDetail: ( state ) => state.order.orderDetail,
|
|
|
+ paperCoupons: ( state ) => state.order.paperCoupons,
|
|
|
+ paperDiscountFee: ( state ) => state.order.paperDiscountFee,
|
|
|
+ paperDiscountTime: ( state ) => state.order.paperDiscountTime,
|
|
|
}),
|
|
|
- // 实际支付金额
|
|
|
- actualFee() {
|
|
|
- const fee = this.servicefee - this.discountFee;
|
|
|
- return fee > 0 ? fee : 0;
|
|
|
- },
|
|
|
- // 已优惠金额
|
|
|
- discountFee() {
|
|
|
- // 超出上限按上限计算
|
|
|
- if (this.parkMallCode === 1) {
|
|
|
- if (this.parkDiscountTotal.feeCopy > this.maxonetimediscountFee) {
|
|
|
- this.parkDiscountTotal.feeCopy = this.maxonetimediscountFee;
|
|
|
- }
|
|
|
- }
|
|
|
- if (this.parkMallCode === 4) {
|
|
|
- if (
|
|
|
- this.parkDiscountTotal.feeCopy - this.parkDiscountTotal.bonusfee >
|
|
|
- this.maxonedaydiscountFee
|
|
|
- ) {
|
|
|
- this.parkDiscountTotal.feeCopy =
|
|
|
- this.maxonedaydiscountFee + this.parkDiscountTotal.bonusfee;
|
|
|
- }
|
|
|
- }
|
|
|
- return this.parkDiscountTotal.feeCopy + this.paperDiscountFee;
|
|
|
- },
|
|
|
- },
|
|
|
- watch: {
|
|
|
- orderDetail(){
|
|
|
- console.log('909090', this.orderDetail)
|
|
|
- }
|
|
|
},
|
|
|
methods: {
|
|
|
- showToast(text) {
|
|
|
+ pageInit() {
|
|
|
+ this.paperCouponList = [...this.paperCoupons]
|
|
|
+ },
|
|
|
+ showToast( text ) {
|
|
|
let options = {};
|
|
|
options.text = text;
|
|
|
this.$refs.toast.show(options);
|
|
|
},
|
|
|
// 扫码
|
|
|
scanCode() {
|
|
|
- const runScanFn = (res) => {
|
|
|
- if (res.scanType == 'QR_CODE' && res.scanType) {
|
|
|
+ const runScanFn = ( res ) => {
|
|
|
+ if ( res.scanType == 'QR_CODE' && res.scanType ) {
|
|
|
console.log(res.result);
|
|
|
const url = res.result;
|
|
|
- if (url.indexOf('auth/') === -1) {
|
|
|
+ if ( url.indexOf('auth/') === -1 ) {
|
|
|
this.getPaperCouponInfo(res.result);
|
|
|
} else {
|
|
|
const start = url.indexOf('auth/');
|
|
|
const end = url.indexOf('?');
|
|
|
- const params = url.slice(start, end).split('/');
|
|
|
- if (params && params.length) {
|
|
|
+ const params = url.slice(start,end).split('/');
|
|
|
+ if ( params && params.length ) {
|
|
|
const couponCode = params[1];
|
|
|
this.getPaperCouponInfo(couponCode);
|
|
|
}
|
|
@@ -117,12 +96,12 @@ export default {
|
|
|
};
|
|
|
// 微信小程序
|
|
|
const platform = getPlatform();
|
|
|
- if (platform === 'miniprogram') {
|
|
|
+ if ( platform === 'miniprogram' ) {
|
|
|
window.toWXSendMsg({
|
|
|
type: 'scanQRCode',
|
|
|
});
|
|
|
- window.subscribe('scanQRCodeOver', (options) => {
|
|
|
- console.log('微信扫码结束之后的返回参数', options);
|
|
|
+ window.subscribe('scanQRCodeOver',( options ) => {
|
|
|
+ console.log('微信扫码结束之后的返回参数',options);
|
|
|
runScanFn(options);
|
|
|
});
|
|
|
} else {
|
|
@@ -130,250 +109,90 @@ export default {
|
|
|
desc: 'scanQRCode desc',
|
|
|
needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
|
|
|
// scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
|
|
|
- success: (res) => {
|
|
|
- console.log(237, res);
|
|
|
+ success: ( res ) => {
|
|
|
+ console.log(237,res);
|
|
|
runScanFn(res);
|
|
|
// this.formMsg.deviceCode = res.resultStr;
|
|
|
},
|
|
|
- error: (res) => {
|
|
|
- console.log(242, res);
|
|
|
+ error: ( res ) => {
|
|
|
+ console.log(242,res);
|
|
|
},
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- /* uni.scanCode({
|
|
|
- onlyFromCamera: false,
|
|
|
- scanType: ['qrCode'],
|
|
|
- success: (res) => {
|
|
|
- console.log('扫码', res);
|
|
|
- if (res.scanType == 'QR_CODE' && res.scanType) {
|
|
|
- console.log(res.result);
|
|
|
- const url = res.result;
|
|
|
- if (url.indexOf('auth/') === -1) {
|
|
|
- this.getPaperCouponInfo(res.result);
|
|
|
- } else {
|
|
|
- const start = url.indexOf('auth/');
|
|
|
- const end = url.indexOf('?');
|
|
|
- const params = url.slice(start, end).split('/');
|
|
|
- if (params && params.length) {
|
|
|
- const couponCode = params[1];
|
|
|
- this.getPaperCouponInfo(couponCode);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- }); */
|
|
|
},
|
|
|
|
|
|
// 根据卡券ID查询卡券信息
|
|
|
- getPaperCouponInfo(couponCode) {
|
|
|
+ async getPaperCouponInfo( couponCode ) {
|
|
|
uni.showLoading({
|
|
|
title: '加载中',
|
|
|
});
|
|
|
- const params = {
|
|
|
- groupId: this.groupId,
|
|
|
- mallid: this.mallid,
|
|
|
- couponcode: couponCode,
|
|
|
- orderno: uni.getStorageSync('orderno'),
|
|
|
- };
|
|
|
- this.$md(params);
|
|
|
- uni.request({
|
|
|
- url: this.$baseURL + 'api/1.0/park/queryTicketCount',
|
|
|
- data: params,
|
|
|
- method: 'POST',
|
|
|
- header: JSON.parse(uni.getStorageSync('handleUser')),
|
|
|
- success: (res) => {
|
|
|
- uni.hideLoading();
|
|
|
- console.log(res);
|
|
|
- if (res.data.code !== 0) {
|
|
|
- // return uni.showToast({
|
|
|
- // title: res.data.msg,
|
|
|
- // duration: 2000,
|
|
|
- // icon: 'none'
|
|
|
- // })
|
|
|
- return Toast({
|
|
|
- message: res.data.msg,
|
|
|
- });
|
|
|
- // return this.showToast(res.data.msg);
|
|
|
- }
|
|
|
- if (res.data.data.type === 2) {
|
|
|
- if (res.data.data.discountType == '0') {
|
|
|
- return Toast({
|
|
|
- message: '该纸质优惠券未激活',
|
|
|
- });
|
|
|
- // return uni.showToast({
|
|
|
- // title: '该纸质优惠券未激活',
|
|
|
- // duration: 2000,
|
|
|
- // icon: 'none',
|
|
|
- // });
|
|
|
- }
|
|
|
- if (res.data.data.discountRuleId == '1') {
|
|
|
- return Toast({
|
|
|
- message: '该纸质优惠券已领取',
|
|
|
- });
|
|
|
- // return uni.showToast({
|
|
|
- // title: '该纸质优惠券已领取',
|
|
|
- // duration: 2000,
|
|
|
- // icon: 'none',
|
|
|
- // });
|
|
|
- }
|
|
|
- if (res.data.data.discountRuleId == '2') {
|
|
|
- return Toast({
|
|
|
- message: '该纸质优惠券已使用',
|
|
|
- });
|
|
|
- // return uni.showToast({
|
|
|
- // title: '该纸质优惠券已使用',
|
|
|
- // duration: 2000,
|
|
|
- // icon: 'none',
|
|
|
- // });
|
|
|
- }
|
|
|
- if (res.data.data.discountRuleId == '3') {
|
|
|
- return Toast({
|
|
|
- message: '该纸质优惠券已核销',
|
|
|
- });
|
|
|
- // return uni.showToast({
|
|
|
- // title: '该纸质优惠券已核销',
|
|
|
- // duration: 2000,
|
|
|
- // icon: 'none',
|
|
|
- // });
|
|
|
- }
|
|
|
- }
|
|
|
- if (this.paperCouponList.length) {
|
|
|
- const index = this.paperCouponList.findIndex(
|
|
|
- (e) => e.discountCode === couponCode
|
|
|
- );
|
|
|
- if (index === -1) {
|
|
|
- this.paperCouponList.push(res.data.data);
|
|
|
- this.paperDiscountFee += Number(res.data.data.discountValueMoney);
|
|
|
- this.paperDiscountTime =
|
|
|
- this.paperDiscountFee / this.parkFee.parkInfoEntity.needmoney;
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.paperCouponList.push(res.data.data);
|
|
|
- this.paperDiscountFee += Number(res.data.data.discountValueMoney);
|
|
|
- this.paperDiscountTime =
|
|
|
- this.paperDiscountFee / this.parkFee.parkInfoEntity.needmoney;
|
|
|
+ // const res = await paperCoupon(couponCode);
|
|
|
+ const res = {
|
|
|
+ "status": "1",
|
|
|
+ "discountCode": "91354260",
|
|
|
+ "discountFee": 1,
|
|
|
+ "used": "0",
|
|
|
+ "content": "嘉里卡券测试"
|
|
|
+ }
|
|
|
+ if ( /0/.test(res.status)) {
|
|
|
+ return Toast({
|
|
|
+ message: '该纸质优惠券未激活',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (/1/.test(res.used)) {
|
|
|
+ return Toast({
|
|
|
+ message: '该纸质优惠券已领取',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (/2/.test(res.used)) {
|
|
|
+ return Toast({
|
|
|
+ message: '该纸质优惠券已使用',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (/3/.test(res.used)) {
|
|
|
+ return Toast({
|
|
|
+ message: '该纸质优惠券已核销',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 如果纸质优惠券不存在的话,则往 paperCoupons 添加
|
|
|
+ if ( this.paperCoupons.findIndex(item => item.discountCode === couponCode) < 0 ) {
|
|
|
+ const {hourPrice} = this.orderDetail.parkingRule
|
|
|
+ const discountTime = Number(res.discountFee) / hourPrice
|
|
|
+ this.$store.commit('order/setPaperCoupons',[
|
|
|
+ ...this.paperCoupons,
|
|
|
+ {
|
|
|
+ ...res,
|
|
|
+ discountTime: res.discountFee / hourPrice
|
|
|
}
|
|
|
-
|
|
|
- // this.crossMessage();
|
|
|
- },
|
|
|
- fail: (err) => {
|
|
|
- uni.hideLoading();
|
|
|
- console.log(err);
|
|
|
- },
|
|
|
- });
|
|
|
+ ])
|
|
|
+ // 金额
|
|
|
+ this.$store.commit('order/setPaperDiscountFee',this.paperDiscountFee + Number(res.discountFee))
|
|
|
+ // 时间
|
|
|
+ this.$store.commit('order/setPaperDiscountTime',this.paperDiscountTime + discountTime)
|
|
|
+ }
|
|
|
},
|
|
|
-
|
|
|
// 删除
|
|
|
- deleteCoupon(i) {
|
|
|
- this.paperDiscountFee -= Number(
|
|
|
- this.paperCouponList[i].discountValueMoney
|
|
|
- );
|
|
|
- this.paperDiscountTime =
|
|
|
- this.paperDiscountFee / this.parkFee.parkInfoEntity.needmoney;
|
|
|
- this.paperCouponList.splice(i, 1);
|
|
|
+ deleteCoupon( i ) {
|
|
|
+ const item = this.paperCoupons[i]
|
|
|
+ const paperCoupons = this.paperCoupons.filter(elm => elm.discountCode !== item.discountCode)
|
|
|
+ const {hourPrice} = this.orderDetail.parkingRule
|
|
|
+ const discountTime = Number(item.discountFee) / hourPrice
|
|
|
+ this.$store.commit('order/setPaperCoupons',paperCoupons)
|
|
|
+ // 金额
|
|
|
+ this.$store.commit('order/setPaperDiscountFee',this.paperDiscountFee - Number(item.discountFee))
|
|
|
+ // 时间
|
|
|
+ this.$store.commit('order/setPaperDiscountTime',this.paperDiscountTime + discountTime)
|
|
|
},
|
|
|
|
|
|
- /**
|
|
|
- * 2021-12-24 微信小群确定取消纸质券限制
|
|
|
- */
|
|
|
- // 超限提示
|
|
|
- // crossMessage() {
|
|
|
- // let totalFee = this.parkDiscountTotal.feeCopy;
|
|
|
- // if (this.paperCouponInfo && this.paperCouponInfo.paperDiscountFee !== 0) {
|
|
|
- // totalFee += this.paperDiscountFee - this.paperCouponInfo.paperDiscountFee;
|
|
|
- // } else {
|
|
|
- // totalFee += this.paperDiscountFee;
|
|
|
- // }
|
|
|
- // // 是否受每次最大优惠限制(浦东)
|
|
|
- // if (this.parkFee.parkPaperCouponsEntities[0].isMaxLimit !== 1) {
|
|
|
- // if (totalFee > this.maxonetimediscountFee) {
|
|
|
- // return uni.showToast({
|
|
|
- // title: `超出抵扣上限,每次最高可抵扣${this.parkFee.parkInfoEntity.maxonetimediscount}小时`,
|
|
|
- // icon: 'none'
|
|
|
- // });
|
|
|
- // }
|
|
|
- // }
|
|
|
- // // 浦东总优惠不包含纸质券
|
|
|
- // if (this.parkMallCode !== 1) {
|
|
|
- // if (totalFee > this.maxonedaydiscountFee) {
|
|
|
- // return uni.showToast({
|
|
|
- // title: `超出抵扣上限,每天最高可抵扣${this.parkFee.parkInfoEntity.maxonedaydiscount}小时`,
|
|
|
- // icon: 'none'
|
|
|
- // });
|
|
|
- // }
|
|
|
- // }
|
|
|
- // },
|
|
|
-
|
|
|
// 确认
|
|
|
confirm() {
|
|
|
- console.log(310, this.orderDetail);
|
|
|
- return
|
|
|
- let paperCouponcode = '';
|
|
|
- this.paperCouponList.forEach((e, i) => {
|
|
|
- if (i === this.paperCouponList.length - 1) {
|
|
|
- paperCouponcode += e.discountCode;
|
|
|
- } else {
|
|
|
- paperCouponcode += e.discountCode + '#';
|
|
|
- }
|
|
|
- });
|
|
|
- uni.setStorageSync('paperCouponInfo', {
|
|
|
- paperDiscountFee: this.paperDiscountFee,
|
|
|
- paperDiscountTime: this.paperDiscountTime,
|
|
|
- paperCouponcode: paperCouponcode,
|
|
|
- paperCouponList: this.paperCouponList,
|
|
|
+ console.log(310,this.orderDetail);
|
|
|
+ this.$store.dispatch('order/savePaperCoupon', {
|
|
|
+ couponList: this.paperCoupons,
|
|
|
+ callback: () => {
|
|
|
+ this.$router.back();
|
|
|
+ },
|
|
|
});
|
|
|
- this.$router.back();
|
|
|
},
|
|
|
- /*
|
|
|
- // h5获取配置---公众号支付
|
|
|
- getTicket() {
|
|
|
- let self = this;
|
|
|
- var datas = {
|
|
|
- groupId: this.$store.state.groupId,
|
|
|
- mallid: this.$store.state.mallid,
|
|
|
- url: window.location.href.split('#')[0],
|
|
|
- };
|
|
|
- self.$md(datas);
|
|
|
- uni.request({
|
|
|
- url: self.$baseURL + 'api/1.0/login/getTicket',
|
|
|
- method: 'POST',
|
|
|
- data: datas,
|
|
|
- header: JSON.parse(uni.getStorageSync('handleUser')),
|
|
|
- success: (res) => {
|
|
|
- if (res.data.code == 0) {
|
|
|
- self.$wx.config({
|
|
|
- debug: false, // 开启调试模式
|
|
|
- appId: res.data.data.appId, // 必填,公众号的唯一标识
|
|
|
- timestamp: res.data.data.timestamp, // 必填,生成签名的时间戳
|
|
|
- nonceStr: res.data.data.nonceStr, // 必填,生成签名的随机串
|
|
|
- signature: res.data.data.signature, // 必填,签名
|
|
|
- jsApiList: ['chooseWXPay', 'scanQRCode', 'checkJsApi'], // 必填,需要使用的JS接口列表
|
|
|
- });
|
|
|
- self.$wx.ready(function () {
|
|
|
- self.$wx.checkJsApi({
|
|
|
- jsApiList: ['chooseWXPay'],
|
|
|
- success: (res) => {
|
|
|
- console.log('checked api:', res);
|
|
|
- },
|
|
|
- fail: (err) => {
|
|
|
- console.log('check api fail:', err);
|
|
|
- },
|
|
|
- });
|
|
|
- });
|
|
|
- self.$wx.error(function (res) {
|
|
|
- console.log('err', res);
|
|
|
- });
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- title: res.data.msg,
|
|
|
- duration: 2000,
|
|
|
- icon: 'none',
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
- */
|
|
|
},
|
|
|
};
|