HHSLinkSLink/HSLink-app/pages/tabbar/my/my.vue

379 lines
8.6 KiB
Vue
Raw Normal View History

2020-09-16 09:25:13 +08:00
<template>
2020-09-17 20:01:50 +08:00
<view class="page">
<view class="top">
<view class="header-photo">
2020-09-27 15:39:35 +08:00
<avatar :userName="userInfo.real_name" size="90"></avatar>
2020-09-17 20:01:50 +08:00
</view>
2020-09-27 15:39:35 +08:00
<view class="user-name">
{{userInfo.real_name}}
2020-09-17 20:01:50 +08:00
</view>
</view>
2020-09-23 18:53:25 +08:00
<view class="middle">
<view class="cu-item content">
<textarea v-model="userInfo.signature"
auto-height="true"
maxlength=2000
2020-09-27 15:39:35 +08:00
disabled="false"
2020-09-23 18:53:25 +08:00
></textarea>
</view>
2020-09-27 15:39:35 +08:00
<view class="other-info">
<view class="score" @tap="goPage('followList')">
关注{{userOtherInfo.followNumber}}
</view>
<view class="score" @tap="goPage('fansList')">
粉丝{{userOtherInfo.fansNumber}}
</view>
<view class="score">
积分{{userInfo.integral}}
</view>
</view>
2020-09-23 18:53:25 +08:00
</view>
2020-09-17 20:01:50 +08:00
<view class="bottom">
<view class="cu-list grid" :class="['col-' + gridCol,gridBorder?'':'no-border']">
<view class="cu-item"
v-for="(item,index) in cuIconList"
:key="index"
2020-09-27 15:39:35 +08:00
v-if="item.admin === 0"
2020-09-17 20:01:50 +08:00
@tap="goToPage(item)">
<view :class="['cuIcon-' + item.cuIcon,'text-' + item.color]">
2020-10-10 10:44:32 +08:00
<view class="cu-tag badge" v-if="item.badge > 0">
<block v-if="item.badge > 0">{{item.badge>99?'99+':item.badge}}</block>
</view>
2020-09-17 20:01:50 +08:00
</view>
<text>{{item.name}}</text>
</view>
</view>
</view>
2020-09-16 09:25:13 +08:00
</view>
</template>
<script>
2020-09-21 18:02:14 +08:00
import request from '@/util/request.js';
2020-09-23 18:53:25 +08:00
import { updateUserInfo } from "@/static/js/public.js";
2020-09-27 15:39:35 +08:00
import avatar from "@/pages/components/avatar/avatar.vue";
2020-09-16 09:25:13 +08:00
export default {
2020-09-27 15:39:35 +08:00
components: {
avatar
},
2020-09-16 09:25:13 +08:00
data() {
return {
2020-09-17 20:01:50 +08:00
gridCol: 3,
gridBorder: false,
cuIconList: [
{
cuIcon: 'favor',
color: 'orange',
name: '收藏',
2020-09-27 15:39:35 +08:00
admin: 0,
2020-10-10 10:44:32 +08:00
badge: 0,
2020-09-17 20:01:50 +08:00
code: 'collection'
},
{
cuIcon: 'list',
color: 'yellow',
name: '我的文章',
2020-09-27 15:39:35 +08:00
admin: 0,
2020-10-10 10:44:32 +08:00
badge: 0,
2020-09-17 20:01:50 +08:00
code: 'myArticle'
},
2020-12-19 12:13:27 +08:00
{
cuIcon: 'notice',
color: 'green',
name: '通知',
admin: 0,
badge: 0,
code: 'notice'
},
2020-09-17 20:01:50 +08:00
{
cuIcon: 'edit',
color: 'red',
name: '编辑信息',
2020-09-27 15:39:35 +08:00
admin: 0,
2020-10-10 10:44:32 +08:00
badge: 0,
2020-09-17 20:01:50 +08:00
code: 'personInfo'
},
{
2020-09-27 15:39:35 +08:00
cuIcon: 'newshot',
2020-09-17 20:01:50 +08:00
color: 'olive',
2020-09-27 15:39:35 +08:00
name: '文章管理',
admin: uni.getStorageSync("userInfo").user_type === "管理员" ? 0 : 1,
2020-10-10 10:44:32 +08:00
badge: 0,
2020-09-27 15:39:35 +08:00
code: 'articleManagement'
},
{
cuIcon: 'peoplelist',
color: 'cyan',
name: '人员管理',
admin: uni.getStorageSync("userInfo").user_type === "管理员" ? 0 : 1,
2020-10-10 10:44:32 +08:00
badge: 0,
2020-09-27 15:39:35 +08:00
code: 'peopleManagement'
},
2020-10-10 10:44:32 +08:00
{
cuIcon: 'friendadd',
2020-12-19 12:13:27 +08:00
color: 'mauve',
2020-10-10 10:44:32 +08:00
name: '注册管理',
admin: uni.getStorageSync("userInfo").user_type === "管理员" ? 0 : 1,
badge: 0,
code: 'registerManagement'
},
2020-09-27 15:39:35 +08:00
{
cuIcon: 'comment',
color: 'brown',
name: '帮助答复',
admin: uni.getStorageSync("userInfo").user_type === "管理员" ? 0 : 1,
2020-10-10 10:44:32 +08:00
badge: 0,
2020-09-27 15:39:35 +08:00
code: 'helpAnswer'
},
2020-12-19 12:13:27 +08:00
{
cuIcon: 'subscription',
color: 'black',
name: '群发消息',
admin: uni.getStorageSync("userInfo").user_type === "管理员" ? 0 : 1,
badge: 0,
code: 'massHair'
},
2020-09-27 15:39:35 +08:00
{
cuIcon: 'settings',
color: 'purple',
2020-09-17 20:01:50 +08:00
name: '设置',
2020-09-27 15:39:35 +08:00
admin: 0,
2020-10-10 10:44:32 +08:00
badge: 0,
2020-09-17 20:01:50 +08:00
code: 'settings'
},
{
cuIcon: 'questionfill',
2020-09-27 15:39:35 +08:00
color: 'pink',
2020-09-17 20:01:50 +08:00
name: '帮助',
2020-09-27 15:39:35 +08:00
admin: uni.getStorageSync("userInfo").user_type === "管理员" ? 1 : 0,
2020-10-10 10:44:32 +08:00
badge: 0,
2020-09-17 20:01:50 +08:00
code: 'help'
},
2020-09-27 15:39:35 +08:00
2020-09-21 18:02:14 +08:00
],
2020-09-23 18:53:25 +08:00
userInfo: {},
2020-10-10 10:44:32 +08:00
userOtherInfo: {},
//通知数量
noticeNumber: 0
2020-09-16 09:25:13 +08:00
}
},
2020-10-10 10:44:32 +08:00
/**
* 跳转通知页面
* @param {Object} e
*/
onNavigationBarButtonTap(e) {
uni.navigateTo({
url: '/pages/tabbar/my/notice/notice'
})
},
2020-09-21 18:06:14 +08:00
onShow() {
this.getUserInfo();
2020-10-10 10:44:32 +08:00
this.getMyPageNumber();
this.getNoticeData();
2020-09-23 18:53:25 +08:00
this.userInfo = uni.getStorageSync("userInfo");
let timesRun = 0;
let interval = setInterval(() => {
updateUserInfo();
timesRun += 1;
if(timesRun === 5){
clearInterval(interval);
}
}, 10000);
2020-09-21 18:06:14 +08:00
},
2020-09-16 09:25:13 +08:00
onLoad() {
2020-10-10 10:44:32 +08:00
2020-09-21 18:02:14 +08:00
},
onPullDownRefresh () {
2020-10-10 10:44:32 +08:00
this.getMyPageNumber();
this.getNoticeData();
2020-09-21 18:02:14 +08:00
this.getUserInfo();
},
mounted() {
2020-09-16 09:25:13 +08:00
},
methods: {
2020-10-10 10:44:32 +08:00
/**
* 获取通知
*/
getNoticeData() {
2020-12-19 12:13:27 +08:00
let _this = this;
2020-10-10 10:44:32 +08:00
request.post('/hs/getNoticeData',{
authorId: uni.getStorageSync("userInfo").user_id
}).then(res => {
this.noticeNumber = res.data.messageNoticeList.length + res.data.verifyNoticeList.length;
2020-12-19 12:13:27 +08:00
_this.cuIconList[2].badge = this.noticeNumber;
2020-10-10 10:44:32 +08:00
if(this.noticeNumber == 0) {
//隐藏
// #ifdef APP-PLUS
const pages = getCurrentPages();
const page = pages[pages.length - 1];
const currentWebview = page.$getAppWebview();
currentWebview.hideTitleNViewButtonRedDot({
index:0
});
// #endif
}else{
//显示
// #ifdef APP-PLUS
const pages = getCurrentPages();
const page = pages[pages.length - 1];
const currentWebview = page.$getAppWebview();
currentWebview.showTitleNViewButtonRedDot({
index:0
});
// #endif
}
console.log("通知",res);
},err => {
console.log("err",err);
})
},
/**
* 获取文章管理/帮助答复的未操作数字
*/
getMyPageNumber() {
let _this = this;
request.post("/admin/getMyPageNumber",{
}).then(res => {
console.log("获取文章管理/帮助答复的未操作数字",res);
2020-12-19 12:13:27 +08:00
_this.cuIconList[4].badge = res.data.articleManagementNumber;
_this.cuIconList[6].badge = res.data.registerManagementNumner;
_this.cuIconList[7].badge = res.data.helpAnswerNumber;
2020-10-10 10:44:32 +08:00
},err => {
console.log("err",err)
})
},
2020-09-21 18:02:14 +08:00
/**
* 跳转页面
* @param {Object} pageName 页面名称
*/
goPage(pageName) {
const FUNCTION_CODE = {
'followList': '/pages/tabbar/follow/follow-list',
'fansList': '/pages/tabbar/follow/fans-list',
}
uni.navigateTo({
url: `${FUNCTION_CODE[pageName]}`
})
},
/**
* 获取个人信息
*/
getUserInfo() {
request.post("/hs/getPersonalInfo",{
userId: uni.getStorageSync("userInfo").user_id,
releaseId: uni.getStorageSync("userInfo").user_id
}).then(res => {
uni.startPullDownRefresh();
console.log("个人信息",res);
this.userOtherInfo = res.data.personalInfo;
},err => {
console.log("err",err);
})
},
2020-09-17 20:01:50 +08:00
/**
* 跳转页面
* @param {Object} item
*/
goToPage(item) {
const FUNCTION_CODE = {
2020-09-27 15:39:35 +08:00
"collection": "/pages/tabbar/my/collection/collection",
"myArticle": "/pages/tabbar/my/my-article/my-article",
"personInfo": "/pages/tabbar/my/edit-info/edit-info",
"settings": "/pages/tabbar/my/settings/settings",
"help": "/pages/tabbar/my/help/help",
"articleManagement": "/pages/tabbar/my/article-management/article-management",
"peopleManagement": "/pages/tabbar/my/people-management/people-management",
2020-10-10 10:44:32 +08:00
"helpAnswer": "/pages/tabbar/my/help-answer/help-answer",
2020-12-19 12:13:27 +08:00
"registerManagement": "/pages/tabbar/my/register-management/register-management",
"notice": "/pages/tabbar/my/notice/notice",
"massHair": "/pages/tabbar/my/mass-hair/mass-hair"
2020-09-21 18:02:14 +08:00
};
2020-09-17 20:01:50 +08:00
uni.navigateTo({
url: `${FUNCTION_CODE[item.code]}`
})
}
2020-09-16 09:25:13 +08:00
}
}
</script>
2020-09-17 20:01:50 +08:00
<style scoped>
2020-09-27 15:39:35 +08:00
.max{
width: 180rpx;
height: 180rpx;
}
2020-09-23 18:53:25 +08:00
.signature{
font-size: 30rpx;
font-weight: bold;
padding-bottom: 10rpx;
}
.content {
background-color: #F1F1F1;
width: 100%;
padding: 20rpx;
border-radius: 10rpx;
}
textarea{
line-height: 1.5;
width: 100%;
height: 100%;
}
2020-09-17 20:01:50 +08:00
.bottom{
display: flex;
flex-flow: column;
}
.grade .r, .grade .l{
font-size: 14rpx;
padding: 5rpx;
border-radius: 5rpx;
}
.grade .l{
background-color: #9DC75F;
}
.grade .r{
background-color: #2D5315;
}
.user-info view{
2020-09-21 18:02:14 +08:00
padding: 10rpx 10rpx;
2020-09-17 20:01:50 +08:00
}
.user-info{
color: #FFFFFF;
display: flex;
2020-09-21 18:02:14 +08:00
flex-flow: nowrap;
2020-09-17 20:01:50 +08:00
justify-content: center;
border: 1rpx solid #b0b0b0;
border-radius: 10rpx;
2020-09-21 18:02:14 +08:00
width: 70%;
font-size: 32rpx;
2020-09-17 20:01:50 +08:00
background-color: #ced8d8;
}
.header-photo{
2020-09-27 15:39:35 +08:00
display: flex;
justify-content: center;
align-items: center;
}
.other-info{
display: flex;
justify-content: space-between;
padding: 20rpx 40rpx;
color: #9a9a9a;
font-size: 30rpx;
2020-09-17 20:01:50 +08:00
}
2020-09-23 18:53:25 +08:00
.middle{
2020-09-27 15:39:35 +08:00
padding: 40rpx 20rpx 0;
}
.user-name{
padding-top: 20rpx;
text-align: center;
2020-09-23 18:53:25 +08:00
}
2020-09-17 20:01:50 +08:00
.top{
display: flex;
2020-09-27 15:39:35 +08:00
flex-flow: column;
justify-content: center;
2020-09-17 20:01:50 +08:00
}
.page{
padding: 20rpx;
display: flex;
flex-flow: column;
background-color: #FFFFFF;
2020-09-16 09:25:13 +08:00
}
</style>