租房掌柜微信小程序Api以及小程序前端模板
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.
 
 
 
 
 
 

177 lines
3.8 KiB

var app = getApp();
var netUtil = require("../../utils/requestUtil.js"); //require引入
Page({
/**
* 页面的初始数据
*/
data: {
id: '',
data: [],
viewUrl: '/pages/member/view'
},
isClean:function(e){
var url = app.globalData.requestUrl + 'index/member/setClean/';
console.log(this.data);
netUtil.sendPost(url,{id:this.data.id,is_clean:e.detail.value ? 1 : 0})
.then((res) => {
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
this.setData({
id: options.id
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
this.getDetail();
},
//修改会员等级
PickerChange(e) {
var self = this
var user_id = e.currentTarget.dataset.userid
var url = app.globalData.requestUrl + 'index/member/level/' + user_id + '/' + e.detail.value;
netUtil.sendGet(url)
.then((res) => {
if (res.statusCode == 200 && res.data.code == 200) {
wx.showToast({
title: '会员等级修改成功',
icon: 'success',
duration: 2000,
success: function() {
//刷新本页面
wx.redirectTo({
url: self.data.viewUrl + '?id=' + self.data.id
})
}
})
} else {
wx.showToast({
title: res.data.msg,
icon: 'none',
duration: 3000
})
}
})
},
//获取数据详情
getDetail: function() {
var self = this;
var url = app.globalData.requestUrl + 'index/member/view/' + this.data.id;
netUtil.sendGet(url)
.then((res) => {
if (res.statusCode == 200 && res.data.code == 200) {
var data = res.data.data
this.setData({
data: data
})
} else {
wx.showToast({
title: res.data.msg,
icon: 'none',
duration: 3000
})
}
})
},
//删除会员
delMember: function(e) {
var self = this
wx.showModal({
title: '删除确认',
content: '请再次确认是否删除数据?',
success(obj) {
if (obj.confirm) {
var url = app.globalData.requestUrl + 'index/member/del/' + self.data.id;
netUtil.sendGet(url)
.then((res) => {
console.log(res)
if (res.statusCode == 200 && res.data.code == 200) {
wx.showToast({
title: '数据删除成功',
icon: 'success',
duration: 2000,
success: function() {
setTimeout(function() {
wx.navigateBack({
delta: 1
})
}, 2000)
}
})
} else {
wx.showToast({
title: res.data.msg,
icon: 'none',
duration: 3000
})
}
})
} else if (obj.cancel) {
console.log(2)
}
}
})
},
//拨打电话
phoneCall: function(e) {
var phone = e.currentTarget.dataset.phone;
wx.makePhoneCall({
phoneNumber: phone,
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
},
})