details.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. // pages/details/details.js
  2. const app = getApp()
  3. const link = app.globalData.url
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. p_id:"",
  10. search_id:"",
  11. goods_sign:"",
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function (options) {
  17. var that=this
  18. const goodsSign=options.goodsSign
  19. const searchId=options.searchId
  20. that.search_id = options.searchId
  21. that.goods_sign = options.goodsSign
  22. console.log(options)
  23. //const pid = "9112489_209622235"
  24. var pid = "9112489_212035116"
  25. var opneId = wx.getStorageSync('openId')
  26. console.log(opneId)
  27. //获取pid
  28. wx.request({
  29. url: link + '/v1/forward/lhf',
  30. data: { openId: opneId },
  31. header: {
  32. "Content-Type": "application/json",
  33. "function":"/v1/user/pid/get"
  34. },
  35. method: "POST",
  36. success (res) {
  37. console.log(res)
  38. console.log(pid)
  39. if (res.data.code == 200){
  40. pid = res.data.data.pid
  41. }
  42. console.log(pid)
  43. that.p_id = pid
  44. that.goods_sign = goodsSign
  45. that.search_id = searchId
  46. wx.request({
  47. url: link + '/v1/forward/lhf',
  48. data: { goods_sign: goodsSign, search_id: searchId,pid: pid },
  49. header: {
  50. "Content-Type": "application/json",
  51. "function":"/v1/pdd/ddk/detail"
  52. },
  53. method: "POST",
  54. success (res) {
  55. console.log(res)
  56. that.setData({
  57. goodsDetails: res.data.data.goods_detail_response.goods_details,
  58. searchId:searchId
  59. })
  60. }
  61. })
  62. }
  63. })
  64. },
  65. counponBtn:function(e){
  66. var that = this
  67. console.log("pdd")
  68. console.log(that.p_id)
  69. wx.request({
  70. url: link + '/v1/forward/lhf',
  71. data: { goods_sign_list: [that.goods_sign], search_id: that.search_id,p_id: that.p_id,generate_we_app:"true" },
  72. header: {
  73. "Content-Type": "application/json",
  74. "function":"/v1/pdd/url/generate"
  75. },
  76. method: "POST",
  77. success (res) {
  78. console.log(res)
  79. // that.setData({
  80. // goodsDetails: res.data.data.goods_detail_response.goods_details,
  81. // searchId:searchId
  82. // })
  83. console.log(res.data.data.goods_promotion_url_generate_response.goods_promotion_url_list[0].we_app_info.page_path)
  84. let path = res.data.data.goods_promotion_url_generate_response.goods_promotion_url_list[0].we_app_info.page_path
  85. //let path = res.data.data.goods_promotion_url_generate_response.goods_promotion_url_list[0].we_app_web_view_short_url
  86. wx.navigateToMiniProgram({
  87. appId: 'wx32540bd863b27570',
  88. path: path,
  89. success(res) {
  90. }
  91. })
  92. }
  93. })
  94. },
  95. bindscroll(e) {
  96. //计算页面 轮播图、详情、评价(砍价)view 高度
  97. this.getTopHeightFunction()
  98. var tabsHeight = this.data.tabsHeight //顶部距离(tabs高度)
  99. if (this.data.tabs[0].topHeight-tabsHeight<=0 && 0 < this.data.tabs[1].topHeight-tabsHeight) { //临界值,根据自己的需求来调整
  100. this.setData({
  101. active: this.data.tabs[0].tabs_name //设置当前标签栏
  102. })
  103. } else if (this.data.tabs.length == 2) {
  104. this.setData({
  105. active: this.data.tabs[1].tabs_name
  106. })
  107. } else if (this.data.tabs[1].topHeight-tabsHeight<=0 && 0 < this.data.tabs[2].topHeight-tabsHeight) {
  108. this.setData({
  109. active: this.data.tabs[1].tabs_name
  110. })
  111. } else if (this.data.tabs[2].topHeight-tabsHeight<=0) {
  112. this.setData({
  113. active: this.data.tabs[2].tabs_name
  114. })
  115. }
  116. },
  117. /**
  118. * 生命周期函数--监听页面初次渲染完成
  119. */
  120. onReady: function () {
  121. },
  122. /**
  123. * 生命周期函数--监听页面显示
  124. */
  125. onShow: function () {
  126. },
  127. /**
  128. * 生命周期函数--监听页面隐藏
  129. */
  130. onHide: function () {
  131. },
  132. /**
  133. * 生命周期函数--监听页面卸载
  134. */
  135. onUnload: function () {
  136. },
  137. /**
  138. * 页面相关事件处理函数--监听用户下拉动作
  139. */
  140. onPullDownRefresh: function () {
  141. },
  142. /**
  143. * 页面上拉触底事件的处理函数
  144. */
  145. onReachBottom: function () {
  146. },
  147. /**
  148. * 用户点击右上角分享
  149. */
  150. // onShareAppMessage: function () {
  151. // }
  152. /**
  153. * 用户点击右上角分享
  154. */
  155. onShareAppMessage: function () {
  156. var that = this
  157. var openId = wx.getStorageSync('openId')
  158. var goodsSign = that.goods_sign
  159. var searchId = that.search_id
  160. return {
  161. title: '电商内部优惠券',
  162. // imageUrl:"../image/yhq.jpg",
  163. desc: '优惠券小程序',
  164. path: `pages/boutique/outique?openId=${openId}&goodsSign=${goodsSign}&searchId=${searchId}` // 路径,传递参数到指定页面。
  165. //url: `/pages/details/details?goodsSign=${goodsSign}&searchId=${searchId}`,
  166. }
  167. }
  168. })