123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- // pages/details/details.js
- const app = getApp()
- const link = app.globalData.url
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- p_id:"",
- search_id:"",
- goods_sign:"",
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- var that=this
- const goodsSign=options.goodsSign
- const searchId=options.searchId
- //const pid = "9112489_209622235"
- var pid = "9112489_212035116"
- var opneId = wx.getStorageSync('openId')
- console.log(opneId)
- //获取pid
- wx.request({
- url: link + '/v1/forward/lhf',
- data: { openId: opneId },
- header: {
- "Content-Type": "application/json",
- "function":"/v1/user/pid/get"
- },
- method: "POST",
-
- success (res) {
- console.log(res)
- console.log(pid)
- if (res.data.code == 200){
- pid = res.data.data.pid
- }
- console.log(pid)
- that.p_id = pid
- that.goods_sign = goodsSign
- that.search_id = searchId
- wx.request({
- url: link + '/v1/forward/lhf',
- data: { goods_sign: goodsSign, search_id: searchId,pid: pid },
- header: {
- "Content-Type": "application/json",
- "function":"/v1/pdd/ddk/detail"
- },
- method: "POST",
-
- success (res) {
- console.log(res)
- that.setData({
- goodsDetails: res.data.data.goods_detail_response.goods_details,
- searchId:searchId
- })
-
- }
- })
- }
- })
-
- },
- counponBtn:function(e){
- var that = this
- console.log("pdd")
- console.log(that.p_id)
- wx.request({
- url: link + '/v1/forward/lhf',
- data: { goods_sign_list: [that.goods_sign], search_id: that.search_id,p_id: that.p_id,generate_we_app:"true" },
- header: {
- "Content-Type": "application/json",
- "function":"/v1/pdd/url/generate"
- },
- method: "POST",
-
- success (res) {
- console.log(res)
- // that.setData({
- // goodsDetails: res.data.data.goods_detail_response.goods_details,
- // searchId:searchId
- // })
- console.log(res.data.data.goods_promotion_url_generate_response.goods_promotion_url_list[0].we_app_info.page_path)
- let path = res.data.data.goods_promotion_url_generate_response.goods_promotion_url_list[0].we_app_info.page_path
- //let path = res.data.data.goods_promotion_url_generate_response.goods_promotion_url_list[0].we_app_web_view_short_url
- wx.navigateToMiniProgram({
- appId: 'wx32540bd863b27570',
- path: path,
- success(res) {
- }
- })
- }
- })
-
-
- },
- bindscroll(e) {
- //计算页面 轮播图、详情、评价(砍价)view 高度
- this.getTopHeightFunction()
- var tabsHeight = this.data.tabsHeight //顶部距离(tabs高度)
- if (this.data.tabs[0].topHeight-tabsHeight<=0 && 0 < this.data.tabs[1].topHeight-tabsHeight) { //临界值,根据自己的需求来调整
- this.setData({
- active: this.data.tabs[0].tabs_name //设置当前标签栏
- })
- } else if (this.data.tabs.length == 2) {
- this.setData({
- active: this.data.tabs[1].tabs_name
- })
- } else if (this.data.tabs[1].topHeight-tabsHeight<=0 && 0 < this.data.tabs[2].topHeight-tabsHeight) {
- this.setData({
- active: this.data.tabs[1].tabs_name
- })
- } else if (this.data.tabs[2].topHeight-tabsHeight<=0) {
- this.setData({
- active: this.data.tabs[2].tabs_name
- })
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- // onShareAppMessage: function () {
- // }
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- var openId = wx.getStorageSync('openId')
- return {
- title: '电商内部优惠券',
- // imageUrl:"../image/yhq.jpg",
- desc: '优惠券小程序',
- path: 'pages/boutique/outique?openId=' + openId // 路径,传递参数到指定页面。
- }
- }
- })
|