优化功能

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

View File

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

View File

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

View File

@ -1,99 +1,103 @@
<template> <template>
<view class=""> <view class="">
<!-- <view class="m-card row"> <!-- <view class="m-card row">
<up-cell-group> <up-cell-group>
<up-cell title="请添加自提点" :isLink="true" :border="false" @click="shopListShow=true"></up-cell> <up-cell title="请添加自提点" :isLink="true" :border="false" @click="shopListShow=true"></up-cell>
</up-cell-group> </up-cell-group>
</view> --> </view> -->
<view class="m-card m-address"> <view class="m-card m-address">
<view class="address-info"> <view class="address-info">
<view class="top" style="align-items: flex-start;"> <view class="top" style="align-items: flex-start;">
<view style="color: #333;display: flex;align-items: center;"> <view style="color: #333;display: flex;align-items: center;">
<up-icon name="map"></up-icon> <up-icon name="map"></up-icon>
<text style="margin: 0 10rpx;">自提点</text> <text style="margin: 0 10rpx;">自提点</text>
</view> </view>
<view v-if="shopInfo.mer_id"> <view v-if="shopInfo.mer_id">
<view> <view>
{{shopInfo.mer_name}} {{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>
<view> <view>
<text>{{shopInfo.service_phone}}</text> <view v-if="shopInfo.service_phone" @click="callphone(shopInfo.service_phone)">
<text <text style="margin-right: 10rpx;">{{shopInfo.service_user}}</text>
style="color: #20b128;margin-left: 10rpx;font-size: 22rpx;">{{shopInfo.distance}}</text> <text>{{shopInfo.service_phone}}</text>
</view> </view>
</view> <text v-if="shopInfo.distance"
</view> style="color: #20b128;font-size: 22rpx;border: 1px solid #20b128;border-radius: 4rpx;">{{shopInfo.distance}}</text>
</view> </view>
<view class="address-btn"> </view>
<view style="width: 80px;"><up-button @click="shopListShow=true" size="small" shape="circle" </view>
color="#f6f6f6" :customStyle="{color:'#666666'}">修改</up-button></view> </view>
</view> <view class="address-btn">
</view> <view style="width: 80px;"><up-button @click="shopListShow=true" size="small" shape="circle" color="#f6f6f6"
<view v-if="!addressInfo.address_id" class="m-card row"> :customStyle="{color:'#666666'}">修改</up-button></view>
<up-cell-group> </view>
<up-cell title="我的地址" :isLink="true" :border="false" @click="openAddress()"></up-cell> </view>
</up-cell-group> <view v-if="!addressInfo.address_id" class="m-card row">
</view> <up-cell-group>
<view v-else class="m-card m-address"> <up-cell title="我的地址" :isLink="true" :border="false" @click="openAddress()"></up-cell>
<view class="address-info"> </up-cell-group>
<view class="top"> </view>
<up-icon name="account"></up-icon> <view v-else class="m-card m-address">
<view class="t-name">{{addressInfo.real_name}}</view> <view class="address-info">
<view>{{addressInfo.phone}}</view> <view class="top">
</view> <up-icon name="account"></up-icon>
<view class="bottom u-line-2"> <view class="t-name">{{addressInfo.real_name}}</view>
{{addressInfo.detail}} <view>{{addressInfo.phone}}</view>
</view> </view>
</view> <view class="bottom u-line-2">
<view class="address-btn"> {{addressInfo.detail}}
<view style="width: 80px;"><up-button @click="showAddress = true" size="small" shape="circle" </view>
color="#f6f6f6" :customStyle="{color:'#666666'}">修改</up-button></view> </view>
</view> <view class="address-btn">
</view> <view style="width: 80px;"><up-button @click="showAddress = true" size="small" shape="circle" color="#f6f6f6"
<view class="m-card m-good" v-for="(item,index) in cartList" :key="index"> :customStyle="{color:'#666666'}">修改</up-button></view>
<view class="image"> </view>
<up-image width="160rpx" height="160rpx" :src="item.imgs"></up-image> </view>
</view> <view class="m-card m-good" v-for="(item,index) in cartList" :key="index">
<view class="body-content"> <view class="image">
<view> <up-image width="160rpx" height="160rpx" :src="item.imgs"></up-image>
<view class="title"> </view>
<view>{{item.name}}</view> <view class="body-content">
<view>¥{{item.price}}</view> <view>
</view> <view class="title">
<view class="tips"> <view>{{item.name}}</view>
<view>{{item.unit_name}}</view> <view>¥{{item.price}}</view>
<view>x{{item.cart_num}}</view> </view>
</view> <view class="tips">
</view> <view>{{item.unit_name}}</view>
<view class="time"> <view>x{{item.cart_num}}</view>
{{orderInfo.delivery_msg}} </view>
</view> </view>
</view> <view class="time">
</view> {{orderInfo.delivery_msg}}
<view class="m-card good-info"> </view>
<view class="head-title">价格明细</view> </view>
<view class="row"> </view>
<view>商品总价 <text>共计{{cartList.length}}款商品</text></view> <view class="m-card good-info">
<view><text>¥</text>{{c_price(orderInfo.total, 0)}}<text>.{{c_price(orderInfo.total, 1)}}</text></view> <view class="head-title">价格明细</view>
</view> <view class="row">
<view class="row"> <view>商品总价 <text>共计{{cartList.length}}款商品</text></view>
<view>运费</view> <view><text>¥</text>{{c_price(orderInfo.total, 0)}}<text>.{{c_price(orderInfo.total, 1)}}</text></view>
<view><text>¥</text>0<text>.00</text></view> </view>
</view> <view class="row">
</view> <view>运费</view>
<view class="m-card good-info"> <view><text>¥</text>0<text>.00</text></view>
<view class="head-title">支付方式</view> </view>
<view class="row"> </view>
<view class="icon-text"><up-icon name="weixin-circle-fill" color="#20b128" size="22" <view class="m-card good-info">
style="margin-right: 10rpx;"></up-icon> </view> <view class="head-title">支付方式</view>
<view class="icon"> <view class="row">
<image v-if="true" src="@/static/icon/check.png"></image> <view class="icon-text"><up-icon name="weixin-circle-fill" color="#20b128" size="22"
<image v-else src="@/static/icon/n-check.png"></image> style="margin-right: 10rpx;"></up-icon> </view>
</view> <view class="icon">
</view> <image v-if="true" src="@/static/icon/check.png"></image>
</view> <image v-else src="@/static/icon/n-check.png"></image>
<!-- <view class="m-card order-remark"> </view>
</view>
</view>
<!-- <view class="m-card order-remark">
<view class="head-title"> <view class="head-title">
<text>订单备注</text> <text>订单备注</text>
<text>0/200</text> <text>0/200</text>
@ -101,386 +105,405 @@
<up-textarea style="background-color: #F6F6F6;" v-model="formData.remark" placeholder="暂无备注内容" <up-textarea style="background-color: #F6F6F6;" v-model="formData.remark" placeholder="暂无备注内容"
:height="100"></up-textarea> :height="100"></up-textarea>
</view> --> </view> -->
<view style="width: 100%;height: 200rpx;"></view> <view style="width: 100%;height: 200rpx;"></view>
<view class="fiexd-btn-box"> <view class="fiexd-btn-box">
<view class="tips"> <view class="tips">
<view style="margin-right: 20rpx;"> {{ cartList.length }} </view> <view style="margin-right: 20rpx;"> {{ cartList.length }} </view>
<view class="all"> <view class="all">
<text style="color: #000;">合计: </text> <text style="color: #000;">合计: </text>
<text></text> <text></text>
<block v-if="orderInfo.total"> <block v-if="orderInfo.total">
<text style="font-size: 32rpx;font-weight: bold;">{{c_price(orderInfo.total, 0)}}</text> <text style="font-size: 32rpx;font-weight: bold;">{{c_price(orderInfo.total, 0)}}</text>
<text>.{{c_price(orderInfo.total, 1)}}</text> <text>.{{c_price(orderInfo.total, 1)}}</text>
</block> </block>
</view> </view>
</view> </view>
<view style="width: 200rpx;"> <view style="width: 200rpx;">
<up-button color="#20B128" shape="circle" @click="submitOrder" :throttleTime="1000">预付款提交</up-button> <up-button color="#20B128" shape="circle" @click="submitOrder" :throttleTime="1000">预付款提交</up-button>
</view> </view>
</view> </view>
<addressPopup ref="addressRef" :show="showAddress" :list="addressList" @close="showAddress=false" <addressPopup ref="addressRef" :show="showAddress" :list="addressList" @close="showAddress=false"
@change="changeAddress" /> @change="changeAddress" />
<shopListPopupVue ref="shopRef" :show="shopListShow" :list="merchantList" @close="shopListShow=false" <shopListPopupVue ref="shopRef" :show="shopListShow" :list="merchantList" @close="shopListShow=false"
@change="changeShop" @search="searchShop" /> @change="changeShop" @search="searchShop" />
<modal title="尚未设置收货地址" content="您还没有添加收货地址,请点击添加" cancleText="添加地址" confirmText="继续支付" :show="toastAddressShow" <modal title="尚未设置收货地址" content="您还没有添加收货地址,请点击添加" cancleText="添加地址" confirmText="继续支付" :show="toastAddressShow"
@close="addAddress" @change="goPay" /> @close="addAddress" @change="goPay" />
</view> <modal title="是否要拨打电话" :content="`即将拨打电话${phone}`" cancleText="取消" confirmText="拨打" :show="callShow" @close="callShow = false"
@change="onCall" />
</view>
</template> </template>
<script setup> <script setup>
import { import {
onLoad, onLoad,
onShow onShow
} from "@dcloudio/uni-app" } from "@dcloudio/uni-app"
import { import {
nextTick, nextTick,
ref ref
} from "vue" } from "vue"
import addressPopup from "@/components/addressPopup.vue"; import addressPopup from "@/components/addressPopup.vue";
import shopListPopupVue from "@/components/shopListPopup.vue"; import shopListPopupVue from "@/components/shopListPopup.vue";
import modal from "@/components/modal.vue" import useCartStore from "@/store/cart.js";
import useCartStore from "@/store/cart.js"; import modal from "@/components/modal.vue";
import { import {
checkOrderApi checkOrderApi
} from "@/api/cart.js"; } from "@/api/cart.js";
import { import {
addressListsApi, addressListsApi,
merchantListApi merchantListApi
} from "@/api/user.js"; } from "@/api/user.js";
import { import {
createOrderApi createOrderApi
} from "@/api/order.js"; } from "@/api/order.js";
const cartStore = useCartStore(); const cartStore = useCartStore();
const formData = ref({ const formData = ref({
remark: "" remark: ""
}) })
const isAddress = ref(false); const isAddress = ref(false);
const toastAddressShow = ref(false); const toastAddressShow = ref(false);
// //
const addressRef = ref(null); const addressRef = ref(null);
const showAddress = ref(false); const showAddress = ref(false);
const addressInfo = ref({}); const addressInfo = ref({});
const changeAddress = (e) => { const changeAddress = (e) => {
addressInfo.value = e; addressInfo.value = e;
showAddress.value = false; showAddress.value = false;
isAddress.value = true; isAddress.value = true;
} }
const openAddress = () => { const openAddress = () => {
if (addressList.length > 0) showAddress.value = true; if (addressList.length > 0) showAddress.value = true;
else uni.navigateTo({ else uni.navigateTo({
url: '/pagesOrder/addressEdit/addressEdit' url: '/pagesOrder/addressEdit/addressEdit'
}) })
} }
// //
const addressList = ref([]); const addressList = ref([]);
const getAddressList = () => { const getAddressList = () => {
addressListsApi().then(res => { addressListsApi().then(res => {
addressList.value = res.data.lists; addressList.value = res.data.lists;
addressList.value.forEach(item => { addressList.value.forEach(item => {
if (item.is_default) { if (item.is_default) {
addressInfo.value = item; addressInfo.value = item;
isAddress.value = true; isAddress.value = true;
} }
}) })
if (!isAddress.value && addressList.value.length > 0) { if (!isAddress.value && addressList.value.length > 0) {
addressInfo.value = addressList.value[0]; addressInfo.value = addressList.value[0];
isAddress.value = true; isAddress.value = true;
} }
if (addressInfo.value.address_id) { if (addressInfo.value.address_id) {
nextTick(() => { nextTick(() => {
addressRef.value.setCheck(addressInfo.value.address_id); addressRef.value.setCheck(addressInfo.value.address_id);
}) })
} }
}) })
} }
//
const shopRef = ref(null); //
const shopListShow = ref(false); const shopRef = ref(null);
const merchantList = ref([]); const shopListShow = ref(false);
const myAddressInfo = ref({ const merchantList = ref([]);
long: "", const myAddressInfo = ref({
lat: "" long: "",
}) lat: ""
const shopInfo = ref({ })
mer_id: '' const shopInfo = ref({
}); mer_id: ''
const getMerchantList = (mer_name = null) => { });
merchantListApi({ const getMerchantList = (mer_name = null) => {
...myAddressInfo.value, merchantListApi({
mer_name: mer_name ? mer_name : '' ...myAddressInfo.value,
}).then(res => { mer_name: mer_name ? mer_name : ''
merchantList.value = res.data.lists; }).then(res => {
if (mer_name === null && myAddressInfo.value.long && merchantList.value.length > 0 && !shopInfo merchantList.value = res.data.lists;
.value.mer_id) { if (mer_name === null && myAddressInfo.value.long && merchantList.value.length > 0 && !shopInfo
shopInfo.value = merchantList.value[0]; .value.mer_id) {
shopInfo.value = merchantList.value[0];
shopInfo.value.recommend = 1; shopInfo.value.recommend = 1;
nextTick(() => { nextTick(() => {
shopRef.value.setCheck(shopInfo.value.mer_id); shopRef.value.setCheck(shopInfo.value.mer_id);
}) })
} }
}) })
} }
getMerchantList(); getMerchantList();
// //
const LoadAddress = () => { const LoadAddress = () => {
uni.getLocation({ uni.getLocation({
success: (res) => {}, success: (res) => {},
fail: (err) => { fail: (err) => {
uni.$u.toast('定位失败, 请手动选择提货点!') uni.$u.toast('定位失败, 请手动选择提货点!')
}, },
complete: (res) => { complete: (res) => {
myAddressInfo.value.long = res.longitude || ""; myAddressInfo.value.long = res.longitude || "";
myAddressInfo.value.lat = res.latitude || ""; myAddressInfo.value.lat = res.latitude || "";
getMerchantList(); getMerchantList();
} }
}) })
} }
LoadAddress(); LoadAddress();
const changeShop = (e) => { const changeShop = (e) => {
shopInfo.value = e; shopInfo.value = e;
shopListShow.value = false; shopListShow.value = false;
} }
const searchShop = (e) => { const searchShop = (e) => {
getMerchantList(e) getMerchantList(e)
} }
//
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 addAddress = () => { const addAddress = () => {
toastAddressShow.value = false; toastAddressShow.value = false;
nextTick(() => { nextTick(() => {
showAddress.value = true; showAddress.value = true;
}) })
} }
// //
const goPay = () => { const goPay = () => {
toastAddressShow.value = false; toastAddressShow.value = false;
isAddress.value = true; isAddress.value = true;
submitOrder(); submitOrder();
} }
// //
const submitOrder = () => { const submitOrder = () => {
if (!shopInfo.value.mer_id) { if (!shopInfo.value.mer_id) {
uni.$u.toast('请先选择提货点'); uni.$u.toast('请先选择提货点');
return shopListShow.value = true; return shopListShow.value = true;
} }
if (!isAddress.value) return toastAddressShow.value = true; if (!isAddress.value) return toastAddressShow.value = true;
createOrder(); createOrder();
} }
// //
const cartList = ref([]); const cartList = ref([]);
const orderInfo = ref({}); const orderInfo = ref({});
const checkOrder = () => { const checkOrder = () => {
checkOrderApi({ checkOrderApi({
cart_id: cartStore.cartList cart_id: cartStore.cartList
}).then(res => { }).then(res => {
cartList.value = res.data.cart_list; cartList.value = res.data.cart_list;
orderInfo.value = res.data.order; orderInfo.value = res.data.order;
}) })
} }
const createOrder = () => { const createOrder = () => {
createOrderApi({ createOrderApi({
cart_id: cartStore.cartList, cart_id: cartStore.cartList,
address_id: addressInfo.value.address_id, address_id: addressInfo.value.address_id,
mer_id: shopInfo.value.mer_id, mer_id: shopInfo.value.mer_id,
pay_type: 1 pay_type: 1
}).then(res => { }).then(res => {
if (!res.data?.nonceStr) return uni.$u.toast('支付失败!'); if (!res.data?.nonceStr) return uni.$u.toast('支付失败!');
uni.requestPayment({ uni.requestPayment({
provider: 'wxpay', provider: 'wxpay',
timeStamp: res.data.timeStamp, timeStamp: res.data.timeStamp,
nonceStr: res.data.nonceStr, nonceStr: res.data.nonceStr,
package: res.data.package, package: res.data.package,
signType: res.data.signType, signType: res.data.signType,
paySign: res.data.paySign, paySign: res.data.paySign,
success: (e) => { success: (e) => {
if (e.errMsg == 'requestPayment:ok') { if (e.errMsg == 'requestPayment:ok') {
uni.showModal({ uni.showModal({
title: '订单支付成功', title: '订单支付成功',
confirmText: '查看订单', confirmText: '查看订单',
cancelText: '继续购买', cancelText: '继续购买',
success: (e) => { success: (e) => {
if (e.confirm) uni.redirectTo({ if (e.confirm) uni.redirectTo({
url: '/pagesOrder/order/order?back=-1&type=2' url: '/pagesOrder/order/order?back=-1&type=2'
}) })
else uni.navigateBack(); else uni.navigateBack();
} }
}) })
} else uni.$u.toast('支付失败') } else uni.$u.toast('支付失败')
}, },
fail: (e) => { fail: (e) => {
uni.$u.toast('用户取消支付') uni.$u.toast('用户取消支付')
} }
}) })
}).catch(err => { }).catch(err => {
uni.$u.toast('网络错误') uni.$u.toast('网络错误')
}) })
} }
const c_price = (price, index = 0) => { const c_price = (price, index = 0) => {
price = price + ''; price = price + '';
return price.split('.')[index] || (index ? '00' : '0'); return price.split('.')[index] || (index ? '00' : '0');
} }
onLoad(options => { onLoad(options => {
checkOrder(); checkOrder();
}) })
onShow(() => { onShow(() => {
getAddressList(); getAddressList();
}) })
</script> </script>
<style lang="scss"> <style lang="scss">
.m-card { .m-card {
margin: 20rpx; margin: 20rpx;
border-radius: 14rpx; border-radius: 14rpx;
background-color: #fff; background-color: #fff;
padding: 20rpx; padding: 20rpx;
} }
.row { .row {
padding: 0; padding: 0;
overflow: hidden; overflow: hidden;
} }
.m-address { .m-address {
margin-bottom: 20rpx; margin-bottom: 20rpx;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
color: #999999; color: #999999;
.address-info { .address-info {
width: 510rpx; width: 510rpx;
.top { .top {
display: flex; display: flex;
font-size: 28rpx; font-size: 28rpx;
.t-name { .t-name {
color: #444; color: #444;
margin: 0 10rpx; margin: 0 10rpx;
} }
} }
.bottom { .bottom {
font-size: 24rpx; font-size: 24rpx;
} }
} }
} }
.m-good { .m-good {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
margin-bottom: 20rpx; margin-bottom: 20rpx;
.image { .image {
width: 160rpx; width: 160rpx;
height: 160rpx; height: 160rpx;
margin-right: 20rpx; margin-right: 20rpx;
border-radius: 14rpx; border-radius: 14rpx;
overflow: hidden; overflow: hidden;
} }
.body-content { .body-content {
width: 490rpx; width: 490rpx;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-between; justify-content: space-between;
color: #989898; color: #989898;
.title { .title {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
font-size: 28rpx; font-size: 28rpx;
color: #444; color: #444;
} }
.tips { .tips {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
font-size: 24rpx; font-size: 24rpx;
margin-top: 10rpx; margin-top: 10rpx;
} }
.time { .time {
background-color: #F6F6F6; background-color: #F6F6F6;
padding: 5rpx 10rpx; padding: 5rpx 10rpx;
font-size: 26rpx; font-size: 26rpx;
color: #444; color: #444;
border-radius: 10rpx; border-radius: 10rpx;
} }
} }
} }
.good-info { .good-info {
margin-bottom: 20rpx; margin-bottom: 20rpx;
.head-title { .head-title {
margin-bottom: 18rpx; margin-bottom: 18rpx;
color: #000; color: #000;
font-weight: bold; font-weight: bold;
} }
.row { .row {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
margin-bottom: 18rpx; margin-bottom: 18rpx;
.red { .red {
color: #F55726; color: #F55726;
} }
.icon-text { .icon-text {
display: flex; display: flex;
} }
.icon { .icon {
image { image {
width: 40rpx; width: 40rpx;
height: 40rpx; height: 40rpx;
} }
} }
} }
.row-need { .row-need {
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
color: #F55726; color: #F55726;
} }
text { text {
font-size: 22rpx; font-size: 22rpx;
} }
} }
.order-remark { .order-remark {
.head-title { .head-title {
margin-bottom: 18rpx; margin-bottom: 18rpx;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
} }
} }
.tips { .tips {
font-size: 28rpx; font-size: 28rpx;
color: #999; color: #999;
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
align-items: center; align-items: center;
flex: 1; flex: 1;
margin-right: 20rpx; margin-right: 20rpx;
.all { .all {
color: #F55726; color: #F55726;
} }
} }
</style> </style>