Showing
2 changed files
with
38 additions
and
15 deletions
| 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-26 16:09:24 | 4 | + * @LastEditTime: 2023-12-27 14:08:21 |
| 5 | * @FilePath: /meihuaApp/src/api/index.js | 5 | * @FilePath: /meihuaApp/src/api/index.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| ... | @@ -15,6 +15,7 @@ const Api = { | ... | @@ -15,6 +15,7 @@ const Api = { |
| 15 | SYS_PARAM: '/srv/?a=room_order&t=sys_param', | 15 | SYS_PARAM: '/srv/?a=room_order&t=sys_param', |
| 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 | } | 19 | } |
| 19 | 20 | ||
| 20 | /** | 21 | /** |
| ... | @@ -69,3 +70,17 @@ export const getListAPI = (params) => fn(fetch.get(Api.GET_LIST, params)); | ... | @@ -69,3 +70,17 @@ export const getListAPI = (params) => fn(fetch.get(Api.GET_LIST, params)); |
| 69 | * @returns | 70 | * @returns |
| 70 | */ | 71 | */ |
| 71 | export const getRoomAPI = (params) => fn(fetch.get(Api.GET_ROOM, params)); | 72 | export const getRoomAPI = (params) => fn(fetch.get(Api.GET_ROOM, params)); |
| 73 | + | ||
| 74 | +/** | ||
| 75 | + * @description: 预定房间 | ||
| 76 | + * @param id ID | ||
| 77 | + * @param num 预定房间数量 | ||
| 78 | + * @param plan_in 入住时间 | ||
| 79 | + * @param plan_out 离店时间 | ||
| 80 | + * @param contact_name 联系人 | ||
| 81 | + * @param contact_phone 联系电话 | ||
| 82 | + * @param order_remark 备注 | ||
| 83 | + * @param room_type floor/room | ||
| 84 | + * @returns | ||
| 85 | + */ | ||
| 86 | +export const addOrderAPI = (params) => fn(fetch.post(Api.ADD_ORDER, params)); | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-09-19 14:11:06 | 2 | * @Date: 2022-09-19 14:11:06 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2023-12-27 10:55:11 | 4 | + * @LastEditTime: 2023-12-27 14:20:17 |
| 5 | * @FilePath: /meihuaApp/src/pages/confirm/index.vue | 5 | * @FilePath: /meihuaApp/src/pages/confirm/index.vue |
| 6 | * @Description: 确认订单页面 | 6 | * @Description: 确认订单页面 |
| 7 | --> | 7 | --> |
| ... | @@ -79,7 +79,7 @@ | ... | @@ -79,7 +79,7 @@ |
| 79 | </view> | 79 | </view> |
| 80 | <view class="space-line"></view> | 80 | <view class="space-line"></view> |
| 81 | <view class="select-user"> | 81 | <view class="select-user"> |
| 82 | - <nut-radio-group v-model="use_type" direction="horizontal"> | 82 | + <nut-radio-group v-model="use_type" direction="horizontal" @change="onChange"> |
| 83 | <nut-radio label="1"> | 83 | <nut-radio label="1"> |
| 84 | 本人入住 | 84 | 本人入住 |
| 85 | <template #icon><IconFont name="checked" color="gray"></IconFont></template> | 85 | <template #icon><IconFont name="checked" color="gray"></IconFont></template> |
| ... | @@ -149,7 +149,7 @@ import { ref, reactive, onMounted, computed } from "vue"; | ... | @@ -149,7 +149,7 @@ import { ref, reactive, onMounted, computed } from "vue"; |
| 149 | import { getCurrentPageParam } from "@/utils/weapp"; | 149 | import { getCurrentPageParam } from "@/utils/weapp"; |
| 150 | import { IconFont } from '@nutui/icons-vue-taro'; | 150 | import { IconFont } from '@nutui/icons-vue-taro'; |
| 151 | import payCard from '@/components/payCard.vue' | 151 | import payCard from '@/components/payCard.vue' |
| 152 | -import { getRoomAPI, showMyInfoAPI, sysParamAPI } from '@/api/index' | 152 | +import { getRoomAPI, showMyInfoAPI, sysParamAPI, addOrderAPI } from '@/api/index' |
| 153 | 153 | ||
| 154 | const booking_info = ref({ | 154 | const booking_info = ref({ |
| 155 | days: 1, // 入住天数 | 155 | days: 1, // 入住天数 |
| ... | @@ -193,6 +193,16 @@ const onBookCountChange = (count) => { | ... | @@ -193,6 +193,16 @@ const onBookCountChange = (count) => { |
| 193 | 193 | ||
| 194 | const use_type = ref('1'); // 本人入住或者帮别人订 | 194 | const use_type = ref('1'); // 本人入住或者帮别人订 |
| 195 | 195 | ||
| 196 | +const onChange = (v) => { | ||
| 197 | + if (v === '2') { | ||
| 198 | + formData = { | ||
| 199 | + name: '', | ||
| 200 | + tel: '', | ||
| 201 | + note: '' | ||
| 202 | + } | ||
| 203 | + } | ||
| 204 | +}; | ||
| 205 | + | ||
| 196 | const formData = reactive({ | 206 | const formData = reactive({ |
| 197 | name: '', | 207 | name: '', |
| 198 | tel: '', | 208 | tel: '', |
| ... | @@ -247,7 +257,7 @@ onMounted(async () => { | ... | @@ -247,7 +257,7 @@ onMounted(async () => { |
| 247 | } | 257 | } |
| 248 | }); | 258 | }); |
| 249 | 259 | ||
| 250 | -const goPay = () => { | 260 | +const goPay = async () => { |
| 251 | if (!formData.name) { | 261 | if (!formData.name) { |
| 252 | Taro.showToast({ | 262 | Taro.showToast({ |
| 253 | title: '请填写联系人', | 263 | title: '请填写联系人', |
| ... | @@ -263,17 +273,15 @@ const goPay = () => { | ... | @@ -263,17 +273,15 @@ const goPay = () => { |
| 263 | }); | 273 | }); |
| 264 | return; | 274 | return; |
| 265 | } else { | 275 | } else { |
| 266 | - // TODO: 先保存订房信息 | 276 | + let params = getCurrentPageParam(); |
| 267 | - console.warn('保存订房信息', formData); | 277 | + // 保存订房信息 |
| 268 | - // TODO: 订房成功后,弹出支付页面 | 278 | + const { code, data } = await addOrderAPI({ id: params.id, contact_name: formData.name, contact_phone: formData.tel, order_remark: formData.note, plan_in: params.start_date, plan_out: params.end_date, room_type: params.room_type }) |
| 269 | - // let params = getCurrentPageParam(); | 279 | + if (code) { |
| 270 | - setTimeout(() => { | ||
| 271 | show_pay.value = true; | 280 | show_pay.value = true; |
| 272 | - payData.value.id = '订单ID'; | 281 | + payData.value.id = data.order_id; |
| 273 | - payData.value.price = room_price_info.value.discount * book_count.value * booking_info.value.days; | 282 | + payData.value.price = data.order_total; |
| 274 | - // TODO: 数据从哪里过去? | 283 | + payData.value.remain_time = data.pay_time; // 支付失效秒数 |
| 275 | - payData.value.remain_time = '1000'; // 支付失效秒数 | 284 | + } |
| 276 | - }, 1000); | ||
| 277 | } | 285 | } |
| 278 | } | 286 | } |
| 279 | 287 | ... | ... |
-
Please register or login to post a comment