This commit is contained in:
pengxiaolong
2025-05-19 18:34:04 +08:00
parent e05d72fccf
commit ff546bd9a9
31 changed files with 174 additions and 195 deletions

View File

@@ -17,6 +17,7 @@
import request from "../../components/request.js";
export default {
inject: ['$global'],
data() {
return {
userinfo:
@@ -59,8 +60,6 @@ export default {
title: "登录中...",
mask: true,
});
try {
const { code } = await uni.login({
provider: "weixin",
onlyAuthorize: true,
@@ -70,9 +69,8 @@ export default {
console.log("code", this.userinfo);
console.log("code", this.id);
console.log("code", this.userSig);
const res = await request({
url: "/user/inputUserInfo",
url: "user/inputUserInfo",
method: "POST",
data: {
id: this.id,
@@ -84,22 +82,19 @@ export default {
userInfo: false,
});
console.log("res", res);
if (res.data.code === 200) {
if (res.code === 200) {
uni.showToast({
title: "登录成功",
icon: "success",
});
console.log("登录成功", res.data);
uni.setStorageSync("userinfo", res.data.info);
uni.hideLoading();
//```````````````````````````````````````````````````````````````````````登录成功后跳转回原页面 或 首页
// const fromPage = decodeURIComponent(options.from || "");
// if (fromPage) {
// uni.redirectTo({
// url: fromPage,
// });
// } else {
// uni.switchTab({ url: "/pages/index/index" }); // 默认首页
// }
uni.reLaunch({
url: this.$global.lastPage || "/pages/Home/Home", // 默认页
});
//````````````````````````````````````````````````````````````````````
} else {
uni.showToast({
@@ -107,19 +102,6 @@ export default {
icon: "none",
});
}
} catch (err) {
console.error("登录错误:", err);
uni.showToast({
title: "请检查网络连接",
icon: "none",
});
} finally {
uni.hideLoading();
}
},
},
};