123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- // 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() {
- }
- })
|