particulars.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. recommendationList: [], //推荐列表
  12. particulars: {}, //详情
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. let method = "query_supplyanddemandMain";
  19. if (options.type == 2) method = "query_mysupplyanddemandMain";
  20. _Http.basic({
  21. "accesstoken": wx.getStorageSync('userData').token,
  22. "classname": "customer.supplyanddemand.supplyanddemand",
  23. "method": method,
  24. "content": {
  25. "tsupplyanddemandid": options.tsupplyanddemandid
  26. }
  27. }).then(res => {
  28. let checkdate = res.data[0].checkdate;
  29. res.data[0].checkdate = checkdate.slice(0, checkdate.lastIndexOf('.'));
  30. this.setData({
  31. particulars: res.data[0]
  32. })
  33. });
  34. /* 获取推荐列表 */
  35. _Http.basic({
  36. "accesstoken": wx.getStorageSync('userData').token,
  37. "classname": "customer.supplyanddemand.supplyanddemand",
  38. "method": "query_supplyanddemandList",
  39. "content": {
  40. "getdatafromdbanyway": true,
  41. "pageNumber": 1,
  42. "pageSize": 10,
  43. "where": {}
  44. }
  45. }).then(res => {
  46. const data = handleList.checkdate(res.data)
  47. const productList = handleList.listOrdering(data);
  48. this.setData({
  49. recommendationList: productList
  50. })
  51. })
  52. },
  53. /* 跳转商品详情页 */
  54. jumpForDetails(e) {
  55. const {
  56. index
  57. } = e.currentTarget.dataset,
  58. id = this.data.recommendationList[index].tsupplyanddemandid;
  59. wx.navigateTo({
  60. url: '/pages/tabbar-pages/supplyAndDemand/particulars?tsupplyanddemandid=' + id,
  61. })
  62. },
  63. /* 预览图片 */
  64. previewImage(e) {
  65. let imageList = this.data.particulars.attinfos,
  66. urls = [];
  67. for (let i = 0; i < imageList.length; i++) {
  68. urls.push(imageList[i].fobsurl)
  69. }
  70. const {
  71. index
  72. } = e.currentTarget.dataset
  73. wx.previewImage({
  74. urls: urls,
  75. current: index
  76. })
  77. },
  78. /* 阻止冒泡 */
  79. stop() {
  80. },
  81. /* 一键联系 */
  82. contact() {
  83. console.log('一键联系')
  84. },
  85. /**
  86. * 生命周期函数--监听页面初次渲染完成
  87. */
  88. onReady: function () {
  89. },
  90. /**
  91. * 生命周期函数--监听页面显示
  92. */
  93. onShow: function () {
  94. },
  95. /**
  96. * 生命周期函数--监听页面隐藏
  97. */
  98. onHide: function () {
  99. },
  100. /**
  101. * 生命周期函数--监听页面卸载
  102. */
  103. onUnload: function () {
  104. },
  105. /**
  106. * 页面相关事件处理函数--监听用户下拉动作
  107. */
  108. onPullDownRefresh: function () {
  109. },
  110. /**
  111. * 页面上拉触底事件的处理函数
  112. */
  113. onReachBottom: function () {
  114. },
  115. /**
  116. * 用户点击右上角分享
  117. */
  118. onShareAppMessage: function () {
  119. }
  120. })