app.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. // app.js
  2. const utils = require('/utils/util.js')
  3. // const baseIp= "http://localhost:9747"
  4. // const baseIp= "https://www.izilaishui.com:9000/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. nickName:"",
  86. avatarUrl:"",
  87. // 当前用户信息
  88. userWxInfo: {},
  89. // 系统中存在的水务公司
  90. waterCompanys: [],
  91. // 小程序启动时带的参数
  92. launchPara: null,
  93. // 当前用户所选择的账户信息
  94. currentAccountInfo:null,
  95. // 是否刷新主页数据
  96. refresh:0,
  97. // 系统接口地址
  98. interfaceUrls: {
  99. loginUrl: baseIp+ '/wechat/login', // 登录+获取绑定列表
  100. accountBind: baseIp+ '/wechat/account/bind', // 账号绑定
  101. homePageInfo: baseIp+ '/wechat/account/info/', // 首页获取用水量等信息
  102. billList: baseIp+ '/wechat/bill/list', // 首页获取用水量等信息
  103. accountList: baseIp+ '/wechat/account/list', // 首页获取用水量等信息
  104. accountUnbind: baseIp+ '/wechat/account/unbind', // 户号解绑方法
  105. setDefaultAccount: baseIp+ '/wechat/account/setDefaultAccount', // 设置默认户号
  106. repairRegistration: baseIp+ '/wechat/registration/repair',//报修登记
  107. feedback: baseIp+ '/wechat/registration/feedback',//投诉建议
  108. mineRepair: baseIp+ '/wechat/mine/repair',//报修登记
  109. mineFeedback: baseIp+ '/wechat/mine/feedback',//投诉建议
  110. paymentList: baseIp+ '/wechat/payment/record',//缴费记录信息
  111. pendingBill: baseIp+ '/wechat/bill/pending/',//代缴费用
  112. prepayOrder:baseIp+ '/wechat/payment/prepayOrder/',//获取缴费的订单信息
  113. createPaymentRecord:baseIp+ '/wechat/payment/record/create',//获取缴费的订单信息
  114. updateRadstateStatus: baseIp+ '/wechat/account/readStatus',//修改已读状态
  115. updateRadstateStatusAll: baseIp+ '/wechat/account/readStatusAll',//全部消息已读
  116. },
  117. // 微信静态文件预览方式 使用二开服务的使用次方法
  118. weChatImgPreviewUrl: "http://192.168.0.215:8020/wechat/",
  119. // 平台
  120. imgPreviewUrl:"http://192.168.0.215:9000/common/sys/sysfile/preview/",
  121. // 统一管理图片路径
  122. images: {
  123. logo: '/static_file/logo.png',
  124. background: '/static_file/background.png',
  125. card: '/static_file/card.png',
  126. tabBar: {
  127. home: '/static_file/homepage.png',
  128. homeActive: '/static_file/homepageCheck.png',
  129. profile: '/static_file/personalCenter.png',
  130. profileActive: '/static_file/personalCenterCheck.png',
  131. tzd: '/static_file/tzd.png',
  132. phone: '/static_file/phone.png',
  133. yl: '/static_file/yl.png',
  134. jcsfcjtzd:'/static_file/jcsfcjtzd.jpg'
  135. }
  136. },
  137. // 用户通知公告
  138. notices:[]
  139. }
  140. })