完善小程序

This commit is contained in:
wwz
2025-03-18 18:29:34 +08:00
parent fc957feb72
commit 9da31e2faa
19 changed files with 594 additions and 352 deletions

50
App.vue
View File

@@ -32,57 +32,7 @@
console.log(error) console.log(error)
} }
// #endif // #endif
try {
uni.getLocation({
type: 'wgs84',
success: async (res) => {
let successres = await APIgeocodelocation({
lng: res.longitude,
lat: res.latitude,
})
if (successres) {
let datastorage = {
country: successres.addressComponent.country, // "中国"
province: successres.addressComponent
.province, //province: "陕西省"
address: successres.addressComponent.city, //district: "西安市"
district: successres.addressComponent.district, //district: "未央区"
lng: res.longitude,
lat: res.latitude,
}
uni.cache.set('getLocationstorage', datastorage);
// 登录
proxy.$isResolve()
}
},
});
} catch (error) {
try {
let successres = await APIgeocodelocation({
lng: '',
lat: '',
})
if (successres) {
let datastorage = {
country: successres.addressComponent.country, // "中国"
province: successres.addressComponent
.province, //province: "陕西省"
address: successres.addressComponent.city, //district: "西安市"
district: successres.addressComponent.district, //district: "未央区"
lng: res.longitude,
lat: res.latitude,
}
uni.cache.set('getLocationstorage', datastorage);
proxy.$isResolve()
}
} catch (error) {
}
}
proxy.$isResolve()
}); });
// export default { // export default {
// onLaunch: async function() { // onLaunch: async function() {

View File

@@ -53,16 +53,11 @@
freeCheck: { freeCheck: {
type: Boolean, type: Boolean,
default: false default: false
},
orderVIP: {
type: Object,
default: {
}
} }
});
});
const orderVIP = ref(uni.cache.get('orderVIP'))
const emits = defineEmits(['customevent', 'groupChange']); const emits = defineEmits(['customevent', 'groupChange']);
@@ -111,7 +106,7 @@
}, },
]) ])
const radiovalue = ref(1) // 支付方式 const radiovalue = ref(2) // 支付方式
const ispws = ref(false) // 输入支付密码 const ispws = ref(false) // 输入支付密码
@@ -134,7 +129,7 @@
// 去充值 // 去充值
const goRecharge = () => { const goRecharge = () => {
uni.pro.navigateTo('user/member/index', { uni.pro.navigateTo('user/member/index', {
shopId: props.orderVIP.shopId shopId: orderVIP.value.shopId
}) })
} }
</script> </script>

View File

@@ -338,9 +338,54 @@
uni.$u.debounce(store.scrollTop = res.scrollTop, 500) uni.$u.debounce(store.scrollTop = res.scrollTop, 500)
}); });
onShow(async () => { onShow(async () => {
try {
uni.getLocation({
type: 'wgs84',
success: async (res) => {
let successres = await APIgeocodelocation({
lng: res.longitude,
lat: res.latitude,
})
if (successres) {
let datastorage = {
country: successres.addressComponent.country, // "中国"
province: successres.addressComponent
.province, //province: "陕西省"
address: successres.addressComponent.city, //district: "西安市"
district: successres.addressComponent.district, //district: "未央区"
lng: res.longitude,
lat: res.latitude,
}
uni.cache.set('getLocationstorage', datastorage);
// 登录
proxy.$isResolve()
}
},
}) });
onMounted(async () => { } catch (error) {
try {
let successres = await APIgeocodelocation({
lng: '',
lat: '',
})
if (successres) {
let datastorage = {
country: successres.addressComponent.country, // "中国"
province: successres.addressComponent
.province, //province: "陕西省"
address: successres.addressComponent.city, //district: "西安市"
district: successres.addressComponent.district, //district: "未央区"
lng: res.longitude,
lat: res.latitude,
}
uni.cache.set('getLocationstorage', datastorage);
proxy.$isResolve()
}
} catch (error) {
}
}
await proxy.$onLaunched; await proxy.$onLaunched;
if (uni.cache.get('shopId')) { if (uni.cache.get('shopId')) {
showindex.value = 'shopIndex' showindex.value = 'shopIndex'
@@ -351,6 +396,9 @@
init_fn() init_fn()
// 获取初始定位高度 // 获取初始定位高度
} }
})
onMounted(async () => {
}); });
onReachBottom(() => { onReachBottom(() => {

View File

@@ -2,13 +2,13 @@
<view class="integral-modal" v-if="visible"> <view class="integral-modal" v-if="visible">
<view class="modal-mask" @click="closeModal"></view> <view class="modal-mask" @click="closeModal"></view>
<view class="modal-content"> <view class="modal-content">
<view class="input-wrapper"> <view class="input-wrapper" style="padding-bottom: 100px;">
<input type="number" v-model="inputValue" :min="minValue" :max="maxValue" @input="handleInput" <input type="number" v-model="inputValue" :min="minValue" :max="maxValue" @input="handleInput"
:placeholder="instructions" /> :placeholder="instructions" />
</view> </view>
<!-- <view class="instructions">{{ instructions }}</view> --> <!-- <view class="instructions">{{ instructions }}</view> -->
<up-button type="primary" @click="confirmIntegral" text="确定"></up-button> <up-button type="primary" @click="confirmIntegral" text="确定"></up-button>
<button style="margin-top: 20rpx;" @click="IntegralInputclose">取消</button> <up-button style="margin-top: 20rpx;" @click="IntegralInputclose">取消</up-button>
</view> </view>
</view> </view>
</template> </template>
@@ -72,7 +72,6 @@
// 确认积分并返回值给父组件 // 确认积分并返回值给父组件
const confirmIntegral = () => { const confirmIntegral = () => {
console.log(inputValue.value, 444)
if (inputValue.value < props.minValue || inputValue.value > props.maxValue) { if (inputValue.value < props.minValue || inputValue.value > props.maxValue) {
uni.showToast({ uni.showToast({
title: '输入的积分值不在有效范围内', title: '输入的积分值不在有效范围内',
@@ -138,7 +137,7 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
background-color: #fff; background-color: #fff;
padding: 20px; padding: 20rpx 20rpx;
box-sizing: border-box; box-sizing: border-box;
border-top-left-radius: 10px; border-top-left-radius: 10px;
border-top-right-radius: 10px; border-top-right-radius: 10px;

View File

@@ -94,7 +94,7 @@
<view class="val"> <view class="val">
<view></view> <view></view>
<view style="font-size: 28rpx;"></view> <view style="font-size: 28rpx;"></view>
<view>{{listinfo.packFee}}</view> <view>{{listinfo.packFeess}}</view>
</view> </view>
</view> </view>
@@ -295,7 +295,17 @@
}, },
listinfo: { listinfo: {
type: Object type: Object,
default: {
combinedArray: {},
Productroll: 0,
coupondiscountAmount: 0,
couponInfoList: '',
pointsDiscountAmount: 0,
packFeess: 0,
totalPrices: 0,
Seatcharge: 0
}
}, },
orderVIP: { orderVIP: {
@@ -359,6 +369,7 @@
}) })
break; break;
case 'points': case 'points':
IntegralInputclose()
if (calcUsablePointsData.usable == 0) { if (calcUsablePointsData.usable == 0) {
uni.showToast({ uni.showToast({
title: calcUsablePointsData.unusableReason, title: calcUsablePointsData.unusableReason,
@@ -384,7 +395,7 @@
calcUsablePointsData.integral = integral calcUsablePointsData.integral = integral
props.listinfo.pointsDiscountAmount = await APImemberPointscalcDeductionAmount({ props.listinfo.pointsDiscountAmount = await APImemberPointscalcDeductionAmount({
points: integral, points: integral,
userId: props.orderVIP.id, shopUserId: props.orderVIP.id,
orderAmount: props.listinfo.totalCost orderAmount: props.listinfo.totalCost
}) })
emits('clickPointsamount', props.listinfo.pointsDiscountAmount); emits('clickPointsamount', props.listinfo.pointsDiscountAmount);

View File

@@ -8,7 +8,7 @@
<view class="containertopboxitemleft_one" v-if="Orderinfo.typeOrder == 1" <view class="containertopboxitemleft_one" v-if="Orderinfo.typeOrder == 1"
:class="Orderinfo.typeOrder == 1 ?'':'containertopboxitemleft_ones'"> :class="Orderinfo.typeOrder == 1 ?'':'containertopboxitemleft_ones'">
<block v-if="item.type == 2"> <block v-if="item.type == 2">
<text>{{item.num || 0}}</text> <text>1</text>
<text style="font-size: 28rpx;margin-left: 6rpx;"></text> <text style="font-size: 28rpx;margin-left: 6rpx;"></text>
</block> </block>
<block v-else> <block v-else>

View File

@@ -123,6 +123,11 @@
const storeMemberpay = Memberpay(); const storeMemberpay = Memberpay();
import {
productStore
} from '@/stores/user.js';
const storeuser = productStore();
import payPassword from '@/components/payPassword.vue' import payPassword from '@/components/payPassword.vue'
import orderInfoAfter from './components/orderInfoAfter.vue' import orderInfoAfter from './components/orderInfoAfter.vue'
// import orderInfoBefore from '../components/orderInfoBefore.vue' // import orderInfoBefore from '../components/orderInfoBefore.vue'
@@ -136,9 +141,7 @@
const ispws = ref(false) const ispws = ref(false)
// 商品订单会员 // 商品订单会员
const ordershopUserInfo = ref({ const ordershopUserInfo = ref(uni.cache.get('ordershopUserInfo'))
isTableFee: 0
})
// 是否显示商家二维码信息 // 是否显示商家二维码信息
try { try {
@@ -155,15 +158,14 @@
combinedArray: {}, combinedArray: {},
Productroll: 0, Productroll: 0,
coupondiscountAmount: 0, coupondiscountAmount: 0,
couponInfoList: '',
pointsDiscountAmount: 0, pointsDiscountAmount: 0,
packFee: 0, packFeess: 0,
totalPrices: 0, totalPrices: 0,
Seatcharge: 0 Seatcharge: 0
}) })
// 会员信息 // 会员信息
const orderVIP = ref() const orderVIP = ref(uni.cache.get('orderVIP'))
//判断是否是打包商品 //判断是否是打包商品
const is_type = ref(0) const is_type = ref(0)
@@ -190,9 +192,6 @@
orderId: orderId.value orderId: orderId.value
}) })
} catch (error) {} } catch (error) {}
// if (listinfo.couponInfoList) {
// listinfo.couponInfoList = JSON.parse(listinfo.couponInfoList)
// }
} }
// 历史订单 // 历史订单
if (listinfo.detailMap) { if (listinfo.detailMap) {
@@ -204,7 +203,7 @@
} }
} }
listinfo.combinedArray = combinedArray listinfo.combinedArray = combinedArray
listinfo.packFee = await cartStore.getTotalPackFee(listinfo.combinedArray) listinfo.packFeess = await cartStore.getTotalPackFee(listinfo.combinedArray)
// 计算购物车商品费用 // 计算购物车商品费用
listinfo.totalPrices = await cartStore.getTotalTotalPrices(listinfo listinfo.totalPrices = await cartStore.getTotalTotalPrices(listinfo
.combinedArray) .combinedArray)
@@ -231,24 +230,24 @@
watchEffect(async () => { watchEffect(async () => {
if (listinfo.combinedArray.length > 0) { if (listinfo.combinedArray.length > 0) {
//总价格 //总价格
// console.log(listinfo.combinedArray, listinfo.packFee, listinfo.totalPrices, listinfo.Seatcharge, // console.log(listinfo.combinedArray, listinfo.packFeess, listinfo.totalPrices, listinfo.Seatcharge,
// listinfo.Productroll, listinfo.coupondiscountAmount) // listinfo.Productroll, listinfo.coupondiscountAmount)
// 打包费packFee 计算购物车商品费用totalPrices 餐位费Seatcharge // 打包费packFeess 计算购物车商品费用totalPrices 餐位费Seatcharge
try { try {
let sum = (is_type.value != 0 ? listinfo.packFee : 0) + listinfo.totalPrices + (is_type let sum = (is_type.value != 0 ? listinfo.packFeess : 0) + listinfo.totalPrices + (is_type
.value == .value ==
0 ? listinfo.Seatcharge : 0); 0 ? listinfo.Seatcharge : 0);
listinfo.originAmount = Math.round(sum * 100) / 100; listinfo.originAmount = Math.round(sum * 100) / 100;
// 打包费packFee 计算购物车商品费用totalPrices 餐位费Seatcharge 商品卷Productroll 优惠卷coupondiscountAmount 积分listinfo.pointsDiscountAmount // 打包费packFeess 计算购物车商品费用totalPrices 餐位费Seatcharge 商品卷Productroll 优惠卷coupondiscountAmount 积分listinfo.pointsDiscountAmount
let sums = (is_type.value != 0 ? listinfo.packFee : 0) + listinfo.totalPrices + (is_type let sums = (is_type.value != 0 ? listinfo.packFeess : 0) + listinfo.totalPrices + (is_type
.value == .value ==
0 ? listinfo.Seatcharge : 0) - (listinfo.Productroll || 0) - (listinfo 0 ? listinfo.Seatcharge : 0) - (listinfo.Productroll || 0) - (listinfo
.coupondiscountAmount || 0) - (listinfo.pointsDiscountAmount || 0); .coupondiscountAmount || 0) - (listinfo.pointsDiscountAmount || 0);
listinfo.totalCost = Math.round(sums * 100) / 100; listinfo.totalCost = Math.round(sums * 100) / 100;
// 积分 // 积分
if (listinfo.totalCost && listinfo.status == 'unpaid') { if (listinfo.totalCost && listinfo.status == 'unpaid') {
uni.$u.debounce(await memberPointscalcUsablePoints(), 500) uni.$u.debounce(memberPointscalcUsablePoints, 500)
} }
} catch (error) { } catch (error) {
@@ -271,9 +270,9 @@
// 支付方式切换 // 支付方式切换
const paymentmethod = reactive({ const paymentmethod = reactive({
radiovalue: 1, radiovalue: 2,
paymentBtnText: "余额支付", paymentBtnText: "微信支付",
payType: 'accountPay' payType: 'wechatPay'
}) })
const groupChange = async (e) => { const groupChange = async (e) => {
@@ -349,7 +348,21 @@
console.log('用户点击取消'); console.log('用户点击取消');
} }
} }
})
} else if (orderVIP.value.payPwd == '') {
uni.showModal({
title: '提示',
content: '您还未设置支付密码,是否去设置?',
success: (res) => {
if (res.confirm) {
uni.pro.navigateTo('user/member/setPassword', {
shopId: orderVIP.value.shopId,
type: 'detail'
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
}) })
} else { } else {
ispws.value = true ispws.value = true
@@ -374,19 +387,23 @@
pointsNum: 0, //(扣除各类折扣 enable_deduction后使用) pointsNum: 0, //(扣除各类折扣 enable_deduction后使用)
remark: '', //用户备注 remark: '', //用户备注
} }
let res = await storeMemberpay.actionsltPayOrder({ try {
checkOrderPay, await storeMemberpay.actionsltPayOrder({
payType: paymentmethod.payType, checkOrderPay,
buyerRemark: '', payType: paymentmethod.payType,
returnUrl: '' buyerRemark: '',
}) returnUrl: ''
await orderorderInfo() })
} catch (error) {
//TODO handle the exception
}
orderorderInfo()
} }
//002-获取订单可用积分及抵扣金额(支付页面使用) //002-获取订单可用积分及抵扣金额(支付页面使用)
const memberPointscalcUsablePoints = async () => { const memberPointscalcUsablePoints = async () => {
let res = await APImemberPointscalcUsablePoints({ let res = await APImemberPointscalcUsablePoints({
userId: orderVIP.value.id, shopUserId: orderVIP.value.id,
orderAmount: listinfo.totalCost, orderAmount: listinfo.totalCost,
}) })
orderInfoAfterRef.value.getCalcUsablePoints(res) orderInfoAfterRef.value.getCalcUsablePoints(res)
@@ -433,7 +450,7 @@
} catch (error) { } catch (error) {
//TODO handle the exception //TODO handle the exception
} }
await orderorderInfo() orderorderInfo()
} }
onUnmounted(() => { onUnmounted(() => {
@@ -453,14 +470,19 @@
// 每次进来全局更新shopId // 每次进来全局更新shopId
uni.cache.set('shopId', options.shopId, 30) uni.cache.set('shopId', options.shopId, 30)
uni.$on('returnData', handleReturnData); uni.$on('returnData', handleReturnData);
// let res = await APIshopUserInfo({
// shopId: options.shopId
// })
// uni.cache.set('orderVIP', res)
// uni.cache.set('ordershopUserInfo', res.shopInfo)
// orderVIP.value = res
// ordershopUserInfo.value = res.shopInfo
}
try {
// * 获取会员信息 // * 获取会员信息
let res = await APIshopUserInfo({ await storeuser.actionsproductqueryProduct()
shopId: options.shopId } catch (error) {
}) //TODO handle the exception
uni.cache.set('orderVIP', res)
uni.cache.set('ordershopUserInfo', res.shopInfo)
orderVIP.value = res
ordershopUserInfo.value = res.shopInfo
} }
orderorderInfo() orderorderInfo()
}) })

View File

@@ -71,7 +71,7 @@
</view> </view>
</view> </view>
<view class="shop-amount"> <view class="shop-amount">
<text class="orderAmount">{{item.orderAmount}}</text> <text class="orderAmount">{{item.status == 'unpaid'?item.originAmount:item.orderAmount}}</text>
<text class="totalNumber">{{item.goods.length}}</text> <text class="totalNumber">{{item.goods.length}}</text>
</view> </view>
</view> </view>

View File

@@ -30,9 +30,28 @@
<script setup> <script setup>
import { import {
ref ref,
onMounted,
getCurrentInstance
} from 'vue' } from 'vue'
import {
onLoad
} from '@dcloudio/uni-app'
import {
Storelogin
} from '@/stores/user.js';
// 获取全局属性
const {
proxy
} = getCurrentInstance();
import {
productStore
} from '@/stores/user.js';
const otherNum = ref('') const otherNum = ref('')
const numIndex = ref(0) const numIndex = ref(0)
@@ -82,6 +101,28 @@
uni.cache.set('dinersNum', dinersNum.value) uni.cache.set('dinersNum', dinersNum.value)
uni.pro.redirectTo('product/index') uni.pro.redirectTo('product/index')
} }
onMounted(async () => {
await proxy.$onLaunched;
// 获取当前页面栈
const pages = getCurrentPages();
// 获取当前页面实例
const currentPage = pages[pages.length - 1];
// 获取页面参数
const options = currentPage.options;
// #ifdef MP-WEIXIN
if (options.q) {
console.log(options.q)
const store = productStore();
await store.scanCodeactions(options.q)
}
// #endif
// #ifdef MP-ALIPAY
if (getApp().globalData.tableCode) {
await store.scanCodeactions(getApp().globalData.tableCode)
}
// #endif
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@@ -18,17 +18,20 @@
<up-image :src="item.coverImg" width="80" radius="10" height="80"></up-image> <up-image :src="item.coverImg" width="80" radius="10" height="80"></up-image>
</view> </view>
<view class="info"> <view class="info">
<view class="name"> {{ item.name }} </view> <view class="name"> {{item.cartListinfo.is_temporary == 1?'临时菜' :item.name }}
</view>
<view class="select-sku-wrap" v-if="item.type == 'sku'"> <view class="select-sku-wrap" v-if="item.type == 'sku'">
<text v-for="i in item.skuList" :key="i.id"> <text v-for="i in item.skuList" :key="i.id">
{{item.cartListinfo.sku_id == i.id? i.name:"" }} {{item.cartListinfo.sku_id == i.id? i.name:"" }}
</text> </text>
</view> </view>
<view class="select-sku-wrap" v-if="item.type == 'package'"> <view class="select-sku-wrap" v-if="item.type == 'package'">
<view>{{dataprocessing(item.cartListinfo).title}}</view> <view v-for="(a,b) in dataprocessing(item.cartListinfo)" :key="b">
<text v-for="i in dataprocessing(item.cartListinfo).goods" :key="i.id"> <!-- <view>{{a.title}}</view> -->
{{i.proName }} <text v-for="i in a.goods" :key="i.proId" style="margin-left: 4rpx;">
</text> {{i.proName }}
</text>
</view>
</view> </view>
<view class="price-wrap" style="padding-top: 0;"> <view class="price-wrap" style="padding-top: 0;">
<view class="price"> <view class="price">
@@ -147,7 +150,14 @@
const dataprocessing = computed(() => { const dataprocessing = computed(() => {
return (item) => { return (item) => {
return JSON.parse(item.pro_group_info); console.log(item.pro_group_info)
let res = null
try {
res = JSON.parse(item.pro_group_info)
} catch (error) {
//TODO handle the exception
}
return res
}; };
}) })
@@ -234,6 +244,8 @@
.shop-item-content { .shop-item-content {
display: flex; display: flex;
justify-content: center;
align-items: center;
} }
.shop-item-remark { .shop-item-remark {

View File

@@ -257,54 +257,58 @@
</view> </view>
<!-- 规格 --> <!-- 规格 -->
<up-popup :show="showShopsku" :round="20" mode="bottom" @close="showShopsku = false;pagemetashow=false" <up-popup :show="showShopsku" :round="20" mode="bottom" @close="showShopsku = false,pagemetashow = false">
:safeAreaInsetBottom='false'> <view class="shop_sku">
<view class="shop_sku" style="max-height:70vh;"> <scroll-view scroll-y style="max-height:60vh;width: 100%;">
<view class="positionabsolute"> <view class="positionabsolute">
<up-icon name="close-circle" @click="showShopsku = false;pagemetashow=false" color="#000" <up-icon name="close-circle" @click="showShopsku = false;pagemetashow=false" color="#000"
size="25"></up-icon> size="25"></up-icon>
</view> </view>
<up-swiper :list="specifications.item.images" height="250"></up-swiper> <up-swiper :list="specifications.item.images" height="250"></up-swiper>
<view class="shop_sku_name"> {{specifications.item.name}} </view> <view class="shop_sku_name"> {{specifications.item.name}} </view>
<view class="shop_sku_description"> {{specifications.item.shortTitle?specifications.item.shortTitle:''}} <view class="shop_sku_description">
</view> {{specifications.item.shortTitle?specifications.item.shortTitle:''}}
<view v-if="specifications.item.type != 'package'"> </view>
<view class="shop_sku_box" v-for="(specOptions,specType) in specifications.item.selectSpecInfo" <view v-if="specifications.item.type != 'package'">
:key="specType"> <view class="shop_sku_box" v-for="(specOptions,specType) in specifications.item.selectSpecInfo"
<view class="shop_sku_box_name"> :key="specType">
{{specType }} <view class="shop_sku_box_name">
</view> {{specType }}
<view class="flex-start"> </view>
<view class="shop_sku_box_item" v-for="option in specOptions" :key="option" <view class="flex-start">
@click="selectSpec(specType, option)" <view class="shop_sku_box_item" v-for="option in specOptions" :key="option"
:class="{ shop_sku_box_item_selected: selectedSpecs[specType] === option }"> @click="selectSpec(specType, option)"
{{option}} :class="{ shop_sku_box_item_selected: selectedSpecs[specType] === option }">
<view class="shop_sku_box_item_tip" v-if="specifications.item.isPauseSale == 1"> {{option}}
<view>售罄</view> <view class="shop_sku_box_item_tip" v-if="specifications.item.isPauseSale == 1">
<view>售罄</view>
</view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</view> <!-- 套餐 -->
<!-- 套餐 --> <view v-else>
<view v-else> <view class="shop_sku_box">
<view class="shop_sku_box"> <view v-for="(setmenu, setmenuindex) in specifications.item.groupSnap" :key='setmenuindex'>
<view class="shop_sku_box_name"> <view class="shop_sku_box_name">
{{specifications.groupSnap.count }} {{specifications.groupSnap.number }} {{setmenu.title}} {{setmenu.count }} {{setmenu.number }}
</view> </view>
<view class="flex-start"> <view class="flex-start">
<view class="shop_sku_box_item" v-for="(option,goodsid) in specifications.groupSnap.goods" <view class="shop_sku_box_item" v-for="(option, goodsid) in setmenu.goods"
:key="goodsid" @click="goodsidClick(option, goodsid)" :key="goodsid" @click="goodsidClick(setmenuindex, option, goodsid)"
:class="{ shop_sku_box_item_selected: isOptionSelected(option)}" :class="{ shop_sku_box_item_selected: isOptionSelected(setmenuindex, option)}"
:disabled="isMaxSelected() &&!isOptionSelected(option)"> :disabled="isMaxSelected(setmenuindex) &&!isOptionSelected(setmenuindex, option)">
{{option.proName}}/{{option.skuName}} {{option.proName}}/{{option.unitName}}
<view class="shop_sku_box_item_tip" v-if="specifications.item.isPauseSale == 1"> <view class="shop_sku_box_item_tip" v-if="specifications.item.isPauseSale == 1">
<view>售罄</view> <view>售罄</view>
</view>
</view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</view> </scroll-view>
<view class="shop_bottom"> <view class="shop_bottom">
<view class="flex-between"> <view class="flex-between">
<view class="price"> <view class="price">
@@ -330,7 +334,11 @@
<view class="shop_skuselect flex-start" v-if="selectedSpecsStr"> <view class="shop_skuselect flex-start" v-if="selectedSpecsStr">
<view class="shop_skuselectname">{{selectedSpecsStr }}</view> <view class="shop_skuselectname">{{selectedSpecsStr }}</view>
</view> </view>
<view class="addShopping" :class="(shopCartNumber>0&&canSubmit)?'active':''" <view v-if="specifications.item.type == 'package'" class="addShopping"
:class="shopCartNumber>0&&allConditionsSatisfied?'active':''" @click="submitSelection()">
{{skuBtnText}}
</view>
<view v-else class="addShopping" :class="shopCartNumber>0&&canSubmit?'active':''"
@click="submitSelection()"> @click="submitSelection()">
{{skuBtnText}} {{skuBtnText}}
</view> </view>
@@ -556,9 +564,9 @@
uni.$u.debounce(navScroll.value = res.scrollTop, 500) uni.$u.debounce(navScroll.value = res.scrollTop, 500)
uni.$u.debounce(mainScroll(res), 500) uni.$u.debounce(mainScroll(res), 500)
if (res.scrollTop >= 44) { if (res.scrollTop >= 44) {
store.showSearch = true // store.showSearch = true
} else { } else {
store.showSearch = false // store.showSearch = false
} }
}); });
@@ -573,7 +581,10 @@
type: '', type: '',
product_id: '', product_id: '',
sku_id: '', sku_id: '',
groupSnap: {} groupSnap: {},
item: {
groupSnap: []
}
}) })
// 用于判断接口数据是否加载完成 // 用于判断接口数据是否加载完成
const isDataLoaded = ref(false); const isDataLoaded = ref(false);
@@ -628,35 +639,71 @@
}; };
// 存储选中的选项 // 存储选中的选项
const selectedOptions = ref([]);
// 选择规格的方法 // 监听 specifications 的变化
const goodsidClick = (option, goodsid) => { watch(
if (isOptionSelected(option)) { () => specifications.item.groupSnap,
(newGroupSnap) => {
if (Array.isArray(newGroupSnap)) {
selectedOptions.value = newGroupSnap.map(() => []);
}
}
);
// 存储选中的选项,二维数组
const selectedOptions = ref(
specifications.item.groupSnap.map(() => [])
);
// / 选择规格的方法
const goodsidClick = (setmenuindex, option, goodsid) => {
if (!selectedOptions.value[setmenuindex]) {
// 如果 selectedOptions.value[setmenuindex] 不存在,初始化一个空数组
selectedOptions.value[setmenuindex] = [];
}
if (isOptionSelected(setmenuindex, option)) {
// 如果已经选中,取消选中 // 如果已经选中,取消选中
selectedOptions.value = selectedOptions.value.filter(item => item.proId !== option.proId); selectedOptions.value[setmenuindex] = selectedOptions.value[setmenuindex].filter(item => item.proId !==
} else if (!isMaxSelected()) { option.proId);
} else if (!isMaxSelected(setmenuindex)) {
// 如果未达到最大选择数量,添加到选中列表 // 如果未达到最大选择数量,添加到选中列表
selectedOptions.value.push(option); selectedOptions.value[setmenuindex].push(option);
} }
}; };
// 判断选项是否已选中 // 判断选项是否已选中
const isOptionSelected = (option) => { const isOptionSelected = (setmenuindex, option) => {
return selectedOptions.value.some(item => item.proId == option.proId); // 确保 selectedOptions.value[setmenuindex] 存在
if (selectedOptions.value[setmenuindex]) {
return selectedOptions.value[setmenuindex].some(item => item.proId === option.proId);
}
return false;
}; };
// 判断是否达到最大选择数量 // 判断是否达到最大选择数量
const isMaxSelected = () => { const isMaxSelected = (setmenuindex) => {
// 初始他为可点击 // 确保 selectedOptions.value[setmenuindex] 存在
if (selectedOptions.value.length >= specifications.groupSnap.number) { if (selectedOptions.value[setmenuindex]) {
canSubmit.value = true; return selectedOptions.value[setmenuindex].length >= specifications.item.groupSnap[setmenuindex]
} else { .number;
canSubmit.value = false;
} }
return selectedOptions.value.length >= specifications.groupSnap.number; return false;
}; };
// 计算所有选中条件是否都符合
const allConditionsSatisfied = computed(() => {
return specifications.item.groupSnap.every((setmenu, index) => {
const selected = selectedOptions.value[index] || [];
// 检查是否达到最大选择数量
const hasEnoughSelection = selected.length === setmenu.number;
return hasEnoughSelection;
});
});
// 提交选择,套餐选中最后处理的数据
const selectedGroupSnap = ref([]);
// 计算属性,将 selectedSpecs 转换为字符串形式 // 计算属性,将 selectedSpecs 转换为字符串形式
const selectedSpecsStr = computed(() => { const selectedSpecsStr = computed(() => {
const values = Object.values(selectedSpecs.value); const values = Object.values(selectedSpecs.value);
@@ -675,25 +722,66 @@
} }
} }
// 套餐比较两个对象是否相等
function isObjectEqual(obj1, obj2) {
if (typeof obj1 !== 'object' || obj1 === null || typeof obj2 !== 'object' || obj2 === null) {
return obj1 === obj2;
}
const keys1 = Object.keys(obj1);
const keys2 = Object.keys(obj2);
if (keys1.length !== keys2.length) {
return false;
}
for (const key of keys1) {
if (Array.isArray(obj1[key]) && Array.isArray(obj2[key])) {
if (!isArrayEqual(obj1[key], obj2[key])) {
return false;
}
} else if (!isObjectEqual(obj1[key], obj2[key])) {
return false;
}
}
return true;
}
// 比较两个数组是否相等(忽略顺序)
function isArrayEqual(arr1, arr2) {
if (arr1.length !== arr2.length) {
return false;
}
const usedIndices = new Array(arr2.length).fill(false);
for (const item1 of arr1) {
let found = false;
for (let i = 0; i < arr2.length; i++) {
if (!usedIndices[i] && isObjectEqual(item1, arr2[i])) {
usedIndices[i] = true;
found = true;
break;
}
}
if (!found) {
return false;
}
}
return true;
}
// 根据购物车的数据匹配选中的商品查找是否有匹配的数组 // 根据购物车的数据匹配选中的商品查找是否有匹配的数组
const matchingProduct = async (data) => { const matchingProduct = async (data) => {
console.log(specifications, matchedProducts.value, selectedOptions.value, '11111')
return matchedProducts.value.find((product, index) => { return matchedProducts.value.find((product, index) => {
if (data.type == 'package') { if (specifications.type == 'package') {
// 套餐 // 套餐
let result = []; let result = false;
if (product.type == "package") { try {
JSON.parse(product.cartListinfo.pro_group_info).goods.forEach(item1 => { if (product.type == "package") {
selectedOptions.value.forEach(item2 => { let res = JSON.parse(product.cartListinfo.pro_group_info);
if (item1.proId === item2.proId && item1.skuId === item2 result = isArrayEqual(res, selectedGroupSnap.value);
.skuId) { }
result.push(item1); } catch (error) {
} //TODO handle the exception
});
});
} }
// 直接返回布尔值
return result.length > 0 ? result : false; return result;
} else if (specifications.item.type == 'sku') { } else if (specifications.item.type == 'sku') {
// 多规格 // 多规格
return product.skuId == data.id && product.id == data.productId return product.skuId == data.id && product.id == data.productId
@@ -704,23 +792,38 @@
}); });
} }
// 提交选择并执行下一步操作的方法 // 提交选择并执行下一步操作的方法
const submitSelection = async () => { const submitSelection = async () => {
if (shopCartNumber.value > 0 && canSubmit.value) {
// 是否是套餐package if (shopCartNumber.value > 0) {
let res = await matchingProduct(specifications.item.type == "package" ? specifications.item : let res = null
specifications.item.result) if (specifications.item.type == "package") {
console.log(res) if (!allConditionsSatisfied.value) {
return false
}
// 是否是套餐package
selectedGroupSnap.value = specifications.item.groupSnap.map((setmenu, index) => {
return {
...setmenu,
goods: selectedOptions.value[index]
};
});
res = await matchingProduct(selectedGroupSnap.value)
} else {
if (!canSubmit.value) {
return false
}
res = await matchingProduct(specifications.item.result)
}
if (res) { if (res) {
await calculateValue(res.cartNumber, '+', shopCartNumber.value) await calculateValue(res.cartNumber, '+', shopCartNumber.value)
} }
// 是否是套餐 有就传 // 是否是套餐 有就传
if (specifications.item.type == "package") { if (specifications.item.type != "package") {
specifications.groupSnap.goods = selectedOptions.value selectedGroupSnap.value = []
} else {
specifications.groupSnap = null
} }
console.log(specifications.groupSnap, 'specifications.groupSnap.goods')
websocketsendMessage({ websocketsendMessage({
id: res ? res.cartListId : '', id: res ? res.cartListId : '',
type: 'shopping', type: 'shopping',
@@ -731,10 +834,12 @@
sku_id: specifications.sku_id, sku_id: specifications.sku_id,
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) : number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) :
shopCartNumber.value, shopCartNumber.value,
pro_group_info: specifications.groupSnap, pro_group_info: selectedGroupSnap.value,
goods_type: specifications.item.type == "package" ? 'package' : '' goods_type: specifications.item.type == "package" ? 'package' : '',
is_print: 1
}) })
// 清空有无无清空套餐 // 清空套餐选中
selectedGroupSnap.value = []
showShopsku.value = false showShopsku.value = false
} }
@@ -742,6 +847,9 @@
//获取多规格数据 //获取多规格数据
const clickspecifications = async (item, index, indexs, type) => { const clickspecifications = async (item, index, indexs, type) => {
if (item.isSoldStock == 1 || item.isSaleTime == 0) {
return false;
}
// 数量清零 // 数量清零
shopCartNumber.value = 0 shopCartNumber.value = 0
// 初始化 // 初始化
@@ -763,7 +871,6 @@
selectedOptions.value = [] selectedOptions.value = []
specifications.product_id = res.id specifications.product_id = res.id
specifications.sku_id = item.skuId specifications.sku_id = item.skuId
specifications.groupSnap = res.groupSnap[0]
} }
// 购物车是否有商品 // 购物车是否有商品
specifications.type = res.type specifications.type = res.type
@@ -779,13 +886,6 @@
const singleclick = async (item, i) => { const singleclick = async (item, i) => {
// 判断购物车是否有该选中商品 // 判断购物车是否有该选中商品
let res = await matchingProduct(item) let res = await matchingProduct(item)
// 是否是套餐 有就传
console.log(specifications, '单规格')
if (specifications.item.type == "package") {
specifications.groupSnap.goods = selectedOptions.value
} else {
specifications.groupSnap = null
}
websocketsendMessage({ websocketsendMessage({
id: res ? item.cartListId : '', id: res ? item.cartListId : '',
type: 'shopping', type: 'shopping',
@@ -794,10 +894,8 @@
operate_type: await calculateValue(item.cartNumber, i) == 'del' ? 'del' : res ? 'edit' : 'add', operate_type: await calculateValue(item.cartNumber, i) == 'del' ? 'del' : res ? 'edit' : 'add',
product_id: item.id, product_id: item.id,
sku_id: item.skuId, sku_id: item.skuId,
number: await calculateValue(item.cartNumber, i) number: await calculateValue(item.cartNumber, i),
// pro_group_info: specifications.groupSnap, is_print: 1
// goods_type: specifications.item.type == "package" ? 'package' : ''
// pro_group_info: specifications.groupSnap
}) })
} }
@@ -900,30 +998,30 @@
return false return false
} }
// 检查消息是否已经处理过
if (processedMessageIds.has(Message.msg_id)) {
return;
}
processedMessageIds.add(Message.msg_id);
// 初始化 // 初始化
if (Message.operate_type == "shopping_init") { if (Message.operate_type == "init") {
cartList.value = Message.data cartList.value = Message.data
} }
// 清空购物车 // 清空购物车
if (Message.operate_type == 'shopping_cleanup') { if (Message.operate_type == 'cleanup') {
cartList.value = [] cartList.value = []
showCart.value = false showCart.value = false
} }
// 初始化购物车数据
if (Message.operate_type == "shopping_init") {
cartList.value = Message.data
}
// 删除除购物车 // 删除除购物车
if (Message.operate_type == 'shopping_del' && Message.status == 1) { if (Message.operate_type == 'del' && Message.status == 1) {
cartList.value = cartList.value.filter(item => item.id != Message.data.id); cartList.value = cartList.value.filter(item => item.id != Message.data.id);
} }
// 添加或者减少购物后返回 // 添加或者减少购物后返回
if (Message.operate_type == 'shopping_add' || Message.operate_type == 'sopping_edit' || Message if (Message.operate_type == 'add' || Message.operate_type == 'edit') {
.type == 'bc') {
[Message.data].forEach((objA) => { [Message.data].forEach((objA) => {
const index = cartList.value.findIndex((objB) => objB.id == objA.id); const index = cartList.value.findIndex((objB) => objB.id == objA.id);
if (index !== -1) { if (index !== -1) {
@@ -935,8 +1033,8 @@
} }
// 购物车数据更新从新请求 // 购物车数据更新从新请求
if (Message.type == 'product') { if (Message.type == 'product' && Message.data_type == 'product_update' && Message
cartList.value = [] .operate_type == 'product_update') {
isDataLoaded.value = false; isDataLoaded.value = false;
productqueryProduct() productqueryProduct()
} }
@@ -947,12 +1045,6 @@
msg_id: Message.msg_id msg_id: Message.msg_id
}) })
// 检查消息是否已经处理过
if (processedMessageIds.has(Message.msg_id)) {
return;
}
processedMessageIds.add(Message.msg_id);
// 初始化商品数量 // 初始化商品数量
await updateProductQuantities() await updateProductQuantities()
@@ -975,7 +1067,7 @@
Specialstop = shopProductList.productInfo Specialstop = shopProductList.productInfo
//TODO handle the exception //TODO handle the exception
} }
return cartList.value.map((cartItem) => { return cartList.value.flatMap((cartItem) => {
for (const group of Specialstop) { for (const group of Specialstop) {
for (const product of group.productList) { for (const product of group.productList) {
if (product.id == cartItem.product_id) { if (product.id == cartItem.product_id) {
@@ -990,6 +1082,59 @@
} }
} }
} }
if (cartItem.is_temporary === 1) {
return [{
// cartListId: 5309
// cartListinfo: Proxy {id: 5309, shop_id: 203, table_code: "40309814459", sku_id: 2863, product_id: 1273, …}
// cartNumber: "2.00"
// coverImg: "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/2/490de935cc9042bfa56d0c392f806484.jpg"
// groupType: null
// id: "1273"
// isHot: 1
// isSaleTime: 1
// isSoldStock: 0
// memberPrice: 0.88
// name: "连衣裙"
// originPrice: 0.88
// packFee: 0
// salePrice: 2.88
// skuId: "2863"
// skuList: Proxy {0: {…}}
// stockNumber: 0
// suitNum: 1
// type: "single"
// unitName: "个"
// cartListId: 5324
// cartListinfo: Proxy {id: 5324, shop_id: 203, table_code: "40309814459", sku_id: 0, product_id: -74982031, …}
// cartNumber: "25.00"
// create_time: "2025-03-18 15:05:37"
// discount_sale_amount: "357.00"
// discount_sale_note: ""
// id: 5324
// is_gift: 0
// is_print: 0
// is_temporary: 1
// is_wait_call: 0
// number: "25.00"
// pack_number: "0.00"
// pro_group_info: ""
// product_id: -74982031
// product_name: "零食吃"
// remark: ""
// shop_id: 203
// sku_id: 0
// sku_name: "VB宝贝"
// table_code: "40309814459"
// update_time: null
...cartItem,
memberPrice: cartItem.discount_sale_amount,
salePrice: cartItem.discount_sale_amount,
cartListinfo: cartItem,
cartListId: cartItem.id, // 购物车id
cartNumber: cartItem.number // 增加一个数量算法
}];
}
// 如果没找到匹配的商品,返回 null 或者其他默认值,这里返回 null // 如果没找到匹配的商品,返回 null 或者其他默认值,这里返回 null
return null; return null;
}).filter(item => item !== null); }).filter(item => item !== null);
@@ -1111,27 +1256,33 @@
shopProductList.hots = await productminiApphotsquery() shopProductList.hots = await productminiApphotsquery()
shopProductList.productInfo = await APIgroupquery() shopProductList.productInfo = await APIgroupquery()
} catch (error) {} } catch (error) {}
if (shopProductList.productInfo.length > 0 || shopProductList.hots.length > 0) {
// 如果商品报错就返回上一页 //TODO handle the exception
if (!shopProductList.productInfo || !shopProductList.hots) { //第一步:将所有商品的 cartNumber 初始化为 0
uni.navigateBack() 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;
} else {
uni.showToast({
title: '错误二维码'
});
isDataLoaded.value = false;
setTimeout(() => {
uni.navigateBack()
}, 1000)
return false; return false;
} }
//TODO handle the exception
//第一步:将所有商品的 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;
} }
@@ -1157,18 +1308,18 @@
// 获取页面参数 // 获取页面参数
const options = currentPage.options; const options = currentPage.options;
// #ifdef MP-WEIXIN // // #ifdef MP-WEIXIN
if (options.q) { // if (options.q) {
console.log(options.q) // console.log(options.q)
const store = productStore(); // const store = productStore();
await store.scanCodeactions(options.q) // await store.scanCodeactions(options.q)
} // }
// #endif // // #endif
// #ifdef MP-ALIPAY // // #ifdef MP-ALIPAY
if (getApp().globalData.tableCode) { // if (getApp().globalData.tableCode) {
await store.scanCodeactions(getApp().globalData.tableCode) // await store.scanCodeactions(getApp().globalData.tableCode)
} // }
// #endif // // #endif
await productqueryProduct() await productqueryProduct()
setTimeout(() => { setTimeout(() => {
@@ -1732,21 +1883,16 @@
position: relative; position: relative;
border-radius: 20rpx; border-radius: 20rpx;
background: #fff; background: #fff;
overflow-y: auto;
padding-bottom: 320rpx;
box-sizing: border-box; box-sizing: border-box;
padding-bottom: 250rpx;
.positionabsolute { .positionabsolute {
position: absolute; position: absolute;
top: 30rpx; top: 30rpx;
z-index: 999;
right: 30rpx; right: 30rpx;
} }
.shop_skucimage {
width: 100%;
height: 500rpx !important;
border-radius: 20rpx 20rpx 0 0;
}
.shop_sku_name { .shop_sku_name {
padding: 0 28rpx; padding: 0 28rpx;
@@ -1776,7 +1922,7 @@
.shop_sku_box { .shop_sku_box {
padding: 0 28rpx; padding: 20rpx 28rpx;
.shop_sku_box_name { .shop_sku_box_name {
margin-top: 20rpx; margin-top: 20rpx;
@@ -1800,7 +1946,6 @@
.shop_sku_box_item_tip { .shop_sku_box_item_tip {
width: 62rpx; width: 62rpx;
height: 47rpx; height: 47rpx;
// background-color: #CECECE;
text-align: right; text-align: right;
position: absolute; position: absolute;
top: 0; top: 0;

View File

@@ -21,7 +21,7 @@
<view class="containertopboxitemleft_one" <view class="containertopboxitemleft_one"
:class="fromInfo.status != 0?'':'containertopboxitemleft_ones'"> :class="fromInfo.status != 0?'':'containertopboxitemleft_ones'">
<block v-if="item.type == 2"> <block v-if="item.type == 2">
<text>{{item.num || 0}}</text> <text>1</text>
<text style="font-size: 28rpx;margin-left: 6rpx;"></text> <text style="font-size: 28rpx;margin-left: 6rpx;"></text>
</block> </block>
<block v-else> <block v-else>

View File

@@ -181,9 +181,8 @@
url: uni.conf.baseUrl + '/account/user/common/upload', url: uni.conf.baseUrl + '/account/user/common/upload',
filePath: avatarUrl, filePath: avatarUrl,
header: { header: {
environment: 'app', shopId: uni.cache.get('shopId'),
type: 'android', token: uni.cache.get('token') || '',
version: '1.7.3',
'content-type': 'multipart/form-data' 'content-type': 'multipart/form-data'
}, },
fileType: 'image', fileType: 'image',

View File

@@ -64,7 +64,7 @@
<view class="gift_list"> <view class="gift_list">
<view class="gift_list_item" v-for="(item,index) in infoForn.couponList" :key="index"> <view class="gift_list_item" v-for="(item,index) in infoForn.couponList" :key="index">
<text class="icon"></text> <text class="icon"></text>
<text class="text"> {{ item.title }} </text> <text class="text"> {{ item.title }} * {{ item.number}}</text>
</view> </view>
</view> </view>
</view> </view>

View File

@@ -29,17 +29,17 @@
<view class="card_cen"> <view class="card_cen">
<view class="card_cen_left">{{ shopUserInfo.shopInfo.isVip == 0 ? '尚未开通会员暂无法享受会员权益' : '欢迎加入本店会员~'}} <view class="card_cen_left">{{ shopUserInfo.shopInfo.isVip == 0 ? '尚未开通会员暂无法享受会员权益' : '欢迎加入本店会员~'}}
</view> </view>
<view class="card_cen_right" v-if="shopUserInfo.shopInfo.isVip != 0">查看特权</view> <!-- <view class="card_cen_right" v-if="shopUserInfo.shopInfo.isVip != 0">查看特权</view> -->
</view> </view>
<view class="card_bom" v-if="shopUserInfo.shopInfo.isVip != 0"> <view class="card_bom" v-if="shopUserInfo.shopInfo.isVip != 0">
<view class="card_bom_item" @click="itemClick(1)"> <view class="card_bom_item" @click="itemClick(1)">
<text>{{shopUserInfo.shopInfo.amount || '0.00'}}</text><text>储值</text> <text>{{shopUserInfo.amount || '0.00'}}</text><text>储值</text>
</view> </view>
<view class="card_bom_item" @click="itemClick(2)"> <view class="card_bom_item" @click="itemClick(2)">
<text>{{shopUserInfo.shopInfo.accountPoints || '0'}}</text><text>积分</text> <text>{{shopUserInfo.accountPoints || '0'}}</text><text>积分</text>
</view> </view>
<view class="card_bom_item" @click="itemClick(3)"> <view class="card_bom_item" @click="itemClick(3)">
<text>{{shopUserInfo.shopInfo.couponNum || '0'}}</text><text>优惠券</text> <text>{{shopUserInfo.couponNum || '0'}}</text><text>优惠券</text>
</view> </view>
<view class="card_bom_item"> <view class="card_bom_item">
<text>0</text><text>权益卡</text> <text>0</text><text>权益卡</text>
@@ -159,6 +159,7 @@
let res = await APIshopUserInfo({ let res = await APIshopUserInfo({
shopId: shopUserInfo.shopId shopId: shopUserInfo.shopId
}) })
Object.assign(shopUserInfo, res);
uni.cache.set('orderVIP', res) uni.cache.set('orderVIP', res)
uni.cache.set('ordershopUserInfo', res.shopInfo) uni.cache.set('ordershopUserInfo', res.shopInfo)
form.memberOpen = res.isVip == 1 ? false : true form.memberOpen = res.isVip == 1 ? false : true
@@ -188,7 +189,6 @@
// 根据传的shopInfo来返回上面的值 // 根据传的shopInfo来返回上面的值
// shopUserInfo.shopExtend = res.shopExtend.member_bg // shopUserInfo.shopExtend = res.shopExtend.member_bg
asyncshopUserInfo() asyncshopUserInfo()
console.log(shopUserInfo.shopId)
} }
}) })

View File

@@ -39,7 +39,7 @@
const formInfo = reactive({ const formInfo = reactive({
shopInfo: '', shopInfo:uni.cache.get('orderVIP'),
url: '', url: '',
shopId: '' shopId: ''
}) })
@@ -51,47 +51,46 @@
const currentPage = pages[pages.length - 1]; const currentPage = pages[pages.length - 1];
// 获取页面参数 // 获取页面参数
const pageParams = currentPage.options; const pageParams = currentPage.options;
formInfo.shopInfo = JSON.parse(decodeURIComponent(pageParams.shopInfo)) // formInfo.shopInfo = JSON.parse(decodeURIComponent(pageParams.shopInfo))
formInfo.shopId = pageParams.shopId formInfo.shopId = pageParams.shopId
let res = await APIshopUsercode({ let res = await APIshopUsercode({
shopId: pageParams.shopId shopId: pageParams.shopId
}) })
console.log(formInfo.shopInfo)
if (res) { if (res) {
formInfo.url = res; formInfo.url = res;
try { try {
nextTick(() => { // nextTick(() => {
const query = uni.createSelectorQuery(); // const query = uni.createSelectorQuery();
query.select('#barcodeCanvas') // query.select('#barcodeCanvas')
.fields({ // .fields({
node: true, // node: true,
size: true // size: true
}) // })
.exec((res) => { // .exec((res) => {
if (res[0]) { // if (res[0]) {
const canvas = res[0].node; // const canvas = res[0].node;
const ctx = canvas.getContext('2d'); // const ctx = canvas.getContext('2d');
const dpr = uni.getSystemInfoSync().pixelRatio; // const dpr = uni.getSystemInfoSync().pixelRatio;
canvas.width = res[0].width * dpr; // canvas.width = res[0].width * dpr;
canvas.height = res[0].height * dpr; // canvas.height = res[0].height * dpr;
ctx.scale(dpr, dpr); // ctx.scale(dpr, dpr);
JsBarcode(canvas, formInfo.url, { // JsBarcode(canvas, formInfo.url, {
width: 2, // width: 2,
height: 100, // height: 100,
displayValue: true, // displayValue: true,
fontOptions: 'bold', // fontOptions: 'bold',
font: 'monospace', // font: 'monospace',
textAlign: 'center', // textAlign: 'center',
textPosition: 'bottom', // textPosition: 'bottom',
textMargin: 2, // textMargin: 2,
fontSize: 20, // fontSize: 20,
background: '#ffffff', // background: '#ffffff',
lineColor: '#000000' // lineColor: '#000000'
}); // });
} // }
}); // });
}); // });
} catch (error) { } catch (error) {
//TODO handle the exception //TODO handle the exception
} }

View File

@@ -1,12 +1,16 @@
<template> <template>
<view class="Box"> <view class="Box">
<view class="box_box"> <view class="box_box">
<view class="box_item flex-between"> <!-- <view class="box_item flex-between">
<text class="top_box_one_text">当前账号</text> <text class="top_box_one_text">当前账号</text>
<input type="number" v-model="form.mobile" placeholder="请输入手机号" maxlength="11" disabled="disabled" /> <input type="number" v-model="form.mobile" placeholder="请输入手机号" maxlength="11" disabled="disabled" />
<button v-if="!form.mobile" class="getPhone" open-type="getPhoneNumber" @getphonenumber="getPhone"> <button v-if="!form.mobile" class="getPhone" open-type="getPhoneNumber" @getphonenumber="getPhone">
<view class="text">获取手机号</view> <view class="text">获取手机号</view>
</button> </button>
</view> -->
<view class="box_item flex-between">
<text class="top_box_one_text">当前账号</text>
<input type="number" v-model="form.mobile" placeholder="请输入手机号" maxlength="11" :disabled="true" />
</view> </view>
<view class="box_item flex-between" style="position:relative;"> <view class="box_item flex-between" style="position:relative;">
@@ -45,13 +49,25 @@
onMounted onMounted
} from 'vue'; } from 'vue';
import {
APIuserpwd,
APIusercode
} from '@/common/api/api.js'
import {
APIshopUserInfo
} from '@/common/api/member.js'
import {
productStore
} from '@/stores/user.js';
const storeuser = productStore();
const shopUserInfo = reactive({ const shopUserInfo = reactive({
shopInfo: "", shopInfo: uni.cache.get('orderVIP'),
shopId: '' shopId: ''
}) })
const form = reactive({ const form = reactive({
mobile: '', mobile: uni.cache.get('orderVIP').phone,
password: '', password: '',
payPassword: '', payPassword: '',
checkCode: '' checkCode: ''
@@ -65,11 +81,10 @@
second: 60, second: 60,
showText: true, showText: true,
Recapture: '获取验证码', Recapture: '获取验证码',
shopUserInfo: null,
}) })
const CodeRegister = async () => { const CodeRegister = async () => {
const res = await this.api.phoneValidateCode({ const res = await APIusercode({
// post 手机验证码 // post 手机验证码
phone: form.mobile phone: form.mobile
}); });
@@ -167,30 +182,15 @@
return false; return false;
} }
let res = await this.api.loginresetPwd({ let res = await APIuserpwd({
vipId: this.shopUserInfo.id, checkPayPwd: form.payPassword,
pwd: this.form.password, payPwd: form.password,
code: this.form.checkCode code: form.checkCode
}) })
// * 获取会员信息
if (res.code == 0) { await storeuser.actionsproductqueryProduct()
if (datalist.isPwd != 0) { if (res) {
uni.showToast({ uni.navigateBack()
title: '修改成功',
icon: 'none'
});
} else {
uni.showToast({
title: '设置成功',
icon: 'none'
});
}
setTimeout(() => {
// 获取用户信息
this.loginwxuserInfo()
uni.navigateBack();
}, 1000);
} }
} }
@@ -201,8 +201,16 @@
const currentPage = pages[pages.length - 1]; const currentPage = pages[pages.length - 1];
// 获取页面参数 // 获取页面参数
const options = currentPage.options; const options = currentPage.options;
shopUserInfo.shopInfo = JSON.parse(decodeURIComponent(options.shopInfo)) // if (options.shopId) {
console.log(shopUserInfo) // let res = await APIshopUserInfo({F
// shopId: options.shopId
// })
// uni.cache.set('shopId', options.shopId, 30)
// uni.cache.set('orderVIP', res)
// uni.cache.set('ordershopUserInfo', res.shopInfo)
// } else {
// shopUserInfo.shopInfo = JSON.parse(decodeURIComponent(options.shopInfo))
// }
}) })
</script> </script>

View File

@@ -17,7 +17,7 @@
</view> </view>
</view> </view>
<view class="my_item my_assets"> <view class="my_item my_assets" @click="Myassets">
<view class="my_item_title">我的资产</view> <view class="my_item_title">我的资产</view>
<view class="my_assets_list"> <view class="my_assets_list">
<view class="my_list_item"> <view class="my_list_item">
@@ -32,14 +32,14 @@
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/points.png"> src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/points.png">
</image> </image>
<view class="my_list_item_name">积分</view> <view class="my_list_item_name">积分</view>
<view class="my_list_item_num">{{userInfo.couponNum ||'0'}}</view> <view class="my_list_item_num">{{userInfo.accountPoints ||'0'}}</view>
</view> </view>
<view class="my_list_item"> <view class="my_list_item">
<image class="my_list_item_icon" <image class="my_list_item_icon"
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/coupon.png"> src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/coupon.png">
</image> </image>
<view class="my_list_item_name">优惠券</view> <view class="my_list_item_name">优惠券</view>
<view class="my_list_item_num">{{userInfo.points ||'0'}}</view> <view class="my_list_item_num">{{userInfo.couponNum ||'0'}}</view>
</view> </view>
</view> </view>
</view> </view>
@@ -107,7 +107,7 @@
const teblist = ref([]) const teblist = ref([])
const shopExtend = ref(null) const shopExtend = ref(null)
const userInfo = reactive({}) const userInfo = reactive({})
const ShopId = ref(uni.cache.get('shopId')) const ShopId = ref(uni.cache.get('shopId'))
const clickEvent = () => { const clickEvent = () => {
@@ -129,6 +129,14 @@
} }
} }
// 我的资产
const Myassets = () => {
uni.pro.navigateTo('user/member/memberdetails', {
shopId: uni.cache.get('shopId'),
type: 'index'
})
}
const clickTo = (item, index) => { const clickTo = (item, index) => {
let shopId = null; let shopId = null;
switch (item.type) { switch (item.type) {

View File

@@ -44,7 +44,8 @@ export const useCartStore = defineStore('cart', () => {
if (uni.cache.get('orderVIP').isVip == 1 && uni.cache.get('ordershopUserInfo') if (uni.cache.get('orderVIP').isVip == 1 && uni.cache.get('ordershopUserInfo')
.isMemberPrice == 1) { .isMemberPrice == 1) {
// memberPrice会员价 // memberPrice会员价
return total + (parseFloat(item.memberPrice) * parseFloat(item.num - item.returnNum)); return total + (parseFloat(item.memberPrice) * parseFloat(item.num - item
.returnNum));
} else { } else {
// salePrice销售价 // salePrice销售价
return total + (parseFloat(item.price) * parseFloat(item.num - item.returnNum)); return total + (parseFloat(item.price) * parseFloat(item.num - item.returnNum));
@@ -94,9 +95,13 @@ export const useCartStore = defineStore('cart', () => {
// 计算购物车总打包费用(向下取整并保留两位小数) // 计算购物车总打包费用(向下取整并保留两位小数)
const getTotalPackFee = (cartList) => computed(() => { const getTotalPackFee = (cartList) => computed(() => {
const total = cartList.reduce((sum, item) => { const total = cartList.reduce((sum, item) => {
return sum + (item.packAmount * (item.packNumber || (item.num - item.returnNum))); return sum + (parseFloat(item.packAmount) * (parseFloat(item.packNumber) || (
parseFloat(item.num) - parseFloat(item.returnNum))));
}, 0); }, 0);
return Math.floor(total * 100) / 100; // 向下取整并保留两位小数
let result = roundUpToTwoDecimals(total, 'downward')
return result;
// return Math.floor(total * 100) / 100;
}); });
return { return {