details.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. //const pid = "9112489_209622235"
  21. var pid = "9112489_212035116"
  22. var opneId = wx.getStorageSync('openId')
  23. console.log(opneId)
  24. //获取pid
  25. wx.request({
  26. url: link + '/v1/forward/lhf',
  27. data: { openId: opneId },
  28. header: {
  29. "Content-Type": "application/json",
  30. "function":"/v1/user/pid/get"
  31. },
  32. method: "POST",
  33. success (res) {
  34. console.log(res)
  35. console.log(pid)
  36. if (res.data.code == 200){
  37. pid = res.data.data.pid
  38. }
  39. console.log(pid)
  40. that.p_id = pid
  41. that.goods_sign = goodsSign
  42. that.search_id = searchId
  43. wx.request({
  44. url: link + '/v1/forward/lhf',
  45. data: { goods_sign: goodsSign, search_id: searchId,pid: pid },
  46. header: {
  47. "Content-Type": "application/json",
  48. "function":"/v1/pdd/ddk/detail"
  49. },
  50. method: "POST",
  51. success (res) {
  52. console.log(res)
  53. that.setData({
  54. goodsDetails: res.data.data.goods_detail_response.goods_details,
  55. searchId:searchId
  56. })
  57. }
  58. })
  59. }
  60. })
  61. },
  62. counponBtn:function(e){
  63. var that = this
  64. console.log("pdd")
  65. console.log(that.p_id)
  66. wx.request({
  67. url: link + '/v1/forward/lhf',
  68. data: { goods_sign_list: [that.goods_sign], search_id: that.search_id,p_id: that.p_id,generate_we_app:"true" },
  69. header: {
  70. "Content-Type": "application/json",
  71. "function":"/v1/pdd/url/generate"
  72. },
  73. method: "POST",
  74. success (res) {
  75. console.log(res)
  76. // that.setData({
  77. // goodsDetails: res.data.data.goods_detail_response.goods_details,
  78. // searchId:searchId
  79. // })
  80. console.log(res.data.data.goods_promotion_url_generate_response.goods_promotion_url_list[0].we_app_info.page_path)
  81. let path = res.data.data.goods_promotion_url_generate_response.goods_promotion_url_list[0].we_app_info.page_path
  82. //let path = res.data.data.goods_promotion_url_generate_response.goods_promotion_url_list[0].we_app_web_view_short_url
  83. wx.navigateToMiniProgram({
  84. appId: 'wx32540bd863b27570',
  85. path: path,
  86. success(res) {
  87. }
  88. })
  89. }
  90. })
  91. },
  92. bindscroll(e) {
  93. //计算页面 轮播图、详情、评价(砍价)view 高度
  94. this.getTopHeightFunction()
  95. var tabsHeight = this.data.tabsHeight //顶部距离(tabs高度)
  96. if (this.data.tabs[0].topHeight-tabsHeight<=0 && 0 < this.data.tabs[1].topHeight-tabsHeight) { //临界值,根据自己的需求来调整
  97. this.setData({
  98. active: this.data.tabs[0].tabs_name //设置当前标签栏
  99. })
  100. } else if (this.data.tabs.length == 2) {
  101. this.setData({
  102. active: this.data.tabs[1].tabs_name
  103. })
  104. } else if (this.data.tabs[1].topHeight-tabsHeight<=0 && 0 < this.data.tabs[2].topHeight-tabsHeight) {
  105. this.setData({
  106. active: this.data.tabs[1].tabs_name
  107. })
  108. } else if (this.data.tabs[2].topHeight-tabsHeight<=0) {
  109. this.setData({
  110. active: this.data.tabs[2].tabs_name
  111. })
  112. }
  113. },
  114. /**
  115. * 生命周期函数--监听页面初次渲染完成
  116. */
  117. onReady: function () {
  118. },
  119. /**
  120. * 生命周期函数--监听页面显示
  121. */
  122. onShow: function () {
  123. },
  124. /**
  125. * 生命周期函数--监听页面隐藏
  126. */
  127. onHide: function () {
  128. },
  129. /**
  130. * 生命周期函数--监听页面卸载
  131. */
  132. onUnload: function () {
  133. },
  134. /**
  135. * 页面相关事件处理函数--监听用户下拉动作
  136. */
  137. onPullDownRefresh: function () {
  138. },
  139. /**
  140. * 页面上拉触底事件的处理函数
  141. */
  142. onReachBottom: function () {
  143. },
  144. /**
  145. * 用户点击右上角分享
  146. */
  147. // onShareAppMessage: function () {
  148. // }
  149. })