|
@@ -12,18 +12,26 @@
|
|
|
<view class="evaluate-area">
|
|
<view class="evaluate-area">
|
|
|
<view class="padding-lr padding-top bg-main">
|
|
<view class="padding-lr padding-top bg-main">
|
|
|
<view class="eva-box dflex-s padding-bottom-lg" v-for="(item, index) in evaluateDatas" :key="index">
|
|
<view class="eva-box dflex-s padding-bottom-lg" v-for="(item, index) in evaluateDatas" :key="index">
|
|
|
- <image class="portrait border-radius-c" :src="item.member_headimg"></image>
|
|
|
|
|
|
|
+ <image class="portrait border-radius-c" :src="item.userImg"></image>
|
|
|
<view class="right-area flex1 padding-left-sm">
|
|
<view class="right-area flex1 padding-left-sm">
|
|
|
<view class="dflex-b ft-dark">
|
|
<view class="dflex-b ft-dark">
|
|
|
<view class="dflex">
|
|
<view class="dflex">
|
|
|
- <text class="name margin-right">{{ item.member_name }}</text>
|
|
|
|
|
- <use-rate :value="item.review_cnt" disabled></use-rate>
|
|
|
|
|
|
|
+ <text class="name margin-right">{{ item.createBy }}</text>
|
|
|
|
|
+ <use-rate :value="item.reviewCnt" disabled></use-rate>
|
|
|
</view>
|
|
</view>
|
|
|
- <text class="time fs-xs">{{ $api.format(item.create_time, 'yyyy-MM-dd') }}</text>
|
|
|
|
|
|
|
+ <text class="time fs-xs">{{ $api.format(item.createTime, 'yyyy-MM-dd') }}</text>
|
|
|
</view>
|
|
</view>
|
|
|
- <view class="fs-sm ft-main padding-top-xs padding-bottom-sm">{{ item.review_content }}</view>
|
|
|
|
|
|
|
+ <view class="fs-sm ft-main padding-top-xs padding-bottom-sm">{{ item.reviewContent }}</view>
|
|
|
<view class="dflex dflex-wrap-w">
|
|
<view class="dflex dflex-wrap-w">
|
|
|
- <image v-for="(img, i) in item.review_imgs" :src="img" :key="i" mode="widthFix" class="" @click="preview(item.imgs, img)"></image>
|
|
|
|
|
|
|
+ <image
|
|
|
|
|
+ class="border-radius-xs"
|
|
|
|
|
+ v-if="item.reviewImgs.indexOf(',') != -1"
|
|
|
|
|
+ mode="aspectFill"
|
|
|
|
|
+ :lazy-load="true"
|
|
|
|
|
+ :src="item.reviewImgs.substring(0, item.reviewImgs.indexOf(','))"
|
|
|
|
|
+ @click="preview(item.reviewImgs.substring(0, item.reviewImgs.indexOf(',')))"
|
|
|
|
|
+ ></image>
|
|
|
|
|
+ <image class="border-radius-xs" v-else mode="aspectFill" :lazy-load="true" :src="item.reviewImgs" @click="preview(item.reviewImgs)"></image>
|
|
|
</view>
|
|
</view>
|
|
|
<view class="">
|
|
<view class="">
|
|
|
<text class="fs-xs ft-dark">{{ item.goods_type || '套餐1' }}</text>
|
|
<text class="fs-xs ft-dark">{{ item.goods_type || '套餐1' }}</text>
|
|
@@ -35,11 +43,17 @@
|
|
|
</view>
|
|
</view>
|
|
|
</template>
|
|
</template>
|
|
|
<script>
|
|
<script>
|
|
|
|
|
+import {pingjia } from '../../utils/api_goods.js'
|
|
|
export default {
|
|
export default {
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
// 评价状态
|
|
// 评价状态
|
|
|
- stateDatas: [],
|
|
|
|
|
|
|
+ stateDatas: [
|
|
|
|
|
+ {name:'全部',cnt:''},
|
|
|
|
|
+ {name:'好评',cnt:''},
|
|
|
|
|
+ {name:'中评',cnt:''},
|
|
|
|
|
+ {name:'差评',cnt:''},
|
|
|
|
|
+ ],
|
|
|
// 评价数据
|
|
// 评价数据
|
|
|
evaluateDatas: [],
|
|
evaluateDatas: [],
|
|
|
// 商品ID
|
|
// 商品ID
|
|
@@ -55,54 +69,90 @@ export default {
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
loadData() {
|
|
loadData() {
|
|
|
- const $ = this.$dbcmd.aggregate;
|
|
|
|
|
- this.$db['usemall-goods-comment']
|
|
|
|
|
- .collection()
|
|
|
|
|
- .aggregate()
|
|
|
|
|
- .match({
|
|
|
|
|
- goods_id: $.eq(this.goods_id),
|
|
|
|
|
- state: '显示'
|
|
|
|
|
- })
|
|
|
|
|
- .group({
|
|
|
|
|
- _id: '$review_type',
|
|
|
|
|
- num: $.sum(1)
|
|
|
|
|
- })
|
|
|
|
|
- .end()
|
|
|
|
|
- .then(res => {
|
|
|
|
|
- let __stateDatas = [];
|
|
|
|
|
- let total = 0;
|
|
|
|
|
- res.result.data.forEach(x => {
|
|
|
|
|
- __stateDatas.push({ name: x._id, cnt: x.num });
|
|
|
|
|
- total += x.num;
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ this.stateDatas[0].cnt=0
|
|
|
|
|
+ this.stateDatas[1].cnt=0
|
|
|
|
|
+ this.stateDatas[2].cnt=0
|
|
|
|
|
+ this.stateDatas[3].cnt=0
|
|
|
|
|
+ this.evaluateDatas=[]
|
|
|
|
|
+ if(this.state=='全部'){
|
|
|
|
|
+ var type=''
|
|
|
|
|
+ }else if(this.state=='好评'){
|
|
|
|
|
+ var type='3'
|
|
|
|
|
+ }else if(this.state=='中评'){
|
|
|
|
|
+ var type='2'
|
|
|
|
|
+ }else if(this.state=='差评'){
|
|
|
|
|
+ var type='1'
|
|
|
|
|
+ }
|
|
|
|
|
+ //商品评价
|
|
|
|
|
+ var data = '?goodsId=' + this.goods_id+'&reviewType='+type
|
|
|
|
|
+ pingjia(data).then((res) => {
|
|
|
|
|
+ console.log('评价', res)
|
|
|
|
|
+ if (res.success) {
|
|
|
|
|
+ // 商品评价
|
|
|
|
|
+ this.evaluateDatas = res.data.list
|
|
|
|
|
+ if (res.data.evaluate_cnt) this.evaluateTitle = `评价(${res.data.evaluate_cnt})`
|
|
|
|
|
+ this.stateDatas[0].cnt=this.evaluateDatas.length
|
|
|
|
|
+ for(var i=0;i<this.evaluateDatas.length;i++){
|
|
|
|
|
+ if(this.evaluateDatas[i].reviewType=='3'){
|
|
|
|
|
+ this.stateDatas[1].cnt++
|
|
|
|
|
+ }else if(this.evaluateDatas[i].reviewType=='2'){
|
|
|
|
|
+ this.stateDatas[2].cnt++
|
|
|
|
|
+ }else if(this.evaluateDatas[i].reviewType=='1'){
|
|
|
|
|
+ this.stateDatas[3].cnt++
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ // const $ = this.$dbcmd.aggregate;
|
|
|
|
|
+ // this.$db['usemall-goods-comment']
|
|
|
|
|
+ // .collection()
|
|
|
|
|
+ // .aggregate()
|
|
|
|
|
+ // .match({
|
|
|
|
|
+ // goods_id: $.eq(this.goods_id),
|
|
|
|
|
+ // state: '显示'
|
|
|
|
|
+ // })
|
|
|
|
|
+ // .group({
|
|
|
|
|
+ // _id: '$review_type',
|
|
|
|
|
+ // num: $.sum(1)
|
|
|
|
|
+ // })
|
|
|
|
|
+ // .end()
|
|
|
|
|
+ // .then(res => {
|
|
|
|
|
+ // let __stateDatas = [];
|
|
|
|
|
+ // let total = 0;
|
|
|
|
|
+ // res.result.data.forEach(x => {
|
|
|
|
|
+ // __stateDatas.push({ name: x._id, cnt: x.num });
|
|
|
|
|
+ // total += x.num;
|
|
|
|
|
+ // });
|
|
|
|
|
|
|
|
- this.stateDatas = [{ name: '全部', cnt: total }, ...__stateDatas];
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ // this.stateDatas = [{ name: '全部', cnt: total }, ...__stateDatas];
|
|
|
|
|
+ // });
|
|
|
|
|
|
|
|
- this.$db['usemall-goods-comment']
|
|
|
|
|
- .where({
|
|
|
|
|
- goods_id: this.goods_id,
|
|
|
|
|
- state: '显示'
|
|
|
|
|
- })
|
|
|
|
|
- .whereif(this.state != '全部', { review_type: this.state })
|
|
|
|
|
- .tolist({ rows: 30, orderby: 'create_time desc' })
|
|
|
|
|
- .then(res => {
|
|
|
|
|
- if (res.code === 200) {
|
|
|
|
|
- this.evaluateDatas = res.datas;
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ // this.$db['usemall-goods-comment']
|
|
|
|
|
+ // .where({
|
|
|
|
|
+ // goods_id: this.goods_id,
|
|
|
|
|
+ // state: '显示'
|
|
|
|
|
+ // })
|
|
|
|
|
+ // .whereif(this.state != '全部', { review_type: this.state })
|
|
|
|
|
+ // .tolist({ rows: 30, orderby: 'create_time desc' })
|
|
|
|
|
+ // .then(res => {
|
|
|
|
|
+ // if (res.code === 200) {
|
|
|
|
|
+ // this.evaluateDatas = res.datas;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // });
|
|
|
},
|
|
},
|
|
|
change(options) {
|
|
change(options) {
|
|
|
this.state = options.name;
|
|
this.state = options.name;
|
|
|
|
|
|
|
|
this.loadData();
|
|
this.loadData();
|
|
|
},
|
|
},
|
|
|
- preview(imgs, cur) {
|
|
|
|
|
|
|
+ preview(imgs) {
|
|
|
|
|
+ console.log(imgs)
|
|
|
if (!imgs) return;
|
|
if (!imgs) return;
|
|
|
|
|
|
|
|
uni.previewImage({
|
|
uni.previewImage({
|
|
|
- urls: imgs,
|
|
|
|
|
- current: cur,
|
|
|
|
|
|
|
+ current: 0,
|
|
|
|
|
+ urls: [imgs],
|
|
|
longPressActions: {
|
|
longPressActions: {
|
|
|
itemList: ['发送给朋友', '保存图片', '收藏'],
|
|
itemList: ['发送给朋友', '保存图片', '收藏'],
|
|
|
success: function(data) {
|
|
success: function(data) {
|