动态分享数据:
1、效果:

2、.js代码:
-
page({
-
-
/**
-
* 用户点击分享按钮或右上角分享
-
*/
-
onShareAppMessage: function (res) {
-
var that = this;
-
return {
-
title: that.data.common.act_name,
-
desc: that.data.common.introduction,
-
path: '/pages/xiangqing/xiangqing?id='+that.data.id,
-
success: function (res) {
-
// 转发成功
-
},
-
fail: function (res) {
-
// 转发失败
-
}
-
}
-
}
-
-
})
根据不同的id来进行设置和读取缓存
本文是根据不同的id来进行设置和读取缓存,是同步缓存的方式:

jonNums.count 是接口返回的数据 是报名总人数 newNumber 新的报名总人数 - 缓存上次的报名总人数 = 新增报名人数
-
[javascript] view plain copy print?
-
onLoad: function (options) {
-
var that = this;
-
var activityId = options.activityId;
-
//报名表人数统计
-
wx.request({
-
url: domain + '/activityjoin/selectJoinCount',
-
data: { activityId: activityId },
-
method: 'GET',
-
success: function (res) {
-
-
var jonNums = res.data;
-
var newNumber = jonNums.count - wx.getStorageSync('jonNumsed' + activityId) //获取缓存
-
-
wx.setStorageSync('jonNumsed' + activityId, jonNums.count);//设置缓存
-
-
if (jonNums.count) {
-
activityId
-
}
-
-
jonNums.joinCount = jonNums.count;
-
-
that.setData({ newNumber: newNumber, jonNums: jonNums })
-
}
-
})
-
-
},