storehomepage.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 list = processingData.imageType(res.data, "default")
  75. let productList = processingData.twoDimensionalArr(list, 6, 5),
  76. double = '';
  77. (productList[0].length > 3) ? double = true: double = false;
  78. this.setData({
  79. productList,
  80. double
  81. })
  82. })
  83. },
  84. toLinkUp() {
  85. _Http.basic({
  86. "accesstoken": wx.getStorageSync('userData').token,
  87. "classname": "system.im.imdialog.imdialog",
  88. "method": "quickcontact",
  89. "content": {
  90. "tenterprise_userid": this.data.storeMsg.tenterprise_userid
  91. }
  92. }).then(res => {
  93. console.log("创建聊天", res)
  94. if (res.msg != '成功') return wx.showToast({
  95. title: res.data,
  96. icon: "none"
  97. })
  98. wx.navigateTo({
  99. url: '/pages/chatRoom/dialogbox?id=' + res.data[0].timdialogid,
  100. })
  101. })
  102. },
  103. /**
  104. * 生命周期函数--监听页面初次渲染完成
  105. */
  106. onReady: function () {
  107. },
  108. /**
  109. * 生命周期函数--监听页面显示
  110. */
  111. onShow: function () {
  112. },
  113. /**
  114. * 生命周期函数--监听页面隐藏
  115. */
  116. onHide: function () {
  117. },
  118. /**
  119. * 生命周期函数--监听页面卸载
  120. */
  121. onUnload: function () {
  122. },
  123. /**
  124. * 页面相关事件处理函数--监听用户下拉动作
  125. */
  126. onPullDownRefresh: function () {
  127. },
  128. /**
  129. * 页面上拉触底事件的处理函数
  130. */
  131. onReachBottom: function () {
  132. },
  133. /**
  134. * 用户点击右上角分享
  135. */
  136. onShareAppMessage: function () {
  137. }
  138. })