汇融云链2
This commit is contained in:
40
mallplusui-uniapp-app2/components/xiujun-evaluate/Readme.md
Normal file
40
mallplusui-uniapp-app2/components/xiujun-evaluate/Readme.md
Normal file
@@ -0,0 +1,40 @@
|
||||
### 评价 列表
|
||||
|
||||
评价列表组件,组件名:``uni-evaluate``,可预览图片
|
||||
|
||||
**使用方式:**
|
||||
|
||||
下载组件,在 ``script`` 中引用组件
|
||||
|
||||
```javascript
|
||||
import uniEvaluate from '../../components/xiujun-evaluate/uni-evaluate.vue';
|
||||
export default {
|
||||
components: {uniEvaluate}
|
||||
}
|
||||
```
|
||||
|
||||
用法
|
||||
|
||||
```html
|
||||
<uni-evaluate :list-data="列表数据" :rate="总评分"/>
|
||||
```
|
||||
|
||||
**组件属性说明:**
|
||||
|
||||
|属性名|类型|默认值 |说明|
|
||||
|---|----|---|---|
|
||||
|listData|Array|-|评价列表数据|
|
||||
|rate|Number|-|总评分|
|
||||
|isShowTotal|Boolean|true|是否显示总评价数量|
|
||||
|isShowIcon|Boolean|true|是否显示评价头图标|
|
||||
|
||||
**listData属性说明:**
|
||||
|
||||
|属性名|类型|默认值|说明|
|
||||
|---|----|---|---|
|
||||
|header_img|String|-|用户头像|
|
||||
|user_name|String| - |用户名|
|
||||
|rate|Number|-|评分|
|
||||
|create_time|String|-|发表评论时间|
|
||||
|content|String|-|评价内容文本|
|
||||
|imgs|Array|-|评价内容图片格式['图片地址1','图片地址2']|
|
||||
@@ -0,0 +1,26 @@
|
||||
@font-face {
|
||||
font-family: 'iconfont'; /* project id 1237225 */
|
||||
src: url('https://at.alicdn.com/t/font_1237225_y90nldmnpij.eot');
|
||||
src: url('https://at.alicdn.com/t/font_1237225_y90nldmnpij.eot?#iefix') format('embedded-opentype'),
|
||||
url('https://at.alicdn.com/t/font_1237225_y90nldmnpij.woff2') format('woff2'),
|
||||
url('https://at.alicdn.com/t/font_1237225_y90nldmnpij.woff') format('woff'),
|
||||
url('https://at.alicdn.com/t/font_1237225_y90nldmnpij.ttf') format('truetype'),
|
||||
url('https://at.alicdn.com/t/font_1237225_y90nldmnpij.svg#iconfont') format('svg');
|
||||
}
|
||||
|
||||
.iconfont {
|
||||
font-family: "iconfont" !important;
|
||||
font-size: 16px;
|
||||
font-style: normal;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.icon-pingjia-copy:before {
|
||||
content: "\e640";
|
||||
}
|
||||
|
||||
.icon-xingxing:before {
|
||||
content: "\e870";
|
||||
}
|
||||
|
||||
62
mallplusui-uniapp-app2/components/xiujun-evaluate/list.js
Normal file
62
mallplusui-uniapp-app2/components/xiujun-evaluate/list.js
Normal file
@@ -0,0 +1,62 @@
|
||||
//测试数据
|
||||
const listData = [{
|
||||
header_img: "http://cs.zhangkaixing.com/face/face_2.jpg",
|
||||
user_name: "测试1",
|
||||
rate:5,
|
||||
create_time: "2019-04-12",
|
||||
content: "好评",
|
||||
imgs:[
|
||||
'/com/face/face.jpg',
|
||||
'http://cs.zhangkaixing.com/face/p10.jpg',
|
||||
'http://cs.zhangkaixing.com/face/face_14.jpg',
|
||||
'http://cs.zhangkaixing.com/face/face.jpg',
|
||||
'http://cs.zhangkaixing.com/face/p10.jpg',
|
||||
]
|
||||
},
|
||||
{
|
||||
content: "中评",
|
||||
create_time: "2019-04-12",
|
||||
header_img: "http://cs.zhangkaixing.com/face/face_12.jpg",
|
||||
user_name: "测试2",
|
||||
rate:4,
|
||||
// imgs:[]
|
||||
},
|
||||
{
|
||||
content: "",
|
||||
create_time: "2019-04-12",
|
||||
header_img: "http://cs.zhangkaixing.com/face/face_15.jpg",
|
||||
user_name: "测试3",
|
||||
rate:2,
|
||||
// imgs:[]
|
||||
},{
|
||||
content: "好评",
|
||||
create_time: "2019-04-12",
|
||||
header_img: "http://cs.zhangkaixing.com/face/face_2.jpg",
|
||||
user_name: "测试1",
|
||||
rate:5,
|
||||
imgs:[
|
||||
'http://cs.zhangkaixing.com/face/face.jpg',
|
||||
'http://cs.zhangkaixing.com/face/p10.jpg',
|
||||
'http://cs.zhangkaixing.com/face/face_14.jpg',
|
||||
'http://cs.zhangkaixing.com/face/face.jpg',
|
||||
'http://cs.zhangkaixing.com/face/p10.jpg',
|
||||
]
|
||||
},
|
||||
{
|
||||
content: "中评",
|
||||
create_time: "2019-04-12",
|
||||
header_img: "http://cs.zhangkaixing.com/face/face_12.jpg",
|
||||
user_name: "测试2",
|
||||
rate:3.5,
|
||||
// imgs:[]
|
||||
},
|
||||
{
|
||||
content: "",
|
||||
create_time: "2019-04-12",
|
||||
header_img: "http://cs.zhangkaixing.com/face/face_15.jpg",
|
||||
user_name: "测试3",
|
||||
rate:2.3,
|
||||
// imgs:[]
|
||||
}]
|
||||
|
||||
export default listData
|
||||
@@ -0,0 +1,236 @@
|
||||
<!-- components/evaluate-components/index.wxml -->
|
||||
<template>
|
||||
<view class="evaluateBox">
|
||||
<view class="evaluate-header">
|
||||
<view class="title">
|
||||
<text v-if="isShowIcon" class="iconfont" style="color:#999"></text>
|
||||
<text v-if="isShowTotal" style="margin-left: 10upx;">评价 ({{ listData.length }})</text>
|
||||
</view>
|
||||
<view class="total">
|
||||
<view class="stars">
|
||||
<view class="stars-normal">
|
||||
<view class="box">
|
||||
<block v-for="i in 5" :key="i"><text class="iconfont"></text></block>
|
||||
</view>
|
||||
</view>
|
||||
<view class="stars-selected" :style="{ width: (rate / 5) * 100 + '%' }">
|
||||
<view class="box">
|
||||
<block v-for="j in 5" :key="j"><text class="iconfont"></text></block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<text>{{ rate }}{{ (rate * 10) % 10 == 0 ? '.0' : '' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="lists" v-if="listData.length > 0">
|
||||
<block v-for="(item, index_) in listData" :key="index_">
|
||||
<view class="item">
|
||||
<view class="icon"><image :src="item.header_img" mode="widthFix" style="width:100%" /></view>
|
||||
<view class="info">
|
||||
<view class="name-time">
|
||||
<text class="name">{{ item.user_name }}</text>
|
||||
<text class="time">{{ item.create_time }}</text>
|
||||
</view>
|
||||
<view class="stars">
|
||||
<view class="stars-normal">
|
||||
<view class="box">
|
||||
<block v-for="i_ in 5" :key="i_"><text class="iconfont"></text></block>
|
||||
</view>
|
||||
</view>
|
||||
<view class="stars-selected" :style="{ width: (item.rate / 5) * 100 + '%' }">
|
||||
<view class="box">
|
||||
<block v-for="j_ in 5" :key="j_"><text class="iconfont"></text></block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="evaluate-content">
|
||||
<text>{{ item.content || '用户暂未评价' }}</text>
|
||||
<view class="imgs" v-if="item.imgs">
|
||||
<block v-for="(imgurl, index) in item.imgs" :key="index">
|
||||
<view class="imgs-box"><image :src="imgurl" mode="widthFix" style="width: 100%;" @click="previewImg(imgurl,item.imgs)"></image></view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
<view class="no-lists" v-else>暂无评论</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
//数据模拟
|
||||
import data from './list.js';
|
||||
export default {
|
||||
props: {
|
||||
//评价列表数据
|
||||
listData: {
|
||||
type: Array,
|
||||
default: data
|
||||
},
|
||||
//是否显示总评价数量
|
||||
isShowTotal: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
//是否显示评价前面的图标
|
||||
isShowIcon: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
//总评分
|
||||
rate: {
|
||||
type: Number,
|
||||
default: 4.6
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {}
|
||||
},
|
||||
methods: {
|
||||
previewImg(src,urls){
|
||||
uni.previewImage({
|
||||
current:src,
|
||||
urls
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
@import './iconfont.css';
|
||||
.evaluateBox {
|
||||
width: 100%;
|
||||
margin-bottom: 120upx;
|
||||
}
|
||||
|
||||
.evaluate-header {
|
||||
width: 100%;
|
||||
height: 80upx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 20upx;
|
||||
align-items: center;
|
||||
margin-bottom: 12upx;
|
||||
box-sizing: border-box;
|
||||
border-bottom: 1upx solid #e5e5e5;
|
||||
}
|
||||
|
||||
.evaluateBox .title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
color: #000000;
|
||||
font-size: 30upx;
|
||||
}
|
||||
|
||||
.total {
|
||||
/* flex: 1; */
|
||||
height: 100%;
|
||||
font-size: 30upx;
|
||||
color: #d76d9d;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.stars {
|
||||
width: 180upx;
|
||||
height: 36upx;
|
||||
position: relative;
|
||||
}
|
||||
.stars .box {
|
||||
width: 180upx;
|
||||
}
|
||||
.stars-normal {
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
color: #ccc;
|
||||
}
|
||||
.stars-selected {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
color: #fde16d;
|
||||
overflow: hidden;
|
||||
}
|
||||
.stars-selected .iconfont,
|
||||
.stars-normal .iconfont {
|
||||
font-size: 36upx;
|
||||
}
|
||||
|
||||
.lists .item {
|
||||
padding: 20upx;
|
||||
display: flex;
|
||||
/* height: auto; */
|
||||
/* align-items: center; */
|
||||
font-size: 22upx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.lists .item .icon {
|
||||
width: 60upx;
|
||||
height: 60upx;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
margin-right: 26upx;
|
||||
/* align-self: flex-start; */
|
||||
}
|
||||
|
||||
.lists .item .info {
|
||||
flex: 1;
|
||||
font-size: 26upx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.info .name-time {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding-bottom: 6upx;
|
||||
}
|
||||
.lists .info .stars {
|
||||
width: 140upx;
|
||||
}
|
||||
|
||||
.info .stars-normal .iconfont,
|
||||
.info .stars-selected .iconfont {
|
||||
font-size: 28upx;
|
||||
}
|
||||
|
||||
.info .stars .box {
|
||||
width: 140upx;
|
||||
}
|
||||
.lists .info .evaluate-content {
|
||||
color: #000;
|
||||
font-size: 28upx;
|
||||
text-align: left;
|
||||
padding-top: 6upx;
|
||||
}
|
||||
.info .evaluate-content .imgs {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
padding-top: 6upx;
|
||||
}
|
||||
.evaluate-content .imgs .imgs-box {
|
||||
width: 25%;
|
||||
padding-right: 10upx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
/* .evaluate-content .imgs .imgs-box:nth-child(4n+1){
|
||||
padding-left: 0;
|
||||
}
|
||||
.evaluate-content .imgs .imgs-box:nth-child(4n){
|
||||
padding-right: 0;
|
||||
} */
|
||||
.no-lists {
|
||||
padding: 20upx 0;
|
||||
text-align: center;
|
||||
font-size: 24upx;
|
||||
color: #666;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user