Commit f326e8ca65b036e41c803d7d5097a2337709c3d4

Authored by pengye
1 parent 49c128cf

消费金领取、使用、列表、明细

@@ -66,7 +66,8 @@ @@ -66,7 +66,8 @@
66 "pages/reserve/index_new", 66 "pages/reserve/index_new",
67 "pages/reserve/sellerGift", 67 "pages/reserve/sellerGift",
68 "pages/customer/login", 68 "pages/customer/login",
69 - "pages/me/consumeAmount" 69 + "pages/me/consumeAmount",
  70 + "pages/me/consumeDetails"
70 ], 71 ],
71 "requiredPrivateInfos": [ 72 "requiredPrivateInfos": [
72 "getLocation", 73 "getLocation",
@@ -100,7 +101,9 @@ @@ -100,7 +101,9 @@
100 "pack/vipRecharge", 101 "pack/vipRecharge",
101 "pack/seeRecharge", 102 "pack/seeRecharge",
102 "pack/receiveCoupon", 103 "pack/receiveCoupon",
103 - "pack/buyFreeCoupon" 104 + "pack/buyFreeCoupon",
  105 + "pack/getConsume",
  106 + "pack/paySuccess"
104 ] 107 ]
105 }, 108 },
106 { 109 {
@@ -17,10 +17,23 @@ Page({ @@ -17,10 +17,23 @@ Page({
17 inputValue: '', //输入的金额 17 inputValue: '', //输入的金额
18 canSolt: {}, //当前时间是哪个餐段、节假日 18 canSolt: {}, //当前时间是哪个餐段、节假日
19 totalPrice: '', //送券的总金额 19 totalPrice: '', //送券的总金额
  20 + couponSwitch: false, //本单使用优惠券开关
  21 + consumeSwitch: false, //本单使用消费金开关
  22 + purePhoneNumber: '', //手机号
  23 + coexist: '0', //1可以同时使用券和消费金 0不可同时使用
  24 + ratio: '', //消费金支付占实际消费金额的百分比
  25 + consumeDiscount: '0.00', //消费金抵扣金额
  26 + consumePrice: '', //个人消费金余额
  27 + remainingConsume: '', //抵扣后剩余消费金余额
  28 + totalConsumePrice: 0, //赠送的消费金金额
  29 + noConfiguration: '', //配置消费金 0未配置 1已配置
  30 + returnData: '', //赠送消费金配置
  31 + isReturn: '', //赠送消费金的开关
20 }, 32 },
21 sid: '', //扫码进入带的参数商家id 33 sid: '', //扫码进入带的参数商家id
22 couponModal: '', 34 couponModal: '',
23 giveCouponModal: '', 35 giveCouponModal: '',
  36 + consumeModal: '',
24 myToast:'', 37 myToast:'',
25 /** 38 /**
26 * 生命周期函数--监听页面加载 39 * 生命周期函数--监听页面加载
@@ -28,11 +41,163 @@ Page({ @@ -28,11 +41,163 @@ Page({
28 onLoad(options) { 41 onLoad(options) {
29 this.couponModal = this.selectComponent("#couponModal"); 42 this.couponModal = this.selectComponent("#couponModal");
30 this.giveCouponModal = this.selectComponent("#giveCouponModal"); 43 this.giveCouponModal = this.selectComponent("#giveCouponModal");
  44 + this.consumeModal = this.selectComponent("#consumeModal");
31 if (options.sid) { 45 if (options.sid) {
32 this.sid = options.sid 46 this.sid = options.sid
33 this.getSellerDetailFun(options.sid) 47 this.getSellerDetailFun(options.sid)
34 } 48 }
35 }, 49 },
  50 + // 检测用户是否绑定手机号
  51 + getCheckUserHavePhone() {
  52 + App.Wechat.CheckUserHavePhone({
  53 + openid: getApp().openid,
  54 + }).then((json) => {
  55 + if (json.ret == 200) {
  56 + let data = json.data;
  57 + if (data) {
  58 + this.setData({
  59 + purePhoneNumber: data.phone,
  60 + })
  61 + this.getUserInfo()
  62 + } else {
  63 + this.setData({
  64 + purePhoneNumber: '',
  65 + })
  66 + }
  67 + }
  68 + })
  69 + },
  70 + // 获取用户在商家&所有消费金
  71 + getUserInfo() {
  72 + App.Activity.GetConsumeBySeller({
  73 + openid: getApp().openid,
  74 + sellerid: this.sid,
  75 + }).then((json) => {
  76 + if (json.ret == 200) {
  77 + let data = json.data;
  78 + if (data && data.length > 0) {
  79 + let obj = data[0]
  80 + console.log('获取用户在商家的消费金----', obj);
  81 + this.setData({
  82 + consumePrice: obj.balance ? (obj.balance * 1).toFixed(2) : '0.00',
  83 + remainingConsume: obj.balance ? (obj.balance * 1).toFixed(2) : '0.00',
  84 + consumeDiscount: '0.00', //消费金抵扣金额
  85 + })
  86 + } else {
  87 + this.setData({
  88 + consumePrice: '0.00',
  89 + remainingConsume: '0.00',
  90 + consumeDiscount: '0.00', //消费金抵扣金额
  91 + })
  92 + }
  93 + }
  94 + })
  95 + },
  96 + // 获取商家消费金规则
  97 + getConsumeConfigFun() {
  98 + App.Activity.GetConsumeConfig({
  99 + sellerid: this.sid,
  100 + }).then(res => {
  101 + if (res && res.data) {
  102 + let data = res.data;
  103 + let together = util.determine(data.together_json);
  104 + let returnData = util.determine(data.return_json);
  105 + returnData.ladder_data = returnData.ladder_data ? util.determine(returnData.ladder_data) : {};
  106 + console.log('111配置---',together);
  107 + console.log('222顾客支付后返消费金---',returnData);
  108 + this.setData({
  109 + noConfiguration: '1', //配置为1 未配置为0
  110 + coexist: together.is_coexist,
  111 + ratio: together.ratio_data ? together.ratio_data : '100',
  112 + couponSwitch: true,
  113 + consumeSwitch: together.is_coexist == '1' ? true : false,
  114 + returnData,
  115 + isReturn: data.is_return,
  116 + })
  117 + } else {
  118 + this.setData({
  119 + noConfiguration: '0', //配置为1 未配置为0
  120 + couponSwitch: true,
  121 + consumeSwitch: false,
  122 + returnData: null,
  123 + isReturn: '0',
  124 + })
  125 + }
  126 + })
  127 + },
  128 + // 使用券或者消费金的开关
  129 + switchChange(event) {
  130 + let type = event.currentTarget.dataset.type;
  131 + if (type == '1') {
  132 + this.setData({
  133 + couponSwitch: event.detail.value,
  134 + })
  135 + if (this.data.coexist == '0' && event.detail.value) {
  136 + this.setData({
  137 + consumeSwitch: false,
  138 + })
  139 + }
  140 + }
  141 + if (type == '2') {
  142 + this.setData({
  143 + consumeSwitch: event.detail.value,
  144 + })
  145 + if (this.data.coexist == '0' && event.detail.value) {
  146 + this.setData({
  147 + couponSwitch: false,
  148 + })
  149 + }
  150 + }
  151 + // 开或者关闭使用优惠券
  152 + if (this.data.couponSwitch) {
  153 + this.colationData()
  154 + }
  155 + if (!this.data.couponSwitch) {
  156 + this.getCoupon()
  157 + let val = parseFloat(this.data.inputValue);
  158 + let discountPrice = 0;
  159 + let actualPrice = (val - this.data.consumeDiscount - discountPrice).toFixed(2)
  160 + this.setData({
  161 + discountPrice: 0,
  162 + actualPrice: actualPrice > 0 ? actualPrice : '0.01'
  163 + })
  164 + }
  165 + // 开或者关闭使用消费金
  166 + if (this.data.consumeSwitch) {
  167 + let val = parseFloat(this.data.inputValue);
  168 + if (!val) return
  169 + let consumeDiscount = this.calculateConsumeGold(val);
  170 + let discountPrice = this.data.couponSwitch ? this.data.discountPrice : 0
  171 + let actualPrice = (val - consumeDiscount - discountPrice).toFixed(2)
  172 + let remainingConsume = (this.data.consumePrice * 1 - consumeDiscount).toFixed(2)
  173 + this.setData({
  174 + consumeDiscount,
  175 + actualPrice: actualPrice > 0 ? actualPrice : '0.01',
  176 + remainingConsume: remainingConsume
  177 + })
  178 + }
  179 + if (!this.data.consumeSwitch) {
  180 + let val = parseFloat(this.data.inputValue);
  181 + if (!val) return
  182 + let discountPrice = this.data.couponSwitch ? this.data.discountPrice : 0
  183 + let consumeDiscount = this.data.consumeSwitch ? this.data.consumeDiscount : 0
  184 + let actualPrice = (val - consumeDiscount - discountPrice).toFixed(2)
  185 + this.setData({
  186 + consumeDiscount: '0.00',
  187 + actualPrice: actualPrice > 0 ? actualPrice : '0.01',
  188 + remainingConsume: this.data.consumePrice,
  189 + })
  190 + }
  191 + },
  192 + // 按比例计算出的最大可用消费金
  193 + calculateConsumeGold(val) {
  194 + let ratio = this.data.ratio;
  195 + let consumePrice = parseFloat(this.data.consumePrice);
  196 + const maxByRatio = val * (ratio / 100).toFixed(2);
  197 + let availableConsumeGold = Math.min(val, maxByRatio).toFixed(2) * 1;
  198 + if (availableConsumeGold > consumePrice) availableConsumeGold = consumePrice
  199 + return availableConsumeGold;
  200 + },
36 // 打开优惠券弹框 201 // 打开优惠券弹框
37 showCouponModal() { 202 showCouponModal() {
38 this.couponModal.showModal() 203 this.couponModal.showModal()
@@ -41,14 +206,30 @@ Page({ @@ -41,14 +206,30 @@ Page({
41 closeCouponModal() { 206 closeCouponModal() {
42 this.couponModal.closeModal() 207 this.couponModal.closeModal()
43 }, 208 },
44 - // 打开优惠券弹框 209 + // 打开送券送消费金弹框
45 showgiveCouponModal() { 210 showgiveCouponModal() {
46 this.giveCouponModal.showModal() 211 this.giveCouponModal.showModal()
47 }, 212 },
  213 + // 打开消费金弹框
  214 + showConsumeModal() {
  215 + this.consumeModal.showModal()
  216 + },
  217 + // 关闭消费金弹框
  218 + closeConsumeModal() {
  219 + this.consumeModal.closeModal()
  220 + },
48 // 关闭优惠券弹框 221 // 关闭优惠券弹框
49 closegiveCouponModal() { 222 closegiveCouponModal() {
50 this.giveCouponModal.closeModal() 223 this.giveCouponModal.closeModal()
51 - wx.exitMiniProgram({}) 224 + this.getUserInfo()
  225 + },
  226 + // 跳转登录页
  227 + gotoLogin(event) {
  228 + wx.navigateTo({
  229 + url: util.http_build_query({
  230 + types: event.currentTarget.dataset.types
  231 + }, '/pages/customer/login')
  232 + })
52 }, 233 },
53 // 获取店铺名称 234 // 获取店铺名称
54 getSellerDetailFun(sid) { 235 getSellerDetailFun(sid) {
@@ -88,9 +269,9 @@ Page({ @@ -88,9 +269,9 @@ Page({
88 if (fullData.rule == '1') { 269 if (fullData.rule == '1') {
89 const price = parseFloat(fullData.price) 270 const price = parseFloat(fullData.price)
90 const amount = parseInt(priceSum / price) 271 const amount = parseInt(priceSum / price)
91 - if (coupons.length > 0) this.getCouponFun(coupons, '1', amount,orderid) 272 + if (coupons.length > 0 && amount > 0) this.getCouponFun(coupons, '1', amount,orderid)
92 } else { 273 } else {
93 - if (coupons.length > 0) this.getCouponFun(coupons, '1', 1,orderid) 274 + if (coupons.length > 0 && amount > 0) this.getCouponFun(coupons, '1', 1,orderid)
94 } 275 }
95 } 276 }
96 } 277 }
@@ -110,7 +291,6 @@ Page({ @@ -110,7 +291,6 @@ Page({
110 } 291 }
111 } 292 }
112 } 293 }
113 -  
114 } 294 }
115 }) 295 })
116 }, 296 },
@@ -160,7 +340,6 @@ Page({ @@ -160,7 +340,6 @@ Page({
160 this.setData({ 340 this.setData({
161 totalPrice, 341 totalPrice,
162 }) 342 })
163 - this.showgiveCouponModal()  
164 this.setcouponFun(ids,orderid) 343 this.setcouponFun(ids,orderid)
165 } 344 }
166 } 345 }
@@ -340,9 +519,24 @@ Page({ @@ -340,9 +519,24 @@ Page({
340 this.setData({ 519 this.setData({
341 discountPrice: '', 520 discountPrice: '',
342 actualPrice: '', 521 actualPrice: '',
  522 + consumeDiscount: '',
  523 + remainingConsume: this.data.consumePrice
343 }) 524 })
344 - }else{  
345 - this.colationData() 525 + } else {
  526 + if (this.data.couponSwitch) {
  527 + this.colationData()
  528 + }
  529 + if (this.data.consumeSwitch && !this.data.couponSwitch) {
  530 + let val = parseFloat(this.data.inputValue);
  531 + let consumeDiscount = this.calculateConsumeGold(val);
  532 + let actualPrice = (val - consumeDiscount - this.data.discountPrice).toFixed(2)
  533 + let remainingConsume = (this.data.consumePrice * 1 - consumeDiscount).toFixed(2)
  534 + this.setData({
  535 + consumeDiscount,
  536 + actualPrice: actualPrice > 0 ? actualPrice : '0.01',
  537 + remainingConsume: remainingConsume
  538 + })
  539 + }
346 } 540 }
347 }, 541 },
348 // 点确认选择 542 // 点确认选择
@@ -358,7 +552,7 @@ Page({ @@ -358,7 +552,7 @@ Page({
358 }) 552 })
359 console.log('优惠金额----', price); 553 console.log('优惠金额----', price);
360 let val = parseFloat(this.data.inputValue); 554 let val = parseFloat(this.data.inputValue);
361 - let actualPrice = (val - price).toFixed(2) 555 + let actualPrice = (val - price - this.data.consumeDiscount).toFixed(2)
362 price = price.toFixed(2) 556 price = price.toFixed(2)
363 this.setData({ 557 this.setData({
364 discountPrice: price, 558 discountPrice: price,
@@ -375,6 +569,19 @@ Page({ @@ -375,6 +569,19 @@ Page({
375 console.log('处理过后的券数据', list); 569 console.log('处理过后的券数据', list);
376 list.sort((a, b) => b.canCheck - a.canCheck); 570 list.sort((a, b) => b.canCheck - a.canCheck);
377 list.sort((a, b) => b.showCpupon - a.showCpupon); 571 list.sort((a, b) => b.showCpupon - a.showCpupon);
  572 + if (this.data.consumeSwitch) {
  573 + let amount = parseFloat(this.data.inputValue);
  574 + let num = (amount - this.data.discountPrice).toFixed(2);
  575 + let val = parseFloat(num);
  576 + let consumeDiscount = this.calculateConsumeGold(val);
  577 + let actualPrice = (amount - consumeDiscount - this.data.discountPrice).toFixed(2)
  578 + let remainingConsume = (this.data.consumePrice * 1 - consumeDiscount).toFixed(2)
  579 + this.setData({
  580 + consumeDiscount,
  581 + actualPrice: actualPrice > 0 ? actualPrice : '0.01',
  582 + remainingConsume: remainingConsume
  583 + })
  584 + }
378 this.setData({ 585 this.setData({
379 couponArr: list, 586 couponArr: list,
380 finalList: obj.finalList 587 finalList: obj.finalList
@@ -389,11 +596,18 @@ Page({ @@ -389,11 +596,18 @@ Page({
389 } 596 }
390 let str = this.data.finalList.map(item => item.activity_id).join(','); 597 let str = this.data.finalList.map(item => item.activity_id).join(',');
391 console.log('核销所勾选的券传参', str); 598 console.log('核销所勾选的券传参', str);
392 - App.PayOnline.CombineTransactionsByNewActivity({ 599 + let params = {
393 sellerid: this.data.seller.sid, 600 sellerid: this.data.seller.sid,
394 price: actualPrice, 601 price: actualPrice,
395 - activity_id:str,  
396 - }).then(res => { 602 + }
  603 + if (this.data.consumeDiscount) {
  604 + params.consume = this.data.consumeDiscount;
  605 + params.phone = this.data.purePhoneNumber;
  606 + }
  607 + if (str) {
  608 + params.activity_id = str;
  609 + }
  610 + App.PayOnline.CombineTransactionsByNewActivity(params).then(res => {
397 console.log('付款信息', res.data); 611 console.log('付款信息', res.data);
398 if (res.ret != '200') { 612 if (res.ret != '200') {
399 wx.showToast({ 613 wx.showToast({
@@ -412,28 +626,106 @@ Page({ @@ -412,28 +626,106 @@ Page({
412 success(ress) { 626 success(ress) {
413 if (ress.errMsg == 'requestPayment:ok') { 627 if (ress.errMsg == 'requestPayment:ok') {
414 that.giftCouponsFun(actualPrice,res.data.orderid) //送券 628 that.giftCouponsFun(actualPrice,res.data.orderid) //送券
415 - that.setData({  
416 - inputValue: '',  
417 - finalList: [],  
418 - couponArr: [],  
419 - discountPrice: '0.00',  
420 - actualPrice: '',  
421 - })  
422 - that.getCoupon() 629 + that.giftConsumeFun(actualPrice, res.data.orderid) //送消费金
  630 + setTimeout(() => {
  631 + console.log('送券金额----', that.data.totalPrice);
  632 + console.log('送消费金----', that.data.totalConsumePrice);
  633 + if (that.data.totalPrice > 0 || that.data.totalConsumePrice > 0) {
  634 + wx.reLaunch({
  635 + url: util.http_build_query({
  636 + totalPrice: that.data.totalPrice,
  637 + totalConsumePrice: that.data.totalConsumePrice,
  638 + }, '/pack-activity/pack/paySuccess')
  639 + })
  640 + }
  641 + }, 1000);
423 console.log('支付成功', ress); 642 console.log('支付成功', ress);
424 return 643 return
425 } 644 }
426 - console.log('支付失败', ress); 645 + that.payFail()
  646 + console.log('支付失败11', ress);
427 return that.myToast.showToast('支付失败,请重新下单', 2000) 647 return that.myToast.showToast('支付失败,请重新下单', 2000)
428 }, 648 },
429 fail(ress) { 649 fail(ress) {
430 - console.log('支付失败', ress); 650 + that.payFail()
  651 + console.log('支付失败22', ress);
431 return that.myToast.showToast('支付失败,请重新下单', 2000) 652 return that.myToast.showToast('支付失败,请重新下单', 2000)
432 }, 653 },
433 }) 654 })
434 } 655 }
435 }) 656 })
436 },3000), 657 },3000),
  658 + payFail() {
  659 + this.setData({
  660 + inputValue: '',
  661 + finalList: [],
  662 + couponArr: [],
  663 + discountPrice: '0.00',
  664 + actualPrice: '',
  665 + consumeDiscount: '0.00', //消费金抵扣金额
  666 + })
  667 + this.getCoupon()
  668 + this.getUserInfo()
  669 + },
  670 + giftConsumeFun(priceSum, orderid) {
  671 + let isReturn = this.data.isReturn;
  672 + let data = this.data.returnData;
  673 + const now = Math.floor(Date.now() / 1000);
  674 + let totalConsumePrice = 0;
  675 + if (isReturn == '1' && data && now >= parseInt(data.stime) && now <= parseInt(data.etime)) {
  676 + priceSum = parseFloat(priceSum)
  677 + // 按百分比 is_ratio 1按比例 0按阶梯 ladder_data
  678 + if (data.is_ratio == '1' && data.ratio_data) {
  679 + totalConsumePrice = priceSum * (data.ratio_data / 100).toFixed(2);
  680 + console.log('送消费金百分比----', totalConsumePrice);
  681 + }
  682 + // 阶梯
  683 + if (data.is_ratio == '0' && data.ladder_data) {
  684 + totalConsumePrice = this.calculateGiftAmount(priceSum, data.ladder_data)
  685 + console.log('送消费金阶梯----', totalConsumePrice);
  686 + }
  687 + if (totalConsumePrice > 0) this.getConsumeFun(totalConsumePrice)
  688 + this.setData({
  689 + totalConsumePrice: (totalConsumePrice * 1).toFixed(2)
  690 + })
  691 + }
  692 + },
  693 + // 为用户增加消费金
  694 + getConsumeFun(amount) {
  695 + App.Activity.SetConsumeByOpenid({
  696 + phone: this.data.purePhoneNumber,
  697 + openid: getApp().openid,
  698 + amount,
  699 + sellerid: this.data.seller.sid
  700 + }).then(res => {
  701 + if (res.data == '0') {
  702 + wx.showToast({
  703 + title: '消费金领取失败!',
  704 + duration: 1000,
  705 + icon: 'none',
  706 + mask: true
  707 + });
  708 + }
  709 + })
  710 + },
  711 + calculateGiftAmount(priceSum, ladder_data) {
  712 + if (!ladder_data || ladder_data.length === 0) {
  713 + return 0; // 没有阶梯数据,返回0
  714 + }
  715 + // 将阶梯数据按 give_price 从大到小排序,确保匹配最高阶梯
  716 + const sortedLadder = [...ladder_data].sort((a, b) =>
  717 + parseFloat(b.give_price) - parseFloat(a.give_price)
  718 + );
  719 + // 遍历排序后的阶梯,找到第一个满足条件的
  720 + for (let i = 0; i < sortedLadder.length; i++) {
  721 + const ladder = sortedLadder[i];
  722 + const threshold = parseFloat(ladder.give_price);
  723 + if (priceSum >= threshold) {
  724 + return ladder.back_price;
  725 + }
  726 + }
  727 + return 0; // 不满足任何阶梯条件
  728 + },
437 // 核销所勾选的券 729 // 核销所勾选的券
438 writeOff() { 730 writeOff() {
439 console.log('勾选的券', this.data.finalList); 731 console.log('勾选的券', this.data.finalList);
@@ -519,8 +811,9 @@ Page({ @@ -519,8 +811,9 @@ Page({
519 // 最优惠的消费券组合(消费要求为无门槛 或者 满足优惠券使用金额 && 勾选最优的、最早到期的) 811 // 最优惠的消费券组合(消费要求为无门槛 或者 满足优惠券使用金额 && 勾选最优的、最早到期的)
520 findBestCoupons(arr) { 812 findBestCoupons(arr) {
521 console.log('勾选最优的之前', arr); 813 console.log('勾选最优的之前', arr);
  814 + let consumeDiscount = this.data.consumeDiscount;
522 let inputValue = this.data.inputValue; 815 let inputValue = this.data.inputValue;
523 - const amount = parseFloat(inputValue); 816 + const amount = parseFloat(inputValue - consumeDiscount);
524 const validCoupons = arr.filter(coupon => (coupon.isOk == '1' && parseFloat(coupon.desc) <= amount) && amount>=parseFloat(coupon.price)); 817 const validCoupons = arr.filter(coupon => (coupon.isOk == '1' && parseFloat(coupon.desc) <= amount) && amount>=parseFloat(coupon.price));
525 // 排序后,优先选择最大优惠的券 818 // 排序后,优先选择最大优惠的券
526 validCoupons.sort((a, b) => parseFloat(b.price) - parseFloat(a.price)); 819 validCoupons.sort((a, b) => parseFloat(b.price) - parseFloat(a.price));
@@ -642,7 +935,6 @@ Page({ @@ -642,7 +935,6 @@ Page({
642 }, 935 },
643 // 计算免费券有效期的起始、结束日期 936 // 计算免费券有效期的起始、结束日期
644 setTimeRange(cdate, startOffset, endOffset) { 937 setTimeRange(cdate, startOffset, endOffset) {
645 - console.log(cdate, startOffset, endOffset);  
646 const startDate = new Date((cdate + startOffset * 86400) * 1000); 938 const startDate = new Date((cdate + startOffset * 86400) * 1000);
647 startDate.setHours(0, 0, 0, 0); 939 startDate.setHours(0, 0, 0, 0);
648 let useStime = startDate.getTime() / 1000 940 let useStime = startDate.getTime() / 1000
@@ -887,6 +1179,12 @@ Page({ @@ -887,6 +1179,12 @@ Page({
887 url: '/pages/me/coupon_news' 1179 url: '/pages/me/coupon_news'
888 }) 1180 })
889 }, 1181 },
  1182 + // 跳转到我的消费金列表
  1183 + gotoConsumeList() {
  1184 + wx.reLaunch({
  1185 + url: '/pages/me/consumeAmount'
  1186 + })
  1187 + },
890 /** 1188 /**
891 * 生命周期函数--监听页面初次渲染完成 1189 * 生命周期函数--监听页面初次渲染完成
892 */ 1190 */
@@ -897,7 +1195,8 @@ Page({ @@ -897,7 +1195,8 @@ Page({
897 * 生命周期函数--监听页面显示 1195 * 生命周期函数--监听页面显示
898 */ 1196 */
899 onShow() { 1197 onShow() {
900 - 1198 + this.getCheckUserHavePhone()
  1199 + this.getConsumeConfigFun()
901 }, 1200 },
902 1201
903 /** 1202 /**
1 <!--pack-activity/pack/buyFreeCoupon.wxml--> 1 <!--pack-activity/pack/buyFreeCoupon.wxml-->
2 -<nav backgroundColor="#f6f6fd">向商家付款</nav> 2 +<nav hasHome>向商家付款</nav>
3 <view class="sellInfo"> 3 <view class="sellInfo">
4 <image src="{{seller.seller_image}}" mode="aspectFill" /> 4 <image src="{{seller.seller_image}}" mode="aspectFill" />
5 <view class="font32r">{{seller.sellername}}</view> 5 <view class="font32r">{{seller.sellername}}</view>
6 </view> 6 </view>
7 <view class="payBox"> 7 <view class="payBox">
8 - <view class="font32r">付款金额</view> 8 + <view class="priceTitle font32r">付款金额</view>
9 <view class="payView"> 9 <view class="payView">
10 <text>¥</text> 10 <text>¥</text>
11 <input type="digit" value="{{inputValue}}" bindchange="bindKeyInput" /> 11 <input type="digit" value="{{inputValue}}" bindchange="bindKeyInput" />
12 </view> 12 </view>
13 <view bindtap="showCouponModal" class="couponsBox {{available == '1' ? 'colorOrange':'colorNine'}}"> 13 <view bindtap="showCouponModal" class="couponsBox {{available == '1' ? 'colorOrange':'colorNine'}}">
14 - <view class="couponLeft">优惠金额</view> 14 + <view class="couponLeft">选择优惠券</view>
15 <view class="couponRight"> 15 <view class="couponRight">
16 - <text wx:if="{{discountPrice && discountPrice!='0.00'}}">{{discountPrice}}</text> 16 + <text wx:if="{{discountPrice && discountPrice!='0.00' && couponSwitch}}">-{{discountPrice}}</text>
  17 + <text class="noUse font28r" wx:if="{{couponArr.length == '0'}}">暂无可用</text>
  18 + <text class="noUse font28r" wx:elif="{{coexist == '0' && !couponSwitch}}">不可用</text>
17 <view class="more" style="margin-top: 6rpx;"></view> 19 <view class="more" style="margin-top: 6rpx;"></view>
18 </view> 20 </view>
19 </view> 21 </view>
  22 + <block wx:if="{{purePhoneNumber}}">
  23 + <view bindtap="showConsumeModal" class="couponsBox colorOrange">
  24 + <view class="couponLeft">使用消费金抵扣</view>
  25 + <view class="couponRight">
  26 + <text wx:if="{{consumeDiscount && consumeDiscount!='0.00' && consumeSwitch}}">-{{consumeDiscount}}</text>
  27 + <text class="noUse font28r" wx:if="{{consumePrice == '0.00'}}">暂无可用</text>
  28 + <text class="noUse font28r" wx:elif="{{coexist == '0' && !consumeSwitch}}">不可用</text>
  29 + <view class="more" style="margin-top: 6rpx;"></view>
  30 + </view>
  31 + </view>
  32 + </block>
  33 + <block wx:else>
  34 + <view bindtap="gotoLogin" data-types="3" class="couponsBox colorOrange">
  35 + <view class="couponLeft">使用消费金抵扣</view>
  36 + <view class="couponRight">
  37 + <view class="more" style="margin-top: 6rpx;"></view>
  38 + </view>
  39 + </view>
  40 + </block>
20 <view class="couponsWrap"> 41 <view class="couponsWrap">
21 <view class="couponLeft">抵扣后</view> 42 <view class="couponLeft">抵扣后</view>
22 <view class="couponRight" wx:if="{{actualPrice && inputValue}}">¥{{actualPrice}}</view> 43 <view class="couponRight" wx:if="{{actualPrice && inputValue}}">¥{{actualPrice}}</view>
23 </view> 44 </view>
24 - <view class="payBtn font32r" bindtap="confirmPayment">付款</view>  
25 </view> 45 </view>
26 -<toast id="myToast"></toast> 46 +<view class="payBtn font32r" bindtap="confirmPayment">付款</view>
  47 +<toast id="myToast"></toast>
  48 +<!-- 使用优惠券弹框 -->
27 <my-modal id="couponModal" fadeStyle="slideUp" height="{{couponArr.length > '3' ? '80%' : '60%'}}"> 49 <my-modal id="couponModal" fadeStyle="slideUp" height="{{couponArr.length > '3' ? '80%' : '60%'}}">
28 <view slot="modalName" class="titleModal"> 50 <view slot="modalName" class="titleModal">
29 - <view class="couponTotalText">所有优惠券</view>  
30 - <view bindtap="checkCertificate" class="btn font32r">确认选择</view> 51 + <image bind:tap="closeCouponModal" src="https://qn.colorcun.com/closeImg1.png" mode="aspectFit" />
  52 + <view class="couponTotalText font28r">所有优惠券</view>
  53 + <view bindtap="checkCertificate" class="btn font32r">确认</view>
31 </view> 54 </view>
32 <view slot="modalContent"> 55 <view slot="modalContent">
  56 + <view class="infoBox">
  57 + <view class="infoTop">
  58 + <view class="info font28r">本单使用优惠券</view>
  59 + <switch checked="{{couponSwitch}}" bindchange="switchChange" data-type="1" color="#09BB07" class="infoSwitch" />
  60 + </view>
  61 + <view class="infoBottom font24r">注意:消费金与优惠券{{coexist == '1'?'可':'不可'}}同时使用</view>
  62 + </view>
33 <scroll-view class="couponBox" scroll-y="true"> 63 <scroll-view class="couponBox" scroll-y="true">
34 <checkbox-group bindchange="checkboxChange"> 64 <checkbox-group bindchange="checkboxChange">
35 <view wx:for="{{couponArr}}" data-activityId="{{item.activity_id}}" class="couponItems {{item.showCpupon == '0' ? 'couponNo' : ''}}"> 65 <view wx:for="{{couponArr}}" data-activityId="{{item.activity_id}}" class="couponItems {{item.showCpupon == '0' ? 'couponNo' : ''}}">
@@ -65,17 +95,51 @@ @@ -65,17 +95,51 @@
65 </scroll-view> 95 </scroll-view>
66 </view> 96 </view>
67 </my-modal> 97 </my-modal>
  98 +<!-- 使用消费金弹框 -->
  99 +<my-modal id="consumeModal" fadeStyle="slideUp">
  100 + <view slot="modalName" class="titleModal">
  101 + <image bind:tap="closeConsumeModal" src="https://qn.colorcun.com/closeImg1.png" mode="aspectFit" />
  102 + <view class="couponTotalText font28r">消费金抵扣</view>
  103 + <view bindtap="closeConsumeModal" class="btn font32r">确认</view>
  104 + </view>
  105 + <view slot="modalContent">
  106 + <view class="infoBox1">
  107 + <view class="infoTop">
  108 + <view class="info font28r">本单使用消费金抵扣</view>
  109 + <switch disabled="{{noConfiguration == '0'}}" checked="{{consumeSwitch}}" bindchange="switchChange" data-type="2" color="#09BB07" class="infoSwitch" />
  110 + </view>
  111 + <view class="infoBottom font24r">注意:消费金与优惠券{{coexist == '1'?'可':'不可'}}同时使用</view>
  112 + </view>
  113 + <view class="infoTop1">
  114 + <view class="info font28r">本店消费金余额</view>
  115 + <view class="info font28r">¥{{consumePrice}}</view>
  116 + </view>
  117 + <view class="infoTop1">
  118 + <view class="info font28r">本单可抵扣</view>
  119 + <view class="info font28r">¥{{consumeDiscount?consumeDiscount:'0.00'}}</view>
  120 + </view>
  121 + <view class="infoTop1">
  122 + <view class="info font28r">抵扣后剩余</view>
  123 + <view class="info font28r">¥{{remainingConsume?remainingConsume:consumePrice}}</view>
  124 + </view>
  125 + </view>
  126 +</my-modal>
  127 +<!-- 赠送优惠券/消费金弹框 -->
68 <my-modal id="giveCouponModal" fadeStyle="slideUp" height="240px"> 128 <my-modal id="giveCouponModal" fadeStyle="slideUp" height="240px">
69 <view slot="modalName" class="titleModal "> 129 <view slot="modalName" class="titleModal ">
70 <image bindtap="closegiveCouponModal" class="closeImg" src="https://qn.colorcun.com/closeOutline.png" mode=""/> 130 <image bindtap="closegiveCouponModal" class="closeImg" src="https://qn.colorcun.com/closeOutline.png" mode=""/>
71 <view class="nameInfo">{{seller.sellername}}</view> 131 <view class="nameInfo">{{seller.sellername}}</view>
72 - <view class="couponTotal">赠送给您<text>{{totalPrice}}元</text>代金券</view> 132 + <view class="couponTotal" wx:if="{{totalPrice && totalPrice>0}}">赠送给您<text>{{totalPrice}}元</text>代金券</view>
  133 + <view class="couponTotal" wx:if="{{totalConsumePrice && totalConsumePrice>0}}">为您返还消费金¥{{totalConsumePrice}}</view>
73 </view> 134 </view>
74 <view slot="modalContent"> 135 <view slot="modalContent">
75 <view class="couponInfo font24r">您到店扫码支付即可自动使用</view> 136 <view class="couponInfo font24r">您到店扫码支付即可自动使用</view>
76 - <subscribe ids="{{[2]}}" bindtap="closegiveCouponModal">  
77 - <view class="couponBtn font36r">我知道了</view> 137 + <subscribe ids="{{[2]}}">
  138 + <view wx:if="{{totalPrice && totalPrice>0 && totalConsumePrice && totalConsumePrice>0}}" class="btnBoxs">
  139 + <view bindtap="gotoConsumeList" class="couponBtn1 font36r">查看消费金</view>
  140 + <view bindtap="certificate" class="couponBtn1 font36r">查看优惠券</view>
  141 + </view>
  142 + <view wx:else bindtap="closegiveCouponModal" class="couponBtn font36r">开心收下</view>
78 </subscribe> 143 </subscribe>
79 - <view class="couponText font24r" bindtap="certificate">点击查看详情</view>  
80 </view> 144 </view>
81 </my-modal> 145 </my-modal>
@@ -29,12 +29,23 @@ @@ -29,12 +29,23 @@
29 29
30 .payView text { 30 .payView text {
31 color: #000; 31 color: #000;
  32 + font-family: PingFang SC;
  33 + font-weight: 500;
  34 + font-size: 64rpx;
32 } 35 }
33 36
34 .payView input { 37 .payView input {
35 - color: #515151; 38 + color: #000;
36 height: 82rpx; 39 height: 82rpx;
37 line-height: 82rpx; 40 line-height: 82rpx;
  41 + font-weight: 600;
  42 + font-size: 64rpx;
  43 +}
  44 +
  45 +.priceTitle {
  46 + color: #000000;
  47 + font-family: PingFang SC;
  48 + font-weight: 500;
38 } 49 }
39 50
40 .couponsBox { 51 .couponsBox {
@@ -42,7 +53,7 @@ @@ -42,7 +53,7 @@
42 align-items: center; 53 align-items: center;
43 justify-content: space-between; 54 justify-content: space-between;
44 color: #999; 55 color: #999;
45 - margin: 26rpx 0; 56 + margin: 24rpx 0;
46 } 57 }
47 58
48 .couponsBox .more { 59 .couponsBox .more {
@@ -61,8 +72,8 @@ @@ -61,8 +72,8 @@
61 72
62 .colorOrange .more { 73 .colorOrange .more {
63 background-image: url('https://qn.colorcun.com/chevronRight.png'); 74 background-image: url('https://qn.colorcun.com/chevronRight.png');
64 - width: 48rpx;  
65 - height: 48rpx; 75 + width: 36rpx;
  76 + height: 32rpx;
66 margin-left: 0; 77 margin-left: 0;
67 } 78 }
68 79
@@ -79,14 +90,19 @@ @@ -79,14 +90,19 @@
79 } 90 }
80 91
81 .payBtn { 92 .payBtn {
82 - background: #05C160;  
83 - width: 70%;  
84 - border-radius: 10rpx;  
85 - margin: 0 auto; 93 + background: #09BB07;
  94 + width: 90%;
86 color: #fff; 95 color: #fff;
87 text-align: center; 96 text-align: center;
88 - padding: 20rpx 10rpx;  
89 - margin-top: 40rpx; 97 + padding: 20rpx 0;
  98 + position: absolute;
  99 + bottom: 10%;
  100 + border-radius: 198rpx;
  101 + left: 5%;
  102 +}
  103 +
  104 +.mymodal .mymodal-title {
  105 + padding: 0 !important;
90 } 106 }
91 107
92 .titleModal { 108 .titleModal {
@@ -94,21 +110,32 @@ @@ -94,21 +110,32 @@
94 display: flex; 110 display: flex;
95 align-items: center; 111 align-items: center;
96 justify-content: space-between; 112 justify-content: space-between;
97 - border-bottom: 2rpx solid #dbdbdb; 113 + padding: 0 32rpx;
  114 +}
  115 +
  116 +.couponTotalText {
  117 + color: #000000;
  118 + font-family: PingFang SC;
  119 + font-weight: 400;
  120 +}
  121 +
  122 +.titleModal image {
  123 + width: 60rpx;
  124 + height: 60rpx;
98 } 125 }
99 126
100 .btn { 127 .btn {
101 - background: #05C160; 128 + background: #09BB07;
102 border-radius: 10rpx; 129 border-radius: 10rpx;
103 color: #fff; 130 color: #fff;
104 text-align: center; 131 text-align: center;
105 - padding: 10rpx; 132 + padding: 10rpx 42rpx;
106 height: 48rpx; 133 height: 48rpx;
107 line-height: 48rpx; 134 line-height: 48rpx;
108 } 135 }
109 136
110 .couponItems { 137 .couponItems {
111 - border: 2rpx solid #05c160; 138 + border: 2rpx solid #09bb07;
112 margin-bottom: 16rpx; 139 margin-bottom: 16rpx;
113 border-radius: 20rpx; 140 border-radius: 20rpx;
114 display: flex; 141 display: flex;
@@ -121,7 +148,7 @@ @@ -121,7 +148,7 @@
121 align-items: center; 148 align-items: center;
122 flex-direction: column; 149 flex-direction: column;
123 justify-content: center; 150 justify-content: center;
124 - border-right: 2rpx dashed #05C160; 151 + border-right: 2rpx dashed #09BB07;
125 padding-right: 14rpx; 152 padding-right: 14rpx;
126 margin-right: 14rpx; 153 margin-right: 14rpx;
127 } 154 }
@@ -135,8 +162,8 @@ @@ -135,8 +162,8 @@
135 } 162 }
136 163
137 .priceText { 164 .priceText {
138 - color: #F6231B;  
139 - font-weight: 500; 165 + color: #FD4D59;
  166 + font-weight: 600;
140 font-size: 56rpx; 167 font-size: 56rpx;
141 margin-top: 6rpx; 168 margin-top: 6rpx;
142 display: flex; 169 display: flex;
@@ -146,8 +173,9 @@ @@ -146,8 +173,9 @@
146 } 173 }
147 174
148 .icons { 175 .icons {
149 - color: #F6231B; 176 + color: #FD4D59;
150 font-size: 20rpx; 177 font-size: 20rpx;
  178 + font-weight: 500;
151 font-family: PingFang SC; 179 font-family: PingFang SC;
152 } 180 }
153 181
@@ -170,7 +198,7 @@ @@ -170,7 +198,7 @@
170 } 198 }
171 199
172 .discountText1 { 200 .discountText1 {
173 - color: #C36607; 201 + color: #fe6d03;
174 font-family: PingFang SC; 202 font-family: PingFang SC;
175 font-weight: 500; 203 font-weight: 500;
176 margin: 0 20rpx; 204 margin: 0 20rpx;
@@ -232,6 +260,11 @@ checkbox { @@ -232,6 +260,11 @@ checkbox {
232 margin-right: 20rpx; 260 margin-right: 20rpx;
233 } 261 }
234 262
  263 +checkbox[checked] .wx-checkbox-input {
  264 + border-color: #09BB07 !important;
  265 + border-width: 4rpx !important;
  266 +}
  267 +
235 radio::before, 268 radio::before,
236 checkbox::before { 269 checkbox::before {
237 height: 40rpx; 270 height: 40rpx;
@@ -284,20 +317,20 @@ checkbox::before { @@ -284,20 +317,20 @@ checkbox::before {
284 font-size: 52rpx; 317 font-size: 52rpx;
285 line-height: 56rpx; 318 line-height: 56rpx;
286 color: #fff; 319 color: #fff;
287 - margin-bottom: 150rpx; 320 + margin-bottom: 100rpx;
288 padding-top: 60rpx; 321 padding-top: 60rpx;
289 } 322 }
290 323
291 .couponTotal { 324 .couponTotal {
292 - color: #dfdfdf; 325 + color: #fff;
293 font-family: PingFang SC; 326 font-family: PingFang SC;
294 font-weight: 400; 327 font-weight: 400;
295 font-size: 40rpx; 328 font-size: 40rpx;
296 line-height: 48rpx; 329 line-height: 48rpx;
297 - margin-bottom: 40rpx;  
298 display: flex; 330 display: flex;
299 align-items: center; 331 align-items: center;
300 justify-content: center; 332 justify-content: center;
  333 + margin-bottom: 12rpx;
301 } 334 }
302 335
303 .counterText { 336 .counterText {
@@ -317,7 +350,7 @@ checkbox::before { @@ -317,7 +350,7 @@ checkbox::before {
317 width: 80%; 350 width: 80%;
318 margin: 0 auto; 351 margin: 0 auto;
319 border-radius: 42rpx; 352 border-radius: 42rpx;
320 - background: linear-gradient(90.98deg, #f41919 0.25%, #ff7426 120.07%); 353 + background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
321 font-weight: 400; 354 font-weight: 400;
322 color: #fff; 355 color: #fff;
323 text-align: center; 356 text-align: center;
@@ -334,7 +367,7 @@ checkbox::before { @@ -334,7 +367,7 @@ checkbox::before {
334 367
335 .couponInfo { 368 .couponInfo {
336 text-decoration: none; 369 text-decoration: none;
337 - margin-bottom: 30rpx; 370 + margin-bottom: 80rpx;
338 color: #DFDFDF; 371 color: #DFDFDF;
339 text-align: center; 372 text-align: center;
340 } 373 }
@@ -343,6 +376,94 @@ checkbox::before { @@ -343,6 +376,94 @@ checkbox::before {
343 width: 60rpx; 376 width: 60rpx;
344 height: 60rpx; 377 height: 60rpx;
345 position: absolute; 378 position: absolute;
346 - right: 0; 379 + right: 20rpx;
347 top: 0; 380 top: 0;
  381 +}
  382 +
  383 +.couponItems:nth-of-type(1) {
  384 + margin-top: 160rpx;
  385 +}
  386 +
  387 +.couponBox {
  388 + position: relative;
  389 +}
  390 +
  391 +.infoBox {
  392 + width: 100%;
  393 + position: absolute;
  394 + box-sizing: border-box;
  395 + left: 0;
  396 + top: 95rpx;
  397 + padding: 28rpx 40rpx 0 40rpx;
  398 + background: #fff;
  399 + z-index: 10;
  400 +}
  401 +
  402 +.infoBox1 {
  403 + width: 100%;
  404 + box-sizing: border-box;
  405 + background: #fff;
  406 + z-index: 10;
  407 + position: relative;
  408 + padding: 0 24rpx 28rpx 24rpx;
  409 +}
  410 +
  411 +.infoTop {
  412 + width: 100%;
  413 + display: flex;
  414 + align-items: center;
  415 + justify-content: space-between;
  416 +}
  417 +
  418 +.infoTop1 {
  419 + width: 100%;
  420 + display: flex;
  421 + align-items: center;
  422 + justify-content: space-between;
  423 + padding: 0 26rpx;
  424 + box-sizing: border-box;
  425 + margin-bottom: 28rpx;
  426 +}
  427 +
  428 +.infoBottom {
  429 + border-bottom: 2rpx solid #dbdbdb;
  430 + color: #696969;
  431 + font-family: PingFang SC;
  432 + font-weight: 400;
  433 + padding: 10rpx 0 30rpx 0;
  434 +}
  435 +
  436 +.info {
  437 + color: #fe6d03;
  438 + font-family: PingFang SC;
  439 + font-weight: 500;
  440 +}
  441 +
  442 +.infoTop switch {
  443 + transform: scale(.9);
  444 +}
  445 +
  446 +.noUse {
  447 + font-family: PingFang SC;
  448 + font-weight: 400;
  449 + color: #ED7B2F;
  450 +}
  451 +
  452 +.btnBoxs {
  453 + display: flex;
  454 + align-items: center;
  455 + justify-content: space-between;
  456 +}
  457 +
  458 +.couponBtn1 {
  459 + width: 40%;
  460 + margin: 0 auto;
  461 + border-radius: 42rpx;
  462 + background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
  463 + font-weight: 400;
  464 + color: #fff;
  465 + text-align: center;
  466 + border: 4rpx solid #fff;
  467 + padding: 12rpx 0;
  468 + margin: 16rpx auto 20rpx auto;
348 } 469 }
  1 +// pack-activity/pack/getConsume.js
  2 +import util from '../../utils/util';
  3 +import App from '../../utils/api';
  4 +Page({
  5 +
  6 + /**
  7 + * 页面的初始数据
  8 + */
  9 + data: {
  10 + sellerid: '',
  11 + amount: '',
  12 + purePhoneNumber: '',
  13 + },
  14 +
  15 + /**
  16 + * 生命周期函数--监听页面加载
  17 + */
  18 + onLoad(options) {
  19 + console.log('options---',options);
  20 + this.setData({
  21 + sellerid: options.sellerid || '',
  22 + amount: options.amount ? (options.amount * 1).toFixed(2) : '',
  23 + })
  24 + if (options.sellerid) {
  25 + this.getSellerDetailFun(options.sellerid)
  26 + }
  27 + },
  28 + /**
  29 + * 生命周期函数--监听页面显示
  30 + */
  31 + onShow() {
  32 + this.getCheckUserHavePhone()
  33 + },
  34 + // 检测用户是否绑定手机号
  35 + getCheckUserHavePhone() {
  36 + App.Wechat.CheckUserHavePhone({
  37 + openid: getApp().openid,
  38 + }).then((json) => {
  39 + if (json.ret == 200) {
  40 + let data = json.data;
  41 + if (data) {
  42 + this.setData({
  43 + purePhoneNumber: data.phone,
  44 + })
  45 + } else {
  46 + this.setData({
  47 + purePhoneNumber: '',
  48 + })
  49 + }
  50 + }
  51 + })
  52 + },
  53 + // 跳转登录页
  54 + gotoLogin(event) {
  55 + wx.navigateTo({
  56 + url: util.http_build_query({
  57 + types: event.currentTarget.dataset.types
  58 + }, '/pages/customer/login')
  59 + })
  60 + },
  61 + // 为用户增加消费金
  62 + getConsumeFun() {
  63 + App.Activity.SetConsumeByOpenid({
  64 + phone: this.data.purePhoneNumber,
  65 + openid: getApp().openid,
  66 + amount: this.data.amount,
  67 + sellerid: this.data.sellerid
  68 + }).then(res => {
  69 + if (res.data == '0') {
  70 + wx.showToast({
  71 + title: '领取失败,请稍后再试!',
  72 + duration: 1000,
  73 + icon: 'none',
  74 + mask: true
  75 + });
  76 + } else {
  77 + wx.showToast({
  78 + title: '领取成功!',
  79 + duration: 1000,
  80 + icon: 'none',
  81 + mask: true
  82 + });
  83 + }
  84 + wx.exitMiniProgram({});
  85 + })
  86 + },
  87 + // 获取店铺名称
  88 + getSellerDetailFun(sellerid) {
  89 + App.Customer.GetSellerDetail({
  90 + sid:sellerid
  91 + }).then(res => {
  92 + let data = res.data;
  93 + this.setData({
  94 + seller: {
  95 + seller_image: data.seller_image,
  96 + sellername: data.sellername,
  97 + sid: data.id
  98 + }
  99 + })
  100 + })
  101 + },
  102 + /**
  103 + * 生命周期函数--监听页面初次渲染完成
  104 + */
  105 + onReady() {
  106 +
  107 + },
  108 +
  109 + /**
  110 + * 生命周期函数--监听页面隐藏
  111 + */
  112 + onHide() {
  113 +
  114 + },
  115 +
  116 + /**
  117 + * 生命周期函数--监听页面卸载
  118 + */
  119 + onUnload() {
  120 +
  121 + },
  122 +
  123 + /**
  124 + * 页面相关事件处理函数--监听用户下拉动作
  125 + */
  126 + onPullDownRefresh() {
  127 +
  128 + },
  129 +
  130 + /**
  131 + * 页面上拉触底事件的处理函数
  132 + */
  133 + onReachBottom() {
  134 +
  135 + },
  136 +
  137 + /**
  138 + * 用户点击右上角分享
  139 + */
  140 + onShareAppMessage() {
  141 +
  142 + }
  143 +})
  1 +{
  2 + "navigationBarBackgroundColor": "#fff",
  3 + "navigationBarTextStyle": "black",
  4 + "usingComponents": {
  5 + "nav": "/components/nav/nav"
  6 + }
  7 + }
  1 +<!--pack-activity/pack/getConsume.wxml-->
  2 +<nav backgroundColor="#fff">领取消费金</nav>
  3 +<view class="boxInfo">
  4 + <image src="{{seller.seller_image}}" mode="aspectFill" />
  5 + <view class="sellerText" wx:if="{{seller.sellername}}">{{seller.sellername}}</view>
  6 + <view class="text1 font40r" wx:if="{{amount}}">为您发放消费金¥{{amount}}</view>
  7 + <view class="text1 font24r">您到店扫码支付即可自动使用</view>
  8 +</view>
  9 +<block wx:if="{{purePhoneNumber}}">
  10 + <view class="btn font28r" bind:tap="getConsumeFun">开心收下</view>
  11 +</block>
  12 +<block wx:else>
  13 + <view class="btn font28r" bind:tap="gotoLogin" data-types="3">开心收下</view>
  14 +</block>
  1 +/* pack-activity/pack/getConsume.wxss */
  2 +.boxInfo {
  3 + padding: 30% 0 40rpx 0;
  4 + display: flex;
  5 + flex-direction: column;
  6 + align-items: center;
  7 + justify-content: center;
  8 + position: relative;
  9 +}
  10 +
  11 +.boxInfo image {
  12 + width: 200rpx;
  13 + height: 200rpx;
  14 + margin-bottom: 20rpx;
  15 +}
  16 +
  17 +.sellerText {
  18 + color: #000000;
  19 + font-family: PingFang SC;
  20 + font-weight: 600;
  21 + font-size: 52rpx;
  22 + margin-bottom: 80rpx;
  23 +}
  24 +
  25 +.text1 {
  26 + color: #000000;
  27 + font-family: PingFang SC;
  28 + font-weight: 400;
  29 + margin-bottom: 20rpx;
  30 +}
  31 +
  32 +.btn {
  33 + position: absolute;
  34 + bottom: 10%;
  35 + width: 90%;
  36 + left: 5%;
  37 + padding: 20rpx 0;
  38 + border-radius: 198rpx;
  39 + color: #ffffff;
  40 + font-family: PingFang SC;
  41 + font-weight: 600;
  42 + text-align: center;
  43 + background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
  44 +}
  1 +// pack-activity/pack/paySuccess.js
  2 +Page({
  3 +
  4 + /**
  5 + * 页面的初始数据
  6 + */
  7 + data: {
  8 + totalPrice: '',
  9 + totalConsumePrice: '',
  10 + },
  11 +
  12 + /**
  13 + * 生命周期函数--监听页面加载
  14 + */
  15 + onLoad(options) {
  16 + this.setData({
  17 + totalPrice: options.totalPrice ? options.totalPrice : '',
  18 + totalConsumePrice: options.totalConsumePrice ? options.totalConsumePrice : '',
  19 + })
  20 + },
  21 + // 跳转到我的券列表
  22 + certificate() {
  23 + wx.reLaunch({
  24 + url: '/pages/me/coupon_news'
  25 + })
  26 + },
  27 + // 退出小程序
  28 + closePage() {
  29 + wx.exitMiniProgram({});
  30 + },
  31 + // 跳转到我的消费金列表
  32 + gotoConsumeList() {
  33 + wx.reLaunch({
  34 + url: '/pages/me/consumeAmount'
  35 + })
  36 + },
  37 + /**
  38 + * 生命周期函数--监听页面初次渲染完成
  39 + */
  40 + onReady() {
  41 +
  42 + },
  43 +
  44 + /**
  45 + * 生命周期函数--监听页面显示
  46 + */
  47 + onShow() {
  48 +
  49 + },
  50 +
  51 + /**
  52 + * 生命周期函数--监听页面隐藏
  53 + */
  54 + onHide() {
  55 +
  56 + },
  57 +
  58 + /**
  59 + * 生命周期函数--监听页面卸载
  60 + */
  61 + onUnload() {
  62 +
  63 + },
  64 +
  65 + /**
  66 + * 页面相关事件处理函数--监听用户下拉动作
  67 + */
  68 + onPullDownRefresh() {
  69 +
  70 + },
  71 +
  72 + /**
  73 + * 页面上拉触底事件的处理函数
  74 + */
  75 + onReachBottom() {
  76 +
  77 + },
  78 +
  79 + /**
  80 + * 用户点击右上角分享
  81 + */
  82 + onShareAppMessage() {
  83 +
  84 + }
  85 +})
  1 +{
  2 + "backgroundTextStyle":"light",
  3 + "navigationBarBackgroundColor": "#fff",
  4 + "navigationBarTextStyle":"black",
  5 + "usingComponents": {
  6 + "nav":"/components/nav/nav"
  7 + }
  8 + }
  1 +<!--pack-activity/pack/paySuccess.wxml-->
  2 +<nav backgroundColor="#fff">支付结果</nav>
  3 +<view class="box">
  4 + <image src="https://qn.colorcun.com/paySuccessImg.png" mode="aspectFit" />
  5 + <view class="nameInfo font40r">支付成功</view>
  6 + <view class="couponTotal" wx:if="{{totalPrice && totalPrice>0}}">赠送给您<text>{{totalPrice}}元</text>代金券</view>
  7 + <view class="couponTotal" wx:if="{{totalConsumePrice && totalConsumePrice>0}}">为您返还消费金¥{{totalConsumePrice}}</view>
  8 + <view class="couponInfo font24r">您到店扫码支付即可自动使用</view>
  9 + <view class="btnBox">
  10 + <subscribe ids="{{[2]}}">
  11 + <view wx:if="{{totalPrice && totalConsumePrice}}" class="btnBoxs">
  12 + <view bindtap="gotoConsumeList" class="couponBtn1 font36r">查看消费金</view>
  13 + <view bindtap="certificate" class="couponBtn1 font36r">查看优惠券</view>
  14 + </view>
  15 + <view wx:else bindtap="closePage" class="couponBtn font36r">开心收下</view>
  16 + </subscribe>
  17 + </view>
  18 +</view>
  1 +/* pack-activity/pack/paySuccess.wxss */
  2 +.box {
  3 + padding-top: 260rpx;
  4 + display: flex;
  5 + flex-direction: column;
  6 + align-items: center;
  7 + justify-content: center;
  8 +}
  9 +
  10 +.box image {
  11 + width: 100rpx;
  12 + height: 100rpx;
  13 +}
  14 +
  15 +.nameInfo {
  16 + margin: 40rpx 0 72rpx 0;
  17 + color: #000000;
  18 + font-family: "PingFang SC";
  19 + font-weight: 600;
  20 +}
  21 +
  22 +.couponTotal {
  23 + color: #000;
  24 + font-family: PingFang SC;
  25 + font-weight: 400;
  26 + font-size: 32rpx;
  27 + line-height: 44rpx;
  28 + display: flex;
  29 + align-items: center;
  30 + justify-content: center;
  31 + margin-bottom: 12rpx;
  32 +}
  33 +
  34 +.couponInfo {
  35 + color: #000;
  36 + text-align: center;
  37 + margin-bottom: 30rpx;
  38 +}
  39 +
  40 +.btnBox {
  41 + width: 100%;
  42 + position: absolute;
  43 + bottom: 20%;
  44 +}
  45 +
  46 +.btnBoxs {
  47 + width: 100%;
  48 + display: flex;
  49 + align-items: center;
  50 + justify-content: space-between;
  51 +}
  52 +
  53 +.couponBtn1 {
  54 + width: 40%;
  55 + margin: 0 auto;
  56 + border-radius: 42rpx;
  57 + background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
  58 + font-weight: 400;
  59 + color: #fff;
  60 + text-align: center;
  61 + border: 4rpx solid #fff;
  62 + padding: 12rpx 0;
  63 + margin: 16rpx auto 20rpx auto;
  64 +}
  65 +
  66 +.couponBtn {
  67 + width: 80%;
  68 + margin: 0 auto;
  69 + border-radius: 42rpx;
  70 + background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
  71 + font-weight: 400;
  72 + color: #fff;
  73 + text-align: center;
  74 + border: 4rpx solid #fff;
  75 + padding: 12rpx 0;
  76 + margin: 16rpx auto 20rpx auto;
  77 +}
@@ -6,7 +6,7 @@ Page({ @@ -6,7 +6,7 @@ Page({
6 * 页面的初始数据 6 * 页面的初始数据
7 */ 7 */
8 data: { 8 data: {
9 - types: '', //1领券 2赴约 9 + types: '', //1领券 2赴约 3优惠券详情领券、消费金领券
10 avatarUrl: 'https://nosqn.colorcun.com/defaultAvatar.png', 10 avatarUrl: 'https://nosqn.colorcun.com/defaultAvatar.png',
11 nickName: '', 11 nickName: '',
12 token: '', 12 token: '',
@@ -189,7 +189,7 @@ Page({ @@ -189,7 +189,7 @@ Page({
189 // 2赴约 189 // 2赴约
190 } else if (this.data.types == '2') { 190 } else if (this.data.types == '2') {
191 this.confirmed() 191 this.confirmed()
192 - // 3优惠券详情领券 192 + // 3优惠券详情领券、消费金领券
193 }else if (this.data.types == '3') { 193 }else if (this.data.types == '3') {
194 setTimeout(() => { 194 setTimeout(() => {
195 util.toast('登陆成功!', 'none') 195 util.toast('登陆成功!', 'none')
1 // pages/me/consumeAmount.js 1 // pages/me/consumeAmount.js
  2 +import App from '../../utils/api';
  3 +import util from '../../utils/util';
2 Page({ 4 Page({
3 5
4 /** 6 /**
5 * 页面的初始数据 7 * 页面的初始数据
6 */ 8 */
7 data: { 9 data: {
8 - 10 + sellerList: [],
9 }, 11 },
10 12
11 /** 13 /**
12 * 生命周期函数--监听页面加载 14 * 生命周期函数--监听页面加载
13 */ 15 */
14 onLoad(options) { 16 onLoad(options) {
15 - 17 + this.getInfo()
  18 + },
  19 + // 获取用户消费金商家余额列表
  20 + getInfo() {
  21 + App.Activity.GetConsumeSellerListByOpenid({
  22 + openid: getApp().openid,
  23 + }).then(res => {
  24 + let sellerList = res.data;
  25 + sellerList.forEach(i => {
  26 + i.balance = (i.balance * 1).toFixed(2)
  27 + })
  28 + this.setData({
  29 + sellerList
  30 + })
  31 + })
  32 + },
  33 + // 跳转用户商家消费金消费记录
  34 + getSeller(event) {
  35 + wx.navigateTo({
  36 + url: util.http_build_query({
  37 + sellerid: event.currentTarget.dataset.id
  38 + }, '/pages/me/consumeDetails')
  39 + })
  40 + },
  41 + // 换号查看
  42 + switchAccount() {
  43 + wx.redirectTo({
  44 + url: util.http_build_query({
  45 + types: '3'
  46 + }, '/pages/customer/login')
  47 + })
16 }, 48 },
17 -  
18 /** 49 /**
19 * 生命周期函数--监听页面初次渲染完成 50 * 生命周期函数--监听页面初次渲染完成
20 */ 51 */
1 <!--pages/me/consumeAmount.wxml--> 1 <!--pages/me/consumeAmount.wxml-->
2 <wxs src="../../utils/util.wxs" module="util" /> 2 <wxs src="../../utils/util.wxs" module="util" />
3 -<nav>我的消费金</nav>  
  3 +<nav hasHome>我的消费金</nav>
  4 +<view class="{{sellerList.length>0?'box':'box1'}}">
  5 + <block wx:if="{{sellerList.length>0}}">
  6 + <view class="items" wx:for="{{sellerList}}" bind:tap="getSeller" data-id="{{item.sellerid}}">
  7 + <image src="{{item.seller_image}}" mode="aspectFit" />
  8 + <view class="info">
  9 + <view class="name font28r">{{item.sellername}}</view>
  10 + <view class="priceBox font32r">余额 <text>¥{{item.balance}}</text></view>
  11 + </view>
  12 + <view class="rightIcon">
  13 + <text class="font28r">查看</text>
  14 + <view class="more"></view>
  15 + </view>
  16 + </view>
  17 + </block>
  18 + <block wx:else>
  19 + <image class="noDataImg" src="https://qn.colorcun.com/noConsumeData.png" mode="aspectFit" />
  20 + <view class="font28r noDataText">暂无消费金</view>
  21 + <view class="btn font28r" bind:tap="switchAccount">换号查看</view>
  22 + </block>
  23 +</view>
1 -/* pages/me/consumeAmount.wxss */  
  1 +/* pages/me/consumeAmount.wxss */
  2 +page {
  3 + background: #F5F5F5;
  4 +}
  5 +
  6 +.box {
  7 + background: #fff;
  8 + margin: 12rpx;
  9 +}
  10 +
  11 +.items {
  12 + padding: 28rpx 24rpx 20rpx 40rpx;
  13 + border-bottom: 2rpx solid #CBCBCB;
  14 + display: flex;
  15 + align-items: center;
  16 + justify-content: space-between;
  17 + margin: 0 8rpx 0 8rpx;
  18 +}
  19 +
  20 +.items image {
  21 + width: 100rpx;
  22 + height: 100rpx;
  23 + border-radius: 10rpx;
  24 +}
  25 +
  26 +.info {
  27 + margin-left: 32rpx;
  28 + flex: 1;
  29 +}
  30 +
  31 +.info .name {
  32 + color: #000000;
  33 + font-family: PingFang SC;
  34 + font-weight: 400;
  35 +}
  36 +
  37 +.priceBox {
  38 + color: #000000;
  39 + font-family: PingFang SC;
  40 + font-weight: 400;
  41 + margin-top: 14rpx;
  42 +}
  43 +
  44 +.priceBox text {
  45 + color: #fe6f03;
  46 +}
  47 +
  48 +.rightIcon {
  49 + display: flex;
  50 + align-items: center;
  51 + color: #696969;
  52 +}
  53 +
  54 +.more {
  55 + margin-left: 14rpx;
  56 +}
  57 +
  58 +.box1 {
  59 + margin-top: 30%;
  60 + display: flex;
  61 + flex-direction: column;
  62 + align-items: center;
  63 + justify-content: center;
  64 +}
  65 +
  66 +.noDataImg {
  67 + width: 162rpx;
  68 + height: 162rpx;
  69 +}
  70 +
  71 +.noDataText {
  72 + color: #696969;
  73 + font-family: PingFang SC;
  74 + font-weight: 400;
  75 +}
  76 +
  77 +.btn {
  78 + position: absolute;
  79 + width: 90%;
  80 + bottom: 10%;
  81 + left: 5%;
  82 + border-radius: 198rpx;
  83 + padding: 20rpx 0;
  84 + color: #ffffff;
  85 + font-family: "PingFang SC";
  86 + font-weight: 600;
  87 + display: flex;
  88 + align-items: center;
  89 + justify-content: center;
  90 + background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
  91 +}
  1 +// pages/me/consumeDetails.js
  2 +import App from '../../utils/api';
  3 +import util from '../../utils/util';
  4 +Page({
  5 +
  6 + /**
  7 + * 页面的初始数据
  8 + */
  9 + data: {
  10 + sellerid: '',
  11 + consumeList: []
  12 + },
  13 +
  14 + /**
  15 + * 生命周期函数--监听页面加载
  16 + */
  17 + onLoad(options) {
  18 + this.setData({
  19 + sellerid: options.sellerid
  20 + })
  21 + this.getInfo(options.sellerid)
  22 + },
  23 + getInfo(sellerid) {
  24 + App.Activity.GetConsumeListByOpenid({
  25 + openid: getApp().openid,
  26 + sellerid
  27 + }).then(res => {
  28 + let consumeList = res.data;
  29 + consumeList.forEach(i => {
  30 + i.price = (i.price * 1).toFixed(2)
  31 + i.balance = (i.balance * 1).toFixed(2)
  32 + i.cdateInfo = i.cdate ? util.unixtoTime(i.cdate, 'YYYY-MM-DD HH:II') : '';
  33 + })
  34 + this.setData({
  35 + consumeList
  36 + })
  37 + })
  38 + },
  39 + /**
  40 + * 生命周期函数--监听页面初次渲染完成
  41 + */
  42 + onReady() {
  43 +
  44 + },
  45 +
  46 + /**
  47 + * 生命周期函数--监听页面显示
  48 + */
  49 + onShow() {
  50 +
  51 + },
  52 +
  53 + /**
  54 + * 生命周期函数--监听页面隐藏
  55 + */
  56 + onHide() {
  57 +
  58 + },
  59 +
  60 + /**
  61 + * 生命周期函数--监听页面卸载
  62 + */
  63 + onUnload() {
  64 +
  65 + },
  66 +
  67 + /**
  68 + * 页面相关事件处理函数--监听用户下拉动作
  69 + */
  70 + onPullDownRefresh() {
  71 +
  72 + },
  73 +
  74 + /**
  75 + * 页面上拉触底事件的处理函数
  76 + */
  77 + onReachBottom() {
  78 +
  79 + },
  80 +
  81 + /**
  82 + * 用户点击右上角分享
  83 + */
  84 + onShareAppMessage() {
  85 +
  86 + }
  87 +})
  1 +{
  2 + "usingComponents": {
  3 + "nav": "/components/nav/nav"
  4 + }
  5 +}
  1 +<!--pages/me/consumeDetails.wxml-->
  2 +<wxs src="../../utils/util.wxs" module="util" />
  3 +<nav hasHome>消费金明细</nav>
  4 +<view class="box">
  5 + <view class="items" wx:for="{{consumeList}}" bind:tap="getSeller" data-id="{{item.sellerid}}">
  6 + <view class="topInfo">
  7 + <view class="types font28r">{{item.type=='1'?'消耗':'获取'}}</view>
  8 + <view class="priceInfo font40r {{item.type=='1'?'colors1':'colors2'}}">{{item.type=='1'?'-':'+'}}¥{{item.price}}</view>
  9 + </view>
  10 + <view class="bottomInfo">
  11 + <view class="text1 font28r">{{item.cdateInfo}}</view>
  12 + <view class="text1 font28r">本店消费金余额 ¥{{item.balance}}</view>
  13 + </view>
  14 + </view>
  15 +</view>
  1 +/* pages/me/consumeDetails.wxss */
  2 +page {
  3 + background: #F5F5F5;
  4 +}
  5 +
  6 +.box {
  7 + background: #fff;
  8 + margin: 12rpx;
  9 +}
  10 +
  11 +.items {
  12 + padding: 28rpx 24rpx 20rpx 40rpx;
  13 + border-bottom: 2rpx solid #CBCBCB;
  14 + display: flex;
  15 + flex-direction: column;
  16 + margin: 0 8rpx 0 8rpx;
  17 +}
  18 +
  19 +.topInfo {
  20 + display: flex;
  21 + align-items: center;
  22 + justify-content: space-between;
  23 +}
  24 +
  25 +.bottomInfo {
  26 + display: flex;
  27 + align-items: center;
  28 + justify-content: space-between;
  29 + margin-top: 30rpx;
  30 +}
  31 +
  32 +.types {
  33 + color: #000000;
  34 + font-family: PingFang SC;
  35 + font-weight: 400;
  36 +}
  37 +
  38 +.priceInfo {
  39 + font-family: PingFang SC;
  40 + font-weight: 500;
  41 +}
  42 +
  43 +.colors1 {
  44 + color: #696969;
  45 +}
  46 +
  47 +.colors2 {
  48 + color: #fe6f03;
  49 +}
  50 +
  51 +.text1 {
  52 + color: #696969;
  53 + font-family: PingFang SC;
  54 + font-weight: 400;
  55 +}
1 <!--pages/taocan/coupon_news.wxml 用户端--我的--卡券--> 1 <!--pages/taocan/coupon_news.wxml 用户端--我的--卡券-->
2 <wxs src="../../utils/util.wxs" module="util" /> 2 <wxs src="../../utils/util.wxs" module="util" />
3 -<nav>卡券</nav> 3 +<nav hasHome>卡券</nav>
4 <scroll-view class="list" style="height:{{contentHeight}}px;" scroll-y> 4 <scroll-view class="list" style="height:{{contentHeight}}px;" scroll-y>
5 <block wx:if="{{list.length>0}}"> 5 <block wx:if="{{list.length>0}}">
6 <view wx:for="{{list}}" bindtap="todetail" data-item="{{item}}" class="preferentialItems {{item.noShow == '0' ? 'noStyle':''}}"> 6 <view wx:for="{{list}}" bindtap="todetail" data-item="{{item}}" class="preferentialItems {{item.noShow == '0' ? 'noStyle':''}}">
@@ -77,6 +77,7 @@ Page({ @@ -77,6 +77,7 @@ Page({
77 this.getlist() 77 this.getlist()
78 this.GetCollectionSellerList() 78 this.GetCollectionSellerList()
79 this.getInfo() 79 this.getInfo()
  80 + this.getUserInfo()
80 }, 81 },
81 // 获取用户昵称、头像 82 // 获取用户昵称、头像
82 getInfo() { 83 getInfo() {
@@ -88,11 +89,30 @@ Page({ @@ -88,11 +89,30 @@ Page({
88 this.setData({ 89 this.setData({
89 nickname: data.nickname ? data.nickname : '', 90 nickname: data.nickname ? data.nickname : '',
90 headimgurl: data.headimgurl ? data.headimgurl : '', 91 headimgurl: data.headimgurl ? data.headimgurl : '',
91 - price: data.price ? data.price : '0.00',  
92 }) 92 })
93 } 93 }
94 }) 94 })
95 }, 95 },
  96 + // 获取用户在商家&所有消费金
  97 + getUserInfo() {
  98 + App.Activity.GetConsumeBySeller({
  99 + openid: getApp().openid,
  100 + }).then((json) => {
  101 + if (json.ret == 200) {
  102 + let data = json.data;
  103 + if (data && data.length > 0) {
  104 + let obj = data[0]
  105 + this.setData({
  106 + price: obj.balance ? (obj.balance * 1).toFixed(2) : '0.00',
  107 + })
  108 + } else {
  109 + this.setData({
  110 + price: '0.00',
  111 + })
  112 + }
  113 + }
  114 + })
  115 + },
96 // 顾客收藏的店铺列表 116 // 顾客收藏的店铺列表
97 GetCollectionSellerList() { 117 GetCollectionSellerList() {
98 App.Customer.GetCollectionSellerList({ 118 App.Customer.GetCollectionSellerList({
@@ -894,5 +894,25 @@ export default { @@ -894,5 +894,25 @@ export default {
894 //根据openid和手机号获取个人账户信息 894 //根据openid和手机号获取个人账户信息
895 'App.Wechat.GetUserInfoByOpenidPhone':{ 895 'App.Wechat.GetUserInfoByOpenidPhone':{
896 }, 896 },
  897 +
  898 + //获取商家消费金规则
  899 + 'App.Activity.GetConsumeConfig':{
  900 + },
  901 +
  902 + //为用户增加消费金
  903 + 'App.Activity.SetConsumeByOpenid':{
  904 + },
  905 +
  906 + //获取用户在商家&所有消费金
  907 + 'App.Activity.GetConsumeBySeller':{
  908 + },
  909 +
  910 + //获取用户消费金商家余额列表
  911 + 'App.Activity.GetConsumeSellerListByOpenid':{
  912 + },
  913 +
  914 + //获取用户消费金消费记录
  915 + 'App.Activity.GetConsumeListByOpenid':{
  916 + },
897 917
898 -}  
  918 +}