app.js 6.4 KB

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