This commit is contained in:
zmj 2024-06-18 11:41:31 +08:00
parent abc37a23b7
commit a4ac3c2af9
1 changed files with 24 additions and 29 deletions

View File

@ -209,7 +209,8 @@
} from "@/api/cart.js"; } from "@/api/cart.js";
import { import {
productLogApi, productLogApi,
userInfoApi userInfoApi,
getStoreInfo
} from "@/api/user.js"; } from "@/api/user.js";
import viewPopup from "@/components/viewPopup.vue" import viewPopup from "@/components/viewPopup.vue"
import goodPopup from "@/components/goodPopup.vue" import goodPopup from "@/components/goodPopup.vue"
@ -225,19 +226,26 @@
const userStore = useUserStore(); const userStore = useUserStore();
const STORE_INFO = reactive({}) const STORE_INFO = reactive({})
const getStoreInfo = () => { const getStoreInfoFn = () => {
if (uni.getStorageSync('STORE_INFO')) { if (uni.getStorageSync('STORE_INFO').length) {
let data = JSON.parse(uni.getStorageSync('STORE_INFO')) let data = JSON.parse(uni.getStorageSync('STORE_INFO'))
for (let key in data) { for (let key in data) {
STORE_INFO[key] = data[key] STORE_INFO[key] = data[key]
} }
} else {
getStoreInfo().then(res => {
uni.setStorageSync("STORE_INFO", JSON.stringify(res.data))
})
} }
} }
getStoreInfo() getStoreInfoFn()
// //
onShareAppMessage(() => { onShareAppMessage(() => {
let shareStr = '?id=' + STORE_INFO.id; let shareStr = '?id=' + STORE_INFO.id;
if (userStore.userInfo.user_ship == 1) { if (userStore.userInfo.user_ship == 1) {
shareStr = shareStr + '&spread_uid=' + userStore.userInfo.id + '&real_name=' + (userStore.userInfo shareStr = shareStr + '&spread_uid=' + userStore.userInfo.id + '&real_name=' + (userStore.userInfo
@ -308,7 +316,7 @@
cart_num: cart_num, cart_num: cart_num,
is_new: 0, // 01 is_new: 0, // 01
// goods_id: id, // goods_id: id,
store_id: STORE_INFO.value.id || 5, store_id: STORE_INFO.id,
product_id: product_id product_id: product_id
}).then(res => { }).then(res => {
getCartList(); getCartList();
@ -336,7 +344,7 @@
name: '', name: '',
order: '', order: '',
store_name: '', store_name: '',
store_id: STORE_INFO.value.id || '5' store_id: STORE_INFO.id
}) })
const loading = ref(true); const loading = ref(true);
@ -361,16 +369,15 @@
if (loadmore) goodList.value.push(...res.data.lists); if (loadmore) goodList.value.push(...res.data.lists);
else goodList.value = res.data.lists; else goodList.value = res.data.lists;
// //
if (!STORE_INFO.value.name || !STORE_INFO.value.detailed_address) { // if (!STORE_INFO.store_name || !STORE_INFO.detailed_address) {
STORE_INFO.value.name = res.data.store.name; // STORE_INFO.store_name = res.data.store.name;
STORE_INFO.value.detailed_address = res.data.store.detailed_address; // STORE_INFO.value.detailed_address = res.data.store.detailed_address;
} // }
}) })
} }
// //
const loadMoreGood = () => { const loadMoreGood = () => {
console.log('触底了');
getGoodList(true); getGoodList(true);
} }
@ -385,7 +392,7 @@
page_no: page_no, page_no: page_no,
page_size: 30, page_size: 30,
level: three, level: three,
store_id: STORE_INFO.value.id || '5' // id store_id: STORE_INFO.id // id
}).then(res => { }).then(res => {
if (pid == 0) { // if (pid == 0) { //
if (!res.data?.lists?.length) return; if (!res.data?.lists?.length) return;
@ -493,7 +500,7 @@
productLogApi({ productLogApi({
product_id: item.product_id, product_id: item.product_id,
cate_id: item.cate_id, cate_id: item.cate_id,
store_id: STORE_INFO.value.id || '5' store_id: STORE_INFO.id
}); });
}; };
const changeGood = (data) => { // const changeGood = (data) => { //
@ -560,34 +567,23 @@
onLoad(async (opt) => { onLoad(async (opt) => {
// id // id
if (opt.id) { if (opt.id) {
where.value.store_id = 5; where.value.store_id = opt.id;
const info = await shopDetailApi({ const info = await shopDetailApi({
store_id: 5 store_id: opt.id
}); });
STORE_INFO.value = info.data;
uni.setStorageSync('STORE_INFO', JSON.stringify(info.data));
// //
if (opt.spread_uid) { if (opt.spread_uid) {
shareInfo.value.uid = opt.spread_uid; shareInfo.value.uid = opt.spread_uid;
shareInfo.value.real_name = opt.real_name; shareInfo.value.real_name = opt.real_name;
shareInfo.value.store_id = opt.id; shareInfo.value.store_id = opt.id;
uni.setStorageSync('SHARE_INFO', shareInfo.value); uni.setStorageSync('SHARE_INFO', shareInfo.value);
} else {
//
const i = uni.getStorageSync('SHARE_INFO');
if (i)
shareInfo.value = i;
} }
} else { } else {
// //
const info = uni.getStorageSync('STORE_INFO'); const info = uni.getStorageSync('STORE_INFO');
if (info) { if (info) {
STORE_INFO.value = JSON.parse(info); where.value.store_id = STORE_INFO.id;
where.value.store_id = 5;
} }
// //
const i = uni.getStorageSync('SHARE_INFO'); const i = uni.getStorageSync('SHARE_INFO');
if (i) if (i)
@ -596,7 +592,6 @@
getgoodClassList(0); getgoodClassList(0);
getGoodList(); getGoodList();
// //
btns.value = uni.getMenuButtonBoundingClientRect(); btns.value = uni.getMenuButtonBoundingClientRect();
}) })