uni-app 7个人中心页开发
Posted 2019ab
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了uni-app 7个人中心页开发相关的知识,希望对你有一定的参考价值。
my.nvue 内容如下
<template>
<view class="page">
<free-nav-bar bgColor="bg-white">
<free-icon-button slot="right"><text class="iconfont font-md"></text></free-icon-button>
</free-nav-bar>
<free-list-item cover="../../../static/images/demo/demo6.jpg" title="呵呵" showRight coverSize="120">
<view class="flex flex-column">
<text class="text-dark font-lg font-weight-bold">呵呵</text>
<text class="text-light-muted font-md">微信号:VmzhbjzhV</text>
</view>
<view slot="right">
<text class="iconfont font-md text-light-muted"></text>
</view>
</free-list-item>
<free-divider></free-divider>
<free-list-item title="支付" showRight>
<text slot="icon" class="iconfont font-lg py-1"></text>
</free-list-item>
<free-divider></free-divider>
<free-list-item title="收藏" showRight>
<text slot="icon" class="iconfont font-lg py-1"></text>
</free-list-item>
<free-list-item title="相册" showRight>
<text slot="icon" class="iconfont font-lg py-1"></text>
</free-list-item>
<free-list-item title="表情" showRight>
<text slot="icon" class="iconfont font-lg py-1"></text>
</free-list-item>
<free-list-item title="设置" showRight>
<text slot="icon" class="iconfont font-lg py-1"></text>
</free-list-item>
</view>
</template>
<script>
import freeNavBar from "@/components/free-ui/free-nav-bar.vue";
import freeIconButton from "@/components/free-ui/free-icon-button.vue";
import freeListItem from "@/components/free-ui/free-list-item.vue";
import freeDivider from "@/components/free-ui/free-divider.vue";
export default {
components:{
freeNavBar,
freeIconButton,
freeListItem,
freeDivider
},
data() {
return {
}
},
methods: {
}
}
</script>
<style>
</style>
插件
free-list-item.vue
<template>
<view class="bg-white flex align-stretch" hover-class="bg-light" @click="$emit('click')">
<view class="flex align-center justify-center py-2 px-3">
<slot name="icon"></slot>
<image :src="cover" v-if="cover" style="width: 75rpx;height: 75rpx;" mode="widthFix" :style="coverStyle"></image>
</view>
<view class="flex-1 border-bottom flex align-center justify-between">
<slot>
<text class="font-md text-dark">{{title}}</text>
</slot>
<view class="flex align-center pr-3" v-if="showRight">
<slot name="right"></slot>
<!-- 右 -->
<text class="iconfont text-light-muted font-md" ></text>
</view>
</view>
</view>
</template>
<script>
export default{
props:{
// 封面
cover:{
type:String,
default:""
},
// 标题
title:{
type:String,
default:""
},
// 显示右边
showRight:{
type:Boolean,
default:false
},
// 封面大小
coverSize:{
type:[String,Number],
default:75
}
},
computed:{
coverStyle(){
return `width:${this.coverSize}rpx;height:${this.coverSize}rpx;`;
}
}
}
</script>
<style>
</style>
free-nav-bar.vue
<template>
<view>
<view :class="getClass">
<!-- 状态栏 -->
<view :style="'height:'+statusBarHeight+'px;'"></view>
<!-- 导航 -->
<view class="w-100 flex align-center justify-between" style="height: 90rpx;">
<!-- 左边 -->
<view class="flex align-center">
<!-- 标题 -->
<text v-if="title" class="font-md ml-3" >{{getTitle}}</text>
</view>
<!-- 右边 -->
<view class="flex align-center">
<slot name="right">
<free-icon-button @click="search"><text class="iconfont font-md"></text></free-icon-button>
<free-icon-button @click="openExtend"><text class="iconfont font-md"></text></free-icon-button>
</slot>
</view>
<!--\\ue6e3 \\ue682 -->
</view>
</view>
<!-- 站位 -->
<view v-if="fixed" :style="fixedStyle"></view>
<!-- 扩展菜单 -->
<free-popup ref="extend" maskColor bottom :bodyWidth="320" :bodyHeight="525" bodyBgColor="bg-dark" transformOrigin="right top">
<view class="flex flex-column" style="width:320rpx;height: 525rpx;">
<view v-for="(item,index) in menus" :key="index" class="flex-1 flex align-center" hover-class="bg-hover-dark" @click="clickEvent(item.event)">
<text class="pl-3 pr-2 iconfont font-md text-white">{{item.icon}}</text>
<text class="font-md text-white">{{item.name}}</text>
</view>
</view>
</free-popup>
</view>
</template>
<script>
import freeIconButton from './free-icon-button.vue';
import freePopup from './free-popup.vue';
export default {
components: {
freeIconButton,
freePopup
},
props: {
title: {
type: String,
default: ''
},
fixed:{
type:Boolean,
default:false
},
noreadnum:{
type:Number,
default:0
},
bgColor:{
type:String,
default:"bg-light"
}
},
data() {
return {
statusBarHeight: 0,
navBarHeight: 0,
menus:[
{
name:'发起群聊',
event:"",
icon:"\\ue633"
},
{
name:'添加好友',
event:"",
icon:"\\ue65d"
},
{
name:'扫一扫',
event:"",
icon:"\\ue614"
},
{
name:'收付款',
event:"",
icon:"\\ue66c"
},
{
name:'帮助与反馈',
event:"",
icon:"\\ue61c"
}
],
}
},
mounted() {
// 获取任务栏高度
// #ifdef APP-PLUS-NVUE
this.statusBarHeight = plus.navigator.getStatusbarHeight()
// #endif
this.navBarHeight = this.statusBarHeight + uni.upx2px(90)
},
computed: {
fixedStyle() {
return `height:${this.navBarHeight}px`;
},
getTitle(){
let noreadnum = this.noreadnum>0 ? '('+this.noreadnum+')' : '';
return this.title + noreadnum;
},
getClass(){
let fixed = this.fixed?"fixed-top":"";
return `${fixed} ${this.bgColor}`;
}
},
methods:{
openExtend(){
this.$refs.extend.show(uni.upx2px(415),uni.upx2px(150));
}
}
}
</script>
<style>
</style>
free-icon-button.vue
<template>
<view class="flex align-center justify-center"
hover-class="bg-hover-light" @click="$emit('click')"
style="height: 90rpx;width: 90rpx;">
<slot></slot>
</view>
</template>
<script>
export default {
props: {
icon: {
type: String,
default: ''
},
},
mounted() {
// #ifdef APP-PLUS-NVUE
// 加载公共图标库
const domModule = weex.requireModule('dom')
domModule.addRule('fontFace', {
'fontFamily': "iconfont",
'src': "url('/static/font_1365296_2ijcbdrmsg.ttf')"
});
// #endif
}
}
</script>
<style>
</style>
页面是酱紫的
感谢大家观看。我们下期再见。
以上是关于uni-app 7个人中心页开发的主要内容,如果未能解决你的问题,请参考以下文章