Commit c56f0dffd5a6af7dd9f1da0118dacdea33ef475e

Authored by pengye
1 parent 5e017fc9

充值几倍当餐免费、使用店铺余额支付

@@ -29,22 +29,37 @@ Page({ @@ -29,22 +29,37 @@ Page({
29 noConfiguration: '', //配置消费金 0未配置 1已配置 29 noConfiguration: '', //配置消费金 0未配置 1已配置
30 returnData: '', //赠送消费金配置 30 returnData: '', //赠送消费金配置
31 isReturn: '', //赠送消费金的开关 31 isReturn: '', //赠送消费金的开关
  32 + giveConsumePrice: '', //新老用户赠送消费金额
  33 + isNewUser: '',//新用户1 老用户2
  34 + recharge_data: [], //所有满赠充值活动
  35 + payType: '2', //1余额支付 2微信支付
  36 + multiple: '', //充值几倍当餐免费
  37 + rechargeList:{},
  38 + myBalance: '', //店铺总余额
  39 + balancePay: '', //余额支付金额
  40 + soothPrice: '', //实付价格-余额的价格
  41 + countDown: '5', //5秒后自动关闭弹框
  42 + timer: null,
32 }, 43 },
33 sid: '', //扫码进入带的参数商家id 44 sid: '', //扫码进入带的参数商家id
34 couponModal: '', 45 couponModal: '',
35 giveCouponModal: '', 46 giveCouponModal: '',
36 consumeModal: '', 47 consumeModal: '',
  48 + giveConsume: '',
37 myToast:'', 49 myToast:'',
38 /** 50 /**
39 * 生命周期函数--监听页面加载 51 * 生命周期函数--监听页面加载
40 */ 52 */
41 onLoad(options) { 53 onLoad(options) {
  54 + console.log('options----', options);
42 this.couponModal = this.selectComponent("#couponModal"); 55 this.couponModal = this.selectComponent("#couponModal");
43 this.giveCouponModal = this.selectComponent("#giveCouponModal"); 56 this.giveCouponModal = this.selectComponent("#giveCouponModal");
44 this.consumeModal = this.selectComponent("#consumeModal"); 57 this.consumeModal = this.selectComponent("#consumeModal");
  58 + this.giveConsume = this.selectComponent("#giveConsume");
45 if (options.sid) { 59 if (options.sid) {
46 this.sid = options.sid 60 this.sid = options.sid
47 this.getSellerDetailFun(options.sid) 61 this.getSellerDetailFun(options.sid)
  62 + this.getRechargeDetail(options.sid)
48 } 63 }
49 }, 64 },
50 // 检测用户是否绑定手机号 65 // 检测用户是否绑定手机号
@@ -59,7 +74,9 @@ Page({ @@ -59,7 +74,9 @@ Page({
59 purePhoneNumber: data.phone, 74 purePhoneNumber: data.phone,
60 }) 75 })
61 this.getUserInfo() 76 this.getUserInfo()
  77 + this.getUserRechargeInfo(data.phone, '0')
62 } else { 78 } else {
  79 + this.getUserInfo()
63 this.setData({ 80 this.setData({
64 purePhoneNumber: '', 81 purePhoneNumber: '',
65 }) 82 })
@@ -67,6 +84,113 @@ Page({ @@ -67,6 +84,113 @@ Page({
67 } 84 }
68 }) 85 })
69 }, 86 },
  87 + // 切换支付方式
  88 + checkPay(e) {
  89 + let type = e.currentTarget.dataset['type'];
  90 + let actualPrice = this.data.actualPrice;
  91 + if (type == '1') {
  92 + let myBalance = this.data.myBalance * 1;
  93 + if (actualPrice && actualPrice > 0) {
  94 + let balancePay = actualPrice > myBalance ? myBalance : actualPrice;
  95 + let soothPrice = (actualPrice - balancePay).toFixed(2)
  96 + this.setData({
  97 + balancePay,
  98 + soothPrice,
  99 + })
  100 + }
  101 + } else {
  102 + this.setData({
  103 + balancePay: '0.00',
  104 + soothPrice: actualPrice,
  105 + })
  106 + }
  107 + this.setData({
  108 + payType: type,
  109 + })
  110 + },
  111 + // 根据充值ID获取充值详情
  112 + getRechargeDetail(sellerid) {
  113 + App.Activity.GetNewRechargeList({
  114 + sellerid,
  115 + }).then(res => {
  116 + if (res.data) {
  117 + let arr = []
  118 + res.data.forEach(i => {
  119 + if (i.status != '1') {
  120 + arr.push(i)
  121 + }
  122 + })
  123 + let recharge_data = arr;
  124 + recharge_data.forEach(item => {
  125 + item.recharge_list = item.recharge_list ? JSON.parse(item.recharge_list) : '';
  126 + let recharge_list = item.recharge_list;
  127 + item.timeStr = util.unixtoTime(item.stime, 'YYYY-MM-DD') + ' - ' + util.unixtoTime(item.etime, 'YYYY-MM-DD')
  128 + })
  129 + // 筛选出 未过期的 && 开启状态的充值活动
  130 + recharge_data = recharge_data.filter(item => {
  131 + return this.data.dataStr < (item.etime * 1) && item.is_open == '1'
  132 + })
  133 + console.log('所有充值活动--------------', recharge_data);
  134 + this.setData({
  135 + recharge_data,
  136 + })
  137 + } else {
  138 + this.setData({
  139 + recharge_data: [],
  140 + })
  141 + }
  142 + })
  143 + },
  144 + // 获取用户在商家的账户余额
  145 + getUserRechargeInfo(phone, type) {
  146 + App.Activity.GetRechargeBalanceByOpenid({
  147 + openid: getApp().openid,
  148 + phone,
  149 + sellerid: this.sid,
  150 + }).then((json) => {
  151 + if (json.ret == 200) {
  152 + let data = json.data;
  153 + if (data) {
  154 + console.log('获取用户在商家的余额----', data.recharge_balance);
  155 + this.setData({
  156 + myBalance: data.recharge_balance ? (data.recharge_balance * 1).toFixed(2) : '0.00',
  157 + })
  158 + } else {
  159 + if (type == '1') this.createInfoFun(phone)
  160 + console.log('用户在商家没有账号');
  161 + this.setData({
  162 + myBalance: null,
  163 + })
  164 + }
  165 + }
  166 + })
  167 + },
  168 + // 用户绑定手机号
  169 + bindUserPhoneFun(phone) {
  170 + console.log('用户绑定手机号');
  171 + let params = {
  172 + phone,
  173 + openid: getApp().openid,
  174 + }
  175 + App.Wechat.BindUserPhone(params).then(res => {
  176 + if (res.ret == 200) {
  177 + console.log(res, '用户绑定手机号');
  178 + }
  179 + })
  180 + },
  181 + // 如果该用户不存在账户 新增用户在商家的账户信息
  182 + createInfoFun(phone) {
  183 + let params = {
  184 + openid: getApp().openid,
  185 + sellerid: this.data.seller.sid,
  186 + phone
  187 + }
  188 + App.Activity.CreateCustomerConsumeSeller(params).then(res => {
  189 + if (res.ret == 200) {
  190 + console.log('新增用户在商家的账户信息----', res);
  191 + }
  192 + })
  193 + },
70 // 获取用户在商家&所有消费金 194 // 获取用户在商家&所有消费金
71 getUserInfo() { 195 getUserInfo() {
72 App.Activity.GetConsumeBySeller({ 196 App.Activity.GetConsumeBySeller({
@@ -90,11 +214,55 @@ Page({ @@ -90,11 +214,55 @@ Page({
90 consumeDiscount: '0.00', //消费金抵扣金额 214 consumeDiscount: '0.00', //消费金抵扣金额
91 }) 215 })
92 } 216 }
  217 + this.getIdentityFun()
93 } 218 }
94 }) 219 })
95 }, 220 },
  221 + // 获取当餐免费的配置信息
  222 + getFreeMealConfigFun() {
  223 + App.Activity.GetFreeMealConfigBySeller({
  224 + sellerid: this.sid,
  225 + }).then(res => {
  226 + if (res && res.data && res.data.length > 0 && res.data[0].is_open == '1') {
  227 + let data = res.data[0];
  228 + let list = data.recharge_list ? JSON.parse(data.recharge_list) : {}
  229 + list.priceInfo = '';
  230 + list.scoreInfo = '';
  231 + list.certificate = '';
  232 + if (list.is_price == '1') list.priceInfo = '赠' + list.price + '元余额';
  233 + if (list.is_score == '1') list.scoreInfo = '赠' + list.score + '积分';
  234 + if (list.is_coupons == '1' && list.coupons_names.length > 0) list.certificate = '赠' + list.coupons_names.join('、') + '券';;
  235 + this.setData({
  236 + multiple: data.multiple,
  237 + rechargeList: list
  238 + })
  239 + } else {
  240 + this.setData({
  241 + multiple: '',
  242 + rechargeList: {}
  243 + })
  244 + }
  245 + })
  246 + },
  247 + // 获取用户在当前商家身份及是否领取过消费金
  248 + getIdentityFun(){
  249 + App.Activity.GetIdentityBySeller({
  250 + sellerid: this.sid,
  251 + openid: getApp().openid,
  252 + phone: this.data.purePhoneNumber,
  253 + }).then(res => {
  254 + let is_get_consume = '1'
  255 + if (res && res.data) {
  256 + is_get_consume = res.data.is_get_consume
  257 + this.setData({
  258 + isNewUser:res.data.identity,
  259 + })
  260 + }
  261 + this.getConsumeConfigFun(is_get_consume)
  262 + })
  263 + },
96 // 获取商家消费金规则 264 // 获取商家消费金规则
97 - getConsumeConfigFun() { 265 + getConsumeConfigFun(isConsume) {
98 App.Activity.GetConsumeConfig({ 266 App.Activity.GetConsumeConfig({
99 sellerid: this.sid, 267 sellerid: this.sid,
100 }).then(res => { 268 }).then(res => {
@@ -102,17 +270,42 @@ Page({ @@ -102,17 +270,42 @@ Page({
102 let data = res.data; 270 let data = res.data;
103 let together = util.determine(data.together_json); 271 let together = util.determine(data.together_json);
104 let returnData = util.determine(data.return_json); 272 let returnData = util.determine(data.return_json);
105 - returnData.ladder_data = returnData.ladder_data ? util.determine(returnData.ladder_data) : {}; 273 + let beforePay = util.determine(data.before_pay_json);
  274 + if(beforePay && beforePay.new) beforePay.new = util.determine(beforePay.new);
  275 + if(beforePay && beforePay.old) beforePay.old = util.determine(beforePay.old);
  276 + console.log('returnData---',returnData);
  277 + if(returnData && returnData.ladder_data) returnData.ladder_data = util.determine(returnData.ladder_data);
106 console.log('111配置---',together); 278 console.log('111配置---',together);
107 console.log('222顾客支付后返消费金---',returnData); 279 console.log('222顾客支付后返消费金---',returnData);
  280 + console.log('3333新老用户领取消费金---',beforePay);
  281 + let time = Math.floor(Date.now() / 1000)
  282 + let giveConsumePrice = '';
  283 + if(beforePay){
  284 + // 新用户 && 没有领取过 && 开启新用户领取
  285 + if(this.data.isNewUser == 'new' && isConsume == '0' && beforePay.new && beforePay.is_new == '1'){
  286 + let newData = beforePay.new;
  287 + if((time > newData.stime) && (time < newData.etime)){
  288 + giveConsumePrice = newData.is_fix == '1'?newData.fix_price :this.getRandomInt(newData.random_min, newData.random_max);
  289 + }
  290 + }
  291 + // 老用户 && 个人消费金大于0 && 开启老用户领取
  292 + if(this.data.isNewUser == 'old' && this.data.consumePrice == '0.00' && beforePay.old && beforePay.is_old == '1'){
  293 + let oldData = beforePay.old;
  294 + if((time > oldData.stime) && (time < oldData.etime)){
  295 + giveConsumePrice = oldData.is_fix == '1'?oldData.fix_price :this.getRandomInt(oldData.random_min, oldData.random_max);
  296 + }
  297 + }
  298 + console.log('giveConsumePrice-------',giveConsumePrice);
  299 + }
108 this.setData({ 300 this.setData({
109 noConfiguration: '1', //配置为1 未配置为0 301 noConfiguration: '1', //配置为1 未配置为0
110 - coexist: together.is_coexist,  
111 - ratio: together.ratio_data ? together.ratio_data : '100', 302 + coexist: together?together.is_coexist:'',
  303 + ratio: together && together.ratio_data ? together.ratio_data : '100',
112 couponSwitch: true, 304 couponSwitch: true,
113 - consumeSwitch: together.is_coexist == '1' ? true : false, 305 + consumeSwitch: together && together.is_coexist == '1' ? true : false,
114 returnData, 306 returnData,
115 isReturn: data.is_return, 307 isReturn: data.is_return,
  308 + giveConsumePrice,
116 }) 309 })
117 } else { 310 } else {
118 this.setData({ 311 this.setData({
@@ -121,6 +314,7 @@ Page({ @@ -121,6 +314,7 @@ Page({
121 consumeSwitch: false, 314 consumeSwitch: false,
122 returnData: null, 315 returnData: null,
123 isReturn: '0', 316 isReturn: '0',
  317 + giveConsumePrice:'',
124 }) 318 })
125 } 319 }
126 }) 320 })
@@ -155,11 +349,18 @@ Page({ @@ -155,11 +349,18 @@ Page({
155 if (!this.data.couponSwitch) { 349 if (!this.data.couponSwitch) {
156 this.getCoupon() 350 this.getCoupon()
157 let val = parseFloat(this.data.inputValue); 351 let val = parseFloat(this.data.inputValue);
  352 + if (!val) return
158 let discountPrice = 0; 353 let discountPrice = 0;
159 let actualPrice = (val - this.data.consumeDiscount - discountPrice).toFixed(2) 354 let actualPrice = (val - this.data.consumeDiscount - discountPrice).toFixed(2)
  355 + console.log('actualPrice----', actualPrice);
  356 + let myBalance = this.data.myBalance * 1;
  357 + let balancePay = (this.data.payType == '1' && actualPrice > myBalance) ? myBalance : actualPrice;
  358 + let soothPrice = this.data.payType == '1' ? (actualPrice - balancePay).toFixed(2) : actualPrice;
160 this.setData({ 359 this.setData({
161 discountPrice: 0, 360 discountPrice: 0,
162 - actualPrice: actualPrice > 0 ? actualPrice : '0.01' 361 + actualPrice,
  362 + balancePay,
  363 + soothPrice,
163 }) 364 })
164 } 365 }
165 // 开或者关闭使用消费金 366 // 开或者关闭使用消费金
@@ -170,10 +371,15 @@ Page({ @@ -170,10 +371,15 @@ Page({
170 let discountPrice = this.data.couponSwitch ? this.data.discountPrice : 0 371 let discountPrice = this.data.couponSwitch ? this.data.discountPrice : 0
171 let actualPrice = (val - consumeDiscount - discountPrice).toFixed(2) 372 let actualPrice = (val - consumeDiscount - discountPrice).toFixed(2)
172 let remainingConsume = (this.data.consumePrice * 1 - consumeDiscount).toFixed(2) 373 let remainingConsume = (this.data.consumePrice * 1 - consumeDiscount).toFixed(2)
  374 + let myBalance = this.data.myBalance * 1;
  375 + let balancePay = (this.data.payType == '1' && actualPrice > myBalance) ? myBalance : actualPrice;
  376 + let soothPrice = this.data.payType == '1' ? (actualPrice - balancePay).toFixed(2) : actualPrice;
173 this.setData({ 377 this.setData({
174 consumeDiscount, 378 consumeDiscount,
175 - actualPrice: actualPrice > 0 ? actualPrice : '0.01',  
176 - remainingConsume: remainingConsume 379 + actualPrice,
  380 + remainingConsume: remainingConsume,
  381 + balancePay,
  382 + soothPrice,
177 }) 383 })
178 } 384 }
179 if (!this.data.consumeSwitch) { 385 if (!this.data.consumeSwitch) {
@@ -182,10 +388,15 @@ Page({ @@ -182,10 +388,15 @@ Page({
182 let discountPrice = this.data.couponSwitch ? this.data.discountPrice : 0 388 let discountPrice = this.data.couponSwitch ? this.data.discountPrice : 0
183 let consumeDiscount = this.data.consumeSwitch ? this.data.consumeDiscount : 0 389 let consumeDiscount = this.data.consumeSwitch ? this.data.consumeDiscount : 0
184 let actualPrice = (val - consumeDiscount - discountPrice).toFixed(2) 390 let actualPrice = (val - consumeDiscount - discountPrice).toFixed(2)
  391 + let myBalance = this.data.myBalance * 1;
  392 + let balancePay = (this.data.payType == '1' && actualPrice > myBalance) ? myBalance : actualPrice;
  393 + let soothPrice = this.data.payType == '1' ? (actualPrice - balancePay).toFixed(2) : actualPrice;
185 this.setData({ 394 this.setData({
186 consumeDiscount: '0.00', 395 consumeDiscount: '0.00',
187 - actualPrice: actualPrice > 0 ? actualPrice : '0.01', 396 + actualPrice,
188 remainingConsume: this.data.consumePrice, 397 remainingConsume: this.data.consumePrice,
  398 + balancePay,
  399 + soothPrice,
189 }) 400 })
190 } 401 }
191 }, 402 },
@@ -218,18 +429,119 @@ Page({ @@ -218,18 +429,119 @@ Page({
218 closeConsumeModal() { 429 closeConsumeModal() {
219 this.consumeModal.closeModal() 430 this.consumeModal.closeModal()
220 }, 431 },
  432 + // 打开赠送消费金弹框
  433 + showGiveConsumeModal() {
  434 + let num = this.data.giveConsumePrice;
  435 + this.setData({
  436 + giveConsumePrice: num
  437 + })
  438 + this.giveConsume.showModal()
  439 + this.setData({
  440 + countDown: 5,
  441 + })
  442 + if (this.data.timer) {
  443 + clearInterval(this.data.timer);
  444 + }
  445 + this.startCountDown();
  446 + console.log('送消费金----',num);
  447 + },
  448 + // 开始倒计时
  449 + startCountDown() {
  450 + let that = this;
  451 + const timer = setInterval(() => {
  452 + if (that.data.countDown <= 1) {
  453 + that.closeGiveConsumeModal()
  454 + clearInterval(timer);
  455 + that.setData({
  456 + timer: null
  457 + });
  458 + } else {
  459 + that.setData({
  460 + countDown: that.data.countDown - 1
  461 + });
  462 + }
  463 + }, 1000);
  464 + this.setData({
  465 + timer
  466 + });
  467 + },
  468 + // 关闭消费金弹框
  469 + closeGiveConsumeModal() {
  470 + this.giveConsume.closeModal()
  471 + this.getConsumeFun(this.data.giveConsumePrice,'1')
  472 + },
  473 + // 选择充值活动
  474 + checkRechargeData(e) {
  475 + let id = e.currentTarget.dataset['id'];
  476 + console.log('id', id);
  477 + if (!id) {
  478 + let price = this.data.actualPrice * 1 * this.data.multiple
  479 + if (!price) return false
  480 + let str = this.data.finalList.map(item => item.activity_id).join(',');
  481 + console.log('核销所勾选的券传参', str);
  482 + let params = {
  483 + type: '2',
  484 + types: '4', // 1邀请函 2提前点餐 3商家端app分享 4支付页充值 5我的页面余额充值
  485 + sid: this.sid,
  486 + totalize: price.toFixed(2), //充值几倍金额
  487 + name: this.data.seller.sellername,
  488 + isFree: '1',
  489 + multiple: this.data.multiple,
  490 + inputValue: this.data.inputValue, //订单实际应该支付金额(扣除消费金、券之前)
  491 + }
  492 + // 消费金开关开启 && 消费金抵扣金额大于0
  493 + if (this.data.consumeDiscount * 1 > 0 && this.data.consumeSwitch) {
  494 + params.consume = this.data.consumeDiscount;
  495 + }
  496 + if (str) {
  497 + params.activity_id = str;
  498 + }
  499 + if (this.data.givePrice) {
  500 + params.givePrice = this.data.givePrice; //当餐免费送的余额
  501 + }
  502 + let url = util.http_build_query({
  503 + ...params
  504 + }, '/pack-activity/pack/vipRecharge')
  505 + return wx.navigateTo({
  506 + url
  507 + })
  508 + }
  509 + wx.navigateTo({
  510 + url: util.http_build_query({
  511 + id,
  512 + name: this.data.seller.sellername,
  513 + sid: this.sid,
  514 + types: '4',
  515 + isFree: '0',
  516 + }, '/pack-activity/pack/vipRecharge')
  517 + })
  518 + },
221 // 关闭优惠券弹框 519 // 关闭优惠券弹框
222 closegiveCouponModal() { 520 closegiveCouponModal() {
223 this.giveCouponModal.closeModal() 521 this.giveCouponModal.closeModal()
224 this.getUserInfo() 522 this.getUserInfo()
225 }, 523 },
226 - // 跳转登录页  
227 - gotoLogin(event) {  
228 - wx.navigateTo({  
229 - url: util.http_build_query({  
230 - types: event.currentTarget.dataset.types  
231 - }, '/pages/customer/login')  
232 - }) 524 + // 获取code、手机号
  525 + getPhoneNumberFun(e) {
  526 + console.log('eeeeeeeeee', e.detail);
  527 + if (e.detail && e.detail.code) {
  528 + App.Wechat.GetUserPhoneNumber({
  529 + code: e.detail.code,
  530 + }).then(res => {
  531 + console.log('resresres----', res);
  532 + if (res.ret == 200 && res.data && res.data.phone_info && res.data.phone_info.purePhoneNumber) {
  533 + this.setData({
  534 + purePhoneNumber: res.data.phone_info.purePhoneNumber,
  535 + })
  536 + this.getUserInfo()
  537 + this.bindUserPhoneFun(res.data.phone_info.purePhoneNumber)
  538 + this.getUserRechargeInfo(res.data.phone_info.purePhoneNumber, '1')
  539 + } else {
  540 + this.getUserInfo()
  541 + util.toast('手机号获取失败!', 'none')
  542 + }
  543 + })
  544 + }
233 }, 545 },
234 // 获取店铺名称 546 // 获取店铺名称
235 getSellerDetailFun(sid) { 547 getSellerDetailFun(sid) {
@@ -266,9 +578,9 @@ Page({ @@ -266,9 +578,9 @@ Page({
266 if (now >= parseInt(fullData.stime) && now <= parseInt(fullData.etime)) { 578 if (now >= parseInt(fullData.stime) && now <= parseInt(fullData.etime)) {
267 // rule 1每满门槛均发放(满50送一张券,金额是100送2张) 579 // rule 1每满门槛均发放(满50送一张券,金额是100送2张)
268 // rule 0仅发放一次(每次满足金额一个券只发一张) 580 // rule 0仅发放一次(每次满足金额一个券只发一张)
  581 + const price = parseFloat(fullData.price)
  582 + const amount = parseInt(priceSum / price)
269 if (fullData.rule == '1') { 583 if (fullData.rule == '1') {
270 - const price = parseFloat(fullData.price)  
271 - const amount = parseInt(priceSum / price)  
272 if (coupons.length > 0 && amount > 0) this.getCouponFun(coupons, '1', amount,orderid) 584 if (coupons.length > 0 && amount > 0) this.getCouponFun(coupons, '1', amount,orderid)
273 } else { 585 } else {
274 if (coupons.length > 0 && amount > 0) this.getCouponFun(coupons, '1', 1,orderid) 586 if (coupons.length > 0 && amount > 0) this.getCouponFun(coupons, '1', 1,orderid)
@@ -367,8 +679,6 @@ Page({ @@ -367,8 +679,6 @@ Page({
367 }).then(res => { 679 }).then(res => {
368 if (res.ret == 200 && res.data && res.data.length > 0) { 680 if (res.ret == 200 && res.data && res.data.length > 0) {
369 let list = res.data 681 let list = res.data
370 - // console.log('listlistlist',JSON.stringify(list));  
371 - // list= list.concat(monidata)  
372 list.forEach(detail => { 682 list.forEach(detail => {
373 detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : ''; 683 detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
374 detail.arule = detail.arule ? util.determine(detail.arule) : ''; 684 detail.arule = detail.arule ? util.determine(detail.arule) : '';
@@ -520,7 +830,10 @@ Page({ @@ -520,7 +830,10 @@ Page({
520 discountPrice: '', 830 discountPrice: '',
521 actualPrice: '', 831 actualPrice: '',
522 consumeDiscount: '', 832 consumeDiscount: '',
523 - remainingConsume: this.data.consumePrice 833 + remainingConsume: this.data.consumePrice,
  834 + soothPrice: '',
  835 + balancePay: '',
  836 + payType: '2',
524 }) 837 })
525 } else { 838 } else {
526 if (this.data.couponSwitch) { 839 if (this.data.couponSwitch) {
@@ -531,17 +844,24 @@ Page({ @@ -531,17 +844,24 @@ Page({
531 let consumeDiscount = this.calculateConsumeGold(val); 844 let consumeDiscount = this.calculateConsumeGold(val);
532 let actualPrice = (val - consumeDiscount - this.data.discountPrice).toFixed(2) 845 let actualPrice = (val - consumeDiscount - this.data.discountPrice).toFixed(2)
533 let remainingConsume = (this.data.consumePrice * 1 - consumeDiscount).toFixed(2) 846 let remainingConsume = (this.data.consumePrice * 1 - consumeDiscount).toFixed(2)
  847 + let myBalance = this.data.myBalance * 1;
  848 + let balancePay = (this.data.payType == '1' && actualPrice > myBalance) ? myBalance : actualPrice;
  849 + let soothPrice = this.data.payType == '1' ? (actualPrice - balancePay).toFixed(2) : actualPrice;
534 this.setData({ 850 this.setData({
535 consumeDiscount, 851 consumeDiscount,
536 - actualPrice: actualPrice > 0 ? actualPrice : '0.01',  
537 - remainingConsume: remainingConsume 852 + actualPrice: actualPrice,
  853 + remainingConsume: remainingConsume,
  854 + balancePay,
  855 + soothPrice
538 }) 856 })
539 } 857 }
540 } 858 }
541 }, 859 },
542 // 点确认选择 860 // 点确认选择
543 checkCertificate() { 861 checkCertificate() {
  862 + let inputValue = parseFloat(this.data.inputValue);
544 this.closeCouponModal() 863 this.closeCouponModal()
  864 + if (!inputValue) return
545 let list = this.data.couponArr; 865 let list = this.data.couponArr;
546 list = list.filter(i => { 866 list = list.filter(i => {
547 return i.checked 867 return i.checked
@@ -554,9 +874,14 @@ Page({ @@ -554,9 +874,14 @@ Page({
554 let val = parseFloat(this.data.inputValue); 874 let val = parseFloat(this.data.inputValue);
555 let actualPrice = (val - price - this.data.consumeDiscount).toFixed(2) 875 let actualPrice = (val - price - this.data.consumeDiscount).toFixed(2)
556 price = price.toFixed(2) 876 price = price.toFixed(2)
  877 + let myBalance = this.data.myBalance * 1;
  878 + let balancePay = (this.data.payType == '1' && actualPrice > myBalance) ? myBalance : actualPrice;
  879 + let soothPrice = this.data.payType == '1' ? (actualPrice - balancePay).toFixed(2) : actualPrice;
557 this.setData({ 880 this.setData({
558 discountPrice: price, 881 discountPrice: price,
559 - actualPrice: actualPrice > 0 ? actualPrice : 0.01, 882 + actualPrice,
  883 + balancePay,
  884 + soothPrice,
560 }) 885 })
561 console.log('点确认选择后', list); 886 console.log('点确认选择后', list);
562 }, 887 },
@@ -569,20 +894,28 @@ Page({ @@ -569,20 +894,28 @@ Page({
569 console.log('处理过后的券数据', list); 894 console.log('处理过后的券数据', list);
570 list.sort((a, b) => b.canCheck - a.canCheck); 895 list.sort((a, b) => b.canCheck - a.canCheck);
571 list.sort((a, b) => b.showCpupon - a.showCpupon); 896 list.sort((a, b) => b.showCpupon - a.showCpupon);
  897 + let consumeDiscount = '';
  898 + let amount = parseFloat(this.data.inputValue);
572 if (this.data.consumeSwitch) { 899 if (this.data.consumeSwitch) {
573 - let amount = parseFloat(this.data.inputValue);  
574 let num = (amount - this.data.discountPrice).toFixed(2); 900 let num = (amount - this.data.discountPrice).toFixed(2);
575 let val = parseFloat(num); 901 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) 902 + consumeDiscount = this.calculateConsumeGold(val);
579 this.setData({ 903 this.setData({
580 consumeDiscount, 904 consumeDiscount,
581 - actualPrice: actualPrice > 0 ? actualPrice : '0.01',  
582 - remainingConsume: remainingConsume  
583 }) 905 })
584 } 906 }
  907 + let actualPrice = (amount - consumeDiscount - this.data.discountPrice).toFixed(2)
  908 + let remainingConsume = (this.data.consumePrice * 1 - consumeDiscount).toFixed(2)
  909 + let myBalance = this.data.myBalance * 1;
  910 + let balancePay = (this.data.payType == '1' && actualPrice > myBalance) ? myBalance : actualPrice;
  911 + let soothPrice = this.data.payType == '1'?(actualPrice - balancePay).toFixed(2):actualPrice
  912 + console.log('实际支付金额:', actualPrice);
585 this.setData({ 913 this.setData({
  914 + consumeDiscount,
  915 + actualPrice,
  916 + remainingConsume: remainingConsume,
  917 + soothPrice,
  918 + balancePay,
586 couponArr: list, 919 couponArr: list,
587 finalList: obj.finalList 920 finalList: obj.finalList
588 }) 921 })
@@ -591,9 +924,9 @@ Page({ @@ -591,9 +924,9 @@ Page({
591 confirmPayment: util.throttle(function () { 924 confirmPayment: util.throttle(function () {
592 let that = this; 925 let that = this;
593 let actualPrice = this.data.actualPrice 926 let actualPrice = this.data.actualPrice
594 - if (actualPrice <= 0) {  
595 - return  
596 - } 927 + wx.showLoading({
  928 + title: '支付中',
  929 + })
597 let str = this.data.finalList.map(item => item.activity_id).join(','); 930 let str = this.data.finalList.map(item => item.activity_id).join(',');
598 console.log('核销所勾选的券传参', str); 931 console.log('核销所勾选的券传参', str);
599 let params = { 932 let params = {
@@ -607,9 +940,46 @@ Page({ @@ -607,9 +940,46 @@ Page({
607 if (str) { 940 if (str) {
608 params.activity_id = str; 941 params.activity_id = str;
609 } 942 }
  943 + // 用余额支付 || 支付金额为0
  944 + if (this.data.soothPrice == '0.00') {
  945 + let obj = {
  946 + openid: getApp().openid,
  947 + sellerid: this.data.seller.sid,
  948 + price: this.data.inputValue,
  949 + phone: this.data.purePhoneNumber,
  950 + recharge_balance: this.data.balancePay * 1,
  951 + }
  952 + if (str) {
  953 + obj.activity_id = str;
  954 + }
  955 + let consumeDiscount = this.data.consumeDiscount * 1
  956 + if (consumeDiscount > 0) {
  957 + obj.consume = this.data.consumeDiscount;
  958 + }
  959 + console.log('用余额支付objobj----', obj);
  960 + App.Activity.CreateRechargeBalanceOrder({
  961 + ...obj
  962 + }).then(res => {
  963 + console.log('付款信息', res.data);
  964 + if (res.ret != '200') {
  965 + wx.hideLoading()
  966 + return wx.showToast({
  967 + title: res.msg,
  968 + duration: 1000,
  969 + icon: 'none',
  970 + })
  971 + }
  972 + if (res.ret == '200') {
  973 + that.deductBalance(actualPrice, res.data.id)
  974 + }
  975 + })
  976 + return false
  977 + }
  978 + // 微信支付
610 App.PayOnline.CombineTransactionsByNewActivity(params).then(res => { 979 App.PayOnline.CombineTransactionsByNewActivity(params).then(res => {
611 console.log('付款信息', res.data); 980 console.log('付款信息', res.data);
612 if (res.ret != '200') { 981 if (res.ret != '200') {
  982 + wx.hideLoading()
613 wx.showToast({ 983 wx.showToast({
614 title: res.msg, 984 title: res.msg,
615 duration: 1000, 985 duration: 1000,
@@ -624,20 +994,19 @@ Page({ @@ -624,20 +994,19 @@ Page({
624 signType: res.data.signType, 994 signType: res.data.signType,
625 paySign: res.data.paySign, 995 paySign: res.data.paySign,
626 success(ress) { 996 success(ress) {
  997 + wx.hideLoading()
627 if (ress.errMsg == 'requestPayment:ok') { 998 if (ress.errMsg == 'requestPayment:ok') {
628 that.giftCouponsFun(actualPrice,res.data.orderid) //送券 999 that.giftCouponsFun(actualPrice,res.data.orderid) //送券
629 that.giftConsumeFun(actualPrice, res.data.orderid) //送消费金 1000 that.giftConsumeFun(actualPrice, res.data.orderid) //送消费金
630 setTimeout(() => { 1001 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 - } 1002 + console.log('2送券金额----', that.data.totalPrice);
  1003 + console.log('2送消费金----', that.data.totalConsumePrice);
  1004 + wx.reLaunch({
  1005 + url: util.http_build_query({
  1006 + totalPrice: that.data.totalPrice,
  1007 + totalConsumePrice: that.data.totalConsumePrice,
  1008 + }, '/pack-activity/pack/paySuccess')
  1009 + })
641 }, 1000); 1010 }, 1000);
642 console.log('支付成功', ress); 1011 console.log('支付成功', ress);
643 return 1012 return
@@ -647,6 +1016,7 @@ Page({ @@ -647,6 +1016,7 @@ Page({
647 return that.myToast.showToast('支付失败,请重新下单', 2000) 1016 return that.myToast.showToast('支付失败,请重新下单', 2000)
648 }, 1017 },
649 fail(ress) { 1018 fail(ress) {
  1019 + wx.hideLoading()
650 that.payFail() 1020 that.payFail()
651 console.log('支付失败22', ress); 1021 console.log('支付失败22', ress);
652 return that.myToast.showToast('支付失败,请重新下单', 2000) 1022 return that.myToast.showToast('支付失败,请重新下单', 2000)
@@ -655,6 +1025,37 @@ Page({ @@ -655,6 +1025,37 @@ Page({
655 } 1025 }
656 }) 1026 })
657 },3000), 1027 },3000),
  1028 + // 扣除支付的余额
  1029 + deductBalance(actualPrice, id) {
  1030 + let that = this;
  1031 + let recharge_balance = this.data.balancePay * 1
  1032 + App.Activity.SetRechargeBalanceByOpenid({
  1033 + openid: getApp().openid,
  1034 + recharge_balance,
  1035 + sellerid: this.data.seller.sid,
  1036 + type: '2',
  1037 + }).then(res => {
  1038 + if (res.ret == 200) {
  1039 + wx.hideLoading()
  1040 + console.log('扣除余额成功');
  1041 + that.giftCouponsFun(actualPrice, id) //送券
  1042 + that.giftConsumeFun(actualPrice, id) //送消费金
  1043 + setTimeout(() => {
  1044 + console.log('1送券金额----', that.data.totalPrice);
  1045 + console.log('1送消费金----', that.data.totalConsumePrice);
  1046 + wx.reLaunch({
  1047 + url: util.http_build_query({
  1048 + totalPrice: that.data.totalPrice,
  1049 + totalConsumePrice: that.data.totalConsumePrice,
  1050 + }, '/pack-activity/pack/paySuccess')
  1051 + })
  1052 + }, 1000);
  1053 + } else {
  1054 + wx.hideLoading()
  1055 + that.myToast.showToast('支付失败,请重新下单', 2000)
  1056 + }
  1057 + })
  1058 + },
658 payFail() { 1059 payFail() {
659 this.setData({ 1060 this.setData({
660 inputValue: '', 1061 inputValue: '',
@@ -663,6 +1064,9 @@ Page({ @@ -663,6 +1064,9 @@ Page({
663 discountPrice: '0.00', 1064 discountPrice: '0.00',
664 actualPrice: '', 1065 actualPrice: '',
665 consumeDiscount: '0.00', //消费金抵扣金额 1066 consumeDiscount: '0.00', //消费金抵扣金额
  1067 + balancePay:'',
  1068 + payType:'2',
  1069 + soothPrice: '',
666 }) 1070 })
667 this.getCoupon() 1071 this.getCoupon()
668 this.getUserInfo() 1072 this.getUserInfo()
@@ -691,20 +1095,15 @@ Page({ @@ -691,20 +1095,15 @@ Page({
691 } 1095 }
692 }, 1096 },
693 // 为用户增加消费金 1097 // 为用户增加消费金
694 - getConsumeFun(amount) { 1098 + getConsumeFun(amount,type) {
695 App.Activity.SetConsumeByOpenid({ 1099 App.Activity.SetConsumeByOpenid({
696 phone: this.data.purePhoneNumber, 1100 phone: this.data.purePhoneNumber,
697 openid: getApp().openid, 1101 openid: getApp().openid,
698 amount, 1102 amount,
699 sellerid: this.data.seller.sid 1103 sellerid: this.data.seller.sid
700 }).then(res => { 1104 }).then(res => {
701 - if (res.data == '0') {  
702 - wx.showToast({  
703 - title: '消费金领取失败!',  
704 - duration: 1000,  
705 - icon: 'none',  
706 - mask: true  
707 - }); 1105 + if(type == '1'){
  1106 + this.getUserInfo()
708 } 1107 }
709 }) 1108 })
710 }, 1109 },
@@ -922,14 +1321,13 @@ Page({ @@ -922,14 +1321,13 @@ Page({
922 }); 1321 });
923 discountPrice = discountPrice.toFixed(2) 1322 discountPrice = discountPrice.toFixed(2)
924 console.log('总优惠金额:', discountPrice); 1323 console.log('总优惠金额:', discountPrice);
925 - let actualPrice = (amount - discountPrice).toFixed(2);  
926 - console.log('实际支付金额:', actualPrice); 1324 + console.log('消费金抵扣:',this.data.consumeDiscount);
927 this.setData({ 1325 this.setData({
928 discountPrice, 1326 discountPrice,
929 - actualPrice: actualPrice > 0 ? actualPrice : '0.01', // 确保实际支付金额不小于0.01  
930 }); 1327 });
931 return { 1328 return {
932 arr, 1329 arr,
  1330 + discountPrice,
933 finalList, // 返回可叠加和不可叠加的优惠券组合 1331 finalList, // 返回可叠加和不可叠加的优惠券组合
934 }; 1332 };
935 }, 1333 },
@@ -1061,7 +1459,6 @@ Page({ @@ -1061,7 +1459,6 @@ Page({
1061 var month = curdate.getMonth() + 1; 1459 var month = curdate.getMonth() + 1;
1062 var date = Math.floor((curdate.getTime() % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60 * 24)) + 1; // 计算当前日期 1460 var date = Math.floor((curdate.getTime() % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60 * 24)) + 1; // 计算当前日期
1063 var formattedDate = year + "-" + month + "-" + date; 1461 var formattedDate = year + "-" + month + "-" + date;
1064 - obj.isshow = '0'  
1065 //在节假日数组内 1462 //在节假日数组内
1066 if ((holidays.indexOf(formattedDate) >= 0) && nWeekend.indexOf(formattedDate) < 0) { 1463 if ((holidays.indexOf(formattedDate) >= 0) && nWeekend.indexOf(formattedDate) < 0) {
1067 obj.isshow = '1' 1464 obj.isshow = '1'
@@ -1185,6 +1582,11 @@ Page({ @@ -1185,6 +1582,11 @@ Page({
1185 url: '/pages/me/consumeAmount' 1582 url: '/pages/me/consumeAmount'
1186 }) 1583 })
1187 }, 1584 },
  1585 + getRandomInt(min, max) {
  1586 + min = Math.ceil(min);
  1587 + max = Math.floor(max);
  1588 + return Math.floor(Math.random() * (max - min + 1)) + min;
  1589 + },
1188 /** 1590 /**
1189 * 生命周期函数--监听页面初次渲染完成 1591 * 生命周期函数--监听页面初次渲染完成
1190 */ 1592 */
@@ -1196,7 +1598,7 @@ Page({ @@ -1196,7 +1598,7 @@ Page({
1196 */ 1598 */
1197 onShow() { 1599 onShow() {
1198 this.getCheckUserHavePhone() 1600 this.getCheckUserHavePhone()
1199 - this.getConsumeConfigFun() 1601 + this.getFreeMealConfigFun()
1200 }, 1602 },
1201 1603
1202 /** 1604 /**
1 <!--pack-activity/pack/buyFreeCoupon.wxml--> 1 <!--pack-activity/pack/buyFreeCoupon.wxml-->
2 <nav hasHome>向商家付款</nav> 2 <nav hasHome>向商家付款</nav>
  3 +<wxs module="utils">
  4 + var formatPrice = function(price, multiple) {
  5 + var result = (price * 1 * multiple).toFixed(2);
  6 + return result;
  7 + }
  8 + module.exports.formatPrice = formatPrice;
  9 +</wxs>
3 <view class="sellInfo"> 10 <view class="sellInfo">
4 <image src="{{seller.seller_image}}" mode="aspectFill" /> 11 <image src="{{seller.seller_image}}" mode="aspectFill" />
5 <view class="font32r">{{seller.sellername}}</view> 12 <view class="font32r">{{seller.sellername}}</view>
@@ -31,19 +38,102 @@ @@ -31,19 +38,102 @@
31 </view> 38 </view>
32 </block> 39 </block>
33 <block wx:else> 40 <block wx:else>
34 - <view bindtap="gotoLogin" data-types="3" class="couponsBox colorOrange">  
35 - <view class="couponLeft">使用消费金抵扣</view>  
36 - <view class="couponRight"> 41 + <button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumberFun" class="couponsBox colorOrange">
  42 + <view class="couponLeft font28r">使用消费金抵扣</view>
  43 + <view class="couponRight font28r">
37 <view class="more" style="margin-top: 6rpx;"></view> 44 <view class="more" style="margin-top: 6rpx;"></view>
38 </view> 45 </view>
39 - </view> 46 + </button>
40 </block> 47 </block>
41 <view class="couponsWrap"> 48 <view class="couponsWrap">
42 <view class="couponLeft">抵扣后</view> 49 <view class="couponLeft">抵扣后</view>
43 <view class="couponRight" wx:if="{{actualPrice && inputValue}}">¥{{actualPrice}}</view> 50 <view class="couponRight" wx:if="{{actualPrice && inputValue}}">¥{{actualPrice}}</view>
44 </view> 51 </view>
  52 + <view wx:if="{{purePhoneNumber && giveConsumePrice && giveConsumePrice>0}}" class="consumeBox">
  53 + <image class="consumeImg" src="https://qn.colorcun.com/myConsume.png" mode=""/>
  54 + <view class="claim font28r" bind:tap="showGiveConsumeModal">免费领取消费金,当餐可用</view>
  55 + </view>
  56 + <button wx:if="{{!purePhoneNumber && giveConsumePrice && giveConsumePrice>0}}" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumberFun" class="consumeBox">
  57 + <image class="consumeImg" src="https://qn.colorcun.com/myConsume.png" mode=""/>
  58 + <view class="claim font28r">免费领取消费金,当餐可用</view>
  59 + </button>
  60 +</view>
  61 +<view class="payBox">
  62 + <view class="balanceBox" wx:if="{{purePhoneNumber}}">
  63 + <view class="balanceLeft">
  64 + <view>
  65 + <image class="balanceImg" src="https://qn.colorcun.com/balanceIcon.png" mode=""/>
  66 + <text class="texts font28r">店铺余额支付</text>
  67 + </view>
  68 + <text class="font24r">总余额¥{{myBalance?myBalance:'0.00'}}</text>
  69 + </view>
  70 + <view class="balanceRight">
  71 + <text wx:if="{{payType == '1' && balancePay && balancePay>0}}">-¥{{balancePay}}</text>
  72 + <image wx:if="{{payType == '1'}}" bind:tap="checkPay" data-type="1" class="checkIcon" src="https://qn.colorcun.com/checkImg1.png" mode=""/>
  73 + <view class="check" wx:else data-type="1" bind:tap="checkPay"></view>
  74 + </view>
  75 + </view>
  76 + <button wx:else open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumberFun" class="balanceBox">
  77 + <view class="balanceLeft">
  78 + <view>
  79 + <image class="balanceImg" src="https://qn.colorcun.com/balanceIcon.png" mode=""/>
  80 + <text class="texts font28r">店铺余额支付</text>
  81 + </view>
  82 + <text class="font24r">总余额¥0.00</text>
  83 + </view>
  84 + <view class="balanceRight">
  85 + <view class="check" ></view>
  86 + </view>
  87 + </button>
  88 + <view class="balanceLeft balanceLeft1">
  89 + <view>
  90 + <image class="balanceImg" src="https://qn.colorcun.com/wxPayIcon.png" mode=""/>
  91 + <text class="texts font28r">微信支付</text>
  92 + </view>
  93 + <image wx:if="{{payType == '2'}}" bind:tap="checkPay" data-type="2" class="checkIcon" src="https://qn.colorcun.com/checkImg1.png" mode=""/>
  94 + <view wx:else class="check" data-type="2" bind:tap="checkPay"></view>
  95 + </view>
  96 + <view class="rechargeBox" wx:if="{{purePhoneNumber}}">
  97 + <view class="rechargeItems" wx:for="{{recharge_data}}" bindtap="checkRechargeData" data-id="{{item.id}}">
  98 + <view class="font24r">充<text>{{item.recharge_money}}</text>元</view>
  99 + <view class="font24r" wx:if="{{item.recharge_list.price && item.recharge_list.price*1 > 0}}">送{{item.recharge_list.price}}元</view>
  100 + </view>
  101 + </view>
  102 + <button wx:else open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumberFun" class="rechargeBox">
  103 + <view class="rechargeItems" wx:for="{{recharge_data}}" data-id="{{item.id}}">
  104 + <view class="font24r">充<text>{{item.recharge_money}}</text>元</view>
  105 + <view class="font24r" wx:if="{{item.recharge_list.price && item.recharge_list.price*1 > 0}}">送{{item.recharge_list.price}}元</view>
  106 + </view>
  107 + </button>
  108 + <view class="rechargeItems rechargeItems1" wx:if="{{purePhoneNumber && multiple && multiple > 0 && rechargeList}}" bindtap="checkRechargeData">
  109 + <view class="font24r">
  110 + <block wx:if="{{multiple && multiple > 0 && !actualPrice}}">
  111 + 充<text>{{multiple}}</text>倍 <text>当餐免费</text>
  112 + </block>
  113 + <block wx:else>
  114 + 充<text>{{utils.formatPrice(actualPrice, multiple)}}</text>元 <text>当餐免费</text>
  115 + </block>
  116 + </view>
  117 + <view class="font24r bottomItem">{{rechargeList.priceInfo}} {{rechargeList.scoreInfo}} {{rechargeList.certificate}}</view>
  118 + </view>
  119 + <button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumberFun" class="rechargeItems rechargeItems1" wx:if="{{!purePhoneNumber && multiple && multiple > 0 && rechargeList}}">
  120 + <view class="font24r">
  121 + <block wx:if="{{multiple && multiple > 0 && !actualPrice}}">
  122 + 充<text>{{multiple}}</text>倍 <text>当餐免费</text>
  123 + </block>
  124 + <block wx:else>
  125 + 充<text>{{actualPrice * 1 * multiple}}</text>元 <text>当餐免费</text>
  126 + </block>
  127 + </view>
  128 + <view class="font24r bottomItem">{{rechargeList.priceInfo}} {{rechargeList.scoreInfo}} {{rechargeList.certificate}}</view>
  129 + </button>
  130 + <!-- <view class="infoAgreement font24r">充值即代表同意<text>《用户协议》</text>及<text>《会员充值协议》</text></view> -->
  131 +</view>
  132 +<view class="bottomBox"></view>
  133 +<view class="payBtnBox">
  134 + <view class="total">合计<text>{{soothPrice?'¥' + soothPrice:''}}</text></view>
  135 + <view class="payBtn font32r" bindtap="confirmPayment">支付</view>
45 </view> 136 </view>
46 -<view class="payBtn font32r" bindtap="confirmPayment">付款</view>  
47 <toast id="myToast"></toast> 137 <toast id="myToast"></toast>
48 <!-- 使用优惠券弹框 --> 138 <!-- 使用优惠券弹框 -->
49 <my-modal id="couponModal" fadeStyle="slideUp" height="{{couponArr.length > '3' ? '80%' : '60%'}}"> 139 <my-modal id="couponModal" fadeStyle="slideUp" height="{{couponArr.length > '3' ? '80%' : '60%'}}">
@@ -125,7 +215,7 @@ @@ -125,7 +215,7 @@
125 </view> 215 </view>
126 </my-modal> 216 </my-modal>
127 <!-- 赠送优惠券/消费金弹框 --> 217 <!-- 赠送优惠券/消费金弹框 -->
128 -<my-modal id="giveCouponModal" fadeStyle="slideUp" height="240px"> 218 +<!-- <my-modal id="giveCouponModal" fadeStyle="slideUp" height="240px">
129 <view slot="modalName" class="titleModal "> 219 <view slot="modalName" class="titleModal ">
130 <image bindtap="closegiveCouponModal" class="closeImg" src="https://qn.colorcun.com/closeOutline.png" mode=""/> 220 <image bindtap="closegiveCouponModal" class="closeImg" src="https://qn.colorcun.com/closeOutline.png" mode=""/>
131 <view class="nameInfo">{{seller.sellername}}</view> 221 <view class="nameInfo">{{seller.sellername}}</view>
@@ -142,4 +232,19 @@ @@ -142,4 +232,19 @@
142 <view wx:else bindtap="closegiveCouponModal" class="couponBtn font36r">开心收下</view> 232 <view wx:else bindtap="closegiveCouponModal" class="couponBtn font36r">开心收下</view>
143 </subscribe> 233 </subscribe>
144 </view> 234 </view>
  235 +</my-modal> -->
  236 +<!-- 新用户/老用户赠送消费金弹框 -->
  237 +<my-modal id="giveConsume" fadeStyle="center" height="300px">
  238 + <view slot="modalContent" class="contentBox">
  239 + <image bindtap="closeGiveConsumeModal" class="closeImg1" src="https://qn.colorcun.com/closeImg3.png" mode="" />
  240 + <view class="nameInfo">{{seller.sellername}}</view>
  241 + <view class="couponTotal1 font28r">赠送给您消费金</view>
  242 + <view class="counterText1">
  243 + <view class="font36r">¥</view>
  244 + <scroll-number value="{{giveConsumePrice}}"></scroll-number>
  245 + </view>
  246 + <view class="couponInfo1 font24r">您到店扫码支付即可自动抵扣</view>
  247 + <view bindtap="closeGiveConsumeModal" class="couponBtn1 font36r">开心收下</view>
  248 + <view class="closeBox font28r">{{countDown}} 秒后自动关闭</view>
  249 + </view>
145 </my-modal> 250 </my-modal>
1 /* pack-activity/pack/buyFreeCoupon.wxss */ 1 /* pack-activity/pack/buyFreeCoupon.wxss */
  2 +page {
  3 + background: #F5F5F5;
  4 +}
  5 +
2 .sellInfo { 6 .sellInfo {
3 padding: 56rpx 0 40rpx 0; 7 padding: 56rpx 0 40rpx 0;
4 display: flex; 8 display: flex;
5 flex-direction: column; 9 flex-direction: column;
6 align-items: center; 10 align-items: center;
7 justify-content: center; 11 justify-content: center;
8 - background: #f6f6fd;  
9 } 12 }
10 13
11 .sellInfo image { 14 .sellInfo image {
@@ -15,9 +18,10 @@ @@ -15,9 +18,10 @@
15 } 18 }
16 19
17 .payBox { 20 .payBox {
18 - padding: 30rpx 40rpx 0 40rpx;  
19 - border-radius: 30rpx 30rpx 0rpx 0rpx; 21 + padding: 40rpx;
20 background: #ffffff; 22 background: #ffffff;
  23 + border-radius: 10rpx;
  24 + margin: 0 20rpx 20rpx 20rpx;
21 } 25 }
22 26
23 .payView { 27 .payView {
@@ -54,6 +58,9 @@ @@ -54,6 +58,9 @@
54 justify-content: space-between; 58 justify-content: space-between;
55 color: #999; 59 color: #999;
56 margin: 24rpx 0; 60 margin: 24rpx 0;
  61 + padding: 0;
  62 + background: transparent;
  63 + border: none;
57 } 64 }
58 65
59 .couponsBox .more { 66 .couponsBox .more {
@@ -89,16 +96,47 @@ @@ -89,16 +96,47 @@
89 justify-content: space-between; 96 justify-content: space-between;
90 } 97 }
91 98
  99 +.payBtnBox {
  100 + position: fixed;
  101 + left: 0;
  102 + bottom: 0;
  103 + height: 160rpx;
  104 + padding: 0 40rpx;
  105 + box-sizing: border-box;
  106 + z-index: 10;
  107 + justify-content: space-between;
  108 + width: 100%;
  109 + background: #fff;
  110 + display: flex;
  111 + align-items: center;
  112 + justify-content: space-between;
  113 +}
  114 +
  115 +.payBtnBox .total {
  116 + display: flex;
  117 + align-items: center;
  118 +}
  119 +
  120 +.payBtnBox .total text {
  121 + color: #FD4D59;
  122 +}
  123 +
  124 +.bottomBox {
  125 + padding-bottom: 160rpx;
  126 + margin-bottom: 60rpx;
  127 +}
  128 +
92 .payBtn { 129 .payBtn {
93 - background: #09BB07;  
94 - width: 90%;  
95 - color: #fff;  
96 - text-align: center;  
97 - padding: 20rpx 0;  
98 - position: absolute;  
99 - bottom: 10%;  
100 - border-radius: 198rpx;  
101 - left: 5%; 130 + background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
  131 + color: #fff;
  132 + height: 72rpx;
  133 + border-radius: 198rpx;
  134 + font-weight: 600;
  135 + margin-right: 20rpx;
  136 + padding: 0 60rpx;
  137 + display: flex;
  138 + align-items: center;
  139 + justify-content: center;
102 } 140 }
103 141
104 .mymodal .mymodal-title { 142 .mymodal .mymodal-title {
@@ -313,8 +351,8 @@ checkbox::before { @@ -313,8 +351,8 @@ checkbox::before {
313 351
314 .nameInfo { 352 .nameInfo {
315 font-family: PingFang SC; 353 font-family: PingFang SC;
316 - font-weight: 600;  
317 - font-size: 52rpx; 354 + font-weight: 500;
  355 + font-size: 40rpx;
318 line-height: 56rpx; 356 line-height: 56rpx;
319 color: #fff; 357 color: #fff;
320 margin-bottom: 100rpx; 358 margin-bottom: 100rpx;
@@ -333,6 +371,18 @@ checkbox::before { @@ -333,6 +371,18 @@ checkbox::before {
333 margin-bottom: 12rpx; 371 margin-bottom: 12rpx;
334 } 372 }
335 373
  374 +.couponTotal1 {
  375 + color: #fff;
  376 + font-family: PingFang SC;
  377 + font-weight: 500;
  378 + font-size: 28rpx;
  379 + line-height: 48rpx;
  380 + margin-bottom: 16rpx;
  381 + display: flex;
  382 + align-items: center;
  383 + justify-content: center;
  384 +}
  385 +
336 .counterText { 386 .counterText {
337 color: #ffc806; 387 color: #ffc806;
338 font-weight: 600; 388 font-weight: 600;
@@ -340,12 +390,27 @@ checkbox::before { @@ -340,12 +390,27 @@ checkbox::before {
340 margin-right: 14rpx; 390 margin-right: 14rpx;
341 } 391 }
342 392
  393 +.counterText1 {
  394 + color: #FFC806;
  395 + font-weight: 600;
  396 + font-size: 100rpx;
  397 + display: flex;
  398 + align-items: flex-end;
  399 + justify-content: center;
  400 +}
  401 +
343 .couponInfo { 402 .couponInfo {
344 color: #DFDFDF; 403 color: #DFDFDF;
345 text-align: center; 404 text-align: center;
346 margin-bottom: 30rpx; 405 margin-bottom: 30rpx;
347 } 406 }
348 407
  408 +.couponInfo1 {
  409 + color: #fff;
  410 + text-align: center;
  411 + margin: 16rpx 0 28rpx;
  412 +}
  413 +
349 .couponBtn { 414 .couponBtn {
350 width: 80%; 415 width: 80%;
351 margin: 0 auto; 416 margin: 0 auto;
@@ -359,6 +424,10 @@ checkbox::before { @@ -359,6 +424,10 @@ checkbox::before {
359 margin: 16rpx auto 20rpx auto; 424 margin: 16rpx auto 20rpx auto;
360 } 425 }
361 426
  427 +.contentBox {
  428 + width: 100%;
  429 +}
  430 +
362 .couponText { 431 .couponText {
363 color: #fff; 432 color: #fff;
364 text-decoration: underline; 433 text-decoration: underline;
@@ -456,14 +525,223 @@ checkbox::before { @@ -456,14 +525,223 @@ checkbox::before {
456 } 525 }
457 526
458 .couponBtn1 { 527 .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; 528 + width: 80%;
  529 + border-radius: 198rpx;
  530 + background: #fff;
  531 + font-family: PingFang SC;
  532 + font-weight: 600;
  533 + color: #F14033;
465 text-align: center; 534 text-align: center;
466 - border: 4rpx solid #fff;  
467 - padding: 12rpx 0;  
468 - margin: 16rpx auto 20rpx auto; 535 + padding: 32rpx 0;
  536 + margin: 28rpx auto 0 auto;
  537 +}
  538 +
  539 +.claim {
  540 + color: #FD4D59;
  541 + text-decoration: underline;
  542 +}
  543 +
  544 +.consumeBox {
  545 + margin-top: 28rpx;
  546 + display: flex;
  547 + align-items: center;
  548 + padding: 0;
  549 + background: transparent;
  550 + line-height: inherit;
  551 +}
  552 +
  553 +.consumeImg {
  554 + width: 40rpx;
  555 + height: 40rpx;
  556 + margin-left: 8rpx;
  557 +}
  558 +
  559 +#giveConsume .mymodal{
  560 + background: #F14033;
  561 + width: 72% !important;
  562 + left: 14% !important;
  563 + top: 30% !important;
  564 +}
  565 +
  566 +#giveConsume .closeImg1 {
  567 + position: absolute;
  568 + width: 60rpx;
  569 + height: 60rpx;
  570 + top: -17%;
  571 + right: -10%;
  572 +}
  573 +
  574 +#giveConsume .mymodal .mymodal-content {
  575 + border-radius: 20rpx;
  576 +}
  577 +
  578 +#giveConsume .mymodal-content {
  579 + display: flex;
  580 + align-items: center;
  581 + justify-content: center;
  582 +}
  583 +
  584 +#giveConsume .nameInfo {
  585 + margin-bottom: 20rpx;
  586 + text-align: center;
  587 +}
  588 +
  589 +#giveConsume .counterText {
  590 + color: #ffc806;
  591 + font-weight: 600;
  592 + display: flex;
  593 + font-size: 100rpx;
  594 + align-items: flex-end;
  595 + justify-content: center;
  596 + margin: 16rpx 0;
  597 +}
  598 +
  599 +#giveConsume .couponInfo {
  600 + margin-bottom:20rpx;
  601 +}
  602 +
  603 +.balanceBox,
  604 +.balanceLeft view,
  605 +.balanceRight {
  606 + display: flex;
  607 + align-items: center;
  608 + justify-content: space-between;
  609 +}
  610 +
  611 +.balanceBox {
  612 + align-items: flex-start;
  613 + margin: 0;
  614 + padding: 0;
  615 + background: transparent;
  616 + border: none;
  617 +}
  618 +
  619 +.balanceLeft {
  620 + display: flex;
  621 + justify-content: space-between;
  622 + flex-direction: column;
  623 +}
  624 +
  625 +.balanceLeft text {
  626 + color: #696969;
  627 + font-family: PingFang SC;
  628 + font-weight: 400;
  629 + margin-top: 10rpx;
  630 +}
  631 +
  632 +.balanceLeft .texts {
  633 + color: #000000;
  634 + font-family: PingFang SC;
  635 + font-weight: 500;
  636 + margin-top: 0;
  637 +}
  638 +
  639 +.balanceLeft image,
  640 +.balanceRight image {
  641 + width: 44rpx;
  642 + height: 44rpx;
  643 +}
  644 +
  645 +.balanceRight text {
  646 + color: #ED7B2F;
  647 + font-family: PingFang SC;
  648 + font-weight: 400;
  649 + margin-right: 8rpx;
  650 +}
  651 +
  652 +.balanceImg {
  653 + margin-right: 4rpx;
  654 +}
  655 +
  656 +.rechargeBox {
  657 + display: flex;
  658 + align-items: center;
  659 + justify-content: space-between;
  660 + flex-wrap: wrap;
  661 + margin-top: 28rpx;
  662 + padding: 0;
  663 + background: transparent;
  664 + border: none;
  665 + line-height: inherit;
  666 +}
  667 +
  668 +.rechargeItems {
  669 + width: 46%;
  670 + padding: 20rpx 0rpx;
  671 + border-radius: 10rpx;
  672 + border: 2rpx solid #cbcbcb;
  673 + background: #fff7f5;
  674 + color: #B56737;
  675 + display: flex;
  676 + align-items: center;
  677 + flex-direction: column;
  678 + justify-content: center;
  679 + margin-bottom: 28rpx;
  680 + height: 84rpx;
  681 +}
  682 +
  683 +.rechargeItems view text {
  684 + font-size: 48rpx;
  685 + margin: 0 4rpx;
  686 + font-family: PingFang SC;
  687 + font-weight: 600;
  688 +}
  689 +
  690 +
  691 +.rechargeItems view text:nth-last-of-type(1) {
  692 + font-size: 40rpx;
  693 + font-family: PingFang SC;
  694 + font-weight: 500;
  695 +}
  696 +
  697 +.rechargeItems view {
  698 + display: flex;
  699 + align-items: center;
  700 + justify-content: center;
  701 +}
  702 +
  703 +.rechargeItems1 {
  704 + width: 100%;
  705 + line-height: inherit;
  706 + height: auto;
  707 +}
  708 +
  709 +.rechargeItems1 view text:nth-last-of-type(1) {
  710 + margin-left: 60rpx;
  711 +}
  712 +
  713 +.bottomItem {
  714 + margin: 10rpx 0;
  715 +}
  716 +
  717 +.infoAgreement {
  718 + color: #696969;
  719 + font-family: "PingFang SC";
  720 + font-weight: 400;
  721 +}
  722 +
  723 +.infoAgreement text {
  724 + color: #ED7B2F;
  725 +}
  726 +
  727 +.check {
  728 + width: 40rpx;
  729 + height: 40rpx;
  730 + border-radius: 50%;
  731 + border: 2rpx solid #cbcbcb;
  732 +}
  733 +
  734 +.balanceLeft1 {
  735 + flex-direction: row;
  736 + margin-top: 28rpx;
  737 +}
  738 +
  739 +.closeBox {
  740 + margin-top: 20rpx;
  741 + color: #ffffff;
  742 + font-family: PingFang SC;
  743 + font-weight: 400;
  744 + display: flex;
  745 + align-items: center;
  746 + justify-content: center;
469 } 747 }
@@ -14,15 +14,16 @@ Page({ @@ -14,15 +14,16 @@ Page({
14 combine_out_trade_no: '', 14 combine_out_trade_no: '',
15 totalize: '', 15 totalize: '',
16 types: '', 16 types: '',
  17 + givePrice:'',
17 }, 18 },
18 type: '', 19 type: '',
19 name: "", 20 name: "",
20 - date: "",  
21 - phone: "",  
22 - calendarData: '', 21 + purePhoneNumber: '', //手机号
23 sex: "先生", 22 sex: "先生",
24 indexs: 0, 23 indexs: 0,
25 StyleType:'',//邀请函模板 24 StyleType:'',//邀请函模板
  25 + showInfo:'0',//有无会员信息
  26 + vipInfo:{},
26 sexList: [{ 27 sexList: [{
27 sex: '先生', 28 sex: '先生',
28 value: '1', 29 value: '1',
@@ -57,6 +58,11 @@ Page({ @@ -57,6 +58,11 @@ Page({
57 oid: options.oid ? options.oid : '', 58 oid: options.oid ? options.oid : '',
58 rid: options.rid ? options.rid : '', 59 rid: options.rid ? options.rid : '',
59 sellerName: options.sellerName ? options.sellerName : '', 60 sellerName: options.sellerName ? options.sellerName : '',
  61 + givePrice: options.givePrice,
  62 + isFree: options.isFree, //当餐免费充值1
  63 + consume: options.consume, //当餐免费使用的消费金金额
  64 + activity_id: options.activity_id, //当餐免费使用的券ID
  65 + inputValue: options.inputValue, //当餐免费抵扣前的金额
60 }, 66 },
61 type: options.type, 67 type: options.type,
62 }) 68 })
@@ -66,14 +72,49 @@ Page({ @@ -66,14 +72,49 @@ Page({
66 if (obj) { 72 if (obj) {
67 this.setData({ 73 this.setData({
68 name: obj.name, 74 name: obj.name,
69 - date: obj.date,  
70 - phone: obj.phone, 75 + purePhoneNumber: obj.purePhoneNumber,
71 indexs: obj.sex * 1 - 1, 76 indexs: obj.sex * 1 - 1,
72 - calendarData: obj.calendarData,  
73 }) 77 })
74 } 78 }
75 this.modal = this.selectComponent("#payModal"); //通过给组件所起的id调用组件 79 this.modal = this.selectComponent("#payModal"); //通过给组件所起的id调用组件
76 this.getSellerTemplateConfFun(options.sid) 80 this.getSellerTemplateConfFun(options.sid)
  81 + this.getCheckUserHavePhone()
  82 + },
  83 + // 检测用户是否绑定手机号
  84 + getCheckUserHavePhone() {
  85 + App.Wechat.CheckUserHavePhone({
  86 + openid: getApp().openid,
  87 + }).then((json) => {
  88 + if (json.ret == 200) {
  89 + let data = json.data;
  90 + if (data && data.phone) {
  91 + this.setData({
  92 + purePhoneNumber: data.phone,
  93 + })
  94 + this.getInfo(data.phone)
  95 + } else {
  96 + this.setData({
  97 + purePhoneNumber: '',
  98 + })
  99 + }
  100 + }
  101 + })
  102 + },
  103 + // 获取code、手机号
  104 + getPhoneNumberFun(e) {
  105 + if (e.detail && e.detail.code) {
  106 + App.Wechat.GetUserPhoneNumber({
  107 + code: e.detail.code,
  108 + }).then(res => {
  109 + if (res.ret == 200 && res.data && res.data.phone_info && res.data.phone_info.purePhoneNumber) {
  110 + this.setData({
  111 + purePhoneNumber: res.data.phone_info.purePhoneNumber,
  112 + })
  113 + } else {
  114 + util.toast('手机号获取失败!', 'none')
  115 + }
  116 + })
  117 + }
77 }, 118 },
78 // 获取商家设置营销信息---获取模板 119 // 获取商家设置营销信息---获取模板
79 getSellerTemplateConfFun(sid){ 120 getSellerTemplateConfFun(sid){
@@ -97,7 +138,7 @@ Page({ @@ -97,7 +138,7 @@ Page({
97 showModal() { 138 showModal() {
98 this.modal.showModal() //调用组件中打开模态框方法 139 this.modal.showModal() //调用组件中打开模态框方法
99 }, 140 },
100 - confirmPayment(gid) { 141 + confirmPaymentFun(gid) {
101 let that = this; 142 let that = this;
102 App.PayOnline.CombineTransactionsByNewRecharge({ 143 App.PayOnline.CombineTransactionsByNewRecharge({
103 combine_out_trade_no: this.data.opt.combine_out_trade_no, 144 combine_out_trade_no: this.data.opt.combine_out_trade_no,
@@ -110,7 +151,7 @@ Page({ @@ -110,7 +151,7 @@ Page({
110 duration: 1000, 151 duration: 1000,
111 icon: 'none', 152 icon: 'none',
112 success: function () { 153 success: function () {
113 - console.log('支付失败', that.data.opt.types); 154 + console.log('支付失败1', that.data.opt.types);
114 that.callbackFun() 155 that.callbackFun()
115 } 156 }
116 }) 157 })
@@ -125,19 +166,20 @@ Page({ @@ -125,19 +166,20 @@ Page({
125 success(ress) { 166 success(ress) {
126 if (ress.errMsg == 'requestPayment:ok') { 167 if (ress.errMsg == 'requestPayment:ok') {
127 console.log('支付成功', ress); 168 console.log('支付成功', ress);
128 - return that.showModal() 169 + return that.addConsume()
129 } 170 }
130 - console.log('支付失败', ress); 171 + console.log('支付失败2', ress);
131 wx.showToast({ 172 wx.showToast({
132 title: '支付失败,请重新下单', 173 title: '支付失败,请重新下单',
133 duration: 1000, 174 duration: 1000,
  175 + icon: 'none',
134 success: function () { 176 success: function () {
135 that.callbackFun() 177 that.callbackFun()
136 } 178 }
137 }) 179 })
138 }, 180 },
139 fail(ress) { 181 fail(ress) {
140 - console.log('支付失败', ress); 182 + console.log('支付失败3', ress);
141 wx.showToast({ 183 wx.showToast({
142 title: '支付失败,请重新下单', 184 title: '支付失败,请重新下单',
143 duration: 1000, 185 duration: 1000,
@@ -152,9 +194,31 @@ Page({ @@ -152,9 +194,31 @@ Page({
152 } 194 }
153 }) 195 })
154 }, 196 },
  197 + // 支付成功 增加余额
  198 + addConsume() {
  199 + let givePrice = this.data.opt.givePrice * 1;
  200 + let totalize = this.data.opt.totalize * 1;
  201 + console.log('givePrice--', givePrice);
  202 + givePrice = givePrice ? givePrice : 0
  203 + console.log('givePrice22--', givePrice);
  204 + let recharge_balance = givePrice + totalize;
  205 + console.log('增加余额--------', recharge_balance);
  206 + App.Activity.SetRechargeBalanceByOpenid({
  207 + openid: getApp().openid,
  208 + recharge_balance,
  209 + sellerid: this.data.opt.sid,
  210 + type: '1',
  211 + }).then(res => {
  212 + if (res.ret == 200) {
  213 + console.log('充值成功');
  214 + this.showModal()
  215 + }
  216 + })
  217 + },
155 // 支付成功/失败回调 types 1邀请函 2提前点餐 3商家端app分享 4支付页充值 5我的页面余额充值 218 // 支付成功/失败回调 types 1邀请函 2提前点餐 3商家端app分享 4支付页充值 5我的页面余额充值
156 callbackFun() { 219 callbackFun() {
157 let that = this; 220 let that = this;
  221 + console.log('types---',that.data.opt.types);
158 let url = '/pack-invitation/pages/detail_owner_invitation1?id=' + that.data.opt.detail.oid; 222 let url = '/pack-invitation/pages/detail_owner_invitation1?id=' + that.data.opt.detail.oid;
159 if(that.data.opt.types == '1'){ 223 if(that.data.opt.types == '1'){
160 console.log('StyleType',this.data.StyleType); 224 console.log('StyleType',this.data.StyleType);
@@ -185,8 +249,11 @@ Page({ @@ -185,8 +249,11 @@ Page({
185 if (that.data.opt.types == '3') { 249 if (that.data.opt.types == '3') {
186 url = '/pages/reserve/index_new'; 250 url = '/pages/reserve/index_new';
187 } 251 }
188 - if (that.data.opt.types == '4' || this.data.opt.types == '5') {  
189 - return wx.navigateBack(2) 252 + if (that.data.opt.types == '4') {
  253 + url = `/pack-activity/pack/buyFreeCoupon?sid=${that.data.opt.sid}`;
  254 + }
  255 + if (that.data.opt.types == '5') {
  256 + return wx.navigateBack(3)
190 } 257 }
191 setTimeout(function () { 258 setTimeout(function () {
192 wx.reLaunch({ 259 wx.reLaunch({
@@ -213,7 +280,7 @@ Page({ @@ -213,7 +280,7 @@ Page({
213 bindKeyPhoneInput(event) { 280 bindKeyPhoneInput(event) {
214 const value = event.detail.value.replace(/\s+/g, ""); 281 const value = event.detail.value.replace(/\s+/g, "");
215 this.setData({ 282 this.setData({
216 - phone: value 283 + purePhoneNumber: value
217 }) 284 })
218 console.log(value); 285 console.log(value);
219 }, 286 },
@@ -235,11 +302,11 @@ Page({ @@ -235,11 +302,11 @@ Page({
235 util.toast('未填写姓名', 'none') 302 util.toast('未填写姓名', 'none')
236 return; 303 return;
237 } 304 }
238 - if (!data.phone) { 305 + if (!data.purePhoneNumber) {
239 util.toast('未填写手机号码', 'none') 306 util.toast('未填写手机号码', 'none')
240 return; 307 return;
241 } 308 }
242 - if (!/^1\d{10}$/.test(data.phone)) { 309 + if (!/^1\d{10}$/.test(data.purePhoneNumber)) {
243 util.toast('手机号码错误', 'none') 310 util.toast('手机号码错误', 'none')
244 return; 311 return;
245 } 312 }
@@ -251,38 +318,163 @@ Page({ @@ -251,38 +318,163 @@ Page({
251 }, 3500); 318 }, 3500);
252 return 319 return
253 } 320 }
254 - this.getInfo() 321 + let sex = this.data.indexs * 1 + 1; //1男 2女 3公司 4贵宾
  322 + let params = {
  323 + sellerid: this.data.opt.sid,
  324 + rname: this.data.name,
  325 + sex,
  326 + phone: this.data.purePhoneNumber,
  327 + }
  328 + if(data.showInfo == '1') {
  329 + if (this.data.purePhoneNumber == data.vipInfo.phone && this.data.name == data.vipInfo.rname && sex == data.vipInfo.sex) {
  330 + console.log('信息都一样,直接支付');
  331 + // 不是当餐免费
  332 + if(this.data.opt.isFree == '0') this.confirmPaymentFun(data.vipInfo.id)
  333 + // 是当餐免费
  334 + if(this.data.opt.isFree == '1') this.payFreeFun()
  335 + }else{
  336 + console.log({...params});
  337 + params.id=data.vipInfo.id;
  338 + console.log('要修改信息');
  339 + this.editInfo(params)
  340 + }
  341 + }else{
  342 + this.addInfo(params)
  343 + }
255 } else { 344 } else {
256 - this.confirmPayment() 345 + this.confirmPaymentFun()
257 } 346 }
258 }, 347 },
259 - getInfo() {  
260 - let sex = this.data.indexs * 1 + 1; //1男 2女 3公司 4贵宾 348 + getInfo(phone) {
261 App.GuestManage.GetIsMemberByPhone({ 349 App.GuestManage.GetIsMemberByPhone({
262 sid: this.data.opt.sid, 350 sid: this.data.opt.sid,
263 - phone: this.data.phone, 351 + phone,
264 }).then(res => { 352 }).then(res => {
265 console.log('用户是否录入',res); 353 console.log('用户是否录入',res);
266 - let params = {  
267 - sellerid: this.data.opt.sid,  
268 - rname: this.data.name,  
269 - sex,  
270 - phone: this.data.phone,  
271 - c_day: this.data.calendarData 354 + if(res.data && res.data.id){
  355 + this.setData({
  356 + purePhoneNumber:res.data.phone,
  357 + name:res.data.rname,
  358 + sex:res.data.sex,
  359 + indexs:res.data.sex*1-1,
  360 + showInfo:'1',//有会员信息
  361 + vipInfo:{
  362 + id:res.data.id,
  363 + phone:res.data.phone,
  364 + rname:res.data.rname,
  365 + sex:res.data.sex,
  366 + indexs:res.data.sex*1-1,
  367 + }
  368 + })
  369 + }else{
  370 + this.setData({
  371 + showInfo:'0',//无会员信息
  372 + vipInfo:{}
  373 + })
272 } 374 }
273 - console.log({...params});  
274 - if (res.data && res.data.id) {  
275 - if (this.data.phone == res.data.phone && this.data.name == res.data.rname && sex == res.data.sex && this.data.calendarData == res.data.c_day) {  
276 - console.log('信息都一样,直接支付');  
277 - this.confirmPayment(res.data.id)  
278 - } else {  
279 - params.id=res.data.id;  
280 - console.log('要修改信息');  
281 - this.editInfo(params)  
282 - }  
283 - } else {  
284 - console.log('没有客户信息,保存信息');  
285 - this.addInfo(params) 375 + })
  376 + },
  377 + // 当餐免费支付
  378 + payFreeFun: util.throttle(function () {
  379 + let that = this;
  380 + wx.showLoading({
  381 + title: '支付中',
  382 + })
  383 + App.PayOnline.CombineTransactionsByNewActivity({
  384 + sellerid:this.data.opt.sid,
  385 + price:this.data.opt.totalize,
  386 + openid:getApp().openid,
  387 + is_free:'1',
  388 + }).then(res=>{
  389 + console.log('付款信息', res.data);
  390 + if (res.ret != '200') {
  391 + wx.hideLoading()
  392 + wx.showToast({
  393 + title: res.msg,
  394 + duration: 1000,
  395 + icon: 'none',
  396 + })
  397 + setTimeout(function () {
  398 + wx.reLaunch({
  399 + url:`/pack-activity/pack/buyFreeCoupon?sid=${that.data.opt.sid}`
  400 + })
  401 + }, 1000);
  402 + }
  403 + if (res.ret == '200') {
  404 + wx.requestPayment({
  405 + timeStamp: res.data.timeStamp + '',
  406 + nonceStr: res.data.nonceStr,
  407 + package: res.data.package,
  408 + signType: res.data.signType,
  409 + paySign: res.data.paySign,
  410 + success(ress) {
  411 + wx.hideLoading()
  412 + if (ress.errMsg == 'requestPayment:ok') {
  413 + that.submitFreeOrder()// 当餐免费充值完成后,提交订单
  414 + that.addConsume()// 当餐免费充值完成后,增加余额
  415 + console.log('支付成功', ress);
  416 + return
  417 + }
  418 + console.log('支付失败11', ress);
  419 + return wx.showToast({
  420 + title: '支付失败,请重新下单',
  421 + duration: 1000,
  422 + icon: 'none',
  423 + success: function () {
  424 + that.callbackFun()
  425 + }
  426 + })
  427 + },
  428 + fail(ress) {
  429 + wx.hideLoading()
  430 + console.log('支付失败22', ress);
  431 + return wx.showToast({
  432 + title: '支付失败,请重新下单',
  433 + duration: 1000,
  434 + icon: 'none',
  435 + success: function () {
  436 + that.callbackFun()
  437 + }
  438 + })
  439 + },
  440 + })
  441 + }
  442 + })
  443 + },3000),
  444 + // 当餐免费充值完成后,提交订单
  445 + submitFreeOrder(){
  446 + let params ={
  447 + openid:getApp().openid,
  448 + sellerid:this.data.opt.sid,
  449 + price:this.data.opt.inputValue,
  450 + phone:this.data.purePhoneNumber,
  451 + is_free:'1',
  452 + recharge_amount:this.data.opt.totalize,
  453 + }
  454 + if (this.data.opt.consume*1>0) {
  455 + params.consume = this.data.opt.consume;
  456 + }
  457 + if (this.data.opt.activity_id) {
  458 + params.activity_id = this.data.opt.activity_id;
  459 + }
  460 + App.Activity.CreateRechargeBalanceOrder({
  461 + ...params
  462 + }).then(res => {
  463 + console.log('付款信息', res.data);
  464 + if (res.ret != '200') {
  465 + wx.hideLoading()
  466 + return wx.showToast({
  467 + title: res.msg,
  468 + duration: 1000,
  469 + icon: 'none',
  470 + })
  471 + }
  472 + if (res.ret == '200') {
  473 + console.log('resresresres-----',res);
  474 + wx.reLaunch({
  475 + url: '/pack-activity/pack/paySuccess'
  476 + })
  477 + console.log('支付成功', res);
286 } 478 }
287 }) 479 })
288 }, 480 },
@@ -290,7 +482,10 @@ Page({ @@ -290,7 +482,10 @@ Page({
290 editInfo(params) { 482 editInfo(params) {
291 App.GuestManage.SetGuestInfo(params).then(res => { 483 App.GuestManage.SetGuestInfo(params).then(res => {
292 if (res.data) { 484 if (res.data) {
293 - this.confirmPayment(params.id) 485 + // 不是当餐免费
  486 + if(!this.data.opt.isFree) this.confirmPaymentFun(params.id)
  487 + // 是当餐免费
  488 + if(this.data.opt.isFree == '1') this.payFreeFun()
294 } 489 }
295 }) 490 })
296 }, 491 },
@@ -300,25 +495,17 @@ Page({ @@ -300,25 +495,17 @@ Page({
300 if (res.ret == '200' && res.data && res.data.id) { 495 if (res.ret == '200' && res.data && res.data.id) {
301 let obj = { 496 let obj = {
302 name: this.data.name, 497 name: this.data.name,
303 - phone: this.data.phone, 498 + purePhoneNumber: this.data.purePhoneNumber,
304 sex: this.data.indexs * 1 + 1, 499 sex: this.data.indexs * 1 + 1,
305 - calendarData: this.data.calendarData,  
306 - date: this.data.date,  
307 } 500 }
308 wx.setStorageSync('info', obj) 501 wx.setStorageSync('info', obj)
309 - this.confirmPayment(res.data.id) 502 + // 不是当餐免费
  503 + if(!this.data.opt.isFree) this.confirmPaymentFun(res.data.id)
  504 + // 是当餐免费
  505 + if(this.data.opt.isFree == '1') this.payFreeFun()
310 } 506 }
311 }) 507 })
312 }, 508 },
313 - // 选择日期  
314 - bind_ChangeDate(event) {  
315 - let date = event.detail.value  
316 - var calendarData = new Date(date) * 1 / 1000;  
317 - this.setData({  
318 - date,  
319 - calendarData  
320 - })  
321 - },  
322 // 选择性别 509 // 选择性别
323 bind_Changesex(event) { 510 bind_Changesex(event) {
324 console.log('event.detail',{...event.detail}); 511 console.log('event.detail',{...event.detail});
@@ -383,8 +570,11 @@ Page({ @@ -383,8 +570,11 @@ Page({
383 url: '/pages/reserve/index_new', 570 url: '/pages/reserve/index_new',
384 }) 571 })
385 } 572 }
386 - if (this.data.opt.types == '4' || this.data.opt.types == '5') {  
387 - wx.navigateBack(2) 573 + if (this.data.opt.types == '4') {
  574 + return wx.navigateBack(2)
  575 + }
  576 + if (this.data.opt.types == '5') {
  577 + return wx.navigateBack(2)
388 } 578 }
389 }, 579 },
390 /** 580 /**
@@ -15,38 +15,30 @@ @@ -15,38 +15,30 @@
15 <view wx:if="{{type=='2'}}" class="coupon"> 15 <view wx:if="{{type=='2'}}" class="coupon">
16 <form catchsubmit="formSubmit"> 16 <form catchsubmit="formSubmit">
17 <view class="page-section"> 17 <view class="page-section">
18 - <view class="page-section-title font32r">您的姓名</view> 18 + <view class="page-section-title font28r">您的姓名</view>
19 <view class="weui-cells weui-cell__bd" style="margin: 30rpx 0"> 19 <view class="weui-cells weui-cell__bd" style="margin: 30rpx 0">
20 <input class="weui-input name-input" value="{{name}}" data-params="name" placeholder="点击输入您的姓名" placeholder-style="color:#999;" bindinput="bindKeyNameInput"/> 20 <input class="weui-input name-input" value="{{name}}" data-params="name" placeholder="点击输入您的姓名" placeholder-style="color:#999;" bindinput="bindKeyNameInput"/>
21 </view> 21 </view>
22 <picker mode="selector" value="{{indexs}}" range-key="sex" data-sex='{{sexList[indexs].sex}}' range="{{sexList}}" bindchange="bind_Changesex" class="pickerSex"> 22 <picker mode="selector" value="{{indexs}}" range-key="sex" data-sex='{{sexList[indexs].sex}}' range="{{sexList}}" bindchange="bind_Changesex" class="pickerSex">
23 - <text class="sexText">{{sexList[indexs].sex}}</text>  
24 - <image src="https://qn.colorcun.com/WechatIMG695.png" mode="" class="imgs"/> 23 + <text class="sexText font28r">{{sexList[indexs].sex}}</text>
  24 + <image src="https://qn.colorcun.com/selectImg.png" mode="" class="imgs"/>
25 </picker> 25 </picker>
26 </view> 26 </view>
27 <view class="page-section"> 27 <view class="page-section">
28 - <view class="page-section-title font32r">联系电话</view> 28 + <view class="page-section-title font28r">联系电话</view>
29 <view class="weui-cells weui-cell__bd" style="margin: 30rpx 0"> 29 <view class="weui-cells weui-cell__bd" style="margin: 30rpx 0">
30 - <input class="weui-input" type="number" name="phone" value="{{phone}}" data-params="phone" maxlength="11" placeholder="点击输入您的电话" placeholder-style="color:#999;" bindinput="bindKeyPhoneInput" style="color: #999" />  
31 - </view>  
32 - </view>  
33 - <view class="page-section page-section1">  
34 - <view class="page-section-title font32r">您的生日</view>  
35 - <view class="weui-cells weui-cell__bd">  
36 - <picker mode="date" value="{{date}}" bindchange="bind_ChangeDate" class="pickerBox">  
37 - <view class="colorSty">{{date?date:'点击输入您的生日'}}</view>  
38 - </picker>  
39 - </view>  
40 - <view class="more"></view> 30 + <input disabled class="weui-input" type="number" name="purePhoneNumber" value="{{purePhoneNumber}}" data-params="phone" maxlength="11" placeholder="点击输入您的电话" placeholder-style="color:#999;" bindinput="bindKeyPhoneInput" style="color: #000" />
  31 + <button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumberFun" class="getPhoneBtn">获取手机号</button>
  32 + </view>
41 </view> 33 </view>
42 <view class="page-section"> 34 <view class="page-section">
43 - <view class="page-section-title font32r">充值金额</view> 35 + <view class="page-section-title font28r">充值金额</view>
44 <view class="weui-cells weui-cell__bd sum colorSty"> 36 <view class="weui-cells weui-cell__bd sum colorSty">
45 - {{opt.detail.recharge_money}}元 37 + {{opt.detail.recharge_money?opt.detail.recharge_money:opt.totalize}}元
46 </view> 38 </view>
47 </view> 39 </view>
48 <view wx:if="{{type=='2'}}" class="fixed_box"> 40 <view wx:if="{{type=='2'}}" class="fixed_box">
49 - <button class="font32r btns" formType="submit">确认支付 41 + <button class="font28r btns" formType="submit">确认支付
50 </button> 42 </button>
51 </view> 43 </view>
52 </form> 44 </form>
@@ -60,9 +52,9 @@ @@ -60,9 +52,9 @@
60 <view slot="modalName" class="titleModal">成功支付{{opt.totalize}}元</view> 52 <view slot="modalName" class="titleModal">成功支付{{opt.totalize}}元</view>
61 <view slot="modalContent"> 53 <view slot="modalContent">
62 <block wx:if="{{type=='2'}}"> 54 <block wx:if="{{type=='2'}}">
63 - <view class="explain"> 55 + <!-- <view class="explain">
64 您的会员充值已经在办理中,到店消费时请和收银核实,谢谢! 56 您的会员充值已经在办理中,到店消费时请和收银核实,谢谢!
65 - </view> 57 + </view> -->
66 <button wx:if="{{type=='2'}}" class="font32r btnsPay" bindtap="recharge">朕知道了 58 <button wx:if="{{type=='2'}}" class="font32r btnsPay" bindtap="recharge">朕知道了
67 </button> 59 </button>
68 </block> 60 </block>
@@ -61,7 +61,7 @@ @@ -61,7 +61,7 @@
61 margin: 0; 61 margin: 0;
62 border-radius: 42rpx; 62 border-radius: 42rpx;
63 color: #fff; 63 color: #fff;
64 - background: linear-gradient(104.24deg, #4c8dad -57.47%, #0143a3 55.72%, #42a5ff 148.72%); 64 + background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
65 } 65 }
66 66
67 #payModal { 67 #payModal {
@@ -98,7 +98,7 @@ @@ -98,7 +98,7 @@
98 display: flex; 98 display: flex;
99 justify-content: space-between; 99 justify-content: space-between;
100 align-items: center; 100 align-items: center;
101 - border-bottom: 2rpx solid #E7E7E7; 101 + border-bottom: 2rpx solid #F7F7F7;
102 } 102 }
103 103
104 .page-section1 .more { 104 .page-section1 .more {
@@ -106,7 +106,22 @@ @@ -106,7 +106,22 @@
106 } 106 }
107 107
108 .weui-cells { 108 .weui-cells {
109 - flex: 1; 109 + flex: 1;
  110 + display: flex;
  111 + align-items: center;
  112 + justify-content: flex-end;
  113 +}
  114 +
  115 +.getPhoneBtn {
  116 + margin: 0;
  117 + margin-right: 30rpx;
  118 + padding: 0 20rpx;
  119 + border-radius: 198rpx;
  120 + font-family: "PingFang SC";
  121 + font-weight: 600;
  122 + font-size: 24rpx;
  123 + color: #fff;
  124 + background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
110 } 125 }
111 126
112 .page-section-title { 127 .page-section-title {
@@ -122,7 +137,8 @@ @@ -122,7 +137,8 @@
122 } 137 }
123 .name-input{ 138 .name-input{
124 margin-right: 0; 139 margin-right: 0;
125 - text-align: left; 140 + text-align: left;
  141 + flex: 1;
126 } 142 }
127 143
128 144
@@ -151,18 +167,20 @@ @@ -151,18 +167,20 @@
151 } 167 }
152 168
153 .colorSty{ 169 .colorSty{
154 - color: #999999; 170 + color: #000;
155 font-size: 32rpx; 171 font-size: 32rpx;
156 } 172 }
157 173
158 -.pickerSex image{  
159 - width: 48rpx;  
160 - height: 48rpx;  
161 - margin-right: 30rpx; 174 +.pickerSex {
  175 + display: flex;
  176 + align-items: center;
  177 + justify-content: center;
162 } 178 }
163 -.sexText{  
164 - position: relative;  
165 - top: -10rpx; 179 +
  180 +.pickerSex image{
  181 + width: 24rpx;
  182 + height: 24rpx;
  183 + margin: 0 30rpx 0 2rpx;
166 } 184 }
167 185
168 .bottom_box { 186 .bottom_box {
@@ -13,6 +13,7 @@ Page({ @@ -13,6 +13,7 @@ Page({
13 * 生命周期函数--监听页面加载 13 * 生命周期函数--监听页面加载
14 */ 14 */
15 onLoad(options) { 15 onLoad(options) {
  16 + console.log('options',options);
16 this.setData({ 17 this.setData({
17 totalPrice: options.totalPrice ? options.totalPrice : '', 18 totalPrice: options.totalPrice ? options.totalPrice : '',
18 totalConsumePrice: options.totalConsumePrice ? options.totalConsumePrice : '', 19 totalConsumePrice: options.totalConsumePrice ? options.totalConsumePrice : '',
@@ -31,7 +32,7 @@ Page({ @@ -31,7 +32,7 @@ Page({
31 // 跳转到我的消费金列表 32 // 跳转到我的消费金列表
32 gotoConsumeList() { 33 gotoConsumeList() {
33 wx.reLaunch({ 34 wx.reLaunch({
34 - url: '/pages/me/consumeAmount' 35 + url: '/pages/me/consumeAmount?type=1'
35 }) 36 })
36 }, 37 },
37 /** 38 /**
@@ -5,14 +5,13 @@ @@ -5,14 +5,13 @@
5 <view class="nameInfo font40r">支付成功</view> 5 <view class="nameInfo font40r">支付成功</view>
6 <view class="couponTotal" wx:if="{{totalPrice && totalPrice>0}}">赠送给您<text>{{totalPrice}}元</text>代金券</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> 7 <view class="couponTotal" wx:if="{{totalConsumePrice && totalConsumePrice>0}}">为您返还消费金¥{{totalConsumePrice}}</view>
8 - <view class="couponInfo font24r">您到店扫码支付即可自动使用</view> 8 + <view class="couponInfo font24r" wx:if="{{(totalConsumePrice && totalConsumePrice>0) || (totalPrice && totalPrice>0)}}">您到店扫码支付即可自动使用</view>
9 <view class="btnBox"> 9 <view class="btnBox">
10 <subscribe ids="{{[2]}}"> 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> 11 + <view class="btnBoxs">
  12 + <view wx:if="{{totalConsumePrice && totalConsumePrice>0}}" bindtap="gotoConsumeList" class="couponBtn1 font36r">查看消费金</view>
  13 + <view wx:if="{{totalPrice && totalPrice>0}}" bindtap="certificate" class="couponBtn1 font36r">查看优惠券</view>
14 </view> 14 </view>
15 - <view wx:else bindtap="closePage" class="couponBtn font36r">开心收下</view>  
16 </subscribe> 15 </subscribe>
17 </view> 16 </view>
18 </view> 17 </view>
@@ -19,6 +19,8 @@ Page({ @@ -19,6 +19,8 @@ Page({
19 detail:{}, 19 detail:{},
20 recharge_list:{}, 20 recharge_list:{},
21 StyleType:'',//邀请函模板 21 StyleType:'',//邀请函模板
  22 + multiple: '',//充值倍数
  23 + recharge_list: {},//充值赠送信息
22 }, 24 },
23 25
24 /** 26 /**
@@ -35,6 +37,13 @@ Page({ @@ -35,6 +37,13 @@ Page({
35 types:options.types, 37 types:options.types,
36 rid:options.rid?options.rid:'', 38 rid:options.rid?options.rid:'',
37 StyleType:options.StyleType|| '1', 39 StyleType:options.StyleType|| '1',
  40 + isFree:options.isFree,
  41 + multiple:options.multiple,
  42 + inputValue:options.inputValue,
  43 + totalize:options.totalize,
  44 + consume:options.consume,
  45 + activity_id:options.activity_id,
  46 + givePrice:options.givePrice,
38 } 47 }
39 }) 48 })
40 console.log('onLoad',{...this.data.opt}); 49 console.log('onLoad',{...this.data.opt});
@@ -44,14 +53,14 @@ Page({ @@ -44,14 +53,14 @@ Page({
44 * 生命周期函数--监听页面初次渲染完成 53 * 生命周期函数--监听页面初次渲染完成
45 */ 54 */
46 onReady() { 55 onReady() {
47 - this.getDetail();  
48 }, 56 },
49 57
50 /** 58 /**
51 * 生命周期函数--监听页面显示 59 * 生命周期函数--监听页面显示
52 */ 60 */
53 onShow() { 61 onShow() {
54 - 62 + if(this.data.opt.id) this.getDetail();
  63 + if(this.data.opt.isFree == '1') this.getFreeMealConfigFun()
55 }, 64 },
56 65
57 /** 66 /**
@@ -60,6 +69,27 @@ Page({ @@ -60,6 +69,27 @@ Page({
60 onHide() { 69 onHide() {
61 70
62 }, 71 },
  72 + // 获取当餐免费的配置信息
  73 + getFreeMealConfigFun() {
  74 + App.Activity.GetFreeMealConfigBySeller({
  75 + sellerid: this.data.opt.sid,
  76 + }).then(res => {
  77 + if (res && res.data && res.data.length > 0 && res.data[0].is_open == '1') {
  78 + let data = res.data[0];
  79 + let list = data.recharge_list ? JSON.parse(data.recharge_list) : {}
  80 + list.explain = data.explain;
  81 + this.setData({
  82 + multiple: data.multiple,
  83 + recharge_list: list
  84 + })
  85 + } else {
  86 + this.setData({
  87 + multiple: '',
  88 + recharge_list: {}
  89 + })
  90 + }
  91 + })
  92 + },
63 getDetail(){ 93 getDetail(){
64 App.Activity.GetNewRecharge({ 94 App.Activity.GetNewRecharge({
65 id: this.data.opt.id 95 id: this.data.opt.id
@@ -83,11 +113,29 @@ Page({ @@ -83,11 +113,29 @@ Page({
83 url: `./receiveCoupon?id=${item.id}&name=${this.data.opt.name}&types=5&sid=${this.data.opt.sid}`, 113 url: `./receiveCoupon?id=${item.id}&name=${this.data.opt.name}&types=5&sid=${this.data.opt.sid}`,
84 }) 114 })
85 }, 115 },
  116 + gotoPay() {
  117 + let url = util.http_build_query({
  118 + type: '2',
  119 + types: this.data.opt.types, // 1邀请函 2提前点餐 3商家端app分享 4支付页充值 5我的页面余额充值
  120 + sid: this.data.opt.sid,
  121 + totalize: this.data.opt.totalize,
  122 + sellerName: this.data.opt.name,
  123 + givePrice: this.data.opt.givePrice,
  124 + isFree: this.data.opt.isFree,
  125 + inputValue: this.data.opt.inputValue,
  126 + multiple: this.data.opt.multiple,
  127 + consume: this.data.opt.consume,
  128 + activity_id: this.data.opt.activity_id,
  129 + }, './confirmPayment')
  130 + wx.navigateTo({
  131 + url
  132 + })
  133 + },
86 submitOrder(){ 134 submitOrder(){
  135 + if(this.data.opt.isFree == '1') return this.gotoPay()
87 console.log('oidoid',this.data.opt.oid); 136 console.log('oidoid',this.data.opt.oid);
88 let detail=this.data.detail 137 let detail=this.data.detail
89 - detail.name=this.data.opt.name;  
90 - detail.oid=this.data.opt.oid; 138 + if(this.data.opt.oid) detail.oid = this.data.opt.oid
91 App.Activity.CreateNewRechargeOrder({ 139 App.Activity.CreateNewRechargeOrder({
92 recharge_id:this.data.opt.id, 140 recharge_id:this.data.opt.id,
93 sellerid:this.data.opt.sid, 141 sellerid:this.data.opt.sid,
@@ -96,6 +144,7 @@ Page({ @@ -96,6 +144,7 @@ Page({
96 type:'2', 144 type:'2',
97 }).then(res=>{ 145 }).then(res=>{
98 if(res.ret=='200'){ 146 if(res.ret=='200'){
  147 + let price = this.data.recharge_list.price*1
99 let url = util.http_build_query({ 148 let url = util.http_build_query({
100 type:'2', 149 type:'2',
101 types: this.data.opt.types,// 1邀请函 2提前点餐 3商家端app分享 4支付页充值 5我的页面余额充值 150 types: this.data.opt.types,// 1邀请函 2提前点餐 3商家端app分享 4支付页充值 5我的页面余额充值
@@ -107,6 +156,8 @@ Page({ @@ -107,6 +156,8 @@ Page({
107 oid: this.data.opt.oid, 156 oid: this.data.opt.oid,
108 rid:this.data.opt.rid?this.data.opt.rid:'', 157 rid:this.data.opt.rid?this.data.opt.rid:'',
109 StyleType:this.data.opt.StyleType, 158 StyleType:this.data.opt.StyleType,
  159 + givePrice:price>0?price:0,
  160 + isFree:this.data.opt.isFree,
110 }, './confirmPayment') 161 }, './confirmPayment')
111 wx.navigateTo({ 162 wx.navigateTo({
112 url 163 url
1 <!--pack-activity/pack/vipRecharge.wxml--> 1 <!--pack-activity/pack/vipRecharge.wxml-->
2 <wxs src="../../utils/util.wxs" module="util" /> 2 <wxs src="../../utils/util.wxs" module="util" />
3 -<nav>{{opt.name}}</nav> 3 +<nav>充值详情</nav>
4 <view class="wrapBox"> 4 <view class="wrapBox">
5 <view class="info"> 5 <view class="info">
6 <view class="info_left font32r"> 6 <view class="info_left font32r">
7 活动名称 7 活动名称
8 </view> 8 </view>
9 <view class="info_right text_info font32r"> 9 <view class="info_right text_info font32r">
10 - {{detail.rname}} 10 + {{opt.isFree == '1'? '当餐免费' : detail.rname}}
11 </view> 11 </view>
12 </view> 12 </view>
13 <view class="info"> 13 <view class="info">
14 <view class="info_left font32r"> 14 <view class="info_left font32r">
15 - 充值满 15 + {{opt.isFree == '1'? '充值实际消费金额的倍数':'充值满'}}
16 </view> 16 </view>
17 <view class="info_right text_info font32r"> 17 <view class="info_right text_info font32r">
18 - {{detail.recharge_money}} 18 + {{opt.isFree == '1'? multiple:detail.recharge_money}}
19 </view> 19 </view>
20 </view> 20 </view>
21 <view class="favourable_box"> 21 <view class="favourable_box">
@@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
23 优惠活动 23 优惠活动
24 </view> 24 </view>
25 <view class="bundle" wx:if="{{recharge_list.is_price=='1'}}"> 25 <view class="bundle" wx:if="{{recharge_list.is_price=='1'}}">
26 - <view class="bundle_left font30r"> 26 + <view class="bundle_left font28r">
27 赠送 27 赠送
28 </view> 28 </view>
29 <view class="bundle_right font30r"> 29 <view class="bundle_right font30r">
@@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
31 </view> 31 </view>
32 </view> 32 </view>
33 <view class="bundle" wx:if="{{recharge_list.is_score=='1'}}"> 33 <view class="bundle" wx:if="{{recharge_list.is_score=='1'}}">
34 - <view class="bundle_left font30r"> 34 + <view class="bundle_left font28r">
35 赠送 35 赠送
36 </view> 36 </view>
37 <view class="bundle_right font30r"> 37 <view class="bundle_right font30r">
@@ -39,7 +39,7 @@ @@ -39,7 +39,7 @@
39 </view> 39 </view>
40 </view> 40 </view>
41 <view class="bundle" wx:if="{{recharge_list.is_coupons=='1'}}"> 41 <view class="bundle" wx:if="{{recharge_list.is_coupons=='1'}}">
42 - <view class="bundle_left font30r"> 42 + <view class="bundle_left font28r">
43 赠送 43 赠送
44 </view> 44 </view>
45 <view class="bundle_right font30r"> 45 <view class="bundle_right font30r">
@@ -52,55 +52,12 @@ @@ -52,55 +52,12 @@
52 {{item.aname}} 52 {{item.aname}}
53 </view> 53 </view>
54 </view> 54 </view>
55 - <view class="week" wx:if="{{exp_date.is_week=='1' || exp_date.is_week===true}}">  
56 - <view class="week_top">  
57 - <view class="week_left font32r">  
58 - 充值日期限制:  
59 - </view>  
60 - <view class="texts font32r">  
61 - 每周指定日期可用  
62 - </view>  
63 - </view>  
64 - <view class="dateList texts font32r">  
65 - {{exp_date.week_date_show}}  
66 - </view>  
67 - </view>  
68 - <view class="week" wx:if="{{exp_date.is_birthday=='1' || exp_date.is_birthday===true}}">  
69 - <view class="week_top">  
70 - <view class="week_left font32r">  
71 - 充值日期限制:  
72 - </view>  
73 - <view class="texts font32r">  
74 - 会员生日当天  
75 - </view>  
76 - </view>  
77 - </view>  
78 - <view class="week" wx:if="{{exp_date.is_fix=='1' || exp_date.is_fix===true}}">  
79 - <view class="week_top">  
80 - <view class="week_left font32r">  
81 - 充值日期限制:  
82 - </view>  
83 - <view class="texts font32r">  
84 - 无  
85 - </view>  
86 - </view>  
87 - </view>  
88 - <view class="week" wx:if="{{exp_date.is_fix=='1' || exp_date.is_fix===true}}">  
89 - <view class="week_top">  
90 - <view class="week_left font32r">  
91 - 有效期:  
92 - </view>  
93 - <view class="texts font32r">  
94 - {{util.unixtoTime(detail.stime,'YYYY-MM-DD')+'至'+util.unixtoTime(detail.etime,'YYYY-MM-DD')}}  
95 - </view>  
96 - </view>  
97 - </view>  
98 <view class="info"> 55 <view class="info">
99 <view class="info_left font32r"> 56 <view class="info_left font32r">
100 备注 57 备注
101 </view> 58 </view>
102 </view> 59 </view>
103 - <text class="explain_news">{{detail.explain}}</text> 60 + <text class="explain_news">{{opt.isFree == '1'? recharge_list.explain:detail.explain}}</text>
104 </view> 61 </view>
105 <view class="fixed_box"> 62 <view class="fixed_box">
106 <button class="font32r btns" bindtap="submitOrder">提交充值 63 <button class="font32r btns" bindtap="submitOrder">提交充值
@@ -13,7 +13,7 @@ page { @@ -13,7 +13,7 @@ page {
13 display: flex; 13 display: flex;
14 justify-content: space-between; 14 justify-content: space-between;
15 margin-left: 32rpx; 15 margin-left: 32rpx;
16 - border-bottom: 2rpx solid #E7E7E7; 16 + border-bottom: 2rpx solid #F7F7F7;
17 } 17 }
18 18
19 .info1 { 19 .info1 {
@@ -26,7 +26,7 @@ page { @@ -26,7 +26,7 @@ page {
26 .info_left { 26 .info_left {
27 flex-shrink: 0; 27 flex-shrink: 0;
28 margin-right: 20rpx; 28 margin-right: 20rpx;
29 - color: #515151; 29 + color: #696969;
30 font-family: PingFang SC; 30 font-family: PingFang SC;
31 } 31 }
32 32
@@ -44,9 +44,9 @@ page { @@ -44,9 +44,9 @@ page {
44 44
45 .explain_news { 45 .explain_news {
46 padding: 24rpx 32rpx; 46 padding: 24rpx 32rpx;
47 - color: #999999; 47 + color: #696969;
48 font-family: PingFang SC; 48 font-family: PingFang SC;
49 - font-size: 24rpx; 49 + font-size: 28rpx;
50 line-height: 48rpx; 50 line-height: 48rpx;
51 display: block; 51 display: block;
52 } 52 }
@@ -75,7 +75,7 @@ page { @@ -75,7 +75,7 @@ page {
75 border-radius: 42rpx; 75 border-radius: 42rpx;
76 width: 100%; 76 width: 100%;
77 color: #fff; 77 color: #fff;
78 - background: linear-gradient(104.24deg, #4c8dad -57.47%, #0143a3 55.72%, #42a5ff 148.72%); 78 + background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
79 } 79 }
80 80
81 .favourable_box { 81 .favourable_box {
@@ -99,26 +99,27 @@ page { @@ -99,26 +99,27 @@ page {
99 } 99 }
100 100
101 .bundle_left { 101 .bundle_left {
102 - color: #515151; 102 + color: #696969;
103 font-family: PingFang SC; 103 font-family: PingFang SC;
104 } 104 }
105 105
106 .bundle_right { 106 .bundle_right {
107 - color: #999; 107 + color: #000;
108 font-family: PingFang SC; 108 font-family: PingFang SC;
109 } 109 }
110 110
111 .list { 111 .list {
112 margin: 0 32rpx; 112 margin: 0 32rpx;
113 display: flex; 113 display: flex;
114 - align-items: center; 114 + align-items: center;
  115 + justify-content: flex-end;
115 flex-wrap: wrap; 116 flex-wrap: wrap;
116 border-bottom: 2rpx solid #dbdbdb; 117 border-bottom: 2rpx solid #dbdbdb;
117 padding-left: 32rpx; 118 padding-left: 32rpx;
118 } 119 }
119 120
120 .item { 121 .item {
121 - color: #0143a3; 122 + color: #e75f2e;
122 font-family: PingFang SC; 123 font-family: PingFang SC;
123 margin-right: 18rpx; 124 margin-right: 18rpx;
124 padding-bottom: 24rpx; 125 padding-bottom: 24rpx;
@@ -168,8 +168,6 @@ Page({ @@ -168,8 +168,6 @@ Page({
168 util.toast('手机号获取失败!', 'none') 168 util.toast('手机号获取失败!', 'none')
169 } 169 }
170 }) 170 })
171 - } else {  
172 - util.toast('手机号获取失败!', 'none')  
173 } 171 }
174 }, 172 },
175 // 用户绑定手机号 173 // 用户绑定手机号
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 <view class="rechargeItems rechargeItems1"> 24 <view class="rechargeItems rechargeItems1">
25 <text class="font36r">¥</text><input class="font28r" maxlength="5" type="number" placeholder="输入自定义金额" /> 25 <text class="font36r">¥</text><input class="font28r" maxlength="5" type="number" placeholder="输入自定义金额" />
26 </view> 26 </view>
27 - <view class="infoAgreement font24r">充值即代表同意<text>《用户协议》</text>及<text>《会员充值协议》</text></view> 27 + <!-- <view class="infoAgreement font24r">充值即代表同意<text>《用户协议》</text>及<text>《会员充值协议》</text></view> -->
28 </view> 28 </view>
29 <view class="payBtnBox"> 29 <view class="payBtnBox">
30 <view class="payBtn font32r" bindtap="confirmPayment">提交充值</view> 30 <view class="payBtn font32r" bindtap="confirmPayment">提交充值</view>
@@ -914,5 +914,28 @@ export default { @@ -914,5 +914,28 @@ export default {
914 //获取用户消费金消费记录 914 //获取用户消费金消费记录
915 'App.Activity.GetConsumeListByOpenid':{ 915 'App.Activity.GetConsumeListByOpenid':{
916 }, 916 },
917 - 917 +
  918 + //获取用户在商家的账户余额
  919 + 'App.Activity.GetRechargeBalanceByOpenid':{
  920 + },
  921 +
  922 + //新增用户在商家的账户信息
  923 + 'App.Activity.CreateCustomerConsumeSeller':{
  924 + },
  925 +
  926 + //修改用户在商家的账户余额
  927 + 'App.Activity.SetRechargeBalanceByOpenid':{
  928 + },
  929 +
  930 + //使用余额支付订单
  931 + 'App.Activity.CreateRechargeBalanceOrder':{
  932 + },
  933 +
  934 + //获取当餐免费的配置信息
  935 + 'App.Activity.GetFreeMealConfigBySeller':{
  936 + },
  937 +
  938 + //获取用户在当前商家身份及是否领取过消费金
  939 + 'App.Activity.GetIdentityBySeller':{
  940 + },
918 } 941 }