feat: 商品详情评论+订单详情物流开发
This commit is contained in:
parent
8d5168365d
commit
003f27fb15
16
api/order.js
16
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
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -10,31 +10,31 @@
|
||||
<!-- 用户信息 -->
|
||||
<view class="user-info">
|
||||
<view class="user-avatar">
|
||||
<avatar-image :url="item.user.avatar_url" :width="50" />
|
||||
<avatar-image :url="item.avatar" :width="50" />
|
||||
</view>
|
||||
<text class="user-name f-26">{{ item.user.nick_name }}</text>
|
||||
<text class="user-name f-26">{{ item.buyerName }}</text>
|
||||
</view>
|
||||
<!-- 评星 -->
|
||||
<u-rate active-color="#f4a213" :current="rates[item.score]" :disabled="true" />
|
||||
<!-- <u-rate active-color="#f4a213" :current="rates[item.score]" :disabled="true" /> -->
|
||||
<!-- 评价日期-->
|
||||
<view class="flex-box f-22 col-9 t-r">{{ item.create_time }}</view>
|
||||
<view class="flex-box f-22 col-9 t-r">{{ new Date(item.createTime).toLocaleString() }}</view>
|
||||
</view>
|
||||
<!-- 评价内容 -->
|
||||
<view class="item-content m-top20">
|
||||
<text class="f-26">{{ item.content }}</text>
|
||||
<text class="f-26">{{ item.productComment }}</text>
|
||||
</view>
|
||||
<!-- 评价图片 -->
|
||||
<view class="images-list clearfix" v-if="item.images.length">
|
||||
<!-- <view class="images-list clearfix" v-if="item.images.length">
|
||||
<view class="image-preview" v-for="(image, imgIdx) in item.images" :key="imgIdx">
|
||||
<image class="image" mode="aspectFill" :src="image.image_url" @click="onPreviewImages(index, imgIdx)">
|
||||
</image>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
<!-- 商品规格 -->
|
||||
<view class="goods-props clearfix">
|
||||
<view class="goods-props-item" v-for="(props, idx) in item.orderGoods.goods_props" :key="idx">
|
||||
<text class="group-name">{{ props.group.name }}: </text>
|
||||
<text>{{ props.value.name }};</text>
|
||||
<view class="goods-props-item" v-for="(props, idx) in item.skuInfo" :key="idx">
|
||||
<text class="group-name">{{ props.propertyName }}: </text>
|
||||
<text>{{ props.propertyValue }};</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -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
|
||||
|
||||
@ -37,7 +37,6 @@
|
||||
|
||||
<script>
|
||||
import AvatarImage from '@/components/avatar-image'
|
||||
import * as CommentApi from '@/api/comment'
|
||||
import * as GoodsApi from '@/api/goods'
|
||||
|
||||
export default {
|
||||
@ -45,12 +44,10 @@
|
||||
AvatarImage
|
||||
},
|
||||
props: {
|
||||
// 商品ID
|
||||
goodsId: {
|
||||
type: Number,
|
||||
default: null
|
||||
},
|
||||
// 加载多少条记录 默认2条
|
||||
limit: {
|
||||
type: Number,
|
||||
default: 2
|
||||
@ -58,24 +55,17 @@
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 正在加载
|
||||
isLoading: true,
|
||||
// 评星数据转换
|
||||
rates: { 10: 5, 20: 3, 30: 1 },
|
||||
// 评价列表数据
|
||||
list: [],
|
||||
// 评价总数量
|
||||
total: 0
|
||||
}
|
||||
},
|
||||
|
||||
created() {
|
||||
// 加载评价列表数据
|
||||
this.getCommentList()
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 加载评价列表数据
|
||||
getCommentList() {
|
||||
const app = this
|
||||
app.isLoading = true
|
||||
@ -88,8 +78,6 @@
|
||||
app.total = result.data.length
|
||||
}).finally(() => app.isLoading = false)
|
||||
},
|
||||
|
||||
// 跳转到评论列表页
|
||||
onTargetToComment() {
|
||||
const app = this
|
||||
app.$navTo('pages/comment/index', { goodsId: app.goodsId })
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 物流信息 -->
|
||||
<view v-if="orderDetail.vvPackageEntity.trackNumber" class="express i-card" @click="handleTargetExpress()">
|
||||
<view v-if="orderDetail.vvPackageEntity.trackNumber" class="express i-card" @click="handleTargetExpress(orderDetail.vvPackageEntity.trackNumber)">
|
||||
<!-- <view v-if="order.delivery.length > 1" class="main">
|
||||
<view class="info-item">
|
||||
<view class="item-content">
|
||||
@ -295,8 +295,8 @@
|
||||
},
|
||||
|
||||
// 跳转到物流跟踪页面
|
||||
handleTargetExpress() {
|
||||
this.$navTo('pages/order/express/index', { orderId: this.orderId })
|
||||
handleTargetExpress(trackNumber) {
|
||||
this.$navTo('pages/order/express/index', { trackNumber })
|
||||
},
|
||||
|
||||
// 跳转到商品详情页面
|
||||
|
||||
@ -2,31 +2,31 @@
|
||||
<view v-if="!isLoading && express.length" class="container">
|
||||
|
||||
<!-- 标签栏 -->
|
||||
<u-tabs v-if="tabs.length > 1" :list="tabs" :isScroll="true" v-model="curTab" :active-color="appTheme.mainBg" :duration="0.2" bar-width="60"
|
||||
@change="onChangeTab"></u-tabs>
|
||||
<!-- <u-tabs v-if="tabs.length > 1" :list="tabs" :isScroll="true" v-model="curTab" :active-color="appTheme.mainBg" :duration="0.2" bar-width="60"
|
||||
@change="onChangeTab"></u-tabs> -->
|
||||
|
||||
<!-- 商品列表 -->
|
||||
<view v-show="tabs.length > 1" class="deliver-goods-list i-card clearfix">
|
||||
<!-- <view v-show="tabs.length > 1" class="deliver-goods-list i-card clearfix">
|
||||
<view class="goods-item" v-for="(goods, idx) in express[curTab].goods" :key="idx">
|
||||
<image class="goods-img" :src="goods.goods.goods_image" alt="商品图片" />
|
||||
<view class="title">共{{ goods.delivery_num }}件</view>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<!-- 物流信息 -->
|
||||
<view class="express i-card">
|
||||
<view class="info-item">
|
||||
<view class="item-lable">物流公司:</view>
|
||||
<view class="item-content">
|
||||
<text v-if="express[curTab].delivery_method == 20">无需物流</text>
|
||||
<text v-else>{{ express[curTab].express ? express[curTab].express.express_name : '--' }}</text>
|
||||
<!-- <text v-if="express[curTab].delivery_method == 20">无需物流</text> -->
|
||||
<text>{{ express[curTab].com || '--' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<view class="item-lable">物流单号:</view>
|
||||
<view class="item-content">
|
||||
<text>{{ express[curTab].express_no ? express[curTab].express_no : '--' }}</text>
|
||||
<view v-show="express[curTab].express_no" class="act-copy" @click.stop="handleCopy(express[curTab].express_no)">
|
||||
<text>{{ express[curTab].nu || '--' }}</text>
|
||||
<view v-show="express[curTab].nu" class="act-copy" @click.stop="handleCopy(express[curTab].nu)">
|
||||
<text>复制</text>
|
||||
</view>
|
||||
</view>
|
||||
@ -34,8 +34,8 @@
|
||||
</view>
|
||||
|
||||
<!-- 物流轨迹 -->
|
||||
<view class="logis-detail" v-if="express[curTab].traces && express[curTab].traces.length">
|
||||
<view class="logis-item" :class="{ first: index === 0 }" v-for="(item, index) in express[curTab].traces" :key="index">
|
||||
<view class="logis-detail" v-if="express[curTab].data && express[curTab].data.length">
|
||||
<view class="logis-item" :class="{ first: index === 0 }" v-for="(item, index) in express[curTab].data" :key="index">
|
||||
<view class="logis-item-content">
|
||||
<view class="logis-item-content__describe">
|
||||
<text class="f-26">{{ item.context }}</text>
|
||||
@ -55,26 +55,15 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
// 正在加载
|
||||
isLoading: true,
|
||||
// 当前标签索引
|
||||
curTab: 0,
|
||||
// 当前订单ID
|
||||
orderId: null,
|
||||
// 物流信息
|
||||
express: {}
|
||||
trackNumber: null,
|
||||
express: [{}]
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
tabs() {
|
||||
if (this.express && this.express.length) {
|
||||
|
||||
const test = this.express.map((item, index) => {
|
||||
return { name: `包裹${index + 1}` }
|
||||
})
|
||||
|
||||
console.log('test', test)
|
||||
|
||||
if (this.express && this.express.length > 1) {
|
||||
return this.express.map((item, index) => {
|
||||
return { name: `包裹${index + 1}` }
|
||||
})
|
||||
@ -82,29 +71,19 @@
|
||||
return []
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad({ orderId }) {
|
||||
this.orderId = orderId
|
||||
// 获取当前订单的物流信息
|
||||
onLoad({ trackNumber }) {
|
||||
this.trackNumber = trackNumber
|
||||
this.getExpress()
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
// 获取当前订单的物流信息
|
||||
getExpress() {
|
||||
const app = this
|
||||
app.isLoading = true
|
||||
OrderApi.express(app.orderId)
|
||||
.then(result => {
|
||||
app.express = result.data.express
|
||||
OrderApi.apiGetOrderLogistics({ trackNumber: app.trackNumber }).then(res => {
|
||||
app.express = [res.data]
|
||||
app.isLoading = false
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
// 复制指定内容
|
||||
handleCopy(value) {
|
||||
const app = this
|
||||
@ -114,7 +93,6 @@
|
||||
fail: ({ errMsg }) => app.$toast('复制失败 ' + errMsg)
|
||||
})
|
||||
},
|
||||
|
||||
// 切换标签项
|
||||
onChangeTab(index) {
|
||||
this.curTab = index
|
||||
|
||||
@ -145,6 +145,7 @@
|
||||
import SettingKeyEnum from '@/common/enum/setting/Key'
|
||||
import SettingModel from '@/common/model/Setting'
|
||||
import { checkLogin } from '@/core/app'
|
||||
import { apiGetOrderCount } from '@/api/order'
|
||||
|
||||
// 订单操作
|
||||
const orderNavbar = [
|
||||
@ -196,11 +197,12 @@
|
||||
this.getPageData()
|
||||
},
|
||||
// 获取页面数据
|
||||
getPageData(callback) {
|
||||
async getPageData(callback) {
|
||||
const app = this
|
||||
app.isLoading = true
|
||||
app.assets = { balance: "500.00", points: 1000, coupon: 5 }
|
||||
const counts = { payment: 2, delivery: 1, received: 3, refund: 0 }
|
||||
const res = await apiGetOrderCount({})
|
||||
const counts = { wait_pay: res.data.waitPayCount, wait_shipping: res.data.waitShippingCount, shipping: res.data.shippingCount, refund: 0 }
|
||||
app.orderNavbar = app.orderNavbar.map(item => {
|
||||
if (item.count != undefined) {
|
||||
item.count = counts[item.id]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user