This commit is contained in:
1154079537 2024-06-13 18:08:15 +08:00
parent a9071886cc
commit c85cb68f7a
4 changed files with 490 additions and 433 deletions

View File

@ -3,3 +3,8 @@ import request from '@/utils/request';
export const shopListApi = (data) => { export const shopListApi = (data) => {
return request.get('/store/store/lists', data); return request.get('/store/store/lists', data);
} }
// 店铺详情
export const shopDetailApi = (data) => {
return request.get('/store/store/detail', data);
}

View File

@ -164,12 +164,14 @@
<script setup> <script setup>
import { import {
onLoad, onLoad,
onShow onShow,
onShareAppMessage,
onShareTimeline
} from "@dcloudio/uni-app" } from "@dcloudio/uni-app"
import { import {
reactive, reactive,
ref, ref,
onMounted onMounted,
} from "vue" } from "vue"
import { import {
goodListApi, goodListApi,
@ -190,9 +192,18 @@
import { import {
getCurrentInstance getCurrentInstance
} from 'vue'; } from 'vue';
import {
shopDetailApi
} from "@/api/multipleShop.js";
import useUserStore from "@/store/user"; import useUserStore from "@/store/user";
const userStore = useUserStore(); const userStore = useUserStore();
const STORE_INFO = ref({
name: '',
id: '',
detailed_address: '',
image: ''
});
const test = () => { const test = () => {
uni.navigateTo({ uni.navigateTo({
@ -200,18 +211,28 @@
}) })
} }
//
onShareAppMessage(() => {
let shareInfo = {
title: STORE_INFO.value.name,
path: '/pages/index/index?id=' + STORE_INFO.value.id,
imageUrl: STORE_INFO.value.image,
success() {
uni.$u.toast('分享成功');
},
fail() {
uni.$u.toast('分享失败');
}
};
return shareInfo;
})
const navgo = (url) => { const navgo = (url) => {
uni.navigateTo({ uni.navigateTo({
url url
}) })
} }
//
let STORE_INFO = uni.getStorageSync('STORE_INFO');
if (STORE_INFO)
STORE_INFO = JSON.parse(STORE_INFO)
/*商品列表滚动隐藏头部导航 */ /*商品列表滚动隐藏头部导航 */
const instance = getCurrentInstance(); // const instance = getCurrentInstance(); //
const targetHeight = ref(0) const targetHeight = ref(0)
@ -261,7 +282,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: where.value.store_id, store_id: STORE_INFO.value.id,
product_id: product_id product_id: product_id
}).then(res => { }).then(res => {
getCartList(); getCartList();
@ -289,10 +310,9 @@
name: '', name: '',
order: '', order: '',
store_name: '', store_name: '',
store_id: STORE_INFO.id || '' store_id: STORE_INFO.value.id || ''
}) })
// console.log(JSON.parse(uni.getStorageSync('STORE_INFO')))
const loading = ref(true); const loading = ref(true);
const goodList = ref([]); const goodList = ref([]);
const getGoodList = (loadmore = false) => { const getGoodList = (loadmore = false) => {
@ -329,13 +349,12 @@
const classMap = new Map(); const classMap = new Map();
const getgoodClassList = (pid = 0, three = 1) => { const getgoodClassList = (pid = 0, three = 1) => {
let page_no = classMap.get(pid) || 1; let page_no = classMap.get(pid) || 1;
// console.log(classMap.get(pid));
goodClassListApi({ goodClassListApi({
pid: pid, pid: pid,
page_no: page_no, page_no: page_no,
page_size: 30, page_size: 30,
level: three, level: three,
store_id: STORE_INFO.id || '' // id store_id: STORE_INFO.value.id || '' // id
}).then(res => { }).then(res => {
if (pid == 0) { // if (pid == 0) { //
if (!res.data?.lists?.length) return; if (!res.data?.lists?.length) return;
@ -443,7 +462,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.id || '' store_id: STORE_INFO.value.id || ''
}); });
}; };
const changeGood = (data) => { // const changeGood = (data) => { //
@ -491,8 +510,22 @@
}) })
} }
onLoad((opt) => { onLoad(async (opt) => {
if (opt.id) where.value.store_id = opt.id; // id
if (opt.id) {
where.value.store_id = opt.id;
const info = await shopDetailApi({
store_id: opt.id
});
STORE_INFO.value = info.data;
uni.setStorageSync('STORE_INFO', JSON.stringify(info.data));
} else {
const info = uni.getStorageSync('STORE_INFO');
if (info)
STORE_INFO.value = JSON.parse(info);
}
getgoodClassList(0); getgoodClassList(0);
getGoodList(); getGoodList();
}) })

View File

@ -132,7 +132,6 @@
const showWeixin = ref(true); // const showWeixin = ref(true); //
const isAgree = ref(false); // const isAgree = ref(false); //
const tempUser = ref(null);
const weixinLogin = () => { const weixinLogin = () => {
if (!isAgree.value) return uni.$u.toast('请先阅读并同意协议'); if (!isAgree.value) return uni.$u.toast('请先阅读并同意协议');
@ -149,7 +148,6 @@
userStore.setToken(res.data.token); userStore.setToken(res.data.token);
if (!res.data.mobile) { // if (!res.data.mobile) { //
// tempUser.value = res.data;
return showBind.value = true; return showBind.value = true;
} else { } else {
userStore.setUserInfo(res.data); userStore.setUserInfo(res.data);
@ -161,13 +159,23 @@
uni.reLaunch({ uni.reLaunch({
url: "/multipleShop/verificationOrder/index" url: "/multipleShop/verificationOrder/index"
}) })
} else { // } else {
// ,
let storeInfo = uni.getStorageSync('STORE_INFO');
if (storeInfo) {
storeInfo = JSON.parse(storeInfo);
//
uni.reLaunch({
url: "/pages/index/index?id=" + storeInfo.id
})
} else {
//
uni.reLaunch({ uni.reLaunch({
url: "/multipleShop/index/index" url: "/multipleShop/index/index"
}) })
} }
} }
// navToIndex(); }
}) })
}, },
fail: (err) => { fail: (err) => {
@ -177,7 +185,6 @@
}) })
} }
const showBind = ref(false); // const showBind = ref(false); //
const getPhoneNumber = (e) => { const getPhoneNumber = (e) => {
if (e.detail?.errMsg == 'getPhoneNumber:ok') { if (e.detail?.errMsg == 'getPhoneNumber:ok') {
@ -192,11 +199,22 @@
uni.reLaunch({ uni.reLaunch({
url: "/multipleShop/verificationOrder/index" url: "/multipleShop/verificationOrder/index"
}) })
} else { // } else {
// ,
let storeInfo = uni.getStorageSync('STORE_INFO');
if (storeInfo) {
storeInfo = JSON.parse(storeInfo);
//
uni.reLaunch({
url: "/pages/index/index?id=" + storeInfo.id
})
} else {
//
uni.reLaunch({ uni.reLaunch({
url: "/multipleShop/index/index" url: "/multipleShop/index/index"
}) })
} }
}
}) })
} else { } else {
console.log("用户拒绝授权"); console.log("用户拒绝授权");

View File

@ -308,10 +308,11 @@ const goPay = () => {
// //
const submitOrder = () => { const submitOrder = () => {
// if (!shopInfo.value.mer_id) { if (orderInfo.value.pay_price == 0) {
// uni.$u.toast(''); pay_type.value = 3;
// return shopListShow.value = true; return uni.$u.toast('当前支付金额为0暂不能使用微信支付')
// } }
if (!isAddress.value && orderInfo.value.shipping_type == 1) return toastAddressShow.value = true; if (!isAddress.value && orderInfo.value.shipping_type == 1) return toastAddressShow.value = true;
createOrder(); createOrder();
} }