// pages/member/cleanorder.js var app = getApp(); var netUtil = require("../../utils/requestUtil.js"); //require引入 Page({ /** * 页面的初始数据 */ data: { orders: [], InputBottom: 0, input_focus: false, id: 0, commont: '', inputCommont: '', page: 1, is_complete:0 }, InputFocus(e) { this.setData({ InputBottom: e.detail.height }) }, InputBlur(e) { this.setData({ InputBottom: 0, }) }, preview: function (e) { var one = e.currentTarget.dataset.one; var two = e.currentTarget.dataset.two; var images = this.data.orders[one].picture; wx.previewImage({ current: images[two], urls: images, success: function (res) { //console.log(res) } }) }, isClean:function(e){ if(e.detail.value==true){ this.setData({ is_complete:1 }) }else{ this.setData({ is_complete:0 }) } console.log(this.data.is_complete); this.setData({ page: 1 }); this.getData().then(() => { wx.stopPullDownRefresh() }); }, goCommont: function (e) { this.setData({ input_focus: true, id: e.currentTarget.dataset.id, index: e.currentTarget.dataset.idx }) }, //去打扫 goComplete: function (e) { wx.navigateTo({ url: '/pages/clean/complete?order_no=' + e.currentTarget.dataset.orderno + '&id=' + e.currentTarget.dataset.id, }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var userInfo = wx.getStorageSync('userInfo'); options.userInfo = userInfo; this.setData(options); }, getInputValue: function (e) { this.setData({ commont: e.detail.value.replace(/\s+/g, '') }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.getData(); }, getData:function(){ var that = this; var url = app.globalData.requestUrl + 'index/clean/my_clean?openid=' + this.data.userInfo.openid + '&page=' + that.data.page + '&is_complete=' + this.data.is_complete; return netUtil.sendGet(url) .then((res) => { if (res.statusCode == 200 && res.data.code == 200) { var data = res.data.data; that.setData({ orders: that.data.page == 1 ? data : that.data.orders.concat(data) }); } else { wx.showToast({ title: res.data.msg, icon: 'none', duration: 3000 }) } }).then(() => { this.loading = false; }) }, //更改时间 changeDate:function(e){ console.log(e); var that = this; var date = e.detail.value; var url = app.globalData.requestUrl + 'index/clean/change_date'; var param = {}; param.openid = this.data.userInfo.openid; param.date = e.detail.value; param.id = e.currentTarget.dataset.id; var idx = e.currentTarget.dataset.index; return netUtil.sendPost(url,param) .then((res) => { if (res.statusCode == 200 && res.data.code == 200) { that.data.orders[idx].create_time = res.data.data.date; that.setData({ orders : that.data.orders }); } else { wx.showToast({ title: res.data.msg, icon: 'none', duration: 3000 }) } }).then(() => { this.loading = false; }) }, //导航 goMap: function (e) { var hourse = this.data.orders[e.currentTarget.dataset.index]; var key = 'RRXBZ-DW33W-SPER5-R6WUB-GGYRZ-GWBIL'; let referer = '租房掌柜-导航'; //系统自带地图 wx.openLocation({ //​使用微信内置地图查看位置。 latitude: parseFloat(hourse.latitude),//要去的纬度-地址 longitude: parseFloat(hourse.longitude),//要去的经度-地址 name: hourse.name }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { this.setData({ page: 1 }); this.getData().then(() => { wx.stopPullDownRefresh() }); }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { var page = this.data.page this.setData({ page: ++page }); this.getData(); }, //拨打电话 phoneCall: function(e) { var phone = e.currentTarget.dataset.phone; wx.makePhoneCall({ phoneNumber: phone, }) }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })