81 lines
2.2 KiB
Vue
81 lines
2.2 KiB
Vue
<template>
|
|
<view class="SignMultiple">
|
|
<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>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import "./login.scss";
|
|
import Taro, {useLoad} from "@tarojs/taro";
|
|
import api from "@/request/index";
|
|
|
|
import {useCounterStore} from '@/store'
|
|
|
|
const store = useCounterStore()
|
|
useLoad(() => {});
|
|
const onLogin = () => {
|
|
Taro.login({
|
|
success: (res) => {
|
|
if (res.code) {
|
|
api.post<LoginUserInfo>("/login", {
|
|
clientType: 'MINI_PROGRAM',
|
|
loginParams: {
|
|
code: res.code
|
|
}
|
|
}).then(async (resp) => {
|
|
const {
|
|
extData: {
|
|
identity: {value}
|
|
}
|
|
} = resp.data
|
|
if (value === 'police') {
|
|
store.updateHomePagePath('/pages/policeManager/index/index') // 公安首页
|
|
} else {
|
|
store.updateHomePagePath('/pages/projectManager/index/index') // 项目经理首页
|
|
}
|
|
// 将更新后的 list 存储到 Pinia 和本地存储
|
|
await Taro.setStorageSync('list', store.list)
|
|
await Taro.setStorage({
|
|
key: "token",
|
|
data: resp.data,
|
|
success(res) {
|
|
Taro.switchTab({
|
|
// url: '/pages/projectManager/index/index'
|
|
url: store.list[0].pagePath
|
|
})
|
|
},
|
|
})
|
|
}).catch((error) => {
|
|
if (error.code === 402) {
|
|
Taro.navigateTo({
|
|
url: "/pages/register/register",
|
|
});
|
|
}
|
|
})
|
|
}
|
|
},
|
|
});
|
|
};
|
|
</script>
|