diff --git a/api/order.js b/api/order.js index c6c7bf3..c14c136 100644 --- a/api/order.js +++ b/api/order.js @@ -100,4 +100,20 @@ export const apiGetOrderDetail = (data) => { ); } +// 获取订单物流信息 +export const apiGetOrderLogistics = (data) => { + return httpRequest.post( + `${baseUrl}/logistics/query`, + data + ); + } + +// 我的个人中心获取订单数量 +export const apiGetOrderCount = (data) => { + return httpRequest.post( + `${baseUrl}/order/count`, + data + ); + } + diff --git a/pages/comment/index.vue b/pages/comment/index.vue index 647d1ce..b1900bd 100644 --- a/pages/comment/index.vue +++ b/pages/comment/index.vue @@ -10,31 +10,31 @@ - + - {{ item.user.nick_name }} + {{ item.buyerName }} - + - {{ item.create_time }} + {{ new Date(item.createTime).toLocaleString() }} - {{ item.content }} + {{ item.productComment }} - + - - {{ props.group.name }}: - {{ props.value.name }}; + + {{ props.propertyName }}: + {{ props.propertyValue }}; @@ -48,21 +48,10 @@ import AvatarImage from '@/components/avatar-image' import { getEmptyPaginateObj, getMoreListData } from '@/core/app' import * as CommentApi from '@/api/comment' + import { apiGetCommentList } from '@/api/goods' const pageSize = 15 - const tabs = [{ - name: `全部`, - scoreType: -1 - }, { - name: `好评`, - scoreType: 10 - }, { - name: `中评`, - scoreType: 20 - }, { - name: `差评`, - scoreType: 30 - }] + const tabs = [{ name: `全部`, scoreType: -1 }, { name: `好评`, scoreType: 10 }, { name: `中评`, scoreType: 20 }, { name: `差评`, scoreType: 30 }] export default { components: { @@ -71,119 +60,70 @@ mixins: [MescrollMixin], data() { return { - // 当前商品ID goodsId: null, - // 当前标签索引 curTab: 0, - // 评价列表数据 list: getEmptyPaginateObj(), - // 评价总数量 total: { all: 0, negative: 0, praise: 0, review: 0 }, - // 评星数据转换 rates: { 10: 5, 20: 3, 30: 1 }, - // 标签栏数据 tabs, // 上拉加载配置 upOption: { // 首次自动执行 auto: true, - // 每页数据的数量; 默认10 page: { size: pageSize }, // 数量要大于4条才显示无更多数据 noMoreSize: 4, - // 空布局 empty: { tip: '亲,暂无相关商品评价' } }, } }, - - /** - * 生命周期函数--监听页面加载 - */ onLoad(options) { - // 记录属性值 this.goodsId = options.goodsId // 获取指定评分总数 this.getTotal() }, methods: { - /** * 上拉加载的回调 (页面初始化时也会执行一次) - * 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 * @param {Object} page */ upCallback(page) { const app = this - // 设置列表数据 - app.getCommentList(page.num) - .then(list => { - const curPageLen = list.data.length - const totalSize = list.total - app.mescroll.endBySize(curPageLen, totalSize) - }) - .catch(() => app.mescroll.endErr()) + apiGetCommentList({ productId: app.goodsId, scoreType: app.tabs[app.curTab].scoreType, page: page.num }).then(res => { + const data = res.data.map(item => ({ + ...item, + skuInfo: JSON.parse(item.skuInfo) + })) + app.list.data = getMoreListData({ data }, app.list, page.num) + app.mescroll.endBySize(data.length, data.length) + }).catch(() => app.mescroll.endErr()) + CommentApi.list({}) }, - - // 加载评价列表数据 - getCommentList(pageNo = 1) { - const app = this - return new Promise((resolve, reject) => { - CommentApi.list(app.goodsId, { scoreType: app.getScoreType(), page: pageNo }, { load: false }) - .then(result => { - // 合并新数据 - const newList = result.data.list - app.list.data = getMoreListData(newList, app.list, pageNo) - resolve(newList) - }) - }) - }, - - // 评分类型 - getScoreType() { - return this.tabs[this.curTab].scoreType - }, - // 获取指定评分总数 getTotal() { const app = this CommentApi.total(app.goodsId) .then(result => { - // tab标签内容 const total = result.data.total - app.getTabs(total) + const tabs = app.tabs + tabs[0].name = `全部(${total.all})` + tabs[1].name = `好评(${total.praise})` + tabs[2].name = `中评(${total.review})` + tabs[3].name = `差评(${total.negative})` }) }, - - // 获取tab标签内容 - getTabs(total) { - const tabs = this.tabs - tabs[0].name = `全部(${total.all})` - tabs[1].name = `好评(${total.praise})` - tabs[2].name = `中评(${total.review})` - tabs[3].name = `差评(${total.negative})` - }, - // 切换标签项 onChangeTab(index) { const app = this - // 设置当前选中的标签 app.curTab = index - // 刷新评价列表 - app.onRefreshList() - }, - - // 刷新评价列表 - onRefreshList() { - this.list = getEmptyPaginateObj() + app.list = getEmptyPaginateObj() setTimeout(() => { - this.mescroll.resetUpScroll() + app.mescroll.resetUpScroll() }, 120) }, - // 预览评价图片 onPreviewImages(dataIdx, imgIndex) { const app = this diff --git a/pages/goods/components/Comment.vue b/pages/goods/components/Comment.vue index 27ce03b..525aa9a 100644 --- a/pages/goods/components/Comment.vue +++ b/pages/goods/components/Comment.vue @@ -37,7 +37,6 @@