app.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. // app.js
  2. const utils = require('/utils/util.js')
  3. // const baseIp= "http://127.0.0.1:9747"
  4. // const baseIp= "http://61.177.40.178:8000/zhsw"
  5. // const baseIp = "http://192.168.0.215:9000/zhsw"
  6. const baseIp = "https://www.izilaishui.com:9000/zhsw"
  7. // 图片预览地址
  8. App({
  9. onLaunch(options) {
  10. const logs = wx.getStorageSync('logs') || []
  11. logs.unshift(Date.now())
  12. wx.setStorageSync('logs', logs)
  13. // 登录
  14. wx.login({
  15. success: res => {
  16. // 发送 res.code 到后台换取 openId, sessionKey, unionId
  17. if(res.code){
  18. const _this = this
  19. // 登录
  20. wx.showLoading({
  21. title: '登陆中...',
  22. mask: true,
  23. });
  24. wx.request({
  25. method: 'POST',
  26. url: _this.globalData.interfaceUrls.loginUrl,
  27. data: {
  28. wxCode: res.code,
  29. dsKey: options.query.deskey
  30. },
  31. success(res) {
  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. nickName:"",
  87. avatarUrl:"",
  88. // 当前用户信息
  89. userWxInfo: {},
  90. // 系统中存在的水务公司
  91. waterCompanys: [],
  92. // 小程序启动时带的参数
  93. launchPara: null,
  94. // 当前用户所选择的账户信息
  95. currentAccountInfo:null,
  96. // 是否刷新主页数据
  97. refresh:0,
  98. // 系统接口地址
  99. interfaceUrls: {
  100. loginUrl: baseIp+ '/wechat/login', // 登录+获取绑定列表
  101. accountBind: baseIp+ '/wechat/account/bind', // 账号绑定
  102. homePageInfo: baseIp+ '/wechat/account/info/', // 首页获取用水量等信息
  103. billList: baseIp+ '/wechat/bill/list', // 首页获取用水量等信息
  104. accountList: baseIp+ '/wechat/account/list', // 首页获取用水量等信息
  105. accountUnbind: baseIp+ '/wechat/account/unbind', // 户号解绑方法
  106. setDefaultAccount: baseIp+ '/wechat/account/setDefaultAccount', // 设置默认户号
  107. repairRegistration: baseIp+ '/wechat/registration/repair',//报修登记
  108. feedback: baseIp+ '/wechat/registration/feedback',//投诉建议
  109. mineRepair: baseIp+ '/wechat/mine/repair',//报修登记
  110. mineFeedback: baseIp+ '/wechat/mine/feedback',//投诉建议
  111. paymentList: baseIp+ '/wechat/payment/record',//缴费记录信息
  112. pendingBill: baseIp+ '/wechat/bill/pending/',//代缴费用
  113. prepayOrder:baseIp+ '/wechat/payment/prepayOrder/',//获取缴费的订单信息
  114. createPaymentRecord:baseIp+ '/wechat/payment/record/create',//获取缴费的订单信息
  115. updateRadstateStatus: baseIp+ '/wechat/account/readStatus',//修改已读状态
  116. updateRadstateStatusAll: baseIp+ '/wechat/account/readStatusAll',//全部消息已读
  117. waterList: baseIp+ '/water/list',//从主库获取全部水站信息
  118. getHuMing: baseIp+ '/wechat/account/getHuMing'//根据户号、水站获取户名
  119. },
  120. // 微信静态文件预览方式 使用二开服务的使用次方法
  121. // weChatImgPreviewUrl: "http://192.168.0.215:8020/wechat/",
  122. // weChatImgPreviewUrl: "http://61.177.40.178:8020/wechat/",
  123. weChatImgPreviewUrl: "https://www.izilaishui.com:8020/wechat/",
  124. // 平台
  125. // imgPreviewUrl:"http://192.168.0.215:9000/common/sys/sysfile/preview/",
  126. // imgPreviewUrl:"http://61.177.40.178:9000/common/sys/sysfile/preview/",
  127. imgPreviewUrl:"https://www.izilaishui.com:9000/common/sys/sysfile/preview/",
  128. // 统一管理图片路径
  129. images: {
  130. logo: '/static_file/logo.png',
  131. background: '/static_file/background.png',
  132. card: '/static_file/card.png',
  133. tabBar: {
  134. home: '/static_file/homepage.png',
  135. homeActive: '/static_file/homepageCheck.png',
  136. profile: '/static_file/personalCenter.png',
  137. profileActive: '/static_file/personalCenterCheck.png',
  138. tzd: '/static_file/tzd.png',
  139. phone: '/static_file/phone.png',
  140. yl: '/static_file/yl.png',
  141. jcsfcjtzd:'/static_file/jcsfcjtzd.jpg'
  142. }
  143. },
  144. // 用户通知公告
  145. notices:[]
  146. }
  147. })