| | |
| | | loginPost,
|
| | | getUserInfo,
|
| | | sendSMsPost,
|
| | | ywWxAuthorize
|
| | | ywWxAuthorize, |
| | | |
| | | getRecordByUserPoint
|
| | | } from '@/api'
|
| | | import {
|
| | | mapState,
|
| | |
| | | form: {
|
| | | phone: '',
|
| | | code: ''
|
| | | },
|
| | | }, |
| | | ywinfo: {},
|
| | | downTime: 0,
|
| | | code: '111' |
| | | // code: ''
|
| | | code: ''
|
| | | }
|
| | | },
|
| | |
|
| | | onLoad(option) {
|
| | | console.log('onLoad');
|
| | | // https://zhcg.fnwtzx.com/#/pages/login?type=0&ywid=ywid |
| | | const ywinfo = uni.getStorageSync('ywinfo') || {} |
| | | if (ywinfo.ywid && (ywinfo.type || ywinfo.type == 0)) { |
| | | this.ywinfo = ywinfo |
| | | uni.setStorageSync('ywinfo', {}) |
| | | }
|
| | | if (option.ywid || option.ywid == 0) {
|
| | | uni.setStorageSync('ywinfo', {
|
| | | type: option.type,
|
| | | ywid: option.ywid
|
| | | })
|
| | | }
|
| | | },
|
| | | onShow() {
|
| | | // return
|
| | | var that = this
|
| | |
| | | ywWxAuthorize({
|
| | | code: code || this.code
|
| | | }).then(res => {
|
| | | if (res.code === 200) { |
| | | if (res.code === 200) {
|
| | | console.log('res', res);
|
| | | that.$store.commit('setOpenId', res.data.openid)
|
| | | if (res.data.token && res.data.token != '') { |
| | | if (res.data.token && res.data.token != '') {
|
| | | that.$store.commit('setToken', res.data.token)
|
| | | getUserInfo().then(ress => {
|
| | | that.$store.commit('setUserInfo', ress.data)
|
| | | })
|
| | | setTimeout(() => {
|
| | | uni.redirectTo({
|
| | | url: "/pages/index"
|
| | | const ywinfo = this.ywinfo
|
| | | if (ywinfo.ywid && (ywinfo.type || ywinfo.type == 0)) { |
| | | getRecordByUserPoint({pointCode: ywinfo.ywid}).then(res => { |
| | | if(res.data && res.data.id){ |
| | | uni.redirectTo({ |
| | | url: "/pages/polling/point?id=" + res.data.id |
| | | }) |
| | | } |
| | | })
|
| | | }, 300)
|
| | | } else {
|
| | | setTimeout(() => {
|
| | | uni.redirectTo({
|
| | | url: "/pages/index"
|
| | | })
|
| | | }, 300)
|
| | | }
|
| | | }
|
| | | }
|
| | | })
|
| | | } else {
|
| | | let url = 'https://zhcg.fnwtzx.com/yunwei_h5'
|
| | | const appID = 'wx95ac1efb67f0330d'
|
| | | // let url = 'https://zhcg.fnwtzx.com/yunwei_h5'
|
| | | // const appID = 'wx95ac1efb67f0330d' |
| | | let url = 'https://dmtest.ahapp.net/yunwei_h5' |
| | | const appID = 'wx4d7c10bdec51942b'
|
| | | let uri = encodeURIComponent(url)
|
| | | let authURL =
|
| | | `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appID}&redirect_uri=${uri}&response_type=code&scope=snsapi_base#wechat_redirect`
|
| | |
| | | }
|
| | |
|
| | | },
|
| | | // onBackPress(options) {
|
| | | // uni.redirectTo({
|
| | | // url: '/pages/login/login'
|
| | | // })
|
| | | // return true
|
| | | // },
|
| | | methods: {
|
| | | ...mapMutations(["setToken", "setUserInfo"]),
|
| | | onLogin() {
|
| | |
| | | this.setToken(res.data)
|
| | | this.showToast('登录成功')
|
| | | getUserInfo().then(ress => {
|
| | | this.setUserInfo(ress.data)
|
| | | uni.redirectTo({
|
| | | url: "/pages/index"
|
| | | })
|
| | | this.setUserInfo(ress.data) |
| | | const ywinfo = this.ywinfo |
| | | if (ywinfo.ywid && (ywinfo.type || ywinfo.type == 0)) { |
| | | getRecordByUserPoint({pointCode: ywinfo.ywid}).then(res => { |
| | | getRecordByUserPoint({pointCode: ywinfo.ywid}).then(res => { |
| | | if(res.data && res.data.id){ |
| | | uni.redirectTo({ |
| | | url: "/pages/polling/point?id=" + res.data.id |
| | | }) |
| | | } |
| | | }) |
| | | }) |
| | | } else { |
| | | uni.redirectTo({ |
| | | url: "/pages/index" |
| | | }) |
| | | }
|
| | | })
|
| | | }
|
| | | })
|