index.js 9.3 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: [], //云展会直播大厅
  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. ftotalcustcount: res.data.ftotalcustcount,
  129. pageNumber: res.data.pageNumber + 1,
  130. pageTotal: res.data.pageTotal
  131. })
  132. }
  133. });
  134. },
  135. scrolltolower() {
  136. this.getLiveChannelData();
  137. },
  138. /* 分类 */
  139. setClassifyList(data) {
  140. let List = [];
  141. for (let i = 0; i < data.length; i++) {
  142. const cur = data[i].flocationclass
  143. if (cur != null && cur != undefined && cur != '' && cur != [] && cur != {}) List.push(cur)
  144. };
  145. let arr = List.reduce((pre, cur) => {
  146. if (!pre.includes(cur)) {
  147. return pre.concat(cur)
  148. } else {
  149. return pre
  150. }
  151. }, [])
  152. arr.unshift('全部');
  153. return arr
  154. },
  155. /* 直播大厅搜索 */
  156. searchBlur(e) {
  157. const {
  158. value
  159. } = e.detail;
  160. const va = value.trim();
  161. let data = JSON.parse(JSON.stringify(this.data.liveList));
  162. if (this.data.liveSelectClassify == '全部') {
  163. if (va == '') {
  164. this.setData({
  165. showLiveList: handleList.twoDimensionalArr(data, 4, 10)
  166. })
  167. } else {
  168. let arrList = data.filter(item => {
  169. let arr = [];
  170. for (let i in item) {
  171. if (item[i] != null || item[i] != undefined) arr.push(item[i])
  172. }
  173. if (arr.includes(va)) {
  174. return item
  175. }
  176. });
  177. this.setData({
  178. showLiveList: handleList.twoDimensionalArr(arrList, 4, 10)
  179. })
  180. }
  181. } else {
  182. let cList = data.filter(item => item.flocationclass == this.data.liveSelectClassify),
  183. list = cList;
  184. if (va != '') {
  185. list = cList.filter(item => {
  186. let arr = [];
  187. for (let i in item) {
  188. if (item[i] != null || item[i] != undefined) arr.push(item[i])
  189. }
  190. if (arr.includes(va)) {
  191. return item
  192. }
  193. })
  194. }
  195. this.setData({
  196. showLiveList: handleList.twoDimensionalArr(list, 4, 10)
  197. })
  198. }
  199. },
  200. /* 显示下拉 */
  201. showPullDown(e) {
  202. const {
  203. index
  204. } = e.target.dataset;
  205. if (this.data.showDownIndex == index) return this.setData({
  206. showDownIndex: -1
  207. });
  208. this.setData({
  209. showDownIndex: index
  210. })
  211. },
  212. /* 关闭 */
  213. closeTheDropDown() {
  214. this.setData({
  215. showDownIndex: -1
  216. })
  217. },
  218. /* 选择分类 */
  219. modeSelect(e) {
  220. const {
  221. name,
  222. index
  223. } = e.target.dataset;
  224. if (this.data.showDownIndex == 1) {
  225. let list = JSON.parse(JSON.stringify(this.data.liveList));
  226. if (name == '全部') {
  227. var List = list;
  228. } else {
  229. var List = list.filter(value => value.flocationclass == name);
  230. };
  231. var liveList = handleList.twoDimensionalArr(List, 4, 10);
  232. //直播大厅
  233. this.setData({
  234. showDownIndex: -1,
  235. liveSelectClassify: name,
  236. showLiveList: liveList
  237. });
  238. } else {
  239. //热门展商
  240. let list = JSON.parse(JSON.stringify(this.data.agentList));
  241. if (name == '全部') {
  242. var List = list;
  243. } else {
  244. var List = list.filter(value => value.flocationclass == name);
  245. };
  246. var agentList = handleList.twoDimensionalArr(List, 4, 10);
  247. this.setData({
  248. showDownIndex: -1,
  249. agentSelectClassify: name,
  250. showAgentList: agentList
  251. });
  252. }
  253. },
  254. /**
  255. * 生命周期函数--监听页面初次渲染完成
  256. */
  257. onReady: function () {
  258. },
  259. /**
  260. * 生命周期函数--监听页面显示
  261. */
  262. onShow: function () {
  263. },
  264. /**
  265. * 生命周期函数--监听页面隐藏
  266. */
  267. onHide: function () {
  268. },
  269. /**
  270. * 生命周期函数--监听页面卸载
  271. */
  272. onUnload: function () {
  273. },
  274. /**
  275. * 页面相关事件处理函数--监听用户下拉动作
  276. */
  277. onPullDownRefresh: function () {
  278. },
  279. /**
  280. * 页面上拉触底事件的处理函数
  281. */
  282. onReachBottom: function () {
  283. },
  284. /**
  285. * 用户点击右上角分享
  286. */
  287. onShareAppMessage: function () {
  288. }
  289. })