Commit 790d4e42ec8badadf916ed6679d192e130eec84d
1 parent
7365c10e
门店组件
Showing
3 changed files
with
54 additions
and
14 deletions
components/store_popup/store_popup.js
| ... | ... | @@ -65,6 +65,7 @@ Component({ |
| 65 | 65 | is_get_guide: 0, |
| 66 | 66 | keyword: '', //门店搜索 |
| 67 | 67 | sec_i: -1,//选中分类门店 下标 |
| 68 | + old_all_sto:null, //分类门店数据 | |
| 68 | 69 | }, |
| 69 | 70 | |
| 70 | 71 | /** |
| ... | ... | @@ -314,7 +315,8 @@ Component({ |
| 314 | 315 | }, |
| 315 | 316 | close_popup() { |
| 316 | 317 | this.setData({ |
| 317 | - store: 0 | |
| 318 | + store: 0, | |
| 319 | + keyword:'' | |
| 318 | 320 | }) |
| 319 | 321 | }, |
| 320 | 322 | //选择更多门店 |
| ... | ... | @@ -609,8 +611,14 @@ Component({ |
| 609 | 611 | } else { //分类下搜索 |
| 610 | 612 | let sec_i = this.data.sec_i |
| 611 | 613 | let all_sto = this.data.all_sto |
| 614 | + let old_all_sto = this.data.old_all_sto | |
| 615 | + if (!old_all_sto) { | |
| 616 | + this.setData({ | |
| 617 | + old_all_sto:JSON.parse(JSON.stringify(all_sto)) | |
| 618 | + }) | |
| 619 | + } | |
| 612 | 620 | let sec_sto = this.data.sec_sto |
| 613 | - let sec_arr = sec_sto.s_arr | |
| 621 | + let sec_arr = this.data.old_all_sto[sec_i].s_arr | |
| 614 | 622 | let keyword = this.data.keyword |
| 615 | 623 | let text = 'sec_sto.s_arr' |
| 616 | 624 | if (keyword) { |
| ... | ... | @@ -634,12 +642,15 @@ Component({ |
| 634 | 642 | }) |
| 635 | 643 | } |
| 636 | 644 | } else { |
| 637 | - console.error(sec_i); | |
| 638 | - console.log(all_sto); | |
| 639 | - console.error(all_sto[sec_i].s_arr); | |
| 640 | - this.setData({ | |
| 641 | - [text]: all_sto[sec_i].s_arr | |
| 642 | - }) | |
| 645 | + if (this.data.old_all_sto) { | |
| 646 | + this.setData({ | |
| 647 | + [text]: this.data.old_all_sto[sec_i].s_arr | |
| 648 | + }) | |
| 649 | + }else{ | |
| 650 | + this.setData({ | |
| 651 | + [text]: all_sto[sec_i].s_arr | |
| 652 | + }) | |
| 653 | + } | |
| 643 | 654 | } |
| 644 | 655 | |
| 645 | 656 | |
| ... | ... | @@ -667,8 +678,9 @@ Component({ |
| 667 | 678 | |
| 668 | 679 | // if (!th.data.sele_g) return false; |
| 669 | 680 | |
| 670 | - console.error('选中的门店'); | |
| 671 | - console.error(item); | |
| 681 | + | |
| 682 | + | |
| 683 | + this.triggerEvent('callback', item) | |
| 672 | 684 | |
| 673 | 685 | th.setData({ |
| 674 | 686 | def_pick_store: item, | ... | ... |
pages/user/user_spsy/user_spsy.js
| ... | ... | @@ -5,7 +5,7 @@ var ut = require('../../../utils/util'); |
| 5 | 5 | var regeneratorRuntime = require('../../../utils/runtime.js'); |
| 6 | 6 | |
| 7 | 7 | Page({ |
| 8 | - /** | |
| 8 | + /** | |
| 9 | 9 | * 页面的初始数据 |
| 10 | 10 | */ |
| 11 | 11 | data: { |
| ... | ... | @@ -64,6 +64,32 @@ Page({ |
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | }, |
| 67 | + //门店回调 | |
| 68 | + async callback(e){ | |
| 69 | + let item = e.detail; | |
| 70 | + console.log('门店信息'); | |
| 71 | + console.log(item); | |
| 72 | + if (item && item.pickup_no) { | |
| 73 | + let qr_code_object=this.data.qr_code_object | |
| 74 | + let data={ | |
| 75 | + store_id:os.stoid,//商家编号 | |
| 76 | + user_id:getApp().globalData.user_id, //会员编号 | |
| 77 | + storageId:item.pickup_no, //门店编号 | |
| 78 | + writeOffCode:qr_code_object.WriteOffCode,//核销码 | |
| 79 | + } | |
| 80 | + let res = await getApp().request.promisePut("/api/weshop/users/grade/storage/update", { | |
| 81 | + data: data | |
| 82 | + }); | |
| 83 | + console.log('门店更新'); | |
| 84 | + console.log(res); | |
| 85 | + }else{ | |
| 86 | + wx.showToast({ | |
| 87 | + title: '门店选择失败', | |
| 88 | + icon: 'none', | |
| 89 | + duration: 2000 | |
| 90 | + }) | |
| 91 | + } | |
| 92 | + }, | |
| 67 | 93 | async requestData() { |
| 68 | 94 | if (this.data.no_more) return false; |
| 69 | 95 | if (this.data.isLoading) return false; | ... | ... |
pages/user/user_spsy/user_spsy.wxml
| ... | ... | @@ -13,8 +13,10 @@ |
| 13 | 13 | 已使用{{list[0].freebh}} |
| 14 | 14 | </view> --> |
| 15 | 15 | <view wx:if="{{is_use}}" class="btn1">已使用</view> |
| 16 | - <!-- <view wx:else bindtap="show_hxm" data-type="1" class="btn">立即使用</view> --> | |
| 17 | - <view wx:else bindtap="select_product" data-type="1" class="btn">选门店</view> | |
| 16 | + <block wx:else> | |
| 17 | + <view wx:if="{{qr_code_object.StorageID}}" bindtap="show_hxm" data-type="1" class="btn">立即使用</view> | |
| 18 | + <view wx:else bindtap="select_product" data-type="1" class="btn">选门店</view> | |
| 19 | + </block> | |
| 18 | 20 | <!-- <view bindtap="right_use" class="btn">立即使用</view></view> --> |
| 19 | 21 | </view> |
| 20 | 22 | </view> |
| ... | ... | @@ -23,4 +25,4 @@ |
| 23 | 25 | <qr_code id="qc_com" bindclose="close"></qr_code> |
| 24 | 26 | |
| 25 | 27 | <!-- 门店选择弹窗 --> |
| 26 | -<store_popup store="{{store}}" ></store_popup> | |
| 27 | 28 | \ No newline at end of file |
| 29 | +<store_popup store="{{store}}" bindcallback="callback" ></store_popup> | |
| 28 | 30 | \ No newline at end of file | ... | ... |