Sanakey
2021-04-02 a38dad3533f5eed77f8f8c52b914d21c4e55f289
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
const app = getApp<IAppOption>();
Page({
  data: {
    selectedSellerIdList:[],
    selectedSellerList:[] as any,
    sellerList:[
      {DocItem: 10, SellerId: 111, SellerName: "好几十", Telephone: "15555555555", isDefaultSellerName: false},
      {DocItem: 10, SellerId: 222, SellerName: "好", Telephone: "15588885555", isDefaultSellerName: false},
      {DocItem: 10, SellerId: 333, SellerName: "555", Telephone: "18888555555", isDefaultSellerName: false},
      {DocItem: 10, SellerId: 444, SellerName: "666", Telephone: "18333333333", isDefaultSellerName: false},
      {DocItem: 10, SellerId: 555, SellerName: "777", Telephone: "18666666666", isDefaultSellerName: false},
    ]
  },
  onLoad() {
    console.log(app);
    // this.getSellerList();
    const eventChannel = this.getOpenerEventChannel();
    eventChannel.on('getSellerListFromPromotionsPage', (data:any)=> {
      console.log('获取新建活动时选中的营销人员',data)
      this.setData({
        selectedSellerIdList:data.selectedSellerIdList,
      })
 
    })
  },
  // handleSelectedSellerList(list:[]){
  //   let {sellerList, selectedSellerIdList} = this.data;
  //   selectedSellerIdList.forEach((id)=>{
  //     sellerList.forEach((item)=>{
  //       if (item.SellerId == id) {
  //
  //       }
  //     })
  //   })
  // },
 
  getSelectedSellerList(){
    let {sellerList, selectedSellerIdList,selectedSellerList} = this.data;
    selectedSellerIdList.forEach((id)=>{
      sellerList.forEach((item)=>{
        if (item.SellerId == Number(id)) {
          selectedSellerList.push(item)
        }
      })
    })
    return selectedSellerList;
  },
  selectSeller(event:any) {
    console.log(event)
    this.setData({
      selectedSellerIdList: event.detail
    });
  },
  toggle(event:any) {
    const { index } = event.currentTarget.dataset;
    const checkbox = this.selectComponent(`.checkboxes-${index}`);
    checkbox.toggle();
    console.log(index);
  },
  toggle2(event:any){
    console.log(event);
  },
  goSellerEdit(event:any){
    let id = event.currentTarget.dataset.id;
    wx.navigateTo({
      url:`../sellerEdit/sellerEdit?id=${id}`
    })
  },
 
  onSubmit(){
    let {selectedSellerIdList} = this.data;
    let selectedSellerList = this.getSelectedSellerList();
    console.log('选中的营销人员id与列表',selectedSellerIdList,selectedSellerList);
    let eventChannel = this.getOpenerEventChannel();
    eventChannel.emit('getSelectedSellerList', {
      selectedSellerIdList,
      selectedSellerList
    });
    wx.navigateBack();
  },
 
  async getSellerList() {
    let [error, result] = await wx.$utils.to(
      wx.$http.request({
        url:`/shopping/panicBuying.do?m=getMyVisiteTraceList`,
      })
    )
    if (error){
      console.log(error);
      return;
    }
    console.log(result);
  }
})
export {}