| | |
| | | loginPost,
|
| | | getUserInfo,
|
| | | sendSMsPost,
|
| | | ywWxAuthorize
|
| | | ywWxAuthorize, |
| | | |
| | | getRecordByUserPoint
|
| | | } from '@/api'
|
| | | import {
|
| | | mapState,
|
| | |
| | | code: ''
|
| | | },
|
| | | downTime: 0,
|
| | | code: '111' |
| | | // code: ''
|
| | | code: ''
|
| | | }
|
| | | },
|
| | |
|
| | | onLoad(option) {
|
| | | console.log('onLoad');
|
| | | // https://zhcg.fnwtzx.com/#/pages/login?type=0&ywid=ywid
|
| | | 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 = uni.getStorageSync('ywinfo') || {}
|
| | | if (ywinfo.ywid && (ywinfo.type || ywinfo.type == 0)) { |
| | | getRecordByUserPoint({pointCode: ywinfo.ywid}).then(res => { |
| | | if(res.data && res.data.id){ |
| | | uni.setStorageSync('ywinfo', {}) |
| | | uni.redirectTo({ |
| | | url: "/pages/polling/point?id=" + res.data.id |
| | | }) |
| | | } |
| | | })
|
| | | }, 300)
|
| | | } else {
|
| | | setTimeout(() => {
|
| | | uni.redirectTo({
|
| | | url: "/pages/index"
|
| | | })
|
| | | }, 300)
|
| | | }
|
| | | }
|
| | | }
|
| | | })
|
| | |
| | | }
|
| | |
|
| | | },
|
| | | // 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 = uni.getStorageSync('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.setStorageSync('ywinfo', {}) |
| | | uni.redirectTo({ |
| | | url: "/pages/polling/point?id=" + res.data.id |
| | | }) |
| | | } |
| | | }) |
| | | }) |
| | | } else { |
| | | uni.redirectTo({ |
| | | url: "/pages/index" |
| | | }) |
| | | }
|
| | | })
|
| | | }
|
| | | })
|