details.js 4.0 KB

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