Pre Merge pull request !89 from 卢越/master
commit
bba04ea785
|
|
@ -1,89 +1,130 @@
|
||||||
<!-- 评价 -->
|
<!-- 评价 -->
|
||||||
<template>
|
<template>
|
||||||
<s-layout title="评价">
|
<s-layout title="评价">
|
||||||
<view>
|
<view>
|
||||||
<view v-for="(item, index) in state.orderInfo.items" :key="item.id">
|
<view v-for="(item, index) in state.orderInfo.items" :key="item.id">
|
||||||
<view>
|
<view>
|
||||||
<view class="commont-from-wrap">
|
<view class="commont-from-wrap">
|
||||||
<!-- 评价商品 -->
|
<!-- 评价商品 -->
|
||||||
<s-goods-item
|
<s-goods-item
|
||||||
:img="item.picUrl"
|
:img="item.picUrl"
|
||||||
:title="item.spuName"
|
:title="item.spuName"
|
||||||
:skuText="item.properties.map((property) => property.valueName).join(' ')"
|
:skuText="item.properties.map((property) => property.valueName).join(' ')"
|
||||||
:price="item.payPrice"
|
:price="item.payPrice"
|
||||||
:num="item.count"
|
:num="item.count"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="form-item">
|
<view class="form-item">
|
||||||
<!-- 评分 -->
|
<!-- 评分 -->
|
||||||
<view class="star-box ss-flex ss-col-center">
|
<view class="star-box ss-flex ss-col-center">
|
||||||
<view class="star-title ss-m-r-40">商品质量</view>
|
<view class="star-title ss-m-r-40">商品质量</view>
|
||||||
<uni-rate v-model="state.commentList[index].descriptionScores" />
|
<uni-rate v-model="state.commentList[index].descriptionScores" />
|
||||||
</view>
|
</view>
|
||||||
<view class="star-box ss-flex ss-col-center">
|
<view class="star-box ss-flex ss-col-center">
|
||||||
<view class="star-title ss-m-r-40">服务态度</view>
|
<view class="star-title ss-m-r-40">服务态度</view>
|
||||||
<uni-rate v-model="state.commentList[index].benefitScores" />
|
<uni-rate v-model="state.commentList[index].benefitScores" />
|
||||||
</view>
|
</view>
|
||||||
<!-- 评价 -->
|
<!-- 评价 -->
|
||||||
<view class="area-box">
|
<view class="area-box">
|
||||||
<uni-easyinput :inputBorder="false" type="textarea" maxlength="120" autoHeight
|
<uni-easyinput
|
||||||
v-model="state.commentList[index].content"
|
:inputBorder="false"
|
||||||
placeholder="宝贝满足你的期待吗?说说你的使用心得,分享给想买的他们吧~" />
|
type="textarea"
|
||||||
<!-- TODO 卢越:【评论】文件上传 -->
|
maxlength="120"
|
||||||
<view class="img-box">
|
autoHeight
|
||||||
<s-uploader v-model:url="state.commentList[index].images" fileMediatype="image"
|
v-model="state.commentList[index].content"
|
||||||
limit="9" mode="grid" :imageStyles="{ width: '168rpx', height: '168rpx' }" />
|
placeholder="宝贝满足你的期待吗?说说你的使用心得,分享给想买的他们吧~"
|
||||||
</view>
|
/>
|
||||||
</view>
|
<view class="img-box">
|
||||||
</view>
|
<s-uploader
|
||||||
</view>
|
v-model:url="state.commentList[index].images"
|
||||||
</view>
|
fileMediatype="image"
|
||||||
</view>
|
limit="9"
|
||||||
<!-- TODO 卢越:【评论】是否匿名 -->
|
mode="grid"
|
||||||
|
:imageStyles="{ width: '168rpx', height: '168rpx' }"
|
||||||
<su-fixed bottom placeholder>
|
@success="(payload) => uploadSuccess(payload, index)"
|
||||||
<view class="foot_box ss-flex ss-row-center ss-col-center">
|
/>
|
||||||
<button class="ss-reset-button post-btn ui-BG-Main-Gradient ui-Shadow-Main" @tap="onSubmit">
|
</view>
|
||||||
发布
|
</view>
|
||||||
</button>
|
<view class="checkbox-container">
|
||||||
</view>
|
<checkbox-group @change="(event) => toggleAnonymous(index, event)">
|
||||||
</su-fixed>
|
<label>
|
||||||
</s-layout>
|
<checkbox value="anonymousChecked" />
|
||||||
|
匿名评论
|
||||||
|
</label>
|
||||||
|
</checkbox-group>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<su-fixed bottom placeholder>
|
||||||
|
<view class="foot_box ss-flex ss-row-center ss-col-center">
|
||||||
|
<button class="ss-reset-button post-btn ui-BG-Main-Gradient ui-Shadow-Main" @tap="onSubmit">
|
||||||
|
发布
|
||||||
|
</button>
|
||||||
|
</view>
|
||||||
|
</su-fixed>
|
||||||
|
</s-layout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
import { onLoad } from '@dcloudio/uni-app';
|
import { onLoad } from '@dcloudio/uni-app';
|
||||||
import { reactive } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
import OrderApi from '@/sheep/api/trade/order';
|
import OrderApi from '@/sheep/api/trade/order';
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
orderInfo: {},
|
orderInfo: {},
|
||||||
commentList: [],
|
commentList: [],
|
||||||
id: null
|
id: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
async function onSubmit() {
|
/**
|
||||||
|
* 切换是否匿名
|
||||||
|
*
|
||||||
|
* @param commentIndex 当前评论下标
|
||||||
|
* @param event 复选框事件
|
||||||
|
*/
|
||||||
|
function toggleAnonymous(commentIndex, event) {
|
||||||
|
state.commentList[commentIndex].anonymous = event.detail.value[0] === 'anonymousChecked';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发布评论
|
||||||
|
*
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async function onSubmit() {
|
||||||
// 顺序提交评论
|
// 顺序提交评论
|
||||||
for (const comment of state.commentList) {
|
for (const comment of state.commentList) {
|
||||||
await OrderApi.createOrderItemComment(comment);
|
await OrderApi.createOrderItemComment(comment);
|
||||||
}
|
}
|
||||||
// 都评论好,返回
|
// 都评论好,返回
|
||||||
sheep.$router.back();
|
sheep.$router.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoad(async (options) => {
|
/**
|
||||||
|
* 图片添加到表单
|
||||||
|
*
|
||||||
|
* @param payload 上传成功后的回调数据
|
||||||
|
* @param commentIndex 当前评论的下标
|
||||||
|
*/
|
||||||
|
function uploadSuccess(payload, commentIndex) {
|
||||||
|
state.commentList[commentIndex].picUrls = state.commentList[commentIndex].images;
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoad(async (options) => {
|
||||||
if (!options.id) {
|
if (!options.id) {
|
||||||
sheep.$helper.toast(`缺少订单信息,请检查`);
|
sheep.$helper.toast(`缺少订单信息,请检查`);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
state.id = options.id;
|
state.id = options.id;
|
||||||
|
|
||||||
const { code, data } = await OrderApi.getOrder(state.id);
|
const { code, data } = await OrderApi.getOrder(state.id);
|
||||||
if (code !== 0) {
|
if (code !== 0) {
|
||||||
sheep.$helper.toast('无待评价订单');
|
sheep.$helper.toast('无待评价订单');
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
// 处理评论
|
// 处理评论
|
||||||
data.items.forEach((item) => {
|
data.items.forEach((item) => {
|
||||||
|
|
@ -93,53 +134,57 @@
|
||||||
descriptionScores: 5,
|
descriptionScores: 5,
|
||||||
benefitScores: 5,
|
benefitScores: 5,
|
||||||
content: '',
|
content: '',
|
||||||
picUrls: []
|
picUrls: [],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
state.orderInfo = data;
|
state.orderInfo = data;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
// 评价商品
|
// 评价商品
|
||||||
.goods-card {
|
.goods-card {
|
||||||
margin: 10rpx 0;
|
margin: 10rpx 0;
|
||||||
padding: 20rpx;
|
padding: 20rpx;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 评论,选择图片
|
// 评论,选择图片
|
||||||
.form-item {
|
.form-item {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
|
|
||||||
.star-box {
|
.star-box {
|
||||||
height: 100rpx;
|
height: 100rpx;
|
||||||
padding: 0 25rpx;
|
padding: 0 25rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.star-title {
|
.star-title {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.area-box {
|
.area-box {
|
||||||
width: 690rpx;
|
width: 690rpx;
|
||||||
min-height: 306rpx;
|
min-height: 306rpx;
|
||||||
background: rgba(249, 250, 251, 1);
|
background: rgba(249, 250, 251, 1);
|
||||||
border-radius: 20rpx;
|
border-radius: 20rpx;
|
||||||
padding: 28rpx;
|
padding: 28rpx;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
|
|
||||||
.img-box {
|
.img-box {
|
||||||
margin-top: 20rpx;
|
margin-top: 20rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-btn {
|
.checkbox-container {
|
||||||
width: 690rpx;
|
padding: 10rpx;
|
||||||
line-height: 80rpx;
|
}
|
||||||
border-radius: 40rpx;
|
|
||||||
color: rgba(#fff, 0.9);
|
.post-btn {
|
||||||
margin-bottom: 20rpx;
|
width: 690rpx;
|
||||||
}
|
line-height: 80rpx;
|
||||||
|
border-radius: 40rpx;
|
||||||
|
color: rgba(#fff, 0.9);
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<!-- 商品评论的分页 -->
|
<!-- 商品评论的分页 -->
|
||||||
<template>
|
<template>
|
||||||
<s-layout title="全部评价">
|
<s-layout title="全部评论">
|
||||||
<su-tabs
|
<su-tabs
|
||||||
:list="state.type"
|
:list="state.type"
|
||||||
:scrollable="false"
|
:scrollable="false"
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
<s-empty v-if="state.pagination.total === 0" text="暂无数据" icon="/static/data-empty.png" />
|
<s-empty v-if="state.pagination.total === 0" text="暂无数据" icon="/static/data-empty.png" />
|
||||||
<!-- 下拉 -->
|
<!-- 下拉 -->
|
||||||
<uni-load-more
|
<uni-load-more
|
||||||
|
icon-type="auto"
|
||||||
v-if="state.pagination.total > 0"
|
v-if="state.pagination.total > 0"
|
||||||
:status="state.loadStatus"
|
:status="state.loadStatus"
|
||||||
:content-text="{
|
:content-text="{
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<!-- SKU 信息 -->
|
<!-- SKU 信息 -->
|
||||||
<view class="ss-modal-box bg-white ss-flex-col">
|
<view class="ss-modal-box bg-white ss-flex-col">
|
||||||
<view class="modal-header ss-flex ss-col-center">
|
<view class="modal-header ss-flex ss-col-center">
|
||||||
<!-- 规格图 -->
|
<!-- 规格图片 -->
|
||||||
<view class="header-left ss-m-r-30">
|
<view class="header-left ss-m-r-30">
|
||||||
<image
|
<image
|
||||||
class="sku-image"
|
class="sku-image"
|
||||||
|
|
@ -125,10 +125,6 @@
|
||||||
return skuPrices;
|
return skuPrices;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!state.goodsInfo.is_sku) {
|
|
||||||
state.selectedSku = state.goodsInfo.skus[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => state.selectedSku,
|
() => state.selectedSku,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue