app.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // app.js
  2. const utils = require('/utils/util.js')
  3. const baseIp= "http://localhost:9747"
  4. // 图片预览地址
  5. App({
  6. onLaunch(options) {
  7. // 展示本地存储能力
  8. const logs = wx.getStorageSync('logs') || []
  9. logs.unshift(Date.now())
  10. wx.setStorageSync('logs', logs)
  11. // 登录
  12. wx.login({
  13. success: res => {
  14. // 发送 res.code 到后台换取 openId, sessionKey, unionId
  15. if(res.code){
  16. const _this = this
  17. // 登录
  18. wx.showLoading({
  19. title: '登陆中...',
  20. mask: true,
  21. });
  22. wx.request({
  23. method: 'POST',
  24. url: _this.globalData.interfaceUrls.loginUrl,
  25. data: {
  26. wxCode: res.code,
  27. dsKey: options.query.deskey
  28. },
  29. success(res) {
  30. wx.hideLoading()
  31. if (!res.data.code || res.data.code!= "200") {
  32. utils.simleInfoWithBack('登录失败,请稍后再试')
  33. return
  34. }
  35. _this.globalData.launchPara=options.query.deskey;
  36. const resData = res.data.data
  37. if (resData) {
  38. _this.globalData.userWxInfo = {
  39. openid: resData.openid,
  40. session_key: resData.session_key,
  41. token: resData.token,
  42. // 当前用户所关联的户号信息
  43. bindAccountInfo: resData.swUserManagementVos,
  44. // 当前用户所对应的水务公司
  45. currentDsKey:""
  46. }
  47. if(resData.swUserManagementVos.length!=0){
  48. _this.globalData.currentAccountInfo=(resData.swUserManagementVos||[])[0];
  49. _this.globalData.userWxInfo.currentDsKey=(resData.swUserManagementVos||[])[0].dsKey;
  50. };
  51. _this.globalData.waterCompanys=resData.waterCompany;
  52. if (resData.swUserManagementVos.length == 0) {
  53. _this.globalData.refresh=0;
  54. wx.navigateTo({
  55. url: '/pages/FirstBangDing/FirstBangDing',
  56. })
  57. } else {
  58. _this.globalData.refresh=1;
  59. wx.switchTab({
  60. url: '/pages/homepage/homepage',
  61. success:function () {
  62. var page = getCurrentPages().pop();
  63. if (page == undefined || page == null) return;
  64. page.onLoad(); //重新刷新页面
  65. }
  66. })
  67. }
  68. } else {
  69. utils.simleInfo('登录失败,请稍后再试')
  70. }
  71. },
  72. fail: error => {
  73. wx.hideLoading()
  74. utils.simleInfo('登录失败,请稍后再试')
  75. }
  76. })
  77. }else{
  78. utils.simleInfo('登录失败,请稍后再试')
  79. }
  80. }
  81. })
  82. },
  83. globalData: {
  84. // 当前用户信息
  85. userWxInfo: {},
  86. // 系统中存在的水务公司
  87. waterCompanys: [],
  88. // 小程序启动时带的参数
  89. launchPara: null,
  90. // 当前用户所选择的账户信息
  91. currentAccountInfo:null,
  92. // 是否刷新主页数据
  93. refresh:0,
  94. // 系统接口地址
  95. interfaceUrls: {
  96. loginUrl: baseIp+ '/wechat/login', // 登录+获取绑定列表
  97. accountBind: baseIp+ '/wechat/account/bind', // 账号绑定
  98. homePageInfo: baseIp+ '/wechat/account/info/', // 首页获取用水量等信息
  99. billList: baseIp+ '/wechat/bill/list', // 首页获取用水量等信息
  100. accountList: baseIp+ '/wechat/account/list', // 首页获取用水量等信息
  101. accountUnbind: baseIp+ '/wechat/account/unbind', // 户号解绑方法
  102. repairRegistration: baseIp+ '/wechat/registration/repair',//报修登记
  103. feedback: baseIp+ '/wechat/registration/feedback',//投诉建议
  104. mineRepair: baseIp+ '/wechat/mine/repair',//报修登记
  105. mineFeedback: baseIp+ '/wechat/mine/feedback',//投诉建议
  106. paymentList: baseIp+ '/wechat/payment/record',//缴费记录信息
  107. },
  108. // 微信静态文件预览方式 使用二开服务的使用次方法
  109. weChatImgPreviewUrl: "http://192.168.0.215:8020/wechat/",
  110. // 平台
  111. imgPreviewUrl:" http://192.168.0.215:9000/common/sys/sysfile/preview/",
  112. // 统一管理图片路径
  113. images: {
  114. logo: '/static_file/logo.png',
  115. background: '/static_file/background.png',
  116. card: '/static_file/card.png',
  117. tabBar: {
  118. home: '/static_file/homepage.png',
  119. homeActive: '/static_file/homepageCheck.png',
  120. profile: '/static_file/personalCenter.png',
  121. profileActive: '/static_file/personalCenterCheck.png',
  122. tzd: '/static_file/tzd.png',
  123. phone: '/static_file/phone.png',
  124. yl: '/static_file/yl.png',
  125. jcsfcjtzd:'/static_file/jcsfcjtzd.jpg'
  126. }
  127. },
  128. // 用户通知公告
  129. notices:[]
  130. }
  131. })