电速宝
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. // pages/setup/index.js
  2. const api = require('../../api/index.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. // 状态栏高度
  9. statusBarHeight: wx.getStorageSync('statusBarHeight'),
  10. // 导航栏高度
  11. navBarHeight: wx.getStorageSync('navBarHeight'),
  12. // 导航栏和状态栏高度
  13. navStatusBarHeight: wx.getStorageSync('navStatusBarHeight'),
  14. // 胶囊
  15. menu:wx.getStorageSync('menu'),
  16. accountInfo:'',
  17. user:'',
  18. station:wx.getStorageSync('station'),
  19. showMultiTextAndTitle:false,
  20. inputValue: '' // 初始值
  21. },
  22. onstation(){
  23. wx.navigateTo({
  24. url: '/pages/station/index', // 登录页面的路径,注意路径前面加上 '/' 表示从根目录开始
  25. });
  26. },
  27. onsetup(){
  28. wx.navigateTo({
  29. url: '/pages/setuplevel/index', // 登录页面的路径,注意路径前面加上 '/' 表示从根目录开始
  30. });
  31. },
  32. // 电站详情
  33. onpowerstation(){
  34. wx.showToast({
  35. title: '暂未开放',
  36. icon: 'none'
  37. });
  38. return
  39. this.setData({
  40. showMultiTextAndTitle:true
  41. })
  42. },
  43. closeDialog(){
  44. this.setData({
  45. showMultiTextAndTitle:false
  46. })
  47. },
  48. // 扫码
  49. onscancode(){
  50. let _this = this
  51. wx.scanCode({
  52. success: (res) => {
  53. console.log(res);
  54. const regex = /[?&]Id=([a-zA-Z0-9]+)/;
  55. const match = res.result.match(regex);
  56. let id = ''
  57. if (match) {
  58. id = match[1]; // 第一个捕获组的值即为 Id 的值
  59. // /^S.{12}\d{8}$/
  60. wx.navigateTo({
  61. url: `/pages/powerstation/index?id=${id}&source=sm`, // 登录页面的路径,注意路径前面加上 '/' 表示从根目录开始
  62. });
  63. }else{
  64. wx.showToast({
  65. title: '二维码没有识别到设备编码',
  66. icon: 'none'
  67. });
  68. }
  69. _this.setData({
  70. showMultiTextAndTitle:false
  71. })
  72. }
  73. })
  74. },
  75. // 创建电站
  76. //
  77. handleInput(e){
  78. console.log(e);
  79. this.setData({
  80. inputValue: e.detail.value // 更新 inputValue
  81. });
  82. },
  83. click(){
  84. console.log('当前输入的文字是:', this.data.inputValue);
  85. },
  86. oncreatestation(){
  87. },
  88. toconfigure(){
  89. wx.showToast({
  90. title: '暂未开放',
  91. icon: 'none'
  92. });
  93. },
  94. /**
  95. * 生命周期函数--监听页面加载
  96. */
  97. onLoad(options) {
  98. let _this = this
  99. try {
  100. const accountInfo = wx.getAccountInfoSync();
  101. this.setData({
  102. accountInfo:accountInfo.miniProgram.version
  103. })
  104. } catch (e) {
  105. console.error("获取小程序版本号失败:", e);
  106. }
  107. // this.getuser()
  108. },
  109. getuser(){
  110. api.request(`/platform/user/selectaccountNumber`, 'POST')
  111. .then((res) => {
  112. // console.log(res);
  113. this.setData({
  114. user:res.data
  115. })
  116. })
  117. .catch((err) => {
  118. console.error('请求失败:', err);
  119. // 在这里处理请求失败的情况
  120. });
  121. },
  122. // 个人信息
  123. onuser(){
  124. wx.showToast({
  125. title: '暂未开放',
  126. icon: 'none'
  127. });
  128. return
  129. wx.navigateTo({
  130. url: '/pages/user/index', // 登录页面的路径,注意路径前面加上 '/' 表示从根目录开始
  131. });
  132. },
  133. /**
  134. * 生命周期函数--监听页面初次渲染完成
  135. */
  136. onReady() {
  137. },
  138. /**
  139. * 生命周期函数--监听页面显示
  140. */
  141. onShow() {
  142. this.setData({
  143. station:wx.getStorageSync('station')
  144. })
  145. },
  146. /**
  147. * 生命周期函数--监听页面隐藏
  148. */
  149. onHide() {
  150. },
  151. /**
  152. * 生命周期函数--监听页面卸载
  153. */
  154. onUnload() {
  155. },
  156. /**
  157. * 页面相关事件处理函数--监听用户下拉动作
  158. */
  159. onPullDownRefresh() {
  160. },
  161. /**
  162. * 页面上拉触底事件的处理函数
  163. */
  164. onReachBottom() {
  165. },
  166. /**
  167. * 用户点击右上角分享
  168. */
  169. onShareAppMessage() {
  170. }
  171. })