You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
2.2 KiB
Vue

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<script setup>
/**
* name
* usersa0ChunLuyu
* date2022-04-20 09:02:17
*/
import {
ref
} from 'vue'
import {
getUserInfoAction,
userLoginAction,
getConfigAction
} from '@/api/index.js'
import {
loginJump
} from '@/tool/login.js'
import {
setToken
} from '@/tool/member.js'
import config from '@/config.js'
import {
useStore
} from 'vuex'
const $store = useStore()
const getConfigPhone = () => {
getConfigAction("'设置手机号'", (list) => {
$store.commit('loadingDone')
if (Number(list["设置手机号"].content) === 1) {
uni.navigateTo({
url: '/pages/user/set_info/set_info'
})
} else {
loginJump()
}
})
}
const getUserInfo = () => {
getUserInfoAction((info) => {
if (!info.phone) {
getConfigPhone()
} else {
$store.commit('loadingDone')
loginJump()
}
})
}
const wxGetUserInfo = (res) => {
$store.commit('loadingStart')
if (!res.detail.iv) {
uni.$lu.toast("您取消了授权,登录失败");
return false;
}
uni.login({
provider: 'weixin',
success: (loginRes) => {
userLoginAction(loginRes.code, (token) => {
setToken(token)
getUserInfo()
}, () => {
$store.commit('loadingDone')
})
},
});
}
</script>
<template>
<Loading></Loading>
<view class="home_wrapper u-text-center">
<view class="home_logo_wrapper">
<u-image width="200rpx" height="200rpx" src="/static/logo.png"></u-image>
</view>
<view class="home_title_wrapper">{{ config.title }}</view>
<view class="primary_button_wrapper">
<button class="opentype_button_wrapper" open-type="getUserInfo" @getuserinfo="wxGetUserInfo"
withCredentials="true"></button>
微信登录
</view>
</view>
</template>
<style scoped>
.home_title_wrapper {
margin: 10rpx 0;
}
.home_logo_wrapper {
width: 200rpx;
height: 200rpx;
margin: 0 auto;
}
.home_wrapper {
position: absolute;
top: 30%;
left: 50%;
transform: translate(-50%, -50%);
}
.open_type_button_wrapper {
margin-top: 30rpx;
width: 500rpx;
height: 80rpx;
line-height: 80rpx;
font-size: 26rpx;
}
</style>