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

@ -2,4 +2,9 @@ import request from '@/utils/request';
export const shopListApi = (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>
import {
onLoad,
onShow
onShow,
onShareAppMessage,
onShareTimeline
} from "@dcloudio/uni-app"
import {
reactive,
ref,
onMounted
onMounted,
} from "vue"
import {
goodListApi,
@ -190,9 +192,18 @@
import {
getCurrentInstance
} from 'vue';
import {
shopDetailApi
} from "@/api/multipleShop.js";
import useUserStore from "@/store/user";
const userStore = useUserStore();
const STORE_INFO = ref({
name: '',
id: '',
detailed_address: '',
image: ''
});
const test = () => {
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) => {
uni.navigateTo({
url
})
}
//
let STORE_INFO = uni.getStorageSync('STORE_INFO');
if (STORE_INFO)
STORE_INFO = JSON.parse(STORE_INFO)
/*商品列表滚动隐藏头部导航 */
const instance = getCurrentInstance(); //
const targetHeight = ref(0)
@ -261,7 +282,7 @@
cart_num: cart_num,
is_new: 0, // 01
// goods_id: id,
store_id: where.value.store_id,
store_id: STORE_INFO.value.id,
product_id: product_id
}).then(res => {
getCartList();
@ -289,10 +310,9 @@
name: '',
order: '',
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 goodList = ref([]);
const getGoodList = (loadmore = false) => {
@ -329,13 +349,12 @@
const classMap = new Map();
const getgoodClassList = (pid = 0, three = 1) => {
let page_no = classMap.get(pid) || 1;
// console.log(classMap.get(pid));
goodClassListApi({
pid: pid,
page_no: page_no,
page_size: 30,
level: three,
store_id: STORE_INFO.id || '' // id
store_id: STORE_INFO.value.id || '' // id
}).then(res => {
if (pid == 0) { //
if (!res.data?.lists?.length) return;
@ -443,7 +462,7 @@
productLogApi({
product_id: item.product_id,
cate_id: item.cate_id,
store_id: STORE_INFO.id || ''
store_id: STORE_INFO.value.id || ''
});
};
const changeGood = (data) => { //
@ -491,8 +510,22 @@
})
}
onLoad((opt) => {
if (opt.id) where.value.store_id = opt.id;
onLoad(async (opt) => {
// 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);
getGoodList();
})

View File

@ -132,7 +132,6 @@
const showWeixin = ref(true); //
const isAgree = ref(false); //
const tempUser = ref(null);
const weixinLogin = () => {
if (!isAgree.value) return uni.$u.toast('请先阅读并同意协议');
@ -149,7 +148,6 @@
userStore.setToken(res.data.token);
if (!res.data.mobile) { //
// tempUser.value = res.data;
return showBind.value = true;
} else {
userStore.setUserInfo(res.data);
@ -161,13 +159,23 @@
uni.reLaunch({
url: "/multipleShop/verificationOrder/index"
})
} else { //
uni.reLaunch({
url: "/multipleShop/index/index"
})
} 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({
url: "/multipleShop/index/index"
})
}
}
}
// navToIndex();
})
},
fail: (err) => {
@ -177,7 +185,6 @@
})
}
const showBind = ref(false); //
const getPhoneNumber = (e) => {
if (e.detail?.errMsg == 'getPhoneNumber:ok') {
@ -192,10 +199,21 @@
uni.reLaunch({
url: "/multipleShop/verificationOrder/index"
})
} else { //
uni.reLaunch({
url: "/multipleShop/index/index"
})
} 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({
url: "/multipleShop/index/index"
})
}
}
})
} else {

View File

@ -141,449 +141,450 @@
</template>
<script setup>
import {
onLoad,
onShow
} from "@dcloudio/uni-app"
import {
nextTick,
ref
} from "vue"
import addressPopup from "@/components/addressPopup.vue";
import shopListPopupVue from "@/components/shopListPopup.vue";
import useCartStore from "@/store/cart.js";
import modal from "@/components/modal.vue";
import {
checkOrderApi
} from "@/api/cart.js";
import {
addressListsApi,
merchantListApi
} from "@/api/user.js";
import {
createOrderApi
} from "@/api/order.js";
import {
onLoad,
onShow
} from "@dcloudio/uni-app"
import {
nextTick,
ref
} from "vue"
import addressPopup from "@/components/addressPopup.vue";
import shopListPopupVue from "@/components/shopListPopup.vue";
import useCartStore from "@/store/cart.js";
import modal from "@/components/modal.vue";
import {
checkOrderApi
} from "@/api/cart.js";
import {
addressListsApi,
merchantListApi
} from "@/api/user.js";
import {
createOrderApi
} from "@/api/order.js";
//
let STORE_INFO = uni.getStorageSync('STORE_INFO');
if (STORE_INFO)
STORE_INFO = JSON.parse(STORE_INFO)
//
let STORE_INFO = uni.getStorageSync('STORE_INFO');
if (STORE_INFO)
STORE_INFO = JSON.parse(STORE_INFO)
const cartStore = useCartStore();
const reservation_time = ref('')
const cartStore = useCartStore();
const reservation_time = ref('')
const formData = ref({
remark: ""
})
const isAddress = ref(false);
const toastAddressShow = ref(false);
const onChoosePaytype = (e) => {
pay_type.value = e;
}
//
const addressRef = ref(null);
const showAddress = ref(false);
const addressInfo = ref({});
const changeAddress = (e) => {
addressInfo.value = e;
showAddress.value = false;
isAddress.value = true;
}
const openAddress = () => {
if (addressList.length > 0) showAddress.value = true;
else uni.navigateTo({
url: '/pagesOrder/addressEdit/addressEdit'
const formData = ref({
remark: ""
})
}
//
const addressList = ref([]);
const getAddressList = () => {
addressListsApi().then(res => {
addressList.value = res.data.lists;
addressList.value.forEach(item => {
if (item.is_default) {
addressInfo.value = item;
isAddress.value = true;
}
const isAddress = ref(false);
const toastAddressShow = ref(false);
const onChoosePaytype = (e) => {
pay_type.value = e;
}
//
const addressRef = ref(null);
const showAddress = ref(false);
const addressInfo = ref({});
const changeAddress = (e) => {
addressInfo.value = e;
showAddress.value = false;
isAddress.value = true;
}
const openAddress = () => {
if (addressList.length > 0) showAddress.value = true;
else uni.navigateTo({
url: '/pagesOrder/addressEdit/addressEdit'
})
if (!isAddress.value && addressList.value.length > 0) {
addressInfo.value = addressList.value[0];
isAddress.value = true;
}
if (addressInfo.value.address_id) {
nextTick(() => {
addressRef.value.setCheck(addressInfo.value.address_id);
})
}
})
}
}
//
const shopRef = ref(null);
const shopListShow = ref(false);
const merchantList = ref([]);
const myAddressInfo = ref({
long: "",
lat: ""
})
const shopInfo = ref({
mer_id: ''
});
const getMerchantList = (mer_name = null) => {
merchantListApi({
...myAddressInfo.value,
mer_name: mer_name ? mer_name : ''
}).then(res => {
merchantList.value = res.data.lists;
if (mer_name === null && myAddressInfo.value.long && merchantList.value.length > 0 && !shopInfo
.value.mer_id) {
shopInfo.value = merchantList.value[0];
shopInfo.value.recommend = 1;
nextTick(() => {
shopRef.value.setCheck(shopInfo.value.mer_id);
})
}
})
}
// getMerchantList();
//
const LoadAddress = () => {
uni.getLocation({
success: (res) => { },
fail: (err) => {
uni.$u.toast('定位失败, 请手动选择提货点!')
},
complete: (res) => {
myAddressInfo.value.long = res.longitude || "";
myAddressInfo.value.lat = res.latitude || "";
getMerchantList();
}
})
}
// LoadAddress();
const changeShop = (e) => {
shopInfo.value = e;
shopListShow.value = false;
}
const searchShop = (e) => {
getMerchantList(e)
}
//
// const callShow = ref(false)
// const phone = ref('');
// const callphone = (e) => {
// callShow.value = true;
// phone.value = e;
// }
const onCall = (e) => {
uni.makePhoneCall({
phoneNumber: e,
success() {
callShow.value = false
}
})
}
//
const addAddress = () => {
toastAddressShow.value = false;
nextTick(() => {
showAddress.value = true;
})
}
//
const goPay = () => {
toastAddressShow.value = false;
isAddress.value = true;
submitOrder();
}
//
const submitOrder = () => {
// if (!shopInfo.value.mer_id) {
// uni.$u.toast('');
// return shopListShow.value = true;
// }
if (!isAddress.value && orderInfo.value.shipping_type == 1) return toastAddressShow.value = true;
createOrder();
}
//
const cartList = ref([]);
const orderInfo = ref({});
const checkOrder = () => {
checkOrderApi({
cart_id: cartStore.cartList,
store_id: STORE_INFO.id || 0
}).then(res => {
cartList.value = res.data.cart_list;
orderInfo.value = res.data.order;
if (orderInfo.value.default_delivery == 0) {
orderInfo.value.shipping_type = 2
}
})
}
const pay_type = ref('');
const createOrder = () => {
if (!pay_type.value) return uni.$u.toast('请选择支付方式');
createOrderApi({
cart_id: cartStore.cartList,
address_id: addressInfo.value.address_id,
pay_type: pay_type.value,
store_id: STORE_INFO.id || 0,
reservation_time: reservation_time.value,
shipping_type: orderInfo.value.shipping_type,
mark: formData.value.remark
}).then(res => {
console.log(res);
if (pay_type.value == 3) {
if (res.code == 1) {
uni.showToast({
title: res.msg,
icon: "none",
success() {
setTimeout(() => {
uni.redirectTo({
url: '/pagesOrder/order/order?back=-1&type=2'
})
}, 1500)
}
})
} else {
uni.$u.toast(res.msg);
}
} else {
if (!res.data?.nonceStr) return uni.$u.toast('支付失败!');
uni.requestPayment({
provider: 'wxpay',
timeStamp: res.data.timeStamp,
nonceStr: res.data.nonceStr,
package: res.data.package,
signType: res.data.signType,
paySign: res.data.paySign,
success: (e) => {
if (e.errMsg == 'requestPayment:ok') {
uni.showModal({
title: '订单支付成功',
confirmText: '查看订单',
cancelText: '继续购买',
success: (e) => {
if (e.confirm) uni.redirectTo({
url: '/pagesOrder/order/order?back=-1&type=2'
})
else uni.navigateBack();
}
})
} else uni.$u.toast('支付失败')
},
fail: (e) => {
uni.$u.toast('用户取消支付');
uni.redirectTo({
url: '/pagesOrder/order/order?back=-1&type=1'
})
//
const addressList = ref([]);
const getAddressList = () => {
addressListsApi().then(res => {
addressList.value = res.data.lists;
addressList.value.forEach(item => {
if (item.is_default) {
addressInfo.value = item;
isAddress.value = true;
}
})
}
}).catch(err => {
uni.$u.toast(err.msg || '网络错误')
if (!isAddress.value && addressList.value.length > 0) {
addressInfo.value = addressList.value[0];
isAddress.value = true;
}
if (addressInfo.value.address_id) {
nextTick(() => {
addressRef.value.setCheck(addressInfo.value.address_id);
})
}
})
}
//
const shopRef = ref(null);
const shopListShow = ref(false);
const merchantList = ref([]);
const myAddressInfo = ref({
long: "",
lat: ""
})
}
const shopInfo = ref({
mer_id: ''
});
const c_price = (price, index = 0) => {
price = price + '';
return price.split('.')[index] || (index ? '00' : '0');
}
const getMerchantList = (mer_name = null) => {
merchantListApi({
...myAddressInfo.value,
mer_name: mer_name ? mer_name : ''
}).then(res => {
merchantList.value = res.data.lists;
if (mer_name === null && myAddressInfo.value.long && merchantList.value.length > 0 && !shopInfo
.value.mer_id) {
shopInfo.value = merchantList.value[0];
shopInfo.value.recommend = 1;
nextTick(() => {
shopRef.value.setCheck(shopInfo.value.mer_id);
})
}
})
}
onLoad(options => {
checkOrder();
})
onShow(() => {
getAddressList();
})
// getMerchantList();
//
const LoadAddress = () => {
uni.getLocation({
success: (res) => {},
fail: (err) => {
uni.$u.toast('定位失败, 请手动选择提货点!')
},
complete: (res) => {
myAddressInfo.value.long = res.longitude || "";
myAddressInfo.value.lat = res.latitude || "";
getMerchantList();
}
})
}
// LoadAddress();
const changeShop = (e) => {
shopInfo.value = e;
shopListShow.value = false;
}
const searchShop = (e) => {
getMerchantList(e)
}
//
// const callShow = ref(false)
// const phone = ref('');
// const callphone = (e) => {
// callShow.value = true;
// phone.value = e;
// }
const onCall = (e) => {
uni.makePhoneCall({
phoneNumber: e,
success() {
callShow.value = false
}
})
}
//
const addAddress = () => {
toastAddressShow.value = false;
nextTick(() => {
showAddress.value = true;
})
}
//
const goPay = () => {
toastAddressShow.value = false;
isAddress.value = true;
submitOrder();
}
//
const submitOrder = () => {
if (orderInfo.value.pay_price == 0) {
pay_type.value = 3;
return uni.$u.toast('当前支付金额为0暂不能使用微信支付')
}
if (!isAddress.value && orderInfo.value.shipping_type == 1) return toastAddressShow.value = true;
createOrder();
}
//
const cartList = ref([]);
const orderInfo = ref({});
const checkOrder = () => {
checkOrderApi({
cart_id: cartStore.cartList,
store_id: STORE_INFO.id || 0
}).then(res => {
cartList.value = res.data.cart_list;
orderInfo.value = res.data.order;
if (orderInfo.value.default_delivery == 0) {
orderInfo.value.shipping_type = 2
}
})
}
const pay_type = ref('');
const createOrder = () => {
if (!pay_type.value) return uni.$u.toast('请选择支付方式');
createOrderApi({
cart_id: cartStore.cartList,
address_id: addressInfo.value.address_id,
pay_type: pay_type.value,
store_id: STORE_INFO.id || 0,
reservation_time: reservation_time.value,
shipping_type: orderInfo.value.shipping_type,
mark: formData.value.remark
}).then(res => {
console.log(res);
if (pay_type.value == 3) {
if (res.code == 1) {
uni.showToast({
title: res.msg,
icon: "none",
success() {
setTimeout(() => {
uni.redirectTo({
url: '/pagesOrder/order/order?back=-1&type=2'
})
}, 1500)
}
})
} else {
uni.$u.toast(res.msg);
}
} else {
if (!res.data?.nonceStr) return uni.$u.toast('支付失败!');
uni.requestPayment({
provider: 'wxpay',
timeStamp: res.data.timeStamp,
nonceStr: res.data.nonceStr,
package: res.data.package,
signType: res.data.signType,
paySign: res.data.paySign,
success: (e) => {
if (e.errMsg == 'requestPayment:ok') {
uni.showModal({
title: '订单支付成功',
confirmText: '查看订单',
cancelText: '继续购买',
success: (e) => {
if (e.confirm) uni.redirectTo({
url: '/pagesOrder/order/order?back=-1&type=2'
})
else uni.navigateBack();
}
})
} else uni.$u.toast('支付失败')
},
fail: (e) => {
uni.$u.toast('用户取消支付');
uni.redirectTo({
url: '/pagesOrder/order/order?back=-1&type=1'
})
}
})
}
}).catch(err => {
uni.$u.toast(err.msg || '网络错误')
})
}
const c_price = (price, index = 0) => {
price = price + '';
return price.split('.')[index] || (index ? '00' : '0');
}
onLoad(options => {
checkOrder();
})
onShow(() => {
getAddressList();
})
</script>
<style lang="scss">
.m-card {
margin: 20rpx;
border-radius: 14rpx;
background-color: #fff;
padding: 20rpx;
}
.row {
padding: 0;
overflow: hidden;
}
.m-address {
margin-bottom: 20rpx;
display: flex;
justify-content: space-between;
color: #999999;
.address-info {
width: 450rpx;
.top {
display: flex;
font-size: 28rpx;
.t-name {
color: #444;
margin: 0 10rpx;
}
}
.bottom {
font-size: 24rpx;
}
}
}
.m-good {
display: flex;
justify-content: space-between;
margin-bottom: 20rpx;
.image {
width: 160rpx;
height: 160rpx;
margin-right: 20rpx;
.m-card {
margin: 20rpx;
border-radius: 14rpx;
overflow: hidden;
}
.body-content {
width: 490rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
color: #989898;
.title {
display: flex;
justify-content: space-between;
font-size: 28rpx;
color: #444;
}
.tips {
display: flex;
justify-content: space-between;
font-size: 24rpx;
margin-top: 10rpx;
}
.time {
background-color: #F6F6F6;
padding: 5rpx 10rpx;
font-size: 26rpx;
color: #444;
border-radius: 10rpx;
}
}
}
.good-info {
margin-bottom: 20rpx;
.head-title {
margin-bottom: 18rpx;
color: #000;
font-weight: bold;
background-color: #fff;
padding: 20rpx;
}
.row {
padding: 0;
overflow: hidden;
}
.m-address {
margin-bottom: 20rpx;
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 18rpx;
color: #999999;
.red {
color: #F55726;
}
.address-info {
width: 450rpx;
.icon-text {
display: flex;
align-items: center;
}
.top {
display: flex;
font-size: 28rpx;
.icon {
image {
width: 40rpx;
height: 40rpx;
.t-name {
color: #444;
margin: 0 10rpx;
}
}
.bottom {
font-size: 24rpx;
}
}
}
.row-need {
display: flex;
justify-content: flex-end;
color: #F55726;
}
text {
font-size: 22rpx;
}
}
.order-remark {
.head-title {
margin-bottom: 18rpx;
.m-good {
display: flex;
justify-content: space-between;
margin-bottom: 20rpx;
.image {
width: 160rpx;
height: 160rpx;
margin-right: 20rpx;
border-radius: 14rpx;
overflow: hidden;
}
.body-content {
width: 490rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
color: #989898;
.title {
display: flex;
justify-content: space-between;
font-size: 28rpx;
color: #444;
}
.tips {
display: flex;
justify-content: space-between;
font-size: 24rpx;
margin-top: 10rpx;
}
.time {
background-color: #F6F6F6;
padding: 5rpx 10rpx;
font-size: 26rpx;
color: #444;
border-radius: 10rpx;
}
}
}
}
.tips {
font-size: 28rpx;
color: #999;
display: flex;
justify-content: flex-end;
align-items: center;
flex: 1;
margin-right: 20rpx;
.good-info {
margin-bottom: 20rpx;
.all {
color: #F55726;
.head-title {
margin-bottom: 18rpx;
color: #000;
font-weight: bold;
}
.row {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 18rpx;
.red {
color: #F55726;
}
.icon-text {
display: flex;
align-items: center;
}
.icon {
image {
width: 40rpx;
height: 40rpx;
}
}
}
.row-need {
display: flex;
justify-content: flex-end;
color: #F55726;
}
text {
font-size: 22rpx;
}
}
}
.item-center {
display: flex;
align-items: center;
position: relative;
}
.order-remark {
.head-title {
margin-bottom: 18rpx;
display: flex;
justify-content: space-between;
}
}
.ship-type {
display: flex;
z-index: 9;
background-color: #F6F6F6;
border-radius: 30rpx;
.tips {
font-size: 28rpx;
color: #999;
display: flex;
justify-content: flex-end;
align-items: center;
flex: 1;
margin-right: 20rpx;
.ship-type-item {
width: 82rpx;
height: 54rpx;
line-height: 54rpx;
text-align: center;
transition: background-color 0.3s ease;
.all {
color: #F55726;
}
}
.item-center {
display: flex;
align-items: center;
position: relative;
}
.ship-type {
display: flex;
z-index: 9;
background-color: #F6F6F6;
border-radius: 30rpx;
}
.actShipItem {
background-color: #27B52F;
color: white;
.ship-type-item {
width: 82rpx;
height: 54rpx;
line-height: 54rpx;
text-align: center;
transition: background-color 0.3s ease;
border-radius: 30rpx;
}
.actShipItem {
background-color: #27B52F;
color: white;
}
}
}
</style>