index.js 9.3 KB

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