index.js 9.1 KB

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