feat: 修改配置文件和页面逻辑,优化门店信息获取功能

This commit is contained in:
mkm 2024-08-19 22:44:31 +08:00
parent d4e222e0b6
commit e665c4ced7
2 changed files with 36 additions and 28 deletions

View File

@ -2,8 +2,8 @@ let BASE_URL
let WSS_URL 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";

View File

@ -24,7 +24,7 @@
<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="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;" @click="navgo('/multipleShop/index/index?event=store_info')">
{{shareInfo.real_name}} {{shareInfo.real_name}}
</text> </text>
<text v-else <text v-else
@ -316,7 +316,8 @@
const userStore = useUserStore(); const userStore = useUserStore();
const STORE_INFO = reactive({ const STORE_INFO = reactive({
id: '', id: '',
store_name: "" store_name: "",
abbreviation: ''
}) })
const priceKey = reactive({ const priceKey = reactive({
off_activity: "", off_activity: "",
@ -340,6 +341,7 @@
uni.setStorageSync("STORE_INFO", JSON.stringify(datas)); uni.setStorageSync("STORE_INFO", JSON.stringify(datas));
STORE_INFO.id = datas.id STORE_INFO.id = datas.id
STORE_INFO.store_name = datas.name STORE_INFO.store_name = datas.name
STORE_INFO.abbreviation = datas.abbreviation
shareInfo.value.real_name = datas.name shareInfo.value.real_name = datas.name
shareInfo.value.store_id = datas.id shareInfo.value.store_id = datas.id
} }
@ -358,13 +360,10 @@
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); getAll()
getGoodList();
getCartList();
} }
@ -374,6 +373,8 @@
if (vipList.includes(userStore.userInfo.user_ship)) { if (vipList.includes(userStore.userInfo.user_ship)) {
shareStr = shareStr + '&spread_uid=' + userStore.userInfo.id + '&real_name=' + (userStore.userInfo shareStr = shareStr + '&spread_uid=' + userStore.userInfo.id + '&real_name=' + (userStore.userInfo
.share_name) .share_name)
} else {
shareStr = shareStr + '&real_name=' + STORE_INFO.abbreviation
} }
let shareInfo = { let shareInfo = {
// title: (userStore.userInfo.real_name || userStore.userInfo.nickname) + '', // title: (userStore.userInfo.real_name || userStore.userInfo.nickname) + '',
@ -747,17 +748,17 @@
onLoad(async (opt) => { onLoad(async (opt) => {
console.log('opt', opt) console.log('opt', opt)
if (opt.id) {
where.value.store_id = (opt.id == 'undefined' ? STORE_INFO.id : opt.id);
} else {
where.value.store_id = STORE_INFO.id
}
// id // id
if (opt.id && opt.id != 'undefined') { if (opt.id && opt.id != 'undefined') {
where.value.store_id = opt.id; STORE_INFO.id = opt.id
const info = await shopDetailApi({ STORE_INFO.store_name = opt.real_name
store_id: where.value.store_id if (opt.real_name == '' || opt.real_name == undefined) {
}); shopDetailApi({
store_id: opt.id
}).then(res => {
STORE_INFO.store_name=res.data.name
})
}
// //
if (opt.spread_uid) { if (opt.spread_uid) {
shareInfo.value.uid = opt.spread_uid; shareInfo.value.uid = opt.spread_uid;
@ -765,10 +766,11 @@
shareInfo.value.store_id = opt.id; shareInfo.value.store_id = opt.id;
uni.setStorageSync('SHARE_INFO', shareInfo.value); uni.setStorageSync('SHARE_INFO', shareInfo.value);
} }
getAll()
} else { } else {
uni.removeStorageSync('SHARE_INFO') uni.removeStorageSync('SHARE_INFO')
getLocation()
} }
getLocation()
// #ifndef H5 // #ifndef H5
// //
@ -777,12 +779,12 @@
}) })
onShow(() => { onShow(() => {
if(STORE_INFO.id){ if (STORE_INFO.id) {
getCartList(); getCartList();
} }
// //
if (userStore.token && userStore.userInfo.mobile) { if (userStore.token && userStore.userInfo.mobile) {
userInfoApi().then(res => { userInfoApi({store_id:STORE_INFO.id}).then(res => {
const user = res.data; const user = res.data;
userStore.setUserInfo(user); userStore.setUserInfo(user);
if (!user.openid) loginUpdateUserApi({ if (!user.openid) loginUpdateUserApi({
@ -820,6 +822,11 @@
const LocationShowOpen = () => { const LocationShowOpen = () => {
LocationShow.value = true; LocationShow.value = true;
} }
const getAll = () => {
getgoodClassList(0)
getGoodList()
getCartList();
}
// //
const opensettings = (a = false) => { const opensettings = (a = false) => {
@ -841,10 +848,11 @@
getStoreInfo(location).then(res => { getStoreInfo(location).then(res => {
STORE_INFO.id = res.data.id STORE_INFO.id = res.data.id
STORE_INFO.store_name = res.data.store_name STORE_INFO.store_name = res.data.store_name
getgoodClassList(0) STORE_INFO.abbreviation = res.data
getGoodList() .abbreviation
getCartList(); getAll()
uni.setStorageSync('STORE_INFO', JSON.stringify(STORE_INFO)) uni.setStorageSync('STORE_INFO', JSON
.stringify(STORE_INFO))
}) })
}, },
@ -873,9 +881,9 @@
getStoreInfo(location).then(res => { getStoreInfo(location).then(res => {
STORE_INFO.id = res.data.id STORE_INFO.id = res.data.id
STORE_INFO.store_name = res.data.store_name STORE_INFO.store_name = res.data.store_name
getgoodClassList(0) STORE_INFO.abbreviation = res.data.abbreviation
getGoodList()
getCartList(); getAll()
uni.setStorageSync('STORE_INFO', JSON.stringify(STORE_INFO)) uni.setStorageSync('STORE_INFO', JSON.stringify(STORE_INFO))
}) })