diff --git a/src/miniprogram-1(1)/pages/navigation/index/delete/delete.js b/src/miniprogram-1(1)/pages/navigation/index/delete/delete.js new file mode 100644 index 0000000..358ce35 --- /dev/null +++ b/src/miniprogram-1(1)/pages/navigation/index/delete/delete.js @@ -0,0 +1,127 @@ +// pages/navigation/index/delete/delete.js +const db=wx.cloud.database(); + +let app=getApp(); + +Page({ + /** + * 页面的初始数据 + */ + data: { + clothes:[] + }, + //定义按钮的事件处理函数 + clear(e) + { + var clothes=this.data.clothes + console.log(clothes) + let index=e.currentTarget.dataset.index + console.log(index) + let id=clothes[index]._id + console.log(id) + //界面数据删除 + this.data.clothes.splice(e.currentTarget.dataset.index,1); + this.setData({ clothes: this.data.clothes }); + console.log('删除成功'); + wx.showToast({ + title: '删除成功', + }) + + //初始化云 + wx.cloud.init({ + env:'cloud1-5ggzbo3kcd4ea4e2' + }); + wx.cloud.callFunction({ + name:'get', + complete:res=>{ + console.log('云函数获取openid:',res.result.openid); + wx.setStorageSync('openid',res.result.openid); + console.log(res); + } + }), + //删除数据库中记录 + db.collection('cloth').where({ + '_id':id + }).remove({ + success: function(res) { + console.log(res.data) + wx.showToast({ + title: '删除成功', + }) + console.log('数据库删除成功') + } + }) + db.collection('cloth').where({ + '_id':id + }).get({ + success: res =>{ + console.log(''); + } + }) + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + db.collection('cloth').get({ + success: res =>{ + console.log(res.data); + this.setData({ + clothes:app.globalData.clothes + }) + } + }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } + +}) \ No newline at end of file diff --git a/src/miniprogram-1(1)/pages/navigation/index/delete/delete.json b/src/miniprogram-1(1)/pages/navigation/index/delete/delete.json new file mode 100644 index 0000000..bab9e34 --- /dev/null +++ b/src/miniprogram-1(1)/pages/navigation/index/delete/delete.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText":"" +} \ No newline at end of file diff --git a/src/miniprogram-1(1)/pages/navigation/index/delete/delete.wxml b/src/miniprogram-1(1)/pages/navigation/index/delete/delete.wxml new file mode 100644 index 0000000..87a237a --- /dev/null +++ b/src/miniprogram-1(1)/pages/navigation/index/delete/delete.wxml @@ -0,0 +1,41 @@ + + + + + + + 名称 + + + 模式 + + + 类型 + + + 操作 + + + + + + + + + + {{item.name}} + + + {{item.pattern}} + + + {{item.kind}} + + + + + + + + + diff --git a/src/miniprogram-1(1)/pages/navigation/index/delete/delete.wxss b/src/miniprogram-1(1)/pages/navigation/index/delete/delete.wxss new file mode 100644 index 0000000..43478ab --- /dev/null +++ b/src/miniprogram-1(1)/pages/navigation/index/delete/delete.wxss @@ -0,0 +1,6 @@ +/* pages/navigation/index/delete/delete.wxss */ + + + + +