This commit is contained in:
pengxiaolong
2025-05-15 22:24:39 +08:00
parent 838cfd9986
commit 595c5329a0
44 changed files with 5142 additions and 81 deletions

View File

@@ -5,7 +5,7 @@
<view class="top-navigation-container">
<top-navigation></top-navigation>
</view>
<view class="Advertisement">
<view class="Advertisement" @click="goAdvertisement">
<advertisement></advertisement>
</view>
<view class="contentList">
@@ -29,18 +29,9 @@ export default {
// this.requestSomething();
},
methods: {
// requestSomething() {
// wx.request({
// url: "http://192.168.0.218:8086/user/login", // 请求的 URL
// method: "POST", // 请求方式
// success: (res) => {
// console.log("请求成功", res.data); // 处理成功的响应
// },
// fail: (err) => {
// console.error("请求失败", err); // 处理失败的响应
// },
// });
// },
goAdvertisement(){
uni.navigateTo({ url: '/pages/login/login' })
}
},
components: {
topNavigation,
@@ -83,7 +74,7 @@ export default {
}
.contentList {
position: fixed;
top: 300rpx;
top: 400rpx;
left: 0;
width: 100%;
height: 1300rpx;

View File

@@ -1,17 +1,22 @@
<template>
<button @click="openChat">OpenChat</button>
</template>
<script>
export default {
methods: {
openChat() {
// 1v1 chat: conversationID = `C2C${userID}`
// group chat: conversationID = `GROUP${groupID}`
const conversationID = 'C2Cqwe';
uni.navigateTo({
url: `/TUIKit/components/TUIChat/index?conversationID=${conversationID}`
});
}
}
}
</script>
</template>
<script>
export default {
data() {
return {
title: 'Hello'
}
},
onLoad() {
uni.reLaunch({ url: "/pages/UserInformation/UserInformation"})
},
methods: {
// 方法定义
}
}
</script>
<style scoped>
/* 样式定义 */
</style>

View File

@@ -0,0 +1,161 @@
<template>
<view class="container">
<button class="login-btn" open-type="chooseAvatar" @chooseavatar="Userinfo">
<image class="avatar" :src="userinfo"></image>
</button>
<input
type="nickname"
class="weui-input"
placeholder="请输入昵称"
@blur="inputName"
/>
<button class="weui-btn" @click="wxLogin">登录</button>
</view>
</template>
<script>
import request from "../../components/request.js";
export default {
data() {
return {
userinfo:
"https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0",
name: "",
id: "",
info: {},
userSig: "",
};
},
onLoad(option) {
uni.getStorage({
key: "userinfo",
success: (res) => {
this.id = res.data.id;
},
});
uni.getStorage({
key: "userSig",
success: (res) => {
this.userSig = res.data;
},
});
// const { info } = option;
// this.id = JSON.parse(info).id
},
methods: {
// 输入昵称
inputName(e) {
this.name = e.detail.value;
},
// 选择头像
async Userinfo(e) {
const { avatarUrl } = e.detail;
this.userinfo = avatarUrl;
},
// 微信登录
async wxLogin(e) {
uni.showLoading({
title: "登录中...",
mask: true,
});
try {
const { code } = await uni.login({
provider: "weixin",
onlyAuthorize: true,
});
console.log("code", code);
console.log("code", this.name);
console.log("code", this.userinfo);
console.log("code", this.id);
console.log("code", this.userSig);
const res = await request({
url: "/user/inputUserInfo",
method: "POST",
data: {
id: this.id,
headerIcon: this.userinfo,
nickName: this.name,
code,
usersig: this.userSig,
},
userInfo: false,
});
console.log("res", res);
if (res.data.code === 200) {
uni.showToast({
title: "登录成功",
icon: "success",
});
console.log("登录成功", res.data);
uni.setStorageSync("userinfo", res.data.info);
//```````````````````````````````````````````````````````````````````````登录成功后跳转回原页面 或 首页
// const fromPage = decodeURIComponent(options.from || "");
// if (fromPage) {
// uni.redirectTo({
// url: fromPage,
// });
// } else {
// uni.switchTab({ url: "/pages/index/index" }); // 默认首页
// }
//````````````````````````````````````````````````````````````````````
} else {
uni.showToast({
title: "登录失败",
icon: "none",
});
}
} catch (err) {
console.error("登录错误:", err);
uni.showToast({
title: "请检查网络连接",
icon: "none",
});
} finally {
uni.hideLoading();
}
},
},
};
</script>
<style scoped>
.container {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background: linear-gradient(to bottom, #11cb2a6e, #2574fc6d);
}
.login-btn {
width: 200rpx;
height: 200rpx;
border-radius: 50%;
padding: 0px;
margin-bottom: 60rpx;
}
.avatar {
width: 100%;
height: 100%;
border-radius: 50%;
}
.weui-input {
width: 80%;
text-align: center;
margin-bottom: 40rpx;
}
.weui-btn {
width: 40%;
margin-top: 20rpx;
background-color: #11cb2a00;
color: #fff;
}
</style>

View File

@@ -2,6 +2,8 @@
</template>
<script>
//此页面用于聊天的链接入口,请不要在这里添加内容,不要删除此页面,否则会导致编译失败
//这里虽然看不出任何于聊天有关的内容,但为了防止编译失败,请保留此页面
export default {
data() {
return {

137
pages/login/login.vue Normal file
View File

@@ -0,0 +1,137 @@
<template>
<view class="container">
<image class="logo" :src="userInfo.avatarUrl"></image>
<view class="nickname"> {{ userInfo.nickName }}</view>
<button class="login-btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
使用微信登录
</button>
</view>
</template>
<script>
import request from "../../components/request.js";
import genTestUserSig from "../../components/debug/GenerateTestUserSig.js";
// const genTestUserSig = require('../../components/debug/GenerateTestUserSig.js');
export default {
data() {
return {
userInfo: {},
info: {},
};
},
onLoad() {
uni.getUserInfo({
provider: "weixin",
success: (res) => {
this.userInfo = res.userInfo;
},
});
},
methods: {
// 获取手机号
async getPhoneNumber(e) {
uni.showLoading({
title: "登录中...",
mask: true,
});
try {
const res = await request({
url: "/user/loginWithPhoneNumber",
method: "POST",
data: {
code: e.detail.code,
},
userInfo: false,
});
console.log("登录结果:", res);
this.info = res;
if (this.info.code === 200) {
if (this.info.data.newAccount) {
const sdkAppID = Number(this.info.data.chatInfo.appId);
const userID ="administrator";
const {userSig} = genTestUserSig({
SDKAPPID : sdkAppID,
SECRETKEY:this.info.data.chatInfo.appKey,
userID: userID,
})
uni.setStorageSync("userSig", userSig)
uni.setStorageSync("userinfo", this.info.data.info);
uni.reLaunch({
url: "/pages/UserInformation/UserInformation",
});
} 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" }); // 默认首页
// }
// `·································································
}
} else {
uni.showToast({
title: "登录失败",
icon: "none",
});
}
} catch (err) {
console.error("登录错误:", err);
uni.showToast({
title: "请检查网络连接",
icon: "none",
});
} finally {
uni.hideLoading();
}
},
},
};
</script>
<style>
.container {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background: linear-gradient(to bottom, #11cb2a6e, #2574fc6d);
}
.logo {
width: 200rpx;
height: 200rpx;
border-radius: 50%;
}
.nickname {
width: 300rpx;
height: 100rpx;
color: rgb(255, 255, 255);
border-radius: 0px;
padding: 20rpx 40rpx;
font-size: 30rpx;
text-align: center;
line-height: 100rpx;
}
.login-btn {
background-color: hsla(0, 0%, 100%, 0);
border: 1px solid #00ff0000;
color: #ffffff;
}
.tips {
color: #666;
font-size: 24rpx;
margin-top: 40rpx;
}
</style>