storehomepage.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import {
  2. ApiModel
  3. } from "../../utils/api"
  4. const _Http = new ApiModel();
  5. let WxParse = require('../../wxParse/wxParse.js');
  6. let processingData = require('../../utils/processingData.js');
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. storeMsg: [], //用户信息
  13. showSaleprodclass: [], //显示经营分类
  14. productList: [], //产品列表
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. /* 获取用户信息 */
  21. _Http.basic({
  22. "accesstoken": wx.getStorageSync('userData').token,
  23. "classname": "customer.tagents.tagents",
  24. "method": "query_cooperationAgentsMain",
  25. "content": {
  26. "tagentsid": options.id
  27. }
  28. }).then(res => {
  29. if (res.msg != '成功') return wx.showToast({
  30. title: res.data,
  31. icon: 'none'
  32. })
  33. if (res.data[0].fintroduction != 'null' && res.data[0].fintroduction != '' && res.data[0].fintroduction != undefined) {
  34. var article = res.data[0].fintroduction;
  35. var that = this;
  36. WxParse.wxParse('article', 'html', article, that, 5);
  37. }
  38. //处理经营分类
  39. let showSaleprodclass = '';
  40. if (res.data[0].saleprodclass != '' && res.data[0].saleprodclass != 'null' && res.data[0].saleprodclass != undefined) {
  41. for (let i = 0; i < res.data[0].saleprodclass.length; i++) {
  42. showSaleprodclass += ',' + res.data[0].saleprodclass[i]
  43. }
  44. showSaleprodclass = showSaleprodclass.slice(1)
  45. }
  46. let data = res.data[0]
  47. for (let i in data) {
  48. if (data[i] == '' || data[i] == null || data[i] == undefined || data[i] == []) {
  49. data[i] = '暂无'
  50. }
  51. }
  52. if (showSaleprodclass == '') showSaleprodclass = '暂无';
  53. this.setData({
  54. storeMsg: data,
  55. showSaleprodclass
  56. })
  57. });
  58. /* 获取产品列表 */
  59. _Http.basic({
  60. "accesstoken": wx.getStorageSync('userData').token,
  61. "classname": "customer.products.products",
  62. "method": "query_cooperationProductsList",
  63. "content": {
  64. "getdatafromdbanyway": true,
  65. "pageNumber": 1,
  66. "pageSize": 30,
  67. "tagentsid": options.id
  68. }
  69. }).then(res => {
  70. if (res.msg != '成功') return wx.showToast({
  71. title: res.data,
  72. icon: 'none'
  73. })
  74. let data = processingData.twoDimensionalArr(res.data, 6, 5);
  75. this.setData({
  76. productList: data
  77. })
  78. })
  79. },
  80. /**
  81. * 生命周期函数--监听页面初次渲染完成
  82. */
  83. onReady: function () {
  84. },
  85. /**
  86. * 生命周期函数--监听页面显示
  87. */
  88. onShow: function () {
  89. },
  90. /**
  91. * 生命周期函数--监听页面隐藏
  92. */
  93. onHide: function () {
  94. },
  95. /**
  96. * 生命周期函数--监听页面卸载
  97. */
  98. onUnload: function () {
  99. },
  100. /**
  101. * 页面相关事件处理函数--监听用户下拉动作
  102. */
  103. onPullDownRefresh: function () {
  104. },
  105. /**
  106. * 页面上拉触底事件的处理函数
  107. */
  108. onReachBottom: function () {
  109. },
  110. /**
  111. * 用户点击右上角分享
  112. */
  113. onShareAppMessage: function () {
  114. }
  115. })