This commit is contained in:
mkm 2024-08-19 18:29:46 +08:00
parent 6b68c8f916
commit d4e222e0b6
4 changed files with 175 additions and 210 deletions

View File

@ -3,9 +3,9 @@ let WSS_URL
import store from "@/store/user.js" import store from "@/store/user.js"
// 环境 // 环境
// let env = "dev" // let env = "dev"
// let env = "prod" let env = "prod"
// let env = "release"; // let env = "release";
let env = "local"; // let env = "local";
switch (env) { switch (env) {
case 'dev': case 'dev':

View File

@ -244,7 +244,7 @@
const cartList = ref([]); const cartList = ref([]);
const cartInfo = ref({}); const cartInfo = ref({});
const getcartList = (check = true) => { const getcartList = (check = true) => {
cartListApi().then(res => { cartListApi({store_id:STORE_INFO.id}).then(res => {
if (check) { if (check) {
res.data.lists = res.data.lists.map(item => { res.data.lists = res.data.lists.map(item => {
item.check = true; item.check = true;

View File

@ -23,21 +23,16 @@
<template #left> <template #left>
<view class="store-info"> <view class="store-info">
<view style="display: flex;font-size: 30rpx;font-weight: bold;"> <view style="display: flex;font-size: 30rpx;font-weight: bold;">
<!-- <text v-if=" vipList.includes(userStore.userInfo.user_ship) || shareInfo.store_id"
style="max-width: 400rpx;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">
<text v-if="vipList.includes(userStore.userInfo.user_ship)">
{{ (userStore.userInfo.real_name || userStore.userInfo.nickname) + '的个人门店' }}</text>
<text v-else>
{{(shareInfo.real_name || (userStore.userInfo.real_name || userStore.userInfo.nickname)) + '的供销店' }}</text>
</text> -->
<text v-if="shareInfo.uid" <text v-if="shareInfo.uid"
style="max-width: 400rpx;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"> style="max-width: 400rpx;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">
{{shareInfo.real_name}} {{shareInfo.real_name}}
</text> </text>
<text v-else <text v-else
style="max-width: 400rpx;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">{{ style="max-width: 400rpx;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"
@click="navgo('/multipleShop/index/index?event=store_info')">{{
STORE_INFO.store_name }}</text> STORE_INFO.store_name }}</text>
<up-icon name="arrow-right"></up-icon> <up-icon name="arrow-right" label="切换" labelSize="10px"
@click="navgo('/multipleShop/index/index?event=store_info')"></up-icon>
</view> </view>
</view> </view>
</template> </template>
@ -258,6 +253,20 @@
</view> </view>
</view> </view>
</u-overlay> </u-overlay>
<up-popup :show="LocationShow" mode="bottom" @open="LocationShowOpen()">
<view style="margin: 40rpx 10rpx;">
<up-row customStyle="margin-bottom: 10px" gutter="10">
<up-col span="6">
<up-button text="取消" @click="userLocationfalse()"></up-button>
</up-col>
<up-col span="6">
<up-button type="primary" text="设置授权" color="#20B128" @click="opensettings()"></up-button>
</up-col>
</up-row>
</view>
</up-popup>
</view> </view>
</template> </template>
@ -298,6 +307,11 @@
} from "@/api/multipleShop.js"; } from "@/api/multipleShop.js";
import useUserStore from "@/store/user"; import useUserStore from "@/store/user";
//
let location = {
lat: '',
long: "",
};
const vipList = reactive([1, 2, 3, 4, 5, 6, 7, 8]) const vipList = reactive([1, 2, 3, 4, 5, 6, 7, 8])
const userStore = useUserStore(); const userStore = useUserStore();
const STORE_INFO = reactive({ const STORE_INFO = reactive({
@ -310,6 +324,28 @@
price: "" price: ""
}) })
const showModal = ref(false)
const navgo = (url) => {
showModal.value &&= false
uni.navigateTo({
url
})
}
const LocationShow = ref(false)
uni.$on('store_info', function(data) {
let datas = JSON.parse(data)
if (datas) {
datas.store_name = datas.name
uni.setStorageSync("STORE_INFO", JSON.stringify(datas));
STORE_INFO.id = datas.id
STORE_INFO.store_name = datas.name
shareInfo.value.real_name = datas.name
shareInfo.value.store_id = datas.id
}
getgoodClassList(0)
getGoodList()
})
const getStoreInfoFn = () => { const getStoreInfoFn = () => {
if (uni.getStorageSync('STORE_INFO').length) { if (uni.getStorageSync('STORE_INFO').length) {
let data = JSON.parse(uni.getStorageSync('STORE_INFO')) let data = JSON.parse(uni.getStorageSync('STORE_INFO'))
@ -322,11 +358,13 @@
let data = res.data; let data = res.data;
for (let key in data) { for (let key in data) {
STORE_INFO[key] = data[key] STORE_INFO[key] = data[key]
} }
}) })
} }
getgoodClassList(0); getgoodClassList(0);
getGoodList(); getGoodList();
getCartList();
} }
@ -673,6 +711,7 @@
cartListApi({ cartListApi({
page_no: 1, page_no: 1,
page_size: 100, page_size: 100,
store_id: STORE_INFO.id,
}).then(res => { }).then(res => {
cartInfo.value = { cartInfo.value = {
total_price: res.data?.extend?.total_price || '0.00', total_price: res.data?.extend?.total_price || '0.00',
@ -729,8 +768,7 @@
} else { } else {
uni.removeStorageSync('SHARE_INFO') uni.removeStorageSync('SHARE_INFO')
} }
getLocation()
getStoreInfoFn()
// #ifndef H5 // #ifndef H5
// //
@ -739,6 +777,9 @@
}) })
onShow(() => { onShow(() => {
if(STORE_INFO.id){
getCartList();
}
// //
if (userStore.token && userStore.userInfo.mobile) { if (userStore.token && userStore.userInfo.mobile) {
userInfoApi().then(res => { userInfoApi().then(res => {
@ -752,14 +793,110 @@
uni.reLaunch({ uni.reLaunch({
url: "/multipleShop/verificationOrder/index" url: "/multipleShop/verificationOrder/index"
}) })
} else {
getCartList();
} }
}); });
} }
}); });
//
const getLocation = () => {
// #ifdef MP-WEIXIN
uni.getSetting({
success(res) {
if (res.authSetting["scope.userLocation"] == false) {
LocationShowOpen()
} else {
opensettings(true)
}
}
})
// #endif
// #ifdef H5
userLocationfalse()
// #endif
}
const LocationShowOpen = () => {
LocationShow.value = true;
}
//
const opensettings = (a = false) => {
if (a == false) {
uni.openSetting({
success(res) {
LocationShow.value = false;
if (res.authSetting["scope.userLocation"] == true) {
uni.authorize({
scope: 'scope.userLocation',
success() {
uni.getLocation({
type: "gcj02",
success(res) {
location.lat = res.latitude;
location.long = res.longitude;
uni.setStorageSync('location', JSON.stringify(
location))
getStoreInfo(location).then(res => {
STORE_INFO.id = res.data.id
STORE_INFO.store_name = res.data.store_name
getgoodClassList(0)
getGoodList()
getCartList();
uni.setStorageSync('STORE_INFO', JSON.stringify(STORE_INFO))
})
},
})
},
fail(e) {
userLocationfalse()
},
})
}
},
fail(e) {
userLocationfalse()
}
});
} else {
uni.authorize({
scope: 'scope.userLocation',
success() {
uni.getLocation({
type: "gcj02",
success(res) {
location.lat = res.latitude;
location.long = res.longitude;
uni.setStorageSync('location', JSON.stringify(location))
getStoreInfo(location).then(res => {
STORE_INFO.id = res.data.id
STORE_INFO.store_name = res.data.store_name
getgoodClassList(0)
getGoodList()
getCartList();
uni.setStorageSync('STORE_INFO', JSON.stringify(STORE_INFO))
})
},
})
},
fail(e) {
userLocationfalse()
},
})
}
}
//
const userLocationfalse = () => {
LocationShow.value = false;
uni.$u.toast('获取位置失败,为你展示默认门店')
getStoreInfoFn()
}
let instance; // let instance; //
const getWXDom = () => { const getWXDom = () => {
let query = uni.createSelectorQuery().in(instance).select("#drag_area"); let query = uni.createSelectorQuery().in(instance).select("#drag_area");

View File

@ -1,87 +1,29 @@
<template> <template>
<view class=""> <view class="">
<!-- <view class="m-card m-address"> --> <view class="m-card good-info">
<!-- <view class="address-info" @click="showAddress = true"> <view class="head-title">商品明细</view>
<view class="top">
<up-icon name="account"></up-icon>
<view class="t-name">{{ addressInfo.real_name }}</view>
<view>{{ addressInfo.phone }}</view>
</view>
<view class="bottom u-line-2">
{{ addressInfo.detail }}
</view>
</view> -->
<!-- <view class="address-info">
<view class="top">
{{ STORE_INFO.name }}是的
</view>
<view class="bottom u-line-2">
{{ STORE_INFO.detailed_address }}
</view>
</view> -->
<!-- <view class="address-btn item-center">
<view class='ship-type' style="">
<view class="ship-type-item" :class='{ actShipItem: orderInfo.shipping_type == 2 }'
@click='orderInfo.shipping_type = 2'>
自提
</view>
<view class="ship-type-item" @click='orderInfo.shipping_type = 1'
:class='{ actShipItem: orderInfo.shipping_type == 1 }' v-if='orderInfo.default_delivery == 1'>
配送
</view>
</view>
</view> -->
<view class="m-card m-address" style="margin-top: 20rpx;"> <view class="m-good" v-for="(item, index) in cartList" :key="index">
<view class="address-info" <view class="image">
style='display: flex;justify-content: space-between;width: 690rpx;align-items: center;'> <up-image width="160rpx" height="160rpx" :src="item.imgs"></up-image>
<view class="top" style="align-items: flex-start;"> </view>
<view style="color: #333;width: 200rpx;"> <view class="body-content">
<view style="margin: 0 10rpx;color:#20B128;width: 150rpx;">推荐自提点</view>
<view class="isreser"> {{reservation?"次日可提":"当日可提" }}
</view>
</view>
<view> <view>
<view style="color: #333;"> <view class="title">
{{shop_Info.name}} <view>{{ item.name }}</view>
<view>¥{{ item.price }}</view>
</view> </view>
<view style="font-size: 24rpx;color: #333;margin: 10rpx 0;"> <view class="tips">
{{shop_Info.detailed_address}} <view>{{ item.unit_name }}</view>
</view> <view>x{{ item.cart_num }}</view>
<view>
<view>
<text>{{shop_Info.phone}}</text>
</view>
</view> </view>
</view> </view>
<view class="time">
{{ orderInfo.delivery_msg }}
</view>
</view> </view>
<view style="padding: 20rpx;background-color:#20B128;color: white;border-radius: 40rpx;flex-shrink: 0;"
@click="navgo(`/multipleShop/index/index?event=settle&cart_id=${cartStore.cartList.join(',')}`)">
切换门店
</view> </view>
</view>
</view>
<!-- </view> -->
<view class="m-card m-good" v-for="(item, index) in cartList" :key="index">
<view class="image">
<up-image width="160rpx" height="160rpx" :src="item.imgs"></up-image>
</view>
<view class="body-content">
<view>
<view class="title">
<view>{{ item.name }}</view>
<view>¥{{ item.price }}</view>
</view>
<view class="tips">
<view>{{ item.unit_name }}</view>
<view>x{{ item.cart_num }}</view>
</view>
</view>
<view class="time">
{{ orderInfo.delivery_msg }}
</view>
</view>
</view> </view>
<view class="m-card good-info"> <view class="m-card good-info">
@ -118,6 +60,7 @@
</view> </view>
</view> </view>
<up-alert v-if="timeContent!=''" type = "error" :description = "timeContent"></up-alert> <up-alert v-if="timeContent!=''" type = "error" :description = "timeContent"></up-alert>
<up-notice-bar text= "门店切换已移动到首页,若切换店铺,购物车商品将跟随门店一起切换"></up-notice-bar>
</view> </view>
@ -222,20 +165,6 @@
<up-modal :show="showModal" title="您还没设置密码" :closeOnClickOverlay="true" zoom confirmText='去设置' showCancelButton <up-modal :show="showModal" title="您还没设置密码" :closeOnClickOverlay="true" zoom confirmText='去设置' showCancelButton
@close='showModal=false' @cancel='showModal=false' @confirm="navgo('/pagesOrder/setPayPassword/index')" @close='showModal=false' @cancel='showModal=false' @confirm="navgo('/pagesOrder/setPayPassword/index')"
confirmColor='#27B52F' cancelText='取消'></up-modal> confirmColor='#27B52F' cancelText='取消'></up-modal>
<up-popup :show="LocationShow" mode="bottom" @open="LocationShowOpen()">
<view style="margin: 40rpx 10rpx;">
<up-row customStyle="margin-bottom: 10px" gutter="10">
<up-col span="6">
<up-button text="取消" @click="userLocationfalse()"></up-button>
</up-col>
<up-col span="6">
<up-button type="primary" text="设置授权" color="#20B128" @click="opensettings()"></up-button>
</up-col>
</up-row>
</view>
</up-popup>
</view> </view>
</template> </template>
@ -274,6 +203,8 @@
let STORE_INFO = uni.getStorageSync('STORE_INFO'); let STORE_INFO = uni.getStorageSync('STORE_INFO');
if (STORE_INFO) { if (STORE_INFO) {
shop_Info.value = JSON.parse(STORE_INFO) shop_Info.value = JSON.parse(STORE_INFO)
}else{
uni.$u.toast('获取门店信息失败,请在首页选择门店')
} }
const cartStore = useCartStore(); const cartStore = useCartStore();
@ -439,24 +370,6 @@
}) })
} }
uni.$on('settle', function(data) {
let datas = JSON.parse(data)
shop_Info.value = datas
console.log(datas)
checkInventoryApi({
cart_id: cartStore.cartList,
store_id: datas.id
}).then(res => {
reservation.value = res.data.reservation
})
checkOrder(datas.id)
// formData.store_id = datas.id
// formData.store_name = datas.name
})
// const checkOrderA // const checkOrderA
const pay_type = ref('7'); const pay_type = ref('7');
@ -574,95 +487,10 @@
} }
onLoad(options => { onLoad(options => {
// if (uni.getStorageSync('location')) { checkOrder(shop_Info.value.id);
// try {
// location = JSON.parse(uni.getStorageSync('location'))
// checkOrder();
// } catch (e) {
// getLocation()
// }
// } else {
getLocation()
// }
}) })
const getLocation = () => {
// #ifdef H5
userLocationfalse()
// #endif
// #ifdef MP-WEIXIN
uni.getSetting({
success(res) {
if (res.authSetting["scope.userLocation"] == false) {
LocationShowOpen()
} else {
opensettings(true)
}
}
})
// #endif
}
const LocationShowOpen = () => {
LocationShow.value = true;
}
const userLocationfalse = () => {
LocationShow.value = false;
uni.$u.toast('获取位置当前失败,为你推荐当前门店')
checkOrder(shop_Info.value.id);
}
const opensettings = (a = false) => {
if (a == false) {
uni.openSetting({
success(res) {
LocationShow.value = false;
if (res.authSetting["scope.userLocation"] == true) {
uni.authorize({
scope: 'scope.userLocation',
success() {
uni.getLocation({
type: "gcj02",
success(res) {
location.lat = res.latitude;
location.long = res.longitude;
uni.setStorageSync('location', JSON.stringify(
location))
checkOrder();
},
})
},
fail(e) {
userLocationfalse()
},
})
}
},
fail(e) {
userLocationfalse()
}
});
} else {
uni.authorize({
scope: 'scope.userLocation',
success() {
uni.getLocation({
type: "gcj02",
success(res) {
location.lat = res.latitude;
location.long = res.longitude;
uni.setStorageSync('location', JSON.stringify(location))
checkOrder();
},
})
},
fail(e) {
userLocationfalse()
},
})
}
}
onShow(() => { onShow(() => {
getAddressList(); getAddressList();
}) })