policeSecurity/collect_information/src/pages/login/login.vue

72 lines
1.6 KiB
Vue
Raw Normal View History

2024-09-10 11:00:20 +08:00
<template>
<view class="SignMultiple">
2024-09-11 09:22:00 +08:00
<view class="urlIndex">
<view class="urlTitle">
<view class="urlWelcome">
<view style="font-size: 26px">Welcome</view>
<view class="urlHibiscus">
<view class="contact">
<image
src='https://img12.360buyimg.com/imagetools/jfs/t1/196430/38/8105/14329/60c806a4Ed506298a/e6de9fb7b8490f38.png'
mode="scaleToFill"
class="image"
/>
<text>欢迎</text>
</view>
</view>
</view>
</view>
</view>
<view class="SignItem">
<view class="Cancel">
<nut-button block type="success" @click="onLogin">一键授权</nut-button>
</view>
</view>
2024-09-10 11:00:20 +08:00
</view>
</template>
<script setup lang="ts">
import "./login.scss";
import Taro, { useLoad } from "@tarojs/taro";
2024-09-11 09:22:00 +08:00
import api from "@/request/index";
2024-09-10 11:00:20 +08:00
2024-09-11 09:22:00 +08:00
useLoad(() => {});
const onLogin = () => {
Taro.login({
success: (res) => {
if(res.code){
api.post<LoginUserInfo>("/login", {
clientType: 'MINI_PROGRAM',
loginParams: {
code:res.code
}
}).then(async (resp)=>{
await Taro.setStorage({
key: "token",
data: resp.data,
success(res) {
Taro.switchTab({
url: '/pages/projectManager/index/index'
})
},
})
}).catch((error)=>{
if(error.code === 402){
Taro.navigateTo({
url: "/pages/register/register",
});
}
})
}
},
});
2024-09-10 11:00:20 +08:00
2024-09-11 09:22:00 +08:00
};
2024-09-10 11:00:20 +08:00
</script>