details.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. // pages/details/details.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. p_id:"",
  8. search_id:"",
  9. goods_sign:"",
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: function (options) {
  15. var that=this
  16. const goodsSign=options.goodsSign
  17. const searchId=options.searchId
  18. const pid = "9112489_209622235"
  19. that.p_id = pid
  20. that.goods_sign = goodsSign
  21. that.search_id = searchId
  22. wx.request({
  23. url: 'https://www.shisanmiao.com/v1/pdd/ddk/detail',
  24. data: { goods_sign: goodsSign, search_id: searchId,pid: pid },
  25. header: {
  26. "Content-Type": "application/json"
  27. },
  28. method: "POST",
  29. success (res) {
  30. console.log(res)
  31. that.setData({
  32. goodsDetails: res.data.data.goods_detail_response.goods_details,
  33. searchId:searchId
  34. })
  35. }
  36. })
  37. },
  38. counponBtn:function(e){
  39. var that = this
  40. console.log("pdd")
  41. wx.request({
  42. url: 'https://www.shisanmiao.com/v1/pdd/url/generate',
  43. data: { goods_sign_list: [that.goods_sign], search_id: that.search_id,p_id: that.p_id,generate_we_app:"true" },
  44. header: {
  45. "Content-Type": "application/json"
  46. },
  47. method: "POST",
  48. success (res) {
  49. console.log(res)
  50. // that.setData({
  51. // goodsDetails: res.data.data.goods_detail_response.goods_details,
  52. // searchId:searchId
  53. // })
  54. console.log(res.data.data.goods_promotion_url_generate_response.goods_promotion_url_list[0].we_app_info.page_path)
  55. let path = res.data.data.goods_promotion_url_generate_response.goods_promotion_url_list[0].we_app_info.page_path
  56. //let path = res.data.data.goods_promotion_url_generate_response.goods_promotion_url_list[0].we_app_web_view_short_url
  57. wx.navigateToMiniProgram({
  58. appId: 'wx32540bd863b27570',
  59. path: path,
  60. success(res) {
  61. }
  62. })
  63. }
  64. })
  65. },
  66. bindscroll(e) {
  67. //计算页面 轮播图、详情、评价(砍价)view 高度
  68. this.getTopHeightFunction()
  69. var tabsHeight = this.data.tabsHeight //顶部距离(tabs高度)
  70. if (this.data.tabs[0].topHeight-tabsHeight<=0 && 0 < this.data.tabs[1].topHeight-tabsHeight) { //临界值,根据自己的需求来调整
  71. this.setData({
  72. active: this.data.tabs[0].tabs_name //设置当前标签栏
  73. })
  74. } else if (this.data.tabs.length == 2) {
  75. this.setData({
  76. active: this.data.tabs[1].tabs_name
  77. })
  78. } else if (this.data.tabs[1].topHeight-tabsHeight<=0 && 0 < this.data.tabs[2].topHeight-tabsHeight) {
  79. this.setData({
  80. active: this.data.tabs[1].tabs_name
  81. })
  82. } else if (this.data.tabs[2].topHeight-tabsHeight<=0) {
  83. this.setData({
  84. active: this.data.tabs[2].tabs_name
  85. })
  86. }
  87. },
  88. /**
  89. * 生命周期函数--监听页面初次渲染完成
  90. */
  91. onReady: function () {
  92. },
  93. /**
  94. * 生命周期函数--监听页面显示
  95. */
  96. onShow: function () {
  97. },
  98. /**
  99. * 生命周期函数--监听页面隐藏
  100. */
  101. onHide: function () {
  102. },
  103. /**
  104. * 生命周期函数--监听页面卸载
  105. */
  106. onUnload: function () {
  107. },
  108. /**
  109. * 页面相关事件处理函数--监听用户下拉动作
  110. */
  111. onPullDownRefresh: function () {
  112. },
  113. /**
  114. * 页面上拉触底事件的处理函数
  115. */
  116. onReachBottom: function () {
  117. },
  118. /**
  119. * 用户点击右上角分享
  120. */
  121. onShareAppMessage: function () {
  122. }
  123. })