|
|
@@ -5,8 +5,13 @@ Page({
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
- orderItemInfo: [], //订单列表页参数
|
|
|
- submitCommCount:0 //已经提交的评论数量
|
|
|
+ orderItemInfo: {
|
|
|
+ images: [],
|
|
|
+ content: "",
|
|
|
+ score: 5,
|
|
|
+ isAnonymous: 1,
|
|
|
+ evaluate: 0,
|
|
|
+ }, //订单列表页参数
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
@@ -14,43 +19,35 @@ Page({
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
// 获取上页(订单列表)数据
|
|
|
- var orderItemInfo = wx.getStorageSync("orderItemInfo");
|
|
|
- // console.log(orderItemInfo);
|
|
|
- for (var i = 0; i < orderItemInfo.length; i++){
|
|
|
- orderItemInfo[i].images = [];
|
|
|
- orderItemInfo[i].content = "";
|
|
|
- orderItemInfo[i].score = 5;
|
|
|
- orderItemInfo[i].isAnonymous = 1;
|
|
|
- orderItemInfo[i].evaluate = 0;
|
|
|
- }
|
|
|
- this.setData({
|
|
|
- orderItemInfo: orderItemInfo
|
|
|
- })
|
|
|
- console.log(orderItemInfo)
|
|
|
+ // var orderItemInfo = wx.getStorageSync("orderItemInfo");
|
|
|
+ // // console.log(orderItemInfo);
|
|
|
+ // for (var i = 0; i < orderItemInfo.length; i++){
|
|
|
+ // orderItemInfo[i].images = [];
|
|
|
+ // orderItemInfo[i].content = "";
|
|
|
+ // orderItemInfo[i].score = 5;
|
|
|
+ // orderItemInfo[i].isAnonymous = 1;
|
|
|
+ // orderItemInfo[i].evaluate = 0;
|
|
|
+ // }
|
|
|
+ // this.setData({
|
|
|
+ // orderItemInfo: orderItemInfo
|
|
|
+ // })
|
|
|
+ // console.log(orderItemInfo)
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 发表评论
|
|
|
*/
|
|
|
submitComm: function (e) {
|
|
|
- var orderItemInfo = this.data.orderItemInfo;
|
|
|
- var allFill = true;
|
|
|
- for (var i = 0; i < orderItemInfo.length; i++) {
|
|
|
- var cont = orderItemInfo[i].content.trim();
|
|
|
- if(cont==""){
|
|
|
- wx.showToast({
|
|
|
- title: '评价不能为空',
|
|
|
- icon:"none"
|
|
|
- })
|
|
|
- allFill = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (allFill){
|
|
|
- for (var i = 0; i < orderItemInfo.length; i++) {
|
|
|
+ var orderItemInfo = this.data.orderItemInfo;
|
|
|
+ if(orderItemInfo.content.trim()==""){
|
|
|
+ return wx.showToast({
|
|
|
+ title: '评价不能为空',
|
|
|
+ icon:"none"
|
|
|
+ })
|
|
|
+ }
|
|
|
wx.showLoading();
|
|
|
var pics = '';
|
|
|
- orderItemInfo[i].images.forEach(function(item){
|
|
|
+ orderItemInfo.images.forEach(function(item){
|
|
|
pics += item.path + ',';
|
|
|
});
|
|
|
if(pics!=''){
|
|
|
@@ -61,36 +58,24 @@ Page({
|
|
|
url: "/p/prodComm",
|
|
|
method: "POST",
|
|
|
data: {
|
|
|
- content: orderItemInfo[i].content,
|
|
|
- score: orderItemInfo[i].score,
|
|
|
- evaluate: orderItemInfo[i].evaluate,
|
|
|
- isAnonymous: orderItemInfo[i].isAnonymous,
|
|
|
- orderItemId: orderItemInfo[i].orderItemId,
|
|
|
- prodId: orderItemInfo[i].prodId,
|
|
|
+ content: orderItemInfo.content,
|
|
|
+ score: orderItemInfo.score,
|
|
|
+ evaluate: orderItemInfo.evaluate,
|
|
|
+ isAnonymous: orderItemInfo.isAnonymous,
|
|
|
+ orderItemId: orderItemInfo.orderItemId,
|
|
|
+ prodId: orderItemInfo.prodId,
|
|
|
pics: pics
|
|
|
},
|
|
|
callBack: (res) => {
|
|
|
- this.setData({
|
|
|
- submitCommCount: this.data.submitCommCount+1
|
|
|
- });
|
|
|
- if (this.data.submitCommCount == orderItemInfo.length) {
|
|
|
- wx.showModal({
|
|
|
- title: '',
|
|
|
- content: '评价成功,感谢您!',
|
|
|
- showCancel:false,
|
|
|
- success(res) {
|
|
|
- wx.navigateBack();
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+
|
|
|
wx.hideLoading();
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pages/commResult/commResult',
|
|
|
+ })
|
|
|
}
|
|
|
};
|
|
|
http.request(params);
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
- }
|
|
|
},
|
|
|
|
|
|
|
|
|
@@ -98,8 +83,6 @@ Page({
|
|
|
* 上传图片
|
|
|
*/
|
|
|
getUploadImg: function(e) {
|
|
|
- const idx = e.target.dataset.idx
|
|
|
- console.log(idx);
|
|
|
var ths = this;
|
|
|
wx.chooseImage({
|
|
|
count: 1, // 默认9
|
|
|
@@ -120,7 +103,7 @@ Page({
|
|
|
img.path = JSON.parse(res2).filePath;
|
|
|
img.url = JSON.parse(res2).resourcesUrl + JSON.parse(res2).filePath;
|
|
|
var orderItemInfo = ths.data.orderItemInfo;
|
|
|
- orderItemInfo[idx].images.push(img);
|
|
|
+ orderItemInfo.images.push(img);
|
|
|
ths.setData({
|
|
|
orderItemInfo: orderItemInfo
|
|
|
})
|
|
|
@@ -136,9 +119,8 @@ Page({
|
|
|
*/
|
|
|
removeImage(e) {
|
|
|
const idx = e.target.dataset.idx
|
|
|
- const index = e.target.dataset.index
|
|
|
var orderItemInfo = this.data.orderItemInfo;
|
|
|
- orderItemInfo[index].images.splice(idx, 1)
|
|
|
+ orderItemInfo.images.splice(idx, 1)
|
|
|
this.setData({
|
|
|
orderItemInfo: orderItemInfo
|
|
|
});
|
|
|
@@ -147,7 +129,7 @@ Page({
|
|
|
onContentInput:function(e){
|
|
|
const index = e.target.dataset.index
|
|
|
var orderItemInfo = this.data.orderItemInfo;
|
|
|
- orderItemInfo[index].content = e.detail.value;
|
|
|
+ orderItemInfo.content = e.detail.value;
|
|
|
this.setData({
|
|
|
orderItemInfo: orderItemInfo
|
|
|
});
|
|
|
@@ -159,15 +141,14 @@ Page({
|
|
|
* 每一项的选择事件
|
|
|
*/
|
|
|
onSelectedItem: function (e) {
|
|
|
- var index = e.target.dataset.index;// 获取data- 传进来的index
|
|
|
var orderItemInfo = this.data.orderItemInfo;// 获取评论项
|
|
|
- var isAnonymous = orderItemInfo[index].isAnonymous; // 获取当前评价的选中状态
|
|
|
+ var isAnonymous = orderItemInfo.isAnonymous; // 获取当前评价的选中状态
|
|
|
if (isAnonymous==1){
|
|
|
isAnonymous = 0;
|
|
|
}else{
|
|
|
isAnonymous = 1;
|
|
|
}
|
|
|
- orderItemInfo[index].isAnonymous = isAnonymous; // 改变状态
|
|
|
+ orderItemInfo.isAnonymous = isAnonymous; // 改变状态
|
|
|
this.setData({
|
|
|
orderItemInfo: orderItemInfo
|
|
|
});
|
|
|
@@ -176,6 +157,7 @@ Page({
|
|
|
onStarChange:function(e){
|
|
|
var index = e.detail.idx;
|
|
|
var val = e.detail.val;
|
|
|
+ console.log(e);
|
|
|
var evaluate = 0;
|
|
|
var orderItemInfo = this.data.orderItemInfo;
|
|
|
if(val<3){
|
|
|
@@ -183,8 +165,8 @@ Page({
|
|
|
}else if(val==3){
|
|
|
evaluate = 1;
|
|
|
}
|
|
|
- orderItemInfo[index].score = val;
|
|
|
- orderItemInfo[index].evaluate = evaluate;
|
|
|
+ orderItemInfo.score = val;
|
|
|
+ orderItemInfo.evaluate = evaluate;
|
|
|
this.setData({
|
|
|
orderItemInfo: orderItemInfo
|
|
|
});
|
|
|
@@ -195,10 +177,9 @@ Page({
|
|
|
* 评价图片预览
|
|
|
*/
|
|
|
comPicPreView(e){
|
|
|
- var index = e.currentTarget.dataset.index
|
|
|
var idx = e.currentTarget.dataset.idx
|
|
|
var urls = []
|
|
|
- this.data.orderItemInfo[index].images.forEach(el => {
|
|
|
+ this.data.orderItemInfo.images.forEach(el => {
|
|
|
urls.push(el.url)
|
|
|
})
|
|
|
wx.previewImage({
|