Commit 790d4e42ec8badadf916ed6679d192e130eec84d

Authored by 前端开发-罗建龙
1 parent 7365c10e

门店组件

components/store_popup/store_popup.js
@@ -65,6 +65,7 @@ Component({ @@ -65,6 +65,7 @@ Component({
65 is_get_guide: 0, 65 is_get_guide: 0,
66 keyword: '', //门店搜索 66 keyword: '', //门店搜索
67 sec_i: -1,//选中分类门店 下标 67 sec_i: -1,//选中分类门店 下标
  68 + old_all_sto:null, //分类门店数据
68 }, 69 },
69 70
70 /** 71 /**
@@ -314,7 +315,8 @@ Component({ @@ -314,7 +315,8 @@ Component({
314 }, 315 },
315 close_popup() { 316 close_popup() {
316 this.setData({ 317 this.setData({
317 - store: 0 318 + store: 0,
  319 + keyword:''
318 }) 320 })
319 }, 321 },
320 //选择更多门店 322 //选择更多门店
@@ -609,8 +611,14 @@ Component({ @@ -609,8 +611,14 @@ Component({
609 } else { //分类下搜索 611 } else { //分类下搜索
610 let sec_i = this.data.sec_i 612 let sec_i = this.data.sec_i
611 let all_sto = this.data.all_sto 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 let sec_sto = this.data.sec_sto 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 let keyword = this.data.keyword 622 let keyword = this.data.keyword
615 let text = 'sec_sto.s_arr' 623 let text = 'sec_sto.s_arr'
616 if (keyword) { 624 if (keyword) {
@@ -634,12 +642,15 @@ Component({ @@ -634,12 +642,15 @@ Component({
634 }) 642 })
635 } 643 }
636 } else { 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,8 +678,9 @@ Component({
667 678
668 // if (!th.data.sele_g) return false; 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 th.setData({ 685 th.setData({
674 def_pick_store: item, 686 def_pick_store: item,
pages/user/user_spsy/user_spsy.js
@@ -5,7 +5,7 @@ var ut = require('../../../utils/util'); @@ -5,7 +5,7 @@ var ut = require('../../../utils/util');
5 var regeneratorRuntime = require('../../../utils/runtime.js'); 5 var regeneratorRuntime = require('../../../utils/runtime.js');
6 6
7 Page({ 7 Page({
8 - /** 8 + /**
9 * 页面的初始数据 9 * 页面的初始数据
10 */ 10 */
11 data: { 11 data: {
@@ -64,6 +64,32 @@ Page({ @@ -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 async requestData() { 93 async requestData() {
68 if (this.data.no_more) return false; 94 if (this.data.no_more) return false;
69 if (this.data.isLoading) return false; 95 if (this.data.isLoading) return false;
pages/user/user_spsy/user_spsy.wxml
@@ -13,8 +13,10 @@ @@ -13,8 +13,10 @@
13 已使用{{list[0].freebh}} 13 已使用{{list[0].freebh}}
14 </view> --> 14 </view> -->
15 <view wx:if="{{is_use}}" class="btn1">已使用</view> 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 <!-- <view bindtap="right_use" class="btn">立即使用</view></view> --> 20 <!-- <view bindtap="right_use" class="btn">立即使用</view></view> -->
19 </view> 21 </view>
20 </view> 22 </view>
@@ -23,4 +25,4 @@ @@ -23,4 +25,4 @@
23 <qr_code id="qc_com" bindclose="close"></qr_code> 25 <qr_code id="qc_com" bindclose="close"></qr_code>
24 26
25 <!-- 门店选择弹窗 --> 27 <!-- 门店选择弹窗 -->
26 -<store_popup store="{{store}}" ></store_popup>  
27 \ No newline at end of file 28 \ No newline at end of file
  29 +<store_popup store="{{store}}" bindcallback="callback" ></store_popup>
28 \ No newline at end of file 30 \ No newline at end of file