thaw.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. // pages/take/thaw.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. device_id: 0,
  9. spout_device_id: 0,
  10. remark: '',
  11. info: '',
  12. userinfo: ''
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad(options) {
  18. this.setData({
  19. device_id: options.device_id,
  20. spout_device_id: options.spout_device_id
  21. })
  22. this.getinfo()
  23. },
  24. /**
  25. * 生命周期函数--监听页面初次渲染完成
  26. */
  27. onReady() {
  28. },
  29. /**
  30. * 生命周期函数--监听页面显示
  31. */
  32. onShow() {
  33. this.getuser()
  34. },
  35. getuser(){
  36. var that=this;
  37. app.api.useApi(app.globalData.baseAppUrl + "api/admin/UserInfo", {
  38. appid: wx.getAccountInfoSync().miniProgram.appId
  39. }, "get").then(function (res) {
  40. console.log(res);
  41. if (res.code != 200) {
  42. wx.showLoading({
  43. title: '请重新登录',
  44. })
  45. setTimeout(function () {
  46. wx.hideLoading();
  47. wx.removeStorageSync('token')
  48. wx.reLaunch({
  49. url: '/pages/login/login',
  50. })
  51. }, 1000);
  52. } else {
  53. wx.hideLoading();
  54. that.setData({
  55. userinfo:res.message.data
  56. })
  57. }
  58. }).catch(function (err) {
  59. console.log(222);
  60. })
  61. },
  62. getinfo() {
  63. var that = this;
  64. wx.showLoading()
  65. app.api.useApi(app.globalData.baseAppUrl + "api/admin/thaw_details", {
  66. device_id: that.data.device_id,
  67. spout_device_id: that.data.spout_device_id
  68. }, "get").then(function (res) {
  69. if (res.code != 200) {
  70. wx.showLoading({
  71. title: res.message.msg,
  72. })
  73. setTimeout(function () {
  74. wx.navigateBack({
  75. delta: 1
  76. })
  77. wx.hideLoading();
  78. }, 1000);
  79. } else {
  80. that.setData({ info: res.message.data })
  81. wx.hideLoading();
  82. }
  83. }).catch(function (err) {
  84. console.log(222);
  85. })
  86. },
  87. gosub() {
  88. var that = this;
  89. if (that.data.remark != '') {
  90. wx.showLoading()
  91. app.api.useApi(app.globalData.baseAppUrl + "api/admin/thaw_submit", {
  92. device_id: that.data.device_id,
  93. spout_device_id: that.data.spout_device_id,
  94. remark: that.data.remark
  95. }, "post").then(function (res) {
  96. if (res.code != 200) {
  97. wx.showLoading({
  98. title: res.message.msg,
  99. })
  100. setTimeout(function () {
  101. wx.hideLoading();
  102. }, 1000);
  103. } else {
  104. wx.showToast({
  105. title: res.message.msg,
  106. icon: 'none'
  107. })
  108. setTimeout(function () {
  109. wx.navigateBack()
  110. }, 1000);
  111. }
  112. }).catch(function (err) {
  113. console.log(222);
  114. })
  115. } else {
  116. wx.showToast({
  117. title: '请填写操作原因',
  118. icon: 'none'
  119. })
  120. }
  121. },
  122. goback() {
  123. wx.navigateBack()
  124. },
  125. changetext(e) {
  126. this.setData({ remark: e.detail.value })
  127. },
  128. /**
  129. * 生命周期函数--监听页面隐藏
  130. */
  131. onHide() {
  132. },
  133. /**
  134. * 生命周期函数--监听页面卸载
  135. */
  136. onUnload() {
  137. },
  138. /**
  139. * 页面相关事件处理函数--监听用户下拉动作
  140. */
  141. onPullDownRefresh() {
  142. },
  143. /**
  144. * 页面上拉触底事件的处理函数
  145. */
  146. onReachBottom() {
  147. },
  148. /**
  149. * 用户点击右上角分享
  150. */
  151. onShareAppMessage() {
  152. }
  153. })