diff --git a/pages/order/detail.vue b/pages/order/detail.vue index 98a9b24..448d996 100644 --- a/pages/order/detail.vue +++ b/pages/order/detail.vue @@ -85,7 +85,8 @@ - + @@ -130,6 +131,9 @@ // import orderInfoBefore from '../components/orderInfoBefore.vue' // import rechargeFree from '../components/rechargeFree.vue' import paymentMethodes from '@/components/paymentMethod.vue'; //支付方式 + import { + onBackPress + } from '@dcloudio/uni-app'; // 输入支付密码 const ispws = ref(false) @@ -229,7 +233,7 @@ .coupondiscountAmount || 0) - (listinfo.pointsDiscountAmount || 0); listinfo.totalCost = Math.round(sums * 100) / 100; // 积分 - if (listinfo.totalCost) { + if (listinfo.totalCost && listinfo.status == 'unpaid') { await memberPointscalcUsablePoints() } } @@ -251,7 +255,7 @@ const paymentmethod = reactive({ radiovalue: 1, paymentBtnText: "余额支付", - payType: '' + payType: 'accountPay' }) const groupChange = async (e) => { @@ -306,11 +310,32 @@ }; + const payPasswordPassword = ref('') + // * 去支付 const goToPay = async () => { // 余额支付 - if (paymentmethod.payType == '') { - ispws.value = true + if (paymentmethod.payType == 'accountPay') { + if (orderVIP.value.isVip == 0) { + uni.showModal({ + title: '提示', + content: '您还不是会员,是否去注册会员?', + success: (res) => { + if (res.confirm) { + uni.pro.navigateTo('user/member/index', { + shopId: orderVIP.value.shopId, + type: 'detail' + }) + } else if (res.cancel) { + console.log('用户点击取消'); + } + } + + }) + } else { + payPasswordPassword.value = '' + ispws.value = true + } return false } let checkOrderPay = { @@ -381,7 +406,7 @@ remark: '', //用户备注 } try { - let res = await storeMemberpay.balancePayOrder({ + await storeMemberpay.balancePayOrder({ checkOrderPay, payType: paymentmethod.payType, pwd: pwd, @@ -393,14 +418,14 @@ } catch (error) { //TODO handle the exception } - payPasswordref.value.closeModal() + payPasswordPassword.value = '' } onUnmounted(() => { uni.$off('returnData', handleReturnData); }); - + // 监听页面返回事件 onMounted(async () => { // 获取当前页面栈 const pages = getCurrentPages(); diff --git a/pages/product/index.vue b/pages/product/index.vue index 188c27a..7c5c6d5 100644 --- a/pages/product/index.vue +++ b/pages/product/index.vue @@ -561,9 +561,9 @@ uni.$u.debounce(store.scrollTop = res.scrollTop, 500) uni.$u.debounce(navScroll.value = res.scrollTop, 500) uni.$u.debounce(mainScroll(res), 500) - if(res.scrollTop >= 44){ + if (res.scrollTop >= 44) { store.showSearch = true - }else{ + } else { store.showSearch = false } }); @@ -583,13 +583,6 @@ goods: [] } }) - - /* 价格 */ - const salePrice = computed(() => { - // return shopInfo.isVip == 1 && memberPrice > 0 ? res.data.memberPrice : res.data.salePrice - return 0 - }) - // 用于判断接口数据是否加载完成 const isDataLoaded = ref(false); @@ -942,10 +935,25 @@ } }) - // 更新购物车数据 + // 更新购物车数据shopProductList.hots const matchedProducts = computed(() => { + if (!cartList.value) { + return false; + } + let Specialstop = null + + try { + Specialstop = [...[{ + id: "", + name: "", + productList: shopProductList.hots + }], ...shopProductList.productInfo] + } catch (error) { + Specialstop = shopProductList.productInfo + //TODO handle the exception + } return cartList.value.map((cartItem) => { - for (const group of shopProductList.productInfo) { + for (const group of Specialstop) { for (const product of group.productList) { if (product.id == cartItem.product_id) { // 多规格 @@ -986,23 +994,6 @@ }, 0); }); - // 计算购物车商品费用 - // const totalPrices = ref(0); - - // watchEffect(() => { - // if (matchedProducts.value.length > 0) { - // totalPrices.value = cartStore.getTotalTotalPrices(matchedProducts.value).value; - // } - // }); - - // matchedProducts 变化时,更新总打包费用 - // watch(() => matchedProducts.value, () => { - // if (matchedProducts.value.length > 0) { - // totalPrices.value = cartStore.getTotalTotalPrices(matchedProducts.value).value; - // } - // }); - - // 计算购物车商品总价格 const totalPrices = computed(() => { // 购物车总数价格 @@ -1091,22 +1082,27 @@ // 列表请求 const productqueryProduct = async () => { - shopProductList.hots = await productminiApphotsquery() - shopProductList.productInfo = await APIgroupquery() - //第一步:将所有商品的 cartNumber 初始化为 0 - shopProductList.productInfo.forEach((group) => { - group.productList.forEach((product) => { - product.cartNumber = 0; + try { + shopProductList.hots = await productminiApphotsquery() + shopProductList.productInfo = await APIgroupquery() + //第一步:将所有商品的 cartNumber 初始化为 0 + shopProductList.productInfo.forEach((group) => { + group.productList.forEach((product) => { + product.cartNumber = 0; + }); }); - }); - shopProductList.hots.forEach((i) => { - i.cartNumber = 0 - }) - scrollTopSize.value = 0 - topArr.value = [] - userStore.actionsAPIuser() - // 数据可以更新 - isDataLoaded.value = true; + shopProductList.hots.forEach((i) => { + i.cartNumber = 0 + }) + scrollTopSize.value = 0 + topArr.value = [] + userStore.actionsAPIuser() + // 数据可以更新 + isDataLoaded.value = true; + } catch (error) { + uni.navigateBack() + //TODO handle the exception + } } onLoad(async (e) => { diff --git a/pages/user/member/components/registermember.vue b/pages/user/member/components/registermember.vue index a238a0e..cecc085 100644 --- a/pages/user/member/components/registermember.vue +++ b/pages/user/member/components/registermember.vue @@ -85,7 +85,8 @@ import { defineProps, reactive, - ref + ref, + defineEmits } from 'vue'; import { @@ -101,6 +102,10 @@ type: Object, default: () => ({}) }, + detailtype: { + type: String, + default: '' + }, memberOpen: { type: Boolean, default: false @@ -340,9 +345,21 @@ phone: formInfo.telephone, birthDay: formInfo.birthDay }) - if (res.code == 0) { - - } + // 定义自定义事件 + let APIshopUserInfores = await APIshopUserInfo({ + shopId: uni.cache.get('shopId') + }) + uni.cache.set('orderVIP', APIshopUserInfores) + uni.cache.set('ordershopUserInfo', APIshopUserInfores.shopInfo) + uni.showToast({ + title: '会员加入成功', + icon: 'none' + }) + setTimeout(() => { + if (props.detailtype == 'detail') { + uni.navigateBack() + } + }, 1500) } diff --git a/pages/user/member/index.vue b/pages/user/member/index.vue index e00a27f..c3e397a 100644 --- a/pages/user/member/index.vue +++ b/pages/user/member/index.vue @@ -94,7 +94,7 @@ 立即充值 - + @@ -159,6 +159,7 @@ infoForn.listdata = res; infoForn.couponList = infoForn.listdata[0].couponList; infoForn.giftAmount = infoForn.listdata[0].giftAmount + infoForn.id = infoForn.listdata[0].id if (infoForn.type == 'topUpActivity') { infoForn.amountChange() } else { @@ -288,11 +289,11 @@ // 充值金额切换 const clickinput = (a, b) => { - console.log(a, b) infoForn.inputshow = b; infoForn.couponList = a.couponList; infoForn.amount = a.amount; infoForn.giftAmount = a.giftAmount; + infoForn.id = a.id; } // 充值 @@ -319,8 +320,17 @@ }); return false; } + console.log({ + shopId: infoForn.shopId, + activateId: infoForn.id, + shopUserId: infoForn.userInfo.id, + amount: infoForn.amount, //金额 + returnUrl: '', //跳转地址 + buyerRemark: '' + }) let res = await store.actionspayltPayVip({ shopId: infoForn.shopId, + activateId: infoForn.id, shopUserId: infoForn.userInfo.id, amount: infoForn.amount, //金额 returnUrl: '', //跳转地址 @@ -329,6 +339,19 @@ console.log(res) } + // 会员总信息 + const asyncshopUserInfo = async () => { + let res = await APIshopUserInfo({ + shopId: uni.cache.get('shopId') + }) + uni.cache.set('orderVIP', res) + uni.cache.set('ordershopUserInfo', res.shopInfo) + infoForn.show = res.isVip == 1 ? false : true + + } + + const detailtype = ref('') + onMounted(async () => { // 获取当前页面栈 const pages = getCurrentPages(); @@ -349,21 +372,17 @@ // } // uni.cache.set('shopId', infoForn.shopId) // // #endif - - if (options.shopId) { + uni.cache.set('shopId', options.shopId, 30) infoForn.shopId = options.shopId ? options.shopId : uni.cache.get('shopId') let resone = await APIusershopInfodetail({ shopId: options.shopId }) infoForn.shopUserInfo = resone.shopInfo - - // 根据传的shopInfo来返回上面的值 - infoForn.userInfo = await APIshopUserInfo({ - shopId: options.shopId - }) - infoForn.show == infoForn.userInfo.isVip == 1 ? true : false - + asyncshopUserInfo() + } + if (options.type == 'detail') { + detailtype.value = 'detail' } if (options.type) { infoForn.type = options.type diff --git a/pages/user/member/memberdetails.vue b/pages/user/member/memberdetails.vue index 993c6b5..02d4b4e 100644 --- a/pages/user/member/memberdetails.vue +++ b/pages/user/member/memberdetails.vue @@ -159,6 +159,18 @@ this.init() } + // 会员总信息 + const asyncshopUserInfo = async () => { + let res = await APIshopUserInfo({ + shopId: shopUserInfo.shopId + }) + uni.cache.set('orderVIP', res) + uni.cache.set('ordershopUserInfo', res.shopInfo) + form.memberOpen = res.isVip == 1 ? false : true + + } + + onMounted(async () => { // 获取当前页面栈 const pages = getCurrentPages(); @@ -171,16 +183,17 @@ const currentPage = pages[pages.length - 1]; // 获取页面参数 const pageParams = currentPage.options; - let res = await APIusershopInfodetail({ - shopId: pageParams.shopId - }) - // 根据传的shopInfo来返回上面的值 - shopUserInfo.shopInfo = await APIshopUserInfo({ - shopId: pageParams.shopId - }) - shopUserInfo.shopExtend = res.shopExtend.member_bg - shopUserInfo.shopId = pageParams.shopId - form.memberOpen = shopUserInfo.shopInfo.isVip == 1 ? false : true + if (pageParams.shopId) { + asyncshopUserInfo() + uni.cache.set('shopId', pageParams.shopId, 30) + let res = await APIusershopInfodetail({ + shopId: pageParams.shopId + }) + // 根据传的shopInfo来返回上面的值 + shopUserInfo.shopExtend = res.shopExtend.member_bg + shopUserInfo.shopId = pageParams.shopId + } + }) diff --git a/pages/user/member/paycode.vue b/pages/user/member/paycode.vue index 7ee1960..9e561ad 100644 --- a/pages/user/member/paycode.vue +++ b/pages/user/member/paycode.vue @@ -59,36 +59,42 @@ console.log(formInfo.shopInfo) if (res) { formInfo.url = res; - nextTick(() => { - const barcodeText = '1234567890'; - const query = uni.createSelectorQuery(); - query.select('#barcodeCanvas') - .fields({ node: true, size: true }) - .exec((res) => { - if (res[0]) { - const canvas = res[0].node; - const ctx = canvas.getContext('2d'); - const dpr = uni.getSystemInfoSync().pixelRatio; - canvas.width = res[0].width * dpr; - canvas.height = res[0].height * dpr; - ctx.scale(dpr, dpr); - - JsBarcode(canvas, barcodeText, { - width: 2, - height: 100, - displayValue: true, - fontOptions: 'bold', - font: 'monospace', - textAlign: 'center', - textPosition: 'bottom', - textMargin: 2, - fontSize: 20, - background: '#ffffff', - lineColor: '#000000' - }); - } - }); - }); + try { + nextTick(() => { + const query = uni.createSelectorQuery(); + query.select('#barcodeCanvas') + .fields({ + node: true, + size: true + }) + .exec((res) => { + if (res[0]) { + const canvas = res[0].node; + const ctx = canvas.getContext('2d'); + const dpr = uni.getSystemInfoSync().pixelRatio; + canvas.width = res[0].width * dpr; + canvas.height = res[0].height * dpr; + ctx.scale(dpr, dpr); + + JsBarcode(canvas, formInfo.url, { + width: 2, + height: 100, + displayValue: true, + fontOptions: 'bold', + font: 'monospace', + textAlign: 'center', + textPosition: 'bottom', + textMargin: 2, + fontSize: 20, + background: '#ffffff', + lineColor: '#000000' + }); + } + }); + }); + } catch (error) { + //TODO handle the exception + } } }) diff --git a/pages/user/user.vue b/pages/user/user.vue index ab0e15b..ed93c9e 100644 --- a/pages/user/user.vue +++ b/pages/user/user.vue @@ -9,10 +9,10 @@ {{userInfo.nickName || '无'}} - - + 免费入会 @@ -92,11 +92,11 @@ icon: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/my_order.png" }, // { name: "收货地址", type: "", icon: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/my_address.png"}, - { - name: "个人资料", - type: "myself", - icon: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/personal.png" - }, + // { + // name: "个人资料", + // type: "myself", + // icon: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/personal.png" + // }, { name: "我的会员卡", type: "my_member", @@ -107,15 +107,19 @@ const teblist = ref([]) const shopExtend = ref(null) const userInfo = reactive({}) + + const ShopId = ref(uni.cache.get('shopId')) + const clickEvent = () => { - if (uni.cache.get('shopId') && uni.cache.get('token')) { + if (ShopId.value) { if (userInfo.isVip == 0) { uni.pro.navigateTo('user/member/memberdetails', { shopId: uni.cache.get('shopId') }) } else { - uni.navigateTo({ - url: '/pages/user/member/qrcode?userInfo=' + JSON.stringify(userInfo) + uni.pro.navigateTo('user/member/paycode', { + shopId: uni.cache.get('shopId'), + shopInfo: JSON.stringify(uni.cache.get('orderVIP').shopInfo) }) } } else { @@ -179,7 +183,7 @@ onShow(async () => { await store.actionsAPIuser() - let res = uni.cache.get('userInfo') + let res = uni.cache.get('orderVIP') if (uni.cache.get('shopId')) { Object.assign(userInfo, res) } else { @@ -188,7 +192,6 @@ ...res.assetsSummary }) } - console.log(userInfo, 11) })