完善小程序
This commit is contained in:
parent
fc957feb72
commit
9da31e2faa
50
App.vue
50
App.vue
|
|
@ -32,57 +32,7 @@
|
|||
console.log(error)
|
||||
}
|
||||
// #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 {
|
||||
// onLaunch: async function() {
|
||||
|
||||
|
|
|
|||
|
|
@ -53,16 +53,11 @@
|
|||
freeCheck: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
orderVIP: {
|
||||
type: Object,
|
||||
default: {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
const orderVIP = ref(uni.cache.get('orderVIP'))
|
||||
const emits = defineEmits(['customevent', 'groupChange']);
|
||||
|
||||
|
||||
|
|
@ -111,7 +106,7 @@
|
|||
},
|
||||
])
|
||||
|
||||
const radiovalue = ref(1) // 支付方式
|
||||
const radiovalue = ref(2) // 支付方式
|
||||
|
||||
const ispws = ref(false) // 输入支付密码
|
||||
|
||||
|
|
@ -134,7 +129,7 @@
|
|||
// 去充值
|
||||
const goRecharge = () => {
|
||||
uni.pro.navigateTo('user/member/index', {
|
||||
shopId: props.orderVIP.shopId
|
||||
shopId: orderVIP.value.shopId
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -338,9 +338,54 @@
|
|||
uni.$u.debounce(store.scrollTop = res.scrollTop, 500)
|
||||
});
|
||||
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;
|
||||
if (uni.cache.get('shopId')) {
|
||||
showindex.value = 'shopIndex'
|
||||
|
|
@ -351,6 +396,9 @@
|
|||
init_fn()
|
||||
// 获取初始定位高度
|
||||
}
|
||||
})
|
||||
onMounted(async () => {
|
||||
|
||||
});
|
||||
|
||||
onReachBottom(() => {
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
<view class="integral-modal" v-if="visible">
|
||||
<view class="modal-mask" @click="closeModal"></view>
|
||||
<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"
|
||||
:placeholder="instructions" />
|
||||
</view>
|
||||
<!-- <view class="instructions">{{ instructions }}</view> -->
|
||||
<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>
|
||||
</template>
|
||||
|
|
@ -72,7 +72,6 @@
|
|||
|
||||
// 确认积分并返回值给父组件
|
||||
const confirmIntegral = () => {
|
||||
console.log(inputValue.value, 444)
|
||||
if (inputValue.value < props.minValue || inputValue.value > props.maxValue) {
|
||||
uni.showToast({
|
||||
title: '输入的积分值不在有效范围内',
|
||||
|
|
@ -138,7 +137,7 @@
|
|||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #fff;
|
||||
padding: 20px;
|
||||
padding: 20rpx 20rpx;
|
||||
box-sizing: border-box;
|
||||
border-top-left-radius: 10px;
|
||||
border-top-right-radius: 10px;
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@
|
|||
<view class="val">
|
||||
<view></view>
|
||||
<view style="font-size: 28rpx;">¥</view>
|
||||
<view>{{listinfo.packFee}}</view>
|
||||
<view>{{listinfo.packFeess}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
|
@ -295,7 +295,17 @@
|
|||
},
|
||||
|
||||
listinfo: {
|
||||
type: Object
|
||||
type: Object,
|
||||
default: {
|
||||
combinedArray: {},
|
||||
Productroll: 0,
|
||||
coupondiscountAmount: 0,
|
||||
couponInfoList: '',
|
||||
pointsDiscountAmount: 0,
|
||||
packFeess: 0,
|
||||
totalPrices: 0,
|
||||
Seatcharge: 0
|
||||
}
|
||||
|
||||
},
|
||||
orderVIP: {
|
||||
|
|
@ -359,6 +369,7 @@
|
|||
})
|
||||
break;
|
||||
case 'points':
|
||||
IntegralInputclose()
|
||||
if (calcUsablePointsData.usable == 0) {
|
||||
uni.showToast({
|
||||
title: calcUsablePointsData.unusableReason,
|
||||
|
|
@ -384,7 +395,7 @@
|
|||
calcUsablePointsData.integral = integral
|
||||
props.listinfo.pointsDiscountAmount = await APImemberPointscalcDeductionAmount({
|
||||
points: integral,
|
||||
userId: props.orderVIP.id,
|
||||
shopUserId: props.orderVIP.id,
|
||||
orderAmount: props.listinfo.totalCost
|
||||
})
|
||||
emits('clickPointsamount', props.listinfo.pointsDiscountAmount);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
<view class="containertopboxitemleft_one" v-if="Orderinfo.typeOrder == 1"
|
||||
:class="Orderinfo.typeOrder == 1 ?'':'containertopboxitemleft_ones'">
|
||||
<block v-if="item.type == 2">
|
||||
<text>{{item.num || 0}}</text>
|
||||
<text>1</text>
|
||||
<text style="font-size: 28rpx;margin-left: 6rpx;">张</text>
|
||||
</block>
|
||||
<block v-else>
|
||||
|
|
|
|||
|
|
@ -123,6 +123,11 @@
|
|||
|
||||
const storeMemberpay = Memberpay();
|
||||
|
||||
import {
|
||||
productStore
|
||||
} from '@/stores/user.js';
|
||||
const storeuser = productStore();
|
||||
|
||||
import payPassword from '@/components/payPassword.vue'
|
||||
import orderInfoAfter from './components/orderInfoAfter.vue'
|
||||
// import orderInfoBefore from '../components/orderInfoBefore.vue'
|
||||
|
|
@ -136,9 +141,7 @@
|
|||
const ispws = ref(false)
|
||||
|
||||
// 商品订单会员
|
||||
const ordershopUserInfo = ref({
|
||||
isTableFee: 0
|
||||
})
|
||||
const ordershopUserInfo = ref(uni.cache.get('ordershopUserInfo'))
|
||||
|
||||
// 是否显示商家二维码信息
|
||||
try {
|
||||
|
|
@ -155,15 +158,14 @@
|
|||
combinedArray: {},
|
||||
Productroll: 0,
|
||||
coupondiscountAmount: 0,
|
||||
couponInfoList: '',
|
||||
pointsDiscountAmount: 0,
|
||||
packFee: 0,
|
||||
packFeess: 0,
|
||||
totalPrices: 0,
|
||||
Seatcharge: 0
|
||||
})
|
||||
|
||||
// 会员信息
|
||||
const orderVIP = ref()
|
||||
const orderVIP = ref(uni.cache.get('orderVIP'))
|
||||
|
||||
//判断是否是打包商品
|
||||
const is_type = ref(0)
|
||||
|
|
@ -190,9 +192,6 @@
|
|||
orderId: orderId.value
|
||||
})
|
||||
} catch (error) {}
|
||||
// if (listinfo.couponInfoList) {
|
||||
// listinfo.couponInfoList = JSON.parse(listinfo.couponInfoList)
|
||||
// }
|
||||
}
|
||||
// 历史订单
|
||||
if (listinfo.detailMap) {
|
||||
|
|
@ -204,7 +203,7 @@
|
|||
}
|
||||
}
|
||||
listinfo.combinedArray = combinedArray
|
||||
listinfo.packFee = await cartStore.getTotalPackFee(listinfo.combinedArray)
|
||||
listinfo.packFeess = await cartStore.getTotalPackFee(listinfo.combinedArray)
|
||||
// 计算购物车商品费用
|
||||
listinfo.totalPrices = await cartStore.getTotalTotalPrices(listinfo
|
||||
.combinedArray)
|
||||
|
|
@ -231,24 +230,24 @@
|
|||
watchEffect(async () => {
|
||||
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)
|
||||
// 打包费packFee 计算购物车商品费用totalPrices 餐位费Seatcharge
|
||||
// 打包费packFeess 计算购物车商品费用totalPrices 餐位费Seatcharge
|
||||
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 ==
|
||||
0 ? listinfo.Seatcharge : 0);
|
||||
listinfo.originAmount = Math.round(sum * 100) / 100;
|
||||
|
||||
// 打包费packFee 计算购物车商品费用totalPrices 餐位费Seatcharge 商品卷Productroll 优惠卷coupondiscountAmount 积分listinfo.pointsDiscountAmount
|
||||
let sums = (is_type.value != 0 ? listinfo.packFee : 0) + listinfo.totalPrices + (is_type
|
||||
// 打包费packFeess 计算购物车商品费用totalPrices 餐位费Seatcharge 商品卷Productroll 优惠卷coupondiscountAmount 积分listinfo.pointsDiscountAmount
|
||||
let sums = (is_type.value != 0 ? listinfo.packFeess : 0) + listinfo.totalPrices + (is_type
|
||||
.value ==
|
||||
0 ? listinfo.Seatcharge : 0) - (listinfo.Productroll || 0) - (listinfo
|
||||
.coupondiscountAmount || 0) - (listinfo.pointsDiscountAmount || 0);
|
||||
listinfo.totalCost = Math.round(sums * 100) / 100;
|
||||
// 积分
|
||||
if (listinfo.totalCost && listinfo.status == 'unpaid') {
|
||||
uni.$u.debounce(await memberPointscalcUsablePoints(), 500)
|
||||
uni.$u.debounce(memberPointscalcUsablePoints, 500)
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
@ -271,9 +270,9 @@
|
|||
|
||||
// 支付方式切换
|
||||
const paymentmethod = reactive({
|
||||
radiovalue: 1,
|
||||
paymentBtnText: "余额支付",
|
||||
payType: 'accountPay'
|
||||
radiovalue: 2,
|
||||
paymentBtnText: "微信支付",
|
||||
payType: 'wechatPay'
|
||||
})
|
||||
|
||||
const groupChange = async (e) => {
|
||||
|
|
@ -349,7 +348,21 @@
|
|||
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 {
|
||||
ispws.value = true
|
||||
|
|
@ -374,19 +387,23 @@
|
|||
pointsNum: 0, //(扣除各类折扣 enable_deduction后使用)
|
||||
remark: '', //用户备注
|
||||
}
|
||||
let res = await storeMemberpay.actionsltPayOrder({
|
||||
checkOrderPay,
|
||||
payType: paymentmethod.payType,
|
||||
buyerRemark: '',
|
||||
returnUrl: ''
|
||||
})
|
||||
await orderorderInfo()
|
||||
try {
|
||||
await storeMemberpay.actionsltPayOrder({
|
||||
checkOrderPay,
|
||||
payType: paymentmethod.payType,
|
||||
buyerRemark: '',
|
||||
returnUrl: ''
|
||||
})
|
||||
} catch (error) {
|
||||
//TODO handle the exception
|
||||
}
|
||||
orderorderInfo()
|
||||
}
|
||||
|
||||
//002-获取订单可用积分及抵扣金额(支付页面使用)
|
||||
const memberPointscalcUsablePoints = async () => {
|
||||
let res = await APImemberPointscalcUsablePoints({
|
||||
userId: orderVIP.value.id,
|
||||
shopUserId: orderVIP.value.id,
|
||||
orderAmount: listinfo.totalCost,
|
||||
})
|
||||
orderInfoAfterRef.value.getCalcUsablePoints(res)
|
||||
|
|
@ -433,7 +450,7 @@
|
|||
} catch (error) {
|
||||
//TODO handle the exception
|
||||
}
|
||||
await orderorderInfo()
|
||||
orderorderInfo()
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
|
|
@ -453,14 +470,19 @@
|
|||
// 每次进来全局更新shopId
|
||||
uni.cache.set('shopId', options.shopId, 30)
|
||||
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({
|
||||
shopId: options.shopId
|
||||
})
|
||||
uni.cache.set('orderVIP', res)
|
||||
uni.cache.set('ordershopUserInfo', res.shopInfo)
|
||||
orderVIP.value = res
|
||||
ordershopUserInfo.value = res.shopInfo
|
||||
await storeuser.actionsproductqueryProduct()
|
||||
} catch (error) {
|
||||
//TODO handle the exception
|
||||
}
|
||||
orderorderInfo()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@
|
|||
</view>
|
||||
</view>
|
||||
<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>
|
||||
</view>
|
||||
</view>
|
||||
|
|
|
|||
|
|
@ -30,9 +30,28 @@
|
|||
|
||||
<script setup>
|
||||
import {
|
||||
ref
|
||||
ref,
|
||||
onMounted,
|
||||
getCurrentInstance
|
||||
} 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 numIndex = ref(0)
|
||||
|
|
@ -82,6 +101,28 @@
|
|||
uni.cache.set('dinersNum', dinersNum.value)
|
||||
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>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
|
|
|||
|
|
@ -18,17 +18,20 @@
|
|||
<up-image :src="item.coverImg" width="80" radius="10" height="80"></up-image>
|
||||
</view>
|
||||
<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'">
|
||||
<text v-for="i in item.skuList" :key="i.id">
|
||||
{{item.cartListinfo.sku_id == i.id? i.name:"" }}
|
||||
</text>
|
||||
</view>
|
||||
<view class="select-sku-wrap" v-if="item.type == 'package'">
|
||||
<view>{{dataprocessing(item.cartListinfo).title}}</view>
|
||||
<text v-for="i in dataprocessing(item.cartListinfo).goods" :key="i.id">
|
||||
{{i.proName }}
|
||||
</text>
|
||||
<view v-for="(a,b) in dataprocessing(item.cartListinfo)" :key="b">
|
||||
<!-- <view>{{a.title}}</view> -->
|
||||
<text v-for="i in a.goods" :key="i.proId" style="margin-left: 4rpx;">
|
||||
{{i.proName }}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="price-wrap" style="padding-top: 0;">
|
||||
<view class="price">
|
||||
|
|
@ -147,7 +150,14 @@
|
|||
|
||||
const dataprocessing = computed(() => {
|
||||
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 {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.shop-item-remark {
|
||||
|
|
|
|||
|
|
@ -257,54 +257,58 @@
|
|||
</view>
|
||||
|
||||
<!-- 规格 -->
|
||||
<up-popup :show="showShopsku" :round="20" mode="bottom" @close="showShopsku = false;pagemetashow=false"
|
||||
:safeAreaInsetBottom='false'>
|
||||
<view class="shop_sku" style="max-height:70vh;">
|
||||
<view class="positionabsolute">
|
||||
<up-icon name="close-circle" @click="showShopsku = false;pagemetashow=false" color="#000"
|
||||
size="25"></up-icon>
|
||||
</view>
|
||||
<up-swiper :list="specifications.item.images" height="250"></up-swiper>
|
||||
<view class="shop_sku_name"> {{specifications.item.name}} </view>
|
||||
<view class="shop_sku_description"> {{specifications.item.shortTitle?specifications.item.shortTitle:''}}
|
||||
</view>
|
||||
<view v-if="specifications.item.type != 'package'">
|
||||
<view class="shop_sku_box" v-for="(specOptions,specType) in specifications.item.selectSpecInfo"
|
||||
:key="specType">
|
||||
<view class="shop_sku_box_name">
|
||||
{{specType }}
|
||||
</view>
|
||||
<view class="flex-start">
|
||||
<view class="shop_sku_box_item" v-for="option in specOptions" :key="option"
|
||||
@click="selectSpec(specType, option)"
|
||||
:class="{ shop_sku_box_item_selected: selectedSpecs[specType] === option }">
|
||||
{{option}}
|
||||
<view class="shop_sku_box_item_tip" v-if="specifications.item.isPauseSale == 1">
|
||||
<view>售罄</view>
|
||||
<up-popup :show="showShopsku" :round="20" mode="bottom" @close="showShopsku = false,pagemetashow = false">
|
||||
<view class="shop_sku">
|
||||
<scroll-view scroll-y style="max-height:60vh;width: 100%;">
|
||||
<view class="positionabsolute">
|
||||
<up-icon name="close-circle" @click="showShopsku = false;pagemetashow=false" color="#000"
|
||||
size="25"></up-icon>
|
||||
</view>
|
||||
<up-swiper :list="specifications.item.images" height="250"></up-swiper>
|
||||
<view class="shop_sku_name"> {{specifications.item.name}} </view>
|
||||
<view class="shop_sku_description">
|
||||
{{specifications.item.shortTitle?specifications.item.shortTitle:''}}
|
||||
</view>
|
||||
<view v-if="specifications.item.type != 'package'">
|
||||
<view class="shop_sku_box" v-for="(specOptions,specType) in specifications.item.selectSpecInfo"
|
||||
:key="specType">
|
||||
<view class="shop_sku_box_name">
|
||||
{{specType }}
|
||||
</view>
|
||||
<view class="flex-start">
|
||||
<view class="shop_sku_box_item" v-for="option in specOptions" :key="option"
|
||||
@click="selectSpec(specType, option)"
|
||||
:class="{ shop_sku_box_item_selected: selectedSpecs[specType] === option }">
|
||||
{{option}}
|
||||
<view class="shop_sku_box_item_tip" v-if="specifications.item.isPauseSale == 1">
|
||||
<view>售罄</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 套餐 -->
|
||||
<view v-else>
|
||||
<view class="shop_sku_box">
|
||||
<view class="shop_sku_box_name">
|
||||
{{specifications.groupSnap.count }} 选 {{specifications.groupSnap.number }}
|
||||
</view>
|
||||
<view class="flex-start">
|
||||
<view class="shop_sku_box_item" v-for="(option,goodsid) in specifications.groupSnap.goods"
|
||||
:key="goodsid" @click="goodsidClick(option, goodsid)"
|
||||
:class="{ shop_sku_box_item_selected: isOptionSelected(option)}"
|
||||
:disabled="isMaxSelected() &&!isOptionSelected(option)">
|
||||
{{option.proName}}/{{option.skuName}}
|
||||
<view class="shop_sku_box_item_tip" v-if="specifications.item.isPauseSale == 1">
|
||||
<view>售罄</view>
|
||||
<!-- 套餐 -->
|
||||
<view v-else>
|
||||
<view class="shop_sku_box">
|
||||
<view v-for="(setmenu, setmenuindex) in specifications.item.groupSnap" :key='setmenuindex'>
|
||||
<view class="shop_sku_box_name">
|
||||
{{setmenu.title}} {{setmenu.count }} 选{{setmenu.number }}
|
||||
</view>
|
||||
<view class="flex-start">
|
||||
<view class="shop_sku_box_item" v-for="(option, goodsid) in setmenu.goods"
|
||||
:key="goodsid" @click="goodsidClick(setmenuindex, option, goodsid)"
|
||||
:class="{ shop_sku_box_item_selected: isOptionSelected(setmenuindex, option)}"
|
||||
:disabled="isMaxSelected(setmenuindex) &&!isOptionSelected(setmenuindex, option)">
|
||||
{{option.proName}}/{{option.unitName}}
|
||||
<view class="shop_sku_box_item_tip" v-if="specifications.item.isPauseSale == 1">
|
||||
<view>售罄</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="shop_bottom">
|
||||
<view class="flex-between">
|
||||
<view class="price">
|
||||
|
|
@ -330,7 +334,11 @@
|
|||
<view class="shop_skuselect flex-start" v-if="selectedSpecsStr">
|
||||
<view class="shop_skuselectname">{{selectedSpecsStr }}</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()">
|
||||
{{skuBtnText}}
|
||||
</view>
|
||||
|
|
@ -556,9 +564,9 @@
|
|||
uni.$u.debounce(navScroll.value = res.scrollTop, 500)
|
||||
uni.$u.debounce(mainScroll(res), 500)
|
||||
if (res.scrollTop >= 44) {
|
||||
store.showSearch = true
|
||||
// store.showSearch = true
|
||||
} else {
|
||||
store.showSearch = false
|
||||
// store.showSearch = false
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -573,7 +581,10 @@
|
|||
type: '',
|
||||
product_id: '',
|
||||
sku_id: '',
|
||||
groupSnap: {}
|
||||
groupSnap: {},
|
||||
item: {
|
||||
groupSnap: []
|
||||
}
|
||||
})
|
||||
// 用于判断接口数据是否加载完成
|
||||
const isDataLoaded = ref(false);
|
||||
|
|
@ -628,35 +639,71 @@
|
|||
};
|
||||
|
||||
// 存储选中的选项
|
||||
const selectedOptions = ref([]);
|
||||
|
||||
// 选择规格的方法
|
||||
const goodsidClick = (option, goodsid) => {
|
||||
if (isOptionSelected(option)) {
|
||||
// 监听 specifications 的变化
|
||||
watch(
|
||||
() => 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);
|
||||
} else if (!isMaxSelected()) {
|
||||
selectedOptions.value[setmenuindex] = selectedOptions.value[setmenuindex].filter(item => item.proId !==
|
||||
option.proId);
|
||||
} else if (!isMaxSelected(setmenuindex)) {
|
||||
// 如果未达到最大选择数量,添加到选中列表
|
||||
selectedOptions.value.push(option);
|
||||
selectedOptions.value[setmenuindex].push(option);
|
||||
}
|
||||
};
|
||||
|
||||
// 判断选项是否已选中
|
||||
const isOptionSelected = (option) => {
|
||||
return selectedOptions.value.some(item => item.proId == option.proId);
|
||||
const isOptionSelected = (setmenuindex, option) => {
|
||||
// 确保 selectedOptions.value[setmenuindex] 存在
|
||||
if (selectedOptions.value[setmenuindex]) {
|
||||
return selectedOptions.value[setmenuindex].some(item => item.proId === option.proId);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
// 判断是否达到最大选择数量
|
||||
const isMaxSelected = () => {
|
||||
// 初始他为可点击
|
||||
if (selectedOptions.value.length >= specifications.groupSnap.number) {
|
||||
canSubmit.value = true;
|
||||
} else {
|
||||
canSubmit.value = false;
|
||||
const isMaxSelected = (setmenuindex) => {
|
||||
// 确保 selectedOptions.value[setmenuindex] 存在
|
||||
if (selectedOptions.value[setmenuindex]) {
|
||||
return selectedOptions.value[setmenuindex].length >= specifications.item.groupSnap[setmenuindex]
|
||||
.number;
|
||||
}
|
||||
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 转换为字符串形式
|
||||
const selectedSpecsStr = computed(() => {
|
||||
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) => {
|
||||
console.log(specifications, matchedProducts.value, selectedOptions.value, '11111')
|
||||
return matchedProducts.value.find((product, index) => {
|
||||
if (data.type == 'package') {
|
||||
if (specifications.type == 'package') {
|
||||
// 套餐
|
||||
let result = [];
|
||||
if (product.type == "package") {
|
||||
JSON.parse(product.cartListinfo.pro_group_info).goods.forEach(item1 => {
|
||||
selectedOptions.value.forEach(item2 => {
|
||||
if (item1.proId === item2.proId && item1.skuId === item2
|
||||
.skuId) {
|
||||
result.push(item1);
|
||||
}
|
||||
});
|
||||
});
|
||||
let result = false;
|
||||
try {
|
||||
if (product.type == "package") {
|
||||
let res = JSON.parse(product.cartListinfo.pro_group_info);
|
||||
result = isArrayEqual(res, selectedGroupSnap.value);
|
||||
}
|
||||
} catch (error) {
|
||||
//TODO handle the exception
|
||||
}
|
||||
|
||||
return result.length > 0 ? result : false;
|
||||
// 直接返回布尔值
|
||||
return result;
|
||||
} else if (specifications.item.type == 'sku') {
|
||||
// 多规格
|
||||
return product.skuId == data.id && product.id == data.productId
|
||||
|
|
@ -704,23 +792,38 @@
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 提交选择并执行下一步操作的方法
|
||||
const submitSelection = async () => {
|
||||
if (shopCartNumber.value > 0 && canSubmit.value) {
|
||||
// 是否是套餐package
|
||||
let res = await matchingProduct(specifications.item.type == "package" ? specifications.item :
|
||||
specifications.item.result)
|
||||
console.log(res)
|
||||
|
||||
if (shopCartNumber.value > 0) {
|
||||
let res = null
|
||||
if (specifications.item.type == "package") {
|
||||
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) {
|
||||
await calculateValue(res.cartNumber, '+', shopCartNumber.value)
|
||||
}
|
||||
// 是否是套餐 有就传
|
||||
if (specifications.item.type == "package") {
|
||||
specifications.groupSnap.goods = selectedOptions.value
|
||||
} else {
|
||||
specifications.groupSnap = null
|
||||
if (specifications.item.type != "package") {
|
||||
selectedGroupSnap.value = []
|
||||
}
|
||||
console.log(specifications.groupSnap, 'specifications.groupSnap.goods')
|
||||
websocketsendMessage({
|
||||
id: res ? res.cartListId : '',
|
||||
type: 'shopping',
|
||||
|
|
@ -731,10 +834,12 @@
|
|||
sku_id: specifications.sku_id,
|
||||
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) :
|
||||
shopCartNumber.value,
|
||||
pro_group_info: specifications.groupSnap,
|
||||
goods_type: specifications.item.type == "package" ? 'package' : ''
|
||||
pro_group_info: selectedGroupSnap.value,
|
||||
goods_type: specifications.item.type == "package" ? 'package' : '',
|
||||
is_print: 1
|
||||
})
|
||||
// 清空有无无清空套餐
|
||||
// 清空套餐选中
|
||||
selectedGroupSnap.value = []
|
||||
showShopsku.value = false
|
||||
}
|
||||
|
||||
|
|
@ -742,6 +847,9 @@
|
|||
|
||||
//获取多规格数据
|
||||
const clickspecifications = async (item, index, indexs, type) => {
|
||||
if (item.isSoldStock == 1 || item.isSaleTime == 0) {
|
||||
return false;
|
||||
}
|
||||
// 数量清零
|
||||
shopCartNumber.value = 0
|
||||
// 初始化
|
||||
|
|
@ -763,7 +871,6 @@
|
|||
selectedOptions.value = []
|
||||
specifications.product_id = res.id
|
||||
specifications.sku_id = item.skuId
|
||||
specifications.groupSnap = res.groupSnap[0]
|
||||
}
|
||||
// 购物车是否有商品
|
||||
specifications.type = res.type
|
||||
|
|
@ -779,13 +886,6 @@
|
|||
const singleclick = async (item, i) => {
|
||||
// 判断购物车是否有该选中商品
|
||||
let res = await matchingProduct(item)
|
||||
// 是否是套餐 有就传
|
||||
console.log(specifications, '单规格')
|
||||
if (specifications.item.type == "package") {
|
||||
specifications.groupSnap.goods = selectedOptions.value
|
||||
} else {
|
||||
specifications.groupSnap = null
|
||||
}
|
||||
websocketsendMessage({
|
||||
id: res ? item.cartListId : '',
|
||||
type: 'shopping',
|
||||
|
|
@ -794,10 +894,8 @@
|
|||
operate_type: await calculateValue(item.cartNumber, i) == 'del' ? 'del' : res ? 'edit' : 'add',
|
||||
product_id: item.id,
|
||||
sku_id: item.skuId,
|
||||
number: await calculateValue(item.cartNumber, i)
|
||||
// pro_group_info: specifications.groupSnap,
|
||||
// goods_type: specifications.item.type == "package" ? 'package' : ''
|
||||
// pro_group_info: specifications.groupSnap
|
||||
number: await calculateValue(item.cartNumber, i),
|
||||
is_print: 1
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -900,30 +998,30 @@
|
|||
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
|
||||
}
|
||||
|
||||
// 清空购物车
|
||||
if (Message.operate_type == 'shopping_cleanup') {
|
||||
if (Message.operate_type == 'cleanup') {
|
||||
cartList.value = []
|
||||
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);
|
||||
}
|
||||
|
||||
// 添加或者减少购物后返回
|
||||
if (Message.operate_type == 'shopping_add' || Message.operate_type == 'sopping_edit' || Message
|
||||
.type == 'bc') {
|
||||
if (Message.operate_type == 'add' || Message.operate_type == 'edit') {
|
||||
[Message.data].forEach((objA) => {
|
||||
const index = cartList.value.findIndex((objB) => objB.id == objA.id);
|
||||
if (index !== -1) {
|
||||
|
|
@ -935,8 +1033,8 @@
|
|||
}
|
||||
|
||||
// 购物车数据更新从新请求
|
||||
if (Message.type == 'product') {
|
||||
cartList.value = []
|
||||
if (Message.type == 'product' && Message.data_type == 'product_update' && Message
|
||||
.operate_type == 'product_update') {
|
||||
isDataLoaded.value = false;
|
||||
productqueryProduct()
|
||||
}
|
||||
|
|
@ -947,12 +1045,6 @@
|
|||
msg_id: Message.msg_id
|
||||
})
|
||||
|
||||
// 检查消息是否已经处理过
|
||||
if (processedMessageIds.has(Message.msg_id)) {
|
||||
return;
|
||||
}
|
||||
processedMessageIds.add(Message.msg_id);
|
||||
|
||||
// 初始化商品数量
|
||||
await updateProductQuantities()
|
||||
|
||||
|
|
@ -975,7 +1067,7 @@
|
|||
Specialstop = shopProductList.productInfo
|
||||
//TODO handle the exception
|
||||
}
|
||||
return cartList.value.map((cartItem) => {
|
||||
return cartList.value.flatMap((cartItem) => {
|
||||
for (const group of Specialstop) {
|
||||
for (const product of group.productList) {
|
||||
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
|
||||
return null;
|
||||
}).filter(item => item !== null);
|
||||
|
|
@ -1111,27 +1256,33 @@
|
|||
shopProductList.hots = await productminiApphotsquery()
|
||||
shopProductList.productInfo = await APIgroupquery()
|
||||
} catch (error) {}
|
||||
|
||||
// 如果商品报错就返回上一页
|
||||
if (!shopProductList.productInfo || !shopProductList.hots) {
|
||||
uni.navigateBack()
|
||||
if (shopProductList.productInfo.length > 0 || shopProductList.hots.length > 0) {
|
||||
//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;
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '错误二维码'
|
||||
});
|
||||
isDataLoaded.value = false;
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1000)
|
||||
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;
|
||||
|
||||
// #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
|
||||
// // #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
|
||||
|
||||
await productqueryProduct()
|
||||
setTimeout(() => {
|
||||
|
|
@ -1732,21 +1883,16 @@
|
|||
position: relative;
|
||||
border-radius: 20rpx;
|
||||
background: #fff;
|
||||
overflow-y: auto;
|
||||
padding-bottom: 320rpx;
|
||||
box-sizing: border-box;
|
||||
padding-bottom: 250rpx;
|
||||
|
||||
.positionabsolute {
|
||||
position: absolute;
|
||||
top: 30rpx;
|
||||
z-index: 999;
|
||||
right: 30rpx;
|
||||
}
|
||||
|
||||
.shop_skucimage {
|
||||
width: 100%;
|
||||
height: 500rpx !important;
|
||||
border-radius: 20rpx 20rpx 0 0;
|
||||
}
|
||||
|
||||
.shop_sku_name {
|
||||
padding: 0 28rpx;
|
||||
|
|
@ -1776,7 +1922,7 @@
|
|||
|
||||
|
||||
.shop_sku_box {
|
||||
padding: 0 28rpx;
|
||||
padding: 20rpx 28rpx;
|
||||
|
||||
.shop_sku_box_name {
|
||||
margin-top: 20rpx;
|
||||
|
|
@ -1800,7 +1946,6 @@
|
|||
.shop_sku_box_item_tip {
|
||||
width: 62rpx;
|
||||
height: 47rpx;
|
||||
// background-color: #CECECE;
|
||||
text-align: right;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
<view class="containertopboxitemleft_one"
|
||||
:class="fromInfo.status != 0?'':'containertopboxitemleft_ones'">
|
||||
<block v-if="item.type == 2">
|
||||
<text>{{item.num || 0}}</text>
|
||||
<text>1</text>
|
||||
<text style="font-size: 28rpx;margin-left: 6rpx;">张</text>
|
||||
</block>
|
||||
<block v-else>
|
||||
|
|
|
|||
|
|
@ -181,9 +181,8 @@
|
|||
url: uni.conf.baseUrl + '/account/user/common/upload',
|
||||
filePath: avatarUrl,
|
||||
header: {
|
||||
environment: 'app',
|
||||
type: 'android',
|
||||
version: '1.7.3',
|
||||
shopId: uni.cache.get('shopId'),
|
||||
token: uni.cache.get('token') || '',
|
||||
'content-type': 'multipart/form-data'
|
||||
},
|
||||
fileType: 'image',
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@
|
|||
<view class="gift_list">
|
||||
<view class="gift_list_item" v-for="(item,index) in infoForn.couponList" :key="index">
|
||||
<text class="icon"></text>
|
||||
<text class="text"> {{ item.title }} </text>
|
||||
<text class="text"> {{ item.title }} * {{ item.number}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
|
|
|||
|
|
@ -29,17 +29,17 @@
|
|||
<view class="card_cen">
|
||||
<view class="card_cen_left">{{ shopUserInfo.shopInfo.isVip == 0 ? '尚未开通会员暂无法享受会员权益' : '欢迎加入本店会员~'}}
|
||||
</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 class="card_bom" v-if="shopUserInfo.shopInfo.isVip != 0">
|
||||
<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 class="card_bom_item" @click="itemClick(2)">
|
||||
<text>{{shopUserInfo.shopInfo.accountPoints || '0'}}</text><text>积分</text>
|
||||
<text>{{shopUserInfo.accountPoints || '0'}}</text><text>积分</text>
|
||||
</view>
|
||||
<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 class="card_bom_item">
|
||||
<text>0</text><text>权益卡</text>
|
||||
|
|
@ -159,6 +159,7 @@
|
|||
let res = await APIshopUserInfo({
|
||||
shopId: shopUserInfo.shopId
|
||||
})
|
||||
Object.assign(shopUserInfo, res);
|
||||
uni.cache.set('orderVIP', res)
|
||||
uni.cache.set('ordershopUserInfo', res.shopInfo)
|
||||
form.memberOpen = res.isVip == 1 ? false : true
|
||||
|
|
@ -188,7 +189,6 @@
|
|||
// 根据传的shopInfo来返回上面的值
|
||||
// shopUserInfo.shopExtend = res.shopExtend.member_bg
|
||||
asyncshopUserInfo()
|
||||
console.log(shopUserInfo.shopId)
|
||||
}
|
||||
|
||||
})
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
|
||||
const formInfo = reactive({
|
||||
shopInfo: '',
|
||||
shopInfo:uni.cache.get('orderVIP'),
|
||||
url: '',
|
||||
shopId: ''
|
||||
})
|
||||
|
|
@ -51,47 +51,46 @@
|
|||
const currentPage = pages[pages.length - 1];
|
||||
// 获取页面参数
|
||||
const pageParams = currentPage.options;
|
||||
formInfo.shopInfo = JSON.parse(decodeURIComponent(pageParams.shopInfo))
|
||||
// formInfo.shopInfo = JSON.parse(decodeURIComponent(pageParams.shopInfo))
|
||||
formInfo.shopId = pageParams.shopId
|
||||
let res = await APIshopUsercode({
|
||||
shopId: pageParams.shopId
|
||||
})
|
||||
console.log(formInfo.shopInfo)
|
||||
if (res) {
|
||||
formInfo.url = res;
|
||||
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);
|
||||
// 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'
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
// 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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
<template>
|
||||
<view class="Box">
|
||||
<view class="box_box">
|
||||
<view class="box_item flex-between">
|
||||
<!-- <view class="box_item flex-between">
|
||||
<text class="top_box_one_text">当前账号</text>
|
||||
<input type="number" v-model="form.mobile" placeholder="请输入手机号" maxlength="11" disabled="disabled" />
|
||||
<button v-if="!form.mobile" class="getPhone" open-type="getPhoneNumber" @getphonenumber="getPhone">
|
||||
<view class="text">获取手机号</view>
|
||||
</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 class="box_item flex-between" style="position:relative;">
|
||||
|
|
@ -45,13 +49,25 @@
|
|||
onMounted
|
||||
} 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({
|
||||
shopInfo: "",
|
||||
shopInfo: uni.cache.get('orderVIP'),
|
||||
shopId: ''
|
||||
})
|
||||
|
||||
const form = reactive({
|
||||
mobile: '',
|
||||
mobile: uni.cache.get('orderVIP').phone,
|
||||
password: '',
|
||||
payPassword: '',
|
||||
checkCode: ''
|
||||
|
|
@ -65,11 +81,10 @@
|
|||
second: 60,
|
||||
showText: true,
|
||||
Recapture: '获取验证码',
|
||||
shopUserInfo: null,
|
||||
})
|
||||
|
||||
const CodeRegister = async () => {
|
||||
const res = await this.api.phoneValidateCode({
|
||||
const res = await APIusercode({
|
||||
// post 手机验证码
|
||||
phone: form.mobile
|
||||
});
|
||||
|
|
@ -167,30 +182,15 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
let res = await this.api.loginresetPwd({
|
||||
vipId: this.shopUserInfo.id,
|
||||
pwd: this.form.password,
|
||||
code: this.form.checkCode
|
||||
let res = await APIuserpwd({
|
||||
checkPayPwd: form.payPassword,
|
||||
payPwd: form.password,
|
||||
code: form.checkCode
|
||||
})
|
||||
|
||||
if (res.code == 0) {
|
||||
if (datalist.isPwd != 0) {
|
||||
uni.showToast({
|
||||
title: '修改成功',
|
||||
icon: 'none'
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '设置成功',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
// 获取用户信息
|
||||
this.loginwxuserInfo()
|
||||
uni.navigateBack();
|
||||
}, 1000);
|
||||
// * 获取会员信息
|
||||
await storeuser.actionsproductqueryProduct()
|
||||
if (res) {
|
||||
uni.navigateBack()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -201,8 +201,16 @@
|
|||
const currentPage = pages[pages.length - 1];
|
||||
// 获取页面参数
|
||||
const options = currentPage.options;
|
||||
shopUserInfo.shopInfo = JSON.parse(decodeURIComponent(options.shopInfo))
|
||||
console.log(shopUserInfo)
|
||||
// if (options.shopId) {
|
||||
// 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>
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
</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_assets_list">
|
||||
<view class="my_list_item">
|
||||
|
|
@ -32,14 +32,14 @@
|
|||
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/points.png">
|
||||
</image>
|
||||
<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 class="my_list_item">
|
||||
<image class="my_list_item_icon"
|
||||
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/coupon.png">
|
||||
</image>
|
||||
<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>
|
||||
|
|
@ -107,7 +107,7 @@
|
|||
const teblist = ref([])
|
||||
const shopExtend = ref(null)
|
||||
const userInfo = reactive({})
|
||||
|
||||
|
||||
const ShopId = ref(uni.cache.get('shopId'))
|
||||
|
||||
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) => {
|
||||
let shopId = null;
|
||||
switch (item.type) {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@ export const useCartStore = defineStore('cart', () => {
|
|||
if (uni.cache.get('orderVIP').isVip == 1 && uni.cache.get('ordershopUserInfo')
|
||||
.isMemberPrice == 1) {
|
||||
// memberPrice会员价
|
||||
return total + (parseFloat(item.memberPrice) * parseFloat(item.num - item.returnNum));
|
||||
return total + (parseFloat(item.memberPrice) * parseFloat(item.num - item
|
||||
.returnNum));
|
||||
} else {
|
||||
// salePrice销售价
|
||||
return total + (parseFloat(item.price) * parseFloat(item.num - item.returnNum));
|
||||
|
|
@ -94,9 +95,13 @@ export const useCartStore = defineStore('cart', () => {
|
|||
// 计算购物车总打包费用(向下取整并保留两位小数)
|
||||
const getTotalPackFee = (cartList) => computed(() => {
|
||||
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);
|
||||
return Math.floor(total * 100) / 100;
|
||||
// 向下取整并保留两位小数
|
||||
let result = roundUpToTwoDecimals(total, 'downward')
|
||||
return result;
|
||||
// return Math.floor(total * 100) / 100;
|
||||
});
|
||||
|
||||
return {
|
||||
|
|
|
|||
Loading…
Reference in New Issue