| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <template>
- <Popup ref="popRef" title="申请回购" isClose closeOnClickOverlay>
- <template #content>
- <view class="popup-content">
- <!-- 图片上传 -->
- <view class="image-section">
- <view class="section-title">
- <trans _t="上传图片" />
- </view>
- <imageUpload v-model="imageList" :maxCount="maxImages" multiple />
- </view>
- <view class="image-section">
- <view class="section-title _required">
- <trans _t="上传视频" />
- </view>
- <videoUpload v-model="videoUrl" />
- </view>
- </view>
- </template>
- <template #footer>
- <view class="popup-footer">
- <view class="btn-group">
- <view class="btn cancel-btn" @click="close">
- <trans _t="取消" />
- </view>
- <view class="btn submit-btn" @click="submitReview">
- <trans _t="提交" />
- </view>
- </view>
- </view>
- </template>
- </Popup>
- </template>
- <script setup>
- import { ref, computed, watch } from "vue";
- import { Toast, TimeOut } from "@/utils";
- import { t } from "@/locale";
- import { SHOP_SUBMIT_BUYBACK } from "@/api";
- import imageUpload from "@/components/imageUpload";
- import videoUpload from "@/components/videoUpload";
- import Popup from "@/components/popup";
- const props = defineProps({
- id: {
- type: [String, Number],
- default: "",
- },
- maxImages: {
- type: Number,
- default: 6,
- },
- });
- const emit = defineEmits(["submit", "close", "open"]);
- const popRef = ref(null);
- const reviewContent = ref("");
- const imageList = ref([]);
- const videoUrl = ref([]);
- // 是否可以提交
- const canSubmit = computed(() => {
- return reviewContent.value.trim().length > 0 && imageList.value.length;
- });
- // 打开弹框
- const open = (data = {}) => {
- popRef.value && popRef.value.open();
- // 重置数据
- videoUrl.value = [];
- imageList.value = [];
- };
- // 关闭弹框
- const close = () => {
- popRef.value && popRef.value.close();
- emit("close");
- };
- // 提交评价
- const submitReview = async () => {
- let images = "";
- let videos = "";
- if (imageList.value.length) {
- images = imageList.value.map((item) => item.url).join(",");
- }
- if (videoUrl.value.length) {
- videos = videoUrl.value.map((item) => item.url).join(",");
- } else {
- return Toast("请上传视频");
- }
- try {
- const submitData = {
- pid: props.id,
- video: videos,
- images: images,
- };
- const res = await SHOP_SUBMIT_BUYBACK(submitData);
- Toast(res.msg).then(() => {
- TimeOut(() => {
- close();
- emit("submit", submitData);
- });
- });
- } catch (error) {
- console.error("提交评价失败:", error);
- Toast(error.msg || "提交失败,请重试");
- }
- };
- // 暴露方法
- defineExpose({
- open,
- close,
- });
- </script>
- <style lang="less" scoped>
- .popup-content {
- flex: 1;
- overflow-y: auto;
- }
- .review-section,
- .image-section,
- .rating-section {
- margin-bottom: 32rpx;
- .section-title {
- font-size: 28rpx;
- font-weight: 600;
- color: var(--text);
- margin-bottom: 16rpx;
- &._required {
- &::before {
- content: "";
- margin-right: 0rpx;
- }
- }
- }
- }
- .image-upload {
- .upload-tip {
- font-size: 24rpx;
- color: var(--text-02);
- }
- }
- .popup-footer {
- padding: 24rpx 32rpx;
- .btn-group {
- display: flex;
- gap: 16rpx;
- .btn {
- flex: 1;
- height: 88rpx;
- border-radius: 16rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 28rpx;
- font-weight: 600;
- }
- .cancel-btn {
- background: #f5f5f5;
- color: var(--text);
- }
- .submit-btn {
- background: var(--black);
- color: var(--light);
- &.disabled {
- background: #ccc;
- color: #999;
- }
- }
- }
- }
- </style>
|