212 lines
4.5 KiB
JavaScript
212 lines
4.5 KiB
JavaScript
// pages/member/IntegralPresent/IntegralPresent.js
|
|
var app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
integral: '',
|
|
id: '',
|
|
path: '',
|
|
title: '',
|
|
member_avatar: "",
|
|
member_nickname: "xxx",
|
|
activity_title: '活动标题',
|
|
activity_explain: "",
|
|
activity_average: "0.00"
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function(options) {
|
|
if (options.activity_id) {
|
|
this.setData({
|
|
id: options.activity_id
|
|
});
|
|
} else {
|
|
wx.navigateBack({
|
|
delta: 1
|
|
});
|
|
}
|
|
try {
|
|
const value = wx.getStorageSync('integral');
|
|
if (value) {
|
|
this.setData({
|
|
integral: value
|
|
});
|
|
// Do something with return value
|
|
if (this.data.integral) {
|
|
wx.setNavigationBarTitle({
|
|
title: this.data.integral + '推广'
|
|
});
|
|
}
|
|
}
|
|
} catch (e) {
|
|
// Do something when catch error
|
|
}
|
|
this._getData();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function() {
|
|
wx.showShareMenu({
|
|
withShareTicket: false,
|
|
menus: ['shareAppMessage', 'shareTimeline']
|
|
});
|
|
// this._initShare();
|
|
this._share();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareTimeline(){
|
|
return{
|
|
title:this.data.title,
|
|
query:`share_tag=2&mid=${uid}`
|
|
};
|
|
},
|
|
onShareAppMessage: function(res) {
|
|
return {
|
|
title: this.data.title,
|
|
path: this.data.path
|
|
};
|
|
},
|
|
_getData() {
|
|
let that = this;
|
|
let urlStr = app.getNetAddresss("plugin.point-activity.Frontend.Modules.Activity.Controllers.receive-page.index");
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
showToastIn: false,
|
|
data: {
|
|
activity_id: that.data.id
|
|
},
|
|
success: function(resdata) {
|
|
var res = resdata.data;
|
|
if (res.result == 1) {
|
|
let activityDate = res.data;
|
|
that.setData({
|
|
member_avatar: activityDate.member_avatar,
|
|
member_nickname: activityDate.member_nickname,
|
|
activity_title: activityDate.activity_title,
|
|
activity_explain: activityDate.activity_explain,
|
|
activity_average: activityDate.activity_average
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: res.msg,
|
|
duration: 1500
|
|
});
|
|
}
|
|
|
|
},
|
|
fail: function(res) {}
|
|
});
|
|
},
|
|
//初始化分享设置
|
|
_initShare() {
|
|
let that = this;
|
|
let urlStr = app.getNetAddresss("member.member.wxJsSdkConfig");
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
showToastIn: false,
|
|
data: {},
|
|
success: function(resdata) {
|
|
var res = resdata.data;
|
|
if (res.result == 1) {
|
|
that._share(res.data);
|
|
} else {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: res.msg,
|
|
duration: 1500
|
|
});
|
|
}
|
|
|
|
},
|
|
fail: function(res) {}
|
|
});
|
|
},
|
|
_share() {
|
|
let that = this;
|
|
let uid = wx.getStorageSync('yz_uid');
|
|
let _title = (app._isTextEmpty(that.data.member_nickname)) ? that.data.activity_title : (that.member_nickname +
|
|
that.activity_title);
|
|
let _link = '/packageB/member/IntegralPresent/IntegralPresent?share_tag=2&mid=' + uid +'&activity_id='+this.data.id;
|
|
this.setData({
|
|
title: _title,
|
|
path: _link,
|
|
uid:uid
|
|
});
|
|
},
|
|
receive() {
|
|
let that = this;
|
|
let urlStr = app.getNetAddresss("plugin.point-activity.Frontend.Modules.Activity.Controllers.receive.index");
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
showToastIn: false,
|
|
data: {
|
|
activity_id: that.data.id
|
|
},
|
|
success: function(resdata) {
|
|
var res = resdata.data;
|
|
if (res.result == 1) {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: '领取成功',
|
|
duration: 1500
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: res.msg,
|
|
duration: 1500
|
|
});
|
|
}
|
|
|
|
},
|
|
fail: function(res) {}
|
|
});
|
|
},
|
|
});
|