|
@@ -10,6 +10,12 @@ Page({
|
|
|
p_id:"",
|
|
|
search_id:"",
|
|
|
goods_sign:"",
|
|
|
+ goods_details:"",
|
|
|
+ goods_name:"",
|
|
|
+ amount:0,
|
|
|
+ price:0,
|
|
|
+ rebate:0,
|
|
|
+ text:"",
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -17,12 +23,40 @@ Page({
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
var that=this
|
|
|
+ console.log("ppp="+options)
|
|
|
+ console.log(options)
|
|
|
const goodsSign=options.goodsSign
|
|
|
const searchId=options.searchId
|
|
|
//const pid = "9112489_209622235"
|
|
|
var pid = "9112489_212035116"
|
|
|
var opneId = wx.getStorageSync('openId')
|
|
|
console.log(opneId)
|
|
|
+ if (options.id == "111"){
|
|
|
+ console.log(options.id)
|
|
|
+ wx.login({
|
|
|
+ success: res => {
|
|
|
+ // 发送 res.code 到后台换取 openId, sessionKey, unionId
|
|
|
+ console.log(res)
|
|
|
+ wx.request( {
|
|
|
+ url: link + "/v1/user/open.id/set",
|
|
|
+ header: {
|
|
|
+ "Content-Type": "application/json"
|
|
|
+ },
|
|
|
+ method: "POST",
|
|
|
+ //
|
|
|
+ data: { code: res.code,openId: options.openId },
|
|
|
+ complete: function( res ) {
|
|
|
+ console.log(res)
|
|
|
+ console.log('openid='+ options.openId )
|
|
|
+ if (res.data.code == 200){
|
|
|
+ wx.setStorageSync('openId', res.data.data.openid)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
//获取pid
|
|
|
wx.request({
|
|
|
url: link + '/v1/user/pid/get',
|
|
@@ -52,6 +86,14 @@ Page({
|
|
|
|
|
|
success (res) {
|
|
|
console.log(res)
|
|
|
+ that.goods_details = res.data.data.goods_detail_response.goods_details[0].goods_image_url
|
|
|
+
|
|
|
+ that.amount =(res.data.data.goods_detail_response.goods_details[0].min_group_price - res.data.data.goods_detail_response.goods_details[0].coupon_discount)/100
|
|
|
+ that.price = (res.data.data.goods_detail_response.goods_details[0].min_group_price)/100
|
|
|
+ that.rebate = res.data.data.goods_detail_response.goods_details[0].rebate
|
|
|
+
|
|
|
+ that.goods_name = res.data.data.goods_detail_response.goods_details[0].goods_name
|
|
|
+ that.text = that.goods_name + "\n" + "原价:" + that.price + "元\n" + "优惠价:"+that.amount + "元\n" + "返利:"+that.rebate + "元\n" + "点击下方链接即可查看产品详情"
|
|
|
that.setData({
|
|
|
goodsDetails: res.data.data.goods_detail_response.goods_details,
|
|
|
searchId:searchId
|
|
@@ -64,6 +106,35 @@ Page({
|
|
|
|
|
|
|
|
|
|
|
|
+ },
|
|
|
+ copyText: function (e) {
|
|
|
+ var that = this
|
|
|
+ console.log(e)
|
|
|
+
|
|
|
+ wx.setClipboardData({
|
|
|
+
|
|
|
+ data: that.text,
|
|
|
+
|
|
|
+ success: function (res) {
|
|
|
+
|
|
|
+ wx.getClipboardData({
|
|
|
+
|
|
|
+ success: function (res) {
|
|
|
+
|
|
|
+ wx.showToast({
|
|
|
+
|
|
|
+ title: '复制成功'
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
},
|
|
|
counponBtn:function(e){
|
|
|
var that = this
|
|
@@ -133,7 +204,7 @@ Page({
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -167,7 +238,38 @@ Page({
|
|
|
/**
|
|
|
* 用户点击右上角分享
|
|
|
*/
|
|
|
- // onShareAppMessage: function () {
|
|
|
+ onShareAppMessage: function () {
|
|
|
+ var that = this
|
|
|
+ var openId = wx.getStorageSync('openId')
|
|
|
+ var goodsSign = that.goods_sign
|
|
|
+ var searchId = that.search_id
|
|
|
+ wx.showShareMenu({
|
|
|
+ withShareTicket: true,
|
|
|
+ menus: ['shareAppMessage', 'shareTimeline']
|
|
|
+ })
|
|
|
|
|
|
- // }
|
|
|
+ return {
|
|
|
+ title: '自定义转发标题',
|
|
|
+ path: `pages/boutique/outique?openId=${openId}&goodsSign=${goodsSign}&searchId=${searchId}` // 路径,传递参数到指定页面。,
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ onShareTimeline: function(){
|
|
|
+ var that = this
|
|
|
+ var openId = wx.getStorageSync('openId')
|
|
|
+ var goodsSign = that.goods_sign
|
|
|
+ var searchId = that.search_id
|
|
|
+ // return {
|
|
|
+ // title: '自定义转发标题',
|
|
|
+ // path: '/page/user?id=123',
|
|
|
+ // promise
|
|
|
+ // }
|
|
|
+ return {
|
|
|
+ title: that.goods_name,
|
|
|
+ query:'goodsSign='+ goodsSign +'&searchId=' + searchId + '&openId=' + openId + '&id=111',
|
|
|
+ imageUrl: that.goods_details
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
})
|