123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <!-- 评价 -->
- <template>
- <s-layout :title="t('order.review_order')">
- <view>
- <view v-for="(item, index) in state.orderInfo.items" :key="item.id">
- <view>
- <view class="commont-from-wrap">
- <!-- 评价商品 -->
- <s-goods-item :img="item.picUrl" :title="item.spuName"
- :skuText="item.properties.map((property) => property.valueName).join(' ')"
- :price="item.payPrice" :num="item.count" />
- </view>
- <view class="form-item">
- <!-- 评分 -->
- <view class="star-box ss-flex ss-col-center">
- <view class="star-title ss-m-r-40">{{ t('order.product_quality') }}</view>
- <uni-rate v-model="state.commentList[index].descriptionScores" />
- </view>
- <view class="star-box ss-flex ss-col-center">
- <view class="star-title ss-m-r-40">{{ t('order.service_attitude') }}</view>
- <uni-rate v-model="state.commentList[index].benefitScores" />
- </view>
- <!-- 评价 -->
- <view class="area-box">
- <uni-easyinput :inputBorder="false" type="textarea" maxlength="120" autoHeight
- v-model="state.commentList[index].content"
- :placeholder="t('order.meet_expectations')" />
- <!-- TODO 非繁人:文件上传 -->
- <view class="img-box">
- <s-uploader v-model:url="state.commentList[index].picUrls" fileMediatype="image"
- limit="9" mode="grid" :imageStyles="{ width: '168rpx', height: '168rpx' }" />
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <!-- TODO 非繁人:是否匿名 -->
- <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">
- {{ t('common.post') }}
- </button>
- </view>
- </su-fixed>
- </s-layout>
- </template>
- <script setup>
- import sheep from '@/sheep';
- import {
- onLoad
- } from '@dcloudio/uni-app';
- import {
- reactive
- } from 'vue';
- import OrderApi from '@/sheep/api/trade/order';
- import { t } from '@/locale'
- const state = reactive({
- orderInfo: {},
- commentList: [],
- id: null
- });
- async function onSubmit() {
- uni.showModal({
- title: t('setting.prompt'),
- content: t('order.confirm_post_review'),
- success: async function(res) {
- if (!res.confirm) {
- return;
- }
- // 顺序提交评论
- for (const comment of state.commentList) {
- await OrderApi.createOrderItemComment(comment);
- }
- // 都评论好,返回
- sheep.$router.back();
- },
- });
-
-
- }
- onLoad(async (options) => {
- if (!options.id) {
- sheep.$helper.toast(t('order.missing_order_info'));
- return
- }
- state.id = options.id;
- const {
- code,
- data
- } = await OrderApi.getOrder(state.id);
- if (code !== 0) {
- sheep.$helper.toast(t('order.no_reviews_pending'));
- return
- }
- // 处理评论
- data.items.forEach((item) => {
- state.commentList.push({
- anonymous: false,
- orderItemId: item.id,
- descriptionScores: 5,
- benefitScores: 5,
- content: '',
- picUrls: []
- });
- });
- state.orderInfo = data;
- });
- </script>
- <style lang="scss" scoped>
- // 评价商品
- .goods-card {
- margin: 10rpx 0;
- padding: 20rpx;
- background: #fff;
- }
- // 评论,选择图片
- .form-item {
- background: #fff;
- .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;
- .img-box {
- margin-top: 20rpx;
- }
- }
- .post-btn {
- width: 690rpx;
- line-height: 80rpx;
- border-radius: 40rpx;
- color: rgba(#fff, 0.9);
- margin-bottom: 20rpx;
- }
- </style>
|