52 lines
1.1 KiB
Vue
52 lines
1.1 KiB
Vue
<template>
|
|
<view class="" style="padding: 100rpx;">
|
|
<up-input :customStyle="{height: '100%'}" v-model="zh" placeholderClass="place" placeholder="请输入手机号" />
|
|
<up-button @click="submit" color="#20B128" size="large"><up-icon name="weixin-fill" color="#fff"
|
|
size="28"></up-icon>账号登录</up-button>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import {
|
|
userLoginApi,
|
|
userInfoApi,
|
|
getStoreInfo
|
|
} from "@/api/user.js";
|
|
import {
|
|
ref
|
|
} from "vue"
|
|
import useUserStore from "@/store/user";
|
|
const userStore = useUserStore();
|
|
const zh = ref("")
|
|
|
|
const submit = () => {
|
|
userLoginApi({
|
|
account: zh.value,
|
|
"password": "123456",
|
|
"terminal": 2,
|
|
"scene": 1
|
|
}).then(res => {
|
|
|
|
getStoreInfo().then(res => {
|
|
uni.setStorageSync("STORE_INFO", JSON.stringify(res.data))
|
|
})
|
|
|
|
uni.setStorageSync('token', res.data.token);
|
|
userStore.setToken(res.data.token);
|
|
console.log(res.data.token)
|
|
userInfoApi().then(res => {
|
|
const user = res.data;
|
|
userStore.setUserInfo(user);
|
|
uni.reLaunch({
|
|
url: '/pages/index/index'
|
|
}) // 存储token到本地存储中
|
|
})
|
|
})
|
|
|
|
|
|
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
</style> |