Commit f326e8ca65b036e41c803d7d5097a2337709c3d4

Authored by pengye
1 parent 49c128cf

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

... ... @@ -66,7 +66,8 @@
"pages/reserve/index_new",
"pages/reserve/sellerGift",
"pages/customer/login",
"pages/me/consumeAmount"
"pages/me/consumeAmount",
"pages/me/consumeDetails"
],
"requiredPrivateInfos": [
"getLocation",
... ... @@ -100,7 +101,9 @@
"pack/vipRecharge",
"pack/seeRecharge",
"pack/receiveCoupon",
"pack/buyFreeCoupon"
"pack/buyFreeCoupon",
"pack/getConsume",
"pack/paySuccess"
]
},
{
... ...
... ... @@ -17,10 +17,23 @@ Page({
inputValue: '', //输入的金额
canSolt: {}, //当前时间是哪个餐段、节假日
totalPrice: '', //送券的总金额
couponSwitch: false, //本单使用优惠券开关
consumeSwitch: false, //本单使用消费金开关
purePhoneNumber: '', //手机号
coexist: '0', //1可以同时使用券和消费金 0不可同时使用
ratio: '', //消费金支付占实际消费金额的百分比
consumeDiscount: '0.00', //消费金抵扣金额
consumePrice: '', //个人消费金余额
remainingConsume: '', //抵扣后剩余消费金余额
totalConsumePrice: 0, //赠送的消费金金额
noConfiguration: '', //配置消费金 0未配置 1已配置
returnData: '', //赠送消费金配置
isReturn: '', //赠送消费金的开关
},
sid: '', //扫码进入带的参数商家id
couponModal: '',
giveCouponModal: '',
consumeModal: '',
myToast:'',
/**
* 生命周期函数--监听页面加载
... ... @@ -28,11 +41,163 @@ Page({
onLoad(options) {
this.couponModal = this.selectComponent("#couponModal");
this.giveCouponModal = this.selectComponent("#giveCouponModal");
this.consumeModal = this.selectComponent("#consumeModal");
if (options.sid) {
this.sid = options.sid
this.getSellerDetailFun(options.sid)
}
},
// 检测用户是否绑定手机号
getCheckUserHavePhone() {
App.Wechat.CheckUserHavePhone({
openid: getApp().openid,
}).then((json) => {
if (json.ret == 200) {
let data = json.data;
if (data) {
this.setData({
purePhoneNumber: data.phone,
})
this.getUserInfo()
} else {
this.setData({
purePhoneNumber: '',
})
}
}
})
},
// 获取用户在商家&所有消费金
getUserInfo() {
App.Activity.GetConsumeBySeller({
openid: getApp().openid,
sellerid: this.sid,
}).then((json) => {
if (json.ret == 200) {
let data = json.data;
if (data && data.length > 0) {
let obj = data[0]
console.log('获取用户在商家的消费金----', obj);
this.setData({
consumePrice: obj.balance ? (obj.balance * 1).toFixed(2) : '0.00',
remainingConsume: obj.balance ? (obj.balance * 1).toFixed(2) : '0.00',
consumeDiscount: '0.00', //消费金抵扣金额
})
} else {
this.setData({
consumePrice: '0.00',
remainingConsume: '0.00',
consumeDiscount: '0.00', //消费金抵扣金额
})
}
}
})
},
// 获取商家消费金规则
getConsumeConfigFun() {
App.Activity.GetConsumeConfig({
sellerid: this.sid,
}).then(res => {
if (res && res.data) {
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) : {};
console.log('111配置---',together);
console.log('222顾客支付后返消费金---',returnData);
this.setData({
noConfiguration: '1', //配置为1 未配置为0
coexist: together.is_coexist,
ratio: together.ratio_data ? together.ratio_data : '100',
couponSwitch: true,
consumeSwitch: together.is_coexist == '1' ? true : false,
returnData,
isReturn: data.is_return,
})
} else {
this.setData({
noConfiguration: '0', //配置为1 未配置为0
couponSwitch: true,
consumeSwitch: false,
returnData: null,
isReturn: '0',
})
}
})
},
// 使用券或者消费金的开关
switchChange(event) {
let type = event.currentTarget.dataset.type;
if (type == '1') {
this.setData({
couponSwitch: event.detail.value,
})
if (this.data.coexist == '0' && event.detail.value) {
this.setData({
consumeSwitch: false,
})
}
}
if (type == '2') {
this.setData({
consumeSwitch: event.detail.value,
})
if (this.data.coexist == '0' && event.detail.value) {
this.setData({
couponSwitch: false,
})
}
}
// 开或者关闭使用优惠券
if (this.data.couponSwitch) {
this.colationData()
}
if (!this.data.couponSwitch) {
this.getCoupon()
let val = parseFloat(this.data.inputValue);
let discountPrice = 0;
let actualPrice = (val - this.data.consumeDiscount - discountPrice).toFixed(2)
this.setData({
discountPrice: 0,
actualPrice: actualPrice > 0 ? actualPrice : '0.01'
})
}
// 开或者关闭使用消费金
if (this.data.consumeSwitch) {
let val = parseFloat(this.data.inputValue);
if (!val) return
let consumeDiscount = this.calculateConsumeGold(val);
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)
this.setData({
consumeDiscount,
actualPrice: actualPrice > 0 ? actualPrice : '0.01',
remainingConsume: remainingConsume
})
}
if (!this.data.consumeSwitch) {
let val = parseFloat(this.data.inputValue);
if (!val) return
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)
this.setData({
consumeDiscount: '0.00',
actualPrice: actualPrice > 0 ? actualPrice : '0.01',
remainingConsume: this.data.consumePrice,
})
}
},
// 按比例计算出的最大可用消费金
calculateConsumeGold(val) {
let ratio = this.data.ratio;
let consumePrice = parseFloat(this.data.consumePrice);
const maxByRatio = val * (ratio / 100).toFixed(2);
let availableConsumeGold = Math.min(val, maxByRatio).toFixed(2) * 1;
if (availableConsumeGold > consumePrice) availableConsumeGold = consumePrice
return availableConsumeGold;
},
// 打开优惠券弹框
showCouponModal() {
this.couponModal.showModal()
... ... @@ -41,14 +206,30 @@ Page({
closeCouponModal() {
this.couponModal.closeModal()
},
// 打开优惠券弹框
// 打开送券送消费金弹框
showgiveCouponModal() {
this.giveCouponModal.showModal()
},
// 打开消费金弹框
showConsumeModal() {
this.consumeModal.showModal()
},
// 关闭消费金弹框
closeConsumeModal() {
this.consumeModal.closeModal()
},
// 关闭优惠券弹框
closegiveCouponModal() {
this.giveCouponModal.closeModal()
wx.exitMiniProgram({})
this.getUserInfo()
},
// 跳转登录页
gotoLogin(event) {
wx.navigateTo({
url: util.http_build_query({
types: event.currentTarget.dataset.types
}, '/pages/customer/login')
})
},
// 获取店铺名称
getSellerDetailFun(sid) {
... ... @@ -88,9 +269,9 @@ Page({
if (fullData.rule == '1') {
const price = parseFloat(fullData.price)
const amount = parseInt(priceSum / price)
if (coupons.length > 0) this.getCouponFun(coupons, '1', amount,orderid)
if (coupons.length > 0 && amount > 0) this.getCouponFun(coupons, '1', amount,orderid)
} else {
if (coupons.length > 0) this.getCouponFun(coupons, '1', 1,orderid)
if (coupons.length > 0 && amount > 0) this.getCouponFun(coupons, '1', 1,orderid)
}
}
}
... ... @@ -110,7 +291,6 @@ Page({
}
}
}
}
})
},
... ... @@ -160,7 +340,6 @@ Page({
this.setData({
totalPrice,
})
this.showgiveCouponModal()
this.setcouponFun(ids,orderid)
}
}
... ... @@ -340,9 +519,24 @@ Page({
this.setData({
discountPrice: '',
actualPrice: '',
consumeDiscount: '',
remainingConsume: this.data.consumePrice
})
}else{
this.colationData()
} else {
if (this.data.couponSwitch) {
this.colationData()
}
if (this.data.consumeSwitch && !this.data.couponSwitch) {
let val = parseFloat(this.data.inputValue);
let consumeDiscount = this.calculateConsumeGold(val);
let actualPrice = (val - consumeDiscount - this.data.discountPrice).toFixed(2)
let remainingConsume = (this.data.consumePrice * 1 - consumeDiscount).toFixed(2)
this.setData({
consumeDiscount,
actualPrice: actualPrice > 0 ? actualPrice : '0.01',
remainingConsume: remainingConsume
})
}
}
},
// 点确认选择
... ... @@ -358,7 +552,7 @@ Page({
})
console.log('优惠金额----', price);
let val = parseFloat(this.data.inputValue);
let actualPrice = (val - price).toFixed(2)
let actualPrice = (val - price - this.data.consumeDiscount).toFixed(2)
price = price.toFixed(2)
this.setData({
discountPrice: price,
... ... @@ -375,6 +569,19 @@ Page({
console.log('处理过后的券数据', list);
list.sort((a, b) => b.canCheck - a.canCheck);
list.sort((a, b) => b.showCpupon - a.showCpupon);
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)
this.setData({
consumeDiscount,
actualPrice: actualPrice > 0 ? actualPrice : '0.01',
remainingConsume: remainingConsume
})
}
this.setData({
couponArr: list,
finalList: obj.finalList
... ... @@ -389,11 +596,18 @@ Page({
}
let str = this.data.finalList.map(item => item.activity_id).join(',');
console.log('核销所勾选的券传参', str);
App.PayOnline.CombineTransactionsByNewActivity({
let params = {
sellerid: this.data.seller.sid,
price: actualPrice,
activity_id:str,
}).then(res => {
}
if (this.data.consumeDiscount) {
params.consume = this.data.consumeDiscount;
params.phone = this.data.purePhoneNumber;
}
if (str) {
params.activity_id = str;
}
App.PayOnline.CombineTransactionsByNewActivity(params).then(res => {
console.log('付款信息', res.data);
if (res.ret != '200') {
wx.showToast({
... ... @@ -412,28 +626,106 @@ Page({
success(ress) {
if (ress.errMsg == 'requestPayment:ok') {
that.giftCouponsFun(actualPrice,res.data.orderid) //送券
that.setData({
inputValue: '',
finalList: [],
couponArr: [],
discountPrice: '0.00',
actualPrice: '',
})
that.getCoupon()
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')
})
}
}, 1000);
console.log('支付成功', ress);
return
}
console.log('支付失败', ress);
that.payFail()
console.log('支付失败11', ress);
return that.myToast.showToast('支付失败,请重新下单', 2000)
},
fail(ress) {
console.log('支付失败', ress);
that.payFail()
console.log('支付失败22', ress);
return that.myToast.showToast('支付失败,请重新下单', 2000)
},
})
}
})
},3000),
payFail() {
this.setData({
inputValue: '',
finalList: [],
couponArr: [],
discountPrice: '0.00',
actualPrice: '',
consumeDiscount: '0.00', //消费金抵扣金额
})
this.getCoupon()
this.getUserInfo()
},
giftConsumeFun(priceSum, orderid) {
let isReturn = this.data.isReturn;
let data = this.data.returnData;
const now = Math.floor(Date.now() / 1000);
let totalConsumePrice = 0;
if (isReturn == '1' && data && now >= parseInt(data.stime) && now <= parseInt(data.etime)) {
priceSum = parseFloat(priceSum)
// 按百分比 is_ratio 1按比例 0按阶梯 ladder_data
if (data.is_ratio == '1' && data.ratio_data) {
totalConsumePrice = priceSum * (data.ratio_data / 100).toFixed(2);
console.log('送消费金百分比----', totalConsumePrice);
}
// 阶梯
if (data.is_ratio == '0' && data.ladder_data) {
totalConsumePrice = this.calculateGiftAmount(priceSum, data.ladder_data)
console.log('送消费金阶梯----', totalConsumePrice);
}
if (totalConsumePrice > 0) this.getConsumeFun(totalConsumePrice)
this.setData({
totalConsumePrice: (totalConsumePrice * 1).toFixed(2)
})
}
},
// 为用户增加消费金
getConsumeFun(amount) {
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
});
}
})
},
calculateGiftAmount(priceSum, ladder_data) {
if (!ladder_data || ladder_data.length === 0) {
return 0; // 没有阶梯数据,返回0
}
// 将阶梯数据按 give_price 从大到小排序,确保匹配最高阶梯
const sortedLadder = [...ladder_data].sort((a, b) =>
parseFloat(b.give_price) - parseFloat(a.give_price)
);
// 遍历排序后的阶梯,找到第一个满足条件的
for (let i = 0; i < sortedLadder.length; i++) {
const ladder = sortedLadder[i];
const threshold = parseFloat(ladder.give_price);
if (priceSum >= threshold) {
return ladder.back_price;
}
}
return 0; // 不满足任何阶梯条件
},
// 核销所勾选的券
writeOff() {
console.log('勾选的券', this.data.finalList);
... ... @@ -519,8 +811,9 @@ Page({
// 最优惠的消费券组合(消费要求为无门槛 或者 满足优惠券使用金额 && 勾选最优的、最早到期的)
findBestCoupons(arr) {
console.log('勾选最优的之前', arr);
let consumeDiscount = this.data.consumeDiscount;
let inputValue = this.data.inputValue;
const amount = parseFloat(inputValue);
const amount = parseFloat(inputValue - consumeDiscount);
const validCoupons = arr.filter(coupon => (coupon.isOk == '1' && parseFloat(coupon.desc) <= amount) && amount>=parseFloat(coupon.price));
// 排序后,优先选择最大优惠的券
validCoupons.sort((a, b) => parseFloat(b.price) - parseFloat(a.price));
... ... @@ -642,7 +935,6 @@ Page({
},
// 计算免费券有效期的起始、结束日期
setTimeRange(cdate, startOffset, endOffset) {
console.log(cdate, startOffset, endOffset);
const startDate = new Date((cdate + startOffset * 86400) * 1000);
startDate.setHours(0, 0, 0, 0);
let useStime = startDate.getTime() / 1000
... ... @@ -887,6 +1179,12 @@ Page({
url: '/pages/me/coupon_news'
})
},
// 跳转到我的消费金列表
gotoConsumeList() {
wx.reLaunch({
url: '/pages/me/consumeAmount'
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
... ... @@ -897,7 +1195,8 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
this.getCheckUserHavePhone()
this.getConsumeConfigFun()
},
/**
... ...
<!--pack-activity/pack/buyFreeCoupon.wxml-->
<nav backgroundColor="#f6f6fd">向商家付款</nav>
<nav hasHome>向商家付款</nav>
<view class="sellInfo">
<image src="{{seller.seller_image}}" mode="aspectFill" />
<view class="font32r">{{seller.sellername}}</view>
</view>
<view class="payBox">
<view class="font32r">付款金额</view>
<view class="priceTitle font32r">付款金额</view>
<view class="payView">
<text>¥</text>
<input type="digit" value="{{inputValue}}" bindchange="bindKeyInput" />
</view>
<view bindtap="showCouponModal" class="couponsBox {{available == '1' ? 'colorOrange':'colorNine'}}">
<view class="couponLeft">优惠金额</view>
<view class="couponLeft">选择优惠券</view>
<view class="couponRight">
<text wx:if="{{discountPrice && discountPrice!='0.00'}}">{{discountPrice}}</text>
<text wx:if="{{discountPrice && discountPrice!='0.00' && couponSwitch}}">-{{discountPrice}}</text>
<text class="noUse font28r" wx:if="{{couponArr.length == '0'}}">暂无可用</text>
<text class="noUse font28r" wx:elif="{{coexist == '0' && !couponSwitch}}">不可用</text>
<view class="more" style="margin-top: 6rpx;"></view>
</view>
</view>
<block wx:if="{{purePhoneNumber}}">
<view bindtap="showConsumeModal" class="couponsBox colorOrange">
<view class="couponLeft">使用消费金抵扣</view>
<view class="couponRight">
<text wx:if="{{consumeDiscount && consumeDiscount!='0.00' && consumeSwitch}}">-{{consumeDiscount}}</text>
<text class="noUse font28r" wx:if="{{consumePrice == '0.00'}}">暂无可用</text>
<text class="noUse font28r" wx:elif="{{coexist == '0' && !consumeSwitch}}">不可用</text>
<view class="more" style="margin-top: 6rpx;"></view>
</view>
</view>
</block>
<block wx:else>
<view bindtap="gotoLogin" data-types="3" class="couponsBox colorOrange">
<view class="couponLeft">使用消费金抵扣</view>
<view class="couponRight">
<view class="more" style="margin-top: 6rpx;"></view>
</view>
</view>
</block>
<view class="couponsWrap">
<view class="couponLeft">抵扣后</view>
<view class="couponRight" wx:if="{{actualPrice && inputValue}}">¥{{actualPrice}}</view>
</view>
<view class="payBtn font32r" bindtap="confirmPayment">付款</view>
</view>
<toast id="myToast"></toast>
<view class="payBtn font32r" bindtap="confirmPayment">付款</view>
<toast id="myToast"></toast>
<!-- 使用优惠券弹框 -->
<my-modal id="couponModal" fadeStyle="slideUp" height="{{couponArr.length > '3' ? '80%' : '60%'}}">
<view slot="modalName" class="titleModal">
<view class="couponTotalText">所有优惠券</view>
<view bindtap="checkCertificate" class="btn font32r">确认选择</view>
<image bind:tap="closeCouponModal" src="https://qn.colorcun.com/closeImg1.png" mode="aspectFit" />
<view class="couponTotalText font28r">所有优惠券</view>
<view bindtap="checkCertificate" class="btn font32r">确认</view>
</view>
<view slot="modalContent">
<view class="infoBox">
<view class="infoTop">
<view class="info font28r">本单使用优惠券</view>
<switch checked="{{couponSwitch}}" bindchange="switchChange" data-type="1" color="#09BB07" class="infoSwitch" />
</view>
<view class="infoBottom font24r">注意:消费金与优惠券{{coexist == '1'?'可':'不可'}}同时使用</view>
</view>
<scroll-view class="couponBox" scroll-y="true">
<checkbox-group bindchange="checkboxChange">
<view wx:for="{{couponArr}}" data-activityId="{{item.activity_id}}" class="couponItems {{item.showCpupon == '0' ? 'couponNo' : ''}}">
... ... @@ -65,17 +95,51 @@
</scroll-view>
</view>
</my-modal>
<!-- 使用消费金弹框 -->
<my-modal id="consumeModal" fadeStyle="slideUp">
<view slot="modalName" class="titleModal">
<image bind:tap="closeConsumeModal" src="https://qn.colorcun.com/closeImg1.png" mode="aspectFit" />
<view class="couponTotalText font28r">消费金抵扣</view>
<view bindtap="closeConsumeModal" class="btn font32r">确认</view>
</view>
<view slot="modalContent">
<view class="infoBox1">
<view class="infoTop">
<view class="info font28r">本单使用消费金抵扣</view>
<switch disabled="{{noConfiguration == '0'}}" checked="{{consumeSwitch}}" bindchange="switchChange" data-type="2" color="#09BB07" class="infoSwitch" />
</view>
<view class="infoBottom font24r">注意:消费金与优惠券{{coexist == '1'?'可':'不可'}}同时使用</view>
</view>
<view class="infoTop1">
<view class="info font28r">本店消费金余额</view>
<view class="info font28r">¥{{consumePrice}}</view>
</view>
<view class="infoTop1">
<view class="info font28r">本单可抵扣</view>
<view class="info font28r">¥{{consumeDiscount?consumeDiscount:'0.00'}}</view>
</view>
<view class="infoTop1">
<view class="info font28r">抵扣后剩余</view>
<view class="info font28r">¥{{remainingConsume?remainingConsume:consumePrice}}</view>
</view>
</view>
</my-modal>
<!-- 赠送优惠券/消费金弹框 -->
<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>
<view class="couponTotal">赠送给您<text>{{totalPrice}}元</text>代金券</view>
<view class="couponTotal" wx:if="{{totalPrice && totalPrice>0}}">赠送给您<text>{{totalPrice}}元</text>代金券</view>
<view class="couponTotal" wx:if="{{totalConsumePrice && totalConsumePrice>0}}">为您返还消费金¥{{totalConsumePrice}}</view>
</view>
<view slot="modalContent">
<view class="couponInfo font24r">您到店扫码支付即可自动使用</view>
<subscribe ids="{{[2]}}" bindtap="closegiveCouponModal">
<view class="couponBtn font36r">我知道了</view>
<subscribe ids="{{[2]}}">
<view wx:if="{{totalPrice && totalPrice>0 && totalConsumePrice && totalConsumePrice>0}}" class="btnBoxs">
<view bindtap="gotoConsumeList" class="couponBtn1 font36r">查看消费金</view>
<view bindtap="certificate" class="couponBtn1 font36r">查看优惠券</view>
</view>
<view wx:else bindtap="closegiveCouponModal" class="couponBtn font36r">开心收下</view>
</subscribe>
<view class="couponText font24r" bindtap="certificate">点击查看详情</view>
</view>
</my-modal>
\ No newline at end of file
... ...
... ... @@ -29,12 +29,23 @@
.payView text {
color: #000;
font-family: PingFang SC;
font-weight: 500;
font-size: 64rpx;
}
.payView input {
color: #515151;
color: #000;
height: 82rpx;
line-height: 82rpx;
font-weight: 600;
font-size: 64rpx;
}
.priceTitle {
color: #000000;
font-family: PingFang SC;
font-weight: 500;
}
.couponsBox {
... ... @@ -42,7 +53,7 @@
align-items: center;
justify-content: space-between;
color: #999;
margin: 26rpx 0;
margin: 24rpx 0;
}
.couponsBox .more {
... ... @@ -61,8 +72,8 @@
.colorOrange .more {
background-image: url('https://qn.colorcun.com/chevronRight.png');
width: 48rpx;
height: 48rpx;
width: 36rpx;
height: 32rpx;
margin-left: 0;
}
... ... @@ -79,14 +90,19 @@
}
.payBtn {
background: #05C160;
width: 70%;
border-radius: 10rpx;
margin: 0 auto;
background: #09BB07;
width: 90%;
color: #fff;
text-align: center;
padding: 20rpx 10rpx;
margin-top: 40rpx;
padding: 20rpx 0;
position: absolute;
bottom: 10%;
border-radius: 198rpx;
left: 5%;
}
.mymodal .mymodal-title {
padding: 0 !important;
}
.titleModal {
... ... @@ -94,21 +110,32 @@
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 2rpx solid #dbdbdb;
padding: 0 32rpx;
}
.couponTotalText {
color: #000000;
font-family: PingFang SC;
font-weight: 400;
}
.titleModal image {
width: 60rpx;
height: 60rpx;
}
.btn {
background: #05C160;
background: #09BB07;
border-radius: 10rpx;
color: #fff;
text-align: center;
padding: 10rpx;
padding: 10rpx 42rpx;
height: 48rpx;
line-height: 48rpx;
}
.couponItems {
border: 2rpx solid #05c160;
border: 2rpx solid #09bb07;
margin-bottom: 16rpx;
border-radius: 20rpx;
display: flex;
... ... @@ -121,7 +148,7 @@
align-items: center;
flex-direction: column;
justify-content: center;
border-right: 2rpx dashed #05C160;
border-right: 2rpx dashed #09BB07;
padding-right: 14rpx;
margin-right: 14rpx;
}
... ... @@ -135,8 +162,8 @@
}
.priceText {
color: #F6231B;
font-weight: 500;
color: #FD4D59;
font-weight: 600;
font-size: 56rpx;
margin-top: 6rpx;
display: flex;
... ... @@ -146,8 +173,9 @@
}
.icons {
color: #F6231B;
color: #FD4D59;
font-size: 20rpx;
font-weight: 500;
font-family: PingFang SC;
}
... ... @@ -170,7 +198,7 @@
}
.discountText1 {
color: #C36607;
color: #fe6d03;
font-family: PingFang SC;
font-weight: 500;
margin: 0 20rpx;
... ... @@ -232,6 +260,11 @@ checkbox {
margin-right: 20rpx;
}
checkbox[checked] .wx-checkbox-input {
border-color: #09BB07 !important;
border-width: 4rpx !important;
}
radio::before,
checkbox::before {
height: 40rpx;
... ... @@ -284,20 +317,20 @@ checkbox::before {
font-size: 52rpx;
line-height: 56rpx;
color: #fff;
margin-bottom: 150rpx;
margin-bottom: 100rpx;
padding-top: 60rpx;
}
.couponTotal {
color: #dfdfdf;
color: #fff;
font-family: PingFang SC;
font-weight: 400;
font-size: 40rpx;
line-height: 48rpx;
margin-bottom: 40rpx;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 12rpx;
}
.counterText {
... ... @@ -317,7 +350,7 @@ checkbox::before {
width: 80%;
margin: 0 auto;
border-radius: 42rpx;
background: linear-gradient(90.98deg, #f41919 0.25%, #ff7426 120.07%);
background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
font-weight: 400;
color: #fff;
text-align: center;
... ... @@ -334,7 +367,7 @@ checkbox::before {
.couponInfo {
text-decoration: none;
margin-bottom: 30rpx;
margin-bottom: 80rpx;
color: #DFDFDF;
text-align: center;
}
... ... @@ -343,6 +376,94 @@ checkbox::before {
width: 60rpx;
height: 60rpx;
position: absolute;
right: 0;
right: 20rpx;
top: 0;
}
.couponItems:nth-of-type(1) {
margin-top: 160rpx;
}
.couponBox {
position: relative;
}
.infoBox {
width: 100%;
position: absolute;
box-sizing: border-box;
left: 0;
top: 95rpx;
padding: 28rpx 40rpx 0 40rpx;
background: #fff;
z-index: 10;
}
.infoBox1 {
width: 100%;
box-sizing: border-box;
background: #fff;
z-index: 10;
position: relative;
padding: 0 24rpx 28rpx 24rpx;
}
.infoTop {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
}
.infoTop1 {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 26rpx;
box-sizing: border-box;
margin-bottom: 28rpx;
}
.infoBottom {
border-bottom: 2rpx solid #dbdbdb;
color: #696969;
font-family: PingFang SC;
font-weight: 400;
padding: 10rpx 0 30rpx 0;
}
.info {
color: #fe6d03;
font-family: PingFang SC;
font-weight: 500;
}
.infoTop switch {
transform: scale(.9);
}
.noUse {
font-family: PingFang SC;
font-weight: 400;
color: #ED7B2F;
}
.btnBoxs {
display: flex;
align-items: center;
justify-content: space-between;
}
.couponBtn1 {
width: 40%;
margin: 0 auto;
border-radius: 42rpx;
background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
font-weight: 400;
color: #fff;
text-align: center;
border: 4rpx solid #fff;
padding: 12rpx 0;
margin: 16rpx auto 20rpx auto;
}
\ No newline at end of file
... ...
// pack-activity/pack/getConsume.js
import util from '../../utils/util';
import App from '../../utils/api';
Page({
/**
* 页面的初始数据
*/
data: {
sellerid: '',
amount: '',
purePhoneNumber: '',
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log('options---',options);
this.setData({
sellerid: options.sellerid || '',
amount: options.amount ? (options.amount * 1).toFixed(2) : '',
})
if (options.sellerid) {
this.getSellerDetailFun(options.sellerid)
}
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.getCheckUserHavePhone()
},
// 检测用户是否绑定手机号
getCheckUserHavePhone() {
App.Wechat.CheckUserHavePhone({
openid: getApp().openid,
}).then((json) => {
if (json.ret == 200) {
let data = json.data;
if (data) {
this.setData({
purePhoneNumber: data.phone,
})
} else {
this.setData({
purePhoneNumber: '',
})
}
}
})
},
// 跳转登录页
gotoLogin(event) {
wx.navigateTo({
url: util.http_build_query({
types: event.currentTarget.dataset.types
}, '/pages/customer/login')
})
},
// 为用户增加消费金
getConsumeFun() {
App.Activity.SetConsumeByOpenid({
phone: this.data.purePhoneNumber,
openid: getApp().openid,
amount: this.data.amount,
sellerid: this.data.sellerid
}).then(res => {
if (res.data == '0') {
wx.showToast({
title: '领取失败,请稍后再试!',
duration: 1000,
icon: 'none',
mask: true
});
} else {
wx.showToast({
title: '领取成功!',
duration: 1000,
icon: 'none',
mask: true
});
}
wx.exitMiniProgram({});
})
},
// 获取店铺名称
getSellerDetailFun(sellerid) {
App.Customer.GetSellerDetail({
sid:sellerid
}).then(res => {
let data = res.data;
this.setData({
seller: {
seller_image: data.seller_image,
sellername: data.sellername,
sid: data.id
}
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
... ...
{
"navigationBarBackgroundColor": "#fff",
"navigationBarTextStyle": "black",
"usingComponents": {
"nav": "/components/nav/nav"
}
}
\ No newline at end of file
... ...
<!--pack-activity/pack/getConsume.wxml-->
<nav backgroundColor="#fff">领取消费金</nav>
<view class="boxInfo">
<image src="{{seller.seller_image}}" mode="aspectFill" />
<view class="sellerText" wx:if="{{seller.sellername}}">{{seller.sellername}}</view>
<view class="text1 font40r" wx:if="{{amount}}">为您发放消费金¥{{amount}}</view>
<view class="text1 font24r">您到店扫码支付即可自动使用</view>
</view>
<block wx:if="{{purePhoneNumber}}">
<view class="btn font28r" bind:tap="getConsumeFun">开心收下</view>
</block>
<block wx:else>
<view class="btn font28r" bind:tap="gotoLogin" data-types="3">开心收下</view>
</block>
\ No newline at end of file
... ...
/* pack-activity/pack/getConsume.wxss */
.boxInfo {
padding: 30% 0 40rpx 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
}
.boxInfo image {
width: 200rpx;
height: 200rpx;
margin-bottom: 20rpx;
}
.sellerText {
color: #000000;
font-family: PingFang SC;
font-weight: 600;
font-size: 52rpx;
margin-bottom: 80rpx;
}
.text1 {
color: #000000;
font-family: PingFang SC;
font-weight: 400;
margin-bottom: 20rpx;
}
.btn {
position: absolute;
bottom: 10%;
width: 90%;
left: 5%;
padding: 20rpx 0;
border-radius: 198rpx;
color: #ffffff;
font-family: PingFang SC;
font-weight: 600;
text-align: center;
background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
}
\ No newline at end of file
... ...
// pack-activity/pack/paySuccess.js
Page({
/**
* 页面的初始数据
*/
data: {
totalPrice: '',
totalConsumePrice: '',
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.setData({
totalPrice: options.totalPrice ? options.totalPrice : '',
totalConsumePrice: options.totalConsumePrice ? options.totalConsumePrice : '',
})
},
// 跳转到我的券列表
certificate() {
wx.reLaunch({
url: '/pages/me/coupon_news'
})
},
// 退出小程序
closePage() {
wx.exitMiniProgram({});
},
// 跳转到我的消费金列表
gotoConsumeList() {
wx.reLaunch({
url: '/pages/me/consumeAmount'
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
... ...
{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTextStyle":"black",
"usingComponents": {
"nav":"/components/nav/nav"
}
}
\ No newline at end of file
... ...
<!--pack-activity/pack/paySuccess.wxml-->
<nav backgroundColor="#fff">支付结果</nav>
<view class="box">
<image src="https://qn.colorcun.com/paySuccessImg.png" mode="aspectFit" />
<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="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>
<view wx:else bindtap="closePage" class="couponBtn font36r">开心收下</view>
</subscribe>
</view>
</view>
\ No newline at end of file
... ...
/* pack-activity/pack/paySuccess.wxss */
.box {
padding-top: 260rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.box image {
width: 100rpx;
height: 100rpx;
}
.nameInfo {
margin: 40rpx 0 72rpx 0;
color: #000000;
font-family: "PingFang SC";
font-weight: 600;
}
.couponTotal {
color: #000;
font-family: PingFang SC;
font-weight: 400;
font-size: 32rpx;
line-height: 44rpx;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 12rpx;
}
.couponInfo {
color: #000;
text-align: center;
margin-bottom: 30rpx;
}
.btnBox {
width: 100%;
position: absolute;
bottom: 20%;
}
.btnBoxs {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
}
.couponBtn1 {
width: 40%;
margin: 0 auto;
border-radius: 42rpx;
background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
font-weight: 400;
color: #fff;
text-align: center;
border: 4rpx solid #fff;
padding: 12rpx 0;
margin: 16rpx auto 20rpx auto;
}
.couponBtn {
width: 80%;
margin: 0 auto;
border-radius: 42rpx;
background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
font-weight: 400;
color: #fff;
text-align: center;
border: 4rpx solid #fff;
padding: 12rpx 0;
margin: 16rpx auto 20rpx auto;
}
\ No newline at end of file
... ...
... ... @@ -6,7 +6,7 @@ Page({
* 页面的初始数据
*/
data: {
types: '', //1领券 2赴约
types: '', //1领券 2赴约 3优惠券详情领券、消费金领券
avatarUrl: 'https://nosqn.colorcun.com/defaultAvatar.png',
nickName: '',
token: '',
... ... @@ -189,7 +189,7 @@ Page({
// 2赴约
} else if (this.data.types == '2') {
this.confirmed()
// 3优惠券详情领券
// 3优惠券详情领券、消费金领券
}else if (this.data.types == '3') {
setTimeout(() => {
util.toast('登陆成功!', 'none')
... ...
// pages/me/consumeAmount.js
import App from '../../utils/api';
import util from '../../utils/util';
Page({
/**
* 页面的初始数据
*/
data: {
sellerList: [],
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.getInfo()
},
// 获取用户消费金商家余额列表
getInfo() {
App.Activity.GetConsumeSellerListByOpenid({
openid: getApp().openid,
}).then(res => {
let sellerList = res.data;
sellerList.forEach(i => {
i.balance = (i.balance * 1).toFixed(2)
})
this.setData({
sellerList
})
})
},
// 跳转用户商家消费金消费记录
getSeller(event) {
wx.navigateTo({
url: util.http_build_query({
sellerid: event.currentTarget.dataset.id
}, '/pages/me/consumeDetails')
})
},
// 换号查看
switchAccount() {
wx.redirectTo({
url: util.http_build_query({
types: '3'
}, '/pages/customer/login')
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
... ...
<!--pages/me/consumeAmount.wxml-->
<wxs src="../../utils/util.wxs" module="util" />
<nav>我的消费金</nav>
\ No newline at end of file
<nav hasHome>我的消费金</nav>
<view class="{{sellerList.length>0?'box':'box1'}}">
<block wx:if="{{sellerList.length>0}}">
<view class="items" wx:for="{{sellerList}}" bind:tap="getSeller" data-id="{{item.sellerid}}">
<image src="{{item.seller_image}}" mode="aspectFit" />
<view class="info">
<view class="name font28r">{{item.sellername}}</view>
<view class="priceBox font32r">余额 <text>¥{{item.balance}}</text></view>
</view>
<view class="rightIcon">
<text class="font28r">查看</text>
<view class="more"></view>
</view>
</view>
</block>
<block wx:else>
<image class="noDataImg" src="https://qn.colorcun.com/noConsumeData.png" mode="aspectFit" />
<view class="font28r noDataText">暂无消费金</view>
<view class="btn font28r" bind:tap="switchAccount">换号查看</view>
</block>
</view>
\ No newline at end of file
... ...
/* pages/me/consumeAmount.wxss */
\ No newline at end of file
/* pages/me/consumeAmount.wxss */
page {
background: #F5F5F5;
}
.box {
background: #fff;
margin: 12rpx;
}
.items {
padding: 28rpx 24rpx 20rpx 40rpx;
border-bottom: 2rpx solid #CBCBCB;
display: flex;
align-items: center;
justify-content: space-between;
margin: 0 8rpx 0 8rpx;
}
.items image {
width: 100rpx;
height: 100rpx;
border-radius: 10rpx;
}
.info {
margin-left: 32rpx;
flex: 1;
}
.info .name {
color: #000000;
font-family: PingFang SC;
font-weight: 400;
}
.priceBox {
color: #000000;
font-family: PingFang SC;
font-weight: 400;
margin-top: 14rpx;
}
.priceBox text {
color: #fe6f03;
}
.rightIcon {
display: flex;
align-items: center;
color: #696969;
}
.more {
margin-left: 14rpx;
}
.box1 {
margin-top: 30%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.noDataImg {
width: 162rpx;
height: 162rpx;
}
.noDataText {
color: #696969;
font-family: PingFang SC;
font-weight: 400;
}
.btn {
position: absolute;
width: 90%;
bottom: 10%;
left: 5%;
border-radius: 198rpx;
padding: 20rpx 0;
color: #ffffff;
font-family: "PingFang SC";
font-weight: 600;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(90deg, #ff4d11 0%, #fe7600 100%);
}
\ No newline at end of file
... ...
// pages/me/consumeDetails.js
import App from '../../utils/api';
import util from '../../utils/util';
Page({
/**
* 页面的初始数据
*/
data: {
sellerid: '',
consumeList: []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.setData({
sellerid: options.sellerid
})
this.getInfo(options.sellerid)
},
getInfo(sellerid) {
App.Activity.GetConsumeListByOpenid({
openid: getApp().openid,
sellerid
}).then(res => {
let consumeList = res.data;
consumeList.forEach(i => {
i.price = (i.price * 1).toFixed(2)
i.balance = (i.balance * 1).toFixed(2)
i.cdateInfo = i.cdate ? util.unixtoTime(i.cdate, 'YYYY-MM-DD HH:II') : '';
})
this.setData({
consumeList
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
... ...
{
"usingComponents": {
"nav": "/components/nav/nav"
}
}
\ No newline at end of file
... ...
<!--pages/me/consumeDetails.wxml-->
<wxs src="../../utils/util.wxs" module="util" />
<nav hasHome>消费金明细</nav>
<view class="box">
<view class="items" wx:for="{{consumeList}}" bind:tap="getSeller" data-id="{{item.sellerid}}">
<view class="topInfo">
<view class="types font28r">{{item.type=='1'?'消耗':'获取'}}</view>
<view class="priceInfo font40r {{item.type=='1'?'colors1':'colors2'}}">{{item.type=='1'?'-':'+'}}¥{{item.price}}</view>
</view>
<view class="bottomInfo">
<view class="text1 font28r">{{item.cdateInfo}}</view>
<view class="text1 font28r">本店消费金余额 ¥{{item.balance}}</view>
</view>
</view>
</view>
\ No newline at end of file
... ...
/* pages/me/consumeDetails.wxss */
page {
background: #F5F5F5;
}
.box {
background: #fff;
margin: 12rpx;
}
.items {
padding: 28rpx 24rpx 20rpx 40rpx;
border-bottom: 2rpx solid #CBCBCB;
display: flex;
flex-direction: column;
margin: 0 8rpx 0 8rpx;
}
.topInfo {
display: flex;
align-items: center;
justify-content: space-between;
}
.bottomInfo {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 30rpx;
}
.types {
color: #000000;
font-family: PingFang SC;
font-weight: 400;
}
.priceInfo {
font-family: PingFang SC;
font-weight: 500;
}
.colors1 {
color: #696969;
}
.colors2 {
color: #fe6f03;
}
.text1 {
color: #696969;
font-family: PingFang SC;
font-weight: 400;
}
\ No newline at end of file
... ...
<!--pages/taocan/coupon_news.wxml 用户端--我的--卡券-->
<wxs src="../../utils/util.wxs" module="util" />
<nav>卡券</nav>
<nav hasHome>卡券</nav>
<scroll-view class="list" style="height:{{contentHeight}}px;" scroll-y>
<block wx:if="{{list.length>0}}">
<view wx:for="{{list}}" bindtap="todetail" data-item="{{item}}" class="preferentialItems {{item.noShow == '0' ? 'noStyle':''}}">
... ...
... ... @@ -77,6 +77,7 @@ Page({
this.getlist()
this.GetCollectionSellerList()
this.getInfo()
this.getUserInfo()
},
// 获取用户昵称、头像
getInfo() {
... ... @@ -88,11 +89,30 @@ Page({
this.setData({
nickname: data.nickname ? data.nickname : '',
headimgurl: data.headimgurl ? data.headimgurl : '',
price: data.price ? data.price : '0.00',
})
}
})
},
// 获取用户在商家&所有消费金
getUserInfo() {
App.Activity.GetConsumeBySeller({
openid: getApp().openid,
}).then((json) => {
if (json.ret == 200) {
let data = json.data;
if (data && data.length > 0) {
let obj = data[0]
this.setData({
price: obj.balance ? (obj.balance * 1).toFixed(2) : '0.00',
})
} else {
this.setData({
price: '0.00',
})
}
}
})
},
// 顾客收藏的店铺列表
GetCollectionSellerList() {
App.Customer.GetCollectionSellerList({
... ...
... ... @@ -894,5 +894,25 @@ export default {
//根据openid和手机号获取个人账户信息
'App.Wechat.GetUserInfoByOpenidPhone':{
},
//获取商家消费金规则
'App.Activity.GetConsumeConfig':{
},
//为用户增加消费金
'App.Activity.SetConsumeByOpenid':{
},
//获取用户在商家&所有消费金
'App.Activity.GetConsumeBySeller':{
},
//获取用户消费金商家余额列表
'App.Activity.GetConsumeSellerListByOpenid':{
},
//获取用户消费金消费记录
'App.Activity.GetConsumeListByOpenid':{
},
}
\ No newline at end of file
}
\ No newline at end of file
... ...