租房掌柜微信小程序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.
 
 
 
 
 
 

167 lines
3.6 KiB

var app = getApp();
var netUtil = require("../../utils/requestUtil.js"); //require引入
Page({
/**
* 页面的初始数据
*/
data: {
data: [],
id: '',
page: 1,
pages: 0,
userInfo: []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
userInfo: wx.getStorageSync('userInfo')
})
//获取列表
this.getList(1, false);
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
//订单通过确认
orderOk: function (e) {
const params = []
var id = e.currentTarget.dataset.id;
var self = this
wx.showModal({
title: '信息确认',
content: '请确认已收到该用户转账?',
success(obj) {
if (obj.confirm) {
params.id = id
params.status = 1
self.orderEdit(params);
} else if (obj.cancel) {
console.log(2)
}
}
})
},
showModal(e) {
this.setData({
modalName: e.currentTarget.dataset.target,
id: e.currentTarget.dataset.id
})
},
hideModal(e) {
this.setData({
modalName: null
})
},
//订单不通过确认
formSubmit: function (e) {
const params = e.detail.value
//执行入库
params.status = 2
params.id = this.data.id
this.orderEdit(params)
this.hideModal()
},
orderFail: function (e) {
var id = e.currentTarget.dataset.id;
},
//订单确认接口
orderEdit: function (data) {
var self = this;
var method_url = 'index/order/tenantEdit';
var url = app.globalData.requestUrl + method_url;
netUtil.sendPost(url, data)
.then((res) => {
console.log(res)
if (res.statusCode == 200 && res.data.code == 200) {
wx.showToast({
title: '操作成功!!!',
icon: 'success',
duration: 2000,
success: function () {
wx.navigateTo({
url: '/pages/tenant/order',
})
}
})
} else {
wx.showToast({
title: res.data.msg,
icon: 'none',
duration: 3000
})
}
})
},
//获取数据列表
getList: function (pageNum, override) {
this.loading = true;
var self = this;
var url = app.globalData.requestUrl + 'index/order/tenant?pagesize=18&page=' + pageNum;
return netUtil.sendGet(url)
.then((res) => {
console.log(res)
this.setData({
pages: res.data.data.pages,
page: pageNum,
//override 为true 则直接覆盖 否则上拉追加数据
data: override ? res.data.data.list : self.data.data.concat(res.data.data.list)
})
}).then(() => {
this.loading = false;
})
},
//上拉加载数据
onReachBottom: function () {
// 下拉触底,先判断是否有请求正在进行中
// 以及检查当前请求页数是不是小于数据总页数,如符合条件,则发送请求
if (!this.loading && this.data.page < this.data.pages) {
this.getList(this.data.page + 1);
}
},
//下拉刷新
onPullDownRefresh: function () {
if (!this.loading) {
this.getList(1, true).then(() => {
wx.stopPullDownRefresh()
})
}
},
//拨打电话
phoneCall: function (e) {
var phone = e.currentTarget.dataset.phone;
wx.makePhoneCall({
phoneNumber: phone,
})
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})