123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- // app.js
- const utils = require('/utils/util.js')
- const baseIp= "http://localhost:9747"
- // const baseIp= "http://61.177.40.178:8000/zhsw"
- // const baseIp = "http://192.168.0.215:9000/zhsw" // 根据实际情况调整端口号
- // 图片预览地址
- App({
- onLaunch(options) {
- const logs = wx.getStorageSync('logs') || []
- logs.unshift(Date.now())
- wx.setStorageSync('logs', logs)
- // 登录
- wx.login({
- success: res => {
- // 发送 res.code 到后台换取 openId, sessionKey, unionId
- if(res.code){
- const _this = this
- // 登录
- wx.showLoading({
- title: '登陆中...',
- mask: true,
- });
- wx.request({
- method: 'POST',
- url: _this.globalData.interfaceUrls.loginUrl,
- data: {
- wxCode: res.code,
- dsKey: options.query.deskey
- },
- success(res) {
- wx.hideLoading()
- if (!res.data.code || res.data.code!= "200") {
- utils.simleInfoWithBack('登录失败,请稍后再试')
- return
- }
- _this.globalData.launchPara=options.query.deskey;
- const resData = res.data.data
- if (resData) {
- _this.globalData.userWxInfo = {
- openid: resData.openid,
- session_key: resData.session_key,
- token: resData.token,
- // 当前用户所关联的户号信息
- bindAccountInfo: resData.swUserManagementVos,
- // 当前用户所对应的水务公司
- currentDsKey:""
- }
- if(resData.swUserManagementVos.length!=0){
- _this.globalData.currentAccountInfo=(resData.swUserManagementVos||[])[0];
- _this.globalData.userWxInfo.currentDsKey=(resData.swUserManagementVos||[])[0].dsKey;
- };
- _this.globalData.waterCompanys=resData.waterCompany;
- if (resData.swUserManagementVos.length == 0) {
- _this.globalData.refresh=0;
- wx.navigateTo({
- url: '/pages/FirstBangDing/FirstBangDing',
- })
- } else {
- _this.globalData.refresh=1;
- wx.switchTab({
- url: '/pages/homepage/homepage',
- success:function () {
- var page = getCurrentPages().pop();
- if (page == undefined || page == null) return;
- page.onLoad(); //重新刷新页面
- }
- })
- }
- } else {
- utils.simleInfo('登录失败,请稍后再试')
- }
- },
- fail: error => {
- wx.hideLoading()
- utils.simleInfo('登录失败,请稍后再试')
- }
- })
- }else{
- utils.simleInfo('登录失败,请稍后再试')
- }
- }
- })
- },
- globalData: {
- // 当前用户信息
- userWxInfo: {},
- // 系统中存在的水务公司
- waterCompanys: [],
- // 小程序启动时带的参数
- launchPara: null,
- // 当前用户所选择的账户信息
- currentAccountInfo:null,
- // 是否刷新主页数据
- refresh:0,
- // 系统接口地址
- interfaceUrls: {
- loginUrl: baseIp+ '/wechat/login', // 登录+获取绑定列表
- accountBind: baseIp+ '/wechat/account/bind', // 账号绑定
- homePageInfo: baseIp+ '/wechat/account/info/', // 首页获取用水量等信息
- billList: baseIp+ '/wechat/bill/list', // 首页获取用水量等信息
- accountList: baseIp+ '/wechat/account/list', // 首页获取用水量等信息
- accountUnbind: baseIp+ '/wechat/account/unbind', // 户号解绑方法
- setDefaultAccount: baseIp+ '/wechat/account/setDefaultAccount', // 设置默认户号
- repairRegistration: baseIp+ '/wechat/registration/repair',//报修登记
- feedback: baseIp+ '/wechat/registration/feedback',//投诉建议
- mineRepair: baseIp+ '/wechat/mine/repair',//报修登记
- mineFeedback: baseIp+ '/wechat/mine/feedback',//投诉建议
- paymentList: baseIp+ '/wechat/payment/record',//缴费记录信息
- updateRadstateStatus: baseIp+ '/wechat/account/readStatus',//修改已读状态
- updateRadstateStatusAll: baseIp+ '/wechat/account/readStatusAll',//全部消息已读
- },
- // 微信静态文件预览方式 使用二开服务的使用次方法
- weChatImgPreviewUrl: "http://192.168.0.215:8020/wechat/",
- // 平台
- imgPreviewUrl:" http://192.168.0.215:9000/common/sys/sysfile/preview/",
-
- // 统一管理图片路径
- images: {
- logo: '/static_file/logo.png',
- background: '/static_file/background.png',
- card: '/static_file/card.png',
- tabBar: {
- home: '/static_file/homepage.png',
- homeActive: '/static_file/homepageCheck.png',
- profile: '/static_file/personalCenter.png',
- profileActive: '/static_file/personalCenterCheck.png',
- tzd: '/static_file/tzd.png',
- phone: '/static_file/phone.png',
- yl: '/static_file/yl.png',
- jcsfcjtzd:'/static_file/jcsfcjtzd.jpg'
- }
- },
- // 用户通知公告
- notices:[]
- }
- })
|