优化代码

This commit is contained in:
pengxiaolong
2025-08-05 22:05:56 +08:00
parent 3eddd94922
commit 40c3282515
86 changed files with 1700 additions and 399 deletions

View File

@@ -1,7 +1,7 @@
<template>
<view class="return" @click="Return">
<image
style="width:40rpx;height:40rpx;"
style="width: 40rpx; height: 40rpx"
src="https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/Return.png"
mode="scaleToFill"
/>
@@ -18,11 +18,11 @@
<script>
import request from "../../components/request.js";
import { goEasylogin } from "../../components/goEasyTool/tool.js";
import { useCounterStore } from '@/stores/counter'
import { useCounterStore } from "@/stores/counter";
const counter = useCounterStore()
const counter = useCounterStore();
export default {
inject: ['$global'],
inject: ["$global"],
data() {
return {
userInfo: {},
@@ -42,14 +42,14 @@ export default {
uni.getStorage({
key: "lastPage",
success: (res) => {
this.lastPage = "/"+res.data;
this.lastPage = "/" + res.data;
},
fail: () => {
this.lastPage = "/pages/Home/Home";
},
})
});
},
methods: {
// 返回首页
Return() {
@@ -58,7 +58,7 @@ export default {
});
},
// 获取手机号
async getPhoneNumber(e) {
getPhoneNumber(e) {
if (e.detail.code == undefined) {
uni.showToast({
title: "登录失败",
@@ -70,40 +70,51 @@ export default {
title: "登录中...",
mask: true,
});
const res = await request({
url: "user/loginWithPhoneNumber",
method: "POST",
data: {
code: e.detail.code,
},
userInfo: false,
});
this.info = res;
uni.setStorageSync("userinfo", this.info.data.info);
const now = Date.now();
uni.setStorageSync("last_clean_time", now);
counter.$patch({ myitem:this.info.data.info })
if (this.info.code === 200) {
if (this.info.data.newAccount) {
uni.reLaunch({
url: "/pages/UserInformation/UserInformation",
});
uni.hideLoading();
request({
url: "user/loginWithPhoneNumber",
method: "POST",
data: {
code: e.detail.code,
},
userInfo: false,
}).then((res) => {
uni.hideLoading();
this.info = res;
uni.setStorageSync("userinfo", this.info.data.info);
const now = Date.now();
uni.setStorageSync("last_clean_time", now);
counter.$patch({ myitem: this.info.data.info });
if (this.info.code === 200) {
if (this.info.data.newAccount) {
uni.reLaunch({
url: "/pages/UserInformation/UserInformation",
});
uni.hideLoading();
} else {
uni.setStorageSync("userinfo", this.info.data.info);
uni.setStorageSync("token", res.data.info.token);
goEasylogin(
this.$goeasy,
String(this.info.data.info.id),
this.info.data.info.headerIcon,
this.info.data.info.nickName
);
uni.hideLoading();
//跳转原来页面否则首页
uni.reLaunch({
url: this.lastPage,
});
}
} else {
uni.setStorageSync("userinfo", this.info.data.info);
goEasylogin(this.$goeasy,String(this.info.data.info.id),this.info.data.info.headerIcon,this.info.data.info.nickName);
uni.hideLoading();
//跳转原来页面否则首页
uni.reLaunch({
url: this.lastPage,
});
uni.showToast({
title: "登录失败",
icon: "none",
});
}
} else {
uni.showToast({
title: "登录失败",
icon: "none",
});
}
})
.catch((err) => {
console.log(err);
});
},
},
};
@@ -146,7 +157,7 @@ export default {
font-size: 24rpx;
margin-top: 40rpx;
}
.return{
.return {
position: fixed;
top: 100rpx;
left: 80rpx;