ucenter.vue 5.4 KB
Newer Older
L
213  
linju 已提交
1 2
<template>
	<view class="center">
L
213  
linju 已提交
3
		<view class="userInfo" @click="goLogin" :hover-class="!login ? 'logo-hover' : ''">
L
213  
linju 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
			<image class="logo-img" :src="login ? (userInfo.avatar || avatarUrl) :avatarUrl"></image>
			<view class="logo-title">
				<text class="uer-name">Hi,{{login ? userInfo.username : '您未登录'}}</text>
				<text class="go-login-navigat-arrow navigat-arrow" v-if="!login">&#xe65e;</text>
			</view>
		</view>
		<uni-grid class="grid" :column="5" :showBorder="false" :square="true">
			<uni-grid-item class="item" v-for="({text,icon},index) in gridList" @click.native="tapGrid(index)">
				<uni-icons class="icon" color="#5d5e64" :type="icon" size="28"></uni-icons>
				<text class="text">{{text}}</text>
			</uni-grid-item>
		</uni-grid>
		<uni-list class="center-list" v-for="(sublist , index) in ucenterList">
			<uni-list-item v-for="item in sublist"
				:title="item.title"
				link :rightText="item.rightText"
				:clickable="true"
				:to="item.to"
				@click="ucenterListClick(item)"
			></uni-list-item>
芊里 已提交
24
		</uni-list>
L
213  
linju 已提交
25 26 27 28 29 30 31 32 33 34 35 36
	</view>
</template>

<script>
	import {
		mapGetters,
		mapMutations
	} from 'vuex';
	import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
	export default {
		data() {
			return {
芊里 已提交
37
				avatarUrl: '/static/uni-center/logo.png',
L
213  
linju 已提交
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
				gridList: [{
						"text": "文字1",
						"icon": "chat"
					},
					{
						"text": "文字2",
						"icon": "cloud-upload"
					},
					{
						"text": "文字3",
						"icon": "contact"
					},
					{
						"text": "文字4",
						"icon": "download"
					},
					{
						"text": "文字5",
						"icon": "paperplane"
					}
				],
				ucenterList: [
					[{
						title: '阅读过的文章',
芊里 已提交
62
						to: '/pages/ucenter/agree-list/agree-list'
L
213  
linju 已提交
63 64
					}, {
						title: '我的积分',
芊里 已提交
65
						to: '/pages/ucenter/agree-list/agree-list'
L
213  
linju 已提交
66 67 68
					}],
					[{
							title: '政策与协议',
芊里 已提交
69
							to: '/pages/ucenter/agree-list/agree-list'
L
213  
linju 已提交
70 71
						}, {
							title: '关于',
芊里 已提交
72
							to: '/pages/ucenter/about/about'
L
213  
linju 已提交
73 74
						},
						//#ifdef APP-PLUS
L
12  
linju 已提交
75 76 77 78 79
						{
							title: '检查更新',
							rightText: `V${getApp().appVersion.finall.version}_${getApp().appVersion.finall.versionCode}`,
							event:'checkVersion'
						}
L
213  
linju 已提交
80 81 82 83
						//#endif
					],
					[{
						title: '反馈',
芊里 已提交
84
						to: '/pages/ucenter/uni-feedback/uni-feedback'
L
213  
linju 已提交
85 86
					}, {
						title: '设置',
芊里 已提交
87
						to: '/pages/ucenter/settings/settings'
L
213  
linju 已提交
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
					}]
				]
			}
		},
		computed: {
			...mapGetters({
				userInfo: 'user/info',
				login: 'user/hasLogin'
			})
		},
		onReady() {

		},
		methods: {
			...mapMutations({
				logout: 'user/logout'
			}),
			/**
			 * 个人中心项目列表点击事件
			 */
			ucenterListClick(item) {
				if (!item.to && item.event) {
					this[item.event]();
				}
			},
			checkVersion() {
				checkUpdate();
			},
芊里 已提交
116
			goLogin() {
L
123  
linju 已提交
117 118 119
				// uni.navigateTo({
				// 	url: './edit/edit'
				// })
芊里 已提交
120
				
L
213  
linju 已提交
121 122 123 124 125 126 127 128 129 130 131
				if (!this.login) {
					console.log('点击前往登录');
					uni.navigateTo({
						url: '/uni_modules/uni-login-page/pages/index/index'
					});
				} else {
					console.log('点击编辑信息');
					uni.navigateTo({
						url: './edit/edit'
					})
				}
芊里 已提交
132
			},
L
213  
linju 已提交
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
			tapGrid(index){
				uni.showToast({
					title: '你点击了,第'+index+'',
					icon: 'none'
				});
			}
		}
	}
</script>

<style>
	/* #ifndef APP-PLUS-NVUE */
	@font-face {
		font-family: texticons;
		font-weight: normal;
		font-style: normal;
		src: url('~@/static/text-icon.ttf') format('truetype');
	}

	page {
		background-color: #f8f8f8;
	}

	/* #endif*/

	/* 解决头条小程序字体图标不显示问题,因为头条运行时自动插入了span标签,且有全局字体 */
	/* #ifdef MP-TOUTIAO */
	text :not(view) {
		font-family: texticons;
	}

	/* #endif */

	.center {
		flex: 1;
		flex-direction: column;
		background-color: #f8f8f8;
	}

L
213  
linju 已提交
172 173 174 175
	.userInfo {
		width: 750rpx;
		padding: 20rpx;
		padding-top:50px;
L
213  
linju 已提交
176
		background-color: #2F85FC;
L
213  
linju 已提交
177
		flex-direction: column;
L
213  
linju 已提交
178 179 180 181 182 183 184 185
		align-items: center;
	}

	.logo-hover {
		opacity: 0.8;
	}

	.logo-img {
L
213  
linju 已提交
186 187 188 189
		width: 150rpx;
		height: 150rpx;
		border-radius: 150rpx;
		border: solid 1px #FFFFFF;
L
213  
linju 已提交
190 191 192
	}

	.logo-title {
L
213  
linju 已提交
193
		height: 150rpx;
L
213  
linju 已提交
194 195 196 197
		flex: 1;
		align-items: center;
		justify-content: space-between;
		flex-direction: row;
L
213  
linju 已提交
198
		margin-left: 20rpx;
L
213  
linju 已提交
199 200 201
	}

	.uer-name {
L
213  
linju 已提交
202 203 204
		height: 60rpx;
		line-height: 60rpx;
		font-size: 38rpx;
L
213  
linju 已提交
205 206 207 208
		color: #FFFFFF;
	}

	.go-login-navigat-arrow {
L
213  
linju 已提交
209
		font-size: 38rpx;
L
213  
linju 已提交
210 211 212 213
		color: #FFFFFF;
	}

	.navigat-arrow {
L
213  
linju 已提交
214 215 216 217 218
		height: 90rpx;
		width: 40rpx;
		line-height: 90rpx;
		font-size: 34rpx;
		color: #FFFFFF;
L
213  
linju 已提交
219 220 221 222
		text-align: right;
		font-family: texticons;
	}

芊里 已提交
223
	.center-list {
L
213  
linju 已提交
224 225 226 227 228
		margin-bottom: 30rpx;
		background-color: #f9f9f9;
	}

	.center-list-cell {
芊里 已提交
229
		width: 750rpx;
L
213  
linju 已提交
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
		background-color: #007AFF;
		height: 40rpx;
	}
	
	.grid{
		background-color: #FFFFFF;
		margin:25rpx 0;
	}
	.uni-grid .text {
		font-size: 26rpx;
		color: #817f82;
	}

	.uni-grid .item /deep/ .uni-grid-item__box {
		justify-content: center;
		align-items: center;
L
213  
linju 已提交
246 247 248 249 250 251 252 253 254 255 256 257 258
	}
	

/*修改边线粗细示例*/
/* #ifndef APP-NVUE */
	.center-list /deep/ .uni-list--border:after,
	.center-list /deep/ .uni-list--border-top ,
	.center-list /deep/ .uni-list--border-bottom{
		-webkit-transform: scaleY(0.2);
		transform: scaleY(0.2);
	}
/* #endif */
	
芊里 已提交
259
</style>