From 8d85440f529fe8008229b6f7e68264eeb931da7b Mon Sep 17 00:00:00 2001 From: devil_gong Date: Thu, 10 Oct 2019 19:13:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E8=AF=84=E8=AE=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Order.php | 14 +- application/api/controller/Orderaftersale.php | 2 +- .../index/controller/Orderaftersale.php | 2 +- application/service/ArticleService.php | 21 +- application/service/CustomViewService.php | 20 +- application/service/GoodsCommentsService.php | 82 +++-- public/appmini/old/alipay/app.js | 1 + public/appmini/old/alipay/app.json | 1 + .../user-order-comments.axml | 46 +++ .../user-order-comments.axss | 40 +++ .../user-order-comments.js | 321 ++++++++++++++++++ .../user-order-comments.json | 3 + .../alipay/pages/user-order/user-order.axml | 15 +- .../old/alipay/pages/user-order/user-order.js | 9 +- public/appmini/old/baidu/app.js | 1 + public/appmini/old/baidu/app.json | 1 + .../user-order-comments.css | 40 +++ .../user-order-comments.js | 311 +++++++++++++++++ .../user-order-comments.json | 3 + .../user-order-comments.swan | 46 +++ .../old/baidu/pages/user-order/user-order.js | 9 +- .../baidu/pages/user-order/user-order.swan | 15 +- public/appmini/old/weixin/app.json | 5 +- .../user-order-comments.js | 253 +++++++++++++- .../user-order-comments.wxml | 23 +- .../old/weixin/pages/user-order/user-order.js | 9 +- .../weixin/pages/user-order/user-order.wxml | 15 +- .../3/9/2019/10/10/1570705883308238.png | Bin 0 -> 28123 bytes 28 files changed, 1226 insertions(+), 82 deletions(-) create mode 100644 public/appmini/old/alipay/pages/user-order-comments/user-order-comments.axml create mode 100644 public/appmini/old/alipay/pages/user-order-comments/user-order-comments.axss create mode 100644 public/appmini/old/alipay/pages/user-order-comments/user-order-comments.js create mode 100644 public/appmini/old/alipay/pages/user-order-comments/user-order-comments.json create mode 100644 public/appmini/old/baidu/pages/user-order-comments/user-order-comments.css create mode 100644 public/appmini/old/baidu/pages/user-order-comments/user-order-comments.js create mode 100644 public/appmini/old/baidu/pages/user-order-comments/user-order-comments.json create mode 100644 public/appmini/old/baidu/pages/user-order-comments/user-order-comments.swan create mode 100644 public/static/upload/images/order_comments/3/9/2019/10/10/1570705883308238.png diff --git a/application/api/controller/Order.php b/application/api/controller/Order.php index c5b9f23d0..d97f3621c 100755 --- a/application/api/controller/Order.php +++ b/application/api/controller/Order.php @@ -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); } diff --git a/application/api/controller/Orderaftersale.php b/application/api/controller/Orderaftersale.php index 2f1cc6eaa..fba06eb08 100644 --- a/application/api/controller/Orderaftersale.php +++ b/application/api/controller/Orderaftersale.php @@ -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); } diff --git a/application/index/controller/Orderaftersale.php b/application/index/controller/Orderaftersale.php index a7503a270..f7ba3b294 100644 --- a/application/index/controller/Orderaftersale.php +++ b/application/index/controller/Orderaftersale.php @@ -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(); diff --git a/application/service/ArticleService.php b/application/service/ArticleService.php index 358141ba4..e7a24e0d9 100755 --- a/application/service/ArticleService.php +++ b/application/service/ArticleService.php @@ -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'], diff --git a/application/service/CustomViewService.php b/application/service/CustomViewService.php index dcb8ef8ba..ee4c92c67 100755 --- a/application/service/CustomViewService.php +++ b/application/service/CustomViewService.php @@ -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, diff --git a/application/service/GoodsCommentsService.php b/application/service/GoodsCommentsService.php index c55a3d0f8..cb8d6655c 100644 --- a/application/service/GoodsCommentsService.php +++ b/application/service/GoodsCommentsService.php @@ -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) diff --git a/public/appmini/old/alipay/app.js b/public/appmini/old/alipay/app.js index 1d9f055ea..25b2515b5 100644 --- a/public/appmini/old/alipay/app.js +++ b/public/appmini/old/alipay/app.js @@ -59,6 +59,7 @@ App({ "goods_comment": "商品评论", "user_orderaftersale": "退款/售后", "user_orderaftersale_detail": "订单售后", + "user_order_comments": "订单评论", }, // 请求地址 diff --git a/public/appmini/old/alipay/app.json b/public/appmini/old/alipay/app.json index 39578bdef..2aabc371f 100644 --- a/public/appmini/old/alipay/app.json +++ b/public/appmini/old/alipay/app.json @@ -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", diff --git a/public/appmini/old/alipay/pages/user-order-comments/user-order-comments.axml b/public/appmini/old/alipay/pages/user-order-comments/user-order-comments.axml new file mode 100644 index 000000000..f496e328e --- /dev/null +++ b/public/appmini/old/alipay/pages/user-order-comments/user-order-comments.axml @@ -0,0 +1,46 @@ + +
+ + + + + + + + + + {{rating_msg[form_rating_list[index]-1]}} + + + +