前端小程序
这个提交包含在:
@@ -0,0 +1,208 @@
|
||||
<!-- 添加评论 -->
|
||||
<template>
|
||||
<view class="commont-from-wrap">
|
||||
<!-- 评价商品 -->
|
||||
<view class="goods-card">
|
||||
<shopro-mini-card :title="goodsDetail.goods_title" :image="goodsDetail.goods_image">
|
||||
<template #describe>
|
||||
<view class="order-sku u-ellipsis-1">
|
||||
<text class="order-num">数量:{{ goodsDetail.goods_num || 0 }};</text>
|
||||
{{ goodsDetail.goods_sku_text ? goodsDetail.goods_sku_text : '' }}
|
||||
</view>
|
||||
</template>
|
||||
<template #cardBottom>
|
||||
<view class="order-price-box u-flex ">
|
||||
<text class="order-price font-OPPOSANS">¥{{ goodsDetail.goods_price || 0 }}</text>
|
||||
<button class="u-reset-button status-btn" v-if="goodsDetail.status_name">{{ goodsDetail.status_name }}</button>
|
||||
</view>
|
||||
</template>
|
||||
</shopro-mini-card>
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<view class="star-box u-flex">
|
||||
<view class="star-title u-m-r-40">{{ starTip }}</view>
|
||||
<u-rate v-model="star" minCount="1"></u-rate>
|
||||
</view>
|
||||
<view class="area-box">
|
||||
<textarea class="inp-area" v-model="message" placeholder="宝贝满足你的期待吗?说说你的使用心得,分享给想买的他们吧~" placeholder-class="pl-style" />
|
||||
<view class="img-box">
|
||||
<u-upload
|
||||
:showProgress="false"
|
||||
@on-uploaded="uploadSuccess"
|
||||
@on-remove="uploadRemove"
|
||||
:action="`${$API_URL}index/upload`"
|
||||
width="138"
|
||||
height="138"
|
||||
maxCount="9"
|
||||
></u-upload>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="foot_box u-flex u-row-center u-col-center u-m-t-60"><button class="u-reset-button post-btn" @tap="subComment">发布</button></view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
imgList: [],
|
||||
star: 5,
|
||||
message: '',
|
||||
goodsDetail: {}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
starTip() {
|
||||
let text = '';
|
||||
if (this.star <= 1) {
|
||||
text = '差评';
|
||||
}
|
||||
if (this.star > 1 && this.star <= 3) {
|
||||
text = '中评';
|
||||
}
|
||||
if (this.star >= 4) {
|
||||
text = '好评';
|
||||
}
|
||||
return text;
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.getOrderItemDetail();
|
||||
},
|
||||
methods: {
|
||||
// 订单详情
|
||||
getOrderItemDetail() {
|
||||
let that = this;
|
||||
that.$http('order.itemDetail', {
|
||||
id: that.$Route.query.orderId,
|
||||
order_item_id: that.$Route.query.orderItemId
|
||||
}).then(res => {
|
||||
if (res.code === 1) {
|
||||
that.goodsDetail = res.data;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 上传图片成功
|
||||
uploadSuccess(e) {
|
||||
this.imgList = [];
|
||||
e.forEach(item => {
|
||||
this.imgList.push(item.response.data.url);
|
||||
});
|
||||
},
|
||||
|
||||
// 移除图片
|
||||
uploadRemove(index) {
|
||||
this.imgList.splice(index, 1);
|
||||
},
|
||||
|
||||
subComment() {
|
||||
let that = this;
|
||||
that.$http('order.comment', {
|
||||
id: that.$Route.query.orderId,
|
||||
order_item_id: that.goodsDetail.id,
|
||||
level: that.star,
|
||||
content: that.message,
|
||||
images: that.imgList
|
||||
}, '提交中...').then(res => {
|
||||
if (res.code === 1) {
|
||||
that.$u.toast('评论发表成功');
|
||||
that.$Router.back();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
// 评价商品
|
||||
.goods-card {
|
||||
margin: 10rpx 0;
|
||||
padding: 20rpx;
|
||||
background: #fff;
|
||||
.order-sku {
|
||||
font-size: 24rpx;
|
||||
|
||||
font-weight: 400;
|
||||
color: rgba(153, 153, 153, 1);
|
||||
width: 450rpx;
|
||||
margin-bottom: 20rpx;
|
||||
.order-num {
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
}
|
||||
.order-price-box {
|
||||
.status-btn {
|
||||
height: 32rpx;
|
||||
border: 1rpx solid rgba(207, 169, 114, 1);
|
||||
border-radius: 15rpx;
|
||||
font-size: 20rpx;
|
||||
font-weight: 400;
|
||||
color: rgba(168, 112, 13, 1);
|
||||
padding: 0 10rpx;
|
||||
margin-left: 20rpx;
|
||||
background: rgba(233, 183, 102, 0.16);
|
||||
}
|
||||
.order-price {
|
||||
font-size: 26rpx;
|
||||
|
||||
font-weight: 600;
|
||||
color: rgba(51, 51, 51, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 评论,选择图片
|
||||
.form-item {
|
||||
background: #ffff;
|
||||
padding-bottom: 30rpx;
|
||||
.star-box {
|
||||
height: 100rpx;
|
||||
padding: 0 25rpx;
|
||||
}
|
||||
.star-title {
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
.area-box {
|
||||
width: 690rpx;
|
||||
min-height: 306rpx;
|
||||
background: rgba(249, 250, 251, 1);
|
||||
border-radius: 20rpx;
|
||||
padding: 28rpx;
|
||||
margin: auto;
|
||||
.pl-style {
|
||||
font-size: 26rpx;
|
||||
|
||||
font-weight: 400;
|
||||
color: rgba(153, 153, 153, 1);
|
||||
line-height: 42rpx;
|
||||
}
|
||||
.inp-area {
|
||||
font-size: 26rpx;
|
||||
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
line-height: 50rpx;
|
||||
width: 100%;
|
||||
}
|
||||
.img-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
}
|
||||
.post-btn {
|
||||
width: 690rpx;
|
||||
line-height: 80rpx;
|
||||
background: linear-gradient(90deg, rgba(240, 199, 133, 1), rgba(246, 214, 157, 1));
|
||||
border-radius: 40rpx;
|
||||
color: rgba(#fff, 0.9);
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,126 @@
|
||||
<!-- 评论列表 -->
|
||||
<template>
|
||||
<view class="page_box">
|
||||
<view class="head_box u-flex">
|
||||
<button :class="{ 'btn-active': typeCurrent === t.code }" class="u-reset-button type-btn" @tap="selType(t.code)" v-for="t in commentTypeList" :key="t.code">
|
||||
{{ t.name }}({{ t.num }})
|
||||
</button>
|
||||
</view>
|
||||
<view class="content_box">
|
||||
<scroll-view scroll-y="true" enable-back-to-top @scrolltolower="loadMore" class="scroll-box">
|
||||
<view class="comment-list">
|
||||
<block v-for="comment in commentList" :key="comment.id"><sh-comment :comment="comment"></sh-comment></block>
|
||||
</view>
|
||||
<shopro-empty v-if="isEmpty" :image="$IMG_URL + '/imgs/empty/comment_empty.png'" tipText="暂无此类评价~"></shopro-empty>
|
||||
<!-- 加载更多 -->
|
||||
<u-loadmore v-if="commentList.length" height="80rpx" :status="loadStatus" icon-type="flower" color="#ccc" />
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import shComment from '../components/sh-comment.vue';
|
||||
export default {
|
||||
components: {
|
||||
shComment
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isEmpty: false,
|
||||
typeCurrent: 'all',
|
||||
commentList: [],
|
||||
commentTypeList: [],
|
||||
loadStatus: 'loadmore', //loadmore-加载前的状态,loading-加载中的状态,nomore-没有更多的状态
|
||||
currentPage: 1,
|
||||
lastPage: 1
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
onLoad() {
|
||||
this.getCommentType();
|
||||
},
|
||||
methods: {
|
||||
selType(id) {
|
||||
if (this.typeCurrent !== id) {
|
||||
this.typeCurrent = id;
|
||||
this.commentList = [];
|
||||
this.currentPage = 1;
|
||||
this.getCommentList();
|
||||
}
|
||||
},
|
||||
// 评价类型
|
||||
getCommentType() {
|
||||
let that = this;
|
||||
that.$http('goods.commentType', {
|
||||
goods_id: that.$Route.query.goodsId
|
||||
}).then(res => {
|
||||
if (res.code === 1) {
|
||||
that.commentTypeList = res.data;
|
||||
that.getCommentList();
|
||||
}
|
||||
});
|
||||
},
|
||||
// 商品评论
|
||||
getCommentList() {
|
||||
let that = this;
|
||||
that.loadStatus = 'loading';
|
||||
that.$http('goods.commentList', {
|
||||
goods_id: that.$Route.query.goodsId,
|
||||
pre_page: 10,
|
||||
page: that.currentPage,
|
||||
type: that.typeCurrent
|
||||
}, '加载中...').then(res => {
|
||||
if (res.code === 1) {
|
||||
that.commentList = [...that.commentList, ...res.data.data];
|
||||
that.isEmpty = !that.commentList.length;
|
||||
that.lastPage = res.data.last_page;
|
||||
that.loadStatus = that.currentPage < res.data.last_page ? 'loadmore' : 'nomore';
|
||||
}
|
||||
});
|
||||
},
|
||||
// 加载更多
|
||||
loadMore() {
|
||||
if (this.currentPage < this.lastPage) {
|
||||
this.currentPage += 1;
|
||||
this.getCommentList();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.empty-box {
|
||||
position: fixed;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
.head_box {
|
||||
height: 114rpx;
|
||||
background-color: #fff;
|
||||
padding: 0 20rpx;
|
||||
.type-btn {
|
||||
width: 130rpx;
|
||||
line-height: 62rpx;
|
||||
background: rgba(238, 238, 238, 1);
|
||||
border-radius: 31rpx;
|
||||
border: none;
|
||||
font-size: 28rpx;
|
||||
|
||||
font-weight: 400;
|
||||
color: rgba(153, 153, 153, 1);
|
||||
padding: 0;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
.btn-active {
|
||||
background: linear-gradient(90deg, #1677FF, #4096FF);
|
||||
box-shadow: 0px 7rpx 6rpx 0px rgba(229, 138, 0, 0.22);
|
||||
color: $brand-price;
|
||||
}
|
||||
}
|
||||
.comment-list {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
</style>
|
||||
在新工单中引用
屏蔽一个用户