// user/wardrobe/wardrobe.js const app = getApp(); const regeneratorRuntime = app.loadAsync() const model = app.loadModel("index") const util = app.loadUtils("util") const http = app.loadHttp() Page({ /** * 页面的初始数据 */ data: { system: app.globalData.system, //设备相关信息 pageTitle: "我家衣柜", //头部标题 isBack: true,//显示返回 isTips: false,//显示备注 remarks: "",//备注 num: 0,//数量 }, // 显示备注 openTips() { this.setData({ isTips: true }) }, // 关闭备注 closeTips() { this.setData({ isTips: false }) }, // 洗衣的数量 numInput(e) { let val = e.detail.value this.setData({ num: val }) }, // 备注 remarksInput(e) { let val = e.detail.value this.setData({ remarks: val }) }, // 打开衣柜 async openWardrobe(e) { if (0 >= this.data.num) { wx.showToast({ title: '请输入数量', icon: 'none', duration: 800 }) return } let data = { total_count: this.data.num, remark: this.data.remarks, template_id: e.detail.formId, lat: "", lng: "" } wx.showModal({ title: '确认打开智能衣柜?', content: '为了避免衣物遗失,请在洗衣柜附近开柜!', cancelText: '取消', confirmText: '确定', success(res) { if (res.confirm) { wx.getLocation({ type: 'gcj02', success(res) { wx.showLoading({ title: '开柜中', }) data.lat = res.latitude data.lng = res.longitude http.http.request2({ url: `${http.api.openCupboard}`, method: "POST", data: data }) .then(res => { if (res.data.status == 1) { wx.hideLoading() wx.navigateTo({ url: "/user/wardrobe/wardrobeInfo/wardrobeInfo" }) } }) } }) } } }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })