// pages/record/record.js
const db = wx.cloud.database()
const pghis = db.collection('pghis')
const _ = db.command
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.getStorage({
key: "_openid",
success:res=>{
this.setData({
_openid : res.data
})
}
})
wx.getStorage({
key: "_openid",
success: res => {
var record;
pghis.where({
_openid: res.data
}).get().then(res => {
record = res.data[0].data
this.setData({
record
})
var i = 0;
for (var key in record) {
this.setData({
[`record.${key}.day`]:key
});
this.setData({
[`dataHanding[${i}]`]:this.data.record[key]
});
this.setData({
[`dataHanding[${i}].word`]:decodeURIComponent(this.data.dataHanding[i].word)
});
i++
};
});
}
})
},
goback: function () {
wx.redirectTo({
url: '../home/home',
})
},
see:function(event){
var num = event.currentTarget.id.replace(/see_/,"");
var a = decodeURIComponent(this.data.dataHanding[num].url);
wx.redirectTo({
url: a+"&later=later"
})
},
del:function(event){
var _openid = this.data._openid;
pghis.where({_openid: _openid}).get().then(res=>{
console.log(res.data)
});
}
})
<van-sticky offset-top="{{ 10 }}">
<van-tag mark size="large" bindtap="goback">返回van-tag>
van-sticky>
<block wx:for="{{dataHanding}}">
<van-panel title="{{item.day}}" status="{{item.grade}}/25" use-footer-slot>
<view class="text_view">
<text class="text">{{item.word}}text>
view>
<view slot="footer" class="panel_btn">
<van-button size="small" color="#7232dd" round bindtap="see" id="see_{{index}}">查看van-button>
<van-button size="small" type="default" round bindtap="del" id="del_{{index}}">删除van-button>
view>
van-panel>
block>
https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/database/remove.html