小程序订单评论
parent
38643907e2
commit
8d85440f52
|
|
@ -12,6 +12,7 @@ namespace app\api\controller;
|
|||
|
||||
use app\service\PaymentService;
|
||||
use app\service\OrderService;
|
||||
use app\service\GoodsCommentsService;
|
||||
|
||||
/**
|
||||
* 我的订单
|
||||
|
|
@ -152,7 +153,18 @@ class Order extends Common
|
|||
$data = OrderService::OrderList($data_params);
|
||||
if(!empty($data['data'][0]))
|
||||
{
|
||||
return DataReturn('success', 0, $data['data'][0]);
|
||||
// 是否已评论
|
||||
if($data['data'][0]['user_is_comments'] > 0)
|
||||
{
|
||||
return DataReturn('你已进行过评论', -100);
|
||||
}
|
||||
|
||||
// 返回数据
|
||||
$result = [
|
||||
'data' => $data['data'][0],
|
||||
'editor_path_type' => 'order_comments-'.$this->user['id'].'-'.$data['data'][0]['id'],
|
||||
];
|
||||
return DataReturn('success', 0, $result);
|
||||
}
|
||||
return DataReturn('没有相关数据', -100);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ class Orderaftersale extends Common
|
|||
'return_money_goods_reason' => empty($return_money_goods_reason) ? [] : explode("\n", $return_money_goods_reason),
|
||||
'aftersale_type_list' => lang('common_order_aftersale_type_list'),
|
||||
'return_goods_address' => MyC('home_order_aftersale_return_goods_address', '管理员未填写', true),
|
||||
'editor_path_type' => 'orderaftersale-'.$this->user['id'].'-'.$order_id.'-'.$order_detail_id,
|
||||
'editor_path_type' => 'order_aftersale-'.$this->user['id'].'-'.$order_id.'-'.$order_detail_id,
|
||||
];
|
||||
return DataReturn('success', 0, $result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ class Orderaftersale extends Common
|
|||
$this->assign('common_order_aftersale_type_list', lang('common_order_aftersale_type_list'));
|
||||
|
||||
// 编辑器文件存放地址
|
||||
$this->assign('editor_path_type', 'orderaftersale-'.$this->user['id'].'-'.$order_id.'-'.$order_detail_id);
|
||||
$this->assign('editor_path_type', 'order_aftersale-'.$this->user['id'].'-'.$order_id.'-'.$order_detail_id);
|
||||
|
||||
$this->assign('params', $params);
|
||||
return $this->fetch();
|
||||
|
|
|
|||
|
|
@ -65,6 +65,21 @@ class ArticleService
|
|||
{
|
||||
$v['content'] = ResourcesService::ContentStaticReplace($v['content'], 'get');
|
||||
}
|
||||
|
||||
// 图片
|
||||
if(isset($v['images']))
|
||||
{
|
||||
if(!empty($v['images']))
|
||||
{
|
||||
$images = json_decode($v['images'], true);
|
||||
foreach($images as &$img)
|
||||
{
|
||||
$img = ResourcesService::AttachmentPathViewHandle($img);
|
||||
}
|
||||
$v['images'] = $images;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($v['add_time']))
|
||||
{
|
||||
$v['add_time_time'] = date('Y-m-d H:i:s', $v['add_time']);
|
||||
|
|
@ -214,15 +229,15 @@ class ArticleService
|
|||
$content = isset($params['content']) ? htmlspecialchars_decode($params['content']) : '';
|
||||
|
||||
// 数据
|
||||
$image = self::MatchContentImage($content);
|
||||
$images = self::MatchContentImage($content);
|
||||
$data = [
|
||||
'title' => $params['title'],
|
||||
'title_color' => empty($params['title_color']) ? '' : $params['title_color'],
|
||||
'article_category_id' => intval($params['article_category_id']),
|
||||
'jump_url' => empty($params['jump_url']) ? '' : $params['jump_url'],
|
||||
'content' => ResourcesService::ContentStaticReplace($content, 'add'),
|
||||
'image' => empty($image) ? '' : json_encode($image),
|
||||
'image_count' => count($image),
|
||||
'images' => empty($images) ? '' : json_encode($images),
|
||||
'images_count' => count($images),
|
||||
'is_enable' => isset($params['is_enable']) ? intval($params['is_enable']) : 0,
|
||||
'is_home_recommended' => isset($params['is_home_recommended']) ? intval($params['is_home_recommended']) : 0,
|
||||
'seo_title' => empty($params['seo_title']) ? '' : $params['seo_title'],
|
||||
|
|
|
|||
|
|
@ -56,6 +56,20 @@ class CustomViewService
|
|||
$v['content'] = ResourcesService::ContentStaticReplace($v['content'], 'get');
|
||||
}
|
||||
|
||||
// 图片
|
||||
if(isset($v['images']))
|
||||
{
|
||||
if(!empty($v['images']))
|
||||
{
|
||||
$images = json_decode($v['images'], true);
|
||||
foreach($images as &$img)
|
||||
{
|
||||
$img = ResourcesService::AttachmentPathViewHandle($img);
|
||||
}
|
||||
$v['images'] = $images;
|
||||
}
|
||||
}
|
||||
|
||||
// 时间
|
||||
if(isset($v['add_time']))
|
||||
{
|
||||
|
|
@ -198,12 +212,12 @@ class CustomViewService
|
|||
$content = isset($params['content']) ? htmlspecialchars_decode($params['content']) : '';
|
||||
|
||||
// 数据
|
||||
$image = self::MatchContentImage($content);
|
||||
$images = self::MatchContentImage($content);
|
||||
$data = [
|
||||
'title' => $params['title'],
|
||||
'content' => ResourcesService::ContentStaticReplace($content, 'add'),
|
||||
'image' => empty($image) ? '' : json_encode($image),
|
||||
'image_count' => count($image),
|
||||
'images' => empty($images) ? '' : json_encode($images),
|
||||
'images_count' => count($images),
|
||||
'is_enable' => isset($params['is_enable']) ? intval($params['is_enable']) : 0,
|
||||
'is_header' => isset($params['is_header']) ? intval($params['is_header']) : 0,
|
||||
'is_footer' => isset($params['is_footer']) ? intval($params['is_footer']) : 0,
|
||||
|
|
|
|||
|
|
@ -47,35 +47,20 @@ class GoodsCommentsService
|
|||
'error_msg' => '业务类型标记不能为空',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'isset',
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'goods_id',
|
||||
'error_msg' => '商品id有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'is_array',
|
||||
'key_name' => 'goods_id',
|
||||
'error_msg' => '商品数据格式有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'isset',
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'rating',
|
||||
'error_msg' => '评级有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'is_array',
|
||||
'key_name' => 'rating',
|
||||
'error_msg' => '评级数据格式有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'isset',
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'content',
|
||||
'error_msg' => '评论内容有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'is_array',
|
||||
'key_name' => 'content',
|
||||
'error_msg' => '评论内容数据格式有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'user',
|
||||
|
|
@ -88,6 +73,63 @@ class GoodsCommentsService
|
|||
return DataReturn($ret, -1);
|
||||
}
|
||||
|
||||
// 参数处理
|
||||
if(!is_array($params['goods_id']))
|
||||
{
|
||||
$params['goods_id'] = json_decode(htmlspecialchars_decode($params['goods_id']), true);
|
||||
}
|
||||
if(!is_array($params['rating']))
|
||||
{
|
||||
$params['rating'] = json_decode(htmlspecialchars_decode($params['rating']), true);
|
||||
}
|
||||
if(!is_array($params['content']))
|
||||
{
|
||||
$params['content'] = json_decode(htmlspecialchars_decode($params['content']), true);
|
||||
}
|
||||
|
||||
// 评分
|
||||
if(min($params['rating']) <= 0)
|
||||
{
|
||||
return DataReturn('评级有误', -1);
|
||||
}
|
||||
if(min($params['rating']) <= 0 || max($params['rating']) > 5)
|
||||
{
|
||||
return DataReturn('评级有误', -1);
|
||||
}
|
||||
|
||||
// 评论内容
|
||||
foreach($params['content'] as $v)
|
||||
{
|
||||
$len = mb_strlen($v, 'utf-8');
|
||||
if($len < 6 || $len > 230)
|
||||
{
|
||||
return DataReturn('评论内容 6~230 个字符之间', -1);
|
||||
}
|
||||
}
|
||||
|
||||
// 附件处理
|
||||
if(!empty($params['images']))
|
||||
{
|
||||
if(!is_array($params['images']))
|
||||
{
|
||||
$params['images'] = json_decode(htmlspecialchars_decode($params['images']), true);
|
||||
}
|
||||
foreach($params['images'] as &$v)
|
||||
{
|
||||
if(!empty($v))
|
||||
{
|
||||
foreach($v as &$vs)
|
||||
{
|
||||
$vs = ResourcesService::AttachmentPathHandle($vs);
|
||||
}
|
||||
if(count($v) > 3)
|
||||
{
|
||||
return DataReturn('每项评论图片不能超过3张', -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取订单信息
|
||||
$order_id = intval($params['id']);
|
||||
$where = ['id'=>$order_id, 'user_id'=>$params['user']['id'], 'is_delete_time'=>0, 'user_is_delete_time'=>0];
|
||||
|
|
@ -108,6 +150,7 @@ class GoodsCommentsService
|
|||
|
||||
// 处理数据
|
||||
Db::startTrans();
|
||||
$is_anonymous = isset($params['is_anonymous']) ? min(1, intval($params['is_anonymous'])) : 0;
|
||||
foreach($params['goods_id'] as $k=>$goods_id)
|
||||
{
|
||||
$data = [
|
||||
|
|
@ -117,8 +160,9 @@ class GoodsCommentsService
|
|||
'goods_id' => $goods_id,
|
||||
'business_type' => $params['business_type'],
|
||||
'content' => isset($params['content'][$k]) ? htmlspecialchars(trim($params['content'][$k])) : '',
|
||||
'images' => empty($params['images'][$k]) ? '' : json_encode($params['images'][$k]),
|
||||
'rating' => isset($params['rating'][$k]) ? intval($params['rating'][$k]) : 0,
|
||||
'is_anonymous' => isset($params['is_anonymous']) ? min(1, intval($params['is_anonymous'])) : 0,
|
||||
'is_anonymous' => $is_anonymous,
|
||||
'add_time' => time(),
|
||||
];
|
||||
if(Db::name('GoodsComments')->insertGetId($data) <= 0)
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ App({
|
|||
"goods_comment": "商品评论",
|
||||
"user_orderaftersale": "退款/售后",
|
||||
"user_orderaftersale_detail": "订单售后",
|
||||
"user_order_comments": "订单评论",
|
||||
},
|
||||
|
||||
// 请求地址
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
"pages/user-address-save/user-address-save",
|
||||
"pages/user-order/user-order",
|
||||
"pages/user-order-detail/user-order-detail",
|
||||
"pages/user-order-comments/user-order-comments",
|
||||
"pages/user-faovr/user-faovr",
|
||||
"pages/user-answer-list/user-answer-list",
|
||||
"pages/answer-list/answer-list",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
<view wx:if="{{detail != null}}">
|
||||
<form bindsubmit="formSubmit" class="form-container">
|
||||
<view wx:for="{{detail.items}}" wx:key="item" class="form-gorup bg-white oh">
|
||||
<view class="oh">
|
||||
<navigator url="/pages/goods-detail/goods-detail?goods_id={{item.goods_id}}" hover-class="none">
|
||||
<image class="goods-image fl br" src="{{item.images}}" mode="aspectFill" />
|
||||
</navigator>
|
||||
<view class="item-base">
|
||||
<block wx:for="{{[1,2,3,4,5]}}" wx:key="tx" wx:for-index="tx">
|
||||
<image class="xingxing-icon" src="/images/default-xingxing-icon{{form_rating_list[index] != undefined && form_rating_list[index] >= item ? '-active' : ''}}.png" mode="aspectFill" bindtap="rating_event" data-index="{{index}}" data-value="{{item}}" />
|
||||
</block>
|
||||
<text wx:if="{{form_rating_list[index] != undefined}}" class="msg-text cr-888">{{rating_msg[form_rating_list[index]-1]}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="form-content">
|
||||
<textarea bindinput="form_content_event" data-index="{{index}}" placeholder-class="cr-ccc" class="cr-666" placeholder="退宝贝满足你的期待吗?说说它的有点和美中不足的地方吧" maxlength="230" value="{{form_msg}}" />
|
||||
<view class="form-container-upload oh">
|
||||
<view class="form-upload-data fl">
|
||||
<block wx:if="{{(form_images_list[index] || null) != null && form_images_list[index].length > 0}}">
|
||||
<view wx:for="{{form_images_list[index]}}" wx:key="item" wx:for-index="ix" class="item fl">
|
||||
<text class="delete-icon" bindtap="upload_delete_event" data-index="{{index}}" data-ix="{{ix}}">x</text>
|
||||
<image src="{{item}}" bindtap="upload_show_event" data-index="{{index}}" data-ix="{{ix}}" mode="aspectFill" />
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
<image wx:if="{{(form_images_list[index] || null) == null || form_images_list[index].length < 3}}" class="upload-icon" src="/images/default-upload-icon.png" mode="aspectFill" bindtap="file_upload_event" data-index="{{index}}" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="form-gorup bg-white anonymous">
|
||||
<switch name="is_anonymous" bindchange="anonymous_event" />
|
||||
<text class="cr-666">匿名</text>
|
||||
<text class="fr cr-888 tips-text">{{anonymous_msg_list[anonymous_value]}}</text>
|
||||
</view>
|
||||
|
||||
<view class="form-gorup">
|
||||
<button formType="submit" class="bg-main submit-bottom" type="default" hover-class="none" disabled="{{form_button_disabled}}">提交</button>
|
||||
</view>
|
||||
</form>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{detail == null}}">
|
||||
<import src="/pages/common/nodata.wxml" />
|
||||
<template is="nodata" data="{{status: data_list_loding_status, msg: data_list_loding_msg}}"></template>
|
||||
</view>
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
.goods-image {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
.item-base {
|
||||
margin: 10rpx 0 0 100rpx;
|
||||
}
|
||||
.item-base .xingxing-icon {
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
margin: 0 15rpx;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.item-base .msg-text {
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
.form-content {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
.form-content textarea {
|
||||
height: 160rpx !important;
|
||||
min-height: 160rpx !important;
|
||||
}
|
||||
.form-container-upload {
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
.form-container-upload .form-upload-data image {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
padding: 5rpx;
|
||||
}
|
||||
.form-container-upload .upload-icon {
|
||||
margin: 10rpx 0 0 10rpx;
|
||||
width: 110rpx;
|
||||
height: 110rpx;
|
||||
}
|
||||
.anonymous .tips-text {
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
|
@ -0,0 +1,321 @@
|
|||
const app = getApp();
|
||||
Page({
|
||||
data: {
|
||||
data_list_loding_status: 1,
|
||||
data_list_loding_msg: '',
|
||||
params: null,
|
||||
|
||||
detail: null,
|
||||
editor_path_type: '',
|
||||
rating_msg: ['非常差', '差', '一般', '好', '非常好'],
|
||||
anonymous_value: 0,
|
||||
anonymous_msg_list: ['你写的评论会以匿名的形式展现', '你写的评论会以昵称的形式展现'],
|
||||
|
||||
form_rating_list: [],
|
||||
form_images_list: [],
|
||||
form_content_list: [],
|
||||
form_button_disabled: false,
|
||||
},
|
||||
|
||||
onLoad(params) {
|
||||
this.setData({ params: params });
|
||||
this.init();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
wx.setNavigationBarTitle({ title: app.data.common_pages_title.user_order_comments });
|
||||
},
|
||||
|
||||
init() {
|
||||
var self = this;
|
||||
wx.showLoading({ title: "加载中..." });
|
||||
this.setData({
|
||||
data_list_loding_status: 1
|
||||
});
|
||||
|
||||
wx.request({
|
||||
url: app.get_request_url("comments", "order"),
|
||||
method: "POST",
|
||||
data: {
|
||||
id: this.data.params.id
|
||||
},
|
||||
dataType: "json",
|
||||
success: res => {
|
||||
wx.hideLoading();
|
||||
wx.stopPullDownRefresh();
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
self.setData({
|
||||
editor_path_type: data.editor_path_type || '',
|
||||
detail: data.data,
|
||||
data_list_loding_status: 3,
|
||||
data_list_loding_msg: '',
|
||||
});
|
||||
} else {
|
||||
self.setData({
|
||||
data_list_loding_status: 2,
|
||||
data_list_loding_msg: res.data.msg,
|
||||
});
|
||||
app.showToast(res.data.msg);
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
wx.hideLoading();
|
||||
wx.stopPullDownRefresh();
|
||||
self.setData({
|
||||
data_list_loding_status: 2,
|
||||
data_list_loding_msg: '服务器请求出错',
|
||||
});
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 上传图片预览
|
||||
upload_show_event(e) {
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var ix = e.currentTarget.dataset.ix;
|
||||
wx.previewImage({
|
||||
current: this.data.form_images_list[index][ix],
|
||||
urls: this.data.form_images_list[index],
|
||||
});
|
||||
},
|
||||
|
||||
// 图片删除
|
||||
upload_delete_event(e) {
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var ix = e.currentTarget.dataset.ix;
|
||||
var self = this;
|
||||
wx.showModal({
|
||||
title: '温馨提示',
|
||||
content: '删除后不可恢复、继续吗?',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
var list = self.data.form_images_list;
|
||||
list[index].splice(ix, 1);
|
||||
self.setData({
|
||||
form_images_list: list,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 文件上传
|
||||
file_upload_event(e) {
|
||||
// 数据初始化
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var temp_list = this.data.form_images_list;
|
||||
var length = this.data.detail.items.length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (temp_list[i] == undefined) {
|
||||
temp_list[i] = [];
|
||||
}
|
||||
}
|
||||
this.setData({ form_images_list: temp_list});
|
||||
|
||||
// 处理上传文件
|
||||
var self = this;
|
||||
wx.chooseImage({
|
||||
count: 3,
|
||||
success(res) {
|
||||
var success = 0;
|
||||
var fail = 0;
|
||||
var length = res.tempFilePaths.length;
|
||||
var count = 0;
|
||||
self.upload_one_by_one(index, res.tempFilePaths, success, fail, count, length);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 采用递归的方式上传多张
|
||||
upload_one_by_one(index, img_paths, success, fail, count, length) {
|
||||
var self = this;
|
||||
if ((self.data.form_images_list[index] || null) == null || self.data.form_images_list[index].length < 3) {
|
||||
wx.uploadFile({
|
||||
url: app.get_request_url("index", "ueditor"),
|
||||
filePath: img_paths[count],
|
||||
name: 'upfile',
|
||||
formData: {
|
||||
action: 'uploadimage',
|
||||
path_type: self.data.editor_path_type
|
||||
},
|
||||
success: function (res) {
|
||||
success++;
|
||||
if (res.statusCode == 200) {
|
||||
var data = (typeof (res.data) == 'object') ? res.data : JSON.parse(res.data);
|
||||
if (data.code == 0 && (data.data.url || null) != null) {
|
||||
var list = self.data.form_images_list;
|
||||
if ((list[index] || null) == null)
|
||||
{
|
||||
list[index] = [];
|
||||
}
|
||||
list[index].push(data.data.url);
|
||||
self.setData({ form_images_list: list });
|
||||
} else {
|
||||
app.showToast(data.msg);
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: function (e) {
|
||||
fail++;
|
||||
},
|
||||
complete: function (e) {
|
||||
count++; // 下一张
|
||||
if (count >= length) {
|
||||
// 上传完毕,作一下提示
|
||||
//app.showToast('上传成功' + success +'张', 'success');
|
||||
} else {
|
||||
// 递归调用,上传下一张
|
||||
self.upload_one_by_one(index, img_paths, success, fail, count, length);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 是否匿名事件
|
||||
anonymous_event(e) {
|
||||
this.setData({ anonymous_value: e.detail.value == true ? 1 : 0});
|
||||
},
|
||||
|
||||
// 评分事件
|
||||
rating_event(e) {
|
||||
// 参数
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var value = e.currentTarget.dataset.value;
|
||||
|
||||
// 数据初始化/赋值
|
||||
var temp_list = this.data.form_rating_list;
|
||||
var length = this.data.detail.items.length;
|
||||
for(var i=0; i<length; i++)
|
||||
{
|
||||
if (temp_list[i] == undefined)
|
||||
{
|
||||
temp_list[i] = 0;
|
||||
}
|
||||
if(index == i)
|
||||
{
|
||||
temp_list[i] = value;
|
||||
}
|
||||
}
|
||||
this.setData({ form_rating_list: temp_list});
|
||||
},
|
||||
|
||||
// 评论内容
|
||||
form_content_event(e) {
|
||||
// 参数
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var value = e.detail.value;
|
||||
|
||||
// 数据初始化/赋值
|
||||
var temp_list = this.data.form_content_list;
|
||||
var length = this.data.detail.items.length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (temp_list[i] == undefined) {
|
||||
temp_list[i] = '';
|
||||
}
|
||||
if (index == i) {
|
||||
temp_list[i] = value;
|
||||
}
|
||||
}
|
||||
this.setData({
|
||||
form_content_list: temp_list
|
||||
});
|
||||
},
|
||||
|
||||
// 表单
|
||||
formSubmit(e) {
|
||||
// 商品数量
|
||||
var length = this.data.detail.items.length;
|
||||
|
||||
// 评分校验
|
||||
var count = this.data.form_rating_list.length;
|
||||
if (count < length)
|
||||
{
|
||||
app.showToast('请评分');
|
||||
return false;
|
||||
}
|
||||
var max = Math.max.apply(null, this.data.form_rating_list);
|
||||
var min = Math.min.apply(null, this.data.form_rating_list);
|
||||
if (min < 1 || max > 5)
|
||||
{
|
||||
app.showToast('评分有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 内容校验
|
||||
var count = this.data.form_content_list.length;
|
||||
if (count < length) {
|
||||
app.showToast('请填写评论内容');
|
||||
return false;
|
||||
}
|
||||
for (var i in this.data.form_content_list)
|
||||
{
|
||||
var count = this.data.form_content_list[i].length;
|
||||
if (count < 6 || count > 230)
|
||||
{
|
||||
app.showToast('评论内容 6~230 个字符之间');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 图片校验
|
||||
if (this.data.form_images_list.length > 0)
|
||||
{
|
||||
for (var i in this.data.form_images_list)
|
||||
{
|
||||
if (this.data.form_images_list[i].length > 3)
|
||||
{
|
||||
app.showToast('每项评论图片不能超过3张');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 表单数据
|
||||
var form_data = e.detail.value;
|
||||
form_data['is_anonymous'] = form_data['is_anonymous'] == true ? 1 : 0;
|
||||
form_data['id'] = this.data.detail.id;
|
||||
form_data['goods_id'] = JSON.stringify(this.data.detail.items.map(function (v) { return v.goods_id }));
|
||||
form_data['rating'] = JSON.stringify(this.data.form_rating_list);
|
||||
form_data['content'] = JSON.stringify(this.data.form_content_list);
|
||||
form_data['images'] = (this.data.form_images_list.length > 0) ? JSON.stringify(this.data.form_images_list) : '';
|
||||
|
||||
// 提交表单
|
||||
var self = this;
|
||||
wx.showLoading({ title: "处理中..." });
|
||||
self.setData({ form_button_disabled: true });
|
||||
wx.request({
|
||||
url: app.get_request_url("commentssave", "order"),
|
||||
method: "POST",
|
||||
data: form_data,
|
||||
dataType: "json",
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
wx.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
app.showToast(res.data.msg, "success");
|
||||
setTimeout(function () {
|
||||
wx.navigateBack();
|
||||
}, 2000);
|
||||
} else {
|
||||
self.setData({ form_button_disabled: false });
|
||||
app.showToast(res.data.msg);
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
wx.hideLoading();
|
||||
self.setData({ form_button_disabled: false });
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.init();
|
||||
},
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
|
|
@ -34,15 +34,12 @@
|
|||
</navigator>
|
||||
</view>
|
||||
<view class="item-describe tr cr-666">{{item.describe}}</view>
|
||||
<view a:if="{{item.status <= 3}}" class="item-operation tr br-t">
|
||||
<button a:if="{{item.status <= 1}}" class="submit-cancel" type="default" size="mini" onTap="cancel_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">取消
|
||||
</button>
|
||||
<button a:if="{{item.status == 1}}" class="submit-pay cr-666" type="default" size="mini" onTap="pay_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">支付
|
||||
</button>
|
||||
<button a:if="{{item.status == 2}}" class="submit-rush cr-666" type="default" size="mini" onTap="rush_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">催催
|
||||
</button>
|
||||
<button a:if="{{item.status == 3}}" class="submit-success cr-666" type="default" size="mini" onTap="collect_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">收货
|
||||
</button>
|
||||
<view a:if="{{item.status <= 3 || (item.status == 4 && item.user_is_comments == 0)}}" class="item-operation tr br-t">
|
||||
<button a:if="{{item.status <= 1}}" class="submit-cancel" type="default" size="mini" onTap="cancel_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">取消</button>
|
||||
<button a:if="{{item.status == 1}}" class="submit-pay cr-666" type="default" size="mini" onTap="pay_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">支付</button>
|
||||
<button a:if="{{item.status == 2}}" class="submit-rush cr-666" type="default" size="mini" onTap="rush_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">催催</button>
|
||||
<button a:if="{{item.status == 3}}" class="submit-success cr-666" type="default" size="mini" onTap="collect_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">收货</button>
|
||||
<button a:if="{{item.status == 4 && item.user_is_comments == 0}}" class="submit-success cr-666 br" type="default" size="mini" onTap="comments_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">评论</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@ Page({
|
|||
params: params,
|
||||
nav_status_index: nav_status_index,
|
||||
});
|
||||
this.init();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
my.setNavigationBar({title: app.data.common_pages_title.user_order});
|
||||
this.init();
|
||||
},
|
||||
|
||||
init() {
|
||||
|
|
@ -393,4 +393,11 @@ Page({
|
|||
url: "/pages/user-orderaftersale-detail/user-orderaftersale-detail?oid=" + oid+"&did="+did
|
||||
});
|
||||
},
|
||||
|
||||
// 订单评论
|
||||
comments_event(e) {
|
||||
my.navigateTo({
|
||||
url: "/pages/user-order-comments/user-order-comments?id=" + e.target.dataset.value
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ App({
|
|||
"goods_comment": "商品评论",
|
||||
"user_orderaftersale": "退款/售后",
|
||||
"user_orderaftersale_detail": "订单售后",
|
||||
"user_order_comments": "订单评论",
|
||||
},
|
||||
|
||||
// 请求地址
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
"pages/user-address-save/user-address-save",
|
||||
"pages/user-order/user-order",
|
||||
"pages/user-order-detail/user-order-detail",
|
||||
"pages/user-order-comments/user-order-comments",
|
||||
"pages/user-faovr/user-faovr",
|
||||
"pages/user-answer-list/user-answer-list",
|
||||
"pages/answer-list/answer-list",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
.goods-image {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
.item-base {
|
||||
margin: 10rpx 0 0 100rpx;
|
||||
}
|
||||
.item-base .xingxing-icon {
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
margin: 0 15rpx;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.item-base .msg-text {
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
.form-content {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
.form-content textarea {
|
||||
height: 160rpx !important;
|
||||
min-height: 160rpx !important;
|
||||
}
|
||||
.form-container-upload {
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
.form-container-upload .form-upload-data image {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
padding: 5rpx;
|
||||
}
|
||||
.form-container-upload .upload-icon {
|
||||
margin: 10rpx 0 0 10rpx;
|
||||
width: 110rpx;
|
||||
height: 110rpx;
|
||||
}
|
||||
.anonymous .tips-text {
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
|
@ -0,0 +1,311 @@
|
|||
const app = getApp();
|
||||
Page({
|
||||
data: {
|
||||
data_list_loding_status: 1,
|
||||
data_list_loding_msg: '',
|
||||
params: null,
|
||||
|
||||
detail: null,
|
||||
editor_path_type: '',
|
||||
rating_msg: ['非常差', '差', '一般', '好', '非常好'],
|
||||
anonymous_value: 0,
|
||||
anonymous_msg_list: ['你写的评论会以匿名的形式展现', '你写的评论会以昵称的形式展现'],
|
||||
|
||||
form_rating_list: [],
|
||||
form_images_list: [],
|
||||
form_content_list: [],
|
||||
form_button_disabled: false
|
||||
},
|
||||
|
||||
onLoad(params) {
|
||||
this.setData({ params: params });
|
||||
this.init();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
swan.setNavigationBarTitle({ title: app.data.common_pages_title.user_order_comments });
|
||||
},
|
||||
|
||||
init() {
|
||||
var self = this;
|
||||
swan.showLoading({ title: "加载中..." });
|
||||
this.setData({
|
||||
data_list_loding_status: 1
|
||||
});
|
||||
|
||||
swan.request({
|
||||
url: app.get_request_url("comments", "order"),
|
||||
method: "POST",
|
||||
data: {
|
||||
id: this.data.params.id
|
||||
},
|
||||
dataType: "json",
|
||||
success: res => {
|
||||
swan.hideLoading();
|
||||
swan.stopPullDownRefresh();
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
self.setData({
|
||||
editor_path_type: data.editor_path_type || '',
|
||||
detail: data.data,
|
||||
data_list_loding_status: 3,
|
||||
data_list_loding_msg: ''
|
||||
});
|
||||
} else {
|
||||
self.setData({
|
||||
data_list_loding_status: 2,
|
||||
data_list_loding_msg: res.data.msg
|
||||
});
|
||||
app.showToast(res.data.msg);
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
swan.hideLoading();
|
||||
swan.stopPullDownRefresh();
|
||||
self.setData({
|
||||
data_list_loding_status: 2,
|
||||
data_list_loding_msg: '服务器请求出错'
|
||||
});
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 上传图片预览
|
||||
upload_show_event(e) {
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var ix = e.currentTarget.dataset.ix;
|
||||
swan.previewImage({
|
||||
current: this.data.form_images_list[index][ix],
|
||||
urls: this.data.form_images_list[index]
|
||||
});
|
||||
},
|
||||
|
||||
// 图片删除
|
||||
upload_delete_event(e) {
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var ix = e.currentTarget.dataset.ix;
|
||||
var self = this;
|
||||
swan.showModal({
|
||||
title: '温馨提示',
|
||||
content: '删除后不可恢复、继续吗?',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
var list = self.data.form_images_list;
|
||||
list[index].splice(ix, 1);
|
||||
self.setData({
|
||||
form_images_list: list
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 文件上传
|
||||
file_upload_event(e) {
|
||||
// 数据初始化
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var temp_list = this.data.form_images_list;
|
||||
var length = this.data.detail.items.length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (temp_list[i] == undefined) {
|
||||
temp_list[i] = [];
|
||||
}
|
||||
}
|
||||
this.setData({ form_images_list: temp_list });
|
||||
|
||||
// 处理上传文件
|
||||
var self = this;
|
||||
swan.chooseImage({
|
||||
count: 3,
|
||||
success(res) {
|
||||
var success = 0;
|
||||
var fail = 0;
|
||||
var length = res.tempFilePaths.length;
|
||||
var count = 0;
|
||||
self.upload_one_by_one(index, res.tempFilePaths, success, fail, count, length);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 采用递归的方式上传多张
|
||||
upload_one_by_one(index, img_paths, success, fail, count, length) {
|
||||
var self = this;
|
||||
if ((self.data.form_images_list[index] || null) == null || self.data.form_images_list[index].length < 3) {
|
||||
swan.uploadFile({
|
||||
url: app.get_request_url("index", "ueditor"),
|
||||
filePath: img_paths[count],
|
||||
name: 'upfile',
|
||||
formData: {
|
||||
action: 'uploadimage',
|
||||
path_type: self.data.editor_path_type
|
||||
},
|
||||
success: function (res) {
|
||||
success++;
|
||||
if (res.statusCode == 200) {
|
||||
var data = typeof res.data == 'object' ? res.data : JSON.parse(res.data);
|
||||
if (data.code == 0 && (data.data.url || null) != null) {
|
||||
var list = self.data.form_images_list;
|
||||
if ((list[index] || null) == null) {
|
||||
list[index] = [];
|
||||
}
|
||||
list[index].push(data.data.url);
|
||||
self.setData({ form_images_list: list });
|
||||
} else {
|
||||
app.showToast(data.msg);
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: function (e) {
|
||||
fail++;
|
||||
},
|
||||
complete: function (e) {
|
||||
count++; // 下一张
|
||||
if (count >= length) {
|
||||
// 上传完毕,作一下提示
|
||||
//app.showToast('上传成功' + success +'张', 'success');
|
||||
} else {
|
||||
// 递归调用,上传下一张
|
||||
self.upload_one_by_one(index, img_paths, success, fail, count, length);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 是否匿名事件
|
||||
anonymous_event(e) {
|
||||
this.setData({ anonymous_value: e.detail.value == true ? 1 : 0 });
|
||||
},
|
||||
|
||||
// 评分事件
|
||||
rating_event(e) {
|
||||
// 参数
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var value = e.currentTarget.dataset.value;
|
||||
|
||||
// 数据初始化/赋值
|
||||
var temp_list = this.data.form_rating_list;
|
||||
var length = this.data.detail.items.length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (temp_list[i] == undefined) {
|
||||
temp_list[i] = 0;
|
||||
}
|
||||
if (index == i) {
|
||||
temp_list[i] = value;
|
||||
}
|
||||
}
|
||||
this.setData({ form_rating_list: temp_list });
|
||||
},
|
||||
|
||||
// 评论内容
|
||||
form_content_event(e) {
|
||||
// 参数
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var value = e.detail.value;
|
||||
|
||||
// 数据初始化/赋值
|
||||
var temp_list = this.data.form_content_list;
|
||||
var length = this.data.detail.items.length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (temp_list[i] == undefined) {
|
||||
temp_list[i] = '';
|
||||
}
|
||||
if (index == i) {
|
||||
temp_list[i] = value;
|
||||
}
|
||||
}
|
||||
this.setData({
|
||||
form_content_list: temp_list
|
||||
});
|
||||
},
|
||||
|
||||
// 表单
|
||||
formSubmit(e) {
|
||||
// 商品数量
|
||||
var length = this.data.detail.items.length;
|
||||
|
||||
// 评分校验
|
||||
var count = this.data.form_rating_list.length;
|
||||
if (count < length) {
|
||||
app.showToast('请评分');
|
||||
return false;
|
||||
}
|
||||
var max = Math.max.apply(null, this.data.form_rating_list);
|
||||
var min = Math.min.apply(null, this.data.form_rating_list);
|
||||
if (min < 1 || max > 5) {
|
||||
app.showToast('评分有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 内容校验
|
||||
var count = this.data.form_content_list.length;
|
||||
if (count < length) {
|
||||
app.showToast('请填写评论内容');
|
||||
return false;
|
||||
}
|
||||
for (var i in this.data.form_content_list) {
|
||||
var count = this.data.form_content_list[i].length;
|
||||
if (count < 6 || count > 230) {
|
||||
app.showToast('评论内容 6~230 个字符之间');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 图片校验
|
||||
if (this.data.form_images_list.length > 0) {
|
||||
for (var i in this.data.form_images_list) {
|
||||
if (this.data.form_images_list[i].length > 3) {
|
||||
app.showToast('每项评论图片不能超过3张');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 表单数据
|
||||
var form_data = e.detail.value;
|
||||
form_data['is_anonymous'] = form_data['is_anonymous'] == true ? 1 : 0;
|
||||
form_data['id'] = this.data.detail.id;
|
||||
form_data['goods_id'] = JSON.stringify(this.data.detail.items.map(function (v) {
|
||||
return v.goods_id;
|
||||
}));
|
||||
form_data['rating'] = JSON.stringify(this.data.form_rating_list);
|
||||
form_data['content'] = JSON.stringify(this.data.form_content_list);
|
||||
form_data['images'] = this.data.form_images_list.length > 0 ? JSON.stringify(this.data.form_images_list) : '';
|
||||
|
||||
// 提交表单
|
||||
var self = this;
|
||||
swan.showLoading({ title: "处理中..." });
|
||||
self.setData({ form_button_disabled: true });
|
||||
swan.request({
|
||||
url: app.get_request_url("commentssave", "order"),
|
||||
method: "POST",
|
||||
data: form_data,
|
||||
dataType: "json",
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
swan.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
app.showToast(res.data.msg, "success");
|
||||
setTimeout(function () {
|
||||
swan.navigateBack();
|
||||
}, 2000);
|
||||
} else {
|
||||
self.setData({ form_button_disabled: false });
|
||||
app.showToast(res.data.msg);
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
swan.hideLoading();
|
||||
self.setData({ form_button_disabled: false });
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.init();
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<view s-if="detail != null">
|
||||
<form bindsubmit="formSubmit" class="form-container">
|
||||
<view s-for="item, index in detail.items" s-key="item" class="form-gorup bg-white oh">
|
||||
<view class="oh">
|
||||
<navigator url="/pages/goods-detail/goods-detail?goods_id={{item.goods_id}}" hover-class="none">
|
||||
<image class="goods-image fl br" src="{{item.images}}" mode="aspectFill" />
|
||||
</navigator>
|
||||
<view class="item-base">
|
||||
<block s-for="item, tx in [1,2,3,4,5]" s-key="tx">
|
||||
<image class="xingxing-icon" src="/images/default-xingxing-icon{{form_rating_list[index] != undefined && form_rating_list[index] >= item ? '-active' : ''}}.png" mode="aspectFill" bindtap="rating_event" data-index="{{index}}" data-value="{{item}}" />
|
||||
</block>
|
||||
<text s-if="form_rating_list[index] != undefined" class="msg-text cr-888">{{rating_msg[form_rating_list[index]-1]}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="form-content">
|
||||
<textarea bindinput="form_content_event" data-index="{{index}}" placeholder-class="cr-ccc" class="cr-666" placeholder="退宝贝满足你的期待吗?说说它的有点和美中不足的地方吧" maxlength="230" value="{=form_msg=}" />
|
||||
<view class="form-container-upload oh">
|
||||
<view class="form-upload-data fl">
|
||||
<block s-if="(form_images_list[index] || null) != null && form_images_list[index].length > 0">
|
||||
<view s-for="item, ix in form_images_list[index]" s-key="item" class="item fl">
|
||||
<text class="delete-icon" bindtap="upload_delete_event" data-index="{{index}}" data-ix="{{ix}}">x</text>
|
||||
<image src="{{item}}" bindtap="upload_show_event" data-index="{{index}}" data-ix="{{ix}}" mode="aspectFill" />
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
<image s-if="(form_images_list[index] || null) == null || form_images_list[index].length < 3" class="upload-icon" src="/images/default-upload-icon.png" mode="aspectFill" bindtap="file_upload_event" data-index="{{index}}" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="form-gorup bg-white anonymous">
|
||||
<switch name="is_anonymous" bindchange="anonymous_event" />
|
||||
<text class="cr-666">匿名</text>
|
||||
<text class="fr cr-888 tips-text">{{anonymous_msg_list[anonymous_value]}}</text>
|
||||
</view>
|
||||
|
||||
<view class="form-gorup">
|
||||
<button formType="submit" class="bg-main submit-bottom" type="default" hover-class="none" disabled="{{form_button_disabled}}">提交</button>
|
||||
</view>
|
||||
</form>
|
||||
</view>
|
||||
|
||||
<view s-if="detail == null">
|
||||
<import src="/pages/common/nodata.swan" />
|
||||
<template is="nodata" data="{{{status: data_list_loding_status, msg: data_list_loding_msg}}}"></template>
|
||||
</view>
|
||||
|
|
@ -34,11 +34,11 @@ Page({
|
|||
params: params,
|
||||
nav_status_index: nav_status_index
|
||||
});
|
||||
this.init();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
swan.setNavigationBarTitle({ title: app.data.common_pages_title.user_order });
|
||||
this.init();
|
||||
},
|
||||
|
||||
init() {
|
||||
|
|
@ -368,4 +368,11 @@ Page({
|
|||
url: "/pages/user-orderaftersale-detail/user-orderaftersale-detail?oid=" + oid + "&did=" + did
|
||||
});
|
||||
},
|
||||
|
||||
// 订单评论
|
||||
comments_event(e) {
|
||||
swan.navigateTo({
|
||||
url: "/pages/user-order-comments/user-order-comments?id=" + e.currentTarget.dataset.value
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
@ -34,15 +34,12 @@
|
|||
</navigator>
|
||||
</view>
|
||||
<view class="item-describe tr cr-666">{{item.describe}}</view>
|
||||
<view s-if="item.status <= 3" class="item-operation tr br-t">
|
||||
<button s-if="item.status <= 1" class="submit-cancel" type="default" size="mini" bindtap="cancel_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">取消
|
||||
</button>
|
||||
<button s-if="item.status == 1" class="submit-pay cr-666 br" type="default" size="mini" bindtap="pay_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">支付
|
||||
</button>
|
||||
<button s-if="item.status == 2" class="submit-rush cr-666 br" type="default" size="mini" bindtap="rush_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">催催
|
||||
</button>
|
||||
<button s-if="item.status == 3" class="submit-success cr-666 br" type="default" size="mini" bindtap="collect_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">收货
|
||||
</button>
|
||||
<view s-if="item.status <= 3 || (item.status == 4 && item.user_is_comments == 0)" class="item-operation tr br-t">
|
||||
<button s-if="item.status <= 1" class="submit-cancel" type="default" size="mini" bindtap="cancel_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">取消</button>
|
||||
<button s-if="item.status == 1" class="submit-pay cr-666 br" type="default" size="mini" bindtap="pay_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">支付</button>
|
||||
<button s-if="item.status == 2" class="submit-rush cr-666 br" type="default" size="mini" bindtap="rush_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">催催</button>
|
||||
<button s-if="item.status == 3" class="submit-success cr-666 br" type="default" size="mini" bindtap="collect_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">收货</button>
|
||||
<button s-if="item.status == 4 && item.user_is_comments == 0" class="submit-success cr-666 br" type="default" size="mini" bindtap="comments_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">评论</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"pages": ["pages/user-order-comments/user-order-comments",
|
||||
"pages": ["pages/user-order/user-order",
|
||||
"pages/index/index",
|
||||
"pages/goods-category/goods-category",
|
||||
"pages/cart/cart",
|
||||
|
|
@ -14,8 +14,9 @@
|
|||
"pages/buy/buy",
|
||||
"pages/user-address/user-address",
|
||||
"pages/user-address-save/user-address-save",
|
||||
"pages/user-order/user-order",
|
||||
|
||||
"pages/user-order-detail/user-order-detail",
|
||||
"pages/user-order-comments/user-order-comments",
|
||||
"pages/user-faovr/user-faovr",
|
||||
"pages/user-answer-list/user-answer-list",
|
||||
"pages/answer-list/answer-list",
|
||||
|
|
|
|||
|
|
@ -6,12 +6,18 @@ Page({
|
|||
params: null,
|
||||
|
||||
detail: null,
|
||||
rating_list: [],
|
||||
editor_path_type: '',
|
||||
rating_msg: ['非常差', '差', '一般', '好', '非常好'],
|
||||
anonymous_value: 0,
|
||||
anonymous_msg_list: ['你写的评论会以匿名的形式展现', '你写的评论会以昵称的形式展现'],
|
||||
|
||||
form_rating_list: [],
|
||||
form_images_list: [],
|
||||
form_content_list: [],
|
||||
form_button_disabled: false,
|
||||
},
|
||||
|
||||
onLoad(params) {
|
||||
params['id'] = 3;
|
||||
this.setData({ params: params });
|
||||
this.init();
|
||||
},
|
||||
|
|
@ -28,7 +34,7 @@ Page({
|
|||
});
|
||||
|
||||
wx.request({
|
||||
url: app.get_request_url("detail", "order"),
|
||||
url: app.get_request_url("comments", "order"),
|
||||
method: "POST",
|
||||
data: {
|
||||
id: this.data.params.id
|
||||
|
|
@ -40,7 +46,8 @@ Page({
|
|||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
self.setData({
|
||||
detail: data,
|
||||
editor_path_type: data.editor_path_type || '',
|
||||
detail: data.data,
|
||||
data_list_loding_status: 3,
|
||||
data_list_loding_msg: '',
|
||||
});
|
||||
|
|
@ -64,20 +71,246 @@ Page({
|
|||
});
|
||||
},
|
||||
|
||||
// 上传图片预览
|
||||
upload_show_event(e) {
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var ix = e.currentTarget.dataset.ix;
|
||||
wx.previewImage({
|
||||
current: this.data.form_images_list[index][ix],
|
||||
urls: this.data.form_images_list[index],
|
||||
});
|
||||
},
|
||||
|
||||
// 图片删除
|
||||
upload_delete_event(e) {
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var ix = e.currentTarget.dataset.ix;
|
||||
var self = this;
|
||||
wx.showModal({
|
||||
title: '温馨提示',
|
||||
content: '删除后不可恢复、继续吗?',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
var list = self.data.form_images_list;
|
||||
list[index].splice(ix, 1);
|
||||
self.setData({
|
||||
form_images_list: list,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 文件上传
|
||||
file_upload_event(e) {
|
||||
// 数据初始化
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var temp_list = this.data.form_images_list;
|
||||
var length = this.data.detail.items.length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (temp_list[i] == undefined) {
|
||||
temp_list[i] = [];
|
||||
}
|
||||
}
|
||||
this.setData({ form_images_list: temp_list});
|
||||
|
||||
// 处理上传文件
|
||||
var self = this;
|
||||
wx.chooseImage({
|
||||
count: 3,
|
||||
success(res) {
|
||||
var success = 0;
|
||||
var fail = 0;
|
||||
var length = res.tempFilePaths.length;
|
||||
var count = 0;
|
||||
self.upload_one_by_one(index, res.tempFilePaths, success, fail, count, length);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 采用递归的方式上传多张
|
||||
upload_one_by_one(index, img_paths, success, fail, count, length) {
|
||||
var self = this;
|
||||
if ((self.data.form_images_list[index] || null) == null || self.data.form_images_list[index].length < 3) {
|
||||
wx.uploadFile({
|
||||
url: app.get_request_url("index", "ueditor"),
|
||||
filePath: img_paths[count],
|
||||
name: 'upfile',
|
||||
formData: {
|
||||
action: 'uploadimage',
|
||||
path_type: self.data.editor_path_type
|
||||
},
|
||||
success: function (res) {
|
||||
success++;
|
||||
if (res.statusCode == 200) {
|
||||
var data = (typeof (res.data) == 'object') ? res.data : JSON.parse(res.data);
|
||||
if (data.code == 0 && (data.data.url || null) != null) {
|
||||
var list = self.data.form_images_list;
|
||||
if ((list[index] || null) == null)
|
||||
{
|
||||
list[index] = [];
|
||||
}
|
||||
list[index].push(data.data.url);
|
||||
self.setData({ form_images_list: list });
|
||||
} else {
|
||||
app.showToast(data.msg);
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: function (e) {
|
||||
fail++;
|
||||
},
|
||||
complete: function (e) {
|
||||
count++; // 下一张
|
||||
if (count >= length) {
|
||||
// 上传完毕,作一下提示
|
||||
//app.showToast('上传成功' + success +'张', 'success');
|
||||
} else {
|
||||
// 递归调用,上传下一张
|
||||
self.upload_one_by_one(index, img_paths, success, fail, count, length);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 是否匿名事件
|
||||
anonymous_event(e) {
|
||||
this.setData({ anonymous_value: e.detail.value == true ? 1 : 0});
|
||||
},
|
||||
|
||||
// 评分事件
|
||||
rating_event(e) {
|
||||
console.log(e.currentTarget.dataset)
|
||||
// 参数
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var tx = e.currentTarget.dataset.tx;
|
||||
var value = e.currentTarget.dataset.value;
|
||||
var temp_list = this.data.rating_list;
|
||||
temp_list[index] = value;
|
||||
this.setData({ rating_list: temp_list});
|
||||
|
||||
// 数据初始化/赋值
|
||||
var temp_list = this.data.form_rating_list;
|
||||
var length = this.data.detail.items.length;
|
||||
for(var i=0; i<length; i++)
|
||||
{
|
||||
if (temp_list[i] == undefined)
|
||||
{
|
||||
temp_list[i] = 0;
|
||||
}
|
||||
if(index == i)
|
||||
{
|
||||
temp_list[i] = value;
|
||||
}
|
||||
}
|
||||
this.setData({ form_rating_list: temp_list});
|
||||
},
|
||||
|
||||
// 评论内容
|
||||
form_content_event(e) {
|
||||
// 参数
|
||||
var index = e.currentTarget.dataset.index;
|
||||
var value = e.detail.value;
|
||||
|
||||
// 数据初始化/赋值
|
||||
var temp_list = this.data.form_content_list;
|
||||
var length = this.data.detail.items.length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (temp_list[i] == undefined) {
|
||||
temp_list[i] = '';
|
||||
}
|
||||
if (index == i) {
|
||||
temp_list[i] = value;
|
||||
}
|
||||
}
|
||||
this.setData({
|
||||
form_content_list: temp_list
|
||||
});
|
||||
},
|
||||
|
||||
// 表单
|
||||
formSubmit(e) {
|
||||
console.log(e.detail.value)
|
||||
// 商品数量
|
||||
var length = this.data.detail.items.length;
|
||||
|
||||
// 评分校验
|
||||
var count = this.data.form_rating_list.length;
|
||||
if (count < length)
|
||||
{
|
||||
app.showToast('请评分');
|
||||
return false;
|
||||
}
|
||||
var max = Math.max.apply(null, this.data.form_rating_list);
|
||||
var min = Math.min.apply(null, this.data.form_rating_list);
|
||||
if (min < 1 || max > 5)
|
||||
{
|
||||
app.showToast('评分有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 内容校验
|
||||
var count = this.data.form_content_list.length;
|
||||
if (count < length) {
|
||||
app.showToast('请填写评论内容');
|
||||
return false;
|
||||
}
|
||||
for (var i in this.data.form_content_list)
|
||||
{
|
||||
var count = this.data.form_content_list[i].length;
|
||||
if (count < 6 || count > 230)
|
||||
{
|
||||
app.showToast('评论内容 6~230 个字符之间');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 图片校验
|
||||
if (this.data.form_images_list.length > 0)
|
||||
{
|
||||
for (var i in this.data.form_images_list)
|
||||
{
|
||||
if (this.data.form_images_list[i].length > 3)
|
||||
{
|
||||
app.showToast('每项评论图片不能超过3张');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 表单数据
|
||||
var form_data = e.detail.value;
|
||||
form_data['is_anonymous'] = form_data['is_anonymous'] == true ? 1 : 0;
|
||||
form_data['id'] = this.data.detail.id;
|
||||
form_data['goods_id'] = JSON.stringify(this.data.detail.items.map(function (v) { return v.goods_id }));
|
||||
form_data['rating'] = JSON.stringify(this.data.form_rating_list);
|
||||
form_data['content'] = JSON.stringify(this.data.form_content_list);
|
||||
form_data['images'] = (this.data.form_images_list.length > 0) ? JSON.stringify(this.data.form_images_list) : '';
|
||||
|
||||
// 提交表单
|
||||
var self = this;
|
||||
wx.showLoading({ title: "处理中..." });
|
||||
self.setData({ form_button_disabled: true });
|
||||
wx.request({
|
||||
url: app.get_request_url("commentssave", "order"),
|
||||
method: "POST",
|
||||
data: form_data,
|
||||
dataType: "json",
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
wx.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
app.showToast(res.data.msg, "success");
|
||||
setTimeout(function () {
|
||||
wx.navigateBack();
|
||||
}, 2000);
|
||||
} else {
|
||||
self.setData({ form_button_disabled: false });
|
||||
app.showToast(res.data.msg);
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
wx.hideLoading();
|
||||
self.setData({ form_button_disabled: false });
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
|
|
|
|||
|
|
@ -7,36 +7,35 @@
|
|||
</navigator>
|
||||
<view class="item-base">
|
||||
<block wx:for="{{[1,2,3,4,5]}}" wx:key="tx" wx:for-index="tx">
|
||||
<image class="xingxing-icon" src="/images/default-xingxing-icon{{rating_list[index] != undefined && rating_list[index] >= item ? '-active' : ''}}.png" mode="aspectFill" bindtap="rating_event" data-index="{{index}}" data-tx="{{tx}}" data-value="{{item}}" />
|
||||
<image class="xingxing-icon" src="/images/default-xingxing-icon{{form_rating_list[index] != undefined && form_rating_list[index] >= item ? '-active' : ''}}.png" mode="aspectFill" bindtap="rating_event" data-index="{{index}}" data-value="{{item}}" />
|
||||
</block>
|
||||
<text wx:if="{{rating_list[index] != undefined}}" class="msg-text cr-888">{{rating_msg[rating_list[index]-1]}}</text>
|
||||
<text wx:if="{{form_rating_list[index] != undefined}}" class="msg-text cr-888">{{rating_msg[form_rating_list[index]-1]}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="form-content">
|
||||
<textarea name="content_{{index}}" placeholder-class="cr-ccc" class="cr-666" placeholder="退宝贝满足你的期待吗?说说它的有点和美中不足的地方吧" maxlength="230" value="{{form_msg}}" />
|
||||
<textarea bindinput="form_content_event" data-index="{{index}}" placeholder-class="cr-ccc" class="cr-666" placeholder="退宝贝满足你的期待吗?说说它的有点和美中不足的地方吧" maxlength="230" value="{{form_msg}}" />
|
||||
<view class="form-container-upload oh">
|
||||
<view class="form-upload-data fl">
|
||||
<block wx:if="{{form_images_list.length > 0}}">
|
||||
<view wx:for="{{form_images_list}}" wx:key="item" class="item fl">
|
||||
<text class="delete-icon" bindtap="upload_delete_event" data-index="{{index}}">x</text>
|
||||
<image src="{{item}}" bindtap="upload_show_event" data-index="{{index}}" mode="aspectFill" />
|
||||
<block wx:if="{{(form_images_list[index] || null) != null && form_images_list[index].length > 0}}">
|
||||
<view wx:for="{{form_images_list[index]}}" wx:key="item" wx:for-index="ix" class="item fl">
|
||||
<text class="delete-icon" bindtap="upload_delete_event" data-index="{{index}}" data-ix="{{ix}}">x</text>
|
||||
<image src="{{item}}" bindtap="upload_show_event" data-index="{{index}}" data-ix="{{ix}}" mode="aspectFill" />
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
<image class="upload-icon" src="/images/default-upload-icon.png" mode="aspectFill" bindtap="file_upload_event" />
|
||||
<image wx:if="{{(form_images_list[index] || null) == null || form_images_list[index].length < 3}}" class="upload-icon" src="/images/default-upload-icon.png" mode="aspectFill" bindtap="file_upload_event" data-index="{{index}}" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
<view class="form-gorup bg-white anonymous">
|
||||
<switch name="is_anonymous" checked="{{switch1Checked}}" bindchange="switch1Change"/>
|
||||
<switch name="is_anonymous" bindchange="anonymous_event" />
|
||||
<text class="cr-666">匿名</text>
|
||||
<text class="fr cr-888 tips-text">公开的评论会展示在商品详情页面</text>
|
||||
<text class="fr cr-888 tips-text">{{anonymous_msg_list[anonymous_value]}}</text>
|
||||
</view>
|
||||
|
||||
<view class="form-gorup">
|
||||
<button formType="submit" class="bg-main submit-bottom" type="default" bindtap="form_submit_event" hover-class="none" disabled="{{form_button_disabled}}">提交</button>
|
||||
<button formType="submit" class="bg-main submit-bottom" type="default" hover-class="none" disabled="{{form_button_disabled}}">提交</button>
|
||||
</view>
|
||||
</form>
|
||||
</view>
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@ Page({
|
|||
params: params,
|
||||
nav_status_index: nav_status_index,
|
||||
});
|
||||
this.init();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
wx.setNavigationBarTitle({title: app.data.common_pages_title.user_order});
|
||||
this.init();
|
||||
},
|
||||
|
||||
init() {
|
||||
|
|
@ -386,4 +386,11 @@ Page({
|
|||
url: "/pages/user-orderaftersale-detail/user-orderaftersale-detail?oid=" + oid+"&did="+did
|
||||
});
|
||||
},
|
||||
|
||||
// 订单评论
|
||||
comments_event(e) {
|
||||
wx.navigateTo({
|
||||
url: "/pages/user-order-comments/user-order-comments?id=" + e.currentTarget.dataset.value
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -34,15 +34,12 @@
|
|||
</navigator>
|
||||
</view>
|
||||
<view class="item-describe tr cr-666">{{item.describe}}</view>
|
||||
<view wx:if="{{item.status <= 3}}" class="item-operation tr br-t">
|
||||
<button wx:if="{{item.status <= 1}}" class="submit-cancel" type="default" size="mini" bindtap="cancel_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">取消
|
||||
</button>
|
||||
<button wx:if="{{item.status == 1}}" class="submit-pay cr-666 br" type="default" size="mini" bindtap="pay_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">支付
|
||||
</button>
|
||||
<button wx:if="{{item.status == 2}}" class="submit-rush cr-666 br" type="default" size="mini" bindtap="rush_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">催催
|
||||
</button>
|
||||
<button wx:if="{{item.status == 3}}" class="submit-success cr-666 br" type="default" size="mini" bindtap="collect_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">收货
|
||||
</button>
|
||||
<view wx:if="{{item.status <= 3 || (item.status == 4 && item.user_is_comments == 0)}}" class="item-operation tr br-t">
|
||||
<button wx:if="{{item.status <= 1}}" class="submit-cancel" type="default" size="mini" bindtap="cancel_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">取消</button>
|
||||
<button wx:if="{{item.status == 1}}" class="submit-pay cr-666 br" type="default" size="mini" bindtap="pay_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">支付</button>
|
||||
<button wx:if="{{item.status == 2}}" class="submit-rush cr-666 br" type="default" size="mini" bindtap="rush_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">催催</button>
|
||||
<button wx:if="{{item.status == 3}}" class="submit-success cr-666 br" type="default" size="mini" bindtap="collect_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">收货</button>
|
||||
<button wx:if="{{item.status == 4 && item.user_is_comments == 0}}" class="submit-success cr-666 br" type="default" size="mini" bindtap="comments_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">评论</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
Loading…
Reference in New Issue