Sanakey
2021-04-30 8724a444c8a1d09dc8f9efd005e8443aad8df1ab
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// index.ts
// 获取应用实例
// import appModule from '../../modules/app';
Page({
  data: {
    roomid:'',
    doccode:'',
    roomList:[],
    liveStatus: {
      101: "直播中",
      102: "未开始",
      103: "回放",
      104: "禁播",
      105: "暂停中",
      106: "异常",
      107: "已过期",
    },
    tagTypes: {
      101: "success",
      102: "primary",
      103: "primary",
      104: "danger",
      105: "success",
      106: "danger",
      107: "warning",
    },
  },
 
  onChange(event:any) {
    console.log(event.detail);
    this.setData({
      radio: event.detail,
    });
  },
 
  async onLoad() {
 
  },
  onShow() {
    this.getLiveRoomList();
  },
  async createPoster(event:any){
    let {roomid,index} = event.currentTarget.dataset;
    let poster =this.selectComponent('#my-poster-creator');
    if (roomid!=this.data.roomid){
      poster.clearPoster()
    }
    this.setData({
      roomid,
      currentLiveRoom: this.data.roomList[index]
    });
    // await this.getSharedCode();
 
    poster.drawPic();
  },
 
  async getSharedCode(){
    let roomid = this.data.roomid;
    let [error, result] = await wx.$utils.to(
      wx.$http.request({
        url:`/shopping/live/getSharedCode.do`,
        data:{
          roomid
        }
      })
    )
    if (error){
      console.log(error);
      return;
    }
    console.log(result);
  },
 
  deleteLiveRoom(event:any){
    let doccode = event.currentTarget.dataset.doccode;
    wx.pro.showModal({
      title: '确定删除该直播间吗?',
    }).then((res:any) => {
      if (res.confirm) {
        console.log('用户点击确定')
        this.setData({doccode})
        this.deleteLiveRoomRequest();
      } else if (res.cancel) {
        console.log('用户点击取消')
      }
      // instance.close();
    });
  },
  async deleteLiveRoomRequest(){
    let doccode = this.data.doccode;
    let [error, result] = await wx.$utils.to(
      wx.$http.request({
        url:`/shopping/live/deleteRoomByDocCode`,
        data:{
          doccode
        }
      })
    )
    if (error){
      console.log(error);
      return;
    }
    console.log(result);
    wx.showToast({
      title:'删除成功'
    })
    this.getLiveRoomList();
  },
  async getLiveRoomList(){
    let [error, result] = await wx.$utils.to(
      wx.$http.request({
        url:`/shopping/panicBuyingLive/getLiveRoomListForOpenId.do`,
      })
    )
    if (error){
      console.log(error);
      return;
    }
    console.log(result);
    this.setData({
      roomList:result.liveList,
      historyList:result.historyList,
    })
  }
})