1.新增时间转换文件

2.添加小程序 话费充值优惠券功能
yj-dev
杨杰 3 years ago
parent 8fc9f0f655
commit b332a97a1a
  1. 5
      Utils/Api.js
  2. 55
      Utils/js/date.js
  3. 12
      main.js
  4. 107
      subPages/unionComfirmation/unionComfirmation.vue

@ -135,6 +135,11 @@ export const getStoreListByMerchant = params => {
export const getDiscountByQrCode = params => { export const getDiscountByQrCode = params => {
return POST('GET', `${base}/discount/getDiscountByQrCode`, params).then(res => res.data); 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 => { export const receiveDiscount = params => {
return POST('POST', `${base}/userDiscount/receiveDiscount`, params).then(res => res.data); return POST('POST', `${base}/userDiscount/receiveDiscount`, params).then(res => res.data);

@ -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
}

@ -1,12 +1,20 @@
import Vue from 'vue' import Vue from 'vue'
import App from './App' import App from './App'
import {VueJsonp} from 'vue-jsonp' import * as filters from './Utils/js/date.js'
import {
VueJsonp
} from 'vue-jsonp'
import share from 'common/share.js' import share from 'common/share.js'
Object.keys(filters).forEach(key => {
Vue.filter(key, filters[key])
})
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.use(VueJsonp) Vue.use(VueJsonp)
App.mpType = 'app' App.mpType = 'app'
Vue.mixin(share) Vue.mixin(share)
const app = new Vue({ const app = new Vue({
...App ...App
}) })
app.$mount() app.$mount()

@ -25,6 +25,24 @@
{{orderPrice}} {{orderPrice}}
</view> </view>
</view> </view>
<!-- #ifdef MP -->
<view class="width94 line1 mart5 marb5"></view>
<view class="height50 width100 backcorfff" @click="showPopup()">
<view class="width50 flleft fcor333 fontwig6 font16" style="padding-left: 4%;">
优惠抵扣<text class="yhqky">{{OrderPreList.length}}张可用</text>
</view>
<view class="width40 flright fotrt paddtright10 font15 fontwig6 fcor666 alijun"
style="align-items: center;" v-if="deductionPrice == 0">
未使用
<image style="width: 40rpx;height: 40rpx;" src="../../static/img/jt.png"></image>
</view>
<view class="width40 flright fotrt paddtright10 font15 fontwig6 fcoreb5 alijun"
style="align-items: center;" v-else>
-{{deductionPrice}}
<image style="width: 40rpx;height: 40rpx;" src="../../static/img/jt.png"></image>
</view>
</view>
<!-- #endif -->
</view> </view>
<view class="width94 comorder mart10"> <view class="width94 comorder mart10">
@ -85,6 +103,21 @@
</view> </view>
</view> </view>
<wybPopup ref="popup" type="bottom" width="500" scrollY="true" radius="6" :showCloseIcon="true">
<view class="fotct font18 fontwig6 fcor333 mart10 height30">优惠券选择</view>
<view class="width92 height110 tccs mart10" v-for="(items, index) in OrderPreList" :key="items"
@click="radioChanges(items)">
<image mode="widthFix" class="flleft" :src="imageUrl+items.discountImg"></image>
<view class="tcrig">
<view class="yhprice">
<radio color="#0083f5" :checked="items.id == memDiscountId" />
</view>
<view class="font16 fontwig6 fcor333 text1">{{items.discountName}}</view>
<view class="font13 fcor999 mart5">有效期至{{items.useEndTime | timeFormat('yyyy-mm-dd')}}</view>
</view>
</view>
</wybPopup>
<ssPaymentPassword ref="paymentPassword" :mode="1" @submit="submitHandle" /> <ssPaymentPassword ref="paymentPassword" :mode="1" @submit="submitHandle" />
</view> </view>
</template> </template>
@ -98,8 +131,10 @@
orderToGoldPayunion, orderToGoldPayunion,
hltUnionCardPayUnion, hltUnionCardPayUnion,
getHuiLianTongCardBalance, getHuiLianTongCardBalance,
loginByPhone loginByPhone,
getUserOrderPreList
} from '../../Utils/Api.js'; } from '../../Utils/Api.js';
import wybPopup from '../../components/wyb-popup/wyb-popup.vue';
import ssPaymentPassword from '../../components/sanshui-payment-password'; import ssPaymentPassword from '../../components/sanshui-payment-password';
let app = getApp(); let app = getApp();
// #ifdef H5 // #ifdef H5
@ -107,6 +142,7 @@
// #endif // #endif
export default { export default {
components: { components: {
wybPopup,
ssPaymentPassword ssPaymentPassword
}, },
data() { data() {
@ -127,25 +163,28 @@
radioStatus: true, radioStatus: true,
memDiscountId: '', memDiscountId: '',
user: '', user: '',
paytype: '', paytype: 'weixin',
PaymentPassword: '', PaymentPassword: '',
orderId: '', orderId: '',
jumpType: '', jumpType: '',
tongCardPrice: 0, tongCardPrice: 0,
// //
orderPrice: 0, orderPrice: 0,
payPrice: 0, payPrice: 0,
//
saveprice:0,
rechargeContent: '', rechargeContent: '',
rechargeModel: '', rechargeModel: '',
agentKey: '', agentKey: '',
objectId: '' objectId: '',
OrderPreList: []
}; };
}, },
onLoad(options) { onLoad(options) {
this.orderPrice = options.orderPrice; this.orderPrice = options.orderPrice;
this.payPrice = options.payPrice; this.payPrice = options.payPrice;
this.saveprice = options.payPrice;
this.rechargeContent = options.rechargeContent; this.rechargeContent = options.rechargeContent;
this.rechargeModel = options.rechargeModel; this.rechargeModel = options.rechargeModel;
this.agentKey = options.agentKey; this.agentKey = options.agentKey;
@ -153,9 +192,12 @@
}, },
onShow() { onShow() {
let that = this; let that = this;
that.paytype = ''; that.paytype = 'weixin';
that.user = app.globalData.userInfo; that.user = app.globalData.userInfo;
that.findUser(); that.findUser();
// #ifdef MP
that.getUserOrderPreList();
// #endif
}, },
onHide() { 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() { showPopup() {
this.$refs.popup.show(); this.$refs.popup.show();
@ -199,6 +252,40 @@
url: '/pages/login/register' 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) { loginByPhone(PhoneNumber) {
if (PhoneNumber.detail.iv == undefined) { if (PhoneNumber.detail.iv == undefined) {
@ -292,6 +379,10 @@
return; return;
} }
}, },
//
showPopup() {
this.$refs.popup.show();
},
// //
orderToUNionPay(item) { orderToUNionPay(item) {
let that = this; let that = this;
@ -520,7 +611,7 @@
border-radius: 8px; border-radius: 8px;
} }
.jtcs { .j {
width: 40rpx; width: 40rpx;
height: 40rpx; height: 40rpx;
margin-top: 30rpx; margin-top: 30rpx;
@ -540,7 +631,8 @@
width: 100%; width: 100%;
height: 25px; height: 25px;
text-align: right; text-align: right;
margin-top: -20px; margin-top: -30px;
margin-left: 50px;
} }
.price-number { .price-number {
@ -627,6 +719,7 @@
image { image {
width: 170rpx; width: 170rpx;
max-height: 170rpx; max-height: 170rpx;
margin-left: 10px;
} }
} }

Loading…
Cancel
Save