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

@@ -22,6 +22,7 @@ import Advertisement from "../../components/Advertisement/Advertisement";
import contentList from "../../components/contentList/contentList";
import tabBar from "../../components/tabBar/tabBar";
export default {
inject: ['$global'],
data() {
return {};
},
@@ -30,6 +31,8 @@ export default {
},
methods: {
goAdvertisement(){
console.log(uni);
this.$global.lastPage = getCurrentPages().router;
uni.navigateTo({ url: '/pages/login/login' })
}
},

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();
}
},
},
};

View File

@@ -13,6 +13,7 @@ import request from "../../components/request.js";
import genTestUserSig from "../../components/debug/GenerateTestUserSig.js";
// const genTestUserSig = require('../../components/debug/GenerateTestUserSig.js');
export default {
inject: ['$global'],
data() {
return {
userInfo: {},
@@ -34,9 +35,8 @@ export default {
title: "登录中...",
mask: true,
});
try {
const res = await request({
url: "/user/loginWithPhoneNumber",
url: "user/loginWithPhoneNumber",
method: "POST",
data: {
code: e.detail.code,
@@ -62,20 +62,10 @@ export default {
} else {
uni.setStorageSync("userinfo", this.info.data.info);
uni.hideLoading();
// `
uni.navigateBack({
delta: 1, // 返回层级(默认值为 1
});
// `································································登录成功后跳转回原页面 或 首页
// 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({
@@ -83,15 +73,6 @@ export default {
icon: "none",
});
}
} catch (err) {
console.error("登录错误:", err);
uni.showToast({
title: "请检查网络连接",
icon: "none",
});
} finally {
uni.hideLoading();
}
},
},
};