更新优化,修复bug

This commit is contained in:
weipengfei 2024-05-08 14:50:27 +08:00
parent 08fbd02dca
commit 605acbe2b9
11 changed files with 261 additions and 75 deletions

View File

@ -28,4 +28,9 @@ export const orderCountApi = (data)=>{
//取消订单
export const cancelOrderApi = (data)=>{
return request.post('/order/RetailOrder/cancel_order', data);
}
//订单确认收货
export const confirmReceiptApi = (data)=>{
return request.post('/order/RetailOrder/confirm_receipt', data);
}

View File

@ -5,21 +5,24 @@
<view class="list-admin">
<view>常用地址</view>
<view class="admin-btn">
<view class="btn" @click="navTo('/pagesOrder/addressList/addressList')"><up-icon name="edit-pen" color="#20B128"></up-icon></view>
<view class="btn" @click="navTo('/pagesOrder/addressEdit/addressEdit')"><up-icon name="plus" color="#20B128"></up-icon></view>
<view class="btn" @click="navTo('/pagesOrder/addressList/addressList')"><up-icon name="edit-pen"
color="#20B128"></up-icon></view>
<view class="btn" @click="navTo('/pagesOrder/addressEdit/addressEdit')"><up-icon name="plus"
color="#20B128"></up-icon></view>
</view>
</view>
<scroll-view style="height: 600rpx;padding-bottom: 20rpx;" scroll-y>
<view class="row" v-for="(item,index) in list" :key="index" @click="addressType=index">
<view class="row" v-for="(item,index) in list" :key="index" @click="addressType=item.address_id">
<view class="content">
<view class="top">
<view class="name">{{item.real_name}}</view>
<view class="phone">{{item.phone}}</view>
<u-tag v-if="item.is_default" style="pointer-events: none;" text="默认" type="success" plain size="mini"></u-tag>
<u-tag v-if="item.is_default" style="pointer-events: none;" text="默认" type="success" plain
size="mini"></u-tag>
</view>
<view class="bottom u-line-2">{{item.detail}}</view>
</view>
<image v-if="addressType==index" src="@/static/icon/check.png"></image>
<image v-if="addressType==item.address_id" src="@/static/icon/check.png"></image>
<image v-else src="@/static/icon/n-check.png"></image>
</view>
</scroll-view>
@ -40,8 +43,8 @@
},
list: {
type: Array,
default: ()=>[]
}
default: () => []
},
})
const emit = defineEmits(['close', 'change']);
@ -50,14 +53,23 @@
}
const submitAddress = () => {
emit('change', props.list[addressType.value]);
let e = props.list.find(item=>item.address_id==addressType.value);
if(addressType.value<=0 || !e) return uni.$u.toast('请选择地址');
emit('change', e);
}
const navTo = (url)=>{
const navTo = (url) => {
uni.navigateTo({
url: url
})
}
const setCheck = (e)=>{
addressType.value = e;
}
defineExpose({
setCheck
})
</script>
<style scoped lang="scss">
@ -83,7 +95,7 @@
margin-left: 20rpx;
display: flex;
align-items: center;
&:active {
color: rgba(#20B128, 0.8);
transition: background-color 0.5s;

View File

@ -7,7 +7,7 @@
@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=index">
<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>
@ -20,7 +20,7 @@
{{item.mer_address||'sdsd'}}
</view>
<view class="check">
<image style="width: 36rpx;height: 36rpx" v-if="addressType==index"
<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>
@ -56,7 +56,9 @@
}
const submitAddress = () => {
emit('change', props.list[addressType.value]);
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('')
@ -69,6 +71,13 @@
url: url
})
}
const setCheck = (e)=>{
addressType.value = e;
}
defineExpose({
setCheck
})
</script>
<style scoped lang="scss">

View File

@ -8,7 +8,7 @@ let env = "prod"
switch(env){
case 'prod': BASE_URL = 'https://erp.lihaink.cn';break;
case 'test': BASE_URL = 'https://ceshi-erp.lihaink.cn';break;
default: BASE_URL = 'http://192.168.1.22:8546';
default: BASE_URL = 'http://192.168.1.15:8546';
}
let HTTP_REQUEST_URL

View File

@ -55,7 +55,7 @@
<scroll-view scroll-y style="height: 100%;width: 100%;">
<view class="page-box1">
<view v-if="frequentlyList.length>0" class="list">
<view class="shop-item" v-for="(item, index) in c" :key="index" @click="openGoodPopup(item)">
<view class="shop-item" v-for="(item, index) in frequentlyList" :key="index" @click="openGoodPopup(item)">
<image class="shop-img" :src="item.imgs"></image>
<view class="shop-content" style="width: 490rpx;">
<view class="title">
@ -368,7 +368,7 @@
align-items: center;
.num {
width: 60rpx;
margin: 0 20rpx;
text-align: center;
}
}

View File

@ -26,7 +26,7 @@
<view class="list-item" @click="navTo(2)">
<image src="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/45241202404261403353935.png"></image>
<view class="">待收货</view>
<view class="badge" v-if="orderCount.waiting">{{orderCount.waiting}}</view>
<view class="badge" v-if="orderCount.receiving">{{orderCount.receiving}}</view>
</view>
<!-- <view class="list-item">
<image src="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/96915202404261403582769.png"></image>
@ -60,6 +60,7 @@
import { ref } from "vue";
import useUserStore from "@/store/user";
import { orderCountApi } from "@/api/order.js";
import { onShow } from "@dcloudio/uni-app"
const userStore = useUserStore();
@ -75,7 +76,6 @@
orderCount.value = res.data;
})
}
getOrderCount();
const navTo = (type=0) => {
uni.navigateTo({
@ -90,6 +90,10 @@
url: '/pages/login/login'
})
}
onShow(()=>{
getOrderCount();
})
</script>
<style lang="scss">
@ -153,7 +157,7 @@
left: 0;
z-index: 3;
background-image: url('https://lihai001.oss-cn-chengdu.aliyuncs.com/def/a8863202404261349533191.png');
background-size: 28% 100%;
background-size: 35% 100%;
background-position: right;
background-repeat: no-repeat;

View File

@ -3,6 +3,28 @@
<view class="count_down" v-if="datas.paid==0&&countDown">
还剩<text>{{countDown}}</text>订单自动取消
</view>
<view class="m-card m-address" style="margin-top: 20rpx;">
<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}}</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 class="m-card m-address" style="margin-top: 20rpx;">
<view class="address-info">
<view class="top">
@ -110,28 +132,32 @@
<block v-else>
<view></view>
<view style="width: 450rpx;">
<up-button v-if="datas.status==0||datas.status==1" color="#20B128" shape="circle" @click="">确认收货</up-button>
<up-button v-else color="#20B128" shape="circle" @click="">再次购买</up-button>
<up-button v-if="datas.status==0||datas.status==1" color="#20B128" shape="circle" @click="showTake=true">确认收货</up-button>
<up-button v-else color="#20B128" plain shape="circle" @click="">再次购买</up-button>
</view>
</block>
</view>
<orderCanclePopup :show="showCancel" @close="showCancel=false" @change="submitCancel" />
<addressPopup v-if="addressList.length>0" :show="showAddress" :list="addressList" @close="showAddress=false" @change="changeAddress" />
<modal :show="false" content="您还没有添加收货地址,请点击添加"></modal>
<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 :show="showTake" title="确认收货" content="请确认您已收到货" @close="showTake=false" @change="confirmReceipt"></modal>
</view>
</template>
<script setup>
import { onLoad, onBackPress } from "@dcloudio/uni-app";
import { ref } from "vue";
import { nextTick, ref } from "vue";
import addressPopup from "@/components/addressPopup.vue";
import orderCanclePopup from "@/components/orderCanclePopup.vue";
import shopListPopupVue from "@/components/shopListPopup.vue";
import modal from "@/components/modal.vue";
import { orderDetailApi, cancelOrderApi, rePaymentApi } from "@/api/order.js"
import { orderDetailApi, cancelOrderApi, rePaymentApi, confirmReceiptApi } from "@/api/order.js"
import { addressListsApi, merchantListApi } from "@/api/user.js";
const showCancel = ref(false);
const showTake = ref(false);
const submitCancel = (e) => {
showCancel.value = false;
@ -157,6 +183,21 @@
order_id: datas.value.id
}).then(res=>{
datas.value = res.data;
shopInfo.value = res.data.merchant_info;
if(addressList.value.length>0 && res.data.paid){
addressInfo.value = addressList.value.find(item=>item.address_id == res.data.address_id);
}else {
addressInfo.value = {
address_id: res.data.address_id,
real_name: res.data.real_name,
phone: res.data.user_phone,
detail: res.data.user_address
}
}
nextTick(()=>{
shopRef.value.setCheck(shopInfo.value.mer_id);
addressRef.value.setCheck(addressInfo.value.address_id);
})
if(!res.data.paid){
targetDate = new Date(res.data.create_time).getTime() + 30*60*1000;
//
@ -173,6 +214,20 @@
return price.split('.')[index] || (index ? '00' : '0');
}
//
const addressRef = ref(null);
const showAddress = ref(false);
const addressInfo = ref({});
const changeAddress = (e) => {
addressInfo.value = e;
showAddress.value = false;
}
const openAddress = ()=>{
if(addressList.length>0) showAddress.value=true;
else uni.navigateTo({
url: '/pagesOrder/addressEdit/addressEdit'
})
}
//
const addressList = ref([]);
const getAddressList = ()=>{
@ -186,26 +241,67 @@
if(addressList.value.length>0){
addressInfo.value = addressList.value[0];
}
if(addressInfo.value.address_id) nextTick(()=>{
addressRef.value.setCheck(addressInfo.value.address_id);
})
})
}
getAddressList();
//
const showAddress = ref(false);
const addressInfo = ref({});
const changeAddress = (e) => {
addressInfo.value = e;
showAddress.value = false;
const shopRef = ref(false);
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];
nextTick(()=>{
shopRef.value.setCheck(shopInfo.value.mer_id);
})
}
})
}
const openAddress = ()=>{
if(addressList.length>0) showAddress.value=true;
else uni.navigateTo({
url: '/pagesOrder/addressEdit/addressEdit'
})
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();
}
})
}
const changeShop = (e) => {
LoadAddress();
shopInfo.value = e;
shopListShow.value = false;
}
const searchShop = (e) => {
getMerchantList(e)
}
const rePay = ()=>{
rePaymentApi({
order_id: datas.value.id,
mer_id: shopInfo.value.mer_id,
address_id: addressInfo.value.address_id,
pay_type: 1
}).then(res=>{
if(!res.data?.nonceStr) return uni.$u.toast('支付失败!');
@ -264,6 +360,21 @@
countDown.value = ""
}
}
//
const confirmReceipt = ()=>{
confirmReceiptApi({
order_id: datas.value.id
}).then(res=>{
showTake.value = false;
uni.$u.toast('确认收货成功');
uni.navigateBack({
success: () => {
uni.$emit('reLoadOrderList');
}
})
})
}
onLoad((option) => {
uni.setNavigationBarTitle({

View File

@ -27,11 +27,11 @@
</view>
<view v-if="datas.paid==0" class="item-btn">
<view style="width: 80px;"><up-button size="small" plain color="#989898" shape="circle" @click="cancleOrder">取消订单</up-button></view>
<view style="width: 80px;"><up-button size="small" plain color="#20B128" shape="circle" @click="rePay">立即支付</up-button></view>
<view style="width: 80px;"><up-button size="small" color="#20B128" shape="circle" @click="rePay">立即支付</up-button></view>
</view>
<view v-else class="item-btn">
<!-- <view style="width: 80px;"><up-button size="small" plain color="#989898" shape="circle">申请售后</up-button></view> -->
<view v-if="datas.status==1" style="width: 80px;"><up-button size="small" plain color="#20B128"
<view @click="takeOrder" v-if="datas.status==1" style="width: 80px;"><up-button size="small" color="#20B128"
shape="circle">确认收货</up-button></view>
<view v-if="datas.status==2||datas.status==3" style="width: 80px;"><up-button size="small" plain color="#20B128"
shape="circle">再次购买</up-button></view>
@ -67,11 +67,15 @@
})
}
const emit = defineEmits(['cancleOrder', 'rePay']);
const emit = defineEmits(['cancleOrder', 'rePay', 'takeOrder']);
const cancleOrder = ()=>{
emit('cancleOrder', props.datas)
}
const takeOrder = ()=>{
emit('takeOrder', props.datas)
}
const rePay = ()=>{
emit('rePay', props.datas)
}

View File

@ -19,7 +19,7 @@
<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="loadMoreGood">
<view class="page-box">
<view v-if="list.length>0" class="list">
<good v-for="(item, index) in list" :datas="item" :key="index" :type="k" @cancleOrder="cancleOrder"
<good v-for="(item, index) in list" :datas="item" :key="index" :type="k" @cancleOrder="cancleOrder" @takeOrder="takeOrder"
@rePay="rePay"></good>
</view>
<view v-if="!where[k].loading&&list.length==0" style="padding-top: 100rpx;">
@ -40,16 +40,17 @@
</swiper-item>
</swiper>
<orderCanclePopup :show="showCancel" @close="showCancel=false" @change="submitCancel" />
<modal :show="showTake" title="确认收货" content="请确认您已收到货" @close="showTake=false" @change="confirmReceipt"></modal>
</view>
</template>
<script setup>
import { onLoad } from "@dcloudio/uni-app"
import { onLoad, onUnload } from "@dcloudio/uni-app"
import { ref } from 'vue';
import good from "./component/good.vue";
import orderCanclePopup from "@/components/orderCanclePopup.vue"
import { orderListApi } from "@/api/order.js";
import { cancelOrderApi, rePaymentApi } from "@/api/order.js"
import modal from "@/components/modal.vue"
import { cancelOrderApi, rePaymentApi, confirmReceiptApi, orderListApi } from "@/api/order.js"
const tabsActive = ref(0)
const changeTab = ({ index }) => {
@ -69,9 +70,10 @@
tabsActive.value = current;
if (swiperCurrent.value == 0 && orderList.value[0].length == 0) getOrderList(0);
if (swiperCurrent.value == 1 && orderList.value[1].length == 0) getOrderList(1, '', 0);
if (swiperCurrent.value == 2 && orderList.value[2].length == 0) getOrderList(2, 0);
if (swiperCurrent.value == 2 && orderList.value[2].length == 0) getOrderList(2, 1);
}
//
const showCancel = ref(false);
let cancelId = '';
const submitCancel = (e) => {
@ -91,10 +93,29 @@
cancelId = e.id;
showCancel.value = true;
}
//
const showTake = ref(false);
let takeId = "";
const takeOrder = (e) => {
takeId = e.id;
showTake.value = true;
}
const confirmReceipt = ()=>{
confirmReceiptApi({
order_id: takeId
}).then(res=>{
showTake.value = false;
uni.$u.toast('确认收货成功');
reloadAll();
})
}
const rePay = (e) => {
rePaymentApi({
order_id: e.id,
address_id: e.address_id,
mer_id: e.merchant,
pay_type: 1
}).then(res => {
if (!res.data?.nonceStr) return uni.$u.toast('支付失败!');
@ -111,7 +132,7 @@
title: '订单支付成功',
icon: 'success'
})
getOrderList(1, '', 0);
reloadAll();
} else uni.$u.toast('支付失败')
},
fail: (e) => {
@ -171,7 +192,7 @@
const loadMoreGood = ()=>{
if (swiperCurrent.value == 0) getOrderList(0);
if (swiperCurrent.value == 1) getOrderList(1, '', 0);
if (swiperCurrent.value == 2) getOrderList(2, 0);
if (swiperCurrent.value == 2) getOrderList(2, 1);
}
//
@ -181,7 +202,7 @@
where.value[+swiperCurrent.value].loadend = false;
if (swiperCurrent.value == 0) getOrderList(0);
if (swiperCurrent.value == 1) getOrderList(1, '', 0);
if (swiperCurrent.value == 2) getOrderList(2, 0);
if (swiperCurrent.value == 2) getOrderList(2, 1);
}
let back = 0;
@ -190,6 +211,16 @@
delta: back ? +back : 0
})
}
const reloadAll = () => { //
where.value.forEach(item=>{
item.page_no = 1;
item.loadend = false;
});
getOrderList(1, '', 0);
getOrderList(0);
getOrderList(2, 1);
}
onLoad((options) => {
if (options.type) {
@ -200,14 +231,13 @@
if(options.back) back = options.back;
// getOrderList(0);
// getOrderList(1, '', 0);
// getOrderList(2, 0);
// getOrderList(2, 1);
uni.$on('reLoadOrderList', () => { //
where.value.forEach(item=>item.page_no=1);
getOrderList(1, '', 0);
getOrderList(0);
getOrderList(2, 0);
});
uni.$on('reLoadOrderList', reloadAll);
})
onUnload(()=>{
uni.$off('reLoadOrderList', reloadAll)
})
</script>

View File

@ -116,9 +116,9 @@
</view>
</view>
<addressPopup v-if="addressList.length>0" :show="showAddress" :list="addressList" @close="showAddress=false"
<addressPopup ref="addressRef" :show="showAddress" :list="addressList" @close="showAddress=false"
@change="changeAddress" />
<shopListPopupVue v-if="merchantList.length>0" :show="shopListShow" :list="merchantList"
<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" />
@ -159,24 +159,8 @@
const toastAddressShow = ref(false);
//
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;
}
})
}
//
const addressRef = ref(null);
const showAddress = ref(false);
const addressInfo = ref({});
const changeAddress = (e) => {
@ -190,8 +174,32 @@
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 shopRef = ref(null);
const shopListShow = ref(false);
const merchantList = ref([]);
const myAddressInfo = ref({
@ -210,6 +218,9 @@
if (mer_name === null && myAddressInfo.value.long && merchantList.value.length > 0 && !shopInfo
.value.mer_id) {
shopInfo.value = merchantList.value[0];
nextTick(()=>{
shopRef.value.setCheck(shopInfo.value.mer_id);
})
}
})
}

View File

@ -24,7 +24,7 @@ const useUserStore = defineStore("user", () => {
}
// #ifdef H5
token.value = "0f680a9bc1cdccd7ce588a2a58029411"
token.value = "1df48a21913ef4eba488983e7b84c056"
// token.value = "95b24dd6d2dda836fe07854b08ba0944"
userInfo.value = {
avatar: "https://lihaiim.oss-cn-chengdu.aliyuncs.com/image/admin/default_avatar.png",