67 lines
1.5 KiB
Vue
67 lines
1.5 KiB
Vue
<template>
|
|
<view class="flex flex-col w-full min-h-full">
|
|
<view class="flex-1 pt-300rpx">
|
|
<view class="px-45rpx ">
|
|
<button
|
|
hover-class="none"
|
|
class="cu-btn bg-primary text-center h-80rpx rounded-full leading-80rpx text-white text-lg mt-40rpx"
|
|
open-type="getPhoneNumber"
|
|
@getphonenumber="getPhoneNumber"
|
|
>
|
|
微信一键登录
|
|
</button>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
<script>
|
|
import { getWxCode } from '@/utils/login';
|
|
import { mapMutations } from 'vuex';
|
|
export default {
|
|
data() {
|
|
return {
|
|
check: false,
|
|
code:'',
|
|
};
|
|
},
|
|
async onLoad() {
|
|
},
|
|
methods: {
|
|
...mapMutations({
|
|
LOGIN: 'user/LOGIN',
|
|
}),
|
|
|
|
//微信快捷登录
|
|
async getPhoneNumber(e) {
|
|
const { encryptedData, iv } = e.detail;
|
|
if(!iv) return
|
|
const invite_code = uni.getStorageSync('INVITE_CODE');
|
|
// const code = await getWxCode();
|
|
const params = {}
|
|
if(!!invite_code) params.inviter_code = invite_code
|
|
const resData = await this.$api.post('/v1/socialite/code-bind-user/wechat-mini', {
|
|
type: 'wechat-mini',
|
|
code:this.code,
|
|
iv,
|
|
data: encryptedData,
|
|
...params
|
|
});
|
|
this.LOGIN(resData.token);
|
|
uni.navigateBack({
|
|
delta: 1,
|
|
});
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
<style>
|
|
page {
|
|
background: #fff;
|
|
height: 100%;
|
|
}
|
|
.borderTop {
|
|
border-top-left-radius: 15rpx;
|
|
border-top-right-radius: 15rpx;
|
|
}
|
|
</style>
|