hookehuyr

订单相关API调整

...@@ -27,7 +27,6 @@ declare module '@vue/runtime-core' { ...@@ -27,7 +27,6 @@ declare module '@vue/runtime-core' {
27 NutRadio: typeof import('@nutui/nutui-taro')['Radio'] 27 NutRadio: typeof import('@nutui/nutui-taro')['Radio']
28 NutRadioGroup: typeof import('@nutui/nutui-taro')['RadioGroup'] 28 NutRadioGroup: typeof import('@nutui/nutui-taro')['RadioGroup']
29 NutRow: typeof import('@nutui/nutui-taro')['Row'] 29 NutRow: typeof import('@nutui/nutui-taro')['Row']
30 - NutSkeleton: typeof import('@nutui/nutui-taro')['Skeleton']
31 NutSwiper: typeof import('@nutui/nutui-taro')['Swiper'] 30 NutSwiper: typeof import('@nutui/nutui-taro')['Swiper']
32 NutSwiperItem: typeof import('@nutui/nutui-taro')['SwiperItem'] 31 NutSwiperItem: typeof import('@nutui/nutui-taro')['SwiperItem']
33 NutTabPane: typeof import('@nutui/nutui-taro')['TabPane'] 32 NutTabPane: typeof import('@nutui/nutui-taro')['TabPane']
......
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 17:27:31 4 + * @LastEditTime: 2023-12-27 18:09:49
5 * @FilePath: /meihuaApp/src/api/index.js 5 * @FilePath: /meihuaApp/src/api/index.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
...@@ -16,6 +16,7 @@ const Api = { ...@@ -16,6 +16,7 @@ const Api = {
16 GET_LIST: '/srv/?a=room_data&t=get_list', 16 GET_LIST: '/srv/?a=room_data&t=get_list',
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 PAY: '/srv/?a=pay', 20 PAY: '/srv/?a=pay',
20 PAY_CHECK: '/srv/?a=pay_check', 21 PAY_CHECK: '/srv/?a=pay_check',
21 } 22 }
...@@ -100,3 +101,12 @@ export const payAPI = (params) => fn(fetch.post(Api.PAY, params)); ...@@ -100,3 +101,12 @@ export const payAPI = (params) => fn(fetch.post(Api.PAY, params));
100 * @returns 101 * @returns
101 */ 102 */
102 export const payCheckAPI = (params) => fn(fetch.post(Api.PAY_CHECK, params)); 103 export const payCheckAPI = (params) => fn(fetch.post(Api.PAY_CHECK, params));
104 +
105 +/**
106 + * @description: 获取我的订单列表
107 + * @param pay_type
108 + * @param page
109 + * @param limit
110 + * @returns
111 + */
112 +export const myOrderAPI = (params) => fn(fetch.get(Api.MY_ORDER, params));
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
3 <view class="order-card-header"> 3 <view class="order-card-header">
4 <nut-row> 4 <nut-row>
5 <nut-col span="16"> 5 <nut-col span="16">
6 - <view style="font-weight: bold; font-size: 34rpx;">家庭豪华连排三室套房</view> 6 + <view style="font-weight: bold; font-size: 34rpx;">{{ title }}</view>
7 - <view style="color: #7D7C7C; font-size: 24rpx;">两室 宜住3人 </view> 7 + <view style="color: #7D7C7C; font-size: 24rpx;">{{ room_num }}室 宜住{{ capacity }}人</view>
8 </nut-col> 8 </nut-col>
9 <nut-col span="8"> 9 <nut-col span="8">
10 - <image mode="aspectFill" src="https://img.yzcdn.cn/vant/cat.jpeg" /> 10 + <image mode="aspectFill" :src="cover" />
11 </nut-col> 11 </nut-col>
12 </nut-row> 12 </nut-row>
13 </view> 13 </view>
...@@ -18,27 +18,27 @@ ...@@ -18,27 +18,27 @@
18 <nut-row> 18 <nut-row>
19 <nut-col span="18"> 19 <nut-col span="18">
20 <view class="order-card-price-text"> 20 <view class="order-card-price-text">
21 - <view class="left"><nut-price :price="980" size="normal" /></view> 21 + <view class="left"><nut-price :price="order_price" size="normal" /></view>
22 - <view class="right" style="margin-top: 10rpx;"><nut-price :price="1280" size="small" strike-through style="color: #7D7C7C;" /></view> 22 + <view class="right" style="margin-top: 10rpx;"><nut-price :price="original_total" size="small" strike-through style="color: #7D7C7C;" /></view>
23 </view> 23 </view>
24 </nut-col> 24 </nut-col>
25 <nut-col span="6" class="order-card-price-num"> 25 <nut-col span="6" class="order-card-price-num">
26 - <IconFont name="close" size="7" color="#000" style="margin-right: 5rpx; margin-bottom: 0.5rpx;"></IconFont><text>1000</text> 26 + <IconFont name="close" size="7" color="#000" style="margin-right: 5rpx; margin-bottom: 0.5rpx;"></IconFont><text>{{ order_num }}</text>
27 </nut-col> 27 </nut-col>
28 </nut-row> 28 </nut-row>
29 </view> 29 </view>
30 <view :class="['calendar-select-page', calcBgColor ? 'bg-gray' : '']"> 30 <view :class="['calendar-select-page', calcBgColor ? 'bg-gray' : '']">
31 - <nut-row gutter="10"> 31 + <nut-row gutter="0">
32 <nut-col span="9"> 32 <nut-col span="9">
33 <view class="check-in-text">入住日期</view> 33 <view class="check-in-text">入住日期</view>
34 - <view class="check-in-info">2023.12.07 星期四</view> 34 + <view class="check-in-info">{{ plan_in }} {{ getDayOfWeek(plan_in) }}</view>
35 </nut-col> 35 </nut-col>
36 - <nut-col span="5" class="book-days"> 36 + <nut-col span="5" class="book-days" style="padding: 0 15rpx;">
37 - <view class="book-days-text">共1晚</view> 37 + <view class="book-days-text">共{{ getDayDifference(plan_in, plan_out) }}晚</view>
38 </nut-col> 38 </nut-col>
39 - <nut-col span="9" style="margin-left: 10rpx;"> 39 + <nut-col span="9" style="text-align: right;">
40 <view class="check-in-text">退房日期</view> 40 <view class="check-in-text">退房日期</view>
41 - <view class="check-in-info">2023.12.08 星期五</view> 41 + <view class="check-in-info">{{ plan_out }} {{ getDayOfWeek(plan_out) }}</view>
42 </nut-col> 42 </nut-col>
43 </nut-row> 43 </nut-row>
44 </view> 44 </view>
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
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 === 'apply'" @tap="cancelOrder('id')" plain color="#6A4925" size="small">取消订单</nut-button>&nbsp; 57 + <nut-button v-if="pay_show || props.data.status === '5'" @tap="cancelOrder('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('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;">
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
79 <view class="check-in-text">入住时间</view> 79 <view class="check-in-text">入住时间</view>
80 </nut-col> 80 </nut-col>
81 <nut-col span="12"> 81 <nut-col span="12">
82 - <view class="check-in-info">12月7日 14:00后</view> 82 + <view class="check-in-info">{{ booking_info.check_in.month }}月{{ booking_info.check_in.day }}日 {{ state.sysInfo.check_in_time }} 后</view>
83 </nut-col> 83 </nut-col>
84 </nut-row> 84 </nut-row>
85 <nut-row> 85 <nut-row>
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
87 <view class="check-out-text">退房日期</view> 87 <view class="check-out-text">退房日期</view>
88 </nut-col> 88 </nut-col>
89 <nut-col span="12"> 89 <nut-col span="12">
90 - <view class="check-out-info">12月8日 12:00前</view> 90 + <view class="check-out-info">{{ booking_info.check_out.month }}月{{ booking_info.check_out.day }}日 {{ state.sysInfo.check_out_time }} 前</view>
91 </nut-col> 91 </nut-col>
92 </nut-row> 92 </nut-row>
93 <nut-row> 93 <nut-row>
...@@ -95,33 +95,33 @@ ...@@ -95,33 +95,33 @@
95 <view class="breakfast-text">早餐</view> 95 <view class="breakfast-text">早餐</view>
96 </nut-col> 96 </nut-col>
97 <nut-col span="12"> 97 <nut-col span="12">
98 - <view class="breakfast-num">3份</view> 98 + <view class="breakfast-num">{{ capacity }} 份</view>
99 </nut-col> 99 </nut-col>
100 </nut-row> 100 </nut-row>
101 <view class="order-info-detail-tip"> 101 <view class="order-info-detail-tip">
102 - <view>12月7日 20:00后未入住,订单将被取消</view> 102 + <view>{{ booking_info.check_in.month }}月{{ booking_info.check_in.day }}日 {{ state.sysInfo.last_check_time }}后未入住,订单将被取消</view>
103 </view> 103 </view>
104 </view> 104 </view>
105 <view class="order-detail"> 105 <view class="order-detail">
106 <nut-row class="wrapper"> 106 <nut-row class="wrapper">
107 <nut-col span="6">联系人:</nut-col> 107 <nut-col span="6">联系人:</nut-col>
108 - <nut-col span="18" class="right">王二虎</nut-col> 108 + <nut-col span="18" class="right">{{ contact_name }}</nut-col>
109 </nut-row> 109 </nut-row>
110 <nut-row class="wrapper"> 110 <nut-row class="wrapper">
111 <nut-col span="6">联系电话:</nut-col> 111 <nut-col span="6">联系电话:</nut-col>
112 - <nut-col span="18" class="right">18996999786</nut-col> 112 + <nut-col span="18" class="right">{{ contact_phone }}</nut-col>
113 </nut-row> 113 </nut-row>
114 <nut-row class="wrapper"> 114 <nut-row class="wrapper">
115 <nut-col span="6">备注:</nut-col> 115 <nut-col span="6">备注:</nut-col>
116 - <nut-col span="18" class="right"></nut-col> 116 + <nut-col span="18" class="right">{{ order_remark }}</nut-col>
117 </nut-row> 117 </nut-row>
118 <nut-row class="wrapper"> 118 <nut-row class="wrapper">
119 <nut-col span="6">下单时间:</nut-col> 119 <nut-col span="6">下单时间:</nut-col>
120 - <nut-col span="18" class="right">2023-12-06</nut-col> 120 + <nut-col span="18" class="right">{{ order_created_time }}</nut-col>
121 </nut-row> 121 </nut-row>
122 <nut-row class="wrapper"> 122 <nut-row class="wrapper">
123 <nut-col span="6">订单号:</nut-col> 123 <nut-col span="6">订单号:</nut-col>
124 - <nut-col span="18" class="right">20231206</nut-col> 124 + <nut-col span="18" class="right">{{ order_id }}</nut-col>
125 </nut-row> 125 </nut-row>
126 </view> 126 </view>
127 </view> 127 </view>
...@@ -129,32 +129,124 @@ ...@@ -129,32 +129,124 @@
129 </template> 129 </template>
130 130
131 <script setup> 131 <script setup>
132 -import { ref, reactive, onMounted, onUnmounted, computed, } 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 135
136 +
137 +/**
138 + * 获取日期星期几
139 + * @param {String} dateString 日期字符串
140 + */
141 +const getDayOfWeek = (dateString) => {
142 + var dateParts = dateString.split('-');
143 + var year = parseInt(dateParts[0]);
144 + var month = parseInt(dateParts[1]) - 1; // 月份从 0 开始,所以要减去 1
145 + var day = parseInt(dateParts[2]);
146 +
147 + var date = new Date(year, month, day);
148 + var dayOfWeek = date.getDay();
149 +
150 + // 定义星期几的名称数组
151 + var days = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
152 +
153 + return days[dayOfWeek];
154 +}
155 +
156 +/**
157 + * 计算日期间隔
158 + * @param {*} startDate
159 + * @param {*} endDate
160 + */
161 +const getDayDifference = (startDate, endDate) => {
162 + var startParts = startDate.split('-');
163 + var startYear = parseInt(startParts[0]);
164 + var startMonth = parseInt(startParts[1]) - 1; // 月份从 0 开始,所以要减去 1
165 + var startDay = parseInt(startParts[2]);
166 +
167 + var endParts = endDate.split('-');
168 + var endYear = parseInt(endParts[0]);
169 + var endMonth = parseInt(endParts[1]) - 1; // 月份从 0 开始,所以要减去 1
170 + var endDay = parseInt(endParts[2]);
171 +
172 + var startDateObj = new Date(startYear, startMonth, startDay);
173 + var endDateObj = new Date(endYear, endMonth, endDay);
174 +
175 + // 跨年处理
176 + if (endYear > startYear) {
177 + endDateObj.setFullYear(endYear);
178 + }
179 +
180 + // 跨月处理
181 + if (endMonth > startMonth || (endMonth === startMonth && endDay > startDay)) {
182 + endDateObj.setMonth(endMonth);
183 + }
184 +
185 + // 计算两个日期之间的时间差(毫秒数)
186 + var timeDiff = endDateObj.getTime() - startDateObj.getTime();
187 +
188 + // 将时间差转换为天数
189 + var dayDiff = Math.floor(timeDiff / (1000 * 3600 * 24));
190 +
191 + return dayDiff;
192 +}
193 +
136 const STATUS_COLOR = { 194 const STATUS_COLOR = {
137 - 'cancel': '#CECECE', 195 + '2': '#CECECE',
138 - 'no-pay': '#D5842D', 196 + '3': '#D5842D',
139 - 'apply': '#6A4925', 197 + '5': '#6A4925',
140 - 'enable': '#656565', 198 + '9': '#656565',
141 } 199 }
142 200
143 const STATUS_TEXT = { 201 const STATUS_TEXT = {
144 - 'cancel': '已取消', 202 + '2': '已取消',
145 - 'apply': '待入住', 203 + '5': '待入住',
146 - 'enable': '已入住', 204 + '9': '已入住',
147 - 'no-pay': '待支付', 205 + '3': '待支付',
148 } 206 }
149 207
208 +const id = ref(''); // 房间id
209 +const cover = ref(''); // 封面图
210 +const title = ref(''); // 标题
211 +const original_total = ref(''); // 原价
212 +const order_price = ref(''); // 优惠价
213 +const capacity = ref(''); // 能住几个人
214 +const num = ref(''); // 可售数量
215 +const room_num = ref(''); // 房间描述 两室
216 +const room_type = ref(''); //
217 +const order_num = ref(''); // 订房数量
218 +const plan_in = ref(''); //
219 +const plan_out = ref(''); //
220 +const contact_name = ref(''); //
221 +const contact_phone = ref(''); //
222 +const order_remark = ref(''); //
223 +const order_created_time = ref(''); //
224 +const order_id = ref(''); //
225 +
226 +const booking_info = ref({
227 + days: 1, // 入住天数
228 + check_in: {
229 + year: '',
230 + month: '',
231 + day: '',
232 + day_of_week: ''
233 + },
234 + check_out: {
235 + year: '',
236 + month: '',
237 + day: '',
238 + day_of_week: ''
239 + },
240 +});
241 +
150 // 日历背景色灰色的条件判断 242 // 日历背景色灰色的条件判断
151 const calcBgColor = computed(() => { 243 const calcBgColor = computed(() => {
152 - return props.data.status === 'enable' || props.data.status === 'cancel'; 244 + return props.data.status === '9' || props.data.status === '2';
153 }); 245 });
154 246
155 // 显示操作按钮的条件判断 247 // 显示操作按钮的条件判断
156 const showBtn = computed(() => { 248 const showBtn = computed(() => {
157 - return props.data.status === 'apply' || props.data.status === 'no-pay'; 249 + return props.data.status === '5' || props.data.status === '3';
158 }); 250 });
159 251
160 /** 252 /**
...@@ -185,6 +277,10 @@ const props = defineProps({ ...@@ -185,6 +277,10 @@ const props = defineProps({
185 data: { 277 data: {
186 type: Object, 278 type: Object,
187 default: {} 279 default: {}
280 + },
281 + sys: {
282 + type: Object,
283 + default: {}
188 } 284 }
189 }); 285 });
190 const emit = defineEmits(["onPay"]); 286 const emit = defineEmits(["onPay"]);
...@@ -199,9 +295,9 @@ const showOrderInfo = (id) => { ...@@ -199,9 +295,9 @@ const showOrderInfo = (id) => {
199 // 控制待支付状态下的显示 295 // 控制待支付状态下的显示
200 const pay_show = computed(() => { 296 const pay_show = computed(() => {
201 let flag = false; 297 let flag = false;
202 - if (props.data.status === 'no-pay' && remain_time.value) { // 倒计时进行时 298 + if (props.data.status === '3' && remain_time.value) { // 倒计时进行时
203 flag = true; 299 flag = true;
204 - } else if (props.data.status === 'no-pay' && !remain_time.value) { // 倒计时结束 300 + } else if (props.data.status === '3' && !remain_time.value) { // 倒计时结束
205 flag = false; 301 flag = false;
206 } 302 }
207 return flag; 303 return flag;
...@@ -209,7 +305,7 @@ const pay_show = computed(() => { ...@@ -209,7 +305,7 @@ const pay_show = computed(() => {
209 305
210 // 支付超时显示 306 // 支付超时显示
211 const delay_pay_show = computed(() => { 307 const delay_pay_show = computed(() => {
212 - return props.data.status === 'no-pay' && !remain_time.value; 308 + return props.data.status === '3' && !remain_time.value;
213 }) 309 })
214 310
215 const cancelOrder = (id) => { 311 const cancelOrder = (id) => {
...@@ -248,15 +344,94 @@ const payOrder = (id) => { ...@@ -248,15 +344,94 @@ const payOrder = (id) => {
248 344
249 let timeId = null; 345 let timeId = null;
250 346
251 -onMounted(() => { 347 +const state = reactive({
252 - console.warn(props.data.status) 348 + sysInfo: {},
253 - remain_time.value = props.data.remain_time; 349 +});
350 +
351 +onMounted(async () => {
352 + id.value = props.data.id;
353 + cover.value = props.data.cover ? props.data.cover : 'https://cdn.ipadbiz.cn/meihua/img1@2x.png';
354 + title.value = props.data.title;
355 + room_num.value = props.data.room_num;
356 + capacity.value = props.data.capacity;
357 + num.value = props.data.num;
358 + original_total.value = props.data.original_total;
359 + order_price.value = props.data.order_price;
360 + room_type.value = props.data.room_type;
361 + order_num.value = props.data.order_num;
362 + plan_in.value = props.data.plan_in;
363 + plan_out.value = props.data.plan_out;
364 + remain_time.value = props.data.pay_time;
365 + contact_name.value = props.data.contact_name;
366 + contact_phone.value = props.data.contact_phone;
367 + order_remark.value = props.data.order_remark;
368 + order_id.value = props.data.id;
369 + // TODO: 给一个格式化的时间
370 + order_created_time.value = props.data._created_time;
371 + //
372 + let check_in = plan_in.value.split('-');
373 + let check_out = plan_out.value.split('-');
374 + //
375 + booking_info.value.check_in = {
376 + year: check_in[0],
377 + month: check_in[1],
378 + day: check_in[2],
379 + }
380 + booking_info.value.check_out = {
381 + year: check_out[0],
382 + month: check_out[1],
383 + day: check_out[2],
384 + }
254 // 进入页面后,开始倒计时 385 // 进入页面后,开始倒计时
255 timeId = setInterval(() => { 386 timeId = setInterval(() => {
256 remain_time.value ? remain_time.value -= 1 : 0; 387 remain_time.value ? remain_time.value -= 1 : 0;
257 }, 1000); 388 }, 1000);
258 }); 389 });
259 390
391 +watch(
392 + () => props.data,
393 + (val) => {
394 + if (val) {
395 + id.value = val.id;
396 + cover.value = val.cover ? val.cover : 'https://cdn.ipadbiz.cn/meihua/img1@2x.png';
397 + title.value = val.title;
398 + room_num.value = val.room_num;
399 + capacity.value = val.capacity;
400 + num.value = val.num;
401 + original_total.value = val.original_total;
402 + order_price.value = val.order_price;
403 + room_type.value = val.room_type;
404 + order_num.value = val.order_num;
405 + plan_in.value = val.plan_in;
406 + plan_out.value = val.plan_out;
407 + remain_time.value = val.pay_time;
408 + contact_name.value = val.contact_name;
409 + contact_phone.value = val.contact_phone;
410 + order_remark.value = val.order_remark;
411 + // TODO: 给一个格式化的时间
412 + order_created_time.value = val._created_time;
413 + order_id.value = val.id;
414 + }
415 + },
416 + {
417 + deep: true,
418 + immediate: true
419 + }
420 +);
421 +
422 +watch(
423 + () => props.sys,
424 + (val) => {
425 + if (val) {
426 + state.sysInfo = val;
427 + }
428 + },
429 + {
430 + deep: true,
431 + immediate: true
432 + }
433 +);
434 +
260 onUnmounted(() => { 435 onUnmounted(() => {
261 timeId && clearInterval(timeId); 436 timeId && clearInterval(timeId);
262 }) 437 })
...@@ -355,7 +530,7 @@ page { ...@@ -355,7 +530,7 @@ page {
355 } 530 }
356 .order-info-detail { 531 .order-info-detail {
357 .order-info { 532 .order-info {
358 - border-bottom: 1px dashed #979797; padding: 0.5rem; 533 + border-bottom: 1px dashed #979797; padding: 0.5rem; padding-top: 0;
359 .check-in-text { 534 .check-in-text {
360 color: #7D7C7C; font-size: 0.85rem; 535 color: #7D7C7C; font-size: 0.85rem;
361 } 536 }
......
1 <!-- 1 <!--
2 * @Date: 2023-12-20 14:11:11 2 * @Date: 2023-12-20 14:11:11
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-12-27 17:37:35 4 + * @LastEditTime: 2023-12-27 18:21:06
5 * @FilePath: /meihuaApp/src/components/payCard.vue 5 * @FilePath: /meihuaApp/src/components/payCard.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -113,7 +113,7 @@ const goToPay = async () => { ...@@ -113,7 +113,7 @@ const goToPay = async () => {
113 if (current_page === 'pages/my/index') { // 我的页面打开 113 if (current_page === 'pages/my/index') { // 我的页面打开
114 // 刷新当前页面 114 // 刷新当前页面
115 Taro.reLaunch({ 115 Taro.reLaunch({
116 - url: '/pages/my/index?tab_index=1' 116 + url: '/pages/my/index?tab_index=5'
117 }); 117 });
118 } 118 }
119 if (current_page === 'pages/detail/index') { // 订房确认页打开 119 if (current_page === 'pages/detail/index') { // 订房确认页打开
......
1 <!-- 1 <!--
2 * @Date: 2023-12-13 11:13:13 2 * @Date: 2023-12-13 11:13:13
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-12-27 14:37:22 4 + * @LastEditTime: 2023-12-27 19:30:49
5 * @FilePath: /meihuaApp/src/pages/my/index.vue 5 * @FilePath: /meihuaApp/src/pages/my/index.vue
6 * @Description: 我的页面 6 * @Description: 我的页面
7 --> 7 -->
...@@ -25,17 +25,13 @@ ...@@ -25,17 +25,13 @@
25 <nut-tab-pane v-for="item in tabList" :title="item.title" :pane-key="item.key" /> 25 <nut-tab-pane v-for="item in tabList" :title="item.title" :pane-key="item.key" />
26 </nut-tabs> 26 </nut-tabs>
27 <view v-if="showContent" class="book-list"> 27 <view v-if="showContent" class="book-list">
28 - <scroll-view ref="refScrollView" :style="scrollStyle" :scroll-y="true" :scroll-with-animation="true" @scrolltolower="onScrollToLower"> 28 + <scroll-view v-if="order_list.length" ref="refScrollView" :style="scrollStyle" :scroll-y="true" :scroll-with-animation="true" @scrolltolower="onScrollToLower">
29 - <view v-for="(item, index) in orderList" :key="index"> 29 + <view v-for="(item, index) in order_list" :key="index">
30 - <order-card :key="index" :data="item" @onPay="onPay"></order-card> 30 + <order-card :key="index" :data="item" :sys="sys_data" @onPay="onPay"></order-card>
31 - <view v-if="index === orderList.length-1" style="height: 2rem;"></view> 31 + <view v-if="index === order_list.length-1" style="height: 2rem;"></view>
32 </view> 32 </view>
33 </scroll-view> 33 </scroll-view>
34 - <nut-empty 34 + <nut-empty v-else image="https://static-ftcms.jd.com/p/files/61a9e3313985005b3958672e.png" description="暂无数据" ></nut-empty>
35 - v-if="orderList.length === 0"
36 - image="https://static-ftcms.jd.com/p/files/61a9e3313985005b3958672e.png"
37 - description="暂无数据"
38 - ></nut-empty>
39 </view> 35 </view>
40 </view> 36 </view>
41 <nav-bar activated="my" /> 37 <nav-bar activated="my" />
...@@ -51,65 +47,11 @@ import navBar from '@/components/navBar.vue' ...@@ -51,65 +47,11 @@ import navBar from '@/components/navBar.vue'
51 import orderCard from '@/components/orderCard.vue' 47 import orderCard from '@/components/orderCard.vue'
52 import payCard from '@/components/payCard.vue' 48 import payCard from '@/components/payCard.vue'
53 import avatar from '@/assets/images/avatar.png' 49 import avatar from '@/assets/images/avatar.png'
54 -import { showMyInfoAPI } from '@/api/index' 50 +import { showMyInfoAPI, myOrderAPI, sysParamAPI } from '@/api/index'
55 import { getCurrentPageParam } from "@/utils/weapp"; 51 import { getCurrentPageParam } from "@/utils/weapp";
56 52
57 const refScrollView = ref(null); 53 const refScrollView = ref(null);
58 54
59 -const tab_index = ref('0');
60 -const tabList = ref([{
61 - title: '全部订单',
62 - key: '0',
63 - value: 'all'
64 -}, {
65 - title: '待入住',
66 - key: '1',
67 - value: 'a'
68 -}, {
69 - title: '待支付',
70 - key: '2',
71 - value: 'b'
72 -}, {
73 - title: '已取消',
74 - key: '3',
75 - value: 'c'
76 -}]);
77 -
78 -const orderList = ref([
79 - {
80 - id: 1,
81 - name: '阿忆妞妞1',
82 - phone: '138****8888',
83 - price: 1200,
84 - remain_time: 1000,
85 - status: 'no-pay',
86 - },
87 - {
88 - id: 2,
89 - name: '阿忆妞妞2',
90 - phone: '138****8888',
91 - price: 1200,
92 - remain_time: 100,
93 - status: 'apply',
94 - },
95 - {
96 - id: 3,
97 - name: '阿忆妞妞3',
98 - phone: '138****8888',
99 - price: 1200,
100 - remain_time: 100,
101 - status: 'enable',
102 - },
103 - {
104 - id: 4,
105 - name: '阿忆妞妞4',
106 - phone: '138****8888',
107 - price: 1200,
108 - remain_time: 100,
109 - status: 'cancel',
110 - },
111 -])
112 -
113 const show_pay = ref(false); 55 const show_pay = ref(false);
114 const payData = ref({}); 56 const payData = ref({});
115 const userInfo = ref({ 57 const userInfo = ref({
...@@ -118,19 +60,6 @@ const userInfo = ref({ ...@@ -118,19 +60,6 @@ const userInfo = ref({
118 phone: '' 60 phone: ''
119 }); 61 });
120 62
121 -const tab_status = computed(() => {
122 - switch (tab_index.value) {
123 - case '0':
124 - return 'all'
125 - case '1':
126 - return 'in';
127 - case '2':
128 - return 'pp';
129 - case '3':
130 - return 'ca';
131 - }
132 -});
133 -
134 onMounted(async () => { 63 onMounted(async () => {
135 // 获取用户信息 64 // 获取用户信息
136 const { code, data } = await showMyInfoAPI(); 65 const { code, data } = await showMyInfoAPI();
...@@ -141,13 +70,6 @@ onMounted(async () => { ...@@ -141,13 +70,6 @@ onMounted(async () => {
141 phone: data.wxapp_user_phone 70 phone: data.wxapp_user_phone
142 } 71 }
143 } 72 }
144 - // 默认勾选栏目
145 - let params = getCurrentPageParam();
146 - if (params.tab_index) {
147 - tab_index.value = params.tab_index;
148 - }
149 - //
150 - console.warn('tab_status', tab_status.value);
151 }); 73 });
152 74
153 const onPay = ({ id, remain_time }) => { 75 const onPay = ({ id, remain_time }) => {
...@@ -178,13 +100,6 @@ const goToEdit = async () => { ...@@ -178,13 +100,6 @@ const goToEdit = async () => {
178 }); 100 });
179 } 101 }
180 } 102 }
181 -
182 -const onTabClick = ({ title, paneKey, disabled }) => {
183 - tab_index.value = paneKey;
184 - // console.warn(title, paneKey, tabList.value[paneKey]);
185 - // console.warn(tab_index.value);
186 - console.warn(tab_status.value);
187 -}
188 </script> 103 </script>
189 104
190 <script> 105 <script>
...@@ -199,18 +114,29 @@ export default { ...@@ -199,18 +114,29 @@ export default {
199 scrollStyle() { 114 scrollStyle() {
200 return { 115 return {
201 height: this.indexCoverHeight + 'px', 116 height: this.indexCoverHeight + 'px',
202 - // paddingBottom: 50 + 'px',
203 }; 117 };
204 }, 118 },
205 }, 119 },
120 + async onShow () {
121 + Taro.showLoading({ mask: true, title: "加载中..." })
122 + // 获取活动和轮播信息
123 + const { code, data } = await myOrderAPI({ page: this.page, limit: this.limit, pay_type: this.tab_index });
124 + if (code) {
125 + this.order_list = data;
126 + this.page = this.page + 1;
127 + Taro.hideLoading()
128 + }
129 + // 获取系统参数
130 + const sysData = await sysParamAPI();
131 + if (sysData.code) {
132 + this.sys_data = sysData.data;
133 + }
134 + },
206 onHide () { // 离开当前页面 135 onHide () { // 离开当前页面
207 - this.page = 0; 136 + this.page = 1;
208 this.flag = true; 137 this.flag = true;
209 }, 138 },
210 mounted () { 139 mounted () {
211 - Taro.showLoading({
212 - title: '加载中',
213 - });
214 // 设置首页封面高度 140 // 设置首页封面高度
215 const windowHeight = wx.getSystemInfoSync().windowHeight; 141 const windowHeight = wx.getSystemInfoSync().windowHeight;
216 // 处理切换显示白屏问题 142 // 处理切换显示白屏问题
...@@ -233,42 +159,68 @@ export default { ...@@ -233,42 +159,68 @@ export default {
233 console.warn('加载完成'); 159 console.warn('加载完成');
234 } 160 }
235 }); 161 });
162 + // 默认勾选栏目
163 + let params = getCurrentPageParam();
164 + if (params.tab_index) {
165 + this.tab_index = params.tab_index;
166 + }
236 }, 167 },
237 data() { 168 data() {
238 return { 169 return {
239 showContent: false, 170 showContent: false,
240 indexCoverHeight: 0, 171 indexCoverHeight: 0,
172 + order_list: [],
173 + sys_data: {},
241 flag: true, 174 flag: true,
242 - page: 0, 175 + page: 1,
243 limit: 10, 176 limit: 10,
177 + tab_index: 'all',
178 + // 房间状态(9=已入住,2=已取消,3=未支付,5=已支付)
179 + tabList: ([{
180 + title: '全部订单',
181 + key: 'all',
182 + }, {
183 + title: '待入住',
184 + key: '5',
185 + }, {
186 + title: '待支付',
187 + key: '3',
188 + }, {
189 + title: '已取消',
190 + key: '2',
191 + }])
244 }; 192 };
245 }, 193 },
246 methods: { 194 methods: {
195 + onTabClick ({ title, paneKey, disabled }) {
196 + this.tab_index = paneKey;
197 + this.order_list = [];
198 + this.page = 1;
199 + this.flag = true;
200 + this.getList();
201 + },
247 onScrollToLower () { 202 onScrollToLower () {
248 - // if(!this.flag){ 203 + if(!this.flag){
249 - // return 204 + return
250 - // } 205 + }
251 - // this.flag = false; 206 + this.flag = false;
252 - // this.getList(); 207 + this.getList();
253 - console.warn('onScrollToLower');
254 }, 208 },
255 async getList () { 209 async getList () {
256 - // // 获取推荐活动列表 210 + // 获取列表
257 - // const { code, data } = await activityHomeAPI({ page: this.page, limit: this.limit }); 211 + const { code, data } = await myOrderAPI({ page: this.page, limit: this.limit, pay_type: this.tab_index });
258 - // if (code) { 212 + if (code) {
259 - // if (data.activity_list.length) { 213 + if (data.length) {
260 - // // 绑定服务器时间,判断状态 214 + this.order_list = this.order_list.concat(data);
261 - // data.activity_list.forEach(item => { 215 + this.page = this.page + 1;
262 - // item.server_time = data.server_time; 216 + this.flag = true;
263 - // }); 217 + } else {
264 - // this.activity_list = this.activity_list.concat(data.activity_list); 218 + Taro.showToast({
265 - // this.page = this.page + 1; 219 + title: '没有更多了',
266 - // this.flag = true; 220 + icon: 'none'
267 - // } else { 221 + });
268 - // Toast('没有数据') 222 + }
269 - // } 223 + }
270 - // }
271 - // }
272 }, 224 },
273 } 225 }
274 }; 226 };
......