1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- // app.js
- const utils = require('/utils/util.js')
- const baseIp= "http://localhost:9747"
- 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:""
- }
- _this.globalData.waterCompanys=resData.waterCompany;
- if (!resData.swUserManagementVos || resData.swUserManagementVos.length == 0) {
- wx.navigateTo({
- url: '/pages/FirstBangDing/FirstBangDing',
- })
- } else {
- // _this.globalData.userBindInfo = groupArr
- }
- } else {
- utils.simleInfo('登录失败,请稍后再试')
- }
- },
- fail: error => {
- wx.hideLoading()
- utils.simleInfo('登录失败,请稍后再试')
- }
- })
- }else{
- utils.simleInfo('登录失败,请稍后再试')
- }
- }
- })
- },
- globalData: {
- // 当前用户信息
- userWxInfo: null,
- // 系统中存在的水务公司
- waterCompanys: [],
- // 小程序启动时带的参数
- launchPara: null,
- // 系统接口地址
- interfaceUrls: {
- loginUrl: baseIp+ '/wechat/login', // 登录+获取绑定列表
- accoundBind: baseIp+ '/wechat/account/bind', // 账号绑定
- },
- // 统一管理图片路径
- 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'
- }
- }
- }
- })
|