浏览代码

:checkered_flag: 商品发布功能(上传商品图片功能除外)

nnkwrik 6 年之前
父节点
当前提交
8a844acbf3
共有 37 个文件被更改,包括 1099 次插入22 次删除
  1. 1 0
      common/src/main/java/io/github/nnkwrik/common/dto/Response.java
  2. 26 1
      goods-service/src/main/java/io/github/nnkwrik/goodsservice/controller/GoodsController.java
  3. 21 0
      goods-service/src/main/java/io/github/nnkwrik/goodsservice/controller/IndexController.java
  4. 19 0
      goods-service/src/main/java/io/github/nnkwrik/goodsservice/dao/GoodsMapper.java
  5. 7 0
      goods-service/src/main/java/io/github/nnkwrik/goodsservice/dao/OtherMapper.java
  6. 9 0
      goods-service/src/main/java/io/github/nnkwrik/goodsservice/model/po/Goods.java
  7. 16 0
      goods-service/src/main/java/io/github/nnkwrik/goodsservice/model/po/Region.java
  8. 3 0
      goods-service/src/main/java/io/github/nnkwrik/goodsservice/service/GoodsService.java
  9. 7 0
      goods-service/src/main/java/io/github/nnkwrik/goodsservice/service/IndexService.java
  10. 5 0
      goods-service/src/main/java/io/github/nnkwrik/goodsservice/service/impl/GoodsServiceImpl.java
  11. 10 0
      goods-service/src/main/java/io/github/nnkwrik/goodsservice/service/impl/IndexServiceImpl.java
  12. 12 0
      wx-front/app.js
  13. 6 2
      wx-front/app.json
  14. 5 2
      wx-front/config/api.js
  15. 2 2
      wx-front/pages/catalog/catalog.wxml
  16. 1 1
      wx-front/pages/commentPost/commentPost.json
  17. 24 8
      wx-front/pages/commentPost/commentPost.wxml
  18. 47 0
      wx-front/pages/commentPost/commentPost.wxss
  19. 5 2
      wx-front/pages/goods/goods.js
  20. 9 4
      wx-front/pages/index/index.wxml
  21. 69 0
      wx-front/pages/nav2post/nav2post.js
  22. 1 0
      wx-front/pages/nav2post/nav2post.json
  23. 1 0
      wx-front/pages/nav2post/nav2post.wxml
  24. 1 0
      wx-front/pages/nav2post/nav2post.wxss
  25. 222 0
      wx-front/pages/post/post.js
  26. 3 0
      wx-front/pages/post/post.json
  27. 61 0
      wx-front/pages/post/post.wxml
  28. 165 0
      wx-front/pages/post/post.wxss
  29. 111 0
      wx-front/pages/postCate/postCate.js
  30. 1 0
      wx-front/pages/postCate/postCate.json
  31. 13 0
      wx-front/pages/postCate/postCate.wxml
  32. 38 0
      wx-front/pages/postCate/postCate.wxss
  33. 115 0
      wx-front/pages/region/region.js
  34. 1 0
      wx-front/pages/region/region.json
  35. 14 0
      wx-front/pages/region/region.wxml
  36. 38 0
      wx-front/pages/region/region.wxss
  37. 10 0
      zuul/src/main/resources/application.yml

+ 1 - 0
common/src/main/java/io/github/nnkwrik/common/dto/Response.java

@@ -19,6 +19,7 @@ public class Response<T> {
     //goods
     public static final int OPEN_ID_IS_EMPTY = 4001;
     public static final int COMMENT_INFO_INCOMPLETE = 4002;
+    public static final int POST_INFO_INCOMPLETE = 4003;
 
     //user
     public static final int USER_IS_NOT_EXIST = 3001;

+ 26 - 1
goods-service/src/main/java/io/github/nnkwrik/goodsservice/controller/GoodsController.java

@@ -3,6 +3,7 @@ package io.github.nnkwrik.goodsservice.controller;
 import io.github.nnkwrik.common.dto.JWTUser;
 import io.github.nnkwrik.common.dto.Response;
 import io.github.nnkwrik.common.token.injection.JWT;
+import io.github.nnkwrik.goodsservice.model.po.Goods;
 import io.github.nnkwrik.goodsservice.model.vo.CategoryPageVo;
 import io.github.nnkwrik.goodsservice.model.vo.GoodsDetailPageVo;
 import io.github.nnkwrik.goodsservice.model.vo.GoodsRelatedVo;
@@ -13,6 +14,7 @@ import io.github.nnkwrik.goodsservice.model.vo.inner.GoodsDetailVo;
 import io.github.nnkwrik.goodsservice.service.GoodsService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
@@ -75,7 +77,7 @@ public class GoodsController {
         if (jwtUser != null)
             userHasCollect = goodsService.userHasCollect(jwtUser.getOpenId(), goodsId);
         GoodsDetailPageVo vo = new GoodsDetailPageVo(goodsDetail, goodsGallery, comment, userHasCollect);
-        log.debug("浏览商品详情 : 商品id={},商品名={}", vo.getInfo().getId(),vo.getInfo().getName());
+        log.debug("浏览商品详情 : 商品id={},商品名={}", vo.getInfo().getId(), vo.getInfo().getName());
 
         return Response.ok(vo);
     }
@@ -89,4 +91,27 @@ public class GoodsController {
     }
 
 
+    @PostMapping("/post")
+    public Response PostGoods(@RequestBody Goods goods,
+                              @JWT(required = true) JWTUser user) {
+
+        if (StringUtils.isEmpty(goods.getName()) ||
+                StringUtils.isEmpty(goods.getDesc()) ||
+                StringUtils.isEmpty(goods.getRegion()) ||
+                goods.getCategoryId() == null ||
+//                goods.getPrimaryPicUrl() == null ||
+                goods.getRegionId() == null ||
+                goods.getPrice() == null) {
+            String msg = "用户发布商品失败,信息不完整";
+            log.info(msg);
+            return Response.fail(Response.POST_INFO_INCOMPLETE, msg);
+        }
+        goods.setSellerId(user.getOpenId());
+        goodsService.postGoods(goods);
+        log.info("用户发布商品:用户昵称=【{}】,商品名=【{}】,详情=【{}】", user.getNickName(),goods.getName(),goods);
+
+        return Response.ok();
+    }
+
+
 }

+ 21 - 0
goods-service/src/main/java/io/github/nnkwrik/goodsservice/controller/IndexController.java

@@ -3,6 +3,8 @@ package io.github.nnkwrik.goodsservice.controller;
 import io.github.nnkwrik.common.dto.JWTUser;
 import io.github.nnkwrik.common.dto.Response;
 import io.github.nnkwrik.common.token.injection.JWT;
+import io.github.nnkwrik.goodsservice.model.po.Category;
+import io.github.nnkwrik.goodsservice.model.po.Region;
 import io.github.nnkwrik.goodsservice.model.vo.CatalogVo;
 import io.github.nnkwrik.goodsservice.model.vo.IndexVO;
 import io.github.nnkwrik.goodsservice.model.vo.inner.CommentVo;
@@ -12,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.List;
+
 /**
  * @author nnkwrik
  * @date 18/11/17 19:49
@@ -79,4 +83,21 @@ public class IndexController {
         return Response.ok();
 
     }
+    @GetMapping("/region/list/{regionId}")
+    public Response getRegionList(@PathVariable("regionId") int regionId){
+        List<Region> regionList = indexService.getRegionList(regionId);
+        log.debug("通过地区id=【{}】,搜索地区子列表。搜索结果为:{}",regionId,regionList);
+        return Response.ok(regionList);
+
+    }
+
+    @GetMapping("/category/post/{cateId}")
+    public Response getPostCateList(@PathVariable("cateId")int cateId){
+        List<Category> cateList = indexService.getPostCateList(cateId);
+        log.debug("通过分类id=【{}】,搜索分类子列表。搜索结果为:{}",cateId,cateList);
+        return Response.ok(cateList);
+    }
+
+
+
 }

+ 19 - 0
goods-service/src/main/java/io/github/nnkwrik/goodsservice/dao/GoodsMapper.java

@@ -136,4 +136,23 @@ public interface GoodsMapper {
     List<GoodsComment> findReplyComment(@Param("reply_comment_id") int commentId);
 
 
+    @Select("insert into goods (category_id,\n" +
+            "                   seller_id,\n" +
+            "                   name,\n" +
+            "                   price,\n" +
+            "                   market_price,\n" +
+            "                   postage,\n" +
+//            "                   primary_pic_url,\n" +
+            "                   `desc`,\n" +
+            "                   region_id,\n" +
+            "                   region,\n" +
+            "                   able_express,\n" +
+            "                   able_meet,\n" +
+            "                   able_self_take)\n" +
+            "values (#{categoryId},#{sellerId},#{name},#{price}," +
+            "#{marketPrice},#{postage}," +
+//            "#{primaryPicUrl}," +
+            "#{desc}," +
+            "#{regionId},#{region},#{ableExpress},#{ableMeet},#{ableSelfTake});")
+    void addGoods(Goods goods);
 }

+ 7 - 0
goods-service/src/main/java/io/github/nnkwrik/goodsservice/dao/OtherMapper.java

@@ -1,7 +1,9 @@
 package io.github.nnkwrik.goodsservice.dao;
 
 import io.github.nnkwrik.goodsservice.model.po.Ad;
+import io.github.nnkwrik.goodsservice.model.po.Category;
 import io.github.nnkwrik.goodsservice.model.po.Channel;
+import io.github.nnkwrik.goodsservice.model.po.Region;
 import org.apache.ibatis.annotations.*;
 
 import java.util.List;
@@ -62,4 +64,9 @@ public interface OtherMapper {
                     @Param("reply_user_id") String replyUserId,
                     @Param("content") String content);
 
+    @Select("select id,name from region where parent_id=#{parent_id}")
+    List<Region> getRegionByParentId(@Param("parent_id") int parentId);
+
+    @Select("select id,name from category where parent_id=#{parent_id}")
+    List<Category> getCateByParentId(@Param("parent_id") int parentId);
 }

+ 9 - 0
goods-service/src/main/java/io/github/nnkwrik/goodsservice/model/po/Goods.java

@@ -23,4 +23,13 @@ public class Goods {
     private Boolean isOnSale;
     private Boolean isDelete;
     private Date lastEdit;
+
+    private Integer regionId;
+    private String region;
+
+    private Double postage;
+
+    private Boolean ableSelfTake;
+    private Boolean ableMeet;
+    private Boolean ableExpress;
 }

+ 16 - 0
goods-service/src/main/java/io/github/nnkwrik/goodsservice/model/po/Region.java

@@ -0,0 +1,16 @@
+package io.github.nnkwrik.goodsservice.model.po;
+
+import lombok.Data;
+
+/**
+ * @author nnkwrik
+ * @date 18/11/26 21:17
+ */
+@Data
+public class Region {
+    private Integer id;
+    private Integer parentId;
+    private String name;
+    private Integer type;
+    private Integer agencyId;
+}

+ 3 - 0
goods-service/src/main/java/io/github/nnkwrik/goodsservice/service/GoodsService.java

@@ -1,5 +1,6 @@
 package io.github.nnkwrik.goodsservice.service;
 
+import io.github.nnkwrik.goodsservice.model.po.Goods;
 import io.github.nnkwrik.goodsservice.model.vo.CategoryPageVo;
 import io.github.nnkwrik.goodsservice.model.vo.GoodsRelatedVo;
 import io.github.nnkwrik.goodsservice.model.vo.inner.CommentVo;
@@ -27,4 +28,6 @@ public interface GoodsService {
     List<CommentVo> getGoodsComment(int goodsId);
 
     Boolean userHasCollect(String userId, int goodsId);
+
+    void postGoods(Goods goods);
 }

+ 7 - 0
goods-service/src/main/java/io/github/nnkwrik/goodsservice/service/IndexService.java

@@ -1,8 +1,12 @@
 package io.github.nnkwrik.goodsservice.service;
 
+import io.github.nnkwrik.goodsservice.model.po.Category;
+import io.github.nnkwrik.goodsservice.model.po.Region;
 import io.github.nnkwrik.goodsservice.model.vo.CatalogVo;
 import io.github.nnkwrik.goodsservice.model.vo.IndexVO;
 
+import java.util.List;
+
 /**
  * @author nnkwrik
  * @date 18/11/16 15:22
@@ -19,4 +23,7 @@ public interface IndexService {
 
     void addComment(int goodsId, String userId, int replyCommentId, String replyUserId, String content);
 
+    List<Region> getRegionList(int regionId);
+
+    List<Category> getPostCateList(int cateId);
 }

+ 5 - 0
goods-service/src/main/java/io/github/nnkwrik/goodsservice/service/impl/GoodsServiceImpl.java

@@ -112,6 +112,11 @@ public class GoodsServiceImpl implements GoodsService {
         return otherMapper.userHasCollect(userId, goodsId);
     }
 
+    @Override
+    public void postGoods(Goods goods) {
+        goodsMapper.addGoods(goods);
+    }
+
     @Override
     public List<CommentVo> getGoodsComment(int goodsId) {
         List<GoodsComment> baseComment = goodsMapper.findBaseComment(goodsId);

+ 10 - 0
goods-service/src/main/java/io/github/nnkwrik/goodsservice/service/impl/IndexServiceImpl.java

@@ -91,5 +91,15 @@ public class IndexServiceImpl implements IndexService {
         otherMapper.addComment(goodsId,userId,replyCommentId,replyUserId,content);
     }
 
+    @Override
+    public List<Region> getRegionList(int regionId) {
+        return otherMapper.getRegionByParentId(regionId);
+    }
+
+    @Override
+    public List<Category> getPostCateList(int cateId) {
+        return otherMapper.getCateByParentId(cateId);
+    }
+
 
 }

+ 12 - 0
wx-front/app.js

@@ -36,5 +36,17 @@ App({
       avatarUrl: 'https://avatars2.githubusercontent.com/u/29662114?s=460&v=4'
     },
     token: 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdmF0YXJVcmwiOiJodHRwczovL2F2YXRhcnMyLmdpdGh1YnVzZXJjb250ZW50LmNvbS91LzI5NjYyMTE0P3M9NDYwJnY9NCIsIm9wZW5JZCI6IjEiLCJuaWNrTmFtZSI6Iua1i-ivleeUqOaItyIsImV4cCI6MTU0MzEyNzQ4OH0.ObcfDrCIgtY6AuqKqwZd_r8HnmjzHH_GsLA7161nBzUJeg2gvJ9xhMNniOKu0BmMI4dXn8TYyBLkee9y1xphLHCyQZwqgsLYKZFTfbcmSbpDAXjknA8qIsVAGpp5srChB6LoM1GDWiIRetJ-kBn0WopypMNck8kLFe6gdw7NyoafP0Wzrryf7DWAL56TlSOZ_IcubavcF58wX2oOMdS8_Q9NSh9Jj5lWJKkqAm395wdbnurFjOF3PtM5OlrJt4hqKcv3Sd9C_MOFiA3svlmmYjNfhUl8E9HEJpm1b5DmwxgkzMLty1VtZliL9hn0Ius4YOXJlk7IuLgHgBfDA2OyXQ',
+  },
+  post:{
+    cate: {
+      id: 0,
+      name: ''
+    },
+    region: {
+      id: 0,
+      name: ''
+    }
   }
+
+
 })

+ 6 - 2
wx-front/app.json

@@ -30,7 +30,11 @@
     "pages/shopping/addressAdd/addressAdd",
     "pages/goods/goods",
     "pages/topicDetail/topicDetail",
-    "pages/auth/auth"
+    "pages/auth/auth",
+    "pages/post/post",
+    "pages/region/region",
+    "pages/nav2post/nav2post",
+    "pages/postCate/postCate"
   ],
   "window": {
     "backgroundTextStyle": "dark",
@@ -58,7 +62,7 @@
         "text": "分类"
       },
       {
-        "pagePath": "pages/topic/topic",
+        "pagePath": "pages/nav2post/nav2post",
         "iconPath": "static/images/ic_menu_add_nor.png",
         "selectedIconPath": "static/images/ic_menu_add_nor.png",
         "text": "发布"

+ 5 - 2
wx-front/config/api.js

@@ -1,5 +1,5 @@
-//const ApiRootUrl = 'https://23788fbf.ngrok.io/';
-const ApiRootUrl = 'http://127.0.0.1:8080/';
+const ApiRootUrl = 'http://8456bb23.ngrok.io/';
+// const ApiRootUrl = 'http://127.0.0.1:8080/';
 
 module.exports = {
   IndexUrl: ApiRootUrl + 'index/index', //首页数据接口
@@ -15,6 +15,9 @@ module.exports = {
   GoodsNew: ApiRootUrl + 'goods/new',  //新品
   GoodsHot: ApiRootUrl + 'goods/hot',  //热门
   GoodsRelated: ApiRootUrl + 'goods/related',  //商品详情页的关联商品(大家都在看)
+  GoodsPost: ApiRootUrl + 'goods/post', //发布商品
+
+  PostCateList: ApiRootUrl + 'category/post', //发布商品时选择分类
 
   BrandList: ApiRootUrl + 'brand/list',  //品牌列表
   BrandDetail: ApiRootUrl + 'brand/detail',  //品牌详情

+ 2 - 2
wx-front/pages/catalog/catalog.wxml

@@ -7,7 +7,7 @@
   </view>
   <view class="catalog">
     <scroll-view class="nav" scroll-y="true">
-        <view class="item {{ currentCategory.id == item.id ? 'active' : ''}}" wx:for="{{navList}}"  data-id="{{item.id}}" data-index="{{index}}" bindtap="switchCate">{{item.name}}</view>
+        <view class="item {{ currentCategory.id == item.id ? 'active' : ''}}" wx:for="{{navList}}"  data-id="{{item.id}}" data-index="{{index}}" bindtap="switchCate"  wx:key="{{item.id}}">{{item.name}}</view>
     </scroll-view>
     <scroll-view class="cate" scroll-y="true">
         <view class="banner">
@@ -19,7 +19,7 @@
             <text class="line"></text>
         </view>
         <view class="bd">
-            <navigator url="/pages/category/category?id={{item.id}}" class="item {{(index+1) % 3 == 0 ? 'last' : ''}}" wx:for="{{currentCategory.subCategoryList}}">
+            <navigator url="/pages/category/category?id={{item.id}}" class="item {{(index+1) % 3 == 0 ? 'last' : ''}}" wx:for="{{currentCategory.subCategoryList}}" wx:key="{{item.id}}">
                 <image class="icon" src="{{item.wap_banner_url}}"></image>
                 <text class="txt">{{item.name}}</text>
             </navigator>

+ 1 - 1
wx-front/pages/commentPost/commentPost.json

@@ -1,3 +1,3 @@
 {
-  "navigationBarTitleText": "填写留言"
+  "navigationBarTitleText": "发布宝贝"
 }

+ 24 - 8
wx-front/pages/commentPost/commentPost.wxml

@@ -1,12 +1,28 @@
 <view class="container">
   <view class="post-comment">
-        <view class="input-box">
-            <textarea class="content" focus="true" bindinput="bindInpuntValue" maxlength="140" placeholder="留言经过筛选后,对所有人可见" />
-            <text class="count">{{140 - content.length}}</text>
-        </view>
-        <view class="btns">
-            <view class="close" bindtap="onClose">取消</view>
-            <view class="post" bindtap="onPost">发表</view>
-        </view>
+    <textarea class="title" focus="true" maxlength="60" placeholder="标题,品牌品类都是买家喜欢搜索的" />
+
+    <view class="input-box">
+      <textarea class="content" focus="true" bindinput="bindInpuntValue" maxlength="800" placeholder="描述一下宝贝的转手原因,入手渠道和使用感受" />
+      <text class="count">{{800 - content.length}}</text>
     </view>
+
+    <view class='post-img'>
+
+    </view>
+
+
+
+
+
+  </view>
+  <view class="detail">
+    <textarea class="price" focus="true" maxlength="8" placeholder="¥0.00" />
+    <textarea class="price" focus="true" maxlength="8" placeholder="¥0.00" />
+    <textarea class="price" focus="true" maxlength="3" placeholder="¥0.00" />
+  </view>
+
+  <view class="bottom-btn">
+    <button class="r">确认发布</button>
+  </view>
 </view>

+ 47 - 0
wx-front/pages/commentPost/commentPost.wxss

@@ -30,6 +30,22 @@ page, .container {
   padding: 20rpx;
 }
 
+.post-comment .title {
+  /* position: absolute; */
+  top: 0;
+  left: 0;
+  display: block;
+  background: #fff;
+  font-size: 29rpx;
+  color: #333;
+  height:35rpx;
+  width: 650rpx;
+  padding: 20rpx;
+  /* margin:10px; */
+  border-bottom: 1px solid #ddd;
+  overflow:hidden;
+}
+
 .post-comment .input-box .count {
   position: absolute;
   bottom: 20rpx;
@@ -61,3 +77,34 @@ page, .container {
   text-align: right;
   padding: 0 30rpx;
 }
+
+.bottom-btn {
+  position: fixed;
+  left: 0;
+  bottom: 0;
+  z-index: 10;
+  width: 750rpx;
+  /* height: 100rpx; */
+  display: flex;
+  background: #fff;
+  padding:10rpx;
+}
+
+.bottom-btn .r {
+  border: 1px solid #f94b4b;
+  background: #f94b4b;
+  float: left;
+  height: 100rpx;
+  line-height: 96rpx;
+  flex: 1;
+  text-align: center;
+  color: #fff;
+}
+
+.detail {
+  margin-top: 20rpx;
+  width: 750rpx;
+  height: auto;
+  overflow: hidden;
+  padding: 30rpx;
+}

+ 5 - 2
wx-front/pages/goods/goods.js

@@ -251,7 +251,7 @@ Page({
 
   postComment: function(event) {
     let that = this
-    if (!event.detail.value) {
+    if (event.detail.value.trim()=='') {
       util.showErrorToast('请填写内容')
       return false;
     }
@@ -281,7 +281,9 @@ Page({
 
   addCannelCollect: function() {
     let that = this;
-    that.checkLogin();
+    user.checkLoginAndNav().then(()=>{
+
+    
     //添加或是取消收藏
     util.request(api.CollectAddOrDelete + '/' + this.data.id + '/' + this.data.userHasCollect, {}, "POST")
       .then(function(res) {
@@ -310,6 +312,7 @@ Page({
           });
         }
       });
+    })
   },
   // openCartPage: function () {
   //   wx.switchTab({

+ 9 - 4
wx-front/pages/index/index.wxml

@@ -1,4 +1,3 @@
-
 <!--index.wxml-->
 <view class="container">
   <swiper class="banner" indicator-dots="true" autoplay="true" interval="3000" duration="1000">
@@ -7,14 +6,20 @@
         <image src="{{item.image_url}}" background-size="cover"></image>
       </navigator>
     </swiper-item>
+
   </swiper>
-  
+
   <!-- 首页分类 -->
   <view class="m-menu">
-    <navigator  class="item" url="{{item.url}}" wx:for="{{channel}}" wx:key="{{item.id}}">
+    <navigator class="item" url="{{item.url}}" wx:for="{{channel}}" wx:key="{{item.id}}">
       <image src="{{item.icon_url}}" background-size="cover"></image>
       <text>{{item.name}}</text>
     </navigator>
+    <navigator open-type="reLaunch" class="item" url="/pages/catalog/catalog">
+      <image src="https://i.postimg.cc/x17Z3PJd/visualization.png" background-size="cover"></image>
+      <text>全部分类</text>
+    </navigator>
+
   </view>
 
 
@@ -111,7 +116,7 @@
     </view>
   </view> -->
 
-<!-- floorGoods[0].goodList -->
+  <!-- floorGoods[0].goodList -->
   <!-- <view class="good-grid" wx:for="{{floorGoods}}" wx:key="{{item.id}}">
     <view class="h">
       <view>

+ 69 - 0
wx-front/pages/nav2post/nav2post.js

@@ -0,0 +1,69 @@
+// pages/topbarNav/topbarNav.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+      wx.navigateTo({
+        url: '/pages/post/post',
+      })
+    
+    
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+    
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 1 - 0
wx-front/pages/nav2post/nav2post.json

@@ -0,0 +1 @@
+{}

+ 1 - 0
wx-front/pages/nav2post/nav2post.wxml

@@ -0,0 +1 @@
+<!-- 只用于跳转到post页面 -->

+ 1 - 0
wx-front/pages/nav2post/nav2post.wxss

@@ -0,0 +1 @@
+/* pages/topbarNav/topbarNav.wxss */

+ 222 - 0
wx-front/pages/post/post.js

@@ -0,0 +1,222 @@
+var app = getApp();
+var util = require('../../utils/util.js');
+var api = require('../../config/api.js');
+var user = require('../../services/user.js');
+Page({
+  data: {
+    desc: '',
+    title: '',
+    regionId: 0,
+    region: '',
+    price: '',
+    marketPrice: '',
+    isPostageFree: false,
+    postage: null,
+    ableSelfTake: false,
+    ableMeet: false,
+    ableExpress: false,
+    cateId: 0,
+    cateName:''
+  },
+  onLoad: function(options) {
+
+    var that = this;
+    user.checkLoginAndNav()
+
+  },
+  onClose() {
+    wx.navigateBack({
+      delta: 1
+    });
+  },
+  onPost() {
+    if (this.data.title.trim() == '') {
+      util.showErrorToast('必须填写商品名')
+      return;
+    }
+
+    if (this.data.desc.trim() == '') {
+      util.showErrorToast('必须填写介绍')
+      return;
+    }
+    if (this.data.region.trim() == '') {
+      util.showErrorToast('请选择发货地点')
+      return;
+    }
+    if (this.data.cateName.trim() == '') {
+      util.showErrorToast('请选择分类')
+      return;
+    }
+
+    let reg1 = /^[0-9]+(.[0-9]{1,})?$/;
+    let reg2 = /^[0-9]+(.[0-9]{1,2})?$/;
+
+    if (this.data.price == '') {
+      util.showErrorToast('必须填写价格')
+      return;
+    }
+
+    let postage = this.data.postage == null ? '0.00' : this.data.postage
+    this.setData({
+      marketPrice: this.data.marketPrice == '' ? '0' : this.data.marketPrice
+    })
+
+    if (!reg1.test(this.data.price) || !reg1.test(this.data.marketPrice) || !reg1.test(postage)) {
+      util.showErrorToast('价格必须是数字')
+      return;
+    }
+    if (!reg2.test(this.data.price) || !reg2.test(this.data.marketPrice) || !reg2.test(postage)) {
+      util.showErrorToast('小数必须是最大2位')
+      return;
+    }
+    if (parseFloat(this.data.price) >= 100000000 || parseFloat(this.data.marketPrice) >= 100000000) {
+      util.showErrorToast("必须在0到1亿元之间")
+      return;
+    }
+    if (parseFloat(postage) > 1000) {
+      util.showErrorToast("邮费最大1千元")
+      return;
+    }
+    if (!this.data.ableSelfTake && !this.data.ableMeet && !this.data.ableExpress ){
+      util.showErrorToast("请选择交易方式")
+      return;
+    }
+
+    let that = this
+    user.checkLoginAndNav().then(() => {
+    util.request(api.GoodsPost, {
+      name: this.data.title,
+      desc: this.data.desc,
+      regionId: this.data.regionId,
+      region: this.data.region,
+      categoryId: this.data.cateId,
+      price: this.data.price,
+      marketPrice: this.data.marketPrice,
+      postage: postage,
+      ableSelfTake: this.data.ableSelfTake,
+      ableMeet: this.data.ableMeet,
+      ableExpress: this.data.ableExpress
+    }, 'POST').then(function(res) {
+      if (res.errno === 0) {
+
+        setTimeout(function goback(){
+          wx.reLaunch({
+            url: '/pages/index/index'
+          })
+        }, 1000)
+
+        wx.showToast({
+          title: '发布成功'
+        })
+      }
+
+      console.log(res)
+    });
+    })
+
+  },
+  bindInputDesc(event) {
+    this.setData({
+      desc: event.detail.value,
+    })
+    console.log(event.detail)
+  },
+  bindInputTitle(event) {
+    this.setData({
+      title: event.detail.value,
+    })
+    console.log(event.detail)
+  },
+  bindInputPrice(event) {
+    this.setData({
+      price: event.detail.value,
+    })
+    console.log(event.detail)
+
+  },
+  bindInputMarketPrice(event) {
+    this.setData({
+      marketPrice: event.detail.value,
+    })
+  },
+  bindInputPostage(event) {
+    this.setData({
+      postage: event.detail.value,
+    })
+  },
+  postageFree(event) {
+    if (event.detail.value[0]) {
+      this.setData({
+        isPostageFree: true,
+        postage: null
+      })
+    } else {
+      this.setData({
+        isPostageFree: false,
+
+      })
+    }
+    console.log(event.detail.value[0])
+  },
+  trade(event) {
+    this.setData({
+      ableSelfTake: false,
+      ableMeet: false,
+      ableExpress: false,
+    })
+    for (let i in event.detail.value) {
+      console.log(event.detail.value[i])
+      if (event.detail.value[i] == 'ableSelfTake') {
+        this.setData({
+          ableSelfTake: true,
+        })
+      } else if (event.detail.value[i] == 'ableMeet') {
+        this.setData({
+          ableMeet: true,
+        })
+      } else if (event.detail.value[i] == 'ableExpress') {
+        this.setData({
+          ableExpress: true,
+        })
+      }
+    };
+
+    console.log(event.detail)
+  },
+  onReady: function() {
+
+  },
+  onShow: function() {
+    // 页面显示
+    if (app.post.region.id) {
+      this.setData({
+        regionId: app.post.region.id,
+        region: app.post.region.name
+      });
+      app.post.region.id = 0;
+      app.post.region.name = ''
+    }
+
+    if(app.post.cate.id){
+      this.setData({
+        cateId: app.post.cate.id,
+        cateName: app.post.cate.name
+      });
+      app.post.cate.id = 0;
+      app.post.cate.name = ''
+    }
+  },
+  onHide: function() {
+    // 页面隐藏
+
+  },
+  onUnload: function() {
+    // 页面关闭
+    //重启
+    wx.reLaunch({
+      url: '/pages/index/index'
+    })
+
+
+  }
+})

+ 3 - 0
wx-front/pages/post/post.json

@@ -0,0 +1,3 @@
+{
+  "navigationBarTitleText": "发布宝贝"
+}

+ 61 - 0
wx-front/pages/post/post.wxml

@@ -0,0 +1,61 @@
+<view class="container">
+  <view class="post-goods">
+    <input class="title" maxlength="60" placeholder="标题,品牌品类都是买家喜欢搜索的" bindinput='bindInputTitle'/>
+
+    <view class="input-box">
+      <textarea class="content" bindinput="bindInputDesc" maxlength="800" placeholder="描述一下宝贝的转手原因,入手渠道和使用感受" />
+      <text class="count">{{800 - desc.length}}</text>
+    </view>
+
+    <navigator url="../region/region" class='location'>
+      <view class="icon" wx:if='{{!regionId}}'>选择发货地点</view>
+      <view class="icon" wx:else>{{region}}</view>
+    </navigator>
+
+
+  </view>
+  <view class="detail">
+    <view class="element">
+      <view class="lable">价格</view>
+      <view class="rmb">¥</view>
+      <input class="price" type="digit" placeholder="0.00"  bindinput='bindInputPrice' />
+    </view>
+    <view class="element">
+      <view class="lable">入手价</view>
+      <view class="rmb">¥</view>
+      <input class="price" type="digit"  placeholder="0.00"  bindinput='bindInputMarketPrice'/>
+    </view>
+    <view class="element">
+      <view class="lable">运费</view>
+      <view class="rmb">¥</view>
+      <input class="price" type="digit"  placeholder="0.00" bindinput='bindInputPostage' value='{{postage}}' disabled='{{isPostageFree}}'/>
+      <checkbox-group bindchange="postageFree">
+        <label class="checkbox-a">
+          <checkbox value="true" color="#fd9f06" />包邮
+        </label>
+      </checkbox-group>
+    </view>
+    <navigator url="../postCate/postCate"  class="element">
+      <view class="lable">分类</view>
+      
+      <view class="cate">{{cateName  ? cateName : '选择分类'}}</view>
+      <image background-size="cover" class="i" src="../../static/images/address_right.png"></image>
+    </navigator>
+
+    <view class="element">
+      <view class="lable">交易方式</view>
+      <checkbox-group bindchange="trade">
+        <label>
+          <checkbox class="checkbox-b" value="ableSelfTake" color="#fd9f06" />自提
+          <checkbox class="checkbox-b" value="ableMeet" color="#fd9f06" />同城面交
+          <checkbox class="checkbox-b" value="ableExpress" color="#fd9f06" />邮寄
+        </label>
+      </checkbox-group>
+    </view>
+
+  </view>
+
+  <view class="bottom-btn">
+    <button class="r"  bindtap='onPost'>确认发布</button>
+  </view>
+</view>

+ 165 - 0
wx-front/pages/post/post.wxss

@@ -0,0 +1,165 @@
+page, .container {
+  height: 100%;
+  background: #f4f4f4;
+}
+
+.post-goods {
+  width: 750rpx;
+  height: auto;
+  overflow: hidden;
+  padding: 30rpx;
+}
+
+.post-goods .input-box {
+  height: 337.5rpx;
+  width: 690rpx;
+  position: relative;
+  background: #fff;
+}
+
+.post-goods .input-box .content {
+  position: absolute;
+  top: 0;
+  left: 0;
+  display: block;
+  background: #fff;
+  font-size: 29rpx;
+  color: #333;
+  height: 300rpx;
+  width: 650rpx;
+  padding: 20rpx;
+}
+
+.post-goods .title {
+  /* position: absolute; */
+  top: 0;
+  left: 0;
+  display: block;
+  background: #fff;
+  font-size: 29rpx;
+  color: #333;
+  height: 35rpx;
+  width: 650rpx;
+  padding: 20rpx;
+  /* margin:10px; */
+  border-bottom: 1px solid #ddd;
+  overflow: hidden;
+}
+
+.post-goods .input-box .count {
+  position: absolute;
+  bottom: 20rpx;
+  right: 20rpx;
+  display: block;
+  height: 30rpx;
+  width: 50rpx;
+  font-size: 29rpx;
+  color: #999;
+}
+
+.post-goods .btns {
+  height: 108rpx;
+}
+
+.post-goods .close {
+  float: left;
+  height: 108rpx;
+  line-height: 108rpx;
+  text-align: left;
+  color: #666;
+  padding: 0 30rpx;
+}
+
+.post-goods .post {
+  float: right;
+  height: 108rpx;
+  line-height: 108rpx;
+  text-align: right;
+  padding: 0 30rpx;
+}
+
+.bottom-btn {
+  position: fixed;
+  left: 0;
+  bottom: 0;
+  z-index: 10;
+  width: 750rpx;
+  /* height: 100rpx; */
+  display: flex;
+  background: #fff;
+  padding: 10rpx;
+}
+
+.bottom-btn .r {
+  border: 1px solid #f94b4b;
+  background: #f94b4b;
+  float: left;
+  height: 100rpx;
+  line-height: 96rpx;
+  flex: 1;
+  text-align: center;
+  color: #fff;
+}
+
+.detail {
+  margin: 0 30rpx 0 30rpx;
+  width: 690rpx;
+  height: auto;
+  overflow: hidden;
+  padding: 30rpx;
+  background: #fff;
+  padding-top: 10rpx;
+}
+
+.detail .element {
+  display: flex;
+  height: 70rpx;
+  border-bottom: 1rpx solid #eee;
+  margin-top: 30rpx;
+}
+
+.detail .lable {
+  width: 130rpx;
+  margin-right: 10rpx;
+  line-height: 60rpx;
+}
+
+.detail .price {
+  font-size: 35rpx;
+  width: 310rpx;
+}
+
+.detail .checkbox-b {
+  margin: 0 10rpx 0 5rpx;
+}
+
+.location {
+  display: flex;
+  background: #fff;
+  padding: 0 0 20rpx 20rpx;
+}
+
+.location  .icon {
+  background: url(https://i.postimg.cc/Hkf6dJzv/placeholder-2.png) 0 center no-repeat;
+  background-size: 30rpx;
+  margin-right: 80rpx;
+  padding-left: 38rpx;
+  color: #666;
+}
+
+.detail .rmb {
+  line-height: 50rpx;
+  margin-right: 10rpx;
+}
+
+.detail .i {
+  float: right;
+  width: 45rpx;
+  height: 45rpx;
+}
+
+.detail .cate{
+  line-height: 50rpx;
+  width:400rpx;
+  color:#666;
+}

+ 111 - 0
wx-front/pages/postCate/postCate.js

@@ -0,0 +1,111 @@
+var app = getApp();
+var util = require('../../utils/util.js');
+var api = require('../../config/api.js');
+
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    parentId: 0,
+    name: '',
+    cateList: []
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    var that = this;
+    if (options.id && options.name) {
+      that.setData({
+        parentId: parseInt(options.id),
+        name: parseInt(options.name)
+      });
+    }
+
+    that.getCateList();
+
+  },
+
+  getCateList() {
+    let that = this;
+    util.request(api.PostCateList + '/' + that.data.parentId).then(function (res) {
+      if (res.errno === 0) {
+        if (res.data.length > 0) {
+          that.setData({
+            cateList: res.data
+          })
+        } else {
+          console.log(that.data.name)
+          app.post.cate.id = that.data.parentId;
+          app.post.cate.name = that.data.name;
+          wx.navigateBack({
+            delta: 1
+          })
+
+        }
+      }
+      console.log(res)
+    });
+  },
+  tapCate: function (event) {
+    if (event.currentTarget.dataset.id != this.data.parentId) {
+      this.setData({
+        parentId: event.currentTarget.dataset.id,
+        name: this.data.name + ' ' + event.currentTarget.dataset.name,
+      })
+      this.getCateList();
+    }
+
+  },
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 1 - 0
wx-front/pages/postCate/postCate.json

@@ -0,0 +1 @@
+{}

+ 13 - 0
wx-front/pages/postCate/postCate.wxml

@@ -0,0 +1,13 @@
+<view class="container">
+
+  <view class="cate">
+    <view class="item" wx:for="{{cateList}}" wx:for-index="index" wx:for-item="item" wx:key="{{item.id}}">
+      <view class="element" bindtap="tapCate" data-id="{{item.id}}" data-name="{{item.name}}"  >
+        <view class="lable">{{item.name}}</view>
+        <image background-size="cover" class="i" src="../../static/images/address_right.png"></image>
+      </view>
+    </view>
+
+  </view>
+
+</view>

+ 38 - 0
wx-front/pages/postCate/postCate.wxss

@@ -0,0 +1,38 @@
+page, .container {
+  height: 100%;
+  background: #f4f4f4;
+}
+
+
+.cate {
+  margin:30rpx 30rpx 0 30rpx;
+  width: 690rpx;
+  height: auto;
+  overflow: hidden;
+  padding:0 30rpx 30rpx 30rpx;
+  background: #fff;
+}
+
+
+.cate .element {
+  display: flex;
+  height: 70rpx;
+  border-bottom: 1rpx solid #eee;
+  margin-top: 30rpx;
+}
+
+.cate .lable {
+  line-height: 60rpx;
+  margin-left:10px;
+  width:600rpx;
+
+}
+
+
+.cate .i{
+float:right;
+width:45rpx;
+height:45rpx;
+
+}
+

+ 115 - 0
wx-front/pages/region/region.js

@@ -0,0 +1,115 @@
+var app = getApp();
+var util = require('../../utils/util.js');
+var api = require('../../config/api.js');
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    parentId: 1,
+    name: '',
+    regionList: []
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function(options) {
+    var that = this;
+    if (options.id && options.name) {
+      that.setData({
+        parentId: parseInt(options.id),
+        name: parseInt(options.name)
+      });
+    }
+
+    that.getRegionList();
+
+  },
+
+  getRegionList() {
+    let that = this;
+    util.request(api.RegionList + '/' + that.data.parentId).then(function(res) {
+      if (res.errno === 0) {
+        if (res.data.length > 0) {
+          that.setData({
+            regionList: res.data
+          })
+        } else {
+          console.log(that.data.name)
+          app.post.region.id = that.data.parentId;
+          app.post.region.name = that.data.name;
+          wx.navigateBack({
+            delta: 1
+          })
+
+        }
+      }
+      console.log(res)
+    });
+  },
+  tapRegion: function(event) {
+    if (event.currentTarget.dataset.id != this.data.parentId){
+      this.setData({
+        parentId: event.currentTarget.dataset.id,
+        name: this.data.name + ' ' + event.currentTarget.dataset.name,
+      })
+      this.getRegionList();
+    }
+    
+  },
+  // clickSkuValue: function (event) {
+  //   let that = this;
+  //   let specNameId = event.currentTarget.dataset.nameId;
+  //   let specValueId = event.currentTarget.dataset.valueId;
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function() {
+
+  }
+})

+ 1 - 0
wx-front/pages/region/region.json

@@ -0,0 +1 @@
+{}

+ 14 - 0
wx-front/pages/region/region.wxml

@@ -0,0 +1,14 @@
+<view class="container">
+
+  <view class="region">
+    <view class="item" wx:for="{{regionList}}" wx:for-index="index" wx:for-item="item" wx:key="{{item.id}}">
+      <view class="element" bindtap="tapRegion" data-id="{{item.id}}" data-name="{{item.name}}"  >
+        <view class="lable">{{item.name}}</view>
+        <image background-size="cover" class="i" src="../../static/images/address_right.png"></image>
+      </view>
+    </view>
+
+
+  </view>
+
+</view>

+ 38 - 0
wx-front/pages/region/region.wxss

@@ -0,0 +1,38 @@
+page, .container {
+  height: 100%;
+  background: #f4f4f4;
+}
+
+
+.region {
+  margin:30rpx 30rpx 0 30rpx;
+  width: 690rpx;
+  height: auto;
+  overflow: hidden;
+  padding:0 30rpx 0 30rpx;
+  background: #fff;
+}
+
+
+.region .element {
+  display: flex;
+  height: 70rpx;
+  border-bottom: 1rpx solid #eee;
+  margin-top: 30rpx;
+}
+
+.region .lable {
+  line-height: 60rpx;
+  margin-left:10px;
+  width:600rpx;
+
+}
+
+
+.region .i{
+float:right;
+width:45rpx;
+height:45rpx;
+
+}
+

+ 10 - 0
zuul/src/main/resources/application.yml

@@ -48,6 +48,16 @@ zuul:
       serviceId: goods-service
       strip-prefix: false
       sensitiveHeaders:
+    region:
+      path: /region/**
+      serviceId: goods-service
+      strip-prefix: false
+      sensitiveHeaders:
+    category:
+      path: /category/**
+      serviceId: goods-service
+      strip-prefix: false
+      sensitiveHeaders: