更新用户头像昵称功能

This commit is contained in:
gong
2025-12-19 14:50:56 +08:00
parent 9ea8a2a7ab
commit 1f9ec41195
3 changed files with 653 additions and 671 deletions

9
.gitignore vendored
View File

@@ -3,3 +3,12 @@
node_modules/
.vscode/
.hbuilderx/
/.idea/inspectionProfiles/Project_Default.xml
/.idea/.gitignore
/.idea/cashier_wx.iml
/.idea/jsLibraryMappings.xml
/.idea/misc.xml
/.idea/modules.xml
/.idea/uniappSupport.xml
/.idea/UniappTool.xml
/.idea/vcs.xml

View File

@@ -31,6 +31,14 @@ export const APIuser = (data) => {
})
}
export const updateUserInfoReq = (data) => {
return request({
url: url + '/user',
method: 'put',
data: data
})
}
//获取手机号
export const APIuserphone = (data) => {
return request({

View File

@@ -1,52 +1,32 @@
<template>
<view class="container">
<image
class="topBack"
:src="
<image class="topBack" :src="
userInfo.shopExtendList
? userInfo.shopExtendList[1].value
? userInfo.shopExtendList[1].value
: 'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/myTopBack.png'
: 'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/myTopBack.png'
"
mode="aspectFill"
></image>
" mode="aspectFill"></image>
<view class="myContent">
<view class="my_info flex-between">
<view class="my_info_left">
<image
class="my_info_left_head"
:src="userInfo.headImg"
mode="aspectFill"
></image>
<view class="name">{{ userInfo.nickName }}</view>
<button class="atatar-btn" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
<image class="my_info_left_head" :src="userInfo.headImg" mode="aspectFill"></image>
</button>
<!-- <view class="name">{{ userInfo.nickName }}</view> -->
<input type="nickname" class="name" v-model="userInfo.nickName" placeholder="输入昵称"
@blur="onNicknameInput" />
</view>
<view class="right-icons">
<image
class="my_info_right_qr"
src="/static/icon/code.png"
mode="aspectFill"
></image>
<image class="my_info_right_qr" src="/static/icon/code.png" mode="aspectFill"></image>
<view class="msg-view" @click="viewUserMsgList">
<view class="msg-icon-wrapper">
<image
v-if="unreadMsgCount > 0"
class="my-msg-icon"
src="/static/mine/msg_select.png"
mode="aspectFill"
></image>
<image
v-else
class="my-msg-icon"
src="/static/mine/msg.png"
mode="aspectFill"
></image>
<image v-if="unreadMsgCount > 0" class="my-msg-icon" src="/static/mine/msg_select.png"
mode="aspectFill"></image>
<image v-else class="my-msg-icon" src="/static/mine/msg.png" mode="aspectFill"></image>
<!-- 角标 -->
<view
v-if="unreadMsgCount > 0"
class="badge"
>
<view v-if="unreadMsgCount > 0" class="badge">
<text class="badge-text">{{ unreadMsgCount > 99 ? '99+' : unreadMsgCount }}</text>
</view>
</view>
@@ -69,11 +49,9 @@
<view class="amount">
<view class="u-flex u-flex-between u-m-t-20">
<view class="u-flex">
<image
style="width: 50rpx; height: 37rpx"
<image style="width: 50rpx; height: 37rpx"
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/storedValue.png"
mode="aspectFill"
></image>
mode="aspectFill"></image>
<text class="color-333 font-14 u-m-l-20">储值</text>
</view>
<view class="u-flex color-666" @click="toChargeList">
@@ -83,18 +61,9 @@
</view>
<view class="card-list">
<view
class="card-list-item"
v-for="(item, index) in rechargeList"
:key="index"
@click="toCharge(item)"
>
<up-image
radius="20rpx"
width="182rpx"
height="182rpx"
:src="item.logo"
></up-image>
<view class="card-list-item" v-for="(item, index) in rechargeList" :key="index"
@click="toCharge(item)">
<up-image radius="20rpx" width="182rpx" height="182rpx" :src="item.logo"></up-image>
<view class="info text-center">
<view class="color-333 u-m-t-14">
<text class="font-10">¥</text>
@@ -107,12 +76,8 @@
}}</view>
</view>
</view>
<view
class="u-flex u-flex-column u-flex-center"
style="width: 12px"
v-if="rechargeList.length"
@click="toChargeList"
>
<view class="u-flex u-flex-column u-flex-center" style="width: 12px" v-if="rechargeList.length"
@click="toChargeList">
<view class="text-center color-333 font-12">查看全部</view>
</view>
</view>
@@ -120,11 +85,8 @@
<view class="vip u-m-t-40">
<view class="u-flex u-flex-between u-m-t-20">
<view class="u-flex">
<image
style="width: 50rpx; height: 40rpx"
src="/static/icon/vip.png"
mode="aspectFill"
></image>
<image style="width: 50rpx; height: 40rpx" src="/static/icon/vip.png" mode="aspectFill">
</image>
<text class="color-333 font-14 u-m-l-20">会员</text>
</view>
<view class="u-flex color-666" @click="tomemberList">
@@ -134,43 +96,26 @@
</view>
<view class="card-list">
<view
class="card-list-item"
v-for="(item, index) in memberList"
:key="index"
@click="tomember(item)"
>
<up-image
radius="20rpx"
width="182rpx"
height="182rpx"
:src="item.logo"
></up-image>
<view class="card-list-item" v-for="(item, index) in memberList" :key="index"
@click="tomember(item)">
<up-image radius="20rpx" width="182rpx" height="182rpx" :src="item.logo"></up-image>
<view class="info text-center">
<view class="font-12 color-666 u-m-t-14 u-line-1">{{
item.shopName
}}</view>
</view>
</view>
<view
class="u-flex u-flex-column u-flex-center"
style="width: 12px"
v-if="memberList.length"
>
<view class="text-center color-333 font-12" @click="tomemberList"
>查看全部</view
>
<view class="u-flex u-flex-column u-flex-center" style="width: 12px" v-if="memberList.length">
<view class="text-center color-333 font-12" @click="tomemberList">查看全部</view>
</view>
</view>
</view>
<view class="amount">
<view class="u-flex u-flex-between u-m-t-20">
<view class="u-flex">
<image
style="width: 50rpx; height: 44rpx"
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/points.png"
mode="aspectFill"
></image>
<image style="width: 50rpx; height: 44rpx"
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/points.png" mode="aspectFill">
</image>
<text class="color-333 font-14 u-m-l-20">积分</text>
</view>
<view class="u-flex color-666" @click="toCoin">
@@ -180,18 +125,9 @@
</view>
<view class="card-list">
<view
class="card-list-item"
v-for="(item, index) in coinList"
:key="index"
@click="toCoin(item)"
>
<up-image
radius="20rpx"
width="182rpx"
height="182rpx"
:src="item.logo"
></up-image>
<view class="card-list-item" v-for="(item, index) in coinList" :key="index"
@click="toCoin(item)">
<up-image radius="20rpx" width="182rpx" height="182rpx" :src="item.logo"></up-image>
<view class="info text-center">
<view class="color-333 u-m-t-14">
<text class="font-10">¥</text>
@@ -204,12 +140,8 @@
}}</view>
</view>
</view>
<view
class="u-flex u-flex-column u-flex-center"
style="width: 12px"
v-if="coinList.length"
@click="toCoin"
>
<view class="u-flex u-flex-column u-flex-center" style="width: 12px" v-if="coinList.length"
@click="toCoin">
<view class="text-center color-333 font-12">查看全部</view>
</view>
</view>
@@ -217,18 +149,10 @@
</view>
<view class="my_item my_fun u-m-t-30">
<view class="my_fun_list">
<view
class="my_list_item"
v-for="(item, index) in myFunList"
:key="index"
@click="clickTo(item, index)"
>
<view class="my_list_item" v-for="(item, index) in myFunList" :key="index"
@click="clickTo(item, index)">
<view class="my_list_item_left">
<image
class="my_list_item_icon"
:src="item.icon"
mode="aspectFill"
></image>
<image class="my_list_item_icon" :src="item.icon" mode="aspectFill"></image>
<view class="my_list_item_name">{{ item.name }}</view>
</view>
<view class="my_list_item_right u-flex">
@@ -237,34 +161,19 @@
}}</text>
<!-- <text v-else-if="item.type=='my_coupon'" class="font-12 ">{{userInfo.couponNum || 0}}</text> -->
<text class="font-12 color-999" v-else>查看</text>
<u-icon
class="u-m-t-2"
name="arrow-right"
color="#999999"
size="12"
></u-icon>
<u-icon class="u-m-t-2" name="arrow-right" color="#999999" size="12"></u-icon>
</view>
</view>
</view>
</view>
<!-- <l-qrcode :value="wechatAcQrcode" @complete="e=>qrcodeResult(e)"/> -->
<view
class="qrcode u-flex u-col-center justify-between"
v-if="showQrcode"
>
<view class="qrcode u-flex u-col-center justify-between" v-if="showQrcode">
<view>
<view class="color-000 font-14 font-bold">扫码关注公众号</view>
<view class="u-m-t-16 color-999 font-12"
>长按识别关注更多优惠不能错过</view
>
<view class="u-m-t-16 color-999 font-12">长按识别关注更多优惠不能错过</view>
</view>
<up-image
width="178rpx"
height="178rpx"
:show-menu-by-longpress="true"
:src="qrcode"
></up-image>
<up-image width="178rpx" height="178rpx" :show-menu-by-longpress="true" :src="qrcode"></up-image>
</view>
</view>
@@ -276,25 +185,47 @@
</template>
<script setup>
import weQrcode from "@/components/wechat-ac-qrcode.vue";
import devetools from "@/components/devetools.vue";
import weQrcode from "@/components/wechat-ac-qrcode.vue";
import devetools from "@/components/devetools.vue";
import { ref, computed, onMounted, reactive, watch } from "vue";
import { onLoad, onReady, onShow } from "@dcloudio/uni-app";
import { productStore } from "@/stores/user.js";
import * as vipApi from "@/common/api/account/vip.js";
import * as rechargeApi from "@/common/api/market/recharge.js";
import { pointsShopList } from '@/common/api/market/points.js'
import { getUnReadCountReq } from "../../common/api/account/message";
import {
ref,
computed,
onMounted,
reactive,
watch
} from "vue";
import {
onLoad,
onReady,
onShow
} from "@dcloudio/uni-app";
import {
productStore
} from "@/stores/user.js";
import * as vipApi from "@/common/api/account/vip.js";
import * as rechargeApi from "@/common/api/market/recharge.js";
import {
pointsShopList
} from '@/common/api/market/points.js'
import {
getUnReadCountReq
} from "../../common/api/account/message";
import {
updateUserInfoReq
} from "../../common/api/api";
import {
uploadFile
} from '@/common/api/upload.js';
function qrcodeResult(res) {
function qrcodeResult(res) {
qrcode.value = res;
}
}
const store = productStore();
const myFunList = ref([
const store = productStore();
const myFunList = ref([
// {
// name: "积分",
// type: "score",
@@ -333,26 +264,26 @@ const myFunList = ref([
// icon: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/my_member.png"
// },
// { name: "关于", type: "", icon: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/inRegard.png"},
]);
]);
const userInfo = reactive({});
const userInfo = reactive({});
const ShopId = ref(uni.cache.get("shopId"));
console.log("ShopId", uni.cache.get("shopId"));
const ShopId = ref(uni.cache.get("shopId"));
console.log("ShopId", uni.cache.get("shopId"));
function tomemberList() {
function tomemberList() {
uni.navigateTo({
url: "/pages/user/member/list",
});
}
}
function tomember(item) {
function tomember(item) {
uni.navigateTo({
url: "/user/vip/vip?shopId=" + item.shopId,
});
}
}
const clickEvent = () => {
const clickEvent = () => {
if (ShopId.value) {
if (!userInfo.isVip) {
uni.navigateTo({
@@ -380,10 +311,10 @@ const clickEvent = () => {
type: "user_payCode",
});
}
};
};
// 我的资产
const Myassets = () => {
// 我的资产
const Myassets = () => {
if (uni.cache.get("shopId")) {
uni.pro.navigateTo("user/member/memberdetails", {
shopId: uni.cache.get("shopId"),
@@ -395,21 +326,21 @@ const Myassets = () => {
type: "index",
});
}
};
};
function toCharge(item) {
function toCharge(item) {
uni.navigateTo({
url: "/pages/user/member/czzx?shopId=" + item.shopId,
});
}
}
function toChargeList() {
function toChargeList() {
uni.navigateTo({
url: "/pages/user/member/amount-list",
});
}
}
const clickTo = (item, index) => {
const clickTo = (item, index) => {
if (item.url) {
uni.navigateTo({
url: item.url,
@@ -419,7 +350,9 @@ const clickTo = (item, index) => {
let shopId = null;
switch (item.type) {
case "msg":
uni.navigateTo({ url: "/pageChat/index" });
uni.navigateTo({
url: "/pageChat/index"
});
break;
case "my_order":
uni.pro.switchTab("order/index");
@@ -473,16 +406,16 @@ const clickTo = (item, index) => {
});
break;
}
};
};
const memberList = ref([]);
const rechargeList = ref([]);
const memberTotal = ref(0);
const rechargeTotal = ref(0);
const memberList = ref([]);
const rechargeList = ref([]);
const memberTotal = ref(0);
const rechargeTotal = ref(0);
const coinTotal = ref(0);
const coinList = ref([]);
async function getData() {
const coinTotal = ref(0);
const coinList = ref([]);
async function getData() {
const res = await vipApi.list();
memberTotal.value = res.length;
memberList.value = res.slice(0, 3);
@@ -493,17 +426,17 @@ async function getData() {
const res3 = await pointsShopList();
coinTotal.value = res3.length;
coinList.value = res3;
}
}
function toCoin() {
function toCoin() {
uni.navigateTo({
url: "/user/score/list",
});
}
}
const unreadMsgCount = ref(0);
const unreadMsgCount = ref(0);
const getUnReadMsgCount = async () => {
const getUnReadMsgCount = async () => {
let res = await getUnReadCountReq()
let badge = Number(res)
@@ -519,16 +452,24 @@ const getUnReadMsgCount = async () => {
}
unreadMsgCount.value = badge
}
}
const viewUserMsgList = () => {
const viewUserMsgList = () => {
uni.navigateTo({
url: "/pages/user/message/index"
})
}
}
onShow(() => {
store.actionsAPIuser();
onShow(() => {
loadUserInfo()
console.log("userInfo", userInfo);
getData();
getUnReadMsgCount()
});
const loadUserInfo = async () => {
await store.actionsAPIuser();
if (uni.cache.get("shopId")) {
Object.assign(userInfo, uni.cache.get("orderVIP"));
} else {
@@ -537,29 +478,44 @@ onShow(() => {
...uni.cache.get("userInfo").assetsSummary,
});
}
console.log("userInfo", userInfo);
getData();
}
getUnReadMsgCount()
});
const qrcode = ref("");
const showQrcode = computed(() => {
const qrcode = ref("");
const showQrcode = computed(() => {
const followIndex = uni.cache.get("followIndex");
if (followIndex == "mine" && qrcode.value) {
return true;
}
});
});
const onChooseAvatar = async (e) => {
const fileRes = await uploadFile(e.detail.avatarUrl)
updateUserInfo({
"headImg": fileRes
})
}
const onNicknameInput = (e) => {
updateUserInfo({
"nickName": e.detail.value
})
}
const updateUserInfo = async (param) => {
await updateUserInfoReq(param)
loadUserInfo()
}
</script>
<style scoped lang="scss">
.topBack {
.topBack {
width: 100%;
height: 400rpx;
position: absolute;
}
}
.myContent {
.myContent {
position: relative;
z-index: 1;
padding: 298rpx 0 60rpx 0;
@@ -574,6 +530,13 @@ const showQrcode = computed(() => {
display: flex;
align-items: center;
.atatar-btn {
padding: 0;
background: transparent;
border: none;
border-radius: 50%;
}
.my_info_left_head {
width: 84rpx;
height: 84rpx;
@@ -694,9 +657,9 @@ const showQrcode = computed(() => {
}
}
}
}
}
.card-list {
.card-list {
display: grid;
grid-template-columns: repeat(4, 1fr);
column-gap: 40rpx;
@@ -713,19 +676,21 @@ const showQrcode = computed(() => {
overflow: hidden;
}
}
}
.qrcode {
}
.qrcode {
padding: 24rpx;
margin: 60rpx 32rpx 60rpx 32rpx;
border-radius: 18rpx;
border: 2rpx solid #d9d9d9;
}
.qrcode-box {
}
.qrcode-box {
position: fixed;
transform: translateX(200vw, 200vh);
}
}
.right-icons {
.right-icons {
display: flex;
.my_info_right_qr {
@@ -766,5 +731,5 @@ const showQrcode = computed(() => {
text-align: center;
}
}
}
}
</style>