diff --git a/pages/goods/comments/components/comments-card/components/images-videos/index.wxml b/pages/goods/comments/components/comments-card/components/images-videos/index.wxml
index a7aefd2..cd185bb 100644
--- a/pages/goods/comments/components/comments-card/components/images-videos/index.wxml
+++ b/pages/goods/comments/components/comments-card/components/images-videos/index.wxml
@@ -5,9 +5,9 @@
wx:for-item="resource"
wx:key="*this"
>
-
+
-
+
diff --git a/pages/goods/comments/create/index.js b/pages/goods/comments/create/index.js
index 5296bc3..e3a1296 100644
--- a/pages/goods/comments/create/index.js
+++ b/pages/goods/comments/create/index.js
@@ -1,5 +1,12 @@
// import { getCommentDetail } from '../../../../services/good/comments/fetchCommentDetail';
import Toast from 'tdesign-miniprogram/toast/index';
+import {
+ ServerBasePath
+} from '~/app'
+import {
+ addComment
+} from '~/services/order/addComment';
+
Page({
data: {
serviceRateValue: 1,
@@ -13,16 +20,21 @@ Page({
column: 3,
},
isAllowedSubmit: false,
+ orderGuid: 0,
+ goodsGuid: 0,
imgUrl: '',
title: '',
goodsDetail: '',
imageProps: {
mode: 'aspectFit',
},
+ textAreaValue: ""
},
onLoad(options) {
this.setData({
+ orderGuid: options.orderGuid,
+ goodsGuid: options.goodsGuid,
imgUrl: options.imgUrl,
title: options.title,
goodsDetail: options.specs,
@@ -30,20 +42,28 @@ Page({
},
onRateChange(e) {
- const { value } = e?.detail;
+ const {
+ value
+ } = e?.detail;
const item = e?.currentTarget?.dataset?.item;
- this.setData({ [item]: value }, () => {
+ this.setData({
+ [item]: value
+ }, () => {
this.updateButtonStatus();
});
},
onAnonymousChange(e) {
const status = !!e?.detail?.checked;
- this.setData({ isAnonymous: status });
+ this.setData({
+ isAnonymous: status
+ });
},
handleSuccess(e) {
- const { files } = e.detail;
+ const {
+ files
+ } = e.detail;
this.setData({
uploadFiles: files,
@@ -51,8 +71,12 @@ Page({
},
handleRemove(e) {
- const { index } = e.detail;
- const { uploadFiles } = this.data;
+ const {
+ index
+ } = e.detail;
+ const {
+ uploadFiles
+ } = this.data;
uploadFiles.splice(index, 1);
this.setData({
uploadFiles,
@@ -61,26 +85,125 @@ Page({
onTextAreaChange(e) {
const value = e?.detail?.value;
- this.textAreaValue = value;
+ this.setData({
+ textAreaValue: value
+ })
this.updateButtonStatus();
},
updateButtonStatus() {
- const { serviceRateValue, goodRateValue, conveyRateValue, isAllowedSubmit } = this.data;
- const { textAreaValue } = this;
+ const {
+ serviceRateValue,
+ goodRateValue,
+ conveyRateValue,
+ isAllowedSubmit
+ } = this.data;
+ const {
+ textAreaValue
+ } = this.data;
const temp = serviceRateValue && goodRateValue && conveyRateValue && textAreaValue;
- if (temp !== isAllowedSubmit) this.setData({ isAllowedSubmit: temp });
+ if (temp !== isAllowedSubmit) this.setData({
+ isAllowedSubmit: temp
+ });
},
- onSubmitBtnClick() {
- const { isAllowedSubmit } = this.data;
- if (!isAllowedSubmit) return;
- Toast({
- context: this,
- selector: '#t-toast',
- message: '评价提交成功',
- icon: 'check-circle',
- });
- wx.navigateBack();
+ // 上传图片
+ handleAddPic(e) {
+ const {
+ files
+ } = e.detail;
+
+ // 每次选择图片都上传,展示每次上传图片的进度
+ files.forEach(file => this.onUploadPic(file))
},
-});
+
+ // 移除Pic
+ handleRemovePic(e) {
+ const {
+ index
+ } = e.detail;
+ const {
+ uploadFiles
+ } = this.data;
+
+ uploadFiles.splice(index, 1);
+ this.setData({
+ uploadFiles: uploadFiles,
+ });
+ },
+
+ // 上传图片方法
+ onUploadPic(file) {
+ let {
+ uploadFiles
+ } = this.data
+
+ this.setData({
+ uploadFiles : [...uploadFiles, {
+ ...file,
+ status: 'loading'
+ }],
+ });
+ const {
+ length
+ } = uploadFiles;
+
+ const task = wx.uploadFile({
+ url: ServerBasePath + 'Common/UploadFile', // 仅为示例,非真实的接口地址
+ filePath: file.url,
+ name: 'file',
+ formData: {
+ fileDir: 'Shops'
+ },
+ success: (res) => {
+ this.setData({
+ [`uploadFiles[${length}].url`]: JSON.parse(res.data).data.url,
+ [`uploadFiles[${length}].status`]: 'done',
+ });
+ // this.triggerEventToParent()
+ },
+ });
+ task.onProgressUpdate((res) => {
+ this.setData({
+ [`uploadFiles[${length}].percent`]: res.progress,
+ });
+ });
+ },
+
+
+ // 提交
+ onSubmitBtnClick() {
+ // goodRateValue 评分
+ // textAreaValue 评价内容
+ // uploadFiles 评价图片
+ const {
+ orderGuid,
+ goodsGuid,
+ goodRateValue,
+ textAreaValue,
+ uploadFiles,
+ isAllowedSubmit
+ } = this.data;
+ let data = {
+ orderGuid: orderGuid,
+ goodsGuid: goodsGuid,
+ GoodsCommentRating: goodRateValue,
+ GoodsCommentContent: textAreaValue,
+ GoodsCommentImages: uploadFiles.map(item => item.url).join(','),
+ }
+ if (!isAllowedSubmit) return;
+
+ addComment(data).then((res) =>{
+ if(res.code === 200){
+ Toast({
+ context: this,
+ selector: '#t-toast',
+ message: '评价提交成功',
+ icon: 'check-circle',
+ });
+ wx.navigateBack();
+ }
+ })
+
+ },
+});
\ No newline at end of file
diff --git a/pages/goods/comments/create/index.wxml b/pages/goods/comments/create/index.wxml
index 5009beb..a22df03 100644
--- a/pages/goods/comments/create/index.wxml
+++ b/pages/goods/comments/create/index.wxml
@@ -2,7 +2,8 @@