sdDetalis.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. import {
  2. ApiModel
  3. } from "../../../utils/api";
  4. const _Http = new ApiModel();
  5. const handleList = require("../../../utils/processingData");
  6. let shareTime = null;
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. detalis: {}, //详情数据
  13. shareObj: null,
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad(options) {
  19. const item = JSON.parse(options.item);
  20. console.log("供需信息", item)
  21. this.setData({
  22. detalis: item
  23. });
  24. /* 获取推荐列表 */
  25. _Http.basic({
  26. "classname": "publicmethod.homepage.homepage",
  27. "method": "query_supplyanddemandList",
  28. "content": {
  29. "getdatafromdbanyway": true,
  30. "pageNumber": 1,
  31. "pageSize": 10,
  32. "siteid": "BWJ",
  33. "where": {
  34. "ftype": "",
  35. "fissupply": "0",
  36. "fstatus": "待对接"
  37. }
  38. }
  39. }).then(res => {
  40. if (res.msg != '成功') return wx.showToast({
  41. title: res.data,
  42. icon: "none"
  43. })
  44. const data = handleList.getYTD(res.data);
  45. this.setData({
  46. productList: data
  47. });
  48. });
  49. /* 浏览计数 */
  50. if (item.tenterprise_userid != wx.getStorageSync('userData').userid) _Http.basic({
  51. "accesstoken": wx.getStorageSync('userData').token,
  52. "classname": "customer.supplyanddemand.supplyanddemand",
  53. "method": "query_supplyanddemandMain",
  54. "content": {
  55. "tsupplyanddemandid": item.tsupplyanddemandid
  56. }
  57. }, false).then(res => {
  58. if (res.msg != '成功') _Http.basic({
  59. "classname": "publicmethod.homepage.homepage",
  60. "method": "query_supplyanddemandMain",
  61. "content": {
  62. "tsupplyanddemandid": item.tsupplyanddemandid,
  63. "tagentsid": item.tagentsid
  64. }
  65. })
  66. })
  67. },
  68. /* 电话联系 */
  69. callUp(e) {
  70. wx.makePhoneCall({
  71. phoneNumber: e.currentTarget.dataset.phone
  72. })
  73. },
  74. /**
  75. * 生命周期函数--监听页面初次渲染完成
  76. */
  77. onReady() {
  78. },
  79. /**
  80. * 生命周期函数--监听页面显示
  81. */
  82. onShow() {
  83. },
  84. /**
  85. * 生命周期函数--监听页面隐藏
  86. */
  87. onHide() {
  88. },
  89. /**
  90. * 生命周期函数--监听页面卸载
  91. */
  92. onUnload() {
  93. },
  94. /**
  95. * 页面相关事件处理函数--监听用户下拉动作
  96. */
  97. onPullDownRefresh() {
  98. },
  99. /**
  100. * 页面上拉触底事件的处理函数
  101. */
  102. onReachBottom() {
  103. },
  104. /* 回调 */
  105. shareCallBack({
  106. detail
  107. }) {
  108. this.setData({
  109. shareObj: detail
  110. })
  111. },
  112. /**
  113. * 用户点击右上角分享
  114. */
  115. onShareAppMessage(e) {
  116. const that = this;
  117. if (e.from == 'button') {
  118. const promise = new Promise(resolve => {
  119. shareTime = setInterval(() => {
  120. if (that.data.shareObj != null) {
  121. let str = JSON.stringify(that.data.shareObj),
  122. obj = JSON.parse(str);
  123. that.setData({
  124. shareObj: null
  125. })
  126. clearInterval(shareTime);
  127. resolve({
  128. title: obj.ftitle,
  129. path: '/pages/tabbar-pages/home/sdDetalis?item=' + str,
  130. imageUrl: obj.attinfos.length >= 1 ? obj.attinfos[0].fobsurl : '',
  131. success: function (res) {
  132. if (res.errMsg == 'shareAppMessage:ok') {
  133. wx.showToast({
  134. title: '分享成功',
  135. })
  136. }
  137. },
  138. })
  139. }
  140. }, 300)
  141. })
  142. return {
  143. title: '自定义转发标题',
  144. path: '/page/user?id=123',
  145. promise
  146. }
  147. /* */
  148. } else {
  149. let obj = this.data.detalis,
  150. str = JSON.stringify(obj);
  151. return {
  152. title: obj.ftitle,
  153. path: '/pages/tabbar-pages/home/sdDetalis?item=' + str,
  154. imageUrl: obj.attinfos.length >= 1 ? obj.attinfos[0].fobsurl : '',
  155. success: function (res) {
  156. if (res.errMsg == 'shareAppMessage:ok') {
  157. wx.showToast({
  158. title: '分享成功',
  159. })
  160. }
  161. },
  162. }
  163. }
  164. }
  165. })