提交 | 用户 | age
|
d98d05
|
1 |
// pages/qrCodeList/qrCodeList.js |
S |
2 |
import utils from '../../utils/util' |
|
3 |
const app = getApp(); |
|
4 |
let eventChannel; |
|
5 |
Page({ |
|
6 |
|
|
7 |
/** |
|
8 |
* 页面的初始数据 |
|
9 |
*/ |
|
10 |
data: { |
|
11 |
radio: '', |
|
12 |
}, |
|
13 |
|
|
14 |
// onChange(event) { |
|
15 |
// this.setData({ |
|
16 |
// radio: event.detail, |
|
17 |
// }); |
|
18 |
// }, |
|
19 |
|
|
20 |
radioOnClick(event) { |
|
21 |
const { name } = event.currentTarget.dataset; |
|
22 |
this.setData({ |
|
23 |
radio: name, |
|
24 |
}); |
|
25 |
}, |
|
26 |
|
|
27 |
enter(){ |
|
28 |
let radio = this.data.radio; |
|
29 |
console.log(this.data.radio); |
|
30 |
if (this.data.isShowRoomList) { |
|
31 |
eventChannel.emit('getSelectedRoom', {room: radio}); |
|
32 |
} else{ |
|
33 |
eventChannel.emit('getSelectedGoods', {goods: radio}); |
|
34 |
} |
|
35 |
this.cancle(); |
|
36 |
}, |
|
37 |
|
|
38 |
async getAllLiveRoomList(){ |
|
39 |
// 获取直播房间 |
|
40 |
let [errMsg, res] = await utils.to( |
|
41 |
wx.$http.request({ |
|
42 |
url: '/shopping/live/getLiveRoomList.do', |
|
43 |
}) |
|
44 |
) |
|
45 |
return [errMsg,res] |
|
46 |
}, |
|
47 |
|
|
48 |
async getGoodsList(){ |
|
49 |
// 获取推荐商品 |
|
50 |
let [errMsg, res] = await utils.to( |
|
51 |
wx.$http.request({ |
|
52 |
url: '/shopping/getMatCodeList.do?fromdata=10', |
|
53 |
}) |
|
54 |
) |
|
55 |
return [errMsg,res]; |
|
56 |
}, |
|
57 |
|
|
58 |
async getLiveRoomQr(){ |
|
59 |
// 获取推荐商品 |
|
60 |
let [errMsg, res] = await utils.to( |
|
61 |
wx.$http.request({ |
|
62 |
url: '/shopping/getMatCodeList.do?fromdata=8', |
|
63 |
}) |
|
64 |
) |
|
65 |
return [errMsg,res]; |
|
66 |
}, |
|
67 |
|
|
68 |
async getGoodsQr(){ |
|
69 |
// 获取推荐商品 |
|
70 |
let [errMsg, res] = await utils.to( |
|
71 |
wx.$http.request({ |
|
72 |
url: '/shopping/getMatCodeList.do?fromdata=8', |
|
73 |
}) |
|
74 |
) |
|
75 |
return [errMsg,res]; |
|
76 |
}, |
|
77 |
|
|
78 |
/** |
|
79 |
* 生命周期函数--监听页面加载 |
|
80 |
*/ |
|
81 |
onLoad: async function (options) { |
|
82 |
eventChannel = this.getOpenerEventChannel(); |
|
83 |
// type=1 直播间 |
|
84 |
if (options.type==1) { |
|
85 |
wx.setNavigationBarTitle({ |
|
86 |
title: '指定直播间', |
|
87 |
}) |
|
88 |
this.setData({ |
|
89 |
isShowRoomList:true |
|
90 |
}) |
|
91 |
await this.handleLiveRoomList() |
|
92 |
} else { |
|
93 |
this.setData({ |
|
94 |
isShowRoomList:false |
|
95 |
}) |
|
96 |
await this.handleGoodsList() |
|
97 |
} |
|
98 |
|
|
99 |
}, |
|
100 |
|
|
101 |
async handleLiveRoomList(){ |
|
102 |
let [errMsg, roomList] = await this.getAllLiveRoomList(); |
|
103 |
if (errMsg) { |
|
104 |
return; |
|
105 |
} |
|
106 |
this.setData({ |
|
107 |
roomList:roomList.list |
|
108 |
}) |
|
109 |
console.log(roomList.list) |
|
110 |
}, |
|
111 |
|
|
112 |
async handleGoodsList(){ |
|
113 |
let [errMsg, goodsList] = await this.getGoodsList(); |
|
114 |
if (errMsg) { |
|
115 |
return; |
|
116 |
} |
|
117 |
this.setData({ |
|
118 |
goodsList:goodsList.list |
|
119 |
}) |
|
120 |
console.log('商品',goodsList.list) |
|
121 |
}, |
|
122 |
|
|
123 |
cancle(){ |
|
124 |
wx.navigateBack({ |
|
125 |
complete: (res) => {}, |
|
126 |
}) |
|
127 |
}, |
|
128 |
/** |
|
129 |
* 生命周期函数--监听页面初次渲染完成 |
|
130 |
*/ |
|
131 |
onReady: function () { |
|
132 |
|
|
133 |
}, |
|
134 |
|
|
135 |
/** |
|
136 |
* 生命周期函数--监听页面显示 |
|
137 |
*/ |
|
138 |
onShow: function () { |
|
139 |
|
|
140 |
}, |
|
141 |
|
|
142 |
/** |
|
143 |
* 生命周期函数--监听页面隐藏 |
|
144 |
*/ |
|
145 |
onHide: function () { |
|
146 |
|
|
147 |
}, |
|
148 |
|
|
149 |
/** |
|
150 |
* 生命周期函数--监听页面卸载 |
|
151 |
*/ |
|
152 |
onUnload: function () { |
|
153 |
|
|
154 |
}, |
|
155 |
|
|
156 |
/** |
|
157 |
* 页面相关事件处理函数--监听用户下拉动作 |
|
158 |
*/ |
|
159 |
onPullDownRefresh: function () { |
|
160 |
|
|
161 |
}, |
|
162 |
|
|
163 |
/** |
|
164 |
* 页面上拉触底事件的处理函数 |
|
165 |
*/ |
|
166 |
onReachBottom: function () { |
|
167 |
|
|
168 |
}, |
|
169 |
|
|
170 |
/** |
|
171 |
* 用户点击右上角分享 |
|
172 |
*/ |
|
173 |
// onShareAppMessage: function () { |
|
174 |
|
|
175 |
// } |
|
176 |
}) |