index.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. import {
  2. ApiModel
  3. } from "../../utils/api";
  4. const _Http = new ApiModel();
  5. const handleList = require("../../utils/processingData")
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. //轮播图列表
  12. swiperBannerList: [],
  13. liveList: [], //云展会直播大厅
  14. showLiveList: [], //显示直播列表
  15. liveClassifyList: [], //直播分类
  16. liveSelectClassify: '全部', //直播分类选择
  17. agentList: [], //热门展商
  18. showAgentList: [], //显示热门展商
  19. agentClassifyList: [], //热门展商分类
  20. agentSelectClassify: '全部', //展商分类选择
  21. prodList: [], //热门展品
  22. fagentcount: null, //展示商
  23. flivecount: null, //正在直播
  24. ftotalcustcount: null, //观众总数
  25. showDownIndex: -1, //显示下拉下标
  26. },
  27. /**
  28. * 生命周期函数--监听页面加载
  29. */
  30. onLoad: function (options) {
  31. let data = {
  32. "classname": "publicmethod.live.live",
  33. "method": "getLiveChannelData",
  34. "content": {
  35. "tactivityid": options.id,
  36. "siteid": "BWJ"
  37. }
  38. }
  39. /* 云展会直播大厅 */
  40. _Http.basic(data).then(res => {
  41. if (res.msg != "成功") {
  42. wx.showToast({
  43. title: '直播大厅加载失败,请重新进入页面',
  44. icon: "error",
  45. duration: 5000
  46. })
  47. } else {
  48. let data = JSON.parse(JSON.stringify(res.data.tlivelist));
  49. const ClassifyList = this.setClassifyList(data);
  50. const liveList = handleList.twoDimensionalArr(data, 4, 10);
  51. this.setData({
  52. liveList: res.data.tlivelist,
  53. showLiveList: liveList,
  54. liveClassifyList: ClassifyList,
  55. fagentcount: res.data.fagentcount,
  56. flivecount: res.data.flivecount,
  57. ftotalcustcount: res.data.ftotalcustcount
  58. })
  59. }
  60. });
  61. /* 热门展商 */
  62. data.method = "agentList";
  63. _Http.basic(data).then(res => {
  64. if (res.msg != "成功") {
  65. wx.showToast({
  66. title: '热门展商加载失败,请重新进入页面',
  67. icon: "error",
  68. duration: 5000
  69. })
  70. } else {
  71. data = JSON.parse(JSON.stringify(res.data));
  72. const classifyList = this.setClassifyList(data);
  73. const list = handleList.imageType(data, "brandcover");
  74. const List = handleList.twoDimensionalArr(list, 4, 10);
  75. this.setData({
  76. agentList: res.data,
  77. showAgentList: List,
  78. agentClassifyList: classifyList
  79. })
  80. }
  81. });
  82. /* 热门展品 */
  83. data.method = "prodList";
  84. _Http.basic(data).then(res => {
  85. if (res.msg != "成功") {
  86. wx.showToast({
  87. title: '热门展品加载失败,请重新进入页面',
  88. icon: "error",
  89. duration: 5000
  90. })
  91. } else {
  92. const prodList = handleList.twoDimensionalArr(res.data, 6, 10);
  93. this.setData({
  94. prodList,
  95. })
  96. }
  97. });
  98. /* 获取轮播图 */
  99. const bannerList = getApp().globalData.bannerDataList.filter(value => value.flocation == 'activity_head');
  100. this.setData({
  101. swiperBannerList: bannerList[0].banner
  102. });
  103. },
  104. /* 分类 */
  105. setClassifyList(data) {
  106. let List = [];
  107. for (let i = 0; i < data.length; i++) {
  108. const cur = data[i].flocationclass
  109. if (cur != null && cur != undefined && cur != '' && cur != [] && cur != {}) List.push(cur)
  110. };
  111. let arr = List.reduce((pre, cur) => {
  112. if (!pre.includes(cur)) {
  113. return pre.concat(cur)
  114. } else {
  115. return pre
  116. }
  117. }, [])
  118. arr.unshift('全部');
  119. return arr
  120. },
  121. /* 直播大厅搜索 */
  122. searchBlur(e) {
  123. const {
  124. value
  125. } = e.detail;
  126. const va = value.trim();
  127. let data = JSON.parse(JSON.stringify(this.data.liveList));
  128. if (this.data.liveSelectClassify == '全部') {
  129. if (va == '') {
  130. this.setData({
  131. showLiveList: handleList.twoDimensionalArr(data, 4, 10)
  132. })
  133. } else {
  134. let arrList = data.filter(item => {
  135. let arr = [];
  136. for (let i in item) {
  137. if (item[i] != null || item[i] != undefined) arr.push(item[i])
  138. }
  139. if (arr.includes(va)) {
  140. return item
  141. }
  142. });
  143. this.setData({
  144. showLiveList: handleList.twoDimensionalArr(arrList, 4, 10)
  145. })
  146. }
  147. } else {
  148. let cList = data.filter(item => item.flocationclass == this.data.liveSelectClassify),
  149. list = cList;
  150. if (va != '') {
  151. list = cList.filter(item => {
  152. let arr = [];
  153. for (let i in item) {
  154. if (item[i] != null || item[i] != undefined) arr.push(item[i])
  155. }
  156. if (arr.includes(va)) {
  157. return item
  158. }
  159. })
  160. }
  161. this.setData({
  162. showLiveList: handleList.twoDimensionalArr(list, 4, 10)
  163. })
  164. }
  165. },
  166. /* 显示下拉 */
  167. showPullDown(e) {
  168. const {
  169. index
  170. } = e.target.dataset;
  171. if (this.data.showDownIndex == index) return this.setData({
  172. showDownIndex: -1
  173. });
  174. this.setData({
  175. showDownIndex: index
  176. })
  177. },
  178. /* 关闭 */
  179. closeTheDropDown() {
  180. this.setData({
  181. showDownIndex: -1
  182. })
  183. },
  184. /* 选择分类 */
  185. modeSelect(e) {
  186. const {
  187. name,
  188. index
  189. } = e.target.dataset;
  190. if (this.data.showDownIndex == 1) {
  191. let list = JSON.parse(JSON.stringify(this.data.liveList));
  192. if (name == '全部') {
  193. var List = list;
  194. } else {
  195. var List = list.filter(value => value.flocationclass == name);
  196. };
  197. var liveList = handleList.twoDimensionalArr(List, 4, 10);
  198. //直播大厅
  199. this.setData({
  200. showDownIndex: -1,
  201. liveSelectClassify: name,
  202. showLiveList: liveList
  203. });
  204. } else {
  205. //热门展商
  206. let list = JSON.parse(JSON.stringify(this.data.agentList));
  207. if (name == '全部') {
  208. var List = list;
  209. } else {
  210. var List = list.filter(value => value.flocationclass == name);
  211. };
  212. var agentList = handleList.twoDimensionalArr(List, 4, 10);
  213. this.setData({
  214. showDownIndex: -1,
  215. agentSelectClassify: name,
  216. showAgentList: agentList
  217. });
  218. }
  219. },
  220. /**
  221. * 生命周期函数--监听页面初次渲染完成
  222. */
  223. onReady: function () {
  224. },
  225. /**
  226. * 生命周期函数--监听页面显示
  227. */
  228. onShow: function () {
  229. },
  230. /**
  231. * 生命周期函数--监听页面隐藏
  232. */
  233. onHide: function () {
  234. },
  235. /**
  236. * 生命周期函数--监听页面卸载
  237. */
  238. onUnload: function () {
  239. },
  240. /**
  241. * 页面相关事件处理函数--监听用户下拉动作
  242. */
  243. onPullDownRefresh: function () {
  244. },
  245. /**
  246. * 页面上拉触底事件的处理函数
  247. */
  248. onReachBottom: function () {
  249. },
  250. /**
  251. * 用户点击右上角分享
  252. */
  253. onShareAppMessage: function () {
  254. }
  255. })