You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
2.3 KiB
116 lines
2.3 KiB
// pages/xiugaibiji/xiugaibiji.js
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
_id:"",
|
|
title:"",
|
|
content:"",
|
|
text:""
|
|
},
|
|
contentFs(e){
|
|
this.setData({
|
|
text: e.detail.text,
|
|
content: e.detail.html
|
|
})
|
|
},
|
|
onEditorReady(){
|
|
const that = this
|
|
wx.createSelectorQuery().select('#editor').context(function(res) {
|
|
that.editorCtx = res.context
|
|
that.editorCtx.setContents({
|
|
html:that.data.content
|
|
});
|
|
}).exec()
|
|
|
|
},
|
|
|
|
titletFs(e){
|
|
this.setData({
|
|
title:e.detail.value
|
|
})
|
|
},
|
|
xiugaiFs(){
|
|
wx.cloud.database().collection("note").doc(this.data._id).update({
|
|
data:{
|
|
title:this.data.title,
|
|
content:this.data.content,
|
|
text:this.data.text,
|
|
create_time:new Date().toLocaleString()
|
|
}
|
|
}).then(res=>{
|
|
wx.switchTab({
|
|
url: '/pages/index/index',})
|
|
}).catch(res=>{
|
|
console.log("笔记修改失败",res);
|
|
})
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (e) {
|
|
this.setData({
|
|
_id:e.id
|
|
})
|
|
wx.cloud.database().collection("note").doc(this.data._id).get().then(res=>{
|
|
this.setData({
|
|
title:res.data.title,
|
|
content:res.data.content,
|
|
text:res.data.text
|
|
})
|
|
this.onEditorReady()
|
|
}).catch(res=>{
|
|
console.log("笔记获取失败",res);
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function (e) {
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
}) |