|
@@ -0,0 +1,172 @@
|
|
|
+// pages/take/thaw.js
|
|
|
+const app = getApp();
|
|
|
+Page({
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面的初始数据
|
|
|
+ */
|
|
|
+ data: {
|
|
|
+ device_id: 0,
|
|
|
+ spout_device_id: 0,
|
|
|
+ remark: '',
|
|
|
+ info: '',
|
|
|
+ userinfo: ''
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面加载
|
|
|
+ */
|
|
|
+ onLoad(options) {
|
|
|
+ this.setData({
|
|
|
+ device_id: options.device_id,
|
|
|
+ spout_device_id: options.spout_device_id
|
|
|
+ })
|
|
|
+ this.getinfo()
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面初次渲染完成
|
|
|
+ */
|
|
|
+ onReady() {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面显示
|
|
|
+ */
|
|
|
+ onShow() {
|
|
|
+ this.getuser()
|
|
|
+ },
|
|
|
+ getuser(){
|
|
|
+ var that=this;
|
|
|
+ app.api.useApi(app.globalData.baseAppUrl + "api/admin/UserInfo", {
|
|
|
+ appid: wx.getAccountInfoSync().miniProgram.appId
|
|
|
+ }, "get").then(function (res) {
|
|
|
+ console.log(res);
|
|
|
+ if (res.code != 200) {
|
|
|
+ wx.showLoading({
|
|
|
+ title: '请重新登录',
|
|
|
+ })
|
|
|
+ setTimeout(function () {
|
|
|
+ wx.hideLoading();
|
|
|
+ wx.removeStorageSync('token')
|
|
|
+ wx.reLaunch({
|
|
|
+ url: '/pages/login/login',
|
|
|
+ })
|
|
|
+ }, 1000);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ wx.hideLoading();
|
|
|
+
|
|
|
+ that.setData({
|
|
|
+ userinfo:res.message.data
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+ }).catch(function (err) {
|
|
|
+
|
|
|
+ console.log(222);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getinfo() {
|
|
|
+ var that = this;
|
|
|
+ wx.showLoading()
|
|
|
+ app.api.useApi(app.globalData.baseAppUrl + "api/admin/thaw_details", {
|
|
|
+ device_id: that.data.device_id,
|
|
|
+ spout_device_id: that.data.spout_device_id
|
|
|
+ }, "get").then(function (res) {
|
|
|
+ if (res.code != 200) {
|
|
|
+ wx.showLoading({
|
|
|
+ title: res.message.msg,
|
|
|
+ })
|
|
|
+ setTimeout(function () {
|
|
|
+ wx.navigateBack({
|
|
|
+ delta: 1
|
|
|
+ })
|
|
|
+ wx.hideLoading();
|
|
|
+ }, 1000);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ that.setData({ info: res.message.data })
|
|
|
+ wx.hideLoading();
|
|
|
+ }
|
|
|
+ }).catch(function (err) {
|
|
|
+ console.log(222);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ gosub() {
|
|
|
+ var that = this;
|
|
|
+ if (that.data.remark != '') {
|
|
|
+ wx.showLoading()
|
|
|
+ app.api.useApi(app.globalData.baseAppUrl + "api/admin/thaw_submit", {
|
|
|
+ device_id: that.data.device_id,
|
|
|
+ spout_device_id: that.data.spout_device_id,
|
|
|
+ remark: that.data.remark
|
|
|
+ }, "post").then(function (res) {
|
|
|
+ if (res.code != 200) {
|
|
|
+ wx.showLoading({
|
|
|
+ title: res.message.msg,
|
|
|
+ })
|
|
|
+ setTimeout(function () {
|
|
|
+ wx.hideLoading();
|
|
|
+ }, 1000);
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: res.message.msg,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ setTimeout(function () {
|
|
|
+ wx.navigateBack()
|
|
|
+ }, 1000);
|
|
|
+ }
|
|
|
+ }).catch(function (err) {
|
|
|
+ console.log(222);
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: '请填写操作原因',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ goback() {
|
|
|
+ wx.navigateBack()
|
|
|
+ },
|
|
|
+ changetext(e) {
|
|
|
+ this.setData({ remark: e.detail.value })
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面隐藏
|
|
|
+ */
|
|
|
+ onHide() {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面卸载
|
|
|
+ */
|
|
|
+ onUnload() {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面相关事件处理函数--监听用户下拉动作
|
|
|
+ */
|
|
|
+ onPullDownRefresh() {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面上拉触底事件的处理函数
|
|
|
+ */
|
|
|
+ onReachBottom() {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户点击右上角分享
|
|
|
+ */
|
|
|
+ onShareAppMessage() {
|
|
|
+
|
|
|
+ }
|
|
|
+})
|