purchase-let/pages/login/test.vue

46 lines
1.0 KiB
Vue
Raw Normal View History

2024-06-15 17:29:39 +08:00
<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 {
accountLogin,
userInfoApi
} from "@/api/user.js";
import {
ref
} from "vue"
import useUserStore from "@/store/user";
const userStore = useUserStore();
const zh = ref("")
const submit = () => {
accountLogin({
account: zh.value,
"password": "123456",
"terminal": 2,
"scene": 1
}).then(res => {
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>