app.js 5.3 KB

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