订单

parent d200caea
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
{ {
"path": "pages/order/order", "path": "pages/order/order",
"style": { "style": {
"navigationBarTitleText": "订单列表" "navigationBarTitleText": "订单列表",
"enablePullDownRefresh": true
} }
}, },
{ {
...@@ -59,7 +60,8 @@ ...@@ -59,7 +60,8 @@
{ {
"path": "pages/ticket/ticket", "path": "pages/ticket/ticket",
"style": { "style": {
"navigationBarTitleText": "我的券" "navigationBarTitleText": "我的券",
"enablePullDownRefresh": true
} }
}, },
{ {
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
></wd-icon> ></wd-icon>
<view class="status-text">{{ statusList[orderDetail.orderStore.status] }}</view> <view class="status-text">{{ statusList[orderDetail.orderStore.status] }}</view>
</view> </view>
<view class="detail" v-if="orderDetail.orderStore.subStatus == 3"> <view class="detail" v-if="orderDetail.orderStore.status == 3">
请在{{ orderDetail.orderStore.receiverTime.slice(0, 4) }}{{ 请在{{ orderDetail.orderStore.receiverTime.slice(0, 4) }}{{
orderDetail.orderStore.receiverTime.slice(5, 7) orderDetail.orderStore.receiverTime.slice(5, 7)
}}{{ orderDetail.orderStore.receiverTime.slice(8, 10) }}前到店消费 }}{{ orderDetail.orderStore.receiverTime.slice(8, 10) }}前到店消费
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
<view class="info-box"> <view class="info-box">
<view <view
class="between" class="between"
v-if="orderDetail.orderStore.subStatus == 2 || orderDetail.orderStore.subStatus == 3" v-if="orderDetail.orderStore.status == 2 || orderDetail.orderStore.status == 3"
> >
<view class="column"> <view class="column">
<text class="title">券码信息(1张可用)</text> <text class="title">券码信息(1张可用)</text>
...@@ -68,17 +68,15 @@ ...@@ -68,17 +68,15 @@
<view class="column"> <view class="column">
<text <text
class="title1" class="title1"
v-if=" v-if="orderDetail.orderStore.status != 2 || orderDetail.orderStore.status != 3"
orderDetail.orderStore.subStatus != 2 || orderDetail.orderStore.subStatus != 3
"
> >
券码信息 券码信息
</text> </text>
<text <text
:class=" :class="
orderDetail.orderStore.subStatus == 5 || orderDetail.orderStore.status == 5 ||
orderDetail.orderStore.subStatus == 6 || orderDetail.orderStore.status == 6 ||
orderDetail.orderStore.subStatus == 7 orderDetail.orderStore.status == 7
? 'linethrough' ? 'linethrough'
: 'phone' : 'phone'
" "
...@@ -235,8 +233,8 @@ import { getOrderDetail, getShopDetail, getProdDetail } from '@/api/order'; ...@@ -235,8 +233,8 @@ import { getOrderDetail, getShopDetail, getProdDetail } from '@/api/order';
import { getDistance } from '@/utils/common'; import { getDistance } from '@/utils/common';
onShow(() => { onShow(() => {
// 获取位置 // 获取位置并计算距离
getLocationFn(); calculateDistance();
}); });
// 当前位置的经纬度 // 当前位置的经纬度
...@@ -313,6 +311,8 @@ const shopDetail = ref(); ...@@ -313,6 +311,8 @@ const shopDetail = ref();
const getShopMailDetail = async (id) => { const getShopMailDetail = async (id) => {
const res = await getShopDetail({ shopId: id }); const res = await getShopDetail({ shopId: id });
shopDetail.value = res.data.shop; shopDetail.value = res.data.shop;
// 获取位置并计算距离
calculateDistance();
}; };
const maskPhoneNumber = (phone) => { const maskPhoneNumber = (phone) => {
...@@ -320,20 +320,40 @@ const maskPhoneNumber = (phone) => { ...@@ -320,20 +320,40 @@ const maskPhoneNumber = (phone) => {
}; };
function getLocationFn() { function getLocationFn() {
xma.getLocation({ return new Promise((resolve, reject) => {
type: 'wgs84', xma.getLocation({
success: function (res) { type: 'wgs84',
const myLatitude = currentLatitudeAndLongitude.value.latitude; isHighAccuracy: true,
const myLongitude = currentLatitudeAndLongitude.value.longitude; success: function (res) {
const distance = getDistance(res.latitude, res.longitude, myLatitude, myLongitude, 1); // 经纬度
shopDetail.value.distance = distance; console.log('res.latitude, res.longitude', res.latitude, res.longitude);
}, resolve({ lat: res.latitude, lon: res.longitude });
fail: function (err) { },
return err; fail: function (err) {
}, return err;
},
});
}); });
} }
// 计算距离的函数封装
async function calculateDistance() {
try {
const res = await getLocationFn();
const distance = getDistance(
res.lat,
res.lon,
shopDetail.value.shopLat,
shopDetail.value.shopLng,
1,
);
shopDetail.value.distance = distance;
console.log('distance', distance, shopDetail.value.shopLat, shopDetail.value.shopLng);
} catch (error) {
console.error('Error calculating distance:', error);
}
}
/** /**
* 拨打商家电话 * 拨打商家电话
* @param {*} phoneNumber * @param {*} phoneNumber
......
...@@ -98,7 +98,19 @@ ...@@ -98,7 +98,19 @@
</view> </view>
</view> </view>
<wd-loadmore :state="state" @reload="getList" /> <!-- <wd-loadmore :state="state" @reload="getList" /> -->
<view
style="
width: 100%;
text-align: center;
font-size: 24rpx;
margin-top: 10rpx;
color: #888989;
"
v-if="isEnd"
>
没有更多啦~
</view>
</view> </view>
<wd-status-tip image="content" tip="暂无内容" v-else /> <wd-status-tip image="content" tip="暂无内容" v-else />
</wd-tab> </wd-tab>
...@@ -194,10 +206,18 @@ onShow(() => { ...@@ -194,10 +206,18 @@ onShow(() => {
} }
}); });
onPullDownRefresh(() => {
initDataList().then(() => {
getList();
xma.stopPullDownRefresh();
});
});
// 触底函数 // 触底函数
onReachBottom(() => { onReachBottom(() => {
if (dataList.value.length >= total.value) { if (dataList.value.length >= total.value) {
state.value = 'finished'; isEnd.value = true;
// state.value = 'finished';
} else { } else {
getList(); getList();
} }
...@@ -208,7 +228,8 @@ onReachBottom(() => { ...@@ -208,7 +228,8 @@ onReachBottom(() => {
*/ */
const total = ref(0); const total = ref(0);
const dataList = ref([]); const dataList = ref([]);
const state = ref('loading'); // const state = ref('loading');
const isEnd = ref(false);
const catalog = reactive({ const catalog = reactive({
current: 0, current: 0,
size: 10, size: 10,
...@@ -219,13 +240,21 @@ const catalog = reactive({ ...@@ -219,13 +240,21 @@ const catalog = reactive({
orderType: 'store', // 团购到店-store,外卖订单-takeaway,筑农物流logistics orderType: 'store', // 团购到店-store,外卖订单-takeaway,筑农物流logistics
}); });
const getList = async () => { const getList = async () => {
if (isEnd.value) return;
catalog.status = tab.value; catalog.status = tab.value;
if (tab.value === 'all') { if (tab.value === 'all') {
catalog.status = ''; catalog.status = '';
} }
catalog.current++; catalog.current++;
state.value = 'loading'; // state.value = 'loading';
xma.showLoading({
title: '加载中...',
mask: true,
});
const res = await getOrderList(catalog); const res = await getOrderList(catalog);
if (res.data.records.length < catalog.size) {
isEnd.value = true;
}
if (res.data.records.length > 0) { if (res.data.records.length > 0) {
res.data.records.forEach((item) => { res.data.records.forEach((item) => {
// 待付款倒计时计算 // 待付款倒计时计算
...@@ -236,7 +265,8 @@ const getList = async () => { ...@@ -236,7 +265,8 @@ const getList = async () => {
dataList.value.push(...res.data.records); dataList.value.push(...res.data.records);
total.value = res.data.total; total.value = res.data.total;
} }
state.value = 'finished'; // state.value = 'finished';
xma.hideLoading();
}; };
/** /**
...@@ -244,17 +274,22 @@ const getList = async () => { ...@@ -244,17 +274,22 @@ const getList = async () => {
*/ */
const handleChange = (e) => { const handleChange = (e) => {
tab.value = e.name; tab.value = e.name;
initDataList(); initDataList().then(() => {
getList();
});
}; };
/** /**
* 刷新订单列表 * 刷新订单列表
*/ */
const initDataList = () => { const initDataList = () => {
dataList.value = []; return new Promise((resolve, reject) => {
total.value = 0; dataList.value = [];
catalog.current = 0; total.value = 0;
getList(); catalog.current = 0;
isEnd.value = false;
resolve();
});
}; };
/** /**
...@@ -262,17 +297,24 @@ const initDataList = () => { ...@@ -262,17 +297,24 @@ const initDataList = () => {
* @param {*} orderNumber * @param {*} orderNumber
*/ */
const handleDelete = (orderNumber) => { const handleDelete = (orderNumber) => {
uni.showModal({ xma.showModal({
title: '提示', title: '提示',
content: '确定要删除订单吗?', content: '确定要删除订单吗?',
success: async (res) => { success: async (res) => {
if (res.confirm) { if (res.confirm) {
const res = await deleteOrderApi(orderNumber); xma.showLoading({
uni.showToast({ title: '删除中...',
mask: true,
});
await deleteOrderApi(orderNumber);
xma.hideLoading();
xma.showToast({
title: '删除成功', title: '删除成功',
icon: 'success', icon: 'success',
}); });
initDataList(); initDataList().then(() => {
getList();
});
} }
}, },
}); });
...@@ -283,17 +325,24 @@ const handleDelete = (orderNumber) => { ...@@ -283,17 +325,24 @@ const handleDelete = (orderNumber) => {
* @param {*} orderNumber * @param {*} orderNumber
*/ */
const handleCancel = (orderNumber) => { const handleCancel = (orderNumber) => {
uni.showModal({ xma.showModal({
title: '提示', title: '提示',
content: '确定要取消订单吗?', content: '确定要取消订单吗?',
success: async (res) => { success: async (res) => {
if (res.confirm) { if (res.confirm) {
const res = await cancelOrderApi({ orderNumber }); xma.showLoading({
uni.showToast({ title: '取消中...',
mask: true,
});
await cancelOrderApi({ orderNumber });
xma.hideLoading();
xma.showToast({
title: '取消成功', title: '取消成功',
icon: 'success', icon: 'success',
}); });
initDataList(); initDataList().then(() => {
getList();
});
} }
}, },
}); });
...@@ -348,7 +397,9 @@ const calculateCountdown = (item) => { ...@@ -348,7 +397,9 @@ const calculateCountdown = (item) => {
*/ */
const onFinish = async (orderNumber) => { const onFinish = async (orderNumber) => {
await cancelOrderApi({ orderNumber }); await cancelOrderApi({ orderNumber });
initDataList(); initDataList().then(() => {
getList();
});
}; };
const handleDetail = (id) => { const handleDetail = (id) => {
......
...@@ -42,6 +42,8 @@ ...@@ -42,6 +42,8 @@
image-mode="aspectFill" image-mode="aspectFill"
:action="action" :action="action"
@change="handleChange" @change="handleChange"
:header="headers"
accept="image"
></wd-upload> ></wd-upload>
</view> </view>
<view class="content-between" @tap="showPop = true"> <view class="content-between" @tap="showPop = true">
...@@ -97,11 +99,18 @@ ...@@ -97,11 +99,18 @@
<script setup> <script setup>
import Header from '@/pages/order/components/Header/index.vue'; import Header from '@/pages/order/components/Header/index.vue';
import { applyForARefundApi, getOrderDetail } from '@/api/order'; import { applyForARefundApi, getOrderDetail } from '@/api/order';
import { getToken } from '@/utils/auth';
const fileDomain = import.meta.env.VITE_APP_IMG_URL; const fileDomain = import.meta.env.VITE_APP_IMG_URL;
const token = getToken();
// 上传图片地址
const action = ref(import.meta.env.VITE_APP_BASE_URL + '/sgyrdd/file/update');
const headers = ref('');
// 订单号
const orderNumber = ref(''); const orderNumber = ref('');
onLoad((options) => { onLoad((options) => {
orderNumber.value = options.orderNumber; orderNumber.value = options.orderNumber;
headers.value = { Authorization: 'Bearer ' + token };
getDetail(); getDetail();
}); });
...@@ -114,11 +123,14 @@ const getDetail = async () => { ...@@ -114,11 +123,14 @@ const getDetail = async () => {
orderDetail.value = res.data; orderDetail.value = res.data;
}; };
/**
* 获取图片列表
*/
// 上传文件地址
const fileList = ref([]); const fileList = ref([]);
const action = ref('');
function handleChange({ fileList: files }) { function handleChange({ fileList: files }) {
console.log(files);
fileList.value = files; fileList.value = files;
console.log(fileList.value);
} }
const showPop = ref(false); const showPop = ref(false);
...@@ -151,6 +163,9 @@ function radioChange(evt) { ...@@ -151,6 +163,9 @@ function radioChange(evt) {
selectType.value = value; selectType.value = value;
} }
/**
* 提交申请
*/
const submit = async () => { const submit = async () => {
if (!selectType.value) { if (!selectType.value) {
return xma.showToast({ return xma.showToast({
...@@ -171,8 +186,8 @@ const submit = async () => { ...@@ -171,8 +186,8 @@ const submit = async () => {
await applyForARefundApi({ await applyForARefundApi({
orderNumber: orderNumber.value, orderNumber: orderNumber.value,
refundMemo: refundMemo:
selectType.value === 4 ? otherReason.value : reasonList.value[selectType.value].name, selectType.value === '4' ? otherReason.value : reasonList.value[selectType.value].name,
imgs: fileList.value.map((item) => item.url), imgs: processingImageAddresses(),
}); });
setTimeout(() => { setTimeout(() => {
xma.hideLoading(); xma.hideLoading();
...@@ -188,6 +203,19 @@ const submit = async () => { ...@@ -188,6 +203,19 @@ const submit = async () => {
}, 1500); }, 1500);
}; };
/**
* 图片地址处理
*/
const processingImageAddresses = () => {
const data = fileList.value.map((item) => {
return JSON.parse(item.response).data.url;
});
return data.join(',');
};
/**
* 提交申请
*/
const chooseReason = () => { const chooseReason = () => {
if (!selectType.value) { if (!selectType.value) {
return xma.showToast({ return xma.showToast({
......
...@@ -138,8 +138,8 @@ import Header from '@/pages/order/components/Header/index.vue'; ...@@ -138,8 +138,8 @@ import Header from '@/pages/order/components/Header/index.vue';
const fileDomain = import.meta.env.VITE_APP_IMG_URL; const fileDomain = import.meta.env.VITE_APP_IMG_URL;
onShow(() => { onShow(() => {
// 获取位置 // 获取位置并计算距离
getLocationFn(); calculateDistance();
}); });
const shopId = ref(); const shopId = ref();
...@@ -224,6 +224,8 @@ const getShopMailDetail = async () => { ...@@ -224,6 +224,8 @@ const getShopMailDetail = async () => {
const res = await getShopDetail({ shopId: shopId.value }); const res = await getShopDetail({ shopId: shopId.value });
if (res.code === 0) { if (res.code === 0) {
shopDetail.value = res.data.shop; shopDetail.value = res.data.shop;
// 获取位置并计算距离
calculateDistance();
} }
}; };
...@@ -248,24 +250,42 @@ function callShopPhone(phoneNumber) { ...@@ -248,24 +250,42 @@ function callShopPhone(phoneNumber) {
}); });
} }
/** // 获取定位
* 获取定位
*/
function getLocationFn() { function getLocationFn() {
xma.getLocation({ return new Promise((resolve, reject) => {
type: 'wgs84', xma.getLocation({
success: function (res) { type: 'wgs84',
const myLatitude = shopDetail.value.shopLat; isHighAccuracy: true,
const myLongitude = shopDetail.value.shopLng; success: function (res) {
const distance = getDistance(res.latitude, res.longitude, myLatitude, myLongitude, 1); // 经纬度
shopDetail.value.distance = distance; console.log('res.latitude, res.longitude', res.latitude, res.longitude);
}, resolve({ lat: res.latitude, lon: res.longitude });
fail: function (err) { },
return err; fail: function (err) {
}, return err;
},
});
}); });
} }
// 计算距离的函数封装
async function calculateDistance() {
try {
const res = await getLocationFn();
const distance = getDistance(
res.lat,
res.lon,
shopDetail.value.shopLat,
shopDetail.value.shopLng,
1,
);
shopDetail.value.distance = distance;
console.log('distance', distance, shopDetail.value.shopLat, shopDetail.value.shopLng);
} catch (error) {
console.error('Error calculating distance:', error);
}
}
/** /**
* 跳转地图 * 跳转地图
*/ */
......
...@@ -99,7 +99,19 @@ ...@@ -99,7 +99,19 @@
</view> </view>
</view> </view>
</view> </view>
<wd-loadmore :state="state" @reload="getCouponList" /> <!-- <wd-loadmore :state="state" @reload="getCouponList" /> -->
<view
style="
width: 100%;
text-align: center;
font-size: 24rpx;
margin-top: 10rpx;
color: #888989;
"
v-if="isEnd"
>
没有更多啦~
</view>
</view> </view>
<wd-status-tip image="content" tip="暂无优惠券" v-else /> <wd-status-tip image="content" tip="暂无优惠券" v-else />
</view> </view>
...@@ -125,8 +137,10 @@ const currentTab = ref(0); ...@@ -125,8 +137,10 @@ const currentTab = ref(0);
const changeTab = (index) => { const changeTab = (index) => {
if (currentTab.value !== index) { if (currentTab.value !== index) {
currentTab.value = parseInt(index); currentTab.value = parseInt(index);
getStatistics(); initCouponList().then(() => {
initCouponList(); getStatistics();
getCouponList();
});
} }
}; };
...@@ -137,8 +151,10 @@ const currenStatus = ref(0); ...@@ -137,8 +151,10 @@ const currenStatus = ref(0);
const changeStatus = (index) => { const changeStatus = (index) => {
if (currenStatus.value !== index) { if (currenStatus.value !== index) {
currenStatus.value = index; currenStatus.value = index;
getStatistics(); initCouponList().then(() => {
initCouponList(); getStatistics();
getCouponList();
});
} }
}; };
...@@ -161,6 +177,7 @@ getStatistics(); ...@@ -161,6 +177,7 @@ getStatistics();
/** /**
* 获取用户优惠券列表 * 获取用户优惠券列表
*/ */
const isEnd = ref(false);
const state = ref('loading'); const state = ref('loading');
const total = ref(0); const total = ref(0);
const couponData = ref([]); const couponData = ref([]);
...@@ -171,12 +188,20 @@ const catalog = reactive({ ...@@ -171,12 +188,20 @@ const catalog = reactive({
statuSon: 0, statuSon: 0,
}); });
const getCouponList = async () => { const getCouponList = async () => {
// if (isEnd.value) return;
catalog.current++; catalog.current++;
state.value = 'loading'; state.value = 'loading';
catalog.statuMain = currentTab.value; catalog.statuMain = currentTab.value;
catalog.statuSon = currenStatus.value; catalog.statuSon = currenStatus.value;
console.log(catalog);
xma.showLoading({
title: '加载中...',
mask: true,
});
const res = await myCouponListApi(catalog); const res = await myCouponListApi(catalog);
if (res.data.records.length < catalog.size) {
isEnd.value = true;
}
if (res.data.records.length > 0) { if (res.data.records.length > 0) {
res.data.records.forEach((item) => { res.data.records.forEach((item) => {
item.showDetail = false; item.showDetail = false;
...@@ -184,24 +209,37 @@ const getCouponList = async () => { ...@@ -184,24 +209,37 @@ const getCouponList = async () => {
couponData.value.push(...res.data.records); couponData.value.push(...res.data.records);
total.value = res.data.total; total.value = res.data.total;
} }
state.value = 'finished'; // state.value = 'finished';
xma.hideLoading();
}; };
getCouponList(); getCouponList();
// 下拉刷新
onPullDownRefresh(() => {
getStatistics();
initCouponList().then(() => {
getCouponList();
xma.stopPullDownRefresh();
});
});
// 触底函数 // 触底函数
onReachBottom(() => { onReachBottom(() => {
if (couponData.value.length >= total.value) { if (couponData.value.length >= total.value) {
state.value = 'finished'; isEnd.value = true;
// state.value = 'finished';
} else { } else {
getCouponList(); getCouponList();
} }
}); });
const initCouponList = () => { const initCouponList = () => {
couponData.value = []; return new Promise((resolve, reject) => {
total.value = 0; couponData.value = [];
catalog.current = 0; total.value = 0;
getCouponList(); catalog.current = 0;
resolve();
});
}; };
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment