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.
xzjl-ui/pages/home/xyc/wdyw/wdyw.js

161 lines
3.7 KiB

// pages/home/xyc/wdyw/wdyw.js
const app = getApp();//新建页面时 默认引入
const req = app.xzjlReq();//初始化一个的request() 实例
Page({
/**
* 页面的初始数据
*/
data: {
showDelDialog:false,
detail:{},
visible:false,
shareVisible:false, //分享弹层
wishes:[]
},
// 分享微信
shareWx(){
console.log('分享微信')
},
showShare(){
this.setData({
shareVisible:!this.data.shareVisible
})
},
go2DelDialog(){
this.setData({showDelDialog:true})
},
closeDelDialog(){
this.setData({showDelDialog:false})
},
confirmDelDialog(e){
console.log(e.target.dataset.del)
console.log('确定删除')
console.log(this.data.detail.id)
/**确定删除愿望 */
this.setData({showDelDialog:false})
req.deleteRequest('/api/user/curt/wish/'+this.data.detail.id,{}).then((res)=>{
console.log(res)
if(res.data.code==200){
wx.showToast({
title:'愿望删除成功',
icon: 'none',
duration: 1000
})
this.getMyWish()
this.setData({
visible: false
})
}
}).catch((err)=>{
console.log(err);
})
},
doFinishWish(e){/**愿望已达成 */
console.log(e.target.dataset.del)
console.log('愿望达成')
console.log(this.data.detail.id)
/**确定删除愿望 */
this.setData({showDelDialog:false})
req.patchRequest('/api/user/curt/wish/'+this.data.detail.id+"/completed",{}).then((res)=>{
console.log(res)
if(res.data.code==200){
wx.showToast({
title:'愿望达成成功',
icon: 'none',
duration: 1000
})
}else{
wx.showToast({
title:res.data.msg,
icon: 'none',
duration: 1000
})
}
}).catch((err)=>{
console.log(err);
})
},
go2WishDetail(e){/**查看愿望详情 */
this.setData({visible:true,detail:e.currentTarget.dataset.wish})
this.setData({detail:e.currentTarget.dataset.wish})
},
onVisibleChange(e) {
this.setData({
visible: e.detail.visible,
});
},
changeVisible(){
this.setData({visible:false})
},
go2Reback(){
wx.navigateBack({ changed: true });
},
getMyWish(){
req.getRequest('/api/user/curt/wish',{}).then((res)=>{
console.log(res,'11111111')
if(res.data.code==200){
this.setData({wishes:res.data.data.records})
}
}).catch((err)=>{
console.log(err);
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.getMyWish()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
},
onShareTimeline(){
}
})