Commit 8a1137f98c4937620cf761c0da5e1655840799f1
1 parent
b14462e3
取消订单
Showing
2 changed files
with
63 additions
and
20 deletions
src/components/giftGivingItem/giftGivingItem.vue
| ... | ... | @@ -44,7 +44,7 @@ |
| 44 | 44 | <!-- 按钮 --> |
| 45 | 45 | <div class="btn_list"> |
| 46 | 46 | <div class="box"> |
| 47 | - <div v-on:click.stop="$parent.actionSheetShow = true" class="btn">取消支付</div> | |
| 47 | + <div v-on:click.stop="onCancelPayment(item)" class="btn">取消支付</div> | |
| 48 | 48 | <div v-on:click.stop="jumpToPay(item)" class="active">立即支付</div> |
| 49 | 49 | </div> |
| 50 | 50 | </div> |
| ... | ... | @@ -69,6 +69,10 @@ export default { |
| 69 | 69 | jumpToPay(item){ |
| 70 | 70 | this.$emit('jumpToPay',item) |
| 71 | 71 | }, |
| 72 | + // 取消订单 | |
| 73 | + onCancelPayment(item){ | |
| 74 | + this.$emit('onCancelPayment',item) | |
| 75 | + } | |
| 72 | 76 | } |
| 73 | 77 | }; |
| 74 | 78 | </script> | ... | ... |
src/pages/myGiftBox/myGiftBox.vue
| ... | ... | @@ -34,6 +34,7 @@ |
| 34 | 34 | <!-- 送礼列表 --> |
| 35 | 35 | <giftGivingItem |
| 36 | 36 | @onGiftGiving="onGiftGiving" |
| 37 | + @onCancelPayment="onCancelPayment" | |
| 37 | 38 | @jumpToPay="jumpToPay" |
| 38 | 39 | v-show="active != 0 && active == 1" |
| 39 | 40 | :giftGivingItem="giftGivingItem" |
| ... | ... | @@ -44,8 +45,8 @@ |
| 44 | 45 | </div> |
| 45 | 46 | </div> |
| 46 | 47 | <!-- 弹出框 --> |
| 47 | - <van-popup position="bottom" v-model="actionSheetShow"> | |
| 48 | - <van-picker :columns="causes" @change="onSelect" /> | |
| 48 | + <van-popup :style="{ height: '160px' }" position="bottom" v-model="actionSheetShow"> | |
| 49 | + <van-picker :columns="orderOperation.causes" @change="onSelect" /> | |
| 49 | 50 | </van-popup> |
| 50 | 51 | </div> |
| 51 | 52 | </template> |
| ... | ... | @@ -76,7 +77,10 @@ export default { |
| 76 | 77 | }, |
| 77 | 78 | tipText: null, // 是否已加载完 |
| 78 | 79 | actionSheetShow: false, |
| 79 | - causes: [] // 取消原因 | |
| 80 | + orderOperation: {// 存取取消订单的信息 | |
| 81 | + causes:[],// 取消原因 | |
| 82 | + id:''//订单id | |
| 83 | + } | |
| 80 | 84 | }; |
| 81 | 85 | }, |
| 82 | 86 | components: { |
| ... | ... | @@ -113,11 +117,6 @@ export default { |
| 113 | 117 | this.setGiftBottomVisibleBySwitchTab(0); |
| 114 | 118 | } |
| 115 | 119 | }, |
| 116 | - // 取消订单选择框 | |
| 117 | - onSelect(picker, value, index) { | |
| 118 | - this.actionSheetShow = false; | |
| 119 | - Toast(`当前值:${value}, 当前索引:${index}`); | |
| 120 | - }, | |
| 121 | 120 | /** |
| 122 | 121 | * 下啦滑动加载更多 |
| 123 | 122 | */ |
| ... | ... | @@ -390,10 +389,9 @@ export default { |
| 390 | 389 | } |
| 391 | 390 | }, |
| 392 | 391 | // 取消支付 |
| 393 | - cancelPayment(item) { | |
| 392 | + cancelPayment() { | |
| 394 | 393 | // 加载中提示 |
| 395 | 394 | Indicator.open("加载中..."); |
| 396 | - | |
| 397 | 395 | // 获取送礼礼物列表接口 |
| 398 | 396 | this.http( |
| 399 | 397 | "/Api/" + this.getApiVersion().index + "/cancel_order_group", |
| ... | ... | @@ -415,21 +413,62 @@ export default { |
| 415 | 413 | |
| 416 | 414 | // 返回处理 |
| 417 | 415 | if (res.code == 200) { |
| 416 | + // 解构数据 | |
| 417 | + let { data: datas } = res; | |
| 418 | + // 获取到的数组存到this.causes中去 | |
| 419 | + if (datas.group && datas.group.length > 0) { | |
| 420 | + this.orderOperation.causes = datas.group; | |
| 421 | + console.log(this.orderOperation) | |
| 422 | + } | |
| 423 | + } | |
| 424 | + }, | |
| 425 | + // 取消支付子组件事件传递 | |
| 426 | + onCancelPayment(item){ | |
| 427 | + this.actionSheetShow = true; // 显示底部取消订单原因弹框 | |
| 428 | + this.orderOperation.id = item.id // 获取当前操作订单ID | |
| 429 | + }, | |
| 430 | + // 取消订单选择框 | |
| 431 | + onSelect(picker, value, index) { | |
| 432 | + this.actionSheetShow = false; | |
| 433 | + // Toast(`当前值:${value}, 当前索引:${index}`); | |
| 434 | + // 调用取消订单原因填写 | |
| 435 | + this.cancelorder(this.orderOperation.id,value) | |
| 436 | + }, | |
| 437 | + // 取消支付填写原因 | |
| 438 | + cancelorder(orderId,content) { | |
| 439 | + // 加载中提示 | |
| 440 | + Indicator.open("加载中..."); | |
| 441 | + | |
| 442 | + // 获取送礼礼物列表接口 | |
| 443 | + this.http( | |
| 444 | + "/Api/" + this.getApiVersion().index + "/cancel_order", | |
| 445 | + { | |
| 446 | + id:orderId, // 订单ID | |
| 447 | + content:content // 取消订单ID | |
| 448 | + }, | |
| 449 | + this.cancelorderCallback, | |
| 450 | + { | |
| 451 | + method: "post" | |
| 452 | + } | |
| 453 | + ); | |
| 454 | + }, | |
| 455 | + /** | |
| 456 | + * 取消订单回调获取取消原因数据 | |
| 457 | + * @param {object} res [服务器返回数据] | |
| 458 | + * @param {object} ext [扩展参数] | |
| 459 | + */ | |
| 460 | + cancelorderCallback(res, ext) { | |
| 461 | + // 加载完成 | |
| 462 | + Indicator.close(); | |
| 463 | + | |
| 464 | + // 返回处理 | |
| 465 | + if (res.code == 200) { | |
| 418 | 466 | this.actionSheetShow = true; |
| 419 | 467 | // 解构数据 |
| 420 | 468 | let { data: datas } = res; |
| 421 | 469 | // 获取到的数组存到this.causes中去 |
| 422 | 470 | if (datas.group && datas.group.length > 0) { |
| 423 | 471 | this.causes = datas.group; |
| 424 | - // for (let i=0; i<datas.group.length; i++) { | |
| 425 | - // var obj = {} | |
| 426 | - // obj.name = datas.group[i] | |
| 427 | - // // push到新数组中 | |
| 428 | - // this.causes.push(obj); | |
| 429 | - // } | |
| 430 | - // // 数组对象去重 | |
| 431 | - // const newres = new Map(); | |
| 432 | - // this.causes = this.causes.filter((arr) => !newres.has(arr.name) && newres.set(arr.name, 1)) | |
| 433 | 472 | } |
| 434 | 473 | } |
| 435 | 474 | }, | ... | ... |