You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
163 lines
4.2 KiB
163 lines
4.2 KiB
<template>
|
|
|
|
<!--<import src="../../../component/rater/rater.wxml"></import>-->
|
|
|
|
<view id="comments">
|
|
<view class="content">
|
|
<view class="no-list" v-if="!list[0].length && init">
|
|
暂无数据
|
|
</view>
|
|
<view v-for="(items, idx) in list" :key="idx">
|
|
<view class="comment_list mx-1px-bottom" v-for="(item, index) in list[idx]" :key="index">
|
|
<view class="comment_user">
|
|
<view class="img-box">
|
|
<image :src="item.user.avatar"></image>
|
|
<view class="user_name">{{item.user.nick_name}}</view>
|
|
</view>
|
|
<view class="rater">
|
|
<!--<template is="rater" data="{{ ...$vlc.rater[item.id] }}"/>-->
|
|
<uni-rate size="18" disabled="true" active-color="red" :value="item.point"></uni-rate>
|
|
</view>
|
|
</view>
|
|
<view class="comment_time">
|
|
<view class="time">
|
|
{{item.updated_at}}
|
|
</view>
|
|
<view class="model">
|
|
{{item.item_meta.specs_text!=undefined?item.item_meta.specs_text:''}}
|
|
</view>
|
|
</view>
|
|
<view class="comment_content">
|
|
{{item.contents}}
|
|
</view>
|
|
<view class="comment-img">
|
|
<image :src="item" mode="widthFix" alt v-for="(item, index) in item.pic_list" :key="index"></image>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
<script>
|
|
import {pageLogin, getUrl,config,is} from '@/common/js/utils.js';
|
|
import uniRate from "@/components/score/uni-rate/uni-rate.vue"
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
hasMore: true,
|
|
init: false,
|
|
list: [],
|
|
page: '',
|
|
id: ''
|
|
};
|
|
},
|
|
|
|
components: {
|
|
uniRate
|
|
},
|
|
// 加载更多
|
|
onReachBottom() {
|
|
if (this.hasMore) {
|
|
var page = this.page + 1;
|
|
this.queryCommodityComments(this.id, page);
|
|
} else {
|
|
wx.showToast({
|
|
image: '../../../static/error.png',
|
|
title: '再拉也没有啦'
|
|
});
|
|
}
|
|
},
|
|
|
|
onLoad(e) {
|
|
wx.showLoading({
|
|
title: "加载中",
|
|
mask: true
|
|
});
|
|
this.queryCommodityComments(e.id, 1);
|
|
this.setData({
|
|
id: e.id
|
|
});
|
|
},
|
|
|
|
components: {},
|
|
props: {},
|
|
methods: {
|
|
// 请求评论列表
|
|
queryCommodityComments(id, page = 1) {
|
|
this.$http.get({
|
|
api: 'api/store/detail/' + id + '/comments',
|
|
data: {
|
|
page: page
|
|
}
|
|
}).then(res => {
|
|
if (res.statusCode == 200) {
|
|
res = res.data;
|
|
|
|
if (res.status) {
|
|
var pages = res.meta.pagination;
|
|
var current_page = pages.current_page;
|
|
var total_pages = pages.total_pages;
|
|
this.setData({
|
|
// [`list[${page - 1}]`]: res.data,
|
|
init: true,
|
|
page: current_page,
|
|
hasMore: current_page < total_pages
|
|
});
|
|
this.list[[page-1]]=res.data;
|
|
|
|
} else {
|
|
wx.showModal({
|
|
title: '',
|
|
content: '请求失败',
|
|
showCancel: false
|
|
});
|
|
}
|
|
} else {
|
|
wx.showModal({
|
|
title: '',
|
|
content: '请求失败',
|
|
showCancel: false
|
|
});
|
|
}
|
|
|
|
wx.hideLoading();
|
|
this.show=false;
|
|
}, err => {
|
|
wx.hideLoading();
|
|
// this.setData({
|
|
// show: false
|
|
// });
|
|
this.show=false;
|
|
});
|
|
},
|
|
|
|
setData: function (obj) {
|
|
let that = this;
|
|
let keys = [];
|
|
let val, data;
|
|
Object.keys(obj).forEach(function (key) {
|
|
keys = key.split('.');
|
|
val = obj[key];
|
|
data = that.$data;
|
|
keys.forEach(function (key2, index) {
|
|
if (index + 1 == keys.length) {
|
|
that.$set(data, key2, val);
|
|
} else {
|
|
if (!data[key2]) {
|
|
that.$set(data, key2, {});
|
|
}
|
|
}
|
|
|
|
data = data[key2];
|
|
});
|
|
});
|
|
}
|
|
},
|
|
computed: {},
|
|
watch: {}
|
|
};
|
|
</script>
|
|
<style rel="stylesheet/less" lang="less">
|
|
@import "comment";
|
|
</style>
|