优化功能

This commit is contained in:
weipengfei 2024-05-20 15:43:48 +08:00
parent aad2f02a5d
commit 0b9758ff3b
4 changed files with 642 additions and 597 deletions

View File

@ -1,189 +1,208 @@
<template>
<up-popup :show="show" closeable round="10" @close="close">
<view class="address-popup">
<view class="head-title">提货点</view>
<view class="list-admin">
<up-search placeholder="请输入提货点名称" @search="searchKeyword" v-model="keyword"
@custom="searchKeyword"></up-search>
</view>
<scroll-view style="height: 600rpx;padding-bottom: 20rpx;" scroll-y>
<view class="list-li border" v-for="(item,index) in list" :key="index" @click="addressType=item.mer_id">
<view class="list-li-top">
<view class="">
<text>{{item.mer_name}}</text>
<text v-if="index==0&&item.distance"
style="background-color: #38BE41;color: white;font-size: 18rpx;margin-left: 24rpx;padding: 0 5rpx;">距离最近</text>
<text v-if="item.distance" class="distance">步行{{item.distance}}</text>
</view>
</view>
<view class="">
{{item.mer_address||'sdsd'}}
</view>
<view class="check">
<image style="width: 36rpx;height: 36rpx" v-if="addressType==item.mer_id"
src="@/static/icon/check.png">
</image>
<image style="width: 36rpx;height: 36rpx" v-else src="@/static/icon/n-check.png"></image>
</view>
</view>
</scroll-view>
<up-button color="#20B128" shape="circle" @click="submitAddress">确认提货点 </up-button>
</view>
</up-popup>
<up-popup :show="show" closeable round="10" @close="close">
<view class="address-popup">
<view class="head-title">提货点</view>
<view class="list-admin">
<up-search placeholder="请输入提货点名称" @search="searchKeyword" v-model="keyword" @custom="searchKeyword"></up-search>
</view>
<scroll-view style="height: 600rpx;padding-bottom: 20rpx;" scroll-y>
<view class="list-li border" v-for="(item,index) in list" :key="index" @click="addressType=item.mer_id">
<view class="list-li-top">
<view class="">
<text>{{item.mer_name}}</text>
<text v-if="index==0&&item.distance"
style="background-color: #38BE41;color: white;font-size: 18rpx;margin-left: 24rpx;padding: 0 5rpx;">距离最近</text>
<text v-if="item.distance" class="distance">步行{{item.distance}}</text>
</view>
</view>
<view class="">
{{item.mer_address||''}}
</view>
<view style="color: #999;">
<text v-if="item.service_phone" @click.stop="callphone(item.service_phone)">{{item.service_user||''}}
{{ item.service_phone||'' }}</text>
</view>
<view class="check">
<image style="width: 36rpx;height: 36rpx" v-if="addressType==item.mer_id" src="@/static/icon/check.png">
</image>
<image style="width: 36rpx;height: 36rpx" v-else src="@/static/icon/n-check.png"></image>
</view>
</view>
</scroll-view>
<up-button color="#20B128" shape="circle" @click="submitAddress">确认提货点 </up-button>
</view>
<modal title="是否要拨打电话" :content="`即将拨打电话${phone}`" cancleText="取消" confirmText="拨打" :show="callShow" @close="callShow = false"
@change="onCall" />
</up-popup>
</template>
<script setup>
import {
ref
} from "vue"
import {
ref
} from "vue";
import modal from "@/components/modal.vue";
const addressType = ref(-1)
const addressType = ref(-1)
const callShow = ref(false)
const phone = ref('');
const callphone = (e) => {
callShow.value = true;
phone.value = e;
}
const onCall = () => {
uni.makePhoneCall({
phoneNumber: phone.value,
success() {
callShow.value = false
}
})
}
const props = defineProps({
show: {
type: Boolean,
default: false
},
list: {
type: Array,
default: () => []
}
})
const props = defineProps({
show: {
type: Boolean,
default: false
},
list: {
type: Array,
default: () => []
}
})
const emit = defineEmits(['close', 'change', 'search']);
const close = () => {
emit('close');
}
const emit = defineEmits(['close', 'change', 'search']);
const close = () => {
emit('close');
}
const submitAddress = () => {
let e = props.list.find(item => item.mer_id == addressType.value);
if (addressType.value <= 0 || !e) return uni.$u.toast('请选择提货点');
emit('change', e);
}
const submitAddress = () => {
let e = props.list.find(item => item.mer_id == addressType.value);
if (addressType.value <= 0 || !e) return uni.$u.toast('请选择提货点');
emit('change', e);
}
const keyword = ref('')
const searchKeyword = () => {
emit('search', keyword.value);
}
const keyword = ref('')
const searchKeyword = () => {
emit('search', keyword.value);
}
const navTo = (url) => {
uni.navigateTo({
url: url
})
}
const navTo = (url) => {
uni.navigateTo({
url: url
})
}
const setCheck = (e) => {
addressType.value = e;
}
defineExpose({
setCheck
})
const setCheck = (e) => {
addressType.value = e;
}
defineExpose({
setCheck
})
</script>
<style scoped lang="scss">
.address-popup {
padding: 30rpx;
.address-popup {
padding: 30rpx;
.head-title {
font-weight: bold;
text-align: center;
margin-bottom: 20rpx;
}
.head-title {
font-weight: bold;
text-align: center;
margin-bottom: 20rpx;
}
.list-admin {
display: flex;
justify-content: space-between;
margin-bottom: 20rpx;
.list-admin {
display: flex;
justify-content: space-between;
margin-bottom: 20rpx;
.admin-btn {
display: flex;
color: #20B128;
.admin-btn {
display: flex;
color: #20B128;
.btn {
margin-left: 20rpx;
display: flex;
align-items: center;
.btn {
margin-left: 20rpx;
display: flex;
align-items: center;
&:active {
color: rgba(#20B128, 0.8);
transition: background-color 0.5s;
animation: disappear 0.5s 0.5s forwards;
}
}
}
}
&:active {
color: rgba(#20B128, 0.8);
transition: background-color 0.5s;
animation: disappear 0.5s 0.5s forwards;
}
}
}
}
.row {
display: flex;
align-items: center;
justify-content: space-between;
padding-bottom: 20rpx;
border-bottom: 1rpx solid #f6f6f6;
margin-bottom: 20rpx;
.row {
display: flex;
align-items: center;
justify-content: space-between;
padding-bottom: 20rpx;
border-bottom: 1rpx solid #f6f6f6;
margin-bottom: 20rpx;
&:last-child {
border-bottom: none;
margin-bottom: 0;
}
&:last-child {
border-bottom: none;
margin-bottom: 0;
}
.content {
.top {
display: flex;
.content {
.top {
display: flex;
view {
margin-right: 20rpx;
}
}
view {
margin-right: 20rpx;
}
}
.bottom {}
}
.bottom {}
}
image {
width: 40rpx;
height: 40rpx;
flex-shrink: 0;
}
}
}
image {
width: 40rpx;
height: 40rpx;
flex-shrink: 0;
}
}
}
.border {
border-bottom: 1px solid #F3F3F3;
}
.border {
border-bottom: 1px solid #F3F3F3;
}
.list-li {
padding: 30rpx 0;
font-size: 24rpx;
position: relative;
.list-li {
padding: 30rpx 0;
font-size: 24rpx;
position: relative;
.list-li-top {
display: flex;
justify-content: space-between;
margin-bottom: 10rpx;
font-size: 30rpx;
}
.list-li-top {
display: flex;
justify-content: space-between;
margin-bottom: 10rpx;
font-size: 30rpx;
}
.distance {
border: 1px solid #40AE36;
font-size: 18rpx;
color: #40AE36;
margin-left: 20rpx;
padding: 0 5rpx;
}
.distance {
border: 1px solid #40AE36;
font-size: 18rpx;
color: #40AE36;
margin-left: 20rpx;
padding: 0 5rpx;
}
.check {
position: absolute;
right: 20rpx;
top: 50%;
transform: translateY(-50%);
}
}
.check {
position: absolute;
right: 20rpx;
top: 50%;
transform: translateY(-50%);
}
}
@keyframes disappear {
to {
opacity: 0;
/* 渐隐 */
transform: scale(0);
/* 缩小 */
}
}
@keyframes disappear {
to {
opacity: 0;
/* 渐隐 */
transform: scale(0);
/* 缩小 */
}
}
</style>

View File

@ -20,7 +20,7 @@ export function createApp() {
const app = createSSRApp(App)
// 创建Pinia实例 // 将pinia实例挂载到vue实例上
app.use(Pinia.createPinia());
app.use(uviewPlus)
app.use(uviewPlus);
return {
app,
Pinia, // 此处必须将 Pinia 返回

View File

@ -95,16 +95,19 @@
const showOfficial = ref(false);
const navToIndex = () => {
if (!userStore.userInfo.supplier) uni.reLaunch({
url: '/pages/index/index'
})
else if (userStore.userInfo.supplier && !userStore.userInfo.supplier.openid) {
return showOfficial.value = true;
} else {
uni.reLaunch({
url: '/pageQuota/quotation/index'
})
}
if (userStore.userInfo && userStore.token) uni.reLaunch({
url: '/pages/index/index'
})
// if (!userStore.userInfo.supplier) uni.reLaunch({
// url: '/pages/index/index'
// })
// else if (userStore.userInfo.supplier && !userStore.userInfo.supplier.openid) {
// return showOfficial.value = true;
// } else {
// uni.reLaunch({
// url: '/pageQuota/quotation/index'
// })
// }
}
//

View File

@ -1,99 +1,103 @@
<template>
<view class="">
<!-- <view class="m-card row">
<view class="">
<!-- <view class="m-card row">
<up-cell-group>
<up-cell title="请添加自提点" :isLink="true" :border="false" @click="shopListShow=true"></up-cell>
</up-cell-group>
</view> -->
<view class="m-card m-address">
<view class="address-info">
<view class="top" style="align-items: flex-start;">
<view style="color: #333;display: flex;align-items: center;">
<up-icon name="map"></up-icon>
<text style="margin: 0 10rpx;">自提点</text>
</view>
<view v-if="shopInfo.mer_id">
<view>
<view class="m-card m-address">
<view class="address-info">
<view class="top" style="align-items: flex-start;">
<view style="color: #333;display: flex;align-items: center;">
<up-icon name="map"></up-icon>
<text style="margin: 0 10rpx;">自提点</text>
</view>
<view v-if="shopInfo.mer_id">
<view>
{{shopInfo.mer_name}}
<span v-if="shopInfo.recommend" style="font-size: 10px;color: #fff;background-color: #20b128;padding: 2rpx 5rpx;border-radius: 4rpx;">推荐</span>
<text v-if="shopInfo.recommend"
style="font-size: 20rpx;color: #fff;background-color: #20b128;padding: 2rpx 5rpx;padding: 1rpx 4rpx;">推荐</text>
</view>
<view>
<text>{{shopInfo.service_phone}}</text>
<text
style="color: #20b128;margin-left: 10rpx;font-size: 22rpx;">{{shopInfo.distance}}</text>
</view>
</view>
</view>
</view>
<view class="address-btn">
<view style="width: 80px;"><up-button @click="shopListShow=true" size="small" shape="circle"
color="#f6f6f6" :customStyle="{color:'#666666'}">修改</up-button></view>
</view>
</view>
<view v-if="!addressInfo.address_id" class="m-card row">
<up-cell-group>
<up-cell title="我的地址" :isLink="true" :border="false" @click="openAddress()"></up-cell>
</up-cell-group>
</view>
<view v-else class="m-card m-address">
<view class="address-info">
<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-btn">
<view style="width: 80px;"><up-button @click="showAddress = true" size="small" shape="circle"
color="#f6f6f6" :customStyle="{color:'#666666'}">修改</up-button></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 class="m-card good-info">
<view class="head-title">价格明细</view>
<view class="row">
<view>商品总价 <text>共计{{cartList.length}}款商品</text></view>
<view><text>¥</text>{{c_price(orderInfo.total, 0)}}<text>.{{c_price(orderInfo.total, 1)}}</text></view>
</view>
<view class="row">
<view>运费</view>
<view><text>¥</text>0<text>.00</text></view>
</view>
</view>
<view class="m-card good-info">
<view class="head-title">支付方式</view>
<view class="row">
<view class="icon-text"><up-icon name="weixin-circle-fill" color="#20b128" size="22"
style="margin-right: 10rpx;"></up-icon> </view>
<view class="icon">
<image v-if="true" src="@/static/icon/check.png"></image>
<image v-else src="@/static/icon/n-check.png"></image>
</view>
</view>
</view>
<!-- <view class="m-card order-remark">
<view>
<view v-if="shopInfo.service_phone" @click="callphone(shopInfo.service_phone)">
<text style="margin-right: 10rpx;">{{shopInfo.service_user}}</text>
<text>{{shopInfo.service_phone}}</text>
</view>
<text v-if="shopInfo.distance"
style="color: #20b128;font-size: 22rpx;border: 1px solid #20b128;border-radius: 4rpx;">{{shopInfo.distance}}</text>
</view>
</view>
</view>
</view>
<view class="address-btn">
<view style="width: 80px;"><up-button @click="shopListShow=true" size="small" shape="circle" color="#f6f6f6"
:customStyle="{color:'#666666'}">修改</up-button></view>
</view>
</view>
<view v-if="!addressInfo.address_id" class="m-card row">
<up-cell-group>
<up-cell title="我的地址" :isLink="true" :border="false" @click="openAddress()"></up-cell>
</up-cell-group>
</view>
<view v-else class="m-card m-address">
<view class="address-info">
<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-btn">
<view style="width: 80px;"><up-button @click="showAddress = true" size="small" shape="circle" color="#f6f6f6"
:customStyle="{color:'#666666'}">修改</up-button></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 class="m-card good-info">
<view class="head-title">价格明细</view>
<view class="row">
<view>商品总价 <text>共计{{cartList.length}}款商品</text></view>
<view><text>¥</text>{{c_price(orderInfo.total, 0)}}<text>.{{c_price(orderInfo.total, 1)}}</text></view>
</view>
<view class="row">
<view>运费</view>
<view><text>¥</text>0<text>.00</text></view>
</view>
</view>
<view class="m-card good-info">
<view class="head-title">支付方式</view>
<view class="row">
<view class="icon-text"><up-icon name="weixin-circle-fill" color="#20b128" size="22"
style="margin-right: 10rpx;"></up-icon> </view>
<view class="icon">
<image v-if="true" src="@/static/icon/check.png"></image>
<image v-else src="@/static/icon/n-check.png"></image>
</view>
</view>
</view>
<!-- <view class="m-card order-remark">
<view class="head-title">
<text>订单备注</text>
<text>0/200</text>
@ -101,386 +105,405 @@
<up-textarea style="background-color: #F6F6F6;" v-model="formData.remark" placeholder="暂无备注内容"
:height="100"></up-textarea>
</view> -->
<view style="width: 100%;height: 200rpx;"></view>
<view class="fiexd-btn-box">
<view class="tips">
<view style="margin-right: 20rpx;"> {{ cartList.length }} </view>
<view class="all">
<text style="color: #000;">合计: </text>
<text></text>
<block v-if="orderInfo.total">
<text style="font-size: 32rpx;font-weight: bold;">{{c_price(orderInfo.total, 0)}}</text>
<text>.{{c_price(orderInfo.total, 1)}}</text>
</block>
</view>
</view>
<view style="width: 200rpx;">
<up-button color="#20B128" shape="circle" @click="submitOrder" :throttleTime="1000">预付款提交</up-button>
</view>
</view>
<view style="width: 100%;height: 200rpx;"></view>
<view class="fiexd-btn-box">
<view class="tips">
<view style="margin-right: 20rpx;"> {{ cartList.length }} </view>
<view class="all">
<text style="color: #000;">合计: </text>
<text></text>
<block v-if="orderInfo.total">
<text style="font-size: 32rpx;font-weight: bold;">{{c_price(orderInfo.total, 0)}}</text>
<text>.{{c_price(orderInfo.total, 1)}}</text>
</block>
</view>
</view>
<view style="width: 200rpx;">
<up-button color="#20B128" shape="circle" @click="submitOrder" :throttleTime="1000">预付款提交</up-button>
</view>
</view>
<addressPopup ref="addressRef" :show="showAddress" :list="addressList" @close="showAddress=false"
@change="changeAddress" />
<shopListPopupVue ref="shopRef" :show="shopListShow" :list="merchantList" @close="shopListShow=false"
@change="changeShop" @search="searchShop" />
<modal title="尚未设置收货地址" content="您还没有添加收货地址,请点击添加" cancleText="添加地址" confirmText="继续支付" :show="toastAddressShow"
@close="addAddress" @change="goPay" />
</view>
<addressPopup ref="addressRef" :show="showAddress" :list="addressList" @close="showAddress=false"
@change="changeAddress" />
<shopListPopupVue ref="shopRef" :show="shopListShow" :list="merchantList" @close="shopListShow=false"
@change="changeShop" @search="searchShop" />
<modal title="尚未设置收货地址" content="您还没有添加收货地址,请点击添加" cancleText="添加地址" confirmText="继续支付" :show="toastAddressShow"
@close="addAddress" @change="goPay" />
<modal title="是否要拨打电话" :content="`即将拨打电话${phone}`" cancleText="取消" confirmText="拨打" :show="callShow" @close="callShow = false"
@change="onCall" />
</view>
</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 modal from "@/components/modal.vue"
import useCartStore from "@/store/cart.js";
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";
const cartStore = useCartStore();
const cartStore = useCartStore();
const formData = ref({
remark: ""
})
const formData = ref({
remark: ""
})
const isAddress = ref(false);
const toastAddressShow = ref(false);
const isAddress = ref(false);
const toastAddressShow = ref(false);
//
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 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 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;
}
})
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 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;
}
})
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];
//
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)
}
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 addAddress = () => {
toastAddressShow.value = false;
nextTick(() => {
showAddress.value = true;
})
}
//
const goPay = () => {
toastAddressShow.value = false;
isAddress.value = true;
submitOrder();
}
//
const callShow = ref(false)
const phone = ref('');
const callphone = (e) => {
callShow.value = true;
phone.value = e;
}
const onCall = () => {
uni.makePhoneCall({
phoneNumber: phone.value,
success() {
callShow.value = false
}
})
}
//
const submitOrder = () => {
if (!shopInfo.value.mer_id) {
uni.$u.toast('请先选择提货点');
return shopListShow.value = true;
}
if (!isAddress.value) return toastAddressShow.value = true;
createOrder();
}
//
const cartList = ref([]);
const orderInfo = ref({});
const checkOrder = () => {
checkOrderApi({
cart_id: cartStore.cartList
}).then(res => {
cartList.value = res.data.cart_list;
orderInfo.value = res.data.order;
})
}
const createOrder = () => {
createOrderApi({
cart_id: cartStore.cartList,
address_id: addressInfo.value.address_id,
mer_id: shopInfo.value.mer_id,
pay_type: 1
}).then(res => {
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('用户取消支付')
}
})
}).catch(err => {
uni.$u.toast('网络错误')
})
}
//
const addAddress = () => {
toastAddressShow.value = false;
nextTick(() => {
showAddress.value = true;
})
}
//
const goPay = () => {
toastAddressShow.value = false;
isAddress.value = true;
submitOrder();
}
const c_price = (price, index = 0) => {
price = price + '';
return price.split('.')[index] || (index ? '00' : '0');
}
//
const submitOrder = () => {
if (!shopInfo.value.mer_id) {
uni.$u.toast('请先选择提货点');
return shopListShow.value = true;
}
if (!isAddress.value) return toastAddressShow.value = true;
createOrder();
}
//
const cartList = ref([]);
const orderInfo = ref({});
const checkOrder = () => {
checkOrderApi({
cart_id: cartStore.cartList
}).then(res => {
cartList.value = res.data.cart_list;
orderInfo.value = res.data.order;
})
}
const createOrder = () => {
createOrderApi({
cart_id: cartStore.cartList,
address_id: addressInfo.value.address_id,
mer_id: shopInfo.value.mer_id,
pay_type: 1
}).then(res => {
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('用户取消支付')
}
})
}).catch(err => {
uni.$u.toast('网络错误')
})
}
onLoad(options => {
checkOrder();
})
onShow(() => {
getAddressList();
})
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;
}
.m-card {
margin: 20rpx;
border-radius: 14rpx;
background-color: #fff;
padding: 20rpx;
}
.row {
padding: 0;
overflow: hidden;
}
.row {
padding: 0;
overflow: hidden;
}
.m-address {
margin-bottom: 20rpx;
display: flex;
justify-content: space-between;
color: #999999;
.m-address {
margin-bottom: 20rpx;
display: flex;
justify-content: space-between;
color: #999999;
.address-info {
width: 510rpx;
.address-info {
width: 510rpx;
.top {
display: flex;
font-size: 28rpx;
.top {
display: flex;
font-size: 28rpx;
.t-name {
color: #444;
margin: 0 10rpx;
}
}
.t-name {
color: #444;
margin: 0 10rpx;
}
}
.bottom {
font-size: 24rpx;
}
}
}
.bottom {
font-size: 24rpx;
}
}
}
.m-good {
display: flex;
justify-content: space-between;
margin-bottom: 20rpx;
.m-good {
display: flex;
justify-content: space-between;
margin-bottom: 20rpx;
.image {
width: 160rpx;
height: 160rpx;
margin-right: 20rpx;
border-radius: 14rpx;
overflow: hidden;
}
.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;
.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;
}
.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;
}
.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;
}
}
}
.time {
background-color: #F6F6F6;
padding: 5rpx 10rpx;
font-size: 26rpx;
color: #444;
border-radius: 10rpx;
}
}
}
.good-info {
margin-bottom: 20rpx;
.good-info {
margin-bottom: 20rpx;
.head-title {
margin-bottom: 18rpx;
color: #000;
font-weight: bold;
}
.head-title {
margin-bottom: 18rpx;
color: #000;
font-weight: bold;
}
.row {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 18rpx;
.row {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 18rpx;
.red {
color: #F55726;
}
.red {
color: #F55726;
}
.icon-text {
display: flex;
}
.icon-text {
display: flex;
}
.icon {
image {
width: 40rpx;
height: 40rpx;
}
}
}
.icon {
image {
width: 40rpx;
height: 40rpx;
}
}
}
.row-need {
display: flex;
justify-content: flex-end;
color: #F55726;
}
.row-need {
display: flex;
justify-content: flex-end;
color: #F55726;
}
text {
font-size: 22rpx;
}
}
text {
font-size: 22rpx;
}
}
.order-remark {
.head-title {
margin-bottom: 18rpx;
display: flex;
justify-content: space-between;
}
}
.order-remark {
.head-title {
margin-bottom: 18rpx;
display: flex;
justify-content: space-between;
}
}
.tips {
font-size: 28rpx;
color: #999;
display: flex;
justify-content: flex-end;
align-items: center;
flex: 1;
margin-right: 20rpx;
.tips {
font-size: 28rpx;
color: #999;
display: flex;
justify-content: flex-end;
align-items: center;
flex: 1;
margin-right: 20rpx;
.all {
color: #F55726;
}
}
.all {
color: #F55726;
}
}
</style>