hookehuyr

联调取消订单API流程

1 /* 1 /*
2 * @Date: 2023-12-22 10:29:37 2 * @Date: 2023-12-22 10:29:37
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-12-27 18:09:49 4 + * @LastEditTime: 2023-12-28 09:55:37
5 * @FilePath: /meihuaApp/src/api/index.js 5 * @FilePath: /meihuaApp/src/api/index.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
...@@ -17,6 +17,7 @@ const Api = { ...@@ -17,6 +17,7 @@ const Api = {
17 GET_ROOM: '/srv/?a=room_data&t=get_room', 17 GET_ROOM: '/srv/?a=room_data&t=get_room',
18 ADD_ORDER: '/srv/?a=room_data&t=add_order', 18 ADD_ORDER: '/srv/?a=room_data&t=add_order',
19 MY_ORDER: '/srv/?a=room_data&t=my_order', 19 MY_ORDER: '/srv/?a=room_data&t=my_order',
20 + ORDER_CANCEL: '/srv/?a=room_data&t=order_cancel',
20 PAY: '/srv/?a=pay', 21 PAY: '/srv/?a=pay',
21 PAY_CHECK: '/srv/?a=pay_check', 22 PAY_CHECK: '/srv/?a=pay_check',
22 } 23 }
...@@ -110,3 +111,10 @@ export const payCheckAPI = (params) => fn(fetch.post(Api.PAY_CHECK, params)); ...@@ -110,3 +111,10 @@ export const payCheckAPI = (params) => fn(fetch.post(Api.PAY_CHECK, params));
110 * @returns 111 * @returns
111 */ 112 */
112 export const myOrderAPI = (params) => fn(fetch.get(Api.MY_ORDER, params)); 113 export const myOrderAPI = (params) => fn(fetch.get(Api.MY_ORDER, params));
114 +
115 +/**
116 + * @description: 取消订单
117 + * @param id
118 + * @returns
119 + */
120 +export const orderCancelAPI = (params) => fn(fetch.post(Api.ORDER_CANCEL, params));
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
45 <view class="order-card-control"> 45 <view class="order-card-control">
46 <nut-row> 46 <nut-row>
47 <nut-col span="6"> 47 <nut-col span="6">
48 - <view class="order-info" @tap="showOrderInfo('id')"> 48 + <view class="order-info" @tap="showOrderInfo(order_id)">
49 <text>入住信息</text>&nbsp; 49 <text>入住信息</text>&nbsp;
50 <IconFont v-if="show_info" name="rect-up" size="12" color="#7D7C7C"></IconFont> 50 <IconFont v-if="show_info" name="rect-up" size="12" color="#7D7C7C"></IconFont>
51 <IconFont v-else name="rect-down" size="12" color="#7D7C7C"></IconFont> 51 <IconFont v-else name="rect-down" size="12" color="#7D7C7C"></IconFont>
...@@ -54,8 +54,8 @@ ...@@ -54,8 +54,8 @@
54 <!-- 待支付状态下,剩余时间归零 操作隐藏 --> 54 <!-- 待支付状态下,剩余时间归零 操作隐藏 -->
55 <nut-col span="18"> 55 <nut-col span="18">
56 <view v-if="showBtn" class="order-control"> 56 <view v-if="showBtn" class="order-control">
57 - <nut-button v-if="pay_show || props.data.status === '5'" @tap="cancelOrder('id')" plain color="#6A4925" size="small">取消订单</nut-button>&nbsp; 57 + <nut-button v-if="pay_show || props.data.status === 5" @tap="cancelOrder(order_id)" plain color="#6A4925" size="small">取消订单</nut-button>&nbsp;
58 - <nut-button v-if="pay_show" @tap="payOrder('id')" color="#6A4925" size="small">立即支付</nut-button> 58 + <nut-button v-if="pay_show" @tap="payOrder(order_id)" color="#6A4925" size="small">立即支付</nut-button>
59 <view v-if="delay_pay_show"> 59 <view v-if="delay_pay_show">
60 <text style="font-size: 23rpx; color: red;"> 60 <text style="font-size: 23rpx; color: red;">
61 支付超时,请重新下单! 61 支付超时,请重新下单!
...@@ -132,6 +132,11 @@ ...@@ -132,6 +132,11 @@
132 import { ref, reactive, onMounted, onUnmounted, computed, watch } from 'vue' 132 import { ref, reactive, onMounted, onUnmounted, computed, watch } from 'vue'
133 import Taro from '@tarojs/taro' 133 import Taro from '@tarojs/taro'
134 import { IconFont } from '@nutui/icons-vue-taro'; 134 import { IconFont } from '@nutui/icons-vue-taro';
135 +import { orderCancelAPI } from '@/api/index'
136 +
137 +/**
138 + * 房间状态(9=已入住,2=已取消,3=未支付,5=已支付)
139 + * /
135 140
136 141
137 /** 142 /**
...@@ -192,17 +197,17 @@ const getDayDifference = (startDate, endDate) => { ...@@ -192,17 +197,17 @@ const getDayDifference = (startDate, endDate) => {
192 } 197 }
193 198
194 const STATUS_COLOR = { 199 const STATUS_COLOR = {
195 - '2': '#CECECE', 200 + 2: '#CECECE',
196 - '3': '#D5842D', 201 + 3: '#D5842D',
197 - '5': '#6A4925', 202 + 5: '#6A4925',
198 - '9': '#656565', 203 + 9: '#656565',
199 } 204 }
200 205
201 const STATUS_TEXT = { 206 const STATUS_TEXT = {
202 - '2': '已取消', 207 + 2: '已取消',
203 - '5': '待入住', 208 + 5: '待入住',
204 - '9': '已入住', 209 + 9: '已入住',
205 - '3': '待支付', 210 + 3: '待支付',
206 } 211 }
207 212
208 const id = ref(''); // 房间id 213 const id = ref(''); // 房间id
...@@ -241,12 +246,12 @@ const booking_info = ref({ ...@@ -241,12 +246,12 @@ const booking_info = ref({
241 246
242 // 日历背景色灰色的条件判断 247 // 日历背景色灰色的条件判断
243 const calcBgColor = computed(() => { 248 const calcBgColor = computed(() => {
244 - return props.data.status === '9' || props.data.status === '2'; 249 + return props.data.status === 9 || props.data.status === 2;
245 }); 250 });
246 251
247 // 显示操作按钮的条件判断 252 // 显示操作按钮的条件判断
248 const showBtn = computed(() => { 253 const showBtn = computed(() => {
249 - return props.data.status === '5' || props.data.status === '3'; 254 + return props.data.status === 5 || props.data.status === 3;
250 }); 255 });
251 256
252 /** 257 /**
...@@ -295,9 +300,9 @@ const showOrderInfo = (id) => { ...@@ -295,9 +300,9 @@ const showOrderInfo = (id) => {
295 // 控制待支付状态下的显示 300 // 控制待支付状态下的显示
296 const pay_show = computed(() => { 301 const pay_show = computed(() => {
297 let flag = false; 302 let flag = false;
298 - if (props.data.status === '3' && remain_time.value) { // 倒计时进行时 303 + if (props.data.status === 3 && remain_time.value) { // 倒计时进行时
299 flag = true; 304 flag = true;
300 - } else if (props.data.status === '3' && !remain_time.value) { // 倒计时结束 305 + } else if (props.data.status === 3 && !remain_time.value) { // 倒计时结束
301 flag = false; 306 flag = false;
302 } 307 }
303 return flag; 308 return flag;
...@@ -305,24 +310,26 @@ const pay_show = computed(() => { ...@@ -305,24 +310,26 @@ const pay_show = computed(() => {
305 310
306 // 支付超时显示 311 // 支付超时显示
307 const delay_pay_show = computed(() => { 312 const delay_pay_show = computed(() => {
308 - return props.data.status === '3' && !remain_time.value; 313 + return props.data.status === 3 && !remain_time.value;
309 }) 314 })
310 315
311 const cancelOrder = (id) => { 316 const cancelOrder = (id) => {
312 Taro.showModal({ 317 Taro.showModal({
313 title: '温馨提示', 318 title: '温馨提示',
314 content: '是否确认取消订单?', 319 content: '是否确认取消订单?',
315 - success: function (res) { 320 + success: async (res) => {
316 if (res.confirm) { 321 if (res.confirm) {
317 - console.log('用户点击确定')
318 - // TODO:取消订单
319 if (id) { 322 if (id) {
320 - Taro.showToast({ 323 + // 取消订单
321 - title: '取消成功', 324 + const { code, data } = await orderCancelAPI({id});
322 - icon:'success', 325 + if (code) {
323 - duration: 2000 326 + Taro.showToast({
324 - }); 327 + title: '取消成功',
325 - // TODO:刷新当前列表接口 328 + icon:'success',
329 + duration: 2000
330 + });
331 + props.data.status = 2; // 取消订单状态置为已取消
332 + }
326 } 333 }
327 } else if (res.cancel) { 334 } else if (res.cancel) {
328 console.log('用户点击取消') 335 console.log('用户点击取消')
...@@ -361,7 +368,8 @@ onMounted(async () => { ...@@ -361,7 +368,8 @@ onMounted(async () => {
361 order_num.value = props.data.order_num; 368 order_num.value = props.data.order_num;
362 plan_in.value = props.data.plan_in; 369 plan_in.value = props.data.plan_in;
363 plan_out.value = props.data.plan_out; 370 plan_out.value = props.data.plan_out;
364 - remain_time.value = props.data.pay_time; 371 + // remain_time.value = props.data.pay_time;
372 + remain_time.value = 1000;
365 contact_name.value = props.data.contact_name; 373 contact_name.value = props.data.contact_name;
366 contact_phone.value = props.data.contact_phone; 374 contact_phone.value = props.data.contact_phone;
367 order_remark.value = props.data.order_remark; 375 order_remark.value = props.data.order_remark;
......