新增昵称页面,修改头像

This commit is contained in:
张凯 2025-06-12 18:31:23 +08:00
parent 78824174cc
commit 4d78563d12
4 changed files with 1576 additions and 15 deletions

View File

@ -17,9 +17,10 @@
<view class="left">
昵称设置
</view>
<view class="right">
<u--input color="#000000" v-model="niName" placeholder="请输入昵称" border="none"
inputAlign="right"></u--input>
<view class="right" @click="toName">
<!-- <u--input color="#000000" v-model="niName" placeholder="请输入昵称" disabled border="none"
inputAlign="right"></u--input> -->
<text>{{niName}}</text>
<u-icon name="arrow-right"></u-icon>
</view>
</view>
@ -61,8 +62,8 @@
</view>
</view>
<view class="bottom">
<u-button v-if="typeop == 2" :customStyle="style" @click="out">退出账号</u-button>
<u-button v-else :customStyle="style" @click="submit">保存</u-button>
<u-button :customStyle="style" @click="out">退出账号</u-button>
<!-- <u-button v-else :customStyle="style" @click="submit">保存</u-button> -->
</view>
<!-- <u-picker :show="show" :columns="columns" keyName='name' @confirm="confirm" @cancel="cancel"></u-picker>
<u-picker :show="show1" :columns="columns1" keyName='name' @confirm="confirm1" @cancel="cancel"></u-picker>
@ -72,7 +73,7 @@
<u-picker :show="show4" ref="uPicker" :loading="loading" :columns="columns3" @change="changeHandler"
@cancel="cancel" @confirm="confirm4"></u-picker> -->
<u-popup :show="show5" @close="close" :closeOnClickOverlay="false" closeable :customStyle="avatarStyle">
<!-- <u-popup :show="show5" @close="close" :closeOnClickOverlay="false" closeable :customStyle="avatarStyle">
<view class="avatar_choose">
<view class="cards" @click="clickAvatar(0)">
<img src="https://naweigetetest2.hschool.com.cn/dyqc/img1.png" alt="" />
@ -99,7 +100,7 @@
</view>
</view>
</view>
</u-popup>
</u-popup> -->
<u-toast ref="uToast"></u-toast>
</view>
</template>
@ -257,6 +258,11 @@
url: '/packageB/card/index'
})
},
toName(){
uni.navigateTo({
url: '/packageB/names/index'
})
},
getSfInfo() {
uni.$u.http.get('/api/school.real_name/info').then(res => {
console.log(res);
@ -283,9 +289,20 @@
// birthday: this.birthday,
// realname: this.realname,
// gender: this.gender == '' ? '1' : '0',
update_fields: ['nickname', 'birthday', 'realname', 'gender', 'work', 'avatar']
update_fields: [
'nickname',
// 'birthday',
// 'realname',
// 'gender',
// 'work',
'avatar'
]
}).then(res => {
if (res.code == 1) {
uni.setStorageSync('userInfo', {
...uni.getStorageSync('userInfo'),
avatar: avatar
});
this.getDetail()
this.$refs.uToast.show({
type: 'success',
@ -402,6 +419,7 @@
that.avatar = group.data.fullurl
console.log(group.data)
console.log(that.avata)
that.submit();
}
});
}

111
packageB/names/index.vue Normal file
View File

@ -0,0 +1,111 @@
<template>
<view class="page">
<view style="padding:30rpx;">
<view style="display: flex;align-items: center;">
<view style="width: 100%;">
<input placeholder-class="plasty" placeholder="输入您的昵称" class="input" v-model="form.nickname" />
</view>
</view>
</view>
<view class="btn_1" @click="save()">保存</view>
</view>
</template>
<script>
export default {
data() {
return {
form: {
nickname: '',
},
}
},
onLoad() {
this.form.nickname = uni.getStorageSync('userInfo').nickname;
},
methods: {
save() {
if (this.form.nickname == '') {
uni.showToast({
title: '请输入昵称',
icon: "none",
duration: 1500,
});
return;
}
let nickname = this.form.nickname;
uni.$u.http
.post("/api/user/profile", {
nickname: nickname,
update_fields: ['nickname']
})
.then((res) => {
console.log(res);
if (res.code == 1) {
uni.showToast({
title: '保存成功',
icon: "none",
duration: 1500,
complete: function () {
setTimeout(function () {
uni.navigateBack(1);
}, 1500);
}
});
uni.setStorageSync('userInfo', {
...uni.getStorageSync('userInfo'),
nickname: nickname
});
uni.setStorageSync('niName', nickname);
} else {
uni.showToast({
title: res.msg,
icon: "none",
duration: 2000,
});
}
})
}
}
}
</script>
<style lang="scss" scoped>
.page {
font-family: PingFang SC Bold, PingFang SC Bold;
}
.input {
border-radius: 18rpx 18rpx 18rpx 18rpx;
border: 1rpx solid #707070;
height: 80rpx;
padding-left: 10rpx;
color: #999999;
}
.plasty {
font-weight: 300;
font-size: 28rpx;
color: #999999;
}
.btn_1 {
width: 95%;
height: 90rpx;
background: #323232;
border-radius: 198rpx 198rpx 198rpx 198rpx;
font-family: YouSheBiaoTiHei, YouSheBiaoTiHei;
font-weight: 400;
font-size: 32rpx;
color: #BBFC5B;
line-height: 90rpx;
text-align: center;
margin: 0 auto;
position: fixed;
bottom: 5%;
left: 0;
right: 0;
}
</style>

View File

@ -78,7 +78,8 @@
}
],
"subPackages": [{
"subPackages": [
{
"root": "packageA",
"pages": [{
"path": "afterSales/index",
@ -309,7 +310,13 @@
},
{
"root": "packageB",
"pages": [{
"pages": [
{
"path": "names/index",
"style": {
"navigationBarTitleText": "昵称修改"
}
},{
"path": "wallet/index",
"style": {
"navigationBarTitleText": "我的钱包"

File diff suppressed because it is too large Load Diff