Commit c56f0dffd5a6af7dd9f1da0118dacdea33ef475e

Authored by pengye
1 parent 5e017fc9

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

... ... @@ -29,22 +29,37 @@ Page({
noConfiguration: '', //配置消费金 0未配置 1已配置
returnData: '', //赠送消费金配置
isReturn: '', //赠送消费金的开关
giveConsumePrice: '', //新老用户赠送消费金额
isNewUser: '',//新用户1 老用户2
recharge_data: [], //所有满赠充值活动
payType: '2', //1余额支付 2微信支付
multiple: '', //充值几倍当餐免费
rechargeList:{},
myBalance: '', //店铺总余额
balancePay: '', //余额支付金额
soothPrice: '', //实付价格-余额的价格
countDown: '5', //5秒后自动关闭弹框
timer: null,
},
sid: '', //扫码进入带的参数商家id
couponModal: '',
giveCouponModal: '',
consumeModal: '',
giveConsume: '',
myToast:'',
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log('options----', options);
this.couponModal = this.selectComponent("#couponModal");
this.giveCouponModal = this.selectComponent("#giveCouponModal");
this.consumeModal = this.selectComponent("#consumeModal");
this.giveConsume = this.selectComponent("#giveConsume");
if (options.sid) {
this.sid = options.sid
this.getSellerDetailFun(options.sid)
this.getRechargeDetail(options.sid)
}
},
// 检测用户是否绑定手机号
... ... @@ -59,7 +74,9 @@ Page({
purePhoneNumber: data.phone,
})
this.getUserInfo()
this.getUserRechargeInfo(data.phone, '0')
} else {
this.getUserInfo()
this.setData({
purePhoneNumber: '',
})
... ... @@ -67,6 +84,113 @@ Page({
}
})
},
// 切换支付方式
checkPay(e) {
let type = e.currentTarget.dataset['type'];
let actualPrice = this.data.actualPrice;
if (type == '1') {
let myBalance = this.data.myBalance * 1;
if (actualPrice && actualPrice > 0) {
let balancePay = actualPrice > myBalance ? myBalance : actualPrice;
let soothPrice = (actualPrice - balancePay).toFixed(2)
this.setData({
balancePay,
soothPrice,
})
}
} else {
this.setData({
balancePay: '0.00',
soothPrice: actualPrice,
})
}
this.setData({
payType: type,
})
},
// 根据充值ID获取充值详情
getRechargeDetail(sellerid) {
App.Activity.GetNewRechargeList({
sellerid,
}).then(res => {
if (res.data) {
let arr = []
res.data.forEach(i => {
if (i.status != '1') {
arr.push(i)
}
})
let recharge_data = arr;
recharge_data.forEach(item => {
item.recharge_list = item.recharge_list ? JSON.parse(item.recharge_list) : '';
let recharge_list = item.recharge_list;
item.timeStr = util.unixtoTime(item.stime, 'YYYY-MM-DD') + ' - ' + util.unixtoTime(item.etime, 'YYYY-MM-DD')
})
// 筛选出 未过期的 && 开启状态的充值活动
recharge_data = recharge_data.filter(item => {
return this.data.dataStr < (item.etime * 1) && item.is_open == '1'
})
console.log('所有充值活动--------------', recharge_data);
this.setData({
recharge_data,
})
} else {
this.setData({
recharge_data: [],
})
}
})
},
// 获取用户在商家的账户余额
getUserRechargeInfo(phone, type) {
App.Activity.GetRechargeBalanceByOpenid({
openid: getApp().openid,
phone,
sellerid: this.sid,
}).then((json) => {
if (json.ret == 200) {
let data = json.data;
if (data) {
console.log('获取用户在商家的余额----', data.recharge_balance);
this.setData({
myBalance: data.recharge_balance ? (data.recharge_balance * 1).toFixed(2) : '0.00',
})
} else {
if (type == '1') this.createInfoFun(phone)
console.log('用户在商家没有账号');
this.setData({
myBalance: null,
})
}
}
})
},
// 用户绑定手机号
bindUserPhoneFun(phone) {
console.log('用户绑定手机号');
let params = {
phone,
openid: getApp().openid,
}
App.Wechat.BindUserPhone(params).then(res => {
if (res.ret == 200) {
console.log(res, '用户绑定手机号');
}
})
},
// 如果该用户不存在账户 新增用户在商家的账户信息
createInfoFun(phone) {
let params = {
openid: getApp().openid,
sellerid: this.data.seller.sid,
phone
}
App.Activity.CreateCustomerConsumeSeller(params).then(res => {
if (res.ret == 200) {
console.log('新增用户在商家的账户信息----', res);
}
})
},
// 获取用户在商家&所有消费金
getUserInfo() {
App.Activity.GetConsumeBySeller({
... ... @@ -90,11 +214,55 @@ Page({
consumeDiscount: '0.00', //消费金抵扣金额
})
}
this.getIdentityFun()
}
})
},
// 获取当餐免费的配置信息
getFreeMealConfigFun() {
App.Activity.GetFreeMealConfigBySeller({
sellerid: this.sid,
}).then(res => {
if (res && res.data && res.data.length > 0 && res.data[0].is_open == '1') {
let data = res.data[0];
let list = data.recharge_list ? JSON.parse(data.recharge_list) : {}
list.priceInfo = '';
list.scoreInfo = '';
list.certificate = '';
if (list.is_price == '1') list.priceInfo = '赠' + list.price + '元余额';
if (list.is_score == '1') list.scoreInfo = '赠' + list.score + '积分';
if (list.is_coupons == '1' && list.coupons_names.length > 0) list.certificate = '赠' + list.coupons_names.join('、') + '券';;
this.setData({
multiple: data.multiple,
rechargeList: list
})
} else {
this.setData({
multiple: '',
rechargeList: {}
})
}
})
},
// 获取用户在当前商家身份及是否领取过消费金
getIdentityFun(){
App.Activity.GetIdentityBySeller({
sellerid: this.sid,
openid: getApp().openid,
phone: this.data.purePhoneNumber,
}).then(res => {
let is_get_consume = '1'
if (res && res.data) {
is_get_consume = res.data.is_get_consume
this.setData({
isNewUser:res.data.identity,
})
}
this.getConsumeConfigFun(is_get_consume)
})
},
// 获取商家消费金规则
getConsumeConfigFun() {
getConsumeConfigFun(isConsume) {
App.Activity.GetConsumeConfig({
sellerid: this.sid,
}).then(res => {
... ... @@ -102,17 +270,42 @@ Page({
let data = res.data;
let together = util.determine(data.together_json);
let returnData = util.determine(data.return_json);
returnData.ladder_data = returnData.ladder_data ? util.determine(returnData.ladder_data) : {};
let beforePay = util.determine(data.before_pay_json);
if(beforePay && beforePay.new) beforePay.new = util.determine(beforePay.new);
if(beforePay && beforePay.old) beforePay.old = util.determine(beforePay.old);
console.log('returnData---',returnData);
if(returnData && returnData.ladder_data) returnData.ladder_data = util.determine(returnData.ladder_data);
console.log('111配置---',together);
console.log('222顾客支付后返消费金---',returnData);
console.log('3333新老用户领取消费金---',beforePay);
let time = Math.floor(Date.now() / 1000)
let giveConsumePrice = '';
if(beforePay){
// 新用户 && 没有领取过 && 开启新用户领取
if(this.data.isNewUser == 'new' && isConsume == '0' && beforePay.new && beforePay.is_new == '1'){
let newData = beforePay.new;
if((time > newData.stime) && (time < newData.etime)){
giveConsumePrice = newData.is_fix == '1'?newData.fix_price :this.getRandomInt(newData.random_min, newData.random_max);
}
}
// 老用户 && 个人消费金大于0 && 开启老用户领取
if(this.data.isNewUser == 'old' && this.data.consumePrice == '0.00' && beforePay.old && beforePay.is_old == '1'){
let oldData = beforePay.old;
if((time > oldData.stime) && (time < oldData.etime)){
giveConsumePrice = oldData.is_fix == '1'?oldData.fix_price :this.getRandomInt(oldData.random_min, oldData.random_max);
}
}
console.log('giveConsumePrice-------',giveConsumePrice);
}
this.setData({
noConfiguration: '1', //配置为1 未配置为0
coexist: together.is_coexist,
ratio: together.ratio_data ? together.ratio_data : '100',
coexist: together?together.is_coexist:'',
ratio: together && together.ratio_data ? together.ratio_data : '100',
couponSwitch: true,
consumeSwitch: together.is_coexist == '1' ? true : false,
consumeSwitch: together && together.is_coexist == '1' ? true : false,
returnData,
isReturn: data.is_return,
giveConsumePrice,
})
} else {
this.setData({
... ... @@ -121,6 +314,7 @@ Page({
consumeSwitch: false,
returnData: null,
isReturn: '0',
giveConsumePrice:'',
})
}
})
... ... @@ -155,11 +349,18 @@ Page({
if (!this.data.couponSwitch) {
this.getCoupon()
let val = parseFloat(this.data.inputValue);
if (!val) return
let discountPrice = 0;
let actualPrice = (val - this.data.consumeDiscount - discountPrice).toFixed(2)
console.log('actualPrice----', actualPrice);
let myBalance = this.data.myBalance * 1;
let balancePay = (this.data.payType == '1' && actualPrice > myBalance) ? myBalance : actualPrice;
let soothPrice = this.data.payType == '1' ? (actualPrice - balancePay).toFixed(2) : actualPrice;
this.setData({
discountPrice: 0,
actualPrice: actualPrice > 0 ? actualPrice : '0.01'
actualPrice,
balancePay,
soothPrice,
})
}
// 开或者关闭使用消费金
... ... @@ -170,10 +371,15 @@ Page({
let discountPrice = this.data.couponSwitch ? this.data.discountPrice : 0
let actualPrice = (val - consumeDiscount - discountPrice).toFixed(2)
let remainingConsume = (this.data.consumePrice * 1 - consumeDiscount).toFixed(2)
let myBalance = this.data.myBalance * 1;
let balancePay = (this.data.payType == '1' && actualPrice > myBalance) ? myBalance : actualPrice;
let soothPrice = this.data.payType == '1' ? (actualPrice - balancePay).toFixed(2) : actualPrice;
this.setData({
consumeDiscount,
actualPrice: actualPrice > 0 ? actualPrice : '0.01',
remainingConsume: remainingConsume
actualPrice,
remainingConsume: remainingConsume,
balancePay,
soothPrice,
})
}
if (!this.data.consumeSwitch) {
... ... @@ -182,10 +388,15 @@ Page({
let discountPrice = this.data.couponSwitch ? this.data.discountPrice : 0
let consumeDiscount = this.data.consumeSwitch ? this.data.consumeDiscount : 0
let actualPrice = (val - consumeDiscount - discountPrice).toFixed(2)
let myBalance = this.data.myBalance * 1;
let balancePay = (this.data.payType == '1' && actualPrice > myBalance) ? myBalance : actualPrice;
let soothPrice = this.data.payType == '1' ? (actualPrice - balancePay).toFixed(2) : actualPrice;
this.setData({
consumeDiscount: '0.00',
actualPrice: actualPrice > 0 ? actualPrice : '0.01',
actualPrice,
remainingConsume: this.data.consumePrice,
balancePay,
soothPrice,
})
}
},
... ... @@ -218,18 +429,119 @@ Page({
closeConsumeModal() {
this.consumeModal.closeModal()
},
// 打开赠送消费金弹框
showGiveConsumeModal() {
let num = this.data.giveConsumePrice;
this.setData({
giveConsumePrice: num
})
this.giveConsume.showModal()
this.setData({
countDown: 5,
})
if (this.data.timer) {
clearInterval(this.data.timer);
}
this.startCountDown();
console.log('送消费金----',num);
},
// 开始倒计时
startCountDown() {
let that = this;
const timer = setInterval(() => {
if (that.data.countDown <= 1) {
that.closeGiveConsumeModal()
clearInterval(timer);
that.setData({
timer: null
});
} else {
that.setData({
countDown: that.data.countDown - 1
});
}
}, 1000);
this.setData({
timer
});
},
// 关闭消费金弹框
closeGiveConsumeModal() {
this.giveConsume.closeModal()
this.getConsumeFun(this.data.giveConsumePrice,'1')
},
// 选择充值活动
checkRechargeData(e) {
let id = e.currentTarget.dataset['id'];
console.log('id', id);
if (!id) {
let price = this.data.actualPrice * 1 * this.data.multiple
if (!price) return false
let str = this.data.finalList.map(item => item.activity_id).join(',');
console.log('核销所勾选的券传参', str);
let params = {
type: '2',
types: '4', // 1邀请函 2提前点餐 3商家端app分享 4支付页充值 5我的页面余额充值
sid: this.sid,
totalize: price.toFixed(2), //充值几倍金额
name: this.data.seller.sellername,
isFree: '1',
multiple: this.data.multiple,
inputValue: this.data.inputValue, //订单实际应该支付金额(扣除消费金、券之前)
}
// 消费金开关开启 && 消费金抵扣金额大于0
if (this.data.consumeDiscount * 1 > 0 && this.data.consumeSwitch) {
params.consume = this.data.consumeDiscount;
}
if (str) {
params.activity_id = str;
}
if (this.data.givePrice) {
params.givePrice = this.data.givePrice; //当餐免费送的余额
}
let url = util.http_build_query({
...params
}, '/pack-activity/pack/vipRecharge')
return wx.navigateTo({
url
})
}
wx.navigateTo({
url: util.http_build_query({
id,
name: this.data.seller.sellername,
sid: this.sid,
types: '4',
isFree: '0',
}, '/pack-activity/pack/vipRecharge')
})
},
// 关闭优惠券弹框
closegiveCouponModal() {
this.giveCouponModal.closeModal()
this.getUserInfo()
},
// 跳转登录页
gotoLogin(event) {
wx.navigateTo({
url: util.http_build_query({
types: event.currentTarget.dataset.types
}, '/pages/customer/login')
})
// 获取code、手机号
getPhoneNumberFun(e) {
console.log('eeeeeeeeee', e.detail);
if (e.detail && e.detail.code) {
App.Wechat.GetUserPhoneNumber({
code: e.detail.code,
}).then(res => {
console.log('resresres----', res);
if (res.ret == 200 && res.data && res.data.phone_info && res.data.phone_info.purePhoneNumber) {
this.setData({
purePhoneNumber: res.data.phone_info.purePhoneNumber,
})
this.getUserInfo()
this.bindUserPhoneFun(res.data.phone_info.purePhoneNumber)
this.getUserRechargeInfo(res.data.phone_info.purePhoneNumber, '1')
} else {
this.getUserInfo()
util.toast('手机号获取失败!', 'none')
}
})
}
},
// 获取店铺名称
getSellerDetailFun(sid) {
... ... @@ -266,9 +578,9 @@ Page({
if (now >= parseInt(fullData.stime) && now <= parseInt(fullData.etime)) {
// rule 1每满门槛均发放(满50送一张券,金额是100送2张)
// rule 0仅发放一次(每次满足金额一个券只发一张)
const price = parseFloat(fullData.price)
const amount = parseInt(priceSum / price)
if (fullData.rule == '1') {
const price = parseFloat(fullData.price)
const amount = parseInt(priceSum / price)
if (coupons.length > 0 && amount > 0) this.getCouponFun(coupons, '1', amount,orderid)
} else {
if (coupons.length > 0 && amount > 0) this.getCouponFun(coupons, '1', 1,orderid)
... ... @@ -367,8 +679,6 @@ Page({
}).then(res => {
if (res.ret == 200 && res.data && res.data.length > 0) {
let list = res.data
// console.log('listlistlist',JSON.stringify(list));
// list= list.concat(monidata)
list.forEach(detail => {
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
detail.arule = detail.arule ? util.determine(detail.arule) : '';
... ... @@ -520,7 +830,10 @@ Page({
discountPrice: '',
actualPrice: '',
consumeDiscount: '',
remainingConsume: this.data.consumePrice
remainingConsume: this.data.consumePrice,
soothPrice: '',
balancePay: '',
payType: '2',
})
} else {
if (this.data.couponSwitch) {
... ... @@ -531,17 +844,24 @@ Page({
let consumeDiscount = this.calculateConsumeGold(val);
let actualPrice = (val - consumeDiscount - this.data.discountPrice).toFixed(2)
let remainingConsume = (this.data.consumePrice * 1 - consumeDiscount).toFixed(2)
let myBalance = this.data.myBalance * 1;
let balancePay = (this.data.payType == '1' && actualPrice > myBalance) ? myBalance : actualPrice;
let soothPrice = this.data.payType == '1' ? (actualPrice - balancePay).toFixed(2) : actualPrice;
this.setData({
consumeDiscount,
actualPrice: actualPrice > 0 ? actualPrice : '0.01',
remainingConsume: remainingConsume
actualPrice: actualPrice,
remainingConsume: remainingConsume,
balancePay,
soothPrice
})
}
}
},
// 点确认选择
checkCertificate() {
let inputValue = parseFloat(this.data.inputValue);
this.closeCouponModal()
if (!inputValue) return
let list = this.data.couponArr;
list = list.filter(i => {
return i.checked
... ... @@ -554,9 +874,14 @@ Page({
let val = parseFloat(this.data.inputValue);
let actualPrice = (val - price - this.data.consumeDiscount).toFixed(2)
price = price.toFixed(2)
let myBalance = this.data.myBalance * 1;
let balancePay = (this.data.payType == '1' && actualPrice > myBalance) ? myBalance : actualPrice;
let soothPrice = this.data.payType == '1' ? (actualPrice - balancePay).toFixed(2) : actualPrice;
this.setData({
discountPrice: price,
actualPrice: actualPrice > 0 ? actualPrice : 0.01,
actualPrice,
balancePay,
soothPrice,
})
console.log('点确认选择后', list);
},
... ... @@ -569,20 +894,28 @@ Page({
console.log('处理过后的券数据', list);
list.sort((a, b) => b.canCheck - a.canCheck);
list.sort((a, b) => b.showCpupon - a.showCpupon);
let consumeDiscount = '';
let amount = parseFloat(this.data.inputValue);
if (this.data.consumeSwitch) {
let amount = parseFloat(this.data.inputValue);
let num = (amount - this.data.discountPrice).toFixed(2);
let val = parseFloat(num);
let consumeDiscount = this.calculateConsumeGold(val);
let actualPrice = (amount - consumeDiscount - this.data.discountPrice).toFixed(2)
let remainingConsume = (this.data.consumePrice * 1 - consumeDiscount).toFixed(2)
consumeDiscount = this.calculateConsumeGold(val);
this.setData({
consumeDiscount,
actualPrice: actualPrice > 0 ? actualPrice : '0.01',
remainingConsume: remainingConsume
})
}
let actualPrice = (amount - consumeDiscount - this.data.discountPrice).toFixed(2)
let remainingConsume = (this.data.consumePrice * 1 - consumeDiscount).toFixed(2)
let myBalance = this.data.myBalance * 1;
let balancePay = (this.data.payType == '1' && actualPrice > myBalance) ? myBalance : actualPrice;
let soothPrice = this.data.payType == '1'?(actualPrice - balancePay).toFixed(2):actualPrice
console.log('实际支付金额:', actualPrice);
this.setData({
consumeDiscount,
actualPrice,
remainingConsume: remainingConsume,
soothPrice,
balancePay,
couponArr: list,
finalList: obj.finalList
})
... ... @@ -591,9 +924,9 @@ Page({
confirmPayment: util.throttle(function () {
let that = this;
let actualPrice = this.data.actualPrice
if (actualPrice <= 0) {
return
}
wx.showLoading({
title: '支付中',
})
let str = this.data.finalList.map(item => item.activity_id).join(',');
console.log('核销所勾选的券传参', str);
let params = {
... ... @@ -607,9 +940,46 @@ Page({
if (str) {
params.activity_id = str;
}
// 用余额支付 || 支付金额为0
if (this.data.soothPrice == '0.00') {
let obj = {
openid: getApp().openid,
sellerid: this.data.seller.sid,
price: this.data.inputValue,
phone: this.data.purePhoneNumber,
recharge_balance: this.data.balancePay * 1,
}
if (str) {
obj.activity_id = str;
}
let consumeDiscount = this.data.consumeDiscount * 1
if (consumeDiscount > 0) {
obj.consume = this.data.consumeDiscount;
}
console.log('用余额支付objobj----', obj);
App.Activity.CreateRechargeBalanceOrder({
...obj
}).then(res => {
console.log('付款信息', res.data);
if (res.ret != '200') {
wx.hideLoading()
return wx.showToast({
title: res.msg,
duration: 1000,
icon: 'none',
})
}
if (res.ret == '200') {
that.deductBalance(actualPrice, res.data.id)
}
})
return false
}
// 微信支付
App.PayOnline.CombineTransactionsByNewActivity(params).then(res => {
console.log('付款信息', res.data);
if (res.ret != '200') {
wx.hideLoading()
wx.showToast({
title: res.msg,
duration: 1000,
... ... @@ -624,20 +994,19 @@ Page({
signType: res.data.signType,
paySign: res.data.paySign,
success(ress) {
wx.hideLoading()
if (ress.errMsg == 'requestPayment:ok') {
that.giftCouponsFun(actualPrice,res.data.orderid) //送券
that.giftConsumeFun(actualPrice, res.data.orderid) //送消费金
setTimeout(() => {
console.log('送券金额----', that.data.totalPrice);
console.log('送消费金----', that.data.totalConsumePrice);
if (that.data.totalPrice > 0 || that.data.totalConsumePrice > 0) {
wx.reLaunch({
url: util.http_build_query({
totalPrice: that.data.totalPrice,
totalConsumePrice: that.data.totalConsumePrice,
}, '/pack-activity/pack/paySuccess')
})
}
console.log('2送券金额----', that.data.totalPrice);
console.log('2送消费金----', that.data.totalConsumePrice);
wx.reLaunch({
url: util.http_build_query({
totalPrice: that.data.totalPrice,
totalConsumePrice: that.data.totalConsumePrice,
}, '/pack-activity/pack/paySuccess')
})
}, 1000);
console.log('支付成功', ress);
return
... ... @@ -647,6 +1016,7 @@ Page({
return that.myToast.showToast('支付失败,请重新下单', 2000)
},
fail(ress) {
wx.hideLoading()
that.payFail()
console.log('支付失败22', ress);
return that.myToast.showToast('支付失败,请重新下单', 2000)
... ... @@ -655,6 +1025,37 @@ Page({
}
})
},3000),
// 扣除支付的余额
deductBalance(actualPrice, id) {
let that = this;
let recharge_balance = this.data.balancePay * 1
App.Activity.SetRechargeBalanceByOpenid({
openid: getApp().openid,
recharge_balance,
sellerid: this.data.seller.sid,
type: '2',
}).then(res => {
if (res.ret == 200) {
wx.hideLoading()
console.log('扣除余额成功');
that.giftCouponsFun(actualPrice, id) //送券
that.giftConsumeFun(actualPrice, id) //送消费金
setTimeout(() => {
console.log('1送券金额----', that.data.totalPrice);
console.log('1送消费金----', that.data.totalConsumePrice);
wx.reLaunch({
url: util.http_build_query({
totalPrice: that.data.totalPrice,
totalConsumePrice: that.data.totalConsumePrice,
}, '/pack-activity/pack/paySuccess')
})
}, 1000);
} else {
wx.hideLoading()
that.myToast.showToast('支付失败,请重新下单', 2000)
}
})
},
payFail() {
this.setData({
inputValue: '',
... ... @@ -663,6 +1064,9 @@ Page({
discountPrice: '0.00',
actualPrice: '',
consumeDiscount: '0.00', //消费金抵扣金额
balancePay:'',
payType:'2',
soothPrice: '',
})
this.getCoupon()
this.getUserInfo()
... ... @@ -691,20 +1095,15 @@ Page({
}
},
// 为用户增加消费金
getConsumeFun(amount) {
getConsumeFun(amount,type) {
App.Activity.SetConsumeByOpenid({
phone: this.data.purePhoneNumber,
openid: getApp().openid,
amount,
sellerid: this.data.seller.sid
}).then(res => {
if (res.data == '0') {
wx.showToast({
title: '消费金领取失败!',
duration: 1000,
icon: 'none',
mask: true
});
if(type == '1'){
this.getUserInfo()
}
})
},
... ... @@ -922,14 +1321,13 @@ Page({
});
discountPrice = discountPrice.toFixed(2)
console.log('总优惠金额:', discountPrice);
let actualPrice = (amount - discountPrice).toFixed(2);
console.log('实际支付金额:', actualPrice);
console.log('消费金抵扣:',this.data.consumeDiscount);
this.setData({
discountPrice,
actualPrice: actualPrice > 0 ? actualPrice : '0.01', // 确保实际支付金额不小于0.01
});
return {
arr,
discountPrice,
finalList, // 返回可叠加和不可叠加的优惠券组合
};
},
... ... @@ -1061,7 +1459,6 @@ Page({
var month = curdate.getMonth() + 1;
var date = Math.floor((curdate.getTime() % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60 * 24)) + 1; // 计算当前日期
var formattedDate = year + "-" + month + "-" + date;
obj.isshow = '0'
//在节假日数组内
if ((holidays.indexOf(formattedDate) >= 0) && nWeekend.indexOf(formattedDate) < 0) {
obj.isshow = '1'
... ... @@ -1185,6 +1582,11 @@ Page({
url: '/pages/me/consumeAmount'
})
},
getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
... ... @@ -1196,7 +1598,7 @@ Page({
*/
onShow() {
this.getCheckUserHavePhone()
this.getConsumeConfigFun()
this.getFreeMealConfigFun()
},
/**
... ...
<!--pack-activity/pack/buyFreeCoupon.wxml-->
<nav hasHome>向商家付款</nav>
<wxs module="utils">
var formatPrice = function(price, multiple) {
var result = (price * 1 * multiple).toFixed(2);
return result;
}
module.exports.formatPrice = formatPrice;
</wxs>
<view class="sellInfo">
<image src="{{seller.seller_image}}" mode="aspectFill" />
<view class="font32r">{{seller.sellername}}</view>
... ... @@ -31,19 +38,102 @@
</view>
</block>
<block wx:else>
<view bindtap="gotoLogin" data-types="3" class="couponsBox colorOrange">
<view class="couponLeft">使用消费金抵扣</view>
<view class="couponRight">
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumberFun" class="couponsBox colorOrange">
<view class="couponLeft font28r">使用消费金抵扣</view>
<view class="couponRight font28r">
<view class="more" style="margin-top: 6rpx;"></view>
</view>
</view>
</button>
</block>
<view class="couponsWrap">
<view class="couponLeft">抵扣后</view>
<view class="couponRight" wx:if="{{actualPrice && inputValue}}">¥{{actualPrice}}</view>
</view>
<view wx:if="{{purePhoneNumber && giveConsumePrice && giveConsumePrice>0}}" class="consumeBox">
<image class="consumeImg" src="https://qn.colorcun.com/myConsume.png" mode=""/>
<view class="claim font28r" bind:tap="showGiveConsumeModal">免费领取消费金,当餐可用</view>
</view>
<button wx:if="{{!purePhoneNumber && giveConsumePrice && giveConsumePrice>0}}" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumberFun" class="consumeBox">
<image class="consumeImg" src="https://qn.colorcun.com/myConsume.png" mode=""/>
<view class="claim font28r">免费领取消费金,当餐可用</view>
</button>
</view>
<view class="payBox">
<view class="balanceBox" wx:if="{{purePhoneNumber}}">
<view class="balanceLeft">
<view>
<image class="balanceImg" src="https://qn.colorcun.com/balanceIcon.png" mode=""/>
<text class="texts font28r">店铺余额支付</text>
</view>
<text class="font24r">总余额¥{{myBalance?myBalance:'0.00'}}</text>
</view>
<view class="balanceRight">
<text wx:if="{{payType == '1' && balancePay && balancePay>0}}">-¥{{balancePay}}</text>
<image wx:if="{{payType == '1'}}" bind:tap="checkPay" data-type="1" class="checkIcon" src="https://qn.colorcun.com/checkImg1.png" mode=""/>
<view class="check" wx:else data-type="1" bind:tap="checkPay"></view>
</view>
</view>
<button wx:else open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumberFun" class="balanceBox">
<view class="balanceLeft">
<view>
<image class="balanceImg" src="https://qn.colorcun.com/balanceIcon.png" mode=""/>
<text class="texts font28r">店铺余额支付</text>
</view>
<text class="font24r">总余额¥0.00</text>
</view>
<view class="balanceRight">
<view class="check" ></view>
</view>
</button>
<view class="balanceLeft balanceLeft1">
<view>
<image class="balanceImg" src="https://qn.colorcun.com/wxPayIcon.png" mode=""/>
<text class="texts font28r">微信支付</text>
</view>
<image wx:if="{{payType == '2'}}" bind:tap="checkPay" data-type="2" class="checkIcon" src="https://qn.colorcun.com/checkImg1.png" mode=""/>
<view wx:else class="check" data-type="2" bind:tap="checkPay"></view>
</view>
<view class="rechargeBox" wx:if="{{purePhoneNumber}}">
<view class="rechargeItems" wx:for="{{recharge_data}}" bindtap="checkRechargeData" data-id="{{item.id}}">
<view class="font24r">充<text>{{item.recharge_money}}</text>元</view>
<view class="font24r" wx:if="{{item.recharge_list.price && item.recharge_list.price*1 > 0}}">送{{item.recharge_list.price}}元</view>
</view>
</view>
<button wx:else open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumberFun" class="rechargeBox">
<view class="rechargeItems" wx:for="{{recharge_data}}" data-id="{{item.id}}">
<view class="font24r">充<text>{{item.recharge_money}}</text>元</view>
<view class="font24r" wx:if="{{item.recharge_list.price && item.recharge_list.price*1 > 0}}">送{{item.recharge_list.price}}元</view>
</view>
</button>
<view class="rechargeItems rechargeItems1" wx:if="{{purePhoneNumber && multiple && multiple > 0 && rechargeList}}" bindtap="checkRechargeData">
<view class="font24r">
<block wx:if="{{multiple && multiple > 0 && !actualPrice}}">
充<text>{{multiple}}</text>倍 <text>当餐免费</text>
</block>
<block wx:else>
充<text>{{utils.formatPrice(actualPrice, multiple)}}</text>元 <text>当餐免费</text>
</block>
</view>
<view class="font24r bottomItem">{{rechargeList.priceInfo}} {{rechargeList.scoreInfo}} {{rechargeList.certificate}}</view>
</view>
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumberFun" class="rechargeItems rechargeItems1" wx:if="{{!purePhoneNumber && multiple && multiple > 0 && rechargeList}}">
<view class="font24r">
<block wx:if="{{multiple && multiple > 0 && !actualPrice}}">
充<text>{{multiple}}</text>倍 <text>当餐免费</text>
</block>
<block wx:else>
充<text>{{actualPrice * 1 * multiple}}</text>元 <text>当餐免费</text>
</block>
</view>
<view class="font24r bottomItem">{{rechargeList.priceInfo}} {{rechargeList.scoreInfo}} {{rechargeList.certificate}}</view>
</button>
<!-- <view class="infoAgreement font24r">充值即代表同意<text>《用户协议》</text>及<text>《会员充值协议》</text></view> -->
</view>
<view class="bottomBox"></view>
<view class="payBtnBox">
<view class="total">合计<text>{{soothPrice?'¥' + soothPrice:''}}</text></view>
<view class="payBtn font32r" bindtap="confirmPayment">支付</view>
</view>
<view class="payBtn font32r" bindtap="confirmPayment">付款</view>
<toast id="myToast"></toast>
<!-- 使用优惠券弹框 -->
<my-modal id="couponModal" fadeStyle="slideUp" height="{{couponArr.length > '3' ? '80%' : '60%'}}">
... ... @@ -125,7 +215,7 @@
</view>
</my-modal>
<!-- 赠送优惠券/消费金弹框 -->
<my-modal id="giveCouponModal" fadeStyle="slideUp" height="240px">
<!-- <my-modal id="giveCouponModal" fadeStyle="slideUp" height="240px">
<view slot="modalName" class="titleModal ">
<image bindtap="closegiveCouponModal" class="closeImg" src="https://qn.colorcun.com/closeOutline.png" mode=""/>
<view class="nameInfo">{{seller.sellername}}</view>
... ... @@ -142,4 +232,19 @@
<view wx:else bindtap="closegiveCouponModal" class="couponBtn font36r">开心收下</view>
</subscribe>
</view>
</my-modal> -->
<!-- 新用户/老用户赠送消费金弹框 -->
<my-modal id="giveConsume" fadeStyle="center" height="300px">
<view slot="modalContent" class="contentBox">
<image bindtap="closeGiveConsumeModal" class="closeImg1" src="https://qn.colorcun.com/closeImg3.png" mode="" />
<view class="nameInfo">{{seller.sellername}}</view>
<view class="couponTotal1 font28r">赠送给您消费金</view>
<view class="counterText1">
<view class="font36r">¥</view>
<scroll-number value="{{giveConsumePrice}}"></scroll-number>
</view>
<view class="couponInfo1 font24r">您到店扫码支付即可自动抵扣</view>
<view bindtap="closeGiveConsumeModal" class="couponBtn1 font36r">开心收下</view>
<view class="closeBox font28r">{{countDown}} 秒后自动关闭</view>
</view>
</my-modal>
\ No newline at end of file
... ...
/* pack-activity/pack/buyFreeCoupon.wxss */
page {
background: #F5F5F5;
}
.sellInfo {
padding: 56rpx 0 40rpx 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: #f6f6fd;
}
.sellInfo image {
... ... @@ -15,9 +18,10 @@
}
.payBox {
padding: 30rpx 40rpx 0 40rpx;
border-radius: 30rpx 30rpx 0rpx 0rpx;
padding: 40rpx;
background: #ffffff;
border-radius: 10rpx;
margin: 0 20rpx 20rpx 20rpx;
}
.payView {
... ... @@ -54,6 +58,9 @@
justify-content: space-between;
color: #999;
margin: 24rpx 0;
padding: 0;
background: transparent;
border: none;
}
.couponsBox .more {
... ... @@ -89,16 +96,47 @@
justify-content: space-between;
}
.payBtnBox {
position: fixed;
left: 0;
bottom: 0;
height: 160rpx;
padding: 0 40rpx;
box-sizing: border-box;
z-index: 10;
justify-content: space-between;
width: 100%;
background: #fff;
display: flex;
align-items: center;
justify-content: space-between;
}
.payBtnBox .total {
display: flex;
align-items: center;
}
.payBtnBox .total text {
color: #FD4D59;
}
.bottomBox {
padding-bottom: 160rpx;
margin-bottom: 60rpx;
}
.payBtn {
background: #09BB07;
width: 90%;
color: #fff;
text-align: center;
padding: 20rpx 0;
position: absolute;
bottom: 10%;
border-radius: 198rpx;
left: 5%;
background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
color: #fff;
height: 72rpx;
border-radius: 198rpx;
font-weight: 600;
margin-right: 20rpx;
padding: 0 60rpx;
display: flex;
align-items: center;
justify-content: center;
}
.mymodal .mymodal-title {
... ... @@ -313,8 +351,8 @@ checkbox::before {
.nameInfo {
font-family: PingFang SC;
font-weight: 600;
font-size: 52rpx;
font-weight: 500;
font-size: 40rpx;
line-height: 56rpx;
color: #fff;
margin-bottom: 100rpx;
... ... @@ -333,6 +371,18 @@ checkbox::before {
margin-bottom: 12rpx;
}
.couponTotal1 {
color: #fff;
font-family: PingFang SC;
font-weight: 500;
font-size: 28rpx;
line-height: 48rpx;
margin-bottom: 16rpx;
display: flex;
align-items: center;
justify-content: center;
}
.counterText {
color: #ffc806;
font-weight: 600;
... ... @@ -340,12 +390,27 @@ checkbox::before {
margin-right: 14rpx;
}
.counterText1 {
color: #FFC806;
font-weight: 600;
font-size: 100rpx;
display: flex;
align-items: flex-end;
justify-content: center;
}
.couponInfo {
color: #DFDFDF;
text-align: center;
margin-bottom: 30rpx;
}
.couponInfo1 {
color: #fff;
text-align: center;
margin: 16rpx 0 28rpx;
}
.couponBtn {
width: 80%;
margin: 0 auto;
... ... @@ -359,6 +424,10 @@ checkbox::before {
margin: 16rpx auto 20rpx auto;
}
.contentBox {
width: 100%;
}
.couponText {
color: #fff;
text-decoration: underline;
... ... @@ -456,14 +525,223 @@ checkbox::before {
}
.couponBtn1 {
width: 40%;
margin: 0 auto;
border-radius: 42rpx;
background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
font-weight: 400;
color: #fff;
width: 80%;
border-radius: 198rpx;
background: #fff;
font-family: PingFang SC;
font-weight: 600;
color: #F14033;
text-align: center;
border: 4rpx solid #fff;
padding: 12rpx 0;
margin: 16rpx auto 20rpx auto;
padding: 32rpx 0;
margin: 28rpx auto 0 auto;
}
.claim {
color: #FD4D59;
text-decoration: underline;
}
.consumeBox {
margin-top: 28rpx;
display: flex;
align-items: center;
padding: 0;
background: transparent;
line-height: inherit;
}
.consumeImg {
width: 40rpx;
height: 40rpx;
margin-left: 8rpx;
}
#giveConsume .mymodal{
background: #F14033;
width: 72% !important;
left: 14% !important;
top: 30% !important;
}
#giveConsume .closeImg1 {
position: absolute;
width: 60rpx;
height: 60rpx;
top: -17%;
right: -10%;
}
#giveConsume .mymodal .mymodal-content {
border-radius: 20rpx;
}
#giveConsume .mymodal-content {
display: flex;
align-items: center;
justify-content: center;
}
#giveConsume .nameInfo {
margin-bottom: 20rpx;
text-align: center;
}
#giveConsume .counterText {
color: #ffc806;
font-weight: 600;
display: flex;
font-size: 100rpx;
align-items: flex-end;
justify-content: center;
margin: 16rpx 0;
}
#giveConsume .couponInfo {
margin-bottom:20rpx;
}
.balanceBox,
.balanceLeft view,
.balanceRight {
display: flex;
align-items: center;
justify-content: space-between;
}
.balanceBox {
align-items: flex-start;
margin: 0;
padding: 0;
background: transparent;
border: none;
}
.balanceLeft {
display: flex;
justify-content: space-between;
flex-direction: column;
}
.balanceLeft text {
color: #696969;
font-family: PingFang SC;
font-weight: 400;
margin-top: 10rpx;
}
.balanceLeft .texts {
color: #000000;
font-family: PingFang SC;
font-weight: 500;
margin-top: 0;
}
.balanceLeft image,
.balanceRight image {
width: 44rpx;
height: 44rpx;
}
.balanceRight text {
color: #ED7B2F;
font-family: PingFang SC;
font-weight: 400;
margin-right: 8rpx;
}
.balanceImg {
margin-right: 4rpx;
}
.rechargeBox {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
margin-top: 28rpx;
padding: 0;
background: transparent;
border: none;
line-height: inherit;
}
.rechargeItems {
width: 46%;
padding: 20rpx 0rpx;
border-radius: 10rpx;
border: 2rpx solid #cbcbcb;
background: #fff7f5;
color: #B56737;
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
margin-bottom: 28rpx;
height: 84rpx;
}
.rechargeItems view text {
font-size: 48rpx;
margin: 0 4rpx;
font-family: PingFang SC;
font-weight: 600;
}
.rechargeItems view text:nth-last-of-type(1) {
font-size: 40rpx;
font-family: PingFang SC;
font-weight: 500;
}
.rechargeItems view {
display: flex;
align-items: center;
justify-content: center;
}
.rechargeItems1 {
width: 100%;
line-height: inherit;
height: auto;
}
.rechargeItems1 view text:nth-last-of-type(1) {
margin-left: 60rpx;
}
.bottomItem {
margin: 10rpx 0;
}
.infoAgreement {
color: #696969;
font-family: "PingFang SC";
font-weight: 400;
}
.infoAgreement text {
color: #ED7B2F;
}
.check {
width: 40rpx;
height: 40rpx;
border-radius: 50%;
border: 2rpx solid #cbcbcb;
}
.balanceLeft1 {
flex-direction: row;
margin-top: 28rpx;
}
.closeBox {
margin-top: 20rpx;
color: #ffffff;
font-family: PingFang SC;
font-weight: 400;
display: flex;
align-items: center;
justify-content: center;
}
\ No newline at end of file
... ...
... ... @@ -14,15 +14,16 @@ Page({
combine_out_trade_no: '',
totalize: '',
types: '',
givePrice:'',
},
type: '',
name: "",
date: "",
phone: "",
calendarData: '',
purePhoneNumber: '', //手机号
sex: "先生",
indexs: 0,
StyleType:'',//邀请函模板
showInfo:'0',//有无会员信息
vipInfo:{},
sexList: [{
sex: '先生',
value: '1',
... ... @@ -57,6 +58,11 @@ Page({
oid: options.oid ? options.oid : '',
rid: options.rid ? options.rid : '',
sellerName: options.sellerName ? options.sellerName : '',
givePrice: options.givePrice,
isFree: options.isFree, //当餐免费充值1
consume: options.consume, //当餐免费使用的消费金金额
activity_id: options.activity_id, //当餐免费使用的券ID
inputValue: options.inputValue, //当餐免费抵扣前的金额
},
type: options.type,
})
... ... @@ -66,14 +72,49 @@ Page({
if (obj) {
this.setData({
name: obj.name,
date: obj.date,
phone: obj.phone,
purePhoneNumber: obj.purePhoneNumber,
indexs: obj.sex * 1 - 1,
calendarData: obj.calendarData,
})
}
this.modal = this.selectComponent("#payModal"); //通过给组件所起的id调用组件
this.getSellerTemplateConfFun(options.sid)
this.getCheckUserHavePhone()
},
// 检测用户是否绑定手机号
getCheckUserHavePhone() {
App.Wechat.CheckUserHavePhone({
openid: getApp().openid,
}).then((json) => {
if (json.ret == 200) {
let data = json.data;
if (data && data.phone) {
this.setData({
purePhoneNumber: data.phone,
})
this.getInfo(data.phone)
} else {
this.setData({
purePhoneNumber: '',
})
}
}
})
},
// 获取code、手机号
getPhoneNumberFun(e) {
if (e.detail && e.detail.code) {
App.Wechat.GetUserPhoneNumber({
code: e.detail.code,
}).then(res => {
if (res.ret == 200 && res.data && res.data.phone_info && res.data.phone_info.purePhoneNumber) {
this.setData({
purePhoneNumber: res.data.phone_info.purePhoneNumber,
})
} else {
util.toast('手机号获取失败!', 'none')
}
})
}
},
// 获取商家设置营销信息---获取模板
getSellerTemplateConfFun(sid){
... ... @@ -97,7 +138,7 @@ Page({
showModal() {
this.modal.showModal() //调用组件中打开模态框方法
},
confirmPayment(gid) {
confirmPaymentFun(gid) {
let that = this;
App.PayOnline.CombineTransactionsByNewRecharge({
combine_out_trade_no: this.data.opt.combine_out_trade_no,
... ... @@ -110,7 +151,7 @@ Page({
duration: 1000,
icon: 'none',
success: function () {
console.log('支付失败', that.data.opt.types);
console.log('支付失败1', that.data.opt.types);
that.callbackFun()
}
})
... ... @@ -125,19 +166,20 @@ Page({
success(ress) {
if (ress.errMsg == 'requestPayment:ok') {
console.log('支付成功', ress);
return that.showModal()
return that.addConsume()
}
console.log('支付失败', ress);
console.log('支付失败2', ress);
wx.showToast({
title: '支付失败,请重新下单',
duration: 1000,
icon: 'none',
success: function () {
that.callbackFun()
}
})
},
fail(ress) {
console.log('支付失败', ress);
console.log('支付失败3', ress);
wx.showToast({
title: '支付失败,请重新下单',
duration: 1000,
... ... @@ -152,9 +194,31 @@ Page({
}
})
},
// 支付成功 增加余额
addConsume() {
let givePrice = this.data.opt.givePrice * 1;
let totalize = this.data.opt.totalize * 1;
console.log('givePrice--', givePrice);
givePrice = givePrice ? givePrice : 0
console.log('givePrice22--', givePrice);
let recharge_balance = givePrice + totalize;
console.log('增加余额--------', recharge_balance);
App.Activity.SetRechargeBalanceByOpenid({
openid: getApp().openid,
recharge_balance,
sellerid: this.data.opt.sid,
type: '1',
}).then(res => {
if (res.ret == 200) {
console.log('充值成功');
this.showModal()
}
})
},
// 支付成功/失败回调 types 1邀请函 2提前点餐 3商家端app分享 4支付页充值 5我的页面余额充值
callbackFun() {
let that = this;
console.log('types---',that.data.opt.types);
let url = '/pack-invitation/pages/detail_owner_invitation1?id=' + that.data.opt.detail.oid;
if(that.data.opt.types == '1'){
console.log('StyleType',this.data.StyleType);
... ... @@ -185,8 +249,11 @@ Page({
if (that.data.opt.types == '3') {
url = '/pages/reserve/index_new';
}
if (that.data.opt.types == '4' || this.data.opt.types == '5') {
return wx.navigateBack(2)
if (that.data.opt.types == '4') {
url = `/pack-activity/pack/buyFreeCoupon?sid=${that.data.opt.sid}`;
}
if (that.data.opt.types == '5') {
return wx.navigateBack(3)
}
setTimeout(function () {
wx.reLaunch({
... ... @@ -213,7 +280,7 @@ Page({
bindKeyPhoneInput(event) {
const value = event.detail.value.replace(/\s+/g, "");
this.setData({
phone: value
purePhoneNumber: value
})
console.log(value);
},
... ... @@ -235,11 +302,11 @@ Page({
util.toast('未填写姓名', 'none')
return;
}
if (!data.phone) {
if (!data.purePhoneNumber) {
util.toast('未填写手机号码', 'none')
return;
}
if (!/^1\d{10}$/.test(data.phone)) {
if (!/^1\d{10}$/.test(data.purePhoneNumber)) {
util.toast('手机号码错误', 'none')
return;
}
... ... @@ -251,38 +318,163 @@ Page({
}, 3500);
return
}
this.getInfo()
let sex = this.data.indexs * 1 + 1; //1男 2女 3公司 4贵宾
let params = {
sellerid: this.data.opt.sid,
rname: this.data.name,
sex,
phone: this.data.purePhoneNumber,
}
if(data.showInfo == '1') {
if (this.data.purePhoneNumber == data.vipInfo.phone && this.data.name == data.vipInfo.rname && sex == data.vipInfo.sex) {
console.log('信息都一样,直接支付');
// 不是当餐免费
if(this.data.opt.isFree == '0') this.confirmPaymentFun(data.vipInfo.id)
// 是当餐免费
if(this.data.opt.isFree == '1') this.payFreeFun()
}else{
console.log({...params});
params.id=data.vipInfo.id;
console.log('要修改信息');
this.editInfo(params)
}
}else{
this.addInfo(params)
}
} else {
this.confirmPayment()
this.confirmPaymentFun()
}
},
getInfo() {
let sex = this.data.indexs * 1 + 1; //1男 2女 3公司 4贵宾
getInfo(phone) {
App.GuestManage.GetIsMemberByPhone({
sid: this.data.opt.sid,
phone: this.data.phone,
phone,
}).then(res => {
console.log('用户是否录入',res);
let params = {
sellerid: this.data.opt.sid,
rname: this.data.name,
sex,
phone: this.data.phone,
c_day: this.data.calendarData
if(res.data && res.data.id){
this.setData({
purePhoneNumber:res.data.phone,
name:res.data.rname,
sex:res.data.sex,
indexs:res.data.sex*1-1,
showInfo:'1',//有会员信息
vipInfo:{
id:res.data.id,
phone:res.data.phone,
rname:res.data.rname,
sex:res.data.sex,
indexs:res.data.sex*1-1,
}
})
}else{
this.setData({
showInfo:'0',//无会员信息
vipInfo:{}
})
}
console.log({...params});
if (res.data && res.data.id) {
if (this.data.phone == res.data.phone && this.data.name == res.data.rname && sex == res.data.sex && this.data.calendarData == res.data.c_day) {
console.log('信息都一样,直接支付');
this.confirmPayment(res.data.id)
} else {
params.id=res.data.id;
console.log('要修改信息');
this.editInfo(params)
}
} else {
console.log('没有客户信息,保存信息');
this.addInfo(params)
})
},
// 当餐免费支付
payFreeFun: util.throttle(function () {
let that = this;
wx.showLoading({
title: '支付中',
})
App.PayOnline.CombineTransactionsByNewActivity({
sellerid:this.data.opt.sid,
price:this.data.opt.totalize,
openid:getApp().openid,
is_free:'1',
}).then(res=>{
console.log('付款信息', res.data);
if (res.ret != '200') {
wx.hideLoading()
wx.showToast({
title: res.msg,
duration: 1000,
icon: 'none',
})
setTimeout(function () {
wx.reLaunch({
url:`/pack-activity/pack/buyFreeCoupon?sid=${that.data.opt.sid}`
})
}, 1000);
}
if (res.ret == '200') {
wx.requestPayment({
timeStamp: res.data.timeStamp + '',
nonceStr: res.data.nonceStr,
package: res.data.package,
signType: res.data.signType,
paySign: res.data.paySign,
success(ress) {
wx.hideLoading()
if (ress.errMsg == 'requestPayment:ok') {
that.submitFreeOrder()// 当餐免费充值完成后,提交订单
that.addConsume()// 当餐免费充值完成后,增加余额
console.log('支付成功', ress);
return
}
console.log('支付失败11', ress);
return wx.showToast({
title: '支付失败,请重新下单',
duration: 1000,
icon: 'none',
success: function () {
that.callbackFun()
}
})
},
fail(ress) {
wx.hideLoading()
console.log('支付失败22', ress);
return wx.showToast({
title: '支付失败,请重新下单',
duration: 1000,
icon: 'none',
success: function () {
that.callbackFun()
}
})
},
})
}
})
},3000),
// 当餐免费充值完成后,提交订单
submitFreeOrder(){
let params ={
openid:getApp().openid,
sellerid:this.data.opt.sid,
price:this.data.opt.inputValue,
phone:this.data.purePhoneNumber,
is_free:'1',
recharge_amount:this.data.opt.totalize,
}
if (this.data.opt.consume*1>0) {
params.consume = this.data.opt.consume;
}
if (this.data.opt.activity_id) {
params.activity_id = this.data.opt.activity_id;
}
App.Activity.CreateRechargeBalanceOrder({
...params
}).then(res => {
console.log('付款信息', res.data);
if (res.ret != '200') {
wx.hideLoading()
return wx.showToast({
title: res.msg,
duration: 1000,
icon: 'none',
})
}
if (res.ret == '200') {
console.log('resresresres-----',res);
wx.reLaunch({
url: '/pack-activity/pack/paySuccess'
})
console.log('支付成功', res);
}
})
},
... ... @@ -290,7 +482,10 @@ Page({
editInfo(params) {
App.GuestManage.SetGuestInfo(params).then(res => {
if (res.data) {
this.confirmPayment(params.id)
// 不是当餐免费
if(!this.data.opt.isFree) this.confirmPaymentFun(params.id)
// 是当餐免费
if(this.data.opt.isFree == '1') this.payFreeFun()
}
})
},
... ... @@ -300,25 +495,17 @@ Page({
if (res.ret == '200' && res.data && res.data.id) {
let obj = {
name: this.data.name,
phone: this.data.phone,
purePhoneNumber: this.data.purePhoneNumber,
sex: this.data.indexs * 1 + 1,
calendarData: this.data.calendarData,
date: this.data.date,
}
wx.setStorageSync('info', obj)
this.confirmPayment(res.data.id)
// 不是当餐免费
if(!this.data.opt.isFree) this.confirmPaymentFun(res.data.id)
// 是当餐免费
if(this.data.opt.isFree == '1') this.payFreeFun()
}
})
},
// 选择日期
bind_ChangeDate(event) {
let date = event.detail.value
var calendarData = new Date(date) * 1 / 1000;
this.setData({
date,
calendarData
})
},
// 选择性别
bind_Changesex(event) {
console.log('event.detail',{...event.detail});
... ... @@ -383,8 +570,11 @@ Page({
url: '/pages/reserve/index_new',
})
}
if (this.data.opt.types == '4' || this.data.opt.types == '5') {
wx.navigateBack(2)
if (this.data.opt.types == '4') {
return wx.navigateBack(2)
}
if (this.data.opt.types == '5') {
return wx.navigateBack(2)
}
},
/**
... ...
... ... @@ -15,38 +15,30 @@
<view wx:if="{{type=='2'}}" class="coupon">
<form catchsubmit="formSubmit">
<view class="page-section">
<view class="page-section-title font32r">您的姓名</view>
<view class="page-section-title font28r">您的姓名</view>
<view class="weui-cells weui-cell__bd" style="margin: 30rpx 0">
<input class="weui-input name-input" value="{{name}}" data-params="name" placeholder="点击输入您的姓名" placeholder-style="color:#999;" bindinput="bindKeyNameInput"/>
</view>
<picker mode="selector" value="{{indexs}}" range-key="sex" data-sex='{{sexList[indexs].sex}}' range="{{sexList}}" bindchange="bind_Changesex" class="pickerSex">
<text class="sexText">{{sexList[indexs].sex}}</text>
<image src="https://qn.colorcun.com/WechatIMG695.png" mode="" class="imgs"/>
<text class="sexText font28r">{{sexList[indexs].sex}}</text>
<image src="https://qn.colorcun.com/selectImg.png" mode="" class="imgs"/>
</picker>
</view>
<view class="page-section">
<view class="page-section-title font32r">联系电话</view>
<view class="page-section-title font28r">联系电话</view>
<view class="weui-cells weui-cell__bd" style="margin: 30rpx 0">
<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" />
</view>
</view>
<view class="page-section page-section1">
<view class="page-section-title font32r">您的生日</view>
<view class="weui-cells weui-cell__bd">
<picker mode="date" value="{{date}}" bindchange="bind_ChangeDate" class="pickerBox">
<view class="colorSty">{{date?date:'点击输入您的生日'}}</view>
</picker>
</view>
<view class="more"></view>
<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" />
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumberFun" class="getPhoneBtn">获取手机号</button>
</view>
</view>
<view class="page-section">
<view class="page-section-title font32r">充值金额</view>
<view class="page-section-title font28r">充值金额</view>
<view class="weui-cells weui-cell__bd sum colorSty">
{{opt.detail.recharge_money}}元
{{opt.detail.recharge_money?opt.detail.recharge_money:opt.totalize}}元
</view>
</view>
<view wx:if="{{type=='2'}}" class="fixed_box">
<button class="font32r btns" formType="submit">确认支付
<button class="font28r btns" formType="submit">确认支付
</button>
</view>
</form>
... ... @@ -60,9 +52,9 @@
<view slot="modalName" class="titleModal">成功支付{{opt.totalize}}元</view>
<view slot="modalContent">
<block wx:if="{{type=='2'}}">
<view class="explain">
<!-- <view class="explain">
您的会员充值已经在办理中,到店消费时请和收银核实,谢谢!
</view>
</view> -->
<button wx:if="{{type=='2'}}" class="font32r btnsPay" bindtap="recharge">朕知道了
</button>
</block>
... ...
... ... @@ -61,7 +61,7 @@
margin: 0;
border-radius: 42rpx;
color: #fff;
background: linear-gradient(104.24deg, #4c8dad -57.47%, #0143a3 55.72%, #42a5ff 148.72%);
background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
}
#payModal {
... ... @@ -98,7 +98,7 @@
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 2rpx solid #E7E7E7;
border-bottom: 2rpx solid #F7F7F7;
}
.page-section1 .more {
... ... @@ -106,7 +106,22 @@
}
.weui-cells {
flex: 1;
flex: 1;
display: flex;
align-items: center;
justify-content: flex-end;
}
.getPhoneBtn {
margin: 0;
margin-right: 30rpx;
padding: 0 20rpx;
border-radius: 198rpx;
font-family: "PingFang SC";
font-weight: 600;
font-size: 24rpx;
color: #fff;
background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
}
.page-section-title {
... ... @@ -122,7 +137,8 @@
}
.name-input{
margin-right: 0;
text-align: left;
text-align: left;
flex: 1;
}
... ... @@ -151,18 +167,20 @@
}
.colorSty{
color: #999999;
color: #000;
font-size: 32rpx;
}
.pickerSex image{
width: 48rpx;
height: 48rpx;
margin-right: 30rpx;
.pickerSex {
display: flex;
align-items: center;
justify-content: center;
}
.sexText{
position: relative;
top: -10rpx;
.pickerSex image{
width: 24rpx;
height: 24rpx;
margin: 0 30rpx 0 2rpx;
}
.bottom_box {
... ...
... ... @@ -13,6 +13,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log('options',options);
this.setData({
totalPrice: options.totalPrice ? options.totalPrice : '',
totalConsumePrice: options.totalConsumePrice ? options.totalConsumePrice : '',
... ... @@ -31,7 +32,7 @@ Page({
// 跳转到我的消费金列表
gotoConsumeList() {
wx.reLaunch({
url: '/pages/me/consumeAmount'
url: '/pages/me/consumeAmount?type=1'
})
},
/**
... ...
... ... @@ -5,14 +5,13 @@
<view class="nameInfo font40r">支付成功</view>
<view class="couponTotal" wx:if="{{totalPrice && totalPrice>0}}">赠送给您<text>{{totalPrice}}元</text>代金券</view>
<view class="couponTotal" wx:if="{{totalConsumePrice && totalConsumePrice>0}}">为您返还消费金¥{{totalConsumePrice}}</view>
<view class="couponInfo font24r">您到店扫码支付即可自动使用</view>
<view class="couponInfo font24r" wx:if="{{(totalConsumePrice && totalConsumePrice>0) || (totalPrice && totalPrice>0)}}">您到店扫码支付即可自动使用</view>
<view class="btnBox">
<subscribe ids="{{[2]}}">
<view wx:if="{{totalPrice && totalConsumePrice}}" class="btnBoxs">
<view bindtap="gotoConsumeList" class="couponBtn1 font36r">查看消费金</view>
<view bindtap="certificate" class="couponBtn1 font36r">查看优惠券</view>
<view class="btnBoxs">
<view wx:if="{{totalConsumePrice && totalConsumePrice>0}}" bindtap="gotoConsumeList" class="couponBtn1 font36r">查看消费金</view>
<view wx:if="{{totalPrice && totalPrice>0}}" bindtap="certificate" class="couponBtn1 font36r">查看优惠券</view>
</view>
<view wx:else bindtap="closePage" class="couponBtn font36r">开心收下</view>
</subscribe>
</view>
</view>
\ No newline at end of file
... ...
... ... @@ -19,6 +19,8 @@ Page({
detail:{},
recharge_list:{},
StyleType:'',//邀请函模板
multiple: '',//充值倍数
recharge_list: {},//充值赠送信息
},
/**
... ... @@ -35,6 +37,13 @@ Page({
types:options.types,
rid:options.rid?options.rid:'',
StyleType:options.StyleType|| '1',
isFree:options.isFree,
multiple:options.multiple,
inputValue:options.inputValue,
totalize:options.totalize,
consume:options.consume,
activity_id:options.activity_id,
givePrice:options.givePrice,
}
})
console.log('onLoad',{...this.data.opt});
... ... @@ -44,14 +53,14 @@ Page({
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
this.getDetail();
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
if(this.data.opt.id) this.getDetail();
if(this.data.opt.isFree == '1') this.getFreeMealConfigFun()
},
/**
... ... @@ -60,6 +69,27 @@ Page({
onHide() {
},
// 获取当餐免费的配置信息
getFreeMealConfigFun() {
App.Activity.GetFreeMealConfigBySeller({
sellerid: this.data.opt.sid,
}).then(res => {
if (res && res.data && res.data.length > 0 && res.data[0].is_open == '1') {
let data = res.data[0];
let list = data.recharge_list ? JSON.parse(data.recharge_list) : {}
list.explain = data.explain;
this.setData({
multiple: data.multiple,
recharge_list: list
})
} else {
this.setData({
multiple: '',
recharge_list: {}
})
}
})
},
getDetail(){
App.Activity.GetNewRecharge({
id: this.data.opt.id
... ... @@ -83,11 +113,29 @@ Page({
url: `./receiveCoupon?id=${item.id}&name=${this.data.opt.name}&types=5&sid=${this.data.opt.sid}`,
})
},
gotoPay() {
let url = util.http_build_query({
type: '2',
types: this.data.opt.types, // 1邀请函 2提前点餐 3商家端app分享 4支付页充值 5我的页面余额充值
sid: this.data.opt.sid,
totalize: this.data.opt.totalize,
sellerName: this.data.opt.name,
givePrice: this.data.opt.givePrice,
isFree: this.data.opt.isFree,
inputValue: this.data.opt.inputValue,
multiple: this.data.opt.multiple,
consume: this.data.opt.consume,
activity_id: this.data.opt.activity_id,
}, './confirmPayment')
wx.navigateTo({
url
})
},
submitOrder(){
if(this.data.opt.isFree == '1') return this.gotoPay()
console.log('oidoid',this.data.opt.oid);
let detail=this.data.detail
detail.name=this.data.opt.name;
detail.oid=this.data.opt.oid;
if(this.data.opt.oid) detail.oid = this.data.opt.oid
App.Activity.CreateNewRechargeOrder({
recharge_id:this.data.opt.id,
sellerid:this.data.opt.sid,
... ... @@ -96,6 +144,7 @@ Page({
type:'2',
}).then(res=>{
if(res.ret=='200'){
let price = this.data.recharge_list.price*1
let url = util.http_build_query({
type:'2',
types: this.data.opt.types,// 1邀请函 2提前点餐 3商家端app分享 4支付页充值 5我的页面余额充值
... ... @@ -107,6 +156,8 @@ Page({
oid: this.data.opt.oid,
rid:this.data.opt.rid?this.data.opt.rid:'',
StyleType:this.data.opt.StyleType,
givePrice:price>0?price:0,
isFree:this.data.opt.isFree,
}, './confirmPayment')
wx.navigateTo({
url
... ...
<!--pack-activity/pack/vipRecharge.wxml-->
<wxs src="../../utils/util.wxs" module="util" />
<nav>{{opt.name}}</nav>
<nav>充值详情</nav>
<view class="wrapBox">
<view class="info">
<view class="info_left font32r">
活动名称
</view>
<view class="info_right text_info font32r">
{{detail.rname}}
{{opt.isFree == '1'? '当餐免费' : detail.rname}}
</view>
</view>
<view class="info">
<view class="info_left font32r">
充值满
{{opt.isFree == '1'? '充值实际消费金额的倍数':'充值满'}}
</view>
<view class="info_right text_info font32r">
{{detail.recharge_money}}
{{opt.isFree == '1'? multiple:detail.recharge_money}}
</view>
</view>
<view class="favourable_box">
... ... @@ -23,7 +23,7 @@
优惠活动
</view>
<view class="bundle" wx:if="{{recharge_list.is_price=='1'}}">
<view class="bundle_left font30r">
<view class="bundle_left font28r">
赠送
</view>
<view class="bundle_right font30r">
... ... @@ -31,7 +31,7 @@
</view>
</view>
<view class="bundle" wx:if="{{recharge_list.is_score=='1'}}">
<view class="bundle_left font30r">
<view class="bundle_left font28r">
赠送
</view>
<view class="bundle_right font30r">
... ... @@ -39,7 +39,7 @@
</view>
</view>
<view class="bundle" wx:if="{{recharge_list.is_coupons=='1'}}">
<view class="bundle_left font30r">
<view class="bundle_left font28r">
赠送
</view>
<view class="bundle_right font30r">
... ... @@ -52,55 +52,12 @@
{{item.aname}}
</view>
</view>
<view class="week" wx:if="{{exp_date.is_week=='1' || exp_date.is_week===true}}">
<view class="week_top">
<view class="week_left font32r">
充值日期限制:
</view>
<view class="texts font32r">
每周指定日期可用
</view>
</view>
<view class="dateList texts font32r">
{{exp_date.week_date_show}}
</view>
</view>
<view class="week" wx:if="{{exp_date.is_birthday=='1' || exp_date.is_birthday===true}}">
<view class="week_top">
<view class="week_left font32r">
充值日期限制:
</view>
<view class="texts font32r">
会员生日当天
</view>
</view>
</view>
<view class="week" wx:if="{{exp_date.is_fix=='1' || exp_date.is_fix===true}}">
<view class="week_top">
<view class="week_left font32r">
充值日期限制:
</view>
<view class="texts font32r">
无
</view>
</view>
</view>
<view class="week" wx:if="{{exp_date.is_fix=='1' || exp_date.is_fix===true}}">
<view class="week_top">
<view class="week_left font32r">
有效期:
</view>
<view class="texts font32r">
{{util.unixtoTime(detail.stime,'YYYY-MM-DD')+'至'+util.unixtoTime(detail.etime,'YYYY-MM-DD')}}
</view>
</view>
</view>
<view class="info">
<view class="info_left font32r">
备注
</view>
</view>
<text class="explain_news">{{detail.explain}}</text>
<text class="explain_news">{{opt.isFree == '1'? recharge_list.explain:detail.explain}}</text>
</view>
<view class="fixed_box">
<button class="font32r btns" bindtap="submitOrder">提交充值
... ...
... ... @@ -13,7 +13,7 @@ page {
display: flex;
justify-content: space-between;
margin-left: 32rpx;
border-bottom: 2rpx solid #E7E7E7;
border-bottom: 2rpx solid #F7F7F7;
}
.info1 {
... ... @@ -26,7 +26,7 @@ page {
.info_left {
flex-shrink: 0;
margin-right: 20rpx;
color: #515151;
color: #696969;
font-family: PingFang SC;
}
... ... @@ -44,9 +44,9 @@ page {
.explain_news {
padding: 24rpx 32rpx;
color: #999999;
color: #696969;
font-family: PingFang SC;
font-size: 24rpx;
font-size: 28rpx;
line-height: 48rpx;
display: block;
}
... ... @@ -75,7 +75,7 @@ page {
border-radius: 42rpx;
width: 100%;
color: #fff;
background: linear-gradient(104.24deg, #4c8dad -57.47%, #0143a3 55.72%, #42a5ff 148.72%);
background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
}
.favourable_box {
... ... @@ -99,26 +99,27 @@ page {
}
.bundle_left {
color: #515151;
color: #696969;
font-family: PingFang SC;
}
.bundle_right {
color: #999;
color: #000;
font-family: PingFang SC;
}
.list {
margin: 0 32rpx;
display: flex;
align-items: center;
align-items: center;
justify-content: flex-end;
flex-wrap: wrap;
border-bottom: 2rpx solid #dbdbdb;
padding-left: 32rpx;
}
.item {
color: #0143a3;
color: #e75f2e;
font-family: PingFang SC;
margin-right: 18rpx;
padding-bottom: 24rpx;
... ...
... ... @@ -168,8 +168,6 @@ Page({
util.toast('手机号获取失败!', 'none')
}
})
} else {
util.toast('手机号获取失败!', 'none')
}
},
// 用户绑定手机号
... ...
... ... @@ -24,7 +24,7 @@
<view class="rechargeItems rechargeItems1">
<text class="font36r">¥</text><input class="font28r" maxlength="5" type="number" placeholder="输入自定义金额" />
</view>
<view class="infoAgreement font24r">充值即代表同意<text>《用户协议》</text>及<text>《会员充值协议》</text></view>
<!-- <view class="infoAgreement font24r">充值即代表同意<text>《用户协议》</text>及<text>《会员充值协议》</text></view> -->
</view>
<view class="payBtnBox">
<view class="payBtn font32r" bindtap="confirmPayment">提交充值</view>
... ...
... ... @@ -914,5 +914,28 @@ export default {
//获取用户消费金消费记录
'App.Activity.GetConsumeListByOpenid':{
},
//获取用户在商家的账户余额
'App.Activity.GetRechargeBalanceByOpenid':{
},
//新增用户在商家的账户信息
'App.Activity.CreateCustomerConsumeSeller':{
},
//修改用户在商家的账户余额
'App.Activity.SetRechargeBalanceByOpenid':{
},
//使用余额支付订单
'App.Activity.CreateRechargeBalanceOrder':{
},
//获取当餐免费的配置信息
'App.Activity.GetFreeMealConfigBySeller':{
},
//获取用户在当前商家身份及是否领取过消费金
'App.Activity.GetIdentityBySeller':{
},
}
\ No newline at end of file
... ...