app.js 5.1 KB

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