55 lines
1.0 KiB
Vue
55 lines
1.0 KiB
Vue
<template>
|
|
<view style="padding: 30rpx;">
|
|
<u-button type="primary" @click="oauth">微信授权</u-button>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import {
|
|
API_URL,
|
|
STATIC_URL
|
|
} from '@/env'
|
|
let self;
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
form: {
|
|
mobile: '',
|
|
code: ''
|
|
},
|
|
}
|
|
},
|
|
onLoad(option) {
|
|
self = this;
|
|
if (option && option.code) {
|
|
self.form.code = option.code;
|
|
self.codelogin();
|
|
} else {
|
|
const pages = getCurrentPages() // 获取栈实例
|
|
|
|
let route = 'pages/index/index';
|
|
if (pages.length > 1) {
|
|
route = pages[pages.length - 2].route; // 获取当前页面的数据,包含页面路由
|
|
}
|
|
uni.setStorageSync('login_back_path', route);
|
|
}
|
|
},
|
|
methods: {
|
|
codelogin() {
|
|
self.$http.post('/app/v10/auth/wxoauthlogin', self.form).then(res => {
|
|
if (res.success) {
|
|
location.href = '/' + uni.getStorageSync('login_back_path');
|
|
}
|
|
})
|
|
},
|
|
oauth() {
|
|
location.href = API_URL + '/app/v10/auth/wxoauth';
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
|
|
</style> |