This commit is contained in:
pengxiaolong
2025-05-20 00:10:07 +08:00
parent ff546bd9a9
commit 6107739077
34 changed files with 583 additions and 92 deletions

View File

@@ -1,20 +1,88 @@
<template>
<div>
<button @click="openConversationList">打开会话列表</button>
<button @click="openContact">打开联系人</button>
</div>
</template>
<script>
export default {
methods: {
// 打开会话列表
openConversationList() {
uni.navigateTo({ url: '/TUIKit/components/TUIConversation/index' });
},
// 打开联系人
openContact() {
uni.navigateTo({ url: '/TUIKit/components/TUIContact/index' });
},
<view class="container">
<view class="PersonalInformation">
<view class="header">
<image :src="userinfo.headerIcon" mode="scaleToFill" class="headerIcon" />
</view>
<view>
<view class="name">{{ userinfo.nickName }}</view>
</view>
<view class="Settings" @click="goSetting">
<image class="SettingsIcon" src="../../static/Settings.png" mode="scaleToFill"/>
</view>
</view>
</view>
<view class="tabBar">
<tabBar></tabBar>
</view>
</template>
<script>
import tabBar from "../../components/tabBar/tabBar";
export default {
data() {
return {
userinfo: {},
};
},
onShow() {
uni.getStorage({
key: "userinfo",
success: (res) => {
this.userinfo = res.data;
console.log(this.userinfo);
},
});
},
methods: {
goSetting() {
uni.navigateTo({
url: '/pages/Setting/Setting'
});
},
};
</script>
},
components: {
tabBar,
},
};
</script>
<style scoped>
.container {
display: flex;
flex-direction: column;
align-items: center;
height: 100%;
width: 100%;
background: linear-gradient(to bottom, #11cb2a6e, #2574fc6d);
}
.PersonalInformation {
margin-top: 200rpx;
display: flex;
align-items: center;
width: 100%;
}
.header {
margin-left: 50rpx;
width: 100rpx;
height: 100rpx;
border-radius: 50%;
}
.headerIcon {
width: 100rpx;
height: 100rpx;
border-radius: 50%;
}
.name {
margin-left: 30rpx;
}
.Settings {
margin-left: 370rpx;
width: 50rpx;
height: 50rpx;
}
.SettingsIcon {
width: 50rpx;
height: 50rpx;
}
</style>

136
pages/Setting/Setting.vue Normal file
View File

@@ -0,0 +1,136 @@
<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 {
inject: ["$global"],
data() {
return {
userinfo:"",
name: "",
id: "",
info: {},
userSig: "",
};
},
onLoad(option) {
uni.getStorage({
key: "userinfo",
success: (res) => {
this.id = res.data.id;
this.name = res.data.nickName;
this.userinfo = res.data.headerIcon;
},
});
uni.getStorage({
key: "userSig",
success: (res) => {
this.userSig = res.data;
},
});
},
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,
});
console.log("userinfo", this.userinfo);
console.log("name", this.name);
console.log("id", this.id);
console.log("userSig", this.userSig);
const res = await request({
url: "user/updateUserInfo",
method: "POST",
data: {
id: this.id,
headerIcon: this.userinfo,
nickName: this.name,
usersig: this.userSig,
},
userInfo: false,
});
console.log("res", res);
if (res.code === 200) {
uni.showToast({
title: "修改成功",
icon: "success",
});
console.log("修改成功", res.data);
uni.setStorageSync("userinfo", res.data.info);
uni.hideLoading();
//```````````````````````````````````````````````````````````````````````登录成功后跳转回原页面 或 首页
uni.navigateBack({
delta: 1
});
//````````````````````````````````````````````````````````````````````
} else {
uni.showToast({
title: "修改失败",
icon: "none",
});
}
},
},
};
</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

@@ -11,6 +11,7 @@
<script>
import request from "../../components/request.js";
import genTestUserSig from "../../components/debug/GenerateTestUserSig.js";
import TUIlogin from "../../components/TUILogin.js";
// const genTestUserSig = require('../../components/debug/GenerateTestUserSig.js');
export default {
inject: ['$global'],
@@ -54,6 +55,7 @@ export default {
SECRETKEY:this.info.data.chatInfo.appKey,
userID: userID,
})
uni.setStorageSync("chatInfo", this.info.data.chatInfo)
uni.setStorageSync("userSig", userSig)
uni.setStorageSync("userinfo", this.info.data.info);
uni.reLaunch({
@@ -62,6 +64,7 @@ export default {
} else {
uni.setStorageSync("userinfo", this.info.data.info);
uni.hideLoading();
TUIlogin(this.info.data.chatInfo.appId, this.info.data.info.userChatId, userSig)
//跳转原来页面否则首页
uni.reLaunch({
url: this.$global.lastPage || "/pages/Home/Home", // 默认页