Files
houyi-uniapp/pages/me/auth.vue
PC-202306242200\Administrator 85b89ccea7 first commit
2026-03-28 23:27:25 +08:00

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>