sdDetalis.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. import {
  2. ApiModel
  3. } from "../../../utils/api";
  4. const _Http = new ApiModel();
  5. const handleList = require("../../../utils/processingData");
  6. let shareTime = null;
  7. import queryLogin from '../../../utils/isLogin';
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. detalis: {}, //详情数据
  14. shareObj: null,
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad(options) {
  20. const item = JSON.parse(options.item);
  21. console.log("供需信息", item)
  22. this.setData({
  23. detalis: item
  24. });
  25. /* 获取推荐列表 */
  26. _Http.basic({
  27. "classname": "publicmethod.homepage.homepage",
  28. "method": "query_supplyanddemandList",
  29. "content": {
  30. "getdatafromdbanyway": true,
  31. "pageNumber": 1,
  32. "pageSize": 10,
  33. "siteid": "BWJ",
  34. "where": {
  35. "ftype": "",
  36. "fissupply": "0",
  37. "fstatus": "待对接"
  38. }
  39. }
  40. }).then(res => {
  41. if (res.msg != '成功') return wx.showToast({
  42. title: res.data,
  43. icon: "none"
  44. })
  45. const data = handleList.getYTD(res.data);
  46. this.setData({
  47. productList: data
  48. });
  49. });
  50. let ism = item.tenterprise_userid == wx.getStorageSync('userData').userid
  51. /* 浏览计数 */
  52. if (!ism) _Http.basic({
  53. "accesstoken": wx.getStorageSync('userData').token,
  54. "classname": "customer.supplyanddemand.supplyanddemand",
  55. "method": "query_supplyanddemandMain",
  56. "content": {
  57. "tsupplyanddemandid": item.tsupplyanddemandid
  58. }
  59. }, false).then(res => {
  60. if (res.msg != '成功') _Http.basic({
  61. "classname": "publicmethod.homepage.homepage",
  62. "method": "query_supplyanddemandMain",
  63. "content": {
  64. "tsupplyanddemandid": item.tsupplyanddemandid,
  65. "tagentsid": item.tagentsid
  66. }
  67. })
  68. });
  69. this.setData({
  70. ism
  71. })
  72. },
  73. /* 电话联系 */
  74. callUp(e) {
  75. if (!queryLogin()) return;
  76. wx.makePhoneCall({
  77. phoneNumber: e.currentTarget.dataset.phone
  78. })
  79. },
  80. toLinkUp(e) {
  81. if (!queryLogin()) return;
  82. const {
  83. tsupplyanddemandid,
  84. tenterprise_userid
  85. } = this.data.detalis;
  86. if (tenterprise_userid == wx.getStorageSync('userData').userid) return wx.showToast({
  87. title: '无法与自己对话',
  88. icon: "none"
  89. })
  90. _Http.basic({
  91. "accesstoken": wx.getStorageSync('userData').token,
  92. "classname": "customer.supplyanddemand.supplyanddemand",
  93. "method": "OpenImDialog",
  94. "content": {
  95. "tsupplyanddemandid": tsupplyanddemandid
  96. }
  97. }).then(res => {
  98. console.log("创建聊天", res)
  99. if (res.msg != '成功') return wx.showToast({
  100. title: res.data,
  101. icon: "none"
  102. })
  103. wx.navigateTo({
  104. url: '/pages/chatRoom/dialogbox?id=' + res.data[0].timdialogid,
  105. })
  106. })
  107. },
  108. /* 删除供需 */
  109. deleteItem() {
  110. console.log()
  111. wx.showModal({
  112. title: '提示',
  113. content: '是否确认删除该供需',
  114. success: (res) => {
  115. if (res.confirm) _Http.basic({
  116. "accesstoken": wx.getStorageSync('userData').token,
  117. "classname": "customer.supplyanddemand.supplyanddemand",
  118. "method": "deletesupplyanddemand",
  119. "content": {
  120. "tsupplyanddemandid": this.data.detalis.tsupplyanddemandid
  121. }
  122. }).then(res => {
  123. wx.showToast({
  124. title: res.data,
  125. icon: "none"
  126. })
  127. if (res.msg == '成功') setTimeout(() => {
  128. let pages = getCurrentPages(),
  129. prevPage = pages[pages.length - 2];
  130. prevPage.backGetList();
  131. wx.navigateBack({
  132. delta: 1
  133. })
  134. }, 1000)
  135. })
  136. }
  137. })
  138. },
  139. noToLinkUp() {
  140. wx.showToast({
  141. title: '该供需当前不可联系',
  142. icon: "none"
  143. })
  144. },
  145. /**
  146. * 生命周期函数--监听页面初次渲染完成
  147. */
  148. onReady() {
  149. },
  150. /**
  151. * 生命周期函数--监听页面显示
  152. */
  153. onShow() {
  154. },
  155. /**
  156. * 生命周期函数--监听页面隐藏
  157. */
  158. onHide() {
  159. },
  160. /**
  161. * 生命周期函数--监听页面卸载
  162. */
  163. onUnload() {
  164. },
  165. /**
  166. * 页面相关事件处理函数--监听用户下拉动作
  167. */
  168. onPullDownRefresh() {
  169. },
  170. /**
  171. * 页面上拉触底事件的处理函数
  172. */
  173. onReachBottom() {
  174. },
  175. /* 回调 */
  176. shareCallBack({
  177. detail
  178. }) {
  179. this.setData({
  180. shareObj: detail
  181. })
  182. },
  183. /**
  184. * 用户点击右上角分享
  185. */
  186. onShareAppMessage(e) {
  187. const that = this;
  188. if (e.from == 'button') {
  189. const promise = new Promise(resolve => {
  190. shareTime = setInterval(() => {
  191. if (that.data.shareObj != null) {
  192. let str = JSON.stringify(that.data.shareObj),
  193. obj = JSON.parse(str);
  194. that.setData({
  195. shareObj: null
  196. })
  197. clearInterval(shareTime);
  198. resolve({
  199. title: obj.ftitle,
  200. path: '/pages/tabbar-pages/home/sdDetalis?item=' + str,
  201. imageUrl: obj.attinfos.length >= 1 ? obj.attinfos[0].fobsurl : '',
  202. success: function (res) {
  203. if (res.errMsg == 'shareAppMessage:ok') {
  204. wx.showToast({
  205. title: '分享成功',
  206. })
  207. }
  208. },
  209. })
  210. }
  211. }, 300)
  212. })
  213. return {
  214. title: '自定义转发标题',
  215. path: '/page/user?id=123',
  216. promise
  217. }
  218. /* */
  219. } else {
  220. let obj = this.data.detalis,
  221. str = JSON.stringify(obj);
  222. return {
  223. title: obj.ftitle,
  224. path: '/pages/tabbar-pages/home/sdDetalis?item=' + str,
  225. imageUrl: obj.attinfos.length >= 1 ? obj.attinfos[0].fobsurl : '',
  226. success: function (res) {
  227. if (res.errMsg == 'shareAppMessage:ok') {
  228. wx.showToast({
  229. title: '分享成功',
  230. })
  231. }
  232. },
  233. }
  234. }
  235. }
  236. })