会员列表,详情,充值,订单列表

This commit is contained in:
wwz
2025-03-01 14:38:02 +08:00
parent 0ab9235f6c
commit 04a84aa17f
33 changed files with 5665 additions and 982 deletions

View File

@@ -2,25 +2,24 @@
<view class="container">
<view class="towcontent">
<view class="towcontentlistxitem flex-start">
<view class="towcontentlistxitembox flex-colum"
:class="tabIndex == item.type?'towcontentlistxitemboxopacity':''" v-for="(item,index) in tabList"
:key="index" @click="towcontentclick(item)">
<view class="towcontentlistxitembox flex-colum" v-for="(item,index) in tabList" :key="index"
@click="towcontentclick(item)"
:class="fromInfo.tabIndex == item.status?'towcontentlistxitemboxopacity':''">
<text class="title">{{item.name}}</text>
<image v-if="tabIndex == item.type"
<image v-if="fromInfo.tabIndex == item.status"
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/index/today/dg.png" mode="widthFix">
</image>
</view>
</view>
</view>
<view class="containertop"
:class="{select: type == 'confirm_order_coupon' || type == 'confirm_order_product' || type == 'orderInfo_coupon' || type == 'orderInfo_product'}">
<view class="containertop">
<view class="containertopbox">
<view class="containertopboxitem flex-start" v-for="(item,index) in list" :key="index">
<view class="containertopboxitem flex-start" v-for="(item,index) in fromInfo.list" :key="index">
<view class="containertopboxitemleft flex-colum"
:class="{'containertopboxitemleft_vip': item.type == 2,'containertopboxitemlefts': status != 1,}">
:class="{'containertopboxitemleft_vip': item.type == 2,'containertopboxitemlefts': fromInfo.status != 1,}">
<view class="containertopboxitemleft_one"
:class="status == 1?'':'containertopboxitemleft_ones'">
:class="fromInfo.status == 1?'':'containertopboxitemleft_ones'">
<block v-if="item.type == 2">
<text>{{item.num || 0}}</text>
<text style="font-size: 28rpx;margin-left: 6rpx;"></text>
@@ -32,7 +31,7 @@
</view>
<view class="containertopboxitemleft_tow" :class="{
'containertopboxitemleft_tows': status != 1,
'containertopboxitemleft_tows': fromInfo.status != 1,
'containertopboxitemleft_nameVip': item.type == 2,
}">
{{ item.type == 2 ? item.name : '优惠券(元)'}}
@@ -44,16 +43,16 @@
<view class="flex-start">
<image class="icon"
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/user/coupon_icon.png"
mode="aspectFill">
<text class="title">{{ item.shopName }}</text>
mode="aspectFill"></image>
<text class="title">{{ item.shopName }}</text>
</view>
<text>无门槛使用</text>
</view>
<view class="containertopboxitemright_tow">
<view> {{ item.type == 2 ? '会员商品券' : item.name}}</view>
<view @click="navigatorGo(item)"
:class="status == 1?'containertopboxitemright_four containertopboxitemright_btn':'containertopboxitemright_fours containertopboxitemright_btn'">
{{status == 1 ? '去使用':'已使用'}}
:class="fromInfo.status == 1?'containertopboxitemright_four containertopboxitemright_btn':'containertopboxitemright_fours containertopboxitemright_btn'">
{{fromInfo.status == 1 ? '去使用':'已使用'}}
</view>
</view>
<view class="containertopboxitemright_there" v-if="item.type == 1 ">
@@ -63,333 +62,136 @@
</view>
</view>
<image style="width: 402rpx;height: 442rpx;margin:240rpx auto 32rpx;"
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/nomore.png" v-if="list.length <= 0"
mode="aspectFill"></image>
<u-loadmore :status="form.status" iconSize='24' fontSize='24' height='40' />
<view v-if="fromInfo.list.length <= 0" style="text-align: center;">
<image style="width: 402rpx;height: 442rpx;margin:240rpx auto 32rpx;"
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/nomore.png" mode="aspectFill"></image>
</view>
<up-loadmore :status="form.status" iconSize='12' fontSize='12' height='20' />
</view>
</view>
<view class="btnBox"
v-if="type == 'confirm_order_coupon' || type == 'confirm_order_product' || type == 'orderInfo_coupon' || type == 'orderInfo_product'">
<!-- <view class="btnBox" >
<view class="btn" @click="cancelCoupon">暂不使用券</view>
</view>
</view> -->
</view>
</template>
<script>
export default {
data() {
return {
tabList: [
<script setup>
import {
ref,
reactive,
onMounted
} from 'vue';
import {
APIcouponfindByUserId
} from '@/common/api/member.js'
{
name: '未使用',
type: '1'
},
{
name: '已使用',
type: '2'
},
{
name: '已过期',
type: '-1'
}
],
tabIndex: 1,
list: [],
status: 1,
type: "",
payAmount: 0,
shopId: null,
orderId: null,
couopnInfo: null,
shoppingCart: [],
productList: [],
};
const tabList = [{
name: '未使用',
status: '0'
},
onLoad(options) {
console.log(options)
if (options.type) {
this.type = options.type
}
if (options.payAmount) {
this.payAmount = options.payAmount
}
if (options.shopId) {
this.shopId = options.shopId
}
if (options.orderId) {
this.orderId = options.orderId
}
if (options.couopnInfo) {
this.couopnInfo = JSON.parse(decodeURIComponent(options.couopnInfo))
}
if (options.shoppingCart) {
this.shoppingCart = JSON.parse(decodeURIComponent(options.shoppingCart))
}
if (options.productList) {
this.productList = JSON.parse(decodeURIComponent(options.productList))
}
{
name: '已使用',
status: '1'
},
onShow() {
this.list = [];
this.getCouponList()
},
methods: {
/**
* 切换类型
* @param {Object} item
*/
towcontentclick(item) {
this.tabIndex = item.type;
this.status = item.type;
this.list = [];
this.getCouponList()
},
/**
* 获取优惠券数据
*/
async getCouponList() {
try {
let params = {
userId: uni.getStorageSync('userInfo').id,
status: this.status
}
if (this.type == 'confirm_order_coupon' || this.type == 'confirm_order_product' || this.type ==
'orderInfo_coupon' || this.type == 'orderInfo_product') {
params.orderId = -1;
}
if (this.shopId) {
params.shopId = this.shopId;
}
let res = await this.api.conponList(params)
if (res) {
console.log(res)
let list = [];
if (this.type == 'confirm_order_coupon' || this.type == 'orderInfo_coupon') {
list = res.data.filter(v => v.type == 1);
} else if (this.type == 'confirm_order_product' || this.type == 'orderInfo_product') {
list = res.data.filter(v => v.type == 2);
} else {
list = res.data;
}
this.list = list;
}
} catch (e) {
//TODO handle the exception
}
},
/**
* 去使用优惠券
*/
navigatorGo(item) {
uni.cache.set('shopId', item.shopId)
if (this.type == 'confirm_order_coupon' || this.type == 'confirm_order_product' || this.type ==
'orderInfo_coupon' || this.type == 'orderInfo_product') {
if (item.type == 1) {
if (this.payAmount < item.fullAmount) {
uni.showToast({
title: "当前订单金额不足使用金额",
icon: "none",
})
return;
}
if (this.payAmount < item.discountAmount) {
uni.showToast({
title: "当前订单金额不足抵扣金额",
icon: "none",
})
return;
}
uni.$emit('couponItem', JSON.stringify(item))
let selectCouponData = uni.cache.get('selectCouponData') || [];
let couponList = selectCouponData.filter(v => v.type == 1);
if (couponList.length > 0) {
couponList.map(items => {
if (item.type == 1) {
for (var v in items) {
items[v] = item[v]
}
}
})
} else {
selectCouponData.push(item)
}
uni.cache.set('selectCouponData', selectCouponData)
uni.navigateBack();
} else {
let productNum = 0; //商品购物车数量
let productTicketNum = 0; //商品券使用数量
let product = this.shoppingCart.filter(v => v.productId == item.proId);
let productTicket = this.productList.filter(v => v.productId == item.proId);
if (product.length <= 0) {
uni.showToast({
title: "购物车没有" + item.name,
icon: "none",
})
return;
}
if (this.productList.filter(v => v.userCouponId == item.id).length > 0) {
uni.showToast({
title: `当前优惠券已选择`,
icon: "none",
})
return;
}
// 计算当前商品购物车数量
product.forEach(item => {
productNum += item.number;
})
// 计算当前商品券使用数量
productTicket.forEach(item => {
productTicketNum += item.num;
})
if ((productNum - productTicketNum) == 0) {
uni.showToast({
title: `当前商品已经全部抵扣`,
icon: "none",
})
return;
}
let isNum = 0;
let isProductItem;
// 确认订单
if (this.type == 'confirm_order_product') {
product.forEach(item => {
for (let i = 0; i < item.number; i++) {
isNum++
if (isNum == productTicketNum + 1) {
isProductItem = item;
}
}
})
if (this.payAmount < (isProductItem.memberPrice > 0 ? isProductItem.memberPrice : isProductItem
.salePrice)) {
uni.showToast({
title: `当前金额不足商品抵扣`,
icon: "none",
})
return;
}
}
// 订单详情
if (this.type == 'orderInfo_product') {
product.forEach(item => {
for (let i = 0; i < item.num; i++) {
isNum++
if (isNum == productTicketNum + 1) {
isProductItem = item;
}
}
})
if (this.payAmount < (isProductItem.memberPrice > 0 ? isProductItem.memberPrice : isProductItem
.price)) {
uni.showToast({
title: `当前金额不足商品抵扣`,
icon: "none",
})
return;
}
}
if (!isProductItem) {
uni.showToast({
title: `当前订单无可抵扣商品`,
icon: "none",
})
return;
}
// let productNum = 0;
// product.map(item => {
// productNum += item.number
// })
// if ( productNum < item.num) {
// uni.showToast({
// title: `购物车${item.name}数量不足`,
// icon: "none",
// })
// return;
// }
// if (product[0].number item.num) {
// }
uni.$emit('couponItem', JSON.stringify(item))
let selectCouponData = uni.cache.get('selectCouponData') || [];
selectCouponData.push(item)
uni.cache.set('selectCouponData', selectCouponData)
uni.navigateBack();
}
} else {
uni.pro.navigateTo('/pages/product/index', {
shopId: item.shopId
})
}
},
/**
* 取消使用优惠券/商品券
*/
async cancelCoupon() {
let selectCouponData = uni.cache.get('selectCouponData')
if (this.type == 'confirm_order_coupon' || this.type == 'orderInfo_coupon') {
let couponList = selectCouponData.filter(v => v.type == 1);
let productList = selectCouponData.filter(v => v.type == 2);
if (couponList.length > 0) {
uni.cache.set('selectCouponData', productList)
if (this.couopnInfo && this.orderId) {
let params = {
shopId: this.shopId,
orderId: this.orderId,
}
if (this.couopnInfo.userCouponInfos.filter(v => v.type == 2).length > 0) {
params.userCouponInfos = this.couopnInfo.userCouponInfos.filter(v => v.type == 2)
}
if (this.couopnInfo.isPointsChecked && this.couopnInfo.calcUsablePointsData.pointsNum &&
this.couopnInfo.calcUsablePointsData.pointsNum > 0) {
params.pointsNum = this.couopnInfo.calcUsablePointsData.pointsNum;
}
let res = await this.api.useCoupon(params)
}
}
} else if (this.type == 'confirm_order_product' || this.type == 'orderInfo_product') {
let couponList = selectCouponData.filter(v => v.type == 1);
let productList = selectCouponData.filter(v => v.type == 2);
if (productList.length > 0) {
uni.cache.set('selectCouponData', couponList)
if (this.couopnInfo && this.orderId) {
let params = {
shopId: this.shopId,
orderId: this.orderId,
}
if (this.couopnInfo.userCouponInfos.filter(v => v.type == 1).length > 0) {
params.userCouponInfos = this.couopnInfo.userCouponInfos.filter(v => v.type == 1)
}
if (this.couopnInfo.isPointsChecked && this.couopnInfo.calcUsablePointsData.pointsNum &&
this.couopnInfo.calcUsablePointsData.pointsNum > 0) {
params.pointsNum = this.couopnInfo.calcUsablePointsData.pointsNum;
}
let res = await this.api.useCoupon(params)
}
}
}
uni.navigateBack();
},
{
name: '已过期',
status: '2'
}
};
]
const fromInfo = reactive({
tabIndex: 0,
list: [],
status: 1,
payAmount: 0,
shopId: null,
orderId: null,
couopnInfo: null,
shoppingCart: [],
productList: [],
})
const form = reactive({
page: 1,
size: 10,
status: 'loadmore',
})
const towcontentclick = (item) => {
fromInfo.tabIndex = item.status;
fromInfo.status = item.status;
fromInfo.list = [];
getCouponList()
}
// 去使用优惠券
const navigatorGo = (item) => {
}
const getCouponList = async () => {
let res = await APIcouponfindByUserId({
userId: uni.cache.get('userInfo').id,
status: fromInfo.status,
shopId: fromInfo.shopId ? fromInfo.shopId : uni.cache.get('shopId'),
page: form.page,
size: form.size,
})
if (!res) {
form.status = 'nomore'
fromInfo.list = []
return false
}
if (res.totalPage == 1 && res.totalRow <= 10) {
form.status = 'nomore'
fromInfo.list = res.records
if (form.page == 1 && res.records.length == 0) {
fromInfo.list = []
}
return false;
} else {
form.status = 'loading';
fromInfo.list = [...fromInfo.list, ...res.records];
form.page = ++form.page;
if (form.page > res.totalPage) {
form.status = 'nomore';
} else {
form.status = 'loading';
}
}
console.log(fromInfo.list)
}
const cancelCoupon = () => {
}
onMounted(async () => {
// 获取当前页面栈
const pages = getCurrentPages();
// 获取当前页面实例
const currentPage = pages[pages.length - 1];
// 获取页面参数
const options = currentPage.options;
if (options.shopId) {
fromInfo.shopId = options.shopId
}
// if (options.payAmount) {
// this.payAmount = options.payAmount
// }
// if (options.orderId) {
// fromInfo.orderId = options.orderId
// }
// if (options.couopnInfo) {
// this.couopnInfo = JSON.parse(decodeURIComponent(options.couopnInfo))
// }
// if (options.shoppingCart) {
// this.shoppingCart = JSON.parse(decodeURIComponent(options.shoppingCart))
// }
// if (options.productList) {
// this.productList = JSON.parse(decodeURIComponent(options.productList))
// }
getCouponList()
})
</script>
<style lang="scss">
@@ -412,6 +214,8 @@
font-weight: 500;
font-size: 28rpx;
color: #333333;
justify-content: flex-start;
height: 50rpx;
image {
margin-top: 6rpx;
@@ -428,6 +232,7 @@
}
image {
margin-top: 6rpx;
width: 38.83rpx;
height: 8.62rpx;
}