Browse Source

chore[litemall-wx, litemall-wx-api]: 评论API调整及文档

Junling Bu 6 years ago
parent
commit
187021381d

+ 150 - 2
doc/api.md

@@ -427,11 +427,11 @@ API应该存在版本控制,以保证兼容性。
     
     
-#### 2.9.2 品牌商信息
+#### 2.9.2 品牌商详情
 
 应用场景
 
-    访问单个品牌商信息
+    访问单个品牌商详情信息
     
 接口链接
 
@@ -467,6 +467,154 @@ API应该存在版本控制,以保证兼容性。
 
 ### 2.11 评论服务
 
+#### 2.11.1 评论数量
+
+应用场景
+
+    某个商品或者专题的评论数量,包括总的评论数量和包含图片的评论数量
+    
+接口链接
+
+    GET /wx/comment/count
+
+请求参数
+    
+    type: 评论类型,如果是0则是商品评论,如果是1则是专题评论
+    valueId: 评论对象ID,如果type=0,则设置商品ID,如果type=0,则设置专题ID
+    
+响应内容
+
+    {
+      "errno": 0,
+      "data": {
+        "hasPicCount": 34,
+        "allCount": 96
+      },
+      "errmsg": "成功"
+    }
+
+错误码
+    
+    无
+    
+
+#### 2.11.2 评论列表
+
+应用场景
+
+    某个商品或者专题的评论列表
+    
+接口链接
+
+    GET /wx/comment/list
+    
+请求参数
+    
+    valueId=1181000&type=0&limit=20&page=1&showType=0
+    type: 评论类型,如果是0则是商品评论,如果是1则是专题评论
+    valueId: 评论对象ID,如果type=0,则设置商品ID,如果type=0,则设置专题ID
+    showType: 评论显示类型,如果是0则是所有评论,如果是1则是包含图片的评论
+    page: 请求页码
+    limit: 每一页数量
+    sort: 排序字段
+    order: 升序降序
+        
+响应内容
+
+    {
+      "errno": 0,
+      "data": {
+        "total": 96,
+        "pages": 20,
+        "limit": 5,
+        "page": 1,
+        "list": [
+          {
+            "userInfo": {
+              "nickName": "user123",
+              "avatarUrl": "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif"
+            },
+            "addTime": "2018-02-01 00:00:00",
+            "picList": [
+              "https://yanxuan.nosdn.127.net/218783173f303ec6d8766810951d0790.jpg"
+            ],
+            "content": "布料很厚实,触感不错,洗过之后不缩水不掉色"
+          },
+          {
+            "userInfo": {
+              "nickName": "user123",
+              "avatarUrl": "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif"
+            },
+            "addTime": "2018-02-01 00:00:00",
+            "picList": [
+              "https://yanxuan.nosdn.127.net/33978a0d6f56d94c45e4fc594b4b8606.jpg"
+            ],
+            "content": "料子很舒服,凉凉的,配合蚕丝被,夏天很凉快~"
+          },
+          {
+            "userInfo": {
+              "nickName": "user123",
+              "avatarUrl": "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif"
+            },
+            "addTime": "2018-02-01 00:00:00",
+            "picList": [
+              "https://yanxuan.nosdn.127.net/d3975d1b6d88e9f9d762cd9a879d1a14.jpg"
+            ],
+            "content": "一直喜欢粗布的床上用品。冬暖夏凉。这套看起来非常漂亮。实际感觉有点粗布的感觉。很好!"
+          },
+          {
+            "userInfo": {
+              "nickName": "user123",
+              "avatarUrl": "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif"
+            },
+            "addTime": "2018-02-01 00:00:00",
+            "picList": [
+              "https://yanxuan.nosdn.127.net/5fe1121396458cfe0dc1b25ec86f7ff9.jpg",
+              "https://yanxuan.nosdn.127.net/d5a55abd6ced5c811d775b04929aaabc.jpg",
+              "https://yanxuan.nosdn.127.net/f1764d820ba6ddaf51d297e3cf3826cd.jpg"
+            ],
+            "content": "太好了,舒服的不得了,腰,腿,脊柱,头,颈椎!\n无一处不舒服,真没想到这么优惠!\n搬了新家还要买!"
+          },
+          {
+            "userInfo": {
+              "nickName": "user123",
+              "avatarUrl": "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif"
+            },
+            "addTime": "2018-02-01 00:00:00",
+            "picList": [
+              "https://yanxuan.nosdn.127.net/f753f91430dfb56f574c737d4b2fde46.jpg"
+            ],
+            "content": "抱着试试的态度 先买了小的 果然感觉很舒服 深陷其中 把自己全身心都给了它 第二个床垫已经在路上"
+          }
+        ]
+      },
+      "errmsg": "成功"
+    }
+    
+错误码
+    
+    无
+        
+
+#### 2.11.3 发表评论
+
+应用场景
+
+    针对某个商品或者专题的发表评论
+    
+接口链接
+
+
+请求参数
+    
+
+响应内容
+
+
+错误码
+    
+    略
+            
 ### 2.12 优惠券服务
 
 ### 2.13 反馈服务

+ 5 - 11
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCommentController.java

@@ -1,6 +1,5 @@
 package org.linlinjava.litemall.wx.web;
 
-import com.github.pagehelper.PageInfo;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -113,10 +112,10 @@ public class WxCommentController {
     public Object count(@NotNull Byte type, @NotNull Integer valueId) {
         int allCount = commentService.count(type, valueId, 0);
         int hasPicCount = commentService.count(type, valueId, 1);
-        Map<String, Object> data = new HashMap<String, Object>();
-        data.put("allCount", allCount);
-        data.put("hasPicCount", hasPicCount);
-        return ResponseUtil.ok(data);
+        Map<String, Object> entity = new HashMap<String, Object>();
+        entity.put("allCount", allCount);
+        entity.put("hasPicCount", hasPicCount);
+        return ResponseUtil.ok(entity);
     }
 
     /**
@@ -136,7 +135,6 @@ public class WxCommentController {
                        @RequestParam(defaultValue = "1") Integer page,
                        @RequestParam(defaultValue = "10") Integer limit) {
         List<LitemallComment> commentList = commentService.query(type, valueId, showType, page, limit);
-        long count = PageInfo.of(commentList).getTotal();
 
         List<Map<String, Object>> commentVoList = new ArrayList<>(commentList.size());
         for (LitemallComment comment : commentList) {
@@ -153,10 +151,6 @@ public class WxCommentController {
 
             commentVoList.add(commentVo);
         }
-        Map<String, Object> data = new HashMap<String, Object>();
-        data.put("data", commentVoList);
-        data.put("count", count);
-        data.put("currentPage", page);
-        return ResponseUtil.ok(data);
+        return ResponseUtil.okList(commentVoList, commentList);
     }
 }

+ 0 - 1
litemall-wx/config/api.js

@@ -82,7 +82,6 @@ module.exports = {
   UserFormIdCreate: WxApiRoot + 'formid/create', //用户FromId,用于发送模版消息
 
   GroupOnList: WxApiRoot + 'groupon/list', //团购列表
-  GroupOn: WxApiRoot + 'groupon/query', //团购API-查询
   GroupOnMy: WxApiRoot + 'groupon/my', //团购API-我的团购
   GroupOnDetail: WxApiRoot + 'groupon/detail', //团购API-详情
   GroupOnJoin: WxApiRoot + 'groupon/join', //团购API-详情

+ 7 - 7
litemall-wx/pages/comment/comment.js

@@ -35,7 +35,7 @@ Page({
     util.request(api.CommentList, {
       valueId: that.data.valueId,
       type: that.data.type,
-      size: that.data.size,
+      limit: that.data.limit,
       page: (that.data.showType == 0 ? that.data.allPage : that.data.picPage),
       showType: that.data.showType
     }).then(function(res) {
@@ -43,15 +43,15 @@ Page({
 
         if (that.data.showType == 0) {
           that.setData({
-            allCommentList: that.data.allCommentList.concat(res.data.data),
-            allPage: res.data.currentPage,
-            comments: that.data.allCommentList.concat(res.data.data)
+            allCommentList: that.data.allCommentList.concat(res.data.list),
+            allPage: res.data.page,
+            comments: that.data.allCommentList.concat(res.data.list)
           });
         } else {
           that.setData({
-            picCommentList: that.data.picCommentList.concat(res.data.data),
-            picPage: res.data.currentPage,
-            comments: that.data.picCommentList.concat(res.data.data)
+            picCommentList: that.data.picCommentList.concat(res.data.list),
+            picPage: res.data.page,
+            comments: that.data.picCommentList.concat(res.data.list)
           });
         }
       }

+ 0 - 1
renard-wx/app.json

@@ -13,7 +13,6 @@
     "pages/ucenter/collect/collect",
     "pages/auth/login/login",
     "pages/payResult/payResult",
-    "pages/comment/comment",
     "pages/commentPost/commentPost",
     "pages/topic/topic",
     "pages/topicDetail/topicDetail",

+ 0 - 3
renard-wx/config/api.js

@@ -41,8 +41,6 @@ module.exports = {
   CollectList: WxApiRoot + 'collect/list', //收藏列表
   CollectAddOrDelete: WxApiRoot + 'collect/addordelete', //添加或取消收藏
 
-  CommentList: WxApiRoot + 'comment/list', //评论列表
-  CommentCount: WxApiRoot + 'comment/count', //评论总数
   CommentPost: WxApiRoot + 'comment/post', //发表评论
 
   TopicList: WxApiRoot + 'topic/list', //专题列表
@@ -78,7 +76,6 @@ module.exports = {
   UserFormIdCreate: WxApiRoot + 'formid/create', //用户FromId,用于发送模版消息
 
   GroupOnList: WxApiRoot + 'groupon/list', //团购列表
-  GroupOn: WxApiRoot + 'groupon/query', //团购API-查询
   GroupOnMy: WxApiRoot + 'groupon/my', //团购API-我的团购
   GroupOnDetail: WxApiRoot + 'groupon/detail', //团购API-详情
   GroupOnJoin: WxApiRoot + 'groupon/join', //团购API-详情

+ 0 - 127
renard-wx/pages/comment/comment.js

@@ -1,127 +0,0 @@
-var app = getApp();
-var util = require('../../utils/util.js');
-var api = require('../../config/api.js');
-
-Page({
-  data: {
-    comments: [],
-    allCommentList: [],
-    picCommentList: [],
-    type: 0,
-    valueId: 0,
-    showType: 0,
-    allCount: 0,
-    hasPicCount: 0,
-    allPage: 1,
-    picPage: 1,
-    size: 20
-  },
-  getCommentCount: function() {
-    let that = this;
-    util.request(api.CommentCount, {
-      valueId: that.data.valueId,
-      type: that.data.type
-    }).then(function(res) {
-      if (res.errno === 0) {
-        that.setData({
-          allCount: res.data.allCount,
-          hasPicCount: res.data.hasPicCount
-        });
-      }
-    });
-  },
-  getCommentList: function() {
-    let that = this;
-    util.request(api.CommentList, {
-      valueId: that.data.valueId,
-      type: that.data.type,
-      size: that.data.size,
-      page: (that.data.showType == 0 ? that.data.allPage : that.data.picPage),
-      showType: that.data.showType
-    }).then(function(res) {
-      if (res.errno === 0) {
-
-        if (that.data.showType == 0) {
-          that.setData({
-            allCommentList: that.data.allCommentList.concat(res.data.data),
-            allPage: res.data.currentPage,
-            comments: that.data.allCommentList.concat(res.data.data)
-          });
-        } else {
-          that.setData({
-            picCommentList: that.data.picCommentList.concat(res.data.data),
-            picPage: res.data.currentPage,
-            comments: that.data.picCommentList.concat(res.data.data)
-          });
-        }
-      }
-    });
-  },
-  onLoad: function(options) {
-    // 页面初始化 options为页面跳转所带来的参数
-    this.setData({
-      type: options.type,
-      valueId: options.valueId
-    });
-    this.getCommentCount();
-    this.getCommentList();
-  },
-  onReady: function() {
-    // 页面渲染完成
-
-  },
-  onShow: function() {
-    // 页面显示
-
-  },
-  onHide: function() {
-    // 页面隐藏
-
-  },
-  onUnload: function() {
-    // 页面关闭
-
-  },
-  switchTab: function() {
-    let that = this;
-    if (that.data.showType == 0) {
-      that.setData({
-        allCommentList: [],
-        allPage: 1,
-        comments: [],
-        showType: 1
-      });
-    } else {
-      that.setData({
-        picCommentList: [],
-        picPage: 1,
-        comments: [],
-        showType: 0
-      });
-    }
-    this.getCommentList();
-  },
-  onReachBottom: function() {
-    console.log('onPullDownRefresh');
-    if (this.data.showType == 0) {
-
-      if (this.data.allCount / this.data.size < this.data.allPage) {
-        return false;
-      }
-
-      this.setData({
-        'allPage': this.data.allPage + 1
-      });
-    } else {
-      if (this.data.hasPicCount / this.data.size < this.data.picPage) {
-        return false;
-      }
-
-      this.setData({
-        'picPage': this.data.picPage + 1
-      });
-    }
-
-    this.getCommentList();
-  }
-})

+ 0 - 3
renard-wx/pages/comment/comment.json

@@ -1,3 +0,0 @@
-{
-  "navigationBarTitleText": "评价"
-}

+ 0 - 30
renard-wx/pages/comment/comment.wxml

@@ -1,30 +0,0 @@
-<view class="comments">
-  <view class="h">
-    <view class="item {{ showType == 0 ? 'active' : ''}}" bindtap="switchTab">
-      <view class="txt">全部({{allCount}})</view>
-    </view>
-    <view class="item {{ showType == 0 ? '' : 'active'}}" bindtap="switchTab">
-      <view class="txt">有图({{hasPicCount}})</view>
-    </view>
-  </view>
-  <view class="b">
-    <view class="item" wx:for="{{comments}}" wx:key="id">
-      <view class="info">
-        <view class="user">
-          <image src="{{item.userInfo.avatarUrl}}"></image>
-          <text>{{item.userInfo.nickname}}</text>
-        </view>
-        <view class="time">{{item.addTime}}</view>
-      </view>
-      <view class="comment">{{item.content}}</view>
-      <view class="imgs" wx:if="{{item.picList.length > 0}}">
-        <image class="img" wx:for="{{item.picList}}" wx:key="*this" wx:for-item="pitem" src="{{pitem}}"></image>
-      </view>
-      <view class="customer-service" wx:if="{{item.reply}}">
-        <text class="u">小商场回复:</text>
-        <text class="c">{{item.reply}}</text>
-      </view>
-    </view>
-
-  </view>
-</view>

+ 0 - 155
renard-wx/pages/comment/comment.wxss

@@ -1,155 +0,0 @@
-.comments {
-  width: 100%;
-  height: auto;
-  padding-left: 30rpx;
-  background: #fff;
-  margin: 20rpx 0;
-}
-
-.comments .h {
-  position: fixed;
-  left: 0;
-  top: 0;
-  z-index: 1000;
-  width: 100%;
-  display: flex;
-  background: #fff;
-  height: 84rpx;
-  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
-}
-
-.comments .h .item {
-  display: inline-block;
-  height: 82rpx;
-  width: 50%;
-  padding: 0 15rpx;
-  text-align: center;
-}
-
-.comments .h .item .txt {
-  display: inline-block;
-  height: 82rpx;
-  padding: 0 20rpx;
-  line-height: 82rpx;
-  color: #333;
-  font-size: 30rpx;
-  width: 170rpx;
-}
-
-.comments .h .item.active .txt {
-  color: #ab2b2b;
-  border-bottom: 4rpx solid #ab2b2b;
-}
-
-.comments .b {
-  margin-top: 85rpx;
-  height: auto;
-  width: 720rpx;
-}
-
-.comments .b.no-h {
-  margin-top: 0;
-}
-
-.comments .item {
-  height: auto;
-  width: 720rpx;
-  overflow: hidden;
-  border-bottom: 1px solid #d9d9d9;
-  padding-bottom: 25rpx;
-}
-
-.comments .info {
-  height: 127rpx;
-  width: 100%;
-  padding: 33rpx 0 27rpx 0;
-}
-
-.comments .user {
-  float: left;
-  width: auto;
-  height: 67rpx;
-  line-height: 67rpx;
-  font-size: 0;
-}
-
-.comments .user image {
-  float: left;
-  width: 67rpx;
-  height: 67rpx;
-  margin-right: 17rpx;
-  border-radius: 50%;
-}
-
-.comments .user text {
-  display: inline-block;
-  width: auto;
-  height: 66rpx;
-  overflow: hidden;
-  font-size: 29rpx;
-  line-height: 66rpx;
-}
-
-.comments .time {
-  display: block;
-  float: right;
-  width: auto;
-  height: 67rpx;
-  line-height: 67rpx;
-  color: #7f7f7f;
-  font-size: 25rpx;
-  margin-right: 30rpx;
-}
-
-.comments .comment {
-  width: 720rpx;
-  padding-right: 30rpx;
-  line-height: 45.8rpx;
-  font-size: 29rpx;
-  margin-bottom: 16rpx;
-}
-
-.comments .imgs {
-  width: 720rpx;
-  height: 150rpx;
-  margin-bottom: 25rpx;
-}
-
-.comments .imgs .img {
-  height: 150rpx;
-  width: 150rpx;
-  margin-right: 28rpx;
-}
-
-.comments .spec {
-  width: 720rpx;
-  height: 25rpx;
-  font-size: 24rpx;
-  color: #999;
-}
-
-.comments .spec .item {
-  color: #7f7f7f;
-  font-size: 25rpx;
-}
-
-.comments .customer-service {
-  width: 690rpx;
-  height: auto;
-  overflow: hidden;
-  margin-top: 23rpx;
-  background: rgba(0, 0, 0, 0.03);
-  padding: 21rpx;
-}
-
-.comments .customer-service .u {
-  font-size: 24rpx;
-  color: #333;
-  line-height: 37.5rpx;
-}
-
-.comments .customer-service .c {
-  font-size: 24rpx;
-  color: #999;
-  line-height: 37.5rpx;
-}