index.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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. productList: [], //供需列表
  12. //轮播图列表
  13. swiperBannerList: [],
  14. /* 宫格列表 */
  15. gridList: [{
  16. text: '供需广场',
  17. icon: '/static/home-grid/icon-02.png'
  18. }, {
  19. text: '私域直播',
  20. icon: '/static/home-grid/icon-01.png'
  21. }],
  22. /* 圆角按钮tabs列表 */
  23. roundedList: [
  24. "兴趣爱好", "关注板块", "最新发布"
  25. ],
  26. partnerList: [], //合作商家列表
  27. },
  28. /* tabs切换 */
  29. /* tabsSelectedIitem(text) {
  30. console.log(text.detail)
  31. }, */
  32. /* 宫格区跳转 */
  33. gridJumpPage(e) {
  34. const {
  35. name
  36. } = e.target.dataset;
  37. if (name == '供需广场') {
  38. wx.switchTab({
  39. url: '/pages/tabbar-pages/supplyAndDemand/index',
  40. })
  41. } else if (name == '私域直播') {
  42. wx.navigateTo({
  43. url: '/pages/liveStreaming/index',
  44. })
  45. } else {
  46. wx.showToast({
  47. title: '功能开发中',
  48. icon: "none"
  49. })
  50. }
  51. },
  52. /* 获得展示区标题 */
  53. getExhibitionTitle(title) {
  54. const {
  55. detail
  56. } = title;
  57. if (detail == '最新供需') {
  58. wx.switchTab({
  59. url: '/pages/tabbar-pages/supplyAndDemand/index',
  60. })
  61. } else if (detail == '合作商家') {
  62. wx.navigateTo({
  63. url: '/pages/businessPartner/index',
  64. })
  65. }
  66. },
  67. /**
  68. * 生命周期函数--监听页面加载
  69. */
  70. onLoad: function (options) {
  71. if (wx.getStorageSync('qrCodeMsg').type) return wx.navigateTo({
  72. url: '/pages/login/QrCode',
  73. });
  74. const that = this;
  75. /* 获取最新供需列表 */
  76. _Http.basic({
  77. "accesstoken": wx.getStorageSync('userData').token,
  78. "classname": "customer.supplyanddemand.supplyanddemand",
  79. "method": "query_supplyanddemandList",
  80. "content": {
  81. "getdatafromdbanyway": true,
  82. "pageNumber": 1,
  83. "pageSize": 8,
  84. "where": {
  85. "fissupply": "0",
  86. "fstatus": "待对接"
  87. }
  88. }
  89. }).then(res => {
  90. console.log(res)
  91. if (res.msg != '成功') return wx.showToast({
  92. title: res.data,
  93. icon: "none"
  94. });
  95. const data = handleList.getYTD(res.data);
  96. this.setData({
  97. productList: data
  98. })
  99. });
  100. /* 获取合作商家 */
  101. _Http.basic({
  102. "accesstoken": wx.getStorageSync('userData').token,
  103. "classname": "customer.tagents.tagents",
  104. "method": "query_cooperation",
  105. "content": {
  106. "getdatafromdbanyway": true,
  107. "pageNumber": 1,
  108. "pageSize": 9,
  109. "where": {
  110. "condition": "",
  111. "ftype": "",
  112. "fstatus": "合作"
  113. }
  114. }
  115. }).then(res => {
  116. if (res.msg != '成功') return wx.showToast({
  117. title: res.data,
  118. icon: "none"
  119. });
  120. let data = handleList.imageType(res.data, 'brandlogo')
  121. const partnerList = handleList.twoDimensionalArr(data, 3);
  122. this.setData({
  123. partnerList
  124. })
  125. })
  126. /* 获取轮播图 */
  127. const bannerList = getApp().globalData.bannerDataList.filter(value => value.flocation == 'home_head');
  128. this.setData({
  129. swiperBannerList: bannerList[0].banner
  130. });
  131. //获取信息数量
  132. this.selectComponent("#gxshuju").unReadMessageCount();
  133. setTimeout(() => {
  134. that.getTabBar().setData({
  135. 'tabbarList[3].fcount': getApp().globalData.msgFcount
  136. })
  137. }, 500)
  138. },
  139. /* 一键联系 */
  140. contact() {
  141. /* wx.showToast({
  142. title: '功能尚在开发',
  143. icon: "none"
  144. }) */
  145. },
  146. /**
  147. * 生命周期函数--监听页面初次渲染完成
  148. */
  149. onReady: function () {
  150. },
  151. /**
  152. * 生命周期函数--监听页面显示
  153. */
  154. onShow: function () {
  155. this.getTabBar().init();
  156. this.getTabBar().setData({
  157. 'tabbarList[3].fcount': getApp().globalData.msgFcount
  158. })
  159. },
  160. /**
  161. * 生命周期函数--监听页面隐藏
  162. */
  163. onHide: function () {
  164. },
  165. /**
  166. * 生命周期函数--监听页面卸载
  167. */
  168. onUnload: function () {
  169. },
  170. /**
  171. * 页面相关事件处理函数--监听用户下拉动作
  172. */
  173. onPullDownRefresh: function () {
  174. },
  175. /**
  176. * 页面上拉触底事件的处理函数
  177. */
  178. onReachBottom: function () {
  179. },
  180. /**
  181. * 用户点击右上角分享
  182. */
  183. onShareAppMessage: function () {
  184. }
  185. })