index.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. /* 获取最新供需列表 */
  72. _Http.basic({
  73. "accesstoken": wx.getStorageSync('userData').token,
  74. "classname": "customer.supplyanddemand.supplyanddemand",
  75. "method": "query_supplyanddemandList",
  76. "content": {
  77. "getdatafromdbanyway": true,
  78. "pageNumber": 1,
  79. "pageSize": 8,
  80. "where": {
  81. "fissupply": "0",
  82. "fstatus": "待对接"
  83. }
  84. }
  85. }).then(res => {
  86. if (res.msg != '成功') return wx.showToast({
  87. title: res.data,
  88. icon: "none"
  89. });
  90. const data = handleList.getYTD(res.data)
  91. const productList = handleList.listOrdering(data);
  92. this.setData({
  93. productList
  94. })
  95. });
  96. /* 获取合作商家 */
  97. _Http.basic({
  98. "accesstoken": wx.getStorageSync('userData').token,
  99. "classname": "customer.tagents.tagents",
  100. "method": "query_cooperation",
  101. "content": {
  102. "getdatafromdbanyway": true,
  103. "pageNumber": 1,
  104. "pageSize": 9,
  105. "where": {
  106. "condition": "",
  107. "ftype": "",
  108. "fstatus": "合作"
  109. }
  110. }
  111. }).then(res => {
  112. if (res.msg != '成功') return wx.showToast({
  113. title: res.data,
  114. icon: "none"
  115. });
  116. let data = handleList.imageType(res.data, 'brandlogo')
  117. const partnerList = handleList.twoDimensionalArr(data, 3);
  118. this.setData({
  119. partnerList
  120. })
  121. })
  122. /* 获取轮播图 */
  123. const bannerList = getApp().globalData.bannerDataList.filter(value => value.flocation == 'home_head');
  124. this.setData({
  125. swiperBannerList: bannerList[0].banner
  126. });
  127. },
  128. /* 一键联系 */
  129. contact() {
  130. /* wx.showToast({
  131. title: '功能尚在开发',
  132. icon: "none"
  133. }) */
  134. },
  135. /**
  136. * 生命周期函数--监听页面初次渲染完成
  137. */
  138. onReady: function () {
  139. },
  140. /**
  141. * 生命周期函数--监听页面显示
  142. */
  143. onShow: function () {
  144. this.getTabBar().init();
  145. },
  146. /**
  147. * 生命周期函数--监听页面隐藏
  148. */
  149. onHide: function () {
  150. },
  151. /**
  152. * 生命周期函数--监听页面卸载
  153. */
  154. onUnload: function () {
  155. },
  156. /**
  157. * 页面相关事件处理函数--监听用户下拉动作
  158. */
  159. onPullDownRefresh: function () {
  160. },
  161. /**
  162. * 页面上拉触底事件的处理函数
  163. */
  164. onReachBottom: function () {
  165. },
  166. /**
  167. * 用户点击右上角分享
  168. */
  169. onShareAppMessage: function () {
  170. }
  171. })