index.js 4.8 KB

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