diff --git a/Utils/Api.js b/Utils/Api.js index f347a74..786a695 100644 --- a/Utils/Api.js +++ b/Utils/Api.js @@ -134,7 +134,12 @@ export const getStoreListByMerchant = params => { //获取优惠券详情 export const getDiscountByQrCode = params => { return POST('GET', `${base}/discount/getDiscountByQrCode`, params).then(res => res.data); -} +} +//查询话费优惠券 +export const getUserOrderPreList = params => { + return POST('GET', `${base}/userDiscount/getUserOrderPreList`, params).then(res => res.data); +} + //领取优惠券 export const receiveDiscount = params => { return POST('POST', `${base}/userDiscount/receiveDiscount`, params).then(res => res.data); diff --git a/Utils/js/date.js b/Utils/js/date.js new file mode 100644 index 0000000..b13cba8 --- /dev/null +++ b/Utils/js/date.js @@ -0,0 +1,55 @@ +const isNullOrEmpty = function(val) { + if (val == null || val == "" || typeof(val) == undefined) { + return true; + } else { + return false; + } +} + +const timeFormat = (value, format) => { + let date = new Date(value); + let y = date.getFullYear(); + let m = date.getMonth() + 1; + let d = date.getDate(); + let h = date.getHours(); + let min = date.getMinutes(); + let s = date.getSeconds(); + let result = ""; + if (format == undefined) { + result = `${y}-${m < 10 ? "0" + m : m}-${d < 10 ? "0" + d : d} ${ + h < 10 ? "0" + h : h + }:${min < 10 ? "0" + min : min}:${s < 10 ? "0" + s : s}`; + } + if (format == "yyyy-mm-dd hh:mm") { + result = `${y}-${m < 10 ? "0" + m : m}-${d < 10 ? "0" + d : d} `; + } + if (format == "yyyy-mm-dd") { + result = `${y}-${m < 10 ? "0" + m : m}-${d < 10 ? "0" + d : d}`; + } + if (format == "yyyy-mm") { + result = `${y}-${m < 10 ? "0" + m : m}`; + } + if (format == "mm-dd") { + result = ` ${mm < 10 ? "0" + mm : mm}:${ddmin < 10 ? "0" + dd : dd}`; + } + if (format == "hh:mm") { + result = ` ${h < 10 ? "0" + h : h}:${min < 10 ? "0" + min : min}`; + } + if (format == "yyyy") { + result = `${y}`; + } + return result; +}; + + +// {{date|isNullOrEmpty}} +// {{date|timeFormat('yyyy-mm-dd')}} +// {{date|timeFormat('yyyy-mm')}} +// {{date|timeFormat('hh:mm')}} +// {{date|timeFormat('yyyy')}} +// {{date|timeFormat}} + +export { + isNullOrEmpty, + timeFormat +} diff --git a/main.js b/main.js index 77ee1e2..1cd853e 100644 --- a/main.js +++ b/main.js @@ -1,12 +1,20 @@ import Vue from 'vue' -import App from './App' -import {VueJsonp} from 'vue-jsonp' +import App from './App' +import * as filters from './Utils/js/date.js' +import { + VueJsonp +} from 'vue-jsonp' import share from 'common/share.js' + +Object.keys(filters).forEach(key => { + Vue.filter(key, filters[key]) +}) + Vue.config.productionTip = false Vue.use(VueJsonp) App.mpType = 'app' Vue.mixin(share) const app = new Vue({ - ...App + ...App }) app.$mount() diff --git a/subPages/unionComfirmation/unionComfirmation.vue b/subPages/unionComfirmation/unionComfirmation.vue index ffd7661..71e2e78 100644 --- a/subPages/unionComfirmation/unionComfirmation.vue +++ b/subPages/unionComfirmation/unionComfirmation.vue @@ -25,6 +25,24 @@ ¥{{orderPrice}} + + + + + 优惠抵扣{{OrderPreList.length}}张可用 + + + 未使用 + + + + -¥{{deductionPrice}} + + + + @@ -85,6 +103,21 @@ + + 优惠券选择 + + + + + + + {{items.discountName}} + 有效期至:{{items.useEndTime | timeFormat('yyyy-mm-dd')}} + + + + @@ -98,8 +131,10 @@ orderToGoldPayunion, hltUnionCardPayUnion, getHuiLianTongCardBalance, - loginByPhone + loginByPhone, + getUserOrderPreList } from '../../Utils/Api.js'; + import wybPopup from '../../components/wyb-popup/wyb-popup.vue'; import ssPaymentPassword from '../../components/sanshui-payment-password'; let app = getApp(); // #ifdef H5 @@ -107,6 +142,7 @@ // #endif export default { components: { + wybPopup, ssPaymentPassword }, data() { @@ -127,25 +163,28 @@ radioStatus: true, memDiscountId: '', user: '', - paytype: '', + paytype: 'weixin', PaymentPassword: '', orderId: '', jumpType: '', tongCardPrice: 0, - //话费充值 orderPrice: 0, - payPrice: 0, + payPrice: 0, + //保存价格 + saveprice:0, rechargeContent: '', rechargeModel: '', agentKey: '', - objectId: '' + objectId: '', + OrderPreList: [] }; }, onLoad(options) { this.orderPrice = options.orderPrice; - this.payPrice = options.payPrice; + this.payPrice = options.payPrice; + this.saveprice = options.payPrice; this.rechargeContent = options.rechargeContent; this.rechargeModel = options.rechargeModel; this.agentKey = options.agentKey; @@ -153,9 +192,12 @@ }, onShow() { let that = this; - that.paytype = ''; + that.paytype = 'weixin'; that.user = app.globalData.userInfo; that.findUser(); + // #ifdef MP + that.getUserOrderPreList(); + // #endif }, onHide() { @@ -176,6 +218,17 @@ } }); }, + //查询优惠券 + getUserOrderPreList() { + let params = { + usingAttribution: 1 + } + getUserOrderPreList(params).then(res => { + if (res.return_code == '000000') { + this.OrderPreList = res.return_data; + } + }); + }, //显示弹出 showPopup() { this.$refs.popup.show(); @@ -199,6 +252,40 @@ url: '/pages/login/register' }) }, + radioChanges(item) { + this.paytheprice = this.saveprice; + if (this.memDiscountId == item.id) { // 如果已经选中,则取消选中 + this.memDiscountId = ''; + this.payPrice = this.saveprice; + this.deductionPrice = '0.00'; + } else { // 否则进行选中赋值 + this.memDiscountId = item.id; + if (item.discountType == 1) { + if (this.paytheprice > item.discountPrice) { + //满减价格 + this.deductionPrice = item.discountPrice; + this.payPrice = (((this.paytheprice * 100) - (this.deductionPrice * 100)) / + 100); + } else { + uni.showToast({ + title: '未满足满减条件', + icon: 'none', + duration: 2000 + }) + } + } else if (item.discountType == 2) { + //抵扣价格 + this.deductionPrice = item.discountPrice; + this.payPrice = (((this.paytheprice * 100) - (this.deductionPrice * 100)) / 100); + } else if (item.discountType == 3) { + // 打折 + this.deductionPrice = this.paytheprice - this.paytheprice * ( + item.discountPrice / 10); + this.payPrice = this.paytheprice * (item.discountPrice / 10); + } + } + this.$refs.popup.hide(); + }, // 微信获取手机号 loginByPhone(PhoneNumber) { if (PhoneNumber.detail.iv == undefined) { @@ -292,6 +379,10 @@ return; } }, + //弹出优惠券 + showPopup() { + this.$refs.popup.show(); + }, //获取订单数据 orderToUNionPay(item) { let that = this; @@ -520,7 +611,7 @@ border-radius: 8px; } - .jtcs { + .j { width: 40rpx; height: 40rpx; margin-top: 30rpx; @@ -540,7 +631,8 @@ width: 100%; height: 25px; text-align: right; - margin-top: -20px; + margin-top: -30px; + margin-left: 50px; } .price-number { @@ -627,6 +719,7 @@ image { width: 170rpx; max-height: 170rpx; + margin-left: 10px; } }