123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- // app.js
- const utils = require('/utils/util.js')
- // 图片预览地址
- const ipConfig = {
- develop: "http://192.168.0.215:", //开发地址
- trial: "http://61.177.40.178:", // 体验地址
- release: "https://www.izilaishui.com:", //上线地址
- }
- const hostConfig = {
- develop: "9000/wechat", //开发地址
- trial: "8000/wechat", // 体验地址
- release: "9000/wechat", //上线地址
- }
- App({
- onLaunch(options) {
- const updateManager = wx.getUpdateManager();
- updateManager.onCheckForUpdate(function(res) {
- // 请求完新版本信息的回调
- console.log(res.hasUpdate);
- });
- updateManager.onUpdateReady(function() {
- wx.showModal({
- title: "更新提示",
- content: "新版本已经准备好,是否重启应用?",
- success: function(res) {
- if (res.confirm) {
- // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
- updateManager.applyUpdate();
- }
- },
- });
- });
- updateManager.onUpdateFailed(function() {});
- const ACCOUNT_INFO = wx.getAccountInfoSync();
- const ENV_VERSION = ACCOUNT_INFO.miniProgram.envVersion;
- const baseIp = ipConfig[ENV_VERSION || develop];
- const host = hostConfig[ENV_VERSION || develop];
- const logs = wx.getStorageSync('logs') || []
- this.globalData.interfaceUrls = {
- loginUrl: baseIp + host + '/wechat/login', // 登录+获取绑定列表
- accountBind: baseIp + host + '/wechat/account/bind', // 账号绑定
- homePageInfo: baseIp + host + '/wechat/account/info/', // 首页获取用水量等信息
- billList: baseIp + host + '/wechat/bill/list', // 首页获取用水量等信息
- accountList: baseIp + host + '/wechat/account/list', // 首页获取用水量等信息
- accountUnbind: baseIp + host + '/wechat/account/unbind', // 户号解绑方法
- setDefaultAccount: baseIp + host + '/wechat/account/setDefaultAccount', // 设置默认户号
- repairRegistration: baseIp + host + '/wechat/registration/repair',//报修登记
- feedback: baseIp + host + '/wechat/registration/feedback',//投诉建议
- mineRepair: baseIp + host + '/wechat/mine/repair',//报修登记
- mineFeedback: baseIp + host + '/wechat/mine/feedback',//投诉建议
- paymentList: baseIp + host + '/wechat/payment/record',//缴费记录信息
- pendingBill: baseIp + host + '/wechat/bill/pending/',//代缴费用
- prepayOrder: baseIp + host + '/wechat/payment/prepayOrder/',//获取缴费的订单信息
- createPaymentRecord: baseIp + host + '/wechat/payment/record/create',//获取缴费的订单信息
- updateRadstateStatus: baseIp + host + '/wechat/account/readStatus',//修改已读状态
- updateRadstateStatusAll: baseIp + host + '/wechat/account/readStatusAll',//全部消息已读
- waterList: baseIp + host + '/water/list',//从主库获取全部水站信息
- getHuMing: baseIp + host + '/wechat/account/getHuMing', //根据户号、水站获取户名
- cancelPay: baseIp + host + '/wechat/wechat/payment/cancel/' //用户表取消付款
- }
- // 微信静态文件预览方式 使用二开服务的使用次方法
- this.globalData.weChatImgPreviewUrl = baseIp + "8020/wechat/";
- // 平台
- this.globalData.imgPreviewUrl = baseIp + "9000/common/sys/sysfile/preview/";
- 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.baseIp.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: {
- nickName: "",
- avatarUrl: "",
- // 当前用户信息
- userWxInfo: {},
- // 系统中存在的水务公司
- waterCompanys: [],
- // 小程序启动时带的参数
- launchPara: null,
- // 当前用户所选择的账户信息
- currentAccountInfo: null,
- // 是否刷新主页数据
- refresh: 0,
- baseIp: "",
- // 系统接口地址
- interfaceUrls: {
- },
- // 微信静态文件预览方式 使用二开服务的使用次方法
- weChatImgPreviewUrl: "",
- // 平台
- imgPreviewUrl: "",
- // 统一管理图片路径
- 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: []
- }
- })
|