有个字段jici 是保存帖子被回复了几次
在记录帖子的数据库表中加入触发器
在小程序中加入按钮button
这个页面在加载后需要request后台获取次数
其中disable是控制按钮能否使用 如果次数大于10 会将disable设置为true
<button bindtap="bindtest" data-jici="{{nr6.data[0].jici}}" disabled="{{nengfoufatie}}" >{{jici}}66</button>
下面是小程序js
onLoad: function (options,e) {
var id=options.Id;
this.setData({id:id})
var that=this;
wx.request({
url: 'https://www.fuhufuhu.com/dl',
data: {
tieziid:id,
},
method: 'post',
header: {
//'content-type': 'application/json' // 默认值
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
// console.log(res.data[0].hfnr);
//console.log(res.data[0].nr[0].jici);//要有0
console.log(res.data);
console.log("_________________________");
// console.log(res.data[0].hfnr.hfopenid);//要有0
var jici=res.data.nr[0].jici;
if(jici>=10){
that.setData({jici:'超过数', nengfoufatie:true//button disabled
})
}else{that.setData({jici:'fatie',nengfoufatie:false})}