index.js 8.1 KB

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