1、图片下加文字
效果图:
template代码
<view class="view-box">
<image class="icon" src="../../static/logo.png"></image>
<text class="title">收藏</text>
</view>
style代码
.view-box {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: #fff;
}
.icon {
width: 7vw;
height: 7vw;
}
.title {
margin-top: 10rpx;
font-size: 20upx;
/* color: #8f8f94; */
}
2、卡片、阴影
a、效果图:
style代码
.box {
width: 96%;
/* padding: 0 3%; */
height: 22vw;
background-color: #fefefe;
border-radius: 24upx;
/* 阴影 */
box-shadow: 0 0 20upx rgba(0, 0, 0, 0.15);
margin: 40upx 2% 0upx 2%;
display: flex;
align-items: center;
justify-content: center;
}
阴影说明:
b、复杂结构,效果图:
template代码
<view class="box">
<view class="label" v-for="(row,index) in orderTypeLise" :key="row.name" hover-class="hover" @tap="toOrderType(index)">
<view class="icon">
<view class="badge" v-if="row.badge>0">{{row.badge}}</view>
<image :src="'../../static/'+row.icon"></image>
</view>
<!-- <text>{{row.name}}</text> -->
{{row.name}}
</view>
</view>
script代码
data() {
return {
orderTypeLise: [
//name-标题 icon-图标 badge-角标
{
name: '待付款',
icon: 'l1.png',
badge: 1
},
{
name: '待发货',
icon: 'l2.png',
badge: 2
},
{
name: '待收货',
icon: 'l3.png',
badge: 6
},
{
name: '待评价',
icon: 'l4.png',
badge: 9
},
{
name: '退换货',
icon: 'l5.png',
badge: 0
}
],
},
style代码 (需要在style里加入 lang=“scss” )
//注意:需要<style lang="scss">
// 圆角长框
.box {
width: 96%;
height: 22vw;
background-color: #fefefe;
border-radius: 24upx;
/* 阴影 */
box-shadow: 0 0 20upx rgba(0, 0, 0, 0.15);
margin: 40upx 2% 0upx 2%;
display: flex;
align-items: center;
justify-content: center;
// 包含图片,数字气泡,图标的view
.label {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 16vw;
color: #666666;
font-size: 26upx;
.icon {
position: relative;
width: 7vw;
height: 7vw;
margin: 0 1vw 2vw 1vw;
// 数字气泡
.badge {
position: absolute;
width: 4vw;
height: 4vw;
background-color: #ec6d2c;
top: -1vw;
right: -1vw;
border-radius: 100%;
font-size: 20upx;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
z-index: 10;
}
// 文字上的图片
image {
width: 7vw;
height: 7vw;
z-index: 9;
}
}
}
}
3、图标–文字–箭头
效果图:
template代码
<view class='container_4'>
<view class='middle-item' hover-stay-time="150">
<image class="image_tupian_1" src="../../static/point.png"></image>
<text class='text_2'>设置</text>
<image class="image-jiantou" src="../../static/to.png"></image>
</view>
<view class="view_line"></view>
<view class='middle-item' hover-class="opcity" hover-stay-time="150">
<image class="image_tupian_1" src="../../static/choujiang.png"></image>
<text class='text_2'>个人信息</text>
<image class="image-jiantou" src="../../static/to.png"></image>
</view>
<view class="view_line"></view>
<view class='middle-item' hover-class="opcity" hover-stay-time="150">
<image class="image_tupian_1" src="../../static/mingxi.png"></image>
<text class='text_2'>消费记录</text>
<image class="image-jiantou" src="../../static/to.png"></image>
</view>
</view>
style代码
.container_4 {
width: 96%;
height: 320rpx;
display: flex;
flex-direction: column;
border-radius: 15rpx;
background-color: #FFFFFF;
margin: 20rpx 2% 100rpx 2%;
}
.middle-item {
height: 100%;
display: flex;
flex-direction: row;
align-items: center;
}
.image_tupian_1 {
display: flex;
width: 50rpx;
height: 50rpx;
margin: 0rpx 20rpx 0rpx 40rpx;
}
.image-jiantou {
width: 32rpx;
height: 32rpx;
position: absolute;
/* 要约束所在位置的子元素的位置要设置成绝对 */
right: 30rpx;
/* 靠右调节 */
margin-right: 35rpx
}
/* 线 */
.view_line {
width: 90%;
height: 5rpx;
background: #f3f3f3;
/* margin: 0rxp 5% 0rxp 5%; */
margin: 0 auto;
text-align: center;
}
4、个人中心
代码
<template>
<view class="content">
<!-- 第一部分 -->
<view class="header" v-bind:class="{'status':isH5Plus}">
<view class="userinfo">
<view class="face">
<image :src="userinfo.face"></image>
</view>
<view class="info">
<view class="username">{{userinfo.username}}</view>
<view class="integral">积分:{{userinfo.integral}}</view>
</view>
</view>
<view class="setting">
<image src="../../static/setting.png"></image>
</view>
</view>
<!-- 第二部分 -->
<view class="container_2">
<view class="box">
<view class="label" v-for="(row,index) in orderTypeLise" :key="row.name" hover-class="hover" @tap="toOrderType(index)">
<view class="icon">
<view class="badge" v-if="row.badge>0">{{row.badge}}</view>
<image :src="'../../static/'+row.icon"></image>
</view>
<!-- <text>{{row.name}}</text> -->
{{row.name}}
</view>
</view>
</view>
<!-- 第三部分 -->
<view class='container_4'>
<view class='middle-item' hover-stay-time="150">
<image class="image_tupian_1" src="../../static/point.png"></image>
<text class='text_2' style="color: #555555;">设置</text>
<image class="image-jiantou" src="../../static/to.png"></image>
</view>
<view class="view_line"></view>
<view class='middle-item' hover-class="opcity" hover-stay-time="150">
<image class="image_tupian_1" src="../../static/choujiang.png"></image>
<text class='text_2' style="color: #555555;">个人信息</text>
<image class="image-jiantou" src="../../static/to.png"></image>
</view>
<view class="view_line"></view>
<view class='middle-item' hover-class="opcity" hover-stay-time="150">
<image class="image_tupian_1" src="../../static/mingxi.png"></image>
<text class='text_2' style="color: #555555;">消费记录</text>
<image class="image-jiantou" src="../../static/to.png"></image>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
//#ifdef APP-PLUS
isH5Plus: true,
//#endif
//#ifndef APP-PLUS
isH5Plus: false,
//#endif
userinfo: {},
orderTypeLise: [
//name-标题 icon-图标 badge-角标
{
name: '待付款',
icon: 'l1.png',
badge: 1
},
{
name: '待发货',
icon: 'l2.png',
badge: 3
},
{
name: '待收货',
icon: 'l3.png',
badge: 5
},
{
name: '待评价',
icon: 'l4.png',
badge: 7
},
{
name: '退换货',
icon: 'l5.png',
badge: 0
}
],
}
},
onLoad() {
//加载
this.init();
},
methods: {
init() {
//用户信息
this.userinfo = {
face: '../../static/face.jpg',
username: "VIP管理员",
integral: "2125"
}
},
//用户点击订单类型
toOrderType(index) {
uni.showToast({
title: this.orderTypeLise[index].name
});
},
//用户点击列表项
// toPage(list_i, li_i) {
// uni.showToast({
// title: this.severList[list_i][li_i].name
// });
// }
}
}
</script>
<style lang="scss">
page {
width: 100%;
height: 100%;
}
.content {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
// justify-content: center;
background-color: #e9e9ef;
}
/* 第一部分 */
.header {
background-color: #76cee1;
width: 92%;
height: 30vw;
padding: 0 4%;
display: flex;
align-items: center;
.userinfo {
width: 90%;
display: flex;
.face {
flex-shrink: 0;
width: 15vw;
height: 15vw;
image {
width: 100%;
height: 100%;
border-radius: 100%
}
}
.info {
display: flex;
flex-flow: wrap;
padding-left: 30upx;
.username {
width: 100%;
color: #fff;
font-size: 40upx
}
.integral {
display: flex;
align-items: center;
padding: 0 20upx;
height: 40upx;
color: #fff;
background-color: rgba(0, 0, 0, 0.1);
border-radius: 20upx;
font-size: 24upx
}
}
}
.setting {
flex-shrink: 0;
width: 6vw;
height: 6vw;
image {
width: 100%;
height: 100%
}
}
}
/* 第二部分 */
.container_2 {
// 改变这里看效果,可以知道布局
background-color: #76cee1;
width: 100%;
height: 11vw;
// padding: 0 2%;
margin-bottom: calc(11vw + 20upx);
display: flex;
align-items: flex-start;
// 弯曲的弧度,可以改变100%的数值来看效果
border-radius: 0 0 40rpx 40rpx;
// 圆角长框
.box {
width: 96%;
height: 22vw;
background-color: #fefefe;
border-radius: 24upx;
/* 阴影 */
box-shadow: 0 0 20upx rgba(0, 0, 0, 0.15);
margin: 0upx 2% 0upx 2%;
display: flex;
align-items: center;
justify-content: center;
// 包含图片,数字气泡,图标的view
.label {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 16vw;
color: #666666;
font-size: 26upx;
.icon {
position: relative;
width: 7vw;
height: 7vw;
margin: 0 1vw 2vw 1vw;
// 数字气泡
.badge {
position: absolute;
width: 4vw;
height: 4vw;
background-color: #ec6d2c;
top: -1vw;
right: -1vw;
border-radius: 100%;
font-size: 20upx;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
z-index: 10;
}
// 文字上的图片
image {
width: 7vw;
height: 7vw;
z-index: 9;
}
}
}
}
}
/* 第三部分 */
.container_4 {
width: 96%;
height: 320rpx;
display: flex;
flex-direction: column;
border-radius: 15rpx;
background-color: #FFFFFF;
margin: 0rpx 2% 100rpx 2%;
}
.middle-item {
height: 100%;
display: flex;
flex-direction: row;
align-items: center;
}
.image_tupian_1 {
display: flex;
width: 50rpx;
height: 50rpx;
margin: 0rpx 20rpx 0rpx 40rpx;
}
.image-jiantou {
width: 32rpx;
height: 32rpx;
position: absolute;
/* 要约束所在位置的子元素的位置要设置成绝对 */
right: 30rpx;
/* 靠右调节 */
margin-right: 35rpx
}
/* 线 */
.view_line {
width: 90%;
height: 5rpx;
background: #f3f3f3;
/* margin: 0rxp 5% 0rxp 5%; */
margin: 0 auto;
text-align: center;
}
</style>
里面的图标我就不放出来了,大家到网上下载自己喜欢的