first commit
This commit is contained in:
55
pages/me/auth.vue
Normal file
55
pages/me/auth.vue
Normal file
@@ -0,0 +1,55 @@
|
||||
<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>
|
||||
Reference in New Issue
Block a user