purchase-let/pages/login/test.vue

52 lines
1.1 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 {
2024-06-17 08:38:39 +08:00
userLoginApi,
2024-06-17 20:47:54 +08:00
userInfoApi,
getStoreInfo
2024-06-15 17:29:39 +08:00
} from "@/api/user.js";
import {
ref
} from "vue"
import useUserStore from "@/store/user";
const userStore = useUserStore();
const zh = ref("")
const submit = () => {
2024-06-17 08:38:39 +08:00
userLoginApi({
2024-06-15 17:29:39 +08:00
account: zh.value,
"password": "123456",
"terminal": 2,
"scene": 1
}).then(res => {
2024-06-17 20:47:54 +08:00
getStoreInfo().then(res => {
uni.setStorageSync("STORE_INFO", JSON.stringify(res.data))
})
2024-06-15 17:29:39 +08:00
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>