商品兑换券更新

This commit is contained in:
GaoHao
2024-11-19 16:58:37 +08:00
parent d2dbfd5163
commit 8c5e03d6c4
10 changed files with 141 additions and 69 deletions

View File

@@ -155,9 +155,12 @@ export default {
locationdistrict(data) { //获取行政区域(区,街道) locationdistrict(data) { //获取行政区域(区,街道)
return uni.api.get("/location/district", data); return uni.api.get("/location/district", data);
}, },
queryMemberAccount(data) { //获取行政区域(区,街道) queryMemberAccount(data) { //获取余额明细
return uni.api.get("/pay/queryMemberAccount", data); return uni.api.get("/pay/queryMemberAccount", data);
}, },
queryMemberPointsLog(data) { //获取余额明细
return uni.api.get("/api/points/member-points-log/page", data);
},
ordermineCoupons(data) { //我的优惠券 ordermineCoupons(data) { //我的优惠券
return uni.api.get("/order/mineCoupons", data, false); return uni.api.get("/order/mineCoupons", data, false);
}, },

View File

@@ -6,10 +6,10 @@ const proxyApi = "/api"
// const proxyApi = 'http://192.168.1.15:9888/cashierService' // 王伟 // const proxyApi = 'http://192.168.1.15:9888/cashierService' // 王伟
// const proxyApi = 'http://192.168.1.27:9888/cashierService' // 帆哥 // const proxyApi = 'http://192.168.1.27:9888/cashierService' // 帆哥
// const proxyApiwws = 'ws://192.168.1.15:9888/netty' // 测试 // const proxyApiwws = 'ws://192.168.1.15:9888/netty' // 测试
const proxyApi = 'https://wxcashiertest.sxczgkj.cn/cashierService' // 测试 // const proxyApi = 'https://wxcashiertest.sxczgkj.cn/cashierService' // 测试
const proxyApiwws = 'wss://wxcashiertest.sxczgkj.cn/netty' // 测试 // const proxyApiwws = 'wss://wxcashiertest.sxczgkj.cn/netty' // 测试
// const proxyApi = 'https://pre-cashier.sxczgkj.cn/cashierService' // 预发布 const proxyApi = 'https://pre-cashier.sxczgkj.cn/cashierService' // 预发布
// const proxyApiwws = 'wss://pre-cashier.sxczgkj.cn/netty' // 预发布 const proxyApiwws = 'wss://pre-cashier.sxczgkj.cn/netty' // 预发布
// const proxyApi = 'https://cashier.sxczgkj.cn/cashierService' // 线上 // const proxyApi = 'https://cashier.sxczgkj.cn/cashierService' // 线上
// const proxyApiwws = 'wss://cashier.sxczgkj.cn/netty' // 线上 // const proxyApiwws = 'wss://cashier.sxczgkj.cn/netty' // 线上
// #endif // #endif

View File

@@ -8,7 +8,7 @@
</view> </view>
<view class="bildRight"> <view class="bildRight">
<text>我的积分</text> <text>我的积分</text>
<view>{{info.levelConsume}}</view> <view>{{info.accountPoints}}</view>
</view> </view>
</view> </view>
<view class="navTop"> <view class="navTop">
@@ -26,14 +26,16 @@
<view class="flex-start"> <view class="flex-start">
<view class="listStyle_left"> <view class="listStyle_left">
<view class="listrigth"> <view class="listrigth">
<view>{{item.biz_name}}</view> <view>{{active == 1 ? item.biz_name : item.memberName}}</view>
<view :class="[item.type == '+'?'colorStyle':'']">{{item.type}}{{item.amount}} <view :class="[item.type == '+'?'colorStyle':'']">
{{ active == 1 ? item.type : (item.floatType == 'add'?'+':'')}}
{{active == 1 ? item.amount : item.floatPoints}}
</view> </view>
</view> </view>
</view> </view>
<view class="listrigth2"> <view class="listrigth2">
<view>{{$u.timeFormat(item.create_time, 'yyyy-mm-dd hh:MM:ss')}}</view> <view>{{$u.timeFormat(item.create_time, 'yyyy-mm-dd hh:MM:ss')}}</view>
<view>余额:{{item.balance}}</view> <view v-if="active == 1">余额:{{item.balance}}</view>
</view> </view>
</view> </view>
@@ -53,13 +55,15 @@
pageSize: 10, pageSize: 10,
memberId: null memberId: null
}, },
info: null info: null,
shopId: null
} }
}, },
onLoad(e) { onLoad(e) {
console.log(JSON.parse(e.shopUserInfo)) console.log(JSON.parse(e.shopUserInfo))
this.info = JSON.parse(e.shopUserInfo) this.info = JSON.parse(e.shopUserInfo)
this.form.memberId = this.info.id; this.form.memberId = this.info.id;
this.shopId = this.info.shopId;
this.getlist() this.getlist()
}, },
onReachBottom() { onReachBottom() {
@@ -73,20 +77,29 @@
}, },
async getlist() { async getlist() {
if (this.active == 1) { if (this.active == 1) {
let res = await this.api.queryMemberAccount(this.form) let res = await this.api.queryMemberAccount({
...this.form
})
if (res.code == 0 && res.data.list.length > 0) { if (res.code == 0 && res.data.list.length > 0) {
console.log(this.list.length)
this.list = this.list.concat(res.data.list) this.list = this.list.concat(res.data.list)
this.form.page++ this.form.page++
console.log(this.list)
} }
} else { } else {
this.list = []
let res = await this.api.queryMemberPointsLog({
shopId: this.shopId,
...this.form
})
if (res.code == 0 && res.data.list.length > 0) {
this.list = this.list.concat(res.data.list)
this.form.page++
}
} }
}, },
clickEvent(i) { clickEvent(i) {
this.active = i; this.active = i;
this.form.page = 1; this.form.page = 1;
this.list = []
this.getlist() this.getlist()
} }
} }

View File

@@ -135,7 +135,9 @@
type: 'index', type: 'index',
}) })
} else if ( type == 3 ) { } else if ( type == 3 ) {
uni.pro.navigateTo('user/coupon') uni.pro.navigateTo('user/coupon', {
shopId: this.shopId,
})
} }
}, },

View File

@@ -715,6 +715,7 @@
"skuId": this.skuId, "skuId": this.skuId,
"num": num, //数量 "num": num, //数量
"type": a == '+' ? 1 : 0, "type": a == '+' ? 1 : 0,
"isVip": item.isVip,
"productId": item.id, //商品id "productId": item.id, //商品id
"shopId": this.shopId, "shopId": this.shopId,
"note": item.note, "note": item.note,
@@ -966,11 +967,12 @@
let res = await this.api.productqueryProductSku({ let res = await this.api.productqueryProductSku({
code: this.tableCode, code: this.tableCode,
shopId: this.shopId, shopId: this.shopId,
"isVip": 0, isVip: item.isVip, //商品id
productId: item.id, //商品id productId: item.id, //商品id
spec_tag: this.skuidname.join(","), spec_tag: this.skuidname.join(","),
}) })
this.salePrice = res.data.salePrice // 价格
this.salePrice = this.isVip == 1 && res.data.memberPrice > 0 ? res.data.memberPrice : res.data.salePrice // 价格
let data = null; let data = null;
if (a == 1) { //1添加购物车 2是websocket返回这个商品的价格(应为不同的多规格商品返回不同的价格) if (a == 1) { //1添加购物车 2是websocket返回这个商品的价格(应为不同的多规格商品返回不同的价格)
let params = { let params = {
@@ -979,7 +981,7 @@
"type": c == '+' ? 1 : 0, "type": c == '+' ? 1 : 0,
"productId": item.id, //商品id "productId": item.id, //商品id
"note": item.note, "note": item.note,
"isVip": 0, "isVip": item.isVip,
"shopId": this.shopId, "shopId": this.shopId,
"userId": uni.cache.get('userInfo').id, "userId": uni.cache.get('userInfo').id,
} }

View File

@@ -95,14 +95,17 @@
status: 1, status: 1,
type: "", type: "",
payAmount: 0, payAmount: 0,
shopId: null,
shoppingCart: [], shoppingCart: [],
productList: [], productList: [],
}; };
}, },
onLoad(options) { onLoad(options) {
console.log(options)
if (options.type) { this.type = options.type } if (options.type) { this.type = options.type }
if (options.payAmount) { this.payAmount = options.payAmount } if (options.payAmount) { this.payAmount = options.payAmount }
if (options.shopId) { this.shopId = options.shopId }
if (options.shoppingCart) { this.shoppingCart = JSON.parse(decodeURIComponent(options.shoppingCart)) } if (options.shoppingCart) { this.shoppingCart = JSON.parse(decodeURIComponent(options.shoppingCart)) }
if (options.productList) { this.productList = JSON.parse(decodeURIComponent(options.productList)) } if (options.productList) { this.productList = JSON.parse(decodeURIComponent(options.productList)) }
}, },
@@ -128,12 +131,14 @@
try { try {
let params = { let params = {
userId: uni.cache.get('userInfo').id, userId: uni.cache.get('userInfo').id,
shopId: uni.cache.get('shopId'),
status: this.status status: this.status
} }
if ( this.type == 'confirm_order_coupon' || this.type == 'confirm_order_product' ) { if ( this.type == 'confirm_order_coupon' || this.type == 'confirm_order_product' ) {
params.orderId = -1; params.orderId = -1;
} }
if ( this.shopId ) {
params.shopId = this.shopId;
}
console.log("params",params) console.log("params",params)
let res = await this.api.conponList(params) let res = await this.api.conponList(params)
if (res.code == 0) { if (res.code == 0) {

View File

@@ -207,7 +207,7 @@
}) })
setTimeout(()=>{ setTimeout(()=>{
uni.pro.redirectTo('/pages/user/coupon', { uni.pro.redirectTo('/pages/user/coupon', {
type: 1 type: 1,
}) })
},1000) },1000)
} }

View File

@@ -61,7 +61,7 @@
</view> </view>
<view class="favorable_right" v-if="item.type=='coupon'"> <view class="favorable_right" v-if="item.type=='coupon'">
<text class="favorable_right_text">{{item.value}}</text> <text class="favorable_right_text">{{item.value}}</text>
<u-icon name="arrow-right" color="#575B66" size="28"></u-icon> <u-icon name="arrow-right" color="#575B66" size="28" v-if="listinfo.status == 'unpaid' || listinfo.status == 'paying'"></u-icon>
</view> </view>
<view class="favorable_right" :class="{column:item.value.length>0}" v-if="item.type=='product'"> <view class="favorable_right" :class="{column:item.value.length>0}" v-if="item.type=='product'">
<view class="favorable_right_text" v-for="(items,indexs) in item.value" :key="indexs"> <view class="favorable_right_text" v-for="(items,indexs) in item.value" :key="indexs">
@@ -69,7 +69,7 @@
<text>X{{items.num}}</text> <text>X{{items.num}}</text>
<text>-{{items.discountAmount || 0}}</text> <text>-{{items.discountAmount || 0}}</text>
</view> </view>
<u-icon v-if="item.value.length <= 0" name="arrow-right" color="#575B66" size="28"></u-icon> <u-icon v-if="item.value.length <= 0 && (listinfo.status == 'unpaid' || listinfo.status == 'paying')" name="arrow-right" color="#575B66" size="28"></u-icon>
</view> </view>
<view class="favorable_right" v-if="item.type=='points'" @click.stop="pointsChange"> <view class="favorable_right" v-if="item.type=='points'" @click.stop="pointsChange">
<text class="favorable_right_text" style="color: #666;margin-right: 16rpx;" v-if="calcUsablePointsData.usable"> <text class="favorable_right_text" style="color: #666;margin-right: 16rpx;" v-if="calcUsablePointsData.usable">
@@ -211,7 +211,12 @@
_this.pointsChange() _this.pointsChange()
_this.getCalcUsablePoints() _this.getCalcUsablePoints()
} }
this.$emit("setPayAmount",_this.listinfo.payAmount) this.$emit("setPayAmount",{
payAmount: this.listinfo.payAmount,
userCouponInfos: this.userCouponInfos,
calcUsablePointsData: this.calcUsablePointsData,
isPointsChecked: this.isPointsChecked,
})
} else { } else {
uni.showToast({ uni.showToast({
title: "优惠券满减金额大于订单金额不可使用", title: "优惠券满减金额大于订单金额不可使用",
@@ -219,7 +224,8 @@
}) })
} }
} else { //商品券 } else { //商品券
//不包含商品券的金额
let currentPayAmount = 0;
// 筛选选中商品券商品列表 // 筛选选中商品券商品列表
let couponList = _this.listinfo.details.filter(v => v.productId == couponData.proId); let couponList = _this.listinfo.details.filter(v => v.productId == couponData.proId);
//金额从小到大排序 //金额从小到大排序
@@ -227,31 +233,43 @@
let productTicketList = _this.userCouponInfos.filter(v => v.productId == couponData.proId); let productTicketList = _this.userCouponInfos.filter(v => v.productId == couponData.proId);
//商品券抵扣的数量 //商品券抵扣的数量
let productNum = couponData.num; let productNum = couponData.num;
// 使用数量
let num = 0;
let productPayAmount = 0; let productPayAmount = 0;
let productTicketNum = 0; let productTicketNum = 0;
let productNumber = 0; let productNumber = 0;
productTicketList.map((item,index) => { productTicketList.map((item,index) => {
console.log(item)
productTicketNum += item.num productTicketNum += item.num
_this.listinfo.payAmount = Number(_this.listinfo.payAmount) + item.discountAmount
}) })
console.log(productTicketList) console.log(productTicketNum)
console.log(minCouponList) let productTicketNumber = 0;
minCouponList.map((item,index) => { minCouponList.map((item,index) => {
// productNumber += item.num // productNumber += item.num
if ( productNum > 0) { console.log("productTicketNum==",productTicketNum)
item.num = (item.num - productTicketNum) <= 0 ? 0 : (item.num - productTicketNum) if ( productNum > 0 && productTicketNum > 0) {
productTicketNumber = productTicketNum
productTicketNum = (item.num - productTicketNum) <= 0 ? (productTicketNum - item.num) : item.num - productTicketNum productTicketNum = (item.num - productTicketNum) <= 0 ? (productTicketNum - item.num) : item.num - productTicketNum
console.log(productTicketNum) console.log("item.num - productTicketNumber===",item.num - productTicketNumber)
} }
if ( productNum > 0 && productTicketNum > 0) {
item.num = (item.num - productTicketNumber) <= 0 ? 0 : (item.num - productTicketNumber)
}
console.log("productTicketNum==",productTicketNum)
console.log("item.num===",item.num)
if ( productNum > 0 && item.num > 0) { if ( productNum > 0 && item.num > 0) {
console.log("index===",index)
let num = productNum >= item.num ? item.num : productNum let num = productNum >= item.num ? item.num : productNum
productNum = (productNum - item.num) >= 0 ? (productNum - item.num) : 0; productNum = (productNum - item.num) >= 0 ? (productNum - item.num) : 0;
productPayAmount = productPayAmount + (num*(item.memberPrice > 0 ? item.memberPrice : item.price))
// let num = productNum >= item.num ? item.num : productNum
// productNum = (productNum - item.num) >= 0 ? (productNum - item.num) : 0;
// productNum = num <= productNum ? num : productNum; productPayAmount = productPayAmount + (num*(item.memberPrice > 0 ? item.memberPrice : item.price))
} }
}) })
if ( productPayAmount > _this.listinfo.payAmount) {
}
_this.userCouponInfos.push({ _this.userCouponInfos.push({
userCouponId: couponData.id, userCouponId: couponData.id,
type: couponData.type, type: couponData.type,
@@ -268,11 +286,11 @@
num: productNum == 0 ? couponData.num : (couponData.num - productNum), num: productNum == 0 ? couponData.num : (couponData.num - productNum),
}) })
console.log(productNum) console.log(productNum)
console.log(productNum == 0 ? couponData.num : productNum)
if ( _this.isPointsChecked) { if ( _this.isPointsChecked) {
_this.pointsChange() _this.pointsChange()
} }
this.setPayAmount()
_this.setPayAmount()
} }
uni.$off('couponItem') uni.$off('couponItem')
}, },
@@ -285,9 +303,9 @@
console.log(this.userCouponInfos) console.log(this.userCouponInfos)
this.userCouponInfos.forEach(item => { this.userCouponInfos.forEach(item => {
if ( item.type == 1 ) { if ( item.type == 1 ) {
if ( item.discountAmount && item.discountAmount > 0 ) { // if ( item.discountAmount && item.discountAmount > 0 ) {
this.listinfo.payAmount = (this.listinfo.payAmount - item.discountAmount).toFixed(2) // this.listinfo.payAmount = (this.listinfo.payAmount - item.discountAmount).toFixed(2)
} // }
} else { } else {
if ( item.discountAmount && item.discountAmount > 0 ) { if ( item.discountAmount && item.discountAmount > 0 ) {
this.listinfo.payAmount = (this.listinfo.payAmount - item.discountAmount).toFixed(2) this.listinfo.payAmount = (this.listinfo.payAmount - item.discountAmount).toFixed(2)
@@ -299,7 +317,12 @@
this.isPointsChecked = false; this.isPointsChecked = false;
this.getCalcUsablePoints() this.getCalcUsablePoints()
this.$emit("setPayAmount",this.listinfo.payAmount) this.$emit("setPayAmount",{
payAmount: this.listinfo.payAmount,
userCouponInfos: this.userCouponInfos,
calcUsablePointsData: this.calcUsablePointsData,
isPointsChecked: this.isPointsChecked,
})
}, },
/** /**
* 积分状态监听 * 积分状态监听
@@ -318,34 +341,45 @@
this.listinfo.payAmount = (Number(this.listinfo.payAmount)+(this.calcUsablePointsData.pointsNum/this.calcUsablePointsData.equivalentPoints)).toFixed(2); this.listinfo.payAmount = (Number(this.listinfo.payAmount)+(this.calcUsablePointsData.pointsNum/this.calcUsablePointsData.equivalentPoints)).toFixed(2);
} }
console.log(this.listinfo.payAmount) console.log(this.listinfo.payAmount)
this.$emit("setPayAmount",this.listinfo.payAmount) this.$emit("setPayAmount",{
payAmount: this.listinfo.payAmount,
userCouponInfos: this.userCouponInfos,
calcUsablePointsData: this.calcUsablePointsData,
isPointsChecked: this.isPointsChecked,
})
}, },
goUrl(item){ goUrl(item){
switch (item.type){ if ( this.listinfo.status == 'unpaid' || this.listinfo.status == 'paying') {
case 'coupon': switch (item.type){
let payAmount = this.listinfo.payAmount; case 'coupon':
let couponList = this.userCouponInfos.filter(v => v.type == 1); let payAmount = this.listinfo.payAmount;
if ( couponList.length > 0 ) { let couponList = this.userCouponInfos.filter(v => v.type == 1);
payAmount = payAmount + couponList.discountAmount; if ( couponList.length > 0 ) {
} payAmount = payAmount + couponList.discountAmount;
uni.pro.navigateTo('/pages/user/coupon', { }
type: "confirm_order_coupon",
payAmount: payAmount, uni.pro.navigateTo('/pages/user/coupon', {
shoppingCart: JSON.stringify(this.listinfo.details) type: "confirm_order_coupon",
}) shopId: this.listinfo.shopId,
break; payAmount: payAmount,
case 'product': shoppingCart: JSON.stringify(this.listinfo.details)
let productList = this.userCouponInfos.filter(v => v.type == 2); })
uni.pro.navigateTo('/pages/user/coupon', { break;
type: "confirm_order_product", case 'product':
payAmount: this.listinfo.payAmount, let productList = this.userCouponInfos.filter(v => v.type == 2);
shoppingCart: JSON.stringify(this.listinfo.details), uni.pro.navigateTo('/pages/user/coupon', {
productList: JSON.stringify(productList) type: "confirm_order_product",
}) shopId: this.listinfo.shopId,
break; payAmount: this.listinfo.payAmount,
shoppingCart: JSON.stringify(this.listinfo.details),
productList: JSON.stringify(productList)
})
break;
}
} }
}, },
/** /**

View File

@@ -472,8 +472,10 @@
if ( couponList.length > 0 ) { if ( couponList.length > 0 ) {
payAmount = payAmount + couponList.discountAmount; payAmount = payAmount + couponList.discountAmount;
} }
uni.pro.navigateTo('/pages/user/coupon', { uni.pro.navigateTo('/pages/user/coupon', {
type: "confirm_order_coupon", type: "confirm_order_coupon",
shopId: this.shopId,
payAmount: payAmount, payAmount: payAmount,
shoppingCart: JSON.stringify(this.listinfo.details) shoppingCart: JSON.stringify(this.listinfo.details)
}) })
@@ -482,6 +484,7 @@
let productList = this.userCouponInfos.filter(v => v.type == 2); let productList = this.userCouponInfos.filter(v => v.type == 2);
uni.pro.navigateTo('/pages/user/coupon', { uni.pro.navigateTo('/pages/user/coupon', {
type: "confirm_order_product", type: "confirm_order_product",
shopId: this.shopId,
payAmount: this.listinfo.payAmount, payAmount: this.listinfo.payAmount,
shoppingCart: JSON.stringify(this.listinfo.details), shoppingCart: JSON.stringify(this.listinfo.details),
productList: JSON.stringify(productList) productList: JSON.stringify(productList)

View File

@@ -92,6 +92,7 @@
listinfoid: null, listinfoid: null,
status: [], status: [],
amountVIP: null, amountVIP: null,
couopnInfo: null,
srcimge: 'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/wx.jpg' srcimge: 'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/wx.jpg'
}; };
}, },
@@ -120,11 +121,10 @@
console.log(e) console.log(e)
}, },
methods: { methods: {
setPayAmount(payAmount) { setPayAmount(data) {
console.log("payAmount===",payAmount) console.log(data)
this.listinfo.payAmount = payAmount this.listinfo.payAmount = data.payAmount
// this.$set(this.listinfo,"payAmount",payAmount) this.couopnInfo = data;
// this.$forceUpdate()
}, },
saveImage (url) { saveImage (url) {
uni.saveImage({ uni.saveImage({
@@ -369,6 +369,16 @@
let res = await this.api.paymodfiyOrderInfo({ let res = await this.api.paymodfiyOrderInfo({
orderId: this.listinfo.orderId, orderId: this.listinfo.orderId,
}) })
// this.couopnInfo
let params = {
shopId: this.listinfo.shopId,
orderId: this.listinfo.orderId,
userCouponInfos: this.couopnInfo.userCouponInfos,
}
if ( this.couopnInfo.isPointsChecked && this.couopnInfo.calcUsablePointsData.pointsNum && this.couopnInfo.calcUsablePointsData.pointsNum > 0) {
params.pointsNum = this.couopnInfo.calcUsablePointsData.pointsNum;
}
let ress = await this.api.useCoupon(params)
}, },
/** /**