Browse Source

:information_desk_person: 前端:商品详情

nnkwrik 6 năm trước cách đây
mục cha
commit
2909d1b913
100 tập tin đã thay đổi với 12522 bổ sung238 xóa
  1. 1 0
      goods-service/src/main/java/io/github/nnkwrik/goodsservice/controller/GoodsController.java
  2. 1 2
      goods-service/src/main/java/io/github/nnkwrik/goodsservice/model/vo/GoodsDetailPageVo.java
  3. 92 0
      mini-app/README.md
  4. 21 112
      mini-app/app.js
  5. 83 8
      mini-app/app.json
  6. 15 6
      mini-app/app.wxss
  7. 63 0
      mini-app/config/api.js
  8. 242 0
      mini-app/lib/wxParse/html2json.js
  9. 182 0
      mini-app/lib/wxParse/htmlparser.js
  10. 2529 0
      mini-app/lib/wxParse/showdown.js
  11. 206 0
      mini-app/lib/wxParse/wxDiscode.js
  12. 146 0
      mini-app/lib/wxParse/wxParse.js
  13. 928 0
      mini-app/lib/wxParse/wxParse.wxml
  14. 202 0
      mini-app/lib/wxParse/wxParse.wxss
  15. 106 0
      mini-app/pages/auth/login/login.js
  16. 1 0
      mini-app/pages/auth/login/login.json
  17. 30 0
      mini-app/pages/auth/login/login.wxml
  18. 89 0
      mini-app/pages/auth/login/login.wxss
  19. 130 0
      mini-app/pages/auth/register/register.js
  20. 1 0
      mini-app/pages/auth/register/register.json
  21. 30 0
      mini-app/pages/auth/register/register.wxml
  22. 89 0
      mini-app/pages/auth/register/register.wxss
  23. 56 0
      mini-app/pages/auth/reset/reset.js
  24. 1 0
      mini-app/pages/auth/reset/reset.json
  25. 20 0
      mini-app/pages/auth/reset/reset.wxml
  26. 68 0
      mini-app/pages/auth/reset/reset.wxss
  27. 56 0
      mini-app/pages/brand/brand.js
  28. 1 0
      mini-app/pages/brand/brand.json
  29. 16 0
      mini-app/pages/brand/brand.wxml
  30. 52 0
      mini-app/pages/brand/brand.wxss
  31. 63 0
      mini-app/pages/brandDetail/brandDetail.js
  32. 3 0
      mini-app/pages/brandDetail/brandDetail.json
  33. 28 0
      mini-app/pages/brandDetail/brandDetail.wxml
  34. 110 0
      mini-app/pages/brandDetail/brandDetail.wxss
  35. 281 0
      mini-app/pages/cart/cart.js
  36. 3 0
      mini-app/pages/cart/cart.json
  37. 79 0
      mini-app/pages/cart/cart.wxml
  38. 352 0
      mini-app/pages/cart/cart.wxss
  39. 76 0
      mini-app/pages/catalog/catalog.js
  40. 1 0
      mini-app/pages/catalog/catalog.json
  41. 29 0
      mini-app/pages/catalog/catalog.wxml
  42. 166 0
      mini-app/pages/catalog/catalog.wxss
  43. 116 0
      mini-app/pages/category/category.js
  44. 1 0
      mini-app/pages/category/category.json
  45. 23 0
      mini-app/pages/category/category.wxml
  46. 117 0
      mini-app/pages/category/category.wxss
  47. 115 0
      mini-app/pages/comment/comment.js
  48. 3 0
      mini-app/pages/comment/comment.json
  49. 33 0
      mini-app/pages/comment/comment.wxml
  50. 156 0
      mini-app/pages/comment/comment.wxss
  51. 80 0
      mini-app/pages/commentPost/commentPost.js
  52. 3 0
      mini-app/pages/commentPost/commentPost.json
  53. 12 0
      mini-app/pages/commentPost/commentPost.wxml
  54. 63 0
      mini-app/pages/commentPost/commentPost.wxss
  55. 331 0
      mini-app/pages/goods/goods.js
  56. 1 0
      mini-app/pages/goods/goods.json
  57. 237 0
      mini-app/pages/goods/goods.wxml
  58. 875 0
      mini-app/pages/goods/goods.wxss
  59. 105 0
      mini-app/pages/hotGoods/hotGoods.js
  60. 3 0
      mini-app/pages/hotGoods/hotGoods.json
  61. 40 0
      mini-app/pages/hotGoods/hotGoods.wxml
  62. 177 0
      mini-app/pages/hotGoods/hotGoods.wxss
  63. 54 84
      mini-app/pages/index/index.js
  64. 135 11
      mini-app/pages/index/index.wxml
  65. 370 11
      mini-app/pages/index/index.wxss
  66. 2 3
      mini-app/pages/logs/logs.js
  67. 1 1
      mini-app/pages/logs/logs.json
  68. 105 0
      mini-app/pages/newGoods/newGoods.js
  69. 3 0
      mini-app/pages/newGoods/newGoods.json
  70. 40 0
      mini-app/pages/newGoods/newGoods.wxml
  71. 177 0
      mini-app/pages/newGoods/newGoods.wxss
  72. 61 0
      mini-app/pages/pay/pay.js
  73. 3 0
      mini-app/pages/pay/pay.json
  74. 29 0
      mini-app/pages/pay/pay.wxml
  75. 123 0
      mini-app/pages/pay/pay.wxss
  76. 42 0
      mini-app/pages/payResult/payResult.js
  77. 4 0
      mini-app/pages/payResult/payResult.json
  78. 23 0
      mini-app/pages/payResult/payResult.wxml
  79. 59 0
      mini-app/pages/payResult/payResult.wxss
  80. 179 0
      mini-app/pages/search/search.js
  81. 3 0
      mini-app/pages/search/search.json
  82. 65 0
      mini-app/pages/search/search.wxml
  83. 336 0
      mini-app/pages/search/search.wxss
  84. 56 0
      mini-app/pages/shopping/address/address.js
  85. 1 0
      mini-app/pages/shopping/address/address.json
  86. 22 0
      mini-app/pages/shopping/address/address.wxml
  87. 132 0
      mini-app/pages/shopping/address/address.wxss
  88. 324 0
      mini-app/pages/shopping/addressAdd/addressAdd.js
  89. 3 0
      mini-app/pages/shopping/addressAdd/addressAdd.json
  90. 39 0
      mini-app/pages/shopping/addressAdd/addressAdd.wxml
  91. 179 0
      mini-app/pages/shopping/addressAdd/addressAdd.wxss
  92. 117 0
      mini-app/pages/shopping/checkout/checkout.js
  93. 3 0
      mini-app/pages/shopping/checkout/checkout.json
  94. 85 0
      mini-app/pages/shopping/checkout/checkout.wxml
  95. 295 0
      mini-app/pages/shopping/checkout/checkout.wxss
  96. 86 0
      mini-app/pages/topic/topic.js
  97. 1 0
      mini-app/pages/topic/topic.json
  98. 16 0
      mini-app/pages/topic/topic.wxml
  99. 94 0
      mini-app/pages/topic/topic.wxss
  100. 116 0
      mini-app/pages/topicComment/topicComment.js

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

@@ -59,6 +59,7 @@ public class GoodsController {
 
     @GetMapping("/goods/detail/{goodsId}")
     public ResponseVO<GoodsDetailPageVo> getGoodsDetail(@PathVariable("goodsId") int goodsId) {
+        //更新浏览次数
         GoodsDetailVo goodsDetail = goodsService.getGoodsDetail(goodsId);
         List<GalleryVo> goodsGallery = goodsService.getGoodsGallery(goodsId);
         //TODO comment

+ 1 - 2
goods-service/src/main/java/io/github/nnkwrik/goodsservice/model/vo/GoodsDetailPageVo.java

@@ -19,6 +19,5 @@ public class GoodsDetailPageVo {
     private GoodsDetailVo info;
     private List<GalleryVo> gallery;
     //TODO comment
-
-
+    //TODO userHasCollect
 }

+ 92 - 0
mini-app/README.md

@@ -0,0 +1,92 @@
+### NideShop商城(微信小程序端)
+
++ 界面高仿网易严选商城(主要是2016年wap版)
++ 测试数据采集自网易严选商城
++ 功能和数据库参考ecshop
++ 服务端api基于Node.js+ThinkJS+MySQL
++ 计划添加基于Vue.js的后台管理系统、PC版、Wap版
+
+**注意:当前版本功能还未完善,请勿商用。**
+
+本项目需要配合NideShop商城服务端使用,GitHub: [https://github.com/tumobi/nideshop](https://github.com/tumobi/nideshop)
+
+### 项目截图
+
+![首页](http://upload-images.jianshu.io/upload_images/3985656-c543b937ac6e79bb.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/320)
+
+![专题](http://upload-images.jianshu.io/upload_images/3985656-bd606aac3b5491c2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/320)
+
+![分类](http://upload-images.jianshu.io/upload_images/3985656-fa9565158376d439.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/320)
+
+![商品列表](http://upload-images.jianshu.io/upload_images/3985656-788b7fd2c4a558d0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/320)
+
+![商品详情](http://upload-images.jianshu.io/upload_images/3985656-99a6e0a57778d85f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/320)
+
+![购物车](http://upload-images.jianshu.io/upload_images/3985656-60ff2307d81f6bb2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/320)
+
+![订单中心](http://upload-images.jianshu.io/upload_images/3985656-dff837e6b2ec87b3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/320)
+
+
+
+### 功能列表
++ 首页
++ 分类首页、分类商品、新品首发、人气推荐商品页面
++ 商品详情页面,包含加入购物车、收藏商品、商品评论功能
++ 搜索功能
++ 专题功能
++ 品牌功能
++ 完整的购物流程,商品的加入、编辑、删除、批量选择,收货地址的选择,下单支付
++ 会员中心(订单、收藏、足迹、收货地址、意见反馈)
+....
+
+### 项目结构
+```
+├─config                
+├─lib
+│  └─wxParse   
+├─pages
+│  ├─auth
+│  │  ├─login
+│  │  ├─register
+│  │  └─reset
+│  ├─brand
+│  ├─brandDetail
+│  ├─cart
+│  ├─catalog
+│  ├─category
+│  ├─comment
+│  ├─goods
+│  ├─hotGoods
+│  ├─index
+│  ├─logs
+│  ├─newGoods
+│  ├─pay
+│  ├─search
+│  ├─shopping
+│  │  ├─address
+│  │  ├─addressAdd
+│  │  └─checkout
+│  ├─topic
+│  ├─topicDetail
+│  └─ucenter
+│      ├─address
+│      ├─addressAdd
+│      ├─collect
+│      ├─coupon
+│      ├─feedback
+│      ├─footprint
+│      ├─index
+│      ├─order
+│      └─orderDetail
+├─static
+│  └─images
+└─utils
+```
+
+### 服务端api
+项目地址:https://github.com/tumobi/nideshop
+
+### 最后
++ 喜欢别忘了 Star
++ 微信号 tumobi
++ 交流 QQ 群:497145766

+ 21 - 112
mini-app/app.js

@@ -1,116 +1,25 @@
-//app.js
-App({
-  onLaunch: function() {
-    // 展示本地存储能力
-    var logs = wx.getStorageSync('logs') || []
-    logs.unshift(Date.now())
-    wx.setStorageSync('logs', logs)
-
-    wx.getUserInfo({
-      success: res => {
-        // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
-        // 没授权的状态下调用getUserInfo会弹框
-
-        this.globalData.userInfo = res.userInfo
-        this.globalData.rawData = res.rawData
-        this.globalData.signature = res.signature
-        console.log("获取用户信息" + res.rawData)
-
-        // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
-        // 所以此处加入 callback 以防止这种情况
-        if (this.userInfoReadyCallback) {
-          console.log("app.userInfoReadyCallback" + res.iv)
-          this.userInfoReadyCallback(res)
-        }
-      }
-    })
-    // 检查sessionKey
-    wx.checkSession({
-      fail() {
-        // session_key 已经失效,需要重新执行登录流程
-        wx.login({
-          success: res => {
-            var userInfo = wx.getStorageSync("userInfo")
-            if (userInfo == null && wx.setStorageSync("token") == null){
-              //注册
-              console.log("注册")
-              wx.setStorage("userInfo", this.globalData.userInfo)
-            } else if (userInfo != this.globalData.userInfo) {
-              //更新 userInfo 和 token
-              console.log("更新 userInfo 和 token")
-              wx.setStorage("userInfo", this.globalData.userInfo)
-            } else  {
-              //更新token
-              console.log("更新token")
-            } 
-          }
-        })
-      }
-    })
+var util = require('./utils/util.js');
+var api = require('./config/api.js');
+var user = require('./services/user.js');
 
-    // 获取用户信息
-    // wx.getSetting({
-    //   success: res => {
-    //     if (res.authSetting['scope.userInfo']) {
-    //       // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
-    //       // 没授权的状态下调用getUserInfo会弹框
-    //       wx.getUserInfo({
-    //         success: res => {
-    //           console.log("app.getUserInfo" + res.iv)
-    //           // 可以将 res 发送给后台解码出 unionId
-    //           this.globalData.userInfo = res.userInfo
-    //           this.globalData.rawData = res.rawData
-    //           this.globalData.signature = res.signature
-    //           this.globalData.encryptedData = res.encryptedData
-    //           this.globalData.iv = res.iv
-
-    //           // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
-    //           // 所以此处加入 callback 以防止这种情况
-    //           if (this.userInfoReadyCallback) {
-    //             console.log("app.userInfoReadyCallback" + res.iv)
-    //             this.userInfoReadyCallback(res)
-    //           }
-    //         }
-    //       })
-    //     }
-    //   }
-    // })
-  },
-  register: function () {
-    //注册新用户
-    wx.request({
-      url: this.globalData.host + "/register",
-      data: {
-        jsCode: res.code,
-        rawData: this.globalData.rawData,
-        signature: this.globalData.signature
-      },
-      header: {
-        'content-type': 'application/json' // 默认值
-      },
-      dataType: "json",
-      method: "POST",
-      success(res) {
-        console.log(res.data)
-      }
-    })
+App({
+  onLaunch: function () {
+    //获取用户的登录信息
+    user.checkLogin().then(res => {
+      console.log('app login')
+      this.globalData.userInfo = wx.getStorageSync('userInfo');
+      this.globalData.token = wx.getStorageSync('token');
+    }).catch(() => {
+      
+    });
   },
+  
   globalData: {
-    userInfo: null,
-    rawData: '',
-    signature: '',
-    host: "https://77ee0a14.ngrok.io"
+    userInfo: {
+      nickname: 'Hi,游客',
+      username: '点击去登录',
+      avatar: 'https://i.postimg.cc/RVbDV5fN/anonymous.png'
+    },
+    token: '',
   }
-})
-
-/*
-已登录的情况
-app.getUserInfosCddGUbsg0MB3oB7tvlmfA==
-app.userInfoReadyCallbacksCddGUbsg0MB3oB7tvlmfA==
-page.userInfoReadyCallbacksCddGUbsg0MB3oB7tvlmfA==
-*/
-/*
-未登录
-先点,点击登录授权
-page.bindGetUserInfoBObXMSFjVRixIoyncg2kyA==
-*/
+})

+ 83 - 8
mini-app/app.json

@@ -1,12 +1,87 @@
 {
-  "pages":[
+  "pages": [
     "pages/index/index",
-    "pages/logs/logs"
+    "pages/catalog/catalog",
+    "pages/newGoods/newGoods",
+    "pages/hotGoods/hotGoods",
+    "pages/ucenter/address/address",
+    "pages/ucenter/addressAdd/addressAdd",
+    "pages/ucenter/footprint/footprint",
+    "pages/ucenter/order/order",
+    "pages/ucenter/orderDetail/orderDetail",
+    "pages/ucenter/express/express",
+    "pages/ucenter/feedback/feedback",
+    "pages/ucenter/coupon/coupon",
+    "pages/ucenter/collect/collect",
+    "pages/auth/login/login",
+    "pages/auth/register/register",
+    "pages/auth/reset/reset",
+    "pages/pay/pay",
+    "pages/payResult/payResult",
+    "pages/ucenter/index/index",
+    "pages/topic/topic",
+    "pages/comment/comment",
+    "pages/commentPost/commentPost",
+    "pages/topicComment/topicComment",
+    "pages/brand/brand",
+    "pages/brandDetail/brandDetail",
+    "pages/search/search",
+    "pages/category/category",
+    "pages/cart/cart",
+    "pages/shopping/checkout/checkout",
+    "pages/shopping/address/address",
+    "pages/shopping/addressAdd/addressAdd",
+    "pages/goods/goods",
+    "pages/topicDetail/topicDetail"
   ],
-  "window":{
-    "backgroundTextStyle":"light",
+  "window": {
+    "backgroundTextStyle": "dark",
     "navigationBarBackgroundColor": "#fff",
-    "navigationBarTitleText": "WeChat",
-    "navigationBarTextStyle":"black"
-  }
-}
+    "navigationBarTitleText": "仿闲鱼交易平台",
+    "navigationBarTextStyle": "black",
+    "enablePullDownRefresh": true
+  },
+  "tabBar": {
+    "backgroundColor": "#fafafa",
+    "borderStyle": "white",
+    "selectedColor": "#333",
+    "color": "#333",
+    "list": [
+      {
+        "pagePath": "pages/index/index",
+        "iconPath": "static/images/ic_menu_home_nor.png",
+        "selectedIconPath": "static/images/ic_menu_home_pressed.png",
+        "text": "首页"
+      },
+      {
+        "pagePath": "pages/catalog/catalog",
+        "iconPath": "static/images/ic_menu_cate_nor.png",
+        "selectedIconPath": "static/images/ic_menu_cate_pressed.png",
+        "text": "分类"
+      },
+      {
+        "pagePath": "pages/topic/topic",
+        "iconPath": "static/images/ic_menu_add_nor.png",
+        "selectedIconPath": "static/images/ic_menu_add_nor.png",
+        "text": "发布"
+      },
+      {
+        "pagePath": "pages/cart/cart",
+        "iconPath": "static/images/ic_menu_chat_nor.png",
+        "selectedIconPath": "static/images/ic_menu_chat_pressed.png",
+        "text": "消息"
+      },
+      {
+        "pagePath": "pages/ucenter/index/index",
+        "iconPath": "static/images/ic_menu_me_nor.png",
+        "selectedIconPath": "static/images/ic_menu_me_pressed.png",
+        "text": "我的"
+      }
+    ]
+  },
+  "networkTimeout": {
+    "request": 10000,
+    "downloadFile": 10000
+  },
+  "debug": true
+}

+ 15 - 6
mini-app/app.wxss

@@ -1,10 +1,19 @@
 /**app.wxss**/
 .container {
-  height: 100%;
-  display: flex;
-  flex-direction: column;
-  align-items: center;
-  justify-content: space-between;
-  padding: 200rpx 0;
   box-sizing: border-box;
+  background-color: #f4f4f4;
+  font-family: PingFangSC-Light,helvetica,'Heiti SC';
 } 
+
+view,image,text,navigator{
+  box-sizing: border-box;
+  padding:0;
+  margin:0;
+
+}
+
+view,text{
+  font-family: PingFangSC-Light,helvetica,'Heiti SC';
+  font-size: 29rpx;
+  color: #333;
+}

+ 63 - 0
mini-app/config/api.js

@@ -0,0 +1,63 @@
+//const ApiRootUrl = 'https://23788fbf.ngrok.io/';
+const ApiRootUrl = 'http://127.0.0.1:8804/';
+
+module.exports = {
+  IndexUrl: ApiRootUrl + 'index/index', //首页数据接口
+  CatalogList: ApiRootUrl + 'catalog/index',  //分类目录全部分类数据接口
+  CatalogCurrent: ApiRootUrl + 'catalog',  //分类目录当前分类数据接口
+
+  AuthLoginByWeixin: ApiRootUrl + 'auth/loginByWeixin', //微信登录
+
+  GoodsCount: ApiRootUrl + 'goods/count',  //统计商品总数
+  GoodsList: ApiRootUrl + 'goods/list',  //获得商品列表
+  GoodsCategory: ApiRootUrl + 'goods/category',  //获得分类数据
+  GoodsDetail: ApiRootUrl + 'goods/detail',  //获得商品的详情
+  GoodsNew: ApiRootUrl + 'goods/new',  //新品
+  GoodsHot: ApiRootUrl + 'goods/hot',  //热门
+  GoodsRelated: ApiRootUrl + 'goods/related',  //商品详情页的关联商品(大家都在看)
+
+  BrandList: ApiRootUrl + 'brand/list',  //品牌列表
+  BrandDetail: ApiRootUrl + 'brand/detail',  //品牌详情
+
+  CartList: ApiRootUrl + 'cart/index', //获取购物车的数据
+  CartAdd: ApiRootUrl + 'cart/add', // 添加商品到购物车
+  CartUpdate: ApiRootUrl + 'cart/update', // 更新购物车的商品
+  CartDelete: ApiRootUrl + 'cart/delete', // 删除购物车的商品
+  CartChecked: ApiRootUrl + 'cart/checked', // 选择或取消选择商品
+  CartGoodsCount: ApiRootUrl + 'cart/goodscount', // 获取购物车商品件数
+  CartCheckout: ApiRootUrl + 'cart/checkout', // 下单前信息确认
+
+  OrderSubmit: ApiRootUrl + 'order/submit', // 提交订单
+  PayPrepayId: ApiRootUrl + 'pay/prepay', //获取微信统一下单prepay_id
+
+  CollectList: ApiRootUrl + 'collect/list',  //收藏列表
+  CollectAddOrDelete: ApiRootUrl + 'collect/addordelete',  //添加或取消收藏
+
+  CommentList: ApiRootUrl + 'comment/list',  //评论列表
+  CommentCount: ApiRootUrl + 'comment/count',  //评论总数
+  CommentPost: ApiRootUrl + 'comment/post',   //发表评论
+
+  TopicList: ApiRootUrl + 'topic/list',  //专题列表
+  TopicDetail: ApiRootUrl + 'topic/detail',  //专题详情GoodsDetail
+  TopicRelated: ApiRootUrl + 'topic/related',  //相关专题
+
+  SearchIndex: ApiRootUrl + 'search/index',  //搜索页面数据
+  SearchResult: ApiRootUrl + 'search/result',  //搜索数据
+  SearchHelper: ApiRootUrl + 'search/helper',  //搜索帮助
+  SearchClearHistory: ApiRootUrl + 'search/clearhistory',  //搜索帮助
+
+  AddressList: ApiRootUrl + 'address/list',  //收货地址列表
+  AddressDetail: ApiRootUrl + 'address/detail',  //收货地址详情
+  AddressSave: ApiRootUrl + 'address/save',  //保存收货地址
+  AddressDelete: ApiRootUrl + 'address/delete',  //保存收货地址
+
+  RegionList: ApiRootUrl + 'region/list',  //获取区域列表
+
+  OrderList: ApiRootUrl + 'order/list',  //订单列表
+  OrderDetail: ApiRootUrl + 'order/detail',  //订单详情
+  OrderCancel: ApiRootUrl + 'order/cancel',  //取消订单
+  OrderExpress: ApiRootUrl + 'order/express', //物流详情
+
+  FootprintList: ApiRootUrl + 'footprint/list',  //足迹列表
+  FootprintDelete: ApiRootUrl + 'footprint/delete',  //删除足迹
+};

+ 242 - 0
mini-app/lib/wxParse/html2json.js

@@ -0,0 +1,242 @@
+/**
+ * author: Di (微信小程序开发工程师)
+ * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
+ *               垂直微信小程序开发交流社区
+ * 
+ * github地址: https://github.com/icindy/wxParse
+ * 
+ * for: 微信小程序富文本解析
+ * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
+ */
+
+var __placeImgeUrlHttps = "https";
+var __emojisReg = '';
+var __emojisBaseSrc = '';
+var __emojis = {};
+var wxDiscode = require('wxDiscode.js');
+var HTMLParser = require('htmlparser.js');
+// Empty Elements - HTML 5
+var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr");
+// Block Elements - HTML 5
+var block = makeMap("br,a,code,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video");
+
+// Inline Elements - HTML 5
+var inline = makeMap("abbr,acronym,applet,b,basefont,bdo,big,button,cite,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var");
+
+// Elements that you can, intentionally, leave open
+// (and which close themselves)
+var closeSelf = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr");
+
+// Attributes that have their values filled in disabled="disabled"
+var fillAttrs = makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected");
+
+// Special Elements (can contain anything)
+var special = makeMap("wxxxcode-style,script,style,view,scroll-view,block");
+function makeMap(str) {
+    var obj = {}, items = str.split(",");
+    for (var i = 0; i < items.length; i++)
+        obj[items[i]] = true;
+    return obj;
+}
+
+function q(v) {
+    return '"' + v + '"';
+}
+
+function removeDOCTYPE(html) {
+    return html
+        .replace(/<\?xml.*\?>\n/, '')
+        .replace(/<!doctype.*\>\n/, '')
+        .replace(/<!DOCTYPE.*\>\n/, '');
+}
+
+
+function html2json(html, bindName) {
+    //处理字符串
+    html = removeDOCTYPE(html);
+    html = wxDiscode.strDiscode(html);
+    //生成node节点
+    var bufArray = [];
+    var results = {
+        node: bindName,
+        nodes: [],
+        images:[],
+        imageUrls:[]
+    };
+    HTMLParser(html, {
+        start: function (tag, attrs, unary) {
+            //debug(tag, attrs, unary);
+            // node for this element
+            var node = {
+                node: 'element',
+                tag: tag,
+            };
+
+            if (block[tag]) {
+                node.tagType = "block";
+            } else if (inline[tag]) {
+                node.tagType = "inline";
+            } else if (closeSelf[tag]) {
+                node.tagType = "closeSelf";
+            }
+
+            if (attrs.length !== 0) {
+                node.attr = attrs.reduce(function (pre, attr) {
+                    var name = attr.name;
+                    var value = attr.value;
+                    if (name == 'class') {
+                        console.dir(value);
+                        //  value = value.join("")
+                        node.classStr = value;
+                    }
+                    // has multi attibutes
+                    // make it array of attribute
+                    if (name == 'style') {
+                        console.dir(value);
+                        //  value = value.join("")
+                        node.styleStr = value;
+                    }
+                    if (value.match(/ /)) {
+                        value = value.split(' ');
+                    }
+                    
+
+                    // if attr already exists
+                    // merge it
+                    if (pre[name]) {
+                        if (Array.isArray(pre[name])) {
+                            // already array, push to last
+                            pre[name].push(value);
+                        } else {
+                            // single value, make it array
+                            pre[name] = [pre[name], value];
+                        }
+                    } else {
+                        // not exist, put it
+                        pre[name] = value;
+                    }
+
+                    return pre;
+                }, {});
+            }
+
+            //对img添加额外数据
+            if (node.tag === 'img') {
+                node.imgIndex = results.images.length;
+                var imgUrl = node.attr.src;
+                imgUrl = wxDiscode.urlToHttpUrl(imgUrl, __placeImgeUrlHttps);
+                node.attr.src = imgUrl;
+                node.from = bindName;
+                results.images.push(node);
+                results.imageUrls.push(imgUrl);
+            }
+
+            if (unary) {
+                // if this tag dosen't have end tag
+                // like <img src="hoge.png"/>
+                // add to parents
+                var parent = bufArray[0] || results;
+                if (parent.nodes === undefined) {
+                    parent.nodes = [];
+                }
+                parent.nodes.push(node);
+            } else {
+                bufArray.unshift(node);
+            }
+        },
+        end: function (tag) {
+            //debug(tag);
+            // merge into parent tag
+            var node = bufArray.shift();
+            if (node.tag !== tag) console.error('invalid state: mismatch end tag');
+
+            if (bufArray.length === 0) {
+                results.nodes.push(node);
+            } else {
+                var parent = bufArray[0];
+                if (parent.nodes === undefined) {
+                    parent.nodes = [];
+                }
+                parent.nodes.push(node);
+            }
+        },
+        chars: function (text) {
+            //debug(text);
+            var node = {
+                node: 'text',
+                text: text,
+                textArray:transEmojiStr(text)
+            };
+            
+            if (bufArray.length === 0) {
+                results.nodes.push(node);
+            } else {
+                var parent = bufArray[0];
+                if (parent.nodes === undefined) {
+                    parent.nodes = [];
+                }
+                parent.nodes.push(node);
+            }
+        },
+        comment: function (text) {
+            //debug(text);
+            var node = {
+                node: 'comment',
+                text: text,
+            };
+            var parent = bufArray[0];
+            if (parent.nodes === undefined) {
+                parent.nodes = [];
+            }
+            parent.nodes.push(node);
+        },
+    });
+    return results;
+};
+
+function transEmojiStr(str){
+  // var eReg = new RegExp("["+__reg+' '+"]");
+//   str = str.replace(/\[([^\[\]]+)\]/g,':$1:')
+  
+  var emojiObjs = [];
+  //如果正则表达式为空
+  if(__emojisReg.length == 0 || !__emojis){
+      var emojiObj = {}
+      emojiObj.node = "text";
+      emojiObj.text = str;
+      array = [emojiObj];
+      return array;
+  }
+  //这个地方需要调整
+  str = str.replace(/\[([^\[\]]+)\]/g,':$1:')
+  var eReg = new RegExp("[:]");
+  var array = str.split(eReg);
+  for(var i = 0; i < array.length; i++){
+    var ele = array[i];
+    var emojiObj = {};
+    if(__emojis[ele]){
+      emojiObj.node = "element";
+      emojiObj.tag = "emoji";
+      emojiObj.text = __emojis[ele];
+      emojiObj.baseSrc= __emojisBaseSrc;
+    }else{
+      emojiObj.node = "text";
+      emojiObj.text = ele;
+    }
+    emojiObjs.push(emojiObj);
+  }
+  
+  return emojiObjs;
+}
+
+function emojisInit(reg='',baseSrc="/wxParse/emojis/",emojis){
+    __emojisReg = reg;
+    __emojisBaseSrc=baseSrc;
+    __emojis=emojis;
+}
+
+module.exports = {
+    html2json: html2json,
+    emojisInit:emojisInit
+};
+

+ 182 - 0
mini-app/lib/wxParse/htmlparser.js

@@ -0,0 +1,182 @@
+/**
+ * author: Di (微信小程序开发工程师)
+ * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
+ *               垂直微信小程序开发交流社区
+ * 
+ * github地址: https://github.com/icindy/wxParse
+ * 
+ * for: 微信小程序富文本解析
+ * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
+ */
+// Regular Expressions for parsing tags and attributes
+var startTag = /^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/,
+	endTag = /^<\/([-A-Za-z0-9_]+)[^>]*>/,
+	attr = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;
+
+// Empty Elements - HTML 5
+var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr");
+
+// Block Elements - HTML 5
+var block = makeMap("a,address,code,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video");
+
+// Inline Elements - HTML 5
+var inline = makeMap("abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var");
+
+// Elements that you can, intentionally, leave open
+// (and which close themselves)
+var closeSelf = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr");
+
+// Attributes that have their values filled in disabled="disabled"
+var fillAttrs = makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected");
+
+// Special Elements (can contain anything)
+var special = makeMap("wxxxcode-style,script,style,view,scroll-view,block");
+
+function HTMLParser(html, handler) {
+	var index, chars, match, stack = [], last = html;
+	stack.last = function () {
+		return this[this.length - 1];
+	};
+
+	while (html) {
+		chars = true;
+
+		// Make sure we're not in a script or style element
+		if (!stack.last() || !special[stack.last()]) {
+
+			// Comment
+			if (html.indexOf("<!--") == 0) {
+				index = html.indexOf("-->");
+
+				if (index >= 0) {
+					if (handler.comment)
+						handler.comment(html.substring(4, index));
+					html = html.substring(index + 3);
+					chars = false;
+				}
+
+				// end tag
+			} else if (html.indexOf("</") == 0) {
+				match = html.match(endTag);
+
+				if (match) {
+					html = html.substring(match[0].length);
+					match[0].replace(endTag, parseEndTag);
+					chars = false;
+				}
+
+				// start tag
+			} else if (html.indexOf("<") == 0) {
+				match = html.match(startTag);
+
+				if (match) {
+					html = html.substring(match[0].length);
+					match[0].replace(startTag, parseStartTag);
+					chars = false;
+				}
+			}
+
+			if (chars) {
+				index = html.indexOf("<");
+
+				var text = index < 0 ? html : html.substring(0, index);
+				html = index < 0 ? "" : html.substring(index);
+
+				if (handler.chars)
+					handler.chars(text);
+			}
+
+		} else {
+
+			html = html.replace(new RegExp("([\\s\\S]*?)<\/" + stack.last() + "[^>]*>"), function (all, text) {
+				text = text.replace(/<!--([\s\S]*?)-->|<!\[CDATA\[([\s\S]*?)]]>/g, "$1$2");
+				if (handler.chars)
+					handler.chars(text);
+
+				return "";
+			});
+
+
+			parseEndTag("", stack.last());
+		}
+
+		if (html == last)
+			throw "Parse Error: " + html;
+		last = html;
+	}
+
+	// Clean up any remaining tags
+	parseEndTag();
+
+	function parseStartTag(tag, tagName, rest, unary) {
+		tagName = tagName.toLowerCase();
+
+		if (block[tagName]) {
+			while (stack.last() && inline[stack.last()]) {
+				parseEndTag("", stack.last());
+			}
+		}
+
+		if (closeSelf[tagName] && stack.last() == tagName) {
+			parseEndTag("", tagName);
+		}
+
+		unary = empty[tagName] || !!unary;
+
+		if (!unary)
+			stack.push(tagName);
+
+		if (handler.start) {
+			var attrs = [];
+
+			rest.replace(attr, function (match, name) {
+				var value = arguments[2] ? arguments[2] :
+					arguments[3] ? arguments[3] :
+						arguments[4] ? arguments[4] :
+							fillAttrs[name] ? name : "";
+
+				attrs.push({
+					name: name,
+					value: value,
+					escaped: value.replace(/(^|[^\\])"/g, '$1\\\"') //"
+				});
+			});
+
+			if (handler.start) {
+				handler.start(tagName, attrs, unary);
+			}
+
+		}
+	}
+
+	function parseEndTag(tag, tagName) {
+		// If no tag name is provided, clean shop
+		if (!tagName)
+			var pos = 0;
+
+		// Find the closest opened tag of the same type
+		else
+			for (var pos = stack.length - 1; pos >= 0; pos--)
+				if (stack[pos] == tagName)
+					break;
+
+		if (pos >= 0) {
+			// Close all the open elements, up the stack
+			for (var i = stack.length - 1; i >= pos; i--)
+				if (handler.end)
+					handler.end(stack[i]);
+
+			// Remove the open elements from the stack
+			stack.length = pos;
+		}
+	}
+};
+
+function makeMap(str) {
+	var obj = {}, items = str.split(",");
+	for (var i = 0; i < items.length; i++)
+		obj[items[i]] = true;
+	return obj;
+}
+
+module.exports = HTMLParser;

+ 2529 - 0
mini-app/lib/wxParse/showdown.js

@@ -0,0 +1,2529 @@
+/**
+ * author: Di (微信小程序开发工程师)
+ * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
+ *               垂直微信小程序开发交流社区
+ * 
+ * github地址: https://github.com/icindy/wxParse
+ * 
+ * for: 微信小程序富文本解析
+ * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
+ */
+
+function getDefaultOpts(simple) {
+  'use strict';
+
+  var defaultOptions = {
+    omitExtraWLInCodeBlocks: {
+      defaultValue: false,
+      describe: 'Omit the default extra whiteline added to code blocks',
+      type: 'boolean'
+    },
+    noHeaderId: {
+      defaultValue: false,
+      describe: 'Turn on/off generated header id',
+      type: 'boolean'
+    },
+    prefixHeaderId: {
+      defaultValue: false,
+      describe: 'Specify a prefix to generated header ids',
+      type: 'string'
+    },
+    headerLevelStart: {
+      defaultValue: false,
+      describe: 'The header blocks level start',
+      type: 'integer'
+    },
+    parseImgDimensions: {
+      defaultValue: false,
+      describe: 'Turn on/off image dimension parsing',
+      type: 'boolean'
+    },
+    simplifiedAutoLink: {
+      defaultValue: false,
+      describe: 'Turn on/off GFM autolink style',
+      type: 'boolean'
+    },
+    literalMidWordUnderscores: {
+      defaultValue: false,
+      describe: 'Parse midword underscores as literal underscores',
+      type: 'boolean'
+    },
+    strikethrough: {
+      defaultValue: false,
+      describe: 'Turn on/off strikethrough support',
+      type: 'boolean'
+    },
+    tables: {
+      defaultValue: false,
+      describe: 'Turn on/off tables support',
+      type: 'boolean'
+    },
+    tablesHeaderId: {
+      defaultValue: false,
+      describe: 'Add an id to table headers',
+      type: 'boolean'
+    },
+    ghCodeBlocks: {
+      defaultValue: true,
+      describe: 'Turn on/off GFM fenced code blocks support',
+      type: 'boolean'
+    },
+    tasklists: {
+      defaultValue: false,
+      describe: 'Turn on/off GFM tasklist support',
+      type: 'boolean'
+    },
+    smoothLivePreview: {
+      defaultValue: false,
+      describe: 'Prevents weird effects in live previews due to incomplete input',
+      type: 'boolean'
+    },
+    smartIndentationFix: {
+      defaultValue: false,
+      description: 'Tries to smartly fix identation in es6 strings',
+      type: 'boolean'
+    }
+  };
+  if (simple === false) {
+    return JSON.parse(JSON.stringify(defaultOptions));
+  }
+  var ret = {};
+  for (var opt in defaultOptions) {
+    if (defaultOptions.hasOwnProperty(opt)) {
+      ret[opt] = defaultOptions[opt].defaultValue;
+    }
+  }
+  return ret;
+}
+
+/**
+ * Created by Tivie on 06-01-2015.
+ */
+
+// Private properties
+var showdown = {},
+    parsers = {},
+    extensions = {},
+    globalOptions = getDefaultOpts(true),
+    flavor = {
+      github: {
+        omitExtraWLInCodeBlocks:   true,
+        prefixHeaderId:            'user-content-',
+        simplifiedAutoLink:        true,
+        literalMidWordUnderscores: true,
+        strikethrough:             true,
+        tables:                    true,
+        tablesHeaderId:            true,
+        ghCodeBlocks:              true,
+        tasklists:                 true
+      },
+      vanilla: getDefaultOpts(true)
+    };
+
+/**
+ * helper namespace
+ * @type {{}}
+ */
+showdown.helper = {};
+
+/**
+ * TODO LEGACY SUPPORT CODE
+ * @type {{}}
+ */
+showdown.extensions = {};
+
+/**
+ * Set a global option
+ * @static
+ * @param {string} key
+ * @param {*} value
+ * @returns {showdown}
+ */
+showdown.setOption = function (key, value) {
+  'use strict';
+  globalOptions[key] = value;
+  return this;
+};
+
+/**
+ * Get a global option
+ * @static
+ * @param {string} key
+ * @returns {*}
+ */
+showdown.getOption = function (key) {
+  'use strict';
+  return globalOptions[key];
+};
+
+/**
+ * Get the global options
+ * @static
+ * @returns {{}}
+ */
+showdown.getOptions = function () {
+  'use strict';
+  return globalOptions;
+};
+
+/**
+ * Reset global options to the default values
+ * @static
+ */
+showdown.resetOptions = function () {
+  'use strict';
+  globalOptions = getDefaultOpts(true);
+};
+
+/**
+ * Set the flavor showdown should use as default
+ * @param {string} name
+ */
+showdown.setFlavor = function (name) {
+  'use strict';
+  if (flavor.hasOwnProperty(name)) {
+    var preset = flavor[name];
+    for (var option in preset) {
+      if (preset.hasOwnProperty(option)) {
+        globalOptions[option] = preset[option];
+      }
+    }
+  }
+};
+
+/**
+ * Get the default options
+ * @static
+ * @param {boolean} [simple=true]
+ * @returns {{}}
+ */
+showdown.getDefaultOptions = function (simple) {
+  'use strict';
+  return getDefaultOpts(simple);
+};
+
+/**
+ * Get or set a subParser
+ *
+ * subParser(name)       - Get a registered subParser
+ * subParser(name, func) - Register a subParser
+ * @static
+ * @param {string} name
+ * @param {function} [func]
+ * @returns {*}
+ */
+showdown.subParser = function (name, func) {
+  'use strict';
+  if (showdown.helper.isString(name)) {
+    if (typeof func !== 'undefined') {
+      parsers[name] = func;
+    } else {
+      if (parsers.hasOwnProperty(name)) {
+        return parsers[name];
+      } else {
+        throw Error('SubParser named ' + name + ' not registered!');
+      }
+    }
+  }
+};
+
+/**
+ * Gets or registers an extension
+ * @static
+ * @param {string} name
+ * @param {object|function=} ext
+ * @returns {*}
+ */
+showdown.extension = function (name, ext) {
+  'use strict';
+
+  if (!showdown.helper.isString(name)) {
+    throw Error('Extension \'name\' must be a string');
+  }
+
+  name = showdown.helper.stdExtName(name);
+
+  // Getter
+  if (showdown.helper.isUndefined(ext)) {
+    if (!extensions.hasOwnProperty(name)) {
+      throw Error('Extension named ' + name + ' is not registered!');
+    }
+    return extensions[name];
+
+    // Setter
+  } else {
+    // Expand extension if it's wrapped in a function
+    if (typeof ext === 'function') {
+      ext = ext();
+    }
+
+    // Ensure extension is an array
+    if (!showdown.helper.isArray(ext)) {
+      ext = [ext];
+    }
+
+    var validExtension = validate(ext, name);
+
+    if (validExtension.valid) {
+      extensions[name] = ext;
+    } else {
+      throw Error(validExtension.error);
+    }
+  }
+};
+
+/**
+ * Gets all extensions registered
+ * @returns {{}}
+ */
+showdown.getAllExtensions = function () {
+  'use strict';
+  return extensions;
+};
+
+/**
+ * Remove an extension
+ * @param {string} name
+ */
+showdown.removeExtension = function (name) {
+  'use strict';
+  delete extensions[name];
+};
+
+/**
+ * Removes all extensions
+ */
+showdown.resetExtensions = function () {
+  'use strict';
+  extensions = {};
+};
+
+/**
+ * Validate extension
+ * @param {array} extension
+ * @param {string} name
+ * @returns {{valid: boolean, error: string}}
+ */
+function validate(extension, name) {
+  'use strict';
+
+  var errMsg = (name) ? 'Error in ' + name + ' extension->' : 'Error in unnamed extension',
+    ret = {
+      valid: true,
+      error: ''
+    };
+
+  if (!showdown.helper.isArray(extension)) {
+    extension = [extension];
+  }
+
+  for (var i = 0; i < extension.length; ++i) {
+    var baseMsg = errMsg + ' sub-extension ' + i + ': ',
+        ext = extension[i];
+    if (typeof ext !== 'object') {
+      ret.valid = false;
+      ret.error = baseMsg + 'must be an object, but ' + typeof ext + ' given';
+      return ret;
+    }
+
+    if (!showdown.helper.isString(ext.type)) {
+      ret.valid = false;
+      ret.error = baseMsg + 'property "type" must be a string, but ' + typeof ext.type + ' given';
+      return ret;
+    }
+
+    var type = ext.type = ext.type.toLowerCase();
+
+    // normalize extension type
+    if (type === 'language') {
+      type = ext.type = 'lang';
+    }
+
+    if (type === 'html') {
+      type = ext.type = 'output';
+    }
+
+    if (type !== 'lang' && type !== 'output' && type !== 'listener') {
+      ret.valid = false;
+      ret.error = baseMsg + 'type ' + type + ' is not recognized. Valid values: "lang/language", "output/html" or "listener"';
+      return ret;
+    }
+
+    if (type === 'listener') {
+      if (showdown.helper.isUndefined(ext.listeners)) {
+        ret.valid = false;
+        ret.error = baseMsg + '. Extensions of type "listener" must have a property called "listeners"';
+        return ret;
+      }
+    } else {
+      if (showdown.helper.isUndefined(ext.filter) && showdown.helper.isUndefined(ext.regex)) {
+        ret.valid = false;
+        ret.error = baseMsg + type + ' extensions must define either a "regex" property or a "filter" method';
+        return ret;
+      }
+    }
+
+    if (ext.listeners) {
+      if (typeof ext.listeners !== 'object') {
+        ret.valid = false;
+        ret.error = baseMsg + '"listeners" property must be an object but ' + typeof ext.listeners + ' given';
+        return ret;
+      }
+      for (var ln in ext.listeners) {
+        if (ext.listeners.hasOwnProperty(ln)) {
+          if (typeof ext.listeners[ln] !== 'function') {
+            ret.valid = false;
+            ret.error = baseMsg + '"listeners" property must be an hash of [event name]: [callback]. listeners.' + ln +
+              ' must be a function but ' + typeof ext.listeners[ln] + ' given';
+            return ret;
+          }
+        }
+      }
+    }
+
+    if (ext.filter) {
+      if (typeof ext.filter !== 'function') {
+        ret.valid = false;
+        ret.error = baseMsg + '"filter" must be a function, but ' + typeof ext.filter + ' given';
+        return ret;
+      }
+    } else if (ext.regex) {
+      if (showdown.helper.isString(ext.regex)) {
+        ext.regex = new RegExp(ext.regex, 'g');
+      }
+      if (!ext.regex instanceof RegExp) {
+        ret.valid = false;
+        ret.error = baseMsg + '"regex" property must either be a string or a RegExp object, but ' + typeof ext.regex + ' given';
+        return ret;
+      }
+      if (showdown.helper.isUndefined(ext.replace)) {
+        ret.valid = false;
+        ret.error = baseMsg + '"regex" extensions must implement a replace string or function';
+        return ret;
+      }
+    }
+  }
+  return ret;
+}
+
+/**
+ * Validate extension
+ * @param {object} ext
+ * @returns {boolean}
+ */
+showdown.validateExtension = function (ext) {
+  'use strict';
+
+  var validateExtension = validate(ext, null);
+  if (!validateExtension.valid) {
+    console.warn(validateExtension.error);
+    return false;
+  }
+  return true;
+};
+
+/**
+ * showdownjs helper functions
+ */
+
+if (!showdown.hasOwnProperty('helper')) {
+  showdown.helper = {};
+}
+
+/**
+ * Check if var is string
+ * @static
+ * @param {string} a
+ * @returns {boolean}
+ */
+showdown.helper.isString = function isString(a) {
+  'use strict';
+  return (typeof a === 'string' || a instanceof String);
+};
+
+/**
+ * Check if var is a function
+ * @static
+ * @param {string} a
+ * @returns {boolean}
+ */
+showdown.helper.isFunction = function isFunction(a) {
+  'use strict';
+  var getType = {};
+  return a && getType.toString.call(a) === '[object Function]';
+};
+
+/**
+ * ForEach helper function
+ * @static
+ * @param {*} obj
+ * @param {function} callback
+ */
+showdown.helper.forEach = function forEach(obj, callback) {
+  'use strict';
+  if (typeof obj.forEach === 'function') {
+    obj.forEach(callback);
+  } else {
+    for (var i = 0; i < obj.length; i++) {
+      callback(obj[i], i, obj);
+    }
+  }
+};
+
+/**
+ * isArray helper function
+ * @static
+ * @param {*} a
+ * @returns {boolean}
+ */
+showdown.helper.isArray = function isArray(a) {
+  'use strict';
+  return a.constructor === Array;
+};
+
+/**
+ * Check if value is undefined
+ * @static
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
+ */
+showdown.helper.isUndefined = function isUndefined(value) {
+  'use strict';
+  return typeof value === 'undefined';
+};
+
+/**
+ * Standardidize extension name
+ * @static
+ * @param {string} s extension name
+ * @returns {string}
+ */
+showdown.helper.stdExtName = function (s) {
+  'use strict';
+  return s.replace(/[_-]||\s/g, '').toLowerCase();
+};
+
+function escapeCharactersCallback(wholeMatch, m1) {
+  'use strict';
+  var charCodeToEscape = m1.charCodeAt(0);
+  return '~E' + charCodeToEscape + 'E';
+}
+
+/**
+ * Callback used to escape characters when passing through String.replace
+ * @static
+ * @param {string} wholeMatch
+ * @param {string} m1
+ * @returns {string}
+ */
+showdown.helper.escapeCharactersCallback = escapeCharactersCallback;
+
+/**
+ * Escape characters in a string
+ * @static
+ * @param {string} text
+ * @param {string} charsToEscape
+ * @param {boolean} afterBackslash
+ * @returns {XML|string|void|*}
+ */
+showdown.helper.escapeCharacters = function escapeCharacters(text, charsToEscape, afterBackslash) {
+  'use strict';
+  // First we have to escape the escape characters so that
+  // we can build a character class out of them
+  var regexString = '([' + charsToEscape.replace(/([\[\]\\])/g, '\\$1') + '])';
+
+  if (afterBackslash) {
+    regexString = '\\\\' + regexString;
+  }
+
+  var regex = new RegExp(regexString, 'g');
+  text = text.replace(regex, escapeCharactersCallback);
+
+  return text;
+};
+
+var rgxFindMatchPos = function (str, left, right, flags) {
+  'use strict';
+  var f = flags || '',
+    g = f.indexOf('g') > -1,
+    x = new RegExp(left + '|' + right, 'g' + f.replace(/g/g, '')),
+    l = new RegExp(left, f.replace(/g/g, '')),
+    pos = [],
+    t, s, m, start, end;
+
+  do {
+    t = 0;
+    while ((m = x.exec(str))) {
+      if (l.test(m[0])) {
+        if (!(t++)) {
+          s = x.lastIndex;
+          start = s - m[0].length;
+        }
+      } else if (t) {
+        if (!--t) {
+          end = m.index + m[0].length;
+          var obj = {
+            left: {start: start, end: s},
+            match: {start: s, end: m.index},
+            right: {start: m.index, end: end},
+            wholeMatch: {start: start, end: end}
+          };
+          pos.push(obj);
+          if (!g) {
+            return pos;
+          }
+        }
+      }
+    }
+  } while (t && (x.lastIndex = s));
+
+  return pos;
+};
+
+/**
+ * matchRecursiveRegExp
+ *
+ * (c) 2007 Steven Levithan <stevenlevithan.com>
+ * MIT License
+ *
+ * Accepts a string to search, a left and right format delimiter
+ * as regex patterns, and optional regex flags. Returns an array
+ * of matches, allowing nested instances of left/right delimiters.
+ * Use the "g" flag to return all matches, otherwise only the
+ * first is returned. Be careful to ensure that the left and
+ * right format delimiters produce mutually exclusive matches.
+ * Backreferences are not supported within the right delimiter
+ * due to how it is internally combined with the left delimiter.
+ * When matching strings whose format delimiters are unbalanced
+ * to the left or right, the output is intentionally as a
+ * conventional regex library with recursion support would
+ * produce, e.g. "<<x>" and "<x>>" both produce ["x"] when using
+ * "<" and ">" as the delimiters (both strings contain a single,
+ * balanced instance of "<x>").
+ *
+ * examples:
+ * matchRecursiveRegExp("test", "\\(", "\\)")
+ * returns: []
+ * matchRecursiveRegExp("<t<<e>><s>>t<>", "<", ">", "g")
+ * returns: ["t<<e>><s>", ""]
+ * matchRecursiveRegExp("<div id=\"x\">test</div>", "<div\\b[^>]*>", "</div>", "gi")
+ * returns: ["test"]
+ */
+showdown.helper.matchRecursiveRegExp = function (str, left, right, flags) {
+  'use strict';
+
+  var matchPos = rgxFindMatchPos (str, left, right, flags),
+    results = [];
+
+  for (var i = 0; i < matchPos.length; ++i) {
+    results.push([
+      str.slice(matchPos[i].wholeMatch.start, matchPos[i].wholeMatch.end),
+      str.slice(matchPos[i].match.start, matchPos[i].match.end),
+      str.slice(matchPos[i].left.start, matchPos[i].left.end),
+      str.slice(matchPos[i].right.start, matchPos[i].right.end)
+    ]);
+  }
+  return results;
+};
+
+/**
+ *
+ * @param {string} str
+ * @param {string|function} replacement
+ * @param {string} left
+ * @param {string} right
+ * @param {string} flags
+ * @returns {string}
+ */
+showdown.helper.replaceRecursiveRegExp = function (str, replacement, left, right, flags) {
+  'use strict';
+
+  if (!showdown.helper.isFunction(replacement)) {
+    var repStr = replacement;
+    replacement = function () {
+      return repStr;
+    };
+  }
+
+  var matchPos = rgxFindMatchPos(str, left, right, flags),
+      finalStr = str,
+      lng = matchPos.length;
+
+  if (lng > 0) {
+    var bits = [];
+    if (matchPos[0].wholeMatch.start !== 0) {
+      bits.push(str.slice(0, matchPos[0].wholeMatch.start));
+    }
+    for (var i = 0; i < lng; ++i) {
+      bits.push(
+        replacement(
+          str.slice(matchPos[i].wholeMatch.start, matchPos[i].wholeMatch.end),
+          str.slice(matchPos[i].match.start, matchPos[i].match.end),
+          str.slice(matchPos[i].left.start, matchPos[i].left.end),
+          str.slice(matchPos[i].right.start, matchPos[i].right.end)
+        )
+      );
+      if (i < lng - 1) {
+        bits.push(str.slice(matchPos[i].wholeMatch.end, matchPos[i + 1].wholeMatch.start));
+      }
+    }
+    if (matchPos[lng - 1].wholeMatch.end < str.length) {
+      bits.push(str.slice(matchPos[lng - 1].wholeMatch.end));
+    }
+    finalStr = bits.join('');
+  }
+  return finalStr;
+};
+
+/**
+ * POLYFILLS
+ */
+if (showdown.helper.isUndefined(console)) {
+  console = {
+    warn: function (msg) {
+      'use strict';
+      alert(msg);
+    },
+    log: function (msg) {
+      'use strict';
+      alert(msg);
+    },
+    error: function (msg) {
+      'use strict';
+      throw msg;
+    }
+  };
+}
+
+/**
+ * Created by Estevao on 31-05-2015.
+ */
+
+/**
+ * Showdown Converter class
+ * @class
+ * @param {object} [converterOptions]
+ * @returns {Converter}
+ */
+showdown.Converter = function (converterOptions) {
+  'use strict';
+
+  var
+      /**
+       * Options used by this converter
+       * @private
+       * @type {{}}
+       */
+      options = {},
+
+      /**
+       * Language extensions used by this converter
+       * @private
+       * @type {Array}
+       */
+      langExtensions = [],
+
+      /**
+       * Output modifiers extensions used by this converter
+       * @private
+       * @type {Array}
+       */
+      outputModifiers = [],
+
+      /**
+       * Event listeners
+       * @private
+       * @type {{}}
+       */
+      listeners = {};
+
+  _constructor();
+
+  /**
+   * Converter constructor
+   * @private
+   */
+  function _constructor() {
+    converterOptions = converterOptions || {};
+
+    for (var gOpt in globalOptions) {
+      if (globalOptions.hasOwnProperty(gOpt)) {
+        options[gOpt] = globalOptions[gOpt];
+      }
+    }
+
+    // Merge options
+    if (typeof converterOptions === 'object') {
+      for (var opt in converterOptions) {
+        if (converterOptions.hasOwnProperty(opt)) {
+          options[opt] = converterOptions[opt];
+        }
+      }
+    } else {
+      throw Error('Converter expects the passed parameter to be an object, but ' + typeof converterOptions +
+      ' was passed instead.');
+    }
+
+    if (options.extensions) {
+      showdown.helper.forEach(options.extensions, _parseExtension);
+    }
+  }
+
+  /**
+   * Parse extension
+   * @param {*} ext
+   * @param {string} [name='']
+   * @private
+   */
+  function _parseExtension(ext, name) {
+
+    name = name || null;
+    // If it's a string, the extension was previously loaded
+    if (showdown.helper.isString(ext)) {
+      ext = showdown.helper.stdExtName(ext);
+      name = ext;
+
+      // LEGACY_SUPPORT CODE
+      if (showdown.extensions[ext]) {
+        console.warn('DEPRECATION WARNING: ' + ext + ' is an old extension that uses a deprecated loading method.' +
+          'Please inform the developer that the extension should be updated!');
+        legacyExtensionLoading(showdown.extensions[ext], ext);
+        return;
+      // END LEGACY SUPPORT CODE
+
+      } else if (!showdown.helper.isUndefined(extensions[ext])) {
+        ext = extensions[ext];
+
+      } else {
+        throw Error('Extension "' + ext + '" could not be loaded. It was either not found or is not a valid extension.');
+      }
+    }
+
+    if (typeof ext === 'function') {
+      ext = ext();
+    }
+
+    if (!showdown.helper.isArray(ext)) {
+      ext = [ext];
+    }
+
+    var validExt = validate(ext, name);
+    if (!validExt.valid) {
+      throw Error(validExt.error);
+    }
+
+    for (var i = 0; i < ext.length; ++i) {
+      switch (ext[i].type) {
+
+        case 'lang':
+          langExtensions.push(ext[i]);
+          break;
+
+        case 'output':
+          outputModifiers.push(ext[i]);
+          break;
+      }
+      if (ext[i].hasOwnProperty(listeners)) {
+        for (var ln in ext[i].listeners) {
+          if (ext[i].listeners.hasOwnProperty(ln)) {
+            listen(ln, ext[i].listeners[ln]);
+          }
+        }
+      }
+    }
+
+  }
+
+  /**
+   * LEGACY_SUPPORT
+   * @param {*} ext
+   * @param {string} name
+   */
+  function legacyExtensionLoading(ext, name) {
+    if (typeof ext === 'function') {
+      ext = ext(new showdown.Converter());
+    }
+    if (!showdown.helper.isArray(ext)) {
+      ext = [ext];
+    }
+    var valid = validate(ext, name);
+
+    if (!valid.valid) {
+      throw Error(valid.error);
+    }
+
+    for (var i = 0; i < ext.length; ++i) {
+      switch (ext[i].type) {
+        case 'lang':
+          langExtensions.push(ext[i]);
+          break;
+        case 'output':
+          outputModifiers.push(ext[i]);
+          break;
+        default:// should never reach here
+          throw Error('Extension loader error: Type unrecognized!!!');
+      }
+    }
+  }
+
+  /**
+   * Listen to an event
+   * @param {string} name
+   * @param {function} callback
+   */
+  function listen(name, callback) {
+    if (!showdown.helper.isString(name)) {
+      throw Error('Invalid argument in converter.listen() method: name must be a string, but ' + typeof name + ' given');
+    }
+
+    if (typeof callback !== 'function') {
+      throw Error('Invalid argument in converter.listen() method: callback must be a function, but ' + typeof callback + ' given');
+    }
+
+    if (!listeners.hasOwnProperty(name)) {
+      listeners[name] = [];
+    }
+    listeners[name].push(callback);
+  }
+
+  function rTrimInputText(text) {
+    var rsp = text.match(/^\s*/)[0].length,
+        rgx = new RegExp('^\\s{0,' + rsp + '}', 'gm');
+    return text.replace(rgx, '');
+  }
+
+  /**
+   * Dispatch an event
+   * @private
+   * @param {string} evtName Event name
+   * @param {string} text Text
+   * @param {{}} options Converter Options
+   * @param {{}} globals
+   * @returns {string}
+   */
+  this._dispatch = function dispatch (evtName, text, options, globals) {
+    if (listeners.hasOwnProperty(evtName)) {
+      for (var ei = 0; ei < listeners[evtName].length; ++ei) {
+        var nText = listeners[evtName][ei](evtName, text, this, options, globals);
+        if (nText && typeof nText !== 'undefined') {
+          text = nText;
+        }
+      }
+    }
+    return text;
+  };
+
+  /**
+   * Listen to an event
+   * @param {string} name
+   * @param {function} callback
+   * @returns {showdown.Converter}
+   */
+  this.listen = function (name, callback) {
+    listen(name, callback);
+    return this;
+  };
+
+  /**
+   * Converts a markdown string into HTML
+   * @param {string} text
+   * @returns {*}
+   */
+  this.makeHtml = function (text) {
+    //check if text is not falsy
+    if (!text) {
+      return text;
+    }
+
+    var globals = {
+      gHtmlBlocks:     [],
+      gHtmlMdBlocks:   [],
+      gHtmlSpans:      [],
+      gUrls:           {},
+      gTitles:         {},
+      gDimensions:     {},
+      gListLevel:      0,
+      hashLinkCounts:  {},
+      langExtensions:  langExtensions,
+      outputModifiers: outputModifiers,
+      converter:       this,
+      ghCodeBlocks:    []
+    };
+
+    // attacklab: Replace ~ with ~T
+    // This lets us use tilde as an escape char to avoid md5 hashes
+    // The choice of character is arbitrary; anything that isn't
+    // magic in Markdown will work.
+    text = text.replace(/~/g, '~T');
+
+    // attacklab: Replace $ with ~D
+    // RegExp interprets $ as a special character
+    // when it's in a replacement string
+    text = text.replace(/\$/g, '~D');
+
+    // Standardize line endings
+    text = text.replace(/\r\n/g, '\n'); // DOS to Unix
+    text = text.replace(/\r/g, '\n'); // Mac to Unix
+
+    if (options.smartIndentationFix) {
+      text = rTrimInputText(text);
+    }
+
+    // Make sure text begins and ends with a couple of newlines:
+    //text = '\n\n' + text + '\n\n';
+    text = text;
+    // detab
+    text = showdown.subParser('detab')(text, options, globals);
+
+    // stripBlankLines
+    text = showdown.subParser('stripBlankLines')(text, options, globals);
+
+    //run languageExtensions
+    showdown.helper.forEach(langExtensions, function (ext) {
+      text = showdown.subParser('runExtension')(ext, text, options, globals);
+    });
+
+    // run the sub parsers
+    text = showdown.subParser('hashPreCodeTags')(text, options, globals);
+    text = showdown.subParser('githubCodeBlocks')(text, options, globals);
+    text = showdown.subParser('hashHTMLBlocks')(text, options, globals);
+    text = showdown.subParser('hashHTMLSpans')(text, options, globals);
+    text = showdown.subParser('stripLinkDefinitions')(text, options, globals);
+    text = showdown.subParser('blockGamut')(text, options, globals);
+    text = showdown.subParser('unhashHTMLSpans')(text, options, globals);
+    text = showdown.subParser('unescapeSpecialChars')(text, options, globals);
+
+    // attacklab: Restore dollar signs
+    text = text.replace(/~D/g, '$$');
+
+    // attacklab: Restore tildes
+    text = text.replace(/~T/g, '~');
+
+    // Run output modifiers
+    showdown.helper.forEach(outputModifiers, function (ext) {
+      text = showdown.subParser('runExtension')(ext, text, options, globals);
+    });
+    return text;
+  };
+
+  /**
+   * Set an option of this Converter instance
+   * @param {string} key
+   * @param {*} value
+   */
+  this.setOption = function (key, value) {
+    options[key] = value;
+  };
+
+  /**
+   * Get the option of this Converter instance
+   * @param {string} key
+   * @returns {*}
+   */
+  this.getOption = function (key) {
+    return options[key];
+  };
+
+  /**
+   * Get the options of this Converter instance
+   * @returns {{}}
+   */
+  this.getOptions = function () {
+    return options;
+  };
+
+  /**
+   * Add extension to THIS converter
+   * @param {{}} extension
+   * @param {string} [name=null]
+   */
+  this.addExtension = function (extension, name) {
+    name = name || null;
+    _parseExtension(extension, name);
+  };
+
+  /**
+   * Use a global registered extension with THIS converter
+   * @param {string} extensionName Name of the previously registered extension
+   */
+  this.useExtension = function (extensionName) {
+    _parseExtension(extensionName);
+  };
+
+  /**
+   * Set the flavor THIS converter should use
+   * @param {string} name
+   */
+  this.setFlavor = function (name) {
+    if (flavor.hasOwnProperty(name)) {
+      var preset = flavor[name];
+      for (var option in preset) {
+        if (preset.hasOwnProperty(option)) {
+          options[option] = preset[option];
+        }
+      }
+    }
+  };
+
+  /**
+   * Remove an extension from THIS converter.
+   * Note: This is a costly operation. It's better to initialize a new converter
+   * and specify the extensions you wish to use
+   * @param {Array} extension
+   */
+  this.removeExtension = function (extension) {
+    if (!showdown.helper.isArray(extension)) {
+      extension = [extension];
+    }
+    for (var a = 0; a < extension.length; ++a) {
+      var ext = extension[a];
+      for (var i = 0; i < langExtensions.length; ++i) {
+        if (langExtensions[i] === ext) {
+          langExtensions[i].splice(i, 1);
+        }
+      }
+      for (var ii = 0; ii < outputModifiers.length; ++i) {
+        if (outputModifiers[ii] === ext) {
+          outputModifiers[ii].splice(i, 1);
+        }
+      }
+    }
+  };
+
+  /**
+   * Get all extension of THIS converter
+   * @returns {{language: Array, output: Array}}
+   */
+  this.getAllExtensions = function () {
+    return {
+      language: langExtensions,
+      output: outputModifiers
+    };
+  };
+};
+
+/**
+ * Turn Markdown link shortcuts into XHTML <a> tags.
+ */
+showdown.subParser('anchors', function (text, options, globals) {
+  'use strict';
+
+  text = globals.converter._dispatch('anchors.before', text, options, globals);
+
+  var writeAnchorTag = function (wholeMatch, m1, m2, m3, m4, m5, m6, m7) {
+    if (showdown.helper.isUndefined(m7)) {
+      m7 = '';
+    }
+    wholeMatch = m1;
+    var linkText = m2,
+        linkId = m3.toLowerCase(),
+        url = m4,
+        title = m7;
+
+    if (!url) {
+      if (!linkId) {
+        // lower-case and turn embedded newlines into spaces
+        linkId = linkText.toLowerCase().replace(/ ?\n/g, ' ');
+      }
+      url = '#' + linkId;
+
+      if (!showdown.helper.isUndefined(globals.gUrls[linkId])) {
+        url = globals.gUrls[linkId];
+        if (!showdown.helper.isUndefined(globals.gTitles[linkId])) {
+          title = globals.gTitles[linkId];
+        }
+      } else {
+        if (wholeMatch.search(/\(\s*\)$/m) > -1) {
+          // Special case for explicit empty url
+          url = '';
+        } else {
+          return wholeMatch;
+        }
+      }
+    }
+
+    url = showdown.helper.escapeCharacters(url, '*_', false);
+    var result = '<a href="' + url + '"';
+
+    if (title !== '' && title !== null) {
+      title = title.replace(/"/g, '&quot;');
+      title = showdown.helper.escapeCharacters(title, '*_', false);
+      result += ' title="' + title + '"';
+    }
+
+    result += '>' + linkText + '</a>';
+
+    return result;
+  };
+
+  // First, handle reference-style links: [link text] [id]
+  /*
+   text = text.replace(/
+   (							// wrap whole match in $1
+   \[
+   (
+   (?:
+   \[[^\]]*\]		// allow brackets nested one level
+   |
+   [^\[]			// or anything else
+   )*
+   )
+   \]
+
+   [ ]?					// one optional space
+   (?:\n[ ]*)?				// one optional newline followed by spaces
+
+   \[
+   (.*?)					// id = $3
+   \]
+   )()()()()					// pad remaining backreferences
+   /g,_DoAnchors_callback);
+   */
+  text = text.replace(/(\[((?:\[[^\]]*]|[^\[\]])*)][ ]?(?:\n[ ]*)?\[(.*?)])()()()()/g, writeAnchorTag);
+
+  //
+  // Next, inline-style links: [link text](url "optional title")
+  //
+
+  /*
+   text = text.replace(/
+   (						// wrap whole match in $1
+   \[
+   (
+   (?:
+   \[[^\]]*\]	// allow brackets nested one level
+   |
+   [^\[\]]			// or anything else
+   )
+   )
+   \]
+   \(						// literal paren
+   [ \t]*
+   ()						// no id, so leave $3 empty
+   <?(.*?)>?				// href = $4
+   [ \t]*
+   (						// $5
+   (['"])				// quote char = $6
+   (.*?)				// Title = $7
+   \6					// matching quote
+   [ \t]*				// ignore any spaces/tabs between closing quote and )
+   )?						// title is optional
+   \)
+   )
+   /g,writeAnchorTag);
+   */
+  text = text.replace(/(\[((?:\[[^\]]*]|[^\[\]])*)]\([ \t]*()<?(.*?(?:\(.*?\).*?)?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,
+                      writeAnchorTag);
+
+  //
+  // Last, handle reference-style shortcuts: [link text]
+  // These must come last in case you've also got [link test][1]
+  // or [link test](/foo)
+  //
+
+  /*
+   text = text.replace(/
+   (                // wrap whole match in $1
+   \[
+   ([^\[\]]+)       // link text = $2; can't contain '[' or ']'
+   \]
+   )()()()()()      // pad rest of backreferences
+   /g, writeAnchorTag);
+   */
+  text = text.replace(/(\[([^\[\]]+)])()()()()()/g, writeAnchorTag);
+
+  text = globals.converter._dispatch('anchors.after', text, options, globals);
+  return text;
+});
+
+showdown.subParser('autoLinks', function (text, options, globals) {
+  'use strict';
+
+  text = globals.converter._dispatch('autoLinks.before', text, options, globals);
+
+  var simpleURLRegex  = /\b(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+)(?=\s|$)(?!["<>])/gi,
+      delimUrlRegex   = /<(((https?|ftp|dict):\/\/|www\.)[^'">\s]+)>/gi,
+      simpleMailRegex = /(?:^|[ \n\t])([A-Za-z0-9!#$%&'*+-/=?^_`\{|}~\.]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)(?:$|[ \n\t])/gi,
+      delimMailRegex  = /<(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi;
+
+  text = text.replace(delimUrlRegex, replaceLink);
+  text = text.replace(delimMailRegex, replaceMail);
+  // simpleURLRegex  = /\b(((https?|ftp|dict):\/\/|www\.)[-.+~:?#@!$&'()*,;=[\]\w]+)\b/gi,
+  // Email addresses: <address@domain.foo>
+
+  if (options.simplifiedAutoLink) {
+    text = text.replace(simpleURLRegex, replaceLink);
+    text = text.replace(simpleMailRegex, replaceMail);
+  }
+
+  function replaceLink(wm, link) {
+    var lnkTxt = link;
+    if (/^www\./i.test(link)) {
+      link = link.replace(/^www\./i, 'http://www.');
+    }
+    return '<a href="' + link + '">' + lnkTxt + '</a>';
+  }
+
+  function replaceMail(wholeMatch, m1) {
+    var unescapedStr = showdown.subParser('unescapeSpecialChars')(m1);
+    return showdown.subParser('encodeEmailAddress')(unescapedStr);
+  }
+
+  text = globals.converter._dispatch('autoLinks.after', text, options, globals);
+
+  return text;
+});
+
+/**
+ * These are all the transformations that form block-level
+ * tags like paragraphs, headers, and list items.
+ */
+showdown.subParser('blockGamut', function (text, options, globals) {
+  'use strict';
+
+  text = globals.converter._dispatch('blockGamut.before', text, options, globals);
+
+  // we parse blockquotes first so that we can have headings and hrs
+  // inside blockquotes
+  text = showdown.subParser('blockQuotes')(text, options, globals);
+  text = showdown.subParser('headers')(text, options, globals);
+
+  // Do Horizontal Rules:
+  var key = showdown.subParser('hashBlock')('<hr />', options, globals);
+  text = text.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm, key);
+  text = text.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm, key);
+  text = text.replace(/^[ ]{0,2}([ ]?_[ ]?){3,}[ \t]*$/gm, key);
+
+  text = showdown.subParser('lists')(text, options, globals);
+  text = showdown.subParser('codeBlocks')(text, options, globals);
+  text = showdown.subParser('tables')(text, options, globals);
+
+  // We already ran _HashHTMLBlocks() before, in Markdown(), but that
+  // was to escape raw HTML in the original Markdown source. This time,
+  // we're escaping the markup we've just created, so that we don't wrap
+  // <p> tags around block-level tags.
+  text = showdown.subParser('hashHTMLBlocks')(text, options, globals);
+  text = showdown.subParser('paragraphs')(text, options, globals);
+
+  text = globals.converter._dispatch('blockGamut.after', text, options, globals);
+
+  return text;
+});
+
+showdown.subParser('blockQuotes', function (text, options, globals) {
+  'use strict';
+
+  text = globals.converter._dispatch('blockQuotes.before', text, options, globals);
+  /*
+   text = text.replace(/
+   (								// Wrap whole match in $1
+   (
+   ^[ \t]*>[ \t]?			// '>' at the start of a line
+   .+\n					// rest of the first line
+   (.+\n)*					// subsequent consecutive lines
+   \n*						// blanks
+   )+
+   )
+   /gm, function(){...});
+   */
+
+  text = text.replace(/((^[ \t]{0,3}>[ \t]?.+\n(.+\n)*\n*)+)/gm, function (wholeMatch, m1) {
+    var bq = m1;
+
+    // attacklab: hack around Konqueror 3.5.4 bug:
+    // "----------bug".replace(/^-/g,"") == "bug"
+    bq = bq.replace(/^[ \t]*>[ \t]?/gm, '~0'); // trim one level of quoting
+
+    // attacklab: clean up hack
+    bq = bq.replace(/~0/g, '');
+
+    bq = bq.replace(/^[ \t]+$/gm, ''); // trim whitespace-only lines
+    bq = showdown.subParser('githubCodeBlocks')(bq, options, globals);
+    bq = showdown.subParser('blockGamut')(bq, options, globals); // recurse
+
+    bq = bq.replace(/(^|\n)/g, '$1  ');
+    // These leading spaces screw with <pre> content, so we need to fix that:
+    bq = bq.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm, function (wholeMatch, m1) {
+      var pre = m1;
+      // attacklab: hack around Konqueror 3.5.4 bug:
+      pre = pre.replace(/^  /mg, '~0');
+      pre = pre.replace(/~0/g, '');
+      return pre;
+    });
+
+    return showdown.subParser('hashBlock')('<blockquote>\n' + bq + '\n</blockquote>', options, globals);
+  });
+
+  text = globals.converter._dispatch('blockQuotes.after', text, options, globals);
+  return text;
+});
+
+/**
+ * Process Markdown `<pre><code>` blocks.
+ */
+showdown.subParser('codeBlocks', function (text, options, globals) {
+  'use strict';
+
+  text = globals.converter._dispatch('codeBlocks.before', text, options, globals);
+  /*
+   text = text.replace(text,
+   /(?:\n\n|^)
+   (								// $1 = the code block -- one or more lines, starting with a space/tab
+   (?:
+   (?:[ ]{4}|\t)			// Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width
+   .*\n+
+   )+
+   )
+   (\n*[ ]{0,3}[^ \t\n]|(?=~0))	// attacklab: g_tab_width
+   /g,function(){...});
+   */
+
+  // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
+  text += '~0';
+
+  var pattern = /(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g;
+  text = text.replace(pattern, function (wholeMatch, m1, m2) {
+    var codeblock = m1,
+        nextChar = m2,
+        end = '\n';
+
+    codeblock = showdown.subParser('outdent')(codeblock);
+    codeblock = showdown.subParser('encodeCode')(codeblock);
+    codeblock = showdown.subParser('detab')(codeblock);
+    codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
+    codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing newlines
+
+    if (options.omitExtraWLInCodeBlocks) {
+      end = '';
+    }
+
+    codeblock = '<pre><code>' + codeblock + end + '</code></pre>';
+
+    return showdown.subParser('hashBlock')(codeblock, options, globals) + nextChar;
+  });
+
+  // attacklab: strip sentinel
+  text = text.replace(/~0/, '');
+
+  text = globals.converter._dispatch('codeBlocks.after', text, options, globals);
+  return text;
+});
+
+/**
+ *
+ *   *  Backtick quotes are used for <code></code> spans.
+ *
+ *   *  You can use multiple backticks as the delimiters if you want to
+ *     include literal backticks in the code span. So, this input:
+ *
+ *         Just type ``foo `bar` baz`` at the prompt.
+ *
+ *       Will translate to:
+ *
+ *         <p>Just type <code>foo `bar` baz</code> at the prompt.</p>
+ *
+ *    There's no arbitrary limit to the number of backticks you
+ *    can use as delimters. If you need three consecutive backticks
+ *    in your code, use four for delimiters, etc.
+ *
+ *  *  You can use spaces to get literal backticks at the edges:
+ *
+ *         ... type `` `bar` `` ...
+ *
+ *       Turns to:
+ *
+ *         ... type <code>`bar`</code> ...
+ */
+showdown.subParser('codeSpans', function (text, options, globals) {
+  'use strict';
+
+  text = globals.converter._dispatch('codeSpans.before', text, options, globals);
+
+  /*
+   text = text.replace(/
+   (^|[^\\])					// Character before opening ` can't be a backslash
+   (`+)						// $2 = Opening run of `
+   (							// $3 = The code block
+   [^\r]*?
+   [^`]					// attacklab: work around lack of lookbehind
+   )
+   \2							// Matching closer
+   (?!`)
+   /gm, function(){...});
+   */
+
+  if (typeof(text) === 'undefined') {
+    text = '';
+  }
+  text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
+    function (wholeMatch, m1, m2, m3) {
+      var c = m3;
+      c = c.replace(/^([ \t]*)/g, '');	// leading whitespace
+      c = c.replace(/[ \t]*$/g, '');	// trailing whitespace
+      c = showdown.subParser('encodeCode')(c);
+      return m1 + '<code>' + c + '</code>';
+    }
+  );
+
+  text = globals.converter._dispatch('codeSpans.after', text, options, globals);
+  return text;
+});
+
+/**
+ * Convert all tabs to spaces
+ */
+showdown.subParser('detab', function (text) {
+  'use strict';
+
+  // expand first n-1 tabs
+  text = text.replace(/\t(?=\t)/g, '    '); // g_tab_width
+
+  // replace the nth with two sentinels
+  text = text.replace(/\t/g, '~A~B');
+
+  // use the sentinel to anchor our regex so it doesn't explode
+  text = text.replace(/~B(.+?)~A/g, function (wholeMatch, m1) {
+    var leadingText = m1,
+        numSpaces = 4 - leadingText.length % 4;  // g_tab_width
+
+    // there *must* be a better way to do this:
+    for (var i = 0; i < numSpaces; i++) {
+      leadingText += ' ';
+    }
+
+    return leadingText;
+  });
+
+  // clean up sentinels
+  text = text.replace(/~A/g, '    ');  // g_tab_width
+  text = text.replace(/~B/g, '');
+
+  return text;
+
+});
+
+/**
+ * Smart processing for ampersands and angle brackets that need to be encoded.
+ */
+showdown.subParser('encodeAmpsAndAngles', function (text) {
+  'use strict';
+  // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
+  // http://bumppo.net/projects/amputator/
+  text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, '&amp;');
+
+  // Encode naked <'s
+  text = text.replace(/<(?![a-z\/?\$!])/gi, '&lt;');
+
+  return text;
+});
+
+/**
+ * Returns the string, with after processing the following backslash escape sequences.
+ *
+ * attacklab: The polite way to do this is with the new escapeCharacters() function:
+ *
+ *    text = escapeCharacters(text,"\\",true);
+ *    text = escapeCharacters(text,"`*_{}[]()>#+-.!",true);
+ *
+ * ...but we're sidestepping its use of the (slow) RegExp constructor
+ * as an optimization for Firefox.  This function gets called a LOT.
+ */
+showdown.subParser('encodeBackslashEscapes', function (text) {
+  'use strict';
+  text = text.replace(/\\(\\)/g, showdown.helper.escapeCharactersCallback);
+  text = text.replace(/\\([`*_{}\[\]()>#+-.!])/g, showdown.helper.escapeCharactersCallback);
+  return text;
+});
+
+/**
+ * Encode/escape certain characters inside Markdown code runs.
+ * The point is that in code, these characters are literals,
+ * and lose their special Markdown meanings.
+ */
+showdown.subParser('encodeCode', function (text) {
+  'use strict';
+
+  // Encode all ampersands; HTML entities are not
+  // entities within a Markdown code span.
+  text = text.replace(/&/g, '&amp;');
+
+  // Do the angle bracket song and dance:
+  text = text.replace(/</g, '&lt;');
+  text = text.replace(/>/g, '&gt;');
+
+  // Now, escape characters that are magic in Markdown:
+  text = showdown.helper.escapeCharacters(text, '*_{}[]\\', false);
+
+  // jj the line above breaks this:
+  //---
+  //* Item
+  //   1. Subitem
+  //            special char: *
+  // ---
+
+  return text;
+});
+
+/**
+ *  Input: an email address, e.g. "foo@example.com"
+ *
+ *  Output: the email address as a mailto link, with each character
+ *    of the address encoded as either a decimal or hex entity, in
+ *    the hopes of foiling most address harvesting spam bots. E.g.:
+ *
+ *    <a href="&#x6D;&#97;&#105;&#108;&#x74;&#111;:&#102;&#111;&#111;&#64;&#101;
+ *       x&#x61;&#109;&#x70;&#108;&#x65;&#x2E;&#99;&#111;&#109;">&#102;&#111;&#111;
+ *       &#64;&#101;x&#x61;&#109;&#x70;&#108;&#x65;&#x2E;&#99;&#111;&#109;</a>
+ *
+ *  Based on a filter by Matthew Wickline, posted to the BBEdit-Talk
+ *  mailing list: <http://tinyurl.com/yu7ue>
+ *
+ */
+showdown.subParser('encodeEmailAddress', function (addr) {
+  'use strict';
+
+  var encode = [
+    function (ch) {
+      return '&#' + ch.charCodeAt(0) + ';';
+    },
+    function (ch) {
+      return '&#x' + ch.charCodeAt(0).toString(16) + ';';
+    },
+    function (ch) {
+      return ch;
+    }
+  ];
+
+  addr = 'mailto:' + addr;
+
+  addr = addr.replace(/./g, function (ch) {
+    if (ch === '@') {
+      // this *must* be encoded. I insist.
+      ch = encode[Math.floor(Math.random() * 2)](ch);
+    } else if (ch !== ':') {
+      // leave ':' alone (to spot mailto: later)
+      var r = Math.random();
+      // roughly 10% raw, 45% hex, 45% dec
+      ch = (
+        r > 0.9 ? encode[2](ch) : r > 0.45 ? encode[1](ch) : encode[0](ch)
+      );
+    }
+    return ch;
+  });
+
+  addr = '<a href="' + addr + '">' + addr + '</a>';
+  addr = addr.replace(/">.+:/g, '">'); // strip the mailto: from the visible part
+
+  return addr;
+});
+
+/**
+ * Within tags -- meaning between < and > -- encode [\ ` * _] so they
+ * don't conflict with their use in Markdown for code, italics and strong.
+ */
+showdown.subParser('escapeSpecialCharsWithinTagAttributes', function (text) {
+  'use strict';
+
+  // Build a regex to find HTML tags and comments.  See Friedl's
+  // "Mastering Regular Expressions", 2nd Ed., pp. 200-201.
+  var regex = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--.*?--\s*)+>)/gi;
+
+  text = text.replace(regex, function (wholeMatch) {
+    var tag = wholeMatch.replace(/(.)<\/?code>(?=.)/g, '$1`');
+    tag = showdown.helper.escapeCharacters(tag, '\\`*_', false);
+    return tag;
+  });
+
+  return text;
+});
+
+/**
+ * Handle github codeblocks prior to running HashHTML so that
+ * HTML contained within the codeblock gets escaped properly
+ * Example:
+ * ```ruby
+ *     def hello_world(x)
+ *       puts "Hello, #{x}"
+ *     end
+ * ```
+ */
+showdown.subParser('githubCodeBlocks', function (text, options, globals) {
+  'use strict';
+
+  // early exit if option is not enabled
+  if (!options.ghCodeBlocks) {
+    return text;
+  }
+
+  text = globals.converter._dispatch('githubCodeBlocks.before', text, options, globals);
+
+  text += '~0';
+
+  text = text.replace(/(?:^|\n)```(.*)\n([\s\S]*?)\n```/g, function (wholeMatch, language, codeblock) {
+    var end = (options.omitExtraWLInCodeBlocks) ? '' : '\n';
+
+    // First parse the github code block
+    codeblock = showdown.subParser('encodeCode')(codeblock);
+    codeblock = showdown.subParser('detab')(codeblock);
+    codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
+    codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing whitespace
+
+    codeblock = '<pre><code' + (language ? ' class="' + language + ' language-' + language + '"' : '') + '>' + codeblock + end + '</code></pre>';
+
+    codeblock = showdown.subParser('hashBlock')(codeblock, options, globals);
+
+    // Since GHCodeblocks can be false positives, we need to
+    // store the primitive text and the parsed text in a global var,
+    // and then return a token
+    return '\n\n~G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n';
+  });
+
+  // attacklab: strip sentinel
+  text = text.replace(/~0/, '');
+
+  return globals.converter._dispatch('githubCodeBlocks.after', text, options, globals);
+});
+
+showdown.subParser('hashBlock', function (text, options, globals) {
+  'use strict';
+  text = text.replace(/(^\n+|\n+$)/g, '');
+  return '\n\n~K' + (globals.gHtmlBlocks.push(text) - 1) + 'K\n\n';
+});
+
+showdown.subParser('hashElement', function (text, options, globals) {
+  'use strict';
+
+  return function (wholeMatch, m1) {
+    var blockText = m1;
+
+    // Undo double lines
+    blockText = blockText.replace(/\n\n/g, '\n');
+    blockText = blockText.replace(/^\n/, '');
+
+    // strip trailing blank lines
+    blockText = blockText.replace(/\n+$/g, '');
+
+    // Replace the element text with a marker ("~KxK" where x is its key)
+    blockText = '\n\n~K' + (globals.gHtmlBlocks.push(blockText) - 1) + 'K\n\n';
+
+    return blockText;
+  };
+});
+
+showdown.subParser('hashHTMLBlocks', function (text, options, globals) {
+  'use strict';
+
+  var blockTags = [
+      'pre',
+      'div',
+      'h1',
+      'h2',
+      'h3',
+      'h4',
+      'h5',
+      'h6',
+      'blockquote',
+      'table',
+      'dl',
+      'ol',
+      'ul',
+      'script',
+      'noscript',
+      'form',
+      'fieldset',
+      'iframe',
+      'math',
+      'style',
+      'section',
+      'header',
+      'footer',
+      'nav',
+      'article',
+      'aside',
+      'address',
+      'audio',
+      'canvas',
+      'figure',
+      'hgroup',
+      'output',
+      'video',
+      'p'
+    ],
+    repFunc = function (wholeMatch, match, left, right) {
+      var txt = wholeMatch;
+      // check if this html element is marked as markdown
+      // if so, it's contents should be parsed as markdown
+      if (left.search(/\bmarkdown\b/) !== -1) {
+        txt = left + globals.converter.makeHtml(match) + right;
+      }
+      return '\n\n~K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n';
+    };
+
+  for (var i = 0; i < blockTags.length; ++i) {
+    text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '^(?: |\\t){0,3}<' + blockTags[i] + '\\b[^>]*>', '</' + blockTags[i] + '>', 'gim');
+  }
+
+  // HR SPECIAL CASE
+  text = text.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,
+    showdown.subParser('hashElement')(text, options, globals));
+
+  // Special case for standalone HTML comments:
+  text = text.replace(/(<!--[\s\S]*?-->)/g,
+    showdown.subParser('hashElement')(text, options, globals));
+
+  // PHP and ASP-style processor instructions (<?...?> and <%...%>)
+  text = text.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,
+    showdown.subParser('hashElement')(text, options, globals));
+  return text;
+});
+
+/**
+ * Hash span elements that should not be parsed as markdown
+ */
+showdown.subParser('hashHTMLSpans', function (text, config, globals) {
+  'use strict';
+
+  var matches = showdown.helper.matchRecursiveRegExp(text, '<code\\b[^>]*>', '</code>', 'gi');
+
+  for (var i = 0; i < matches.length; ++i) {
+    text = text.replace(matches[i][0], '~L' + (globals.gHtmlSpans.push(matches[i][0]) - 1) + 'L');
+  }
+  return text;
+});
+
+/**
+ * Unhash HTML spans
+ */
+showdown.subParser('unhashHTMLSpans', function (text, config, globals) {
+  'use strict';
+
+  for (var i = 0; i < globals.gHtmlSpans.length; ++i) {
+    text = text.replace('~L' + i + 'L', globals.gHtmlSpans[i]);
+  }
+
+  return text;
+});
+
+/**
+ * Hash span elements that should not be parsed as markdown
+ */
+showdown.subParser('hashPreCodeTags', function (text, config, globals) {
+  'use strict';
+
+  var repFunc = function (wholeMatch, match, left, right) {
+    // encode html entities
+    var codeblock = left + showdown.subParser('encodeCode')(match) + right;
+    return '\n\n~G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n';
+  };
+
+  text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '^(?: |\\t){0,3}<pre\\b[^>]*>\\s*<code\\b[^>]*>', '^(?: |\\t){0,3}</code>\\s*</pre>', 'gim');
+  return text;
+});
+
+showdown.subParser('headers', function (text, options, globals) {
+  'use strict';
+
+  text = globals.converter._dispatch('headers.before', text, options, globals);
+
+  var prefixHeader = options.prefixHeaderId,
+      headerLevelStart = (isNaN(parseInt(options.headerLevelStart))) ? 1 : parseInt(options.headerLevelStart),
+
+  // Set text-style headers:
+  //	Header 1
+  //	========
+  //
+  //	Header 2
+  //	--------
+  //
+      setextRegexH1 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n={2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n=+[ \t]*\n+/gm,
+      setextRegexH2 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n-{2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n-+[ \t]*\n+/gm;
+
+  text = text.replace(setextRegexH1, function (wholeMatch, m1) {
+
+    var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
+        hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
+        hLevel = headerLevelStart,
+        hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>';
+    return showdown.subParser('hashBlock')(hashBlock, options, globals);
+  });
+
+  text = text.replace(setextRegexH2, function (matchFound, m1) {
+    var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
+        hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
+        hLevel = headerLevelStart + 1,
+      hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>';
+    return showdown.subParser('hashBlock')(hashBlock, options, globals);
+  });
+
+  // atx-style headers:
+  //  # Header 1
+  //  ## Header 2
+  //  ## Header 2 with closing hashes ##
+  //  ...
+  //  ###### Header 6
+  //
+  text = text.replace(/^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm, function (wholeMatch, m1, m2) {
+    var span = showdown.subParser('spanGamut')(m2, options, globals),
+        hID = (options.noHeaderId) ? '' : ' id="' + headerId(m2) + '"',
+        hLevel = headerLevelStart - 1 + m1.length,
+        header = '<h' + hLevel + hID + '>' + span + '</h' + hLevel + '>';
+
+    return showdown.subParser('hashBlock')(header, options, globals);
+  });
+
+  function headerId(m) {
+    var title, escapedId = m.replace(/[^\w]/g, '').toLowerCase();
+
+    if (globals.hashLinkCounts[escapedId]) {
+      title = escapedId + '-' + (globals.hashLinkCounts[escapedId]++);
+    } else {
+      title = escapedId;
+      globals.hashLinkCounts[escapedId] = 1;
+    }
+
+    // Prefix id to prevent causing inadvertent pre-existing style matches.
+    if (prefixHeader === true) {
+      prefixHeader = 'section';
+    }
+
+    if (showdown.helper.isString(prefixHeader)) {
+      return prefixHeader + title;
+    }
+    return title;
+  }
+
+  text = globals.converter._dispatch('headers.after', text, options, globals);
+  return text;
+});
+
+/**
+ * Turn Markdown image shortcuts into <img> tags.
+ */
+showdown.subParser('images', function (text, options, globals) {
+  'use strict';
+
+  text = globals.converter._dispatch('images.before', text, options, globals);
+
+  var inlineRegExp    = /!\[(.*?)]\s?\([ \t]*()<?(\S+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(['"])(.*?)\6[ \t]*)?\)/g,
+      referenceRegExp = /!\[([^\]]*?)] ?(?:\n *)?\[(.*?)]()()()()()/g;
+
+  function writeImageTag (wholeMatch, altText, linkId, url, width, height, m5, title) {
+
+    var gUrls   = globals.gUrls,
+        gTitles = globals.gTitles,
+        gDims   = globals.gDimensions;
+
+    linkId = linkId.toLowerCase();
+
+    if (!title) {
+      title = '';
+    }
+
+    if (url === '' || url === null) {
+      if (linkId === '' || linkId === null) {
+        // lower-case and turn embedded newlines into spaces
+        linkId = altText.toLowerCase().replace(/ ?\n/g, ' ');
+      }
+      url = '#' + linkId;
+
+      if (!showdown.helper.isUndefined(gUrls[linkId])) {
+        url = gUrls[linkId];
+        if (!showdown.helper.isUndefined(gTitles[linkId])) {
+          title = gTitles[linkId];
+        }
+        if (!showdown.helper.isUndefined(gDims[linkId])) {
+          width = gDims[linkId].width;
+          height = gDims[linkId].height;
+        }
+      } else {
+        return wholeMatch;
+      }
+    }
+
+    altText = altText.replace(/"/g, '&quot;');
+    altText = showdown.helper.escapeCharacters(altText, '*_', false);
+    url = showdown.helper.escapeCharacters(url, '*_', false);
+    var result = '<img src="' + url + '" alt="' + altText + '"';
+
+    if (title) {
+      title = title.replace(/"/g, '&quot;');
+      title = showdown.helper.escapeCharacters(title, '*_', false);
+      result += ' title="' + title + '"';
+    }
+
+    if (width && height) {
+      width  = (width === '*') ? 'auto' : width;
+      height = (height === '*') ? 'auto' : height;
+
+      result += ' width="' + width + '"';
+      result += ' height="' + height + '"';
+    }
+
+    result += ' />';
+    return result;
+  }
+
+  // First, handle reference-style labeled images: ![alt text][id]
+  text = text.replace(referenceRegExp, writeImageTag);
+
+  // Next, handle inline images:  ![alt text](url =<width>x<height> "optional title")
+  text = text.replace(inlineRegExp, writeImageTag);
+
+  text = globals.converter._dispatch('images.after', text, options, globals);
+  return text;
+});
+
+showdown.subParser('italicsAndBold', function (text, options, globals) {
+  'use strict';
+
+  text = globals.converter._dispatch('italicsAndBold.before', text, options, globals);
+
+  if (options.literalMidWordUnderscores) {
+    //underscores
+    // Since we are consuming a \s character, we need to add it
+    text = text.replace(/(^|\s|>|\b)__(?=\S)([\s\S]+?)__(?=\b|<|\s|$)/gm, '$1<strong>$2</strong>');
+    text = text.replace(/(^|\s|>|\b)_(?=\S)([\s\S]+?)_(?=\b|<|\s|$)/gm, '$1<em>$2</em>');
+    //asterisks
+    text = text.replace(/(\*\*)(?=\S)([^\r]*?\S[*]*)\1/g, '<strong>$2</strong>');
+    text = text.replace(/(\*)(?=\S)([^\r]*?\S)\1/g, '<em>$2</em>');
+
+  } else {
+    // <strong> must go first:
+    text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g, '<strong>$2</strong>');
+    text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g, '<em>$2</em>');
+  }
+
+  text = globals.converter._dispatch('italicsAndBold.after', text, options, globals);
+  return text;
+});
+
+/**
+ * Form HTML ordered (numbered) and unordered (bulleted) lists.
+ */
+showdown.subParser('lists', function (text, options, globals) {
+  'use strict';
+
+  text = globals.converter._dispatch('lists.before', text, options, globals);
+  /**
+   * Process the contents of a single ordered or unordered list, splitting it
+   * into individual list items.
+   * @param {string} listStr
+   * @param {boolean} trimTrailing
+   * @returns {string}
+   */
+  function processListItems (listStr, trimTrailing) {
+    // The $g_list_level global keeps track of when we're inside a list.
+    // Each time we enter a list, we increment it; when we leave a list,
+    // we decrement. If it's zero, we're not in a list anymore.
+    //
+    // We do this because when we're not inside a list, we want to treat
+    // something like this:
+    //
+    //    I recommend upgrading to version
+    //    8. Oops, now this line is treated
+    //    as a sub-list.
+    //
+    // As a single paragraph, despite the fact that the second line starts
+    // with a digit-period-space sequence.
+    //
+    // Whereas when we're inside a list (or sub-list), that line will be
+    // treated as the start of a sub-list. What a kludge, huh? This is
+    // an aspect of Markdown's syntax that's hard to parse perfectly
+    // without resorting to mind-reading. Perhaps the solution is to
+    // change the syntax rules such that sub-lists must start with a
+    // starting cardinal number; e.g. "1." or "a.".
+    globals.gListLevel++;
+
+    // trim trailing blank lines:
+    listStr = listStr.replace(/\n{2,}$/, '\n');
+
+    // attacklab: add sentinel to emulate \z
+    listStr += '~0';
+
+    var rgx = /(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,
+        isParagraphed = (/\n[ \t]*\n(?!~0)/.test(listStr));
+
+    listStr = listStr.replace(rgx, function (wholeMatch, m1, m2, m3, m4, taskbtn, checked) {
+      checked = (checked && checked.trim() !== '');
+      var item = showdown.subParser('outdent')(m4, options, globals),
+          bulletStyle = '';
+
+      // Support for github tasklists
+      if (taskbtn && options.tasklists) {
+        bulletStyle = ' class="task-list-item" style="list-style-type: none;"';
+        item = item.replace(/^[ \t]*\[(x|X| )?]/m, function () {
+          var otp = '<input type="checkbox" disabled style="margin: 0px 0.35em 0.25em -1.6em; vertical-align: middle;"';
+          if (checked) {
+            otp += ' checked';
+          }
+          otp += '>';
+          return otp;
+        });
+      }
+      // m1 - Leading line or
+      // Has a double return (multi paragraph) or
+      // Has sublist
+      if (m1 || (item.search(/\n{2,}/) > -1)) {
+        item = showdown.subParser('githubCodeBlocks')(item, options, globals);
+        item = showdown.subParser('blockGamut')(item, options, globals);
+      } else {
+        // Recursion for sub-lists:
+        item = showdown.subParser('lists')(item, options, globals);
+        item = item.replace(/\n$/, ''); // chomp(item)
+        if (isParagraphed) {
+          item = showdown.subParser('paragraphs')(item, options, globals);
+        } else {
+          item = showdown.subParser('spanGamut')(item, options, globals);
+        }
+      }
+      item =  '\n<li' + bulletStyle + '>' + item + '</li>\n';
+      return item;
+    });
+
+    // attacklab: strip sentinel
+    listStr = listStr.replace(/~0/g, '');
+
+    globals.gListLevel--;
+
+    if (trimTrailing) {
+      listStr = listStr.replace(/\s+$/, '');
+    }
+
+    return listStr;
+  }
+
+  /**
+   * Check and parse consecutive lists (better fix for issue #142)
+   * @param {string} list
+   * @param {string} listType
+   * @param {boolean} trimTrailing
+   * @returns {string}
+   */
+  function parseConsecutiveLists(list, listType, trimTrailing) {
+    // check if we caught 2 or more consecutive lists by mistake
+    // we use the counterRgx, meaning if listType is UL we look for UL and vice versa
+    var counterRxg = (listType === 'ul') ? /^ {0,2}\d+\.[ \t]/gm : /^ {0,2}[*+-][ \t]/gm,
+      subLists = [],
+      result = '';
+
+    if (list.search(counterRxg) !== -1) {
+      (function parseCL(txt) {
+        var pos = txt.search(counterRxg);
+        if (pos !== -1) {
+          // slice
+          result += '\n\n<' + listType + '>' + processListItems(txt.slice(0, pos), !!trimTrailing) + '</' + listType + '>\n\n';
+
+          // invert counterType and listType
+          listType = (listType === 'ul') ? 'ol' : 'ul';
+          counterRxg = (listType === 'ul') ? /^ {0,2}\d+\.[ \t]/gm : /^ {0,2}[*+-][ \t]/gm;
+
+          //recurse
+          parseCL(txt.slice(pos));
+        } else {
+          result += '\n\n<' + listType + '>' + processListItems(txt, !!trimTrailing) + '</' + listType + '>\n\n';
+        }
+      })(list);
+      for (var i = 0; i < subLists.length; ++i) {
+
+      }
+    } else {
+      result = '\n\n<' + listType + '>' + processListItems(list, !!trimTrailing) + '</' + listType + '>\n\n';
+    }
+
+    return result;
+  }
+
+  // attacklab: add sentinel to hack around khtml/safari bug:
+  // http://bugs.webkit.org/show_bug.cgi?id=11231
+  text += '~0';
+
+  // Re-usable pattern to match any entire ul or ol list:
+  var wholeList = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
+
+  if (globals.gListLevel) {
+    text = text.replace(wholeList, function (wholeMatch, list, m2) {
+      var listType = (m2.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
+      return parseConsecutiveLists(list, listType, true);
+    });
+  } else {
+    wholeList = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
+    //wholeList = /(\n\n|^\n?)( {0,3}([*+-]|\d+\.)[ \t]+[\s\S]+?)(?=(~0)|(\n\n(?!\t| {2,}| {0,3}([*+-]|\d+\.)[ \t])))/g;
+    text = text.replace(wholeList, function (wholeMatch, m1, list, m3) {
+
+      var listType = (m3.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
+      return parseConsecutiveLists(list, listType);
+    });
+  }
+
+  // attacklab: strip sentinel
+  text = text.replace(/~0/, '');
+
+  text = globals.converter._dispatch('lists.after', text, options, globals);
+  return text;
+});
+
+/**
+ * Remove one level of line-leading tabs or spaces
+ */
+showdown.subParser('outdent', function (text) {
+  'use strict';
+
+  // attacklab: hack around Konqueror 3.5.4 bug:
+  // "----------bug".replace(/^-/g,"") == "bug"
+  text = text.replace(/^(\t|[ ]{1,4})/gm, '~0'); // attacklab: g_tab_width
+
+  // attacklab: clean up hack
+  text = text.replace(/~0/g, '');
+
+  return text;
+});
+
+/**
+ *
+ */
+showdown.subParser('paragraphs', function (text, options, globals) {
+  'use strict';
+
+  text = globals.converter._dispatch('paragraphs.before', text, options, globals);
+  // Strip leading and trailing lines:
+  text = text.replace(/^\n+/g, '');
+  text = text.replace(/\n+$/g, '');
+
+  var grafs = text.split(/\n{2,}/g),
+      grafsOut = [],
+      end = grafs.length; // Wrap <p> tags
+
+  for (var i = 0; i < end; i++) {
+    var str = grafs[i];
+    // if this is an HTML marker, copy it
+    if (str.search(/~(K|G)(\d+)\1/g) >= 0) {
+      grafsOut.push(str);
+    } else {
+      str = showdown.subParser('spanGamut')(str, options, globals);
+      str = str.replace(/^([ \t]*)/g, '<p>');
+      str += '</p>';
+      grafsOut.push(str);
+    }
+  }
+
+  /** Unhashify HTML blocks */
+  end = grafsOut.length;
+  for (i = 0; i < end; i++) {
+    var blockText = '',
+        grafsOutIt = grafsOut[i],
+        codeFlag = false;
+    // if this is a marker for an html block...
+    while (grafsOutIt.search(/~(K|G)(\d+)\1/) >= 0) {
+      var delim = RegExp.$1,
+          num   = RegExp.$2;
+
+      if (delim === 'K') {
+        blockText = globals.gHtmlBlocks[num];
+      } else {
+        // we need to check if ghBlock is a false positive
+        if (codeFlag) {
+          // use encoded version of all text
+          blockText = showdown.subParser('encodeCode')(globals.ghCodeBlocks[num].text);
+        } else {
+          blockText = globals.ghCodeBlocks[num].codeblock;
+        }
+      }
+      blockText = blockText.replace(/\$/g, '$$$$'); // Escape any dollar signs
+
+      grafsOutIt = grafsOutIt.replace(/(\n\n)?~(K|G)\d+\2(\n\n)?/, blockText);
+      // Check if grafsOutIt is a pre->code
+      if (/^<pre\b[^>]*>\s*<code\b[^>]*>/.test(grafsOutIt)) {
+        codeFlag = true;
+      }
+    }
+    grafsOut[i] = grafsOutIt;
+  }
+  text = grafsOut.join('\n\n');
+  // Strip leading and trailing lines:
+  text = text.replace(/^\n+/g, '');
+  text = text.replace(/\n+$/g, '');
+  return globals.converter._dispatch('paragraphs.after', text, options, globals);
+});
+
+/**
+ * Run extension
+ */
+showdown.subParser('runExtension', function (ext, text, options, globals) {
+  'use strict';
+
+  if (ext.filter) {
+    text = ext.filter(text, globals.converter, options);
+
+  } else if (ext.regex) {
+    // TODO remove this when old extension loading mechanism is deprecated
+    var re = ext.regex;
+    if (!re instanceof RegExp) {
+      re = new RegExp(re, 'g');
+    }
+    text = text.replace(re, ext.replace);
+  }
+
+  return text;
+});
+
+/**
+ * These are all the transformations that occur *within* block-level
+ * tags like paragraphs, headers, and list items.
+ */
+showdown.subParser('spanGamut', function (text, options, globals) {
+  'use strict';
+
+  text = globals.converter._dispatch('spanGamut.before', text, options, globals);
+  text = showdown.subParser('codeSpans')(text, options, globals);
+  text = showdown.subParser('escapeSpecialCharsWithinTagAttributes')(text, options, globals);
+  text = showdown.subParser('encodeBackslashEscapes')(text, options, globals);
+
+  // Process anchor and image tags. Images must come first,
+  // because ![foo][f] looks like an anchor.
+  text = showdown.subParser('images')(text, options, globals);
+  text = showdown.subParser('anchors')(text, options, globals);
+
+  // Make links out of things like `<http://example.com/>`
+  // Must come after _DoAnchors(), because you can use < and >
+  // delimiters in inline links like [this](<url>).
+  text = showdown.subParser('autoLinks')(text, options, globals);
+  text = showdown.subParser('encodeAmpsAndAngles')(text, options, globals);
+  text = showdown.subParser('italicsAndBold')(text, options, globals);
+  text = showdown.subParser('strikethrough')(text, options, globals);
+
+  // Do hard breaks:
+  text = text.replace(/  +\n/g, ' <br />\n');
+
+  text = globals.converter._dispatch('spanGamut.after', text, options, globals);
+  return text;
+});
+
+showdown.subParser('strikethrough', function (text, options, globals) {
+  'use strict';
+
+  if (options.strikethrough) {
+    text = globals.converter._dispatch('strikethrough.before', text, options, globals);
+    text = text.replace(/(?:~T){2}([\s\S]+?)(?:~T){2}/g, '<del>$1</del>');
+    text = globals.converter._dispatch('strikethrough.after', text, options, globals);
+  }
+
+  return text;
+});
+
+/**
+ * Strip any lines consisting only of spaces and tabs.
+ * This makes subsequent regexs easier to write, because we can
+ * match consecutive blank lines with /\n+/ instead of something
+ * contorted like /[ \t]*\n+/
+ */
+showdown.subParser('stripBlankLines', function (text) {
+  'use strict';
+  return text.replace(/^[ \t]+$/mg, '');
+});
+
+/**
+ * Strips link definitions from text, stores the URLs and titles in
+ * hash references.
+ * Link defs are in the form: ^[id]: url "optional title"
+ *
+ * ^[ ]{0,3}\[(.+)\]: // id = $1  attacklab: g_tab_width - 1
+ * [ \t]*
+ * \n?                  // maybe *one* newline
+ * [ \t]*
+ * <?(\S+?)>?          // url = $2
+ * [ \t]*
+ * \n?                // maybe one newline
+ * [ \t]*
+ * (?:
+ * (\n*)              // any lines skipped = $3 attacklab: lookbehind removed
+ * ["(]
+ * (.+?)              // title = $4
+ * [")]
+ * [ \t]*
+ * )?                 // title is optional
+ * (?:\n+|$)
+ * /gm,
+ * function(){...});
+ *
+ */
+showdown.subParser('stripLinkDefinitions', function (text, options, globals) {
+  'use strict';
+
+  var regex = /^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*<?(\S+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n+|(?=~0))/gm;
+
+  // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
+  text += '~0';
+
+  text = text.replace(regex, function (wholeMatch, linkId, url, width, height, blankLines, title) {
+    linkId = linkId.toLowerCase();
+    globals.gUrls[linkId] = showdown.subParser('encodeAmpsAndAngles')(url);  // Link IDs are case-insensitive
+
+    if (blankLines) {
+      // Oops, found blank lines, so it's not a title.
+      // Put back the parenthetical statement we stole.
+      return blankLines + title;
+
+    } else {
+      if (title) {
+        globals.gTitles[linkId] = title.replace(/"|'/g, '&quot;');
+      }
+      if (options.parseImgDimensions && width && height) {
+        globals.gDimensions[linkId] = {
+          width:  width,
+          height: height
+        };
+      }
+    }
+    // Completely remove the definition from the text
+    return '';
+  });
+
+  // attacklab: strip sentinel
+  text = text.replace(/~0/, '');
+
+  return text;
+});
+
+showdown.subParser('tables', function (text, options, globals) {
+  'use strict';
+
+  if (!options.tables) {
+    return text;
+  }
+
+  var tableRgx = /^[ \t]{0,3}\|?.+\|.+\n[ \t]{0,3}\|?[ \t]*:?[ \t]*(?:-|=){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:-|=){2,}[\s\S]+?(?:\n\n|~0)/gm;
+
+  function parseStyles(sLine) {
+    if (/^:[ \t]*--*$/.test(sLine)) {
+      return ' style="text-align:left;"';
+    } else if (/^--*[ \t]*:[ \t]*$/.test(sLine)) {
+      return ' style="text-align:right;"';
+    } else if (/^:[ \t]*--*[ \t]*:$/.test(sLine)) {
+      return ' style="text-align:center;"';
+    } else {
+      return '';
+    }
+  }
+
+  function parseHeaders(header, style) {
+    var id = '';
+    header = header.trim();
+    if (options.tableHeaderId) {
+      id = ' id="' + header.replace(/ /g, '_').toLowerCase() + '"';
+    }
+    header = showdown.subParser('spanGamut')(header, options, globals);
+
+    return '<th' + id + style + '>' + header + '</th>\n';
+  }
+
+  function parseCells(cell, style) {
+    var subText = showdown.subParser('spanGamut')(cell, options, globals);
+    return '<td' + style + '>' + subText + '</td>\n';
+  }
+
+  function buildTable(headers, cells) {
+    var tb = '<table>\n<thead>\n<tr>\n',
+        tblLgn = headers.length;
+
+    for (var i = 0; i < tblLgn; ++i) {
+      tb += headers[i];
+    }
+    tb += '</tr>\n</thead>\n<tbody>\n';
+
+    for (i = 0; i < cells.length; ++i) {
+      tb += '<tr>\n';
+      for (var ii = 0; ii < tblLgn; ++ii) {
+        tb += cells[i][ii];
+      }
+      tb += '</tr>\n';
+    }
+    tb += '</tbody>\n</table>\n';
+    return tb;
+  }
+
+  text = globals.converter._dispatch('tables.before', text, options, globals);
+
+  text = text.replace(tableRgx, function (rawTable) {
+
+    var i, tableLines = rawTable.split('\n');
+
+    // strip wrong first and last column if wrapped tables are used
+    for (i = 0; i < tableLines.length; ++i) {
+      if (/^[ \t]{0,3}\|/.test(tableLines[i])) {
+        tableLines[i] = tableLines[i].replace(/^[ \t]{0,3}\|/, '');
+      }
+      if (/\|[ \t]*$/.test(tableLines[i])) {
+        tableLines[i] = tableLines[i].replace(/\|[ \t]*$/, '');
+      }
+    }
+
+    var rawHeaders = tableLines[0].split('|').map(function (s) { return s.trim();}),
+        rawStyles = tableLines[1].split('|').map(function (s) { return s.trim();}),
+        rawCells = [],
+        headers = [],
+        styles = [],
+        cells = [];
+
+    tableLines.shift();
+    tableLines.shift();
+
+    for (i = 0; i < tableLines.length; ++i) {
+      if (tableLines[i].trim() === '') {
+        continue;
+      }
+      rawCells.push(
+        tableLines[i]
+          .split('|')
+          .map(function (s) {
+            return s.trim();
+          })
+      );
+    }
+
+    if (rawHeaders.length < rawStyles.length) {
+      return rawTable;
+    }
+
+    for (i = 0; i < rawStyles.length; ++i) {
+      styles.push(parseStyles(rawStyles[i]));
+    }
+
+    for (i = 0; i < rawHeaders.length; ++i) {
+      if (showdown.helper.isUndefined(styles[i])) {
+        styles[i] = '';
+      }
+      headers.push(parseHeaders(rawHeaders[i], styles[i]));
+    }
+
+    for (i = 0; i < rawCells.length; ++i) {
+      var row = [];
+      for (var ii = 0; ii < headers.length; ++ii) {
+        if (showdown.helper.isUndefined(rawCells[i][ii])) {
+
+        }
+        row.push(parseCells(rawCells[i][ii], styles[ii]));
+      }
+      cells.push(row);
+    }
+
+    return buildTable(headers, cells);
+  });
+
+  text = globals.converter._dispatch('tables.after', text, options, globals);
+
+  return text;
+});
+
+/**
+ * Swap back in all the special characters we've hidden.
+ */
+showdown.subParser('unescapeSpecialChars', function (text) {
+  'use strict';
+
+  text = text.replace(/~E(\d+)E/g, function (wholeMatch, m1) {
+    var charCodeToReplace = parseInt(m1);
+    return String.fromCharCode(charCodeToReplace);
+  });
+  return text;
+});
+module.exports = showdown;

+ 206 - 0
mini-app/lib/wxParse/wxDiscode.js

@@ -0,0 +1,206 @@
+// HTML 支持的数学符号
+function strNumDiscode(str){
+    str = str.replace(/&forall;/g, '∀');
+    str = str.replace(/&part;/g, '∂');
+    str = str.replace(/&exists;/g, '∃');
+    str = str.replace(/&empty;/g, '∅');
+    str = str.replace(/&nabla;/g, '∇');
+    str = str.replace(/&isin;/g, '∈');
+    str = str.replace(/&notin;/g, '∉');
+    str = str.replace(/&ni;/g, '∋');
+    str = str.replace(/&prod;/g, '∏');
+    str = str.replace(/&sum;/g, '∑');
+    str = str.replace(/&minus;/g, '−');
+    str = str.replace(/&lowast;/g, '∗');
+    str = str.replace(/&radic;/g, '√');
+    str = str.replace(/&prop;/g, '∝');
+    str = str.replace(/&infin;/g, '∞');
+    str = str.replace(/&ang;/g, '∠');
+    str = str.replace(/&and;/g, '∧');
+    str = str.replace(/&or;/g, '∨');
+    str = str.replace(/&cap;/g, '∩');
+    str = str.replace(/&cap;/g, '∪');
+    str = str.replace(/&int;/g, '∫');
+    str = str.replace(/&there4;/g, '∴');
+    str = str.replace(/&sim;/g, '∼');
+    str = str.replace(/&cong;/g, '≅');
+    str = str.replace(/&asymp;/g, '≈');
+    str = str.replace(/&ne;/g, '≠');
+    str = str.replace(/&le;/g, '≤');
+    str = str.replace(/&ge;/g, '≥');
+    str = str.replace(/&sub;/g, '⊂');
+    str = str.replace(/&sup;/g, '⊃');
+    str = str.replace(/&nsub;/g, '⊄');
+    str = str.replace(/&sube;/g, '⊆');
+    str = str.replace(/&supe;/g, '⊇');
+    str = str.replace(/&oplus;/g, '⊕');
+    str = str.replace(/&otimes;/g, '⊗');
+    str = str.replace(/&perp;/g, '⊥');
+    str = str.replace(/&sdot;/g, '⋅');
+    return str;
+}
+
+//HTML 支持的希腊字母
+function strGreeceDiscode(str){
+    str = str.replace(/&Alpha;/g, 'Α');
+    str = str.replace(/&Beta;/g, 'Β');
+    str = str.replace(/&Gamma;/g, 'Γ');
+    str = str.replace(/&Delta;/g, 'Δ');
+    str = str.replace(/&Epsilon;/g, 'Ε');
+    str = str.replace(/&Zeta;/g, 'Ζ');
+    str = str.replace(/&Eta;/g, 'Η');
+    str = str.replace(/&Theta;/g, 'Θ');
+    str = str.replace(/&Iota;/g, 'Ι');
+    str = str.replace(/&Kappa;/g, 'Κ');
+    str = str.replace(/&Lambda;/g, 'Λ');
+    str = str.replace(/&Mu;/g, 'Μ');
+    str = str.replace(/&Nu;/g, 'Ν');
+    str = str.replace(/&Xi;/g, 'Ν');
+    str = str.replace(/&Omicron;/g, 'Ο');
+    str = str.replace(/&Pi;/g, 'Π');
+    str = str.replace(/&Rho;/g, 'Ρ');
+    str = str.replace(/&Sigma;/g, 'Σ');
+    str = str.replace(/&Tau;/g, 'Τ');
+    str = str.replace(/&Upsilon;/g, 'Υ');
+    str = str.replace(/&Phi;/g, 'Φ');
+    str = str.replace(/&Chi;/g, 'Χ');
+    str = str.replace(/&Psi;/g, 'Ψ');
+    str = str.replace(/&Omega;/g, 'Ω');
+
+    str = str.replace(/&alpha;/g, 'α');
+    str = str.replace(/&beta;/g, 'β');
+    str = str.replace(/&gamma;/g, 'γ');
+    str = str.replace(/&delta;/g, 'δ');
+    str = str.replace(/&epsilon;/g, 'ε');
+    str = str.replace(/&zeta;/g, 'ζ');
+    str = str.replace(/&eta;/g, 'η');
+    str = str.replace(/&theta;/g, 'θ');
+    str = str.replace(/&iota;/g, 'ι');
+    str = str.replace(/&kappa;/g, 'κ');
+    str = str.replace(/&lambda;/g, 'λ');
+    str = str.replace(/&mu;/g, 'μ');
+    str = str.replace(/&nu;/g, 'ν');
+    str = str.replace(/&xi;/g, 'ξ');
+    str = str.replace(/&omicron;/g, 'ο');
+    str = str.replace(/&pi;/g, 'π');
+    str = str.replace(/&rho;/g, 'ρ');
+    str = str.replace(/&sigmaf;/g, 'ς');
+    str = str.replace(/&sigma;/g, 'σ');
+    str = str.replace(/&tau;/g, 'τ');
+    str = str.replace(/&upsilon;/g, 'υ');
+    str = str.replace(/&phi;/g, 'φ');
+    str = str.replace(/&chi;/g, 'χ');
+    str = str.replace(/&psi;/g, 'ψ');
+    str = str.replace(/&omega;/g, 'ω');
+    str = str.replace(/&thetasym;/g, 'ϑ');
+    str = str.replace(/&upsih;/g, 'ϒ');
+    str = str.replace(/&piv;/g, 'ϖ');
+    str = str.replace(/&middot;/g, '·');
+    return str;
+}
+
+// 
+
+function strcharacterDiscode(str){
+    // 加入常用解析
+    str = str.replace(/&nbsp;/g, ' ');
+    str = str.replace(/&quot;/g, '"');
+    str = str.replace(/&amp;/g, '&');
+    // str = str.replace(/&lt;/g, '‹');
+    // str = str.replace(/&gt;/g, '›');
+
+    str = str.replace(/&lt;/g, '<');
+    str = str.replace(/&gt;/g, '>');
+
+    return str;
+}
+
+// HTML 支持的其他实体
+function strOtherDiscode(str){
+    str = str.replace(/&OElig;/g, 'Œ');
+    str = str.replace(/&oelig;/g, 'œ');
+    str = str.replace(/&Scaron;/g, 'Š');
+    str = str.replace(/&scaron;/g, 'š');
+    str = str.replace(/&Yuml;/g, 'Ÿ');
+    str = str.replace(/&fnof;/g, 'ƒ');
+    str = str.replace(/&circ;/g, 'ˆ');
+    str = str.replace(/&tilde;/g, '˜');
+    str = str.replace(/&ensp;/g, '');
+    str = str.replace(/&emsp;/g, '');
+    str = str.replace(/&thinsp;/g, '');
+    str = str.replace(/&zwnj;/g, '');
+    str = str.replace(/&zwj;/g, '');
+    str = str.replace(/&lrm;/g, '');
+    str = str.replace(/&rlm;/g, '');
+    str = str.replace(/&ndash;/g, '–');
+    str = str.replace(/&mdash;/g, '—');
+    str = str.replace(/&lsquo;/g, '‘');
+    str = str.replace(/&rsquo;/g, '’');
+    str = str.replace(/&sbquo;/g, '‚');
+    str = str.replace(/&ldquo;/g, '“');
+    str = str.replace(/&rdquo;/g, '”');
+    str = str.replace(/&bdquo;/g, '„');
+    str = str.replace(/&dagger;/g, '†');
+    str = str.replace(/&Dagger;/g, '‡');
+    str = str.replace(/&bull;/g, '•');
+    str = str.replace(/&hellip;/g, '…');
+    str = str.replace(/&permil;/g, '‰');
+    str = str.replace(/&prime;/g, '′');
+    str = str.replace(/&Prime;/g, '″');
+    str = str.replace(/&lsaquo;/g, '‹');
+    str = str.replace(/&rsaquo;/g, '›');
+    str = str.replace(/&oline;/g, '‾');
+    str = str.replace(/&euro;/g, '€');
+    str = str.replace(/&trade;/g, '™');
+
+    str = str.replace(/&larr;/g, '←');
+    str = str.replace(/&uarr;/g, '↑');
+    str = str.replace(/&rarr;/g, '→');
+    str = str.replace(/&darr;/g, '↓');
+    str = str.replace(/&harr;/g, '↔');
+    str = str.replace(/&crarr;/g, '↵');
+    str = str.replace(/&lceil;/g, '⌈');
+    str = str.replace(/&rceil;/g, '⌉');
+
+    str = str.replace(/&lfloor;/g, '⌊');
+    str = str.replace(/&rfloor;/g, '⌋');
+    str = str.replace(/&loz;/g, '◊');
+    str = str.replace(/&spades;/g, '♠');
+    str = str.replace(/&clubs;/g, '♣');
+    str = str.replace(/&hearts;/g, '♥');
+
+    str = str.replace(/&diams;/g, '♦');
+
+    return str;
+}
+
+function strMoreDiscode(str){
+    str = str.replace(/\r\n/g,"");  
+    str = str.replace(/\n/g,"");
+
+    str = str.replace(/code/g,"wxxxcode-style");
+    return str;
+}
+
+function strDiscode(str){
+    str = strNumDiscode(str);
+    str = strGreeceDiscode(str);
+    str = strcharacterDiscode(str);
+    str = strOtherDiscode(str);
+    str = strMoreDiscode(str);
+    return str;
+}
+function urlToHttpUrl(url,rep){
+    
+    var patt1 = new RegExp("^//");
+    var result = patt1.test(url);
+    if(result){
+        url = rep+":"+url;
+    }
+    return  url;
+}
+
+module.exports = {
+    strDiscode:strDiscode,
+    urlToHttpUrl:urlToHttpUrl
+}

+ 146 - 0
mini-app/lib/wxParse/wxParse.js

@@ -0,0 +1,146 @@
+/**
+ * author: Di (微信小程序开发工程师)
+ * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
+ *               垂直微信小程序开发交流社区
+ * 
+ * github地址: https://github.com/icindy/wxParse
+ * 
+ * for: 微信小程序富文本解析
+ * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
+ */
+
+/**
+ * utils函数引入
+ **/
+import showdown from 'showdown.js';
+import HtmlToJson from 'html2json.js';
+/**
+ * 配置及公有属性
+ **/
+/**
+ * 主函数入口区
+ **/
+function wxParse(bindName = 'wxParseData', type='html', data='<div class="color:red;">数据不能为空</div>', target,imagePadding) {
+  var that = target;
+  var transData = {};//存放转化后的数据
+  if (type == 'html') {
+    transData = HtmlToJson.html2json(data, bindName);
+    console.log(JSON.stringify(transData, ' ', ' '));
+  } else if (type == 'md' || type == 'markdown') {
+    var converter = new showdown.Converter();
+    var html = converter.makeHtml(data);
+    transData = HtmlToJson.html2json(html, bindName);
+    console.log(JSON.stringify(transData, ' ', ' '));
+  }
+  transData.view = {};
+  transData.view.imagePadding = 0;
+  if(typeof(imagePadding) != 'undefined'){
+    transData.view.imagePadding = imagePadding
+  }
+  var bindData = {};
+  bindData[bindName] = transData;
+  that.setData(bindData)
+  that.wxParseImgLoad = wxParseImgLoad;
+  that.wxParseImgTap = wxParseImgTap;
+}
+// 图片点击事件
+function wxParseImgTap(e) {
+  var that = this;
+  var nowImgUrl = e.target.dataset.src;
+  var tagFrom = e.target.dataset.from;
+  if (typeof (tagFrom) != 'undefined' && tagFrom.length > 0) {
+    wx.previewImage({
+      current: nowImgUrl, // 当前显示图片的http链接
+      urls: that.data[tagFrom].imageUrls // 需要预览的图片http链接列表
+    })
+  }
+}
+
+/**
+ * 图片视觉宽高计算函数区 
+ **/
+function wxParseImgLoad(e) {
+  var that = this;
+  var tagFrom = e.target.dataset.from;
+  var idx = e.target.dataset.idx;
+  if (typeof (tagFrom) != 'undefined' && tagFrom.length > 0) {
+    calMoreImageInfo(e, idx, that, tagFrom)
+  } 
+}
+// 假循环获取计算图片视觉最佳宽高
+function calMoreImageInfo(e, idx, that, bindName) {
+  var temData = that.data[bindName];
+  if (temData.images.length == 0) {
+    return;
+  }
+  var temImages = temData.images;
+  //因为无法获取view宽度 需要自定义padding进行计算,稍后处理
+  var recal = wxAutoImageCal(e.detail.width, e.detail.height,that,bindName); 
+  temImages[idx].width = recal.imageWidth;
+  temImages[idx].height = recal.imageheight; 
+  temData.images = temImages;
+  var bindData = {};
+  bindData[bindName] = temData;
+  that.setData(bindData);
+}
+
+// 计算视觉优先的图片宽高
+function wxAutoImageCal(originalWidth, originalHeight,that,bindName) {
+  //获取图片的原始长宽
+  var windowWidth = 0, windowHeight = 0;
+  var autoWidth = 0, autoHeight = 0;
+  var results = {};
+  wx.getSystemInfo({
+    success: function (res) {
+      var padding = that.data[bindName].view.imagePadding;
+      windowWidth = res.windowWidth-2*padding;
+      windowHeight = res.windowHeight;
+      //判断按照那种方式进行缩放
+      console.log("windowWidth" + windowWidth);
+      if (originalWidth > windowWidth) {//在图片width大于手机屏幕width时候
+        autoWidth = windowWidth;
+        console.log("autoWidth" + autoWidth);
+        autoHeight = (autoWidth * originalHeight) / originalWidth;
+        console.log("autoHeight" + autoHeight);
+        results.imageWidth = autoWidth;
+        results.imageheight = autoHeight;
+      } else {//否则展示原来的数据
+        results.imageWidth = originalWidth;
+        results.imageheight = originalHeight;
+      }
+    }
+  })
+  return results;
+}
+
+function wxParseTemArray(temArrayName,bindNameReg,total,that){
+  var array = [];
+  var temData = that.data;
+  var obj = null;
+  for(var i = 0; i < total; i++){
+    var simArr = temData[bindNameReg+i].nodes;
+    array.push(simArr);
+  }
+
+  temArrayName = temArrayName || 'wxParseTemArray';
+  obj = JSON.parse('{"'+ temArrayName +'":""}');
+  obj[temArrayName] = array;
+  that.setData(obj);
+}
+
+/**
+ * 配置emojis
+ * 
+ */
+
+function emojisInit(reg='',baseSrc="/wxParse/emojis/",emojis){
+   HtmlToJson.emojisInit(reg,baseSrc,emojis);
+}
+
+module.exports = {
+  wxParse: wxParse,
+  wxParseTemArray:wxParseTemArray,
+  emojisInit:emojisInit
+}
+
+

+ 928 - 0
mini-app/lib/wxParse/wxParse.wxml

@@ -0,0 +1,928 @@
+
+<!--**
+ * author: Di (微信小程序开发工程师)
+ * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
+ *               垂直微信小程序开发交流社区
+ * 
+ * github地址: https://github.com/icindy/wxParse
+ * 
+ * for: 微信小程序富文本解析
+ * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
+ */-->
+
+ <!--基础元素-->
+<template name="wxParseVideo">
+    <!--增加video标签支持,并循环添加-->
+    <view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
+        <video class="{{item.classStr}} wxParse-{{item.tag}}-video" src="{{item.attr.src}}"></video>
+    </view>
+</template>
+
+<template name="wxParseImg">
+    <image class="{{item.classStr}} wxParse-{{item.tag}}" data-from="{{item.from}}" data-src="{{item.attr.src}}"  data-idx="{{item.imgIndex}}"  src="{{item.attr.src}}" mode="aspectFit" bindload="wxParseImgLoad" bindtap="wxParseImgTap" style="width:{{item.width}}px;height:{{item.height}}px;{{item.attr.style}}"   />
+</template>
+
+<template name="WxEmojiView">
+  <view class="WxEmojiView wxParse-inline" style="{{item.styleStr}}">
+    <block wx:for="{{item.textArray}}" wx:key="">
+      <block class="{{item.text == '\\n' ? 'wxParse-hide':''}}" wx:if="{{item.node == 'text'}}">{{item.text}}</block>
+      <block wx:elif="{{item.node == 'element'}}">
+        <image class="wxEmoji" src="{{item.baseSrc}}{{item.text}}" />
+      </block>
+    </block>
+  </view>
+</template>
+
+<!--入口模版-->
+
+<template name="wxParse">
+    <block wx:for="{{wxParseData}}" wx:key="">
+        <template is="wxParse0" data="{{item}}"/>
+    </block>
+</template>
+
+
+<!--循环模版-->
+<template name="wxParse0">
+    <!--<template is="wxParse1" data="{{item}}" />-->
+    <!--判断是否是标签节点-->
+    <block wx:if="{{item.node == 'element'}}">
+        <block wx:if="{{item.tag == 'button'}}">
+            <button type="default" size="mini" >
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse1" data="{{item}}"/>
+                </block>
+             </button>
+        </block>
+        <!--li类型-->
+        <block wx:elif="{{item.tag == 'li'}}">
+            <view class="{{item.classStr}} wxParse-li">
+                <view class="{{item.classStr}} wxParse-li-inner">
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <view class="{{item.classStr}} wxParse-li-circle"></view>
+                    </view>
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                            <template is="wxParse1" data="{{item}}"/>
+                        </block>
+                    </view>
+                </view>
+            </view>
+        </block>
+
+        <!--video类型-->
+        <block wx:elif="{{item.tag == 'video'}}">
+            <template is="wxParseVideo" data="{{item}}"/>  
+        </block>
+
+        <!--img类型-->
+        <block wx:elif="{{item.tag == 'img'}}">
+            <template is="wxParseImg" data="{{item}}"/>
+        </block>
+
+        <!--a类型-->
+        <block wx:elif="{{item.tag == 'a'}}">
+            <view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-c="{{item.attr.href}}"  style="{{item.styleStr}}">
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse1" data="{{item}}"/>
+                </block>
+            </view>
+        </block>
+        <block wx:elif="{{item.tag == 'table'}}">
+            <view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
+                <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                    <template is="wxParse1" data="{{item}}"/>                 
+                </block>
+            </view>
+        </block>
+
+        <!--其他块级标签-->
+        <block wx:elif="{{item.tagType == 'block'}}">
+            <view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
+                <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                    <template is="wxParse1" data="{{item}}"/>                 
+                </block>
+            </view>
+        </block>
+
+        <!--内联标签-->
+        <view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
+            <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                <template is="wxParse1" data="{{item}}"/>                 
+            </block>
+        </view>
+
+    </block>
+
+    <!--判断是否是文本节点-->
+    <block wx:elif="{{item.node == 'text'}}">
+        <!--如果是,直接进行-->
+        <template is="WxEmojiView" data="{{item}}"/>
+    </block>
+
+</template>
+
+
+
+<!--循环模版-->
+<template name="wxParse1">
+    <!--<template is="wxParse2" data="{{item}}" />-->
+    <!--判断是否是标签节点-->
+    <block wx:if="{{item.node == 'element'}}">
+        <block wx:if="{{item.tag == 'button'}}">
+            <button type="default" size="mini" >
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse2" data="{{item}}"/>
+                </block>
+             </button>
+        </block>
+        <!--li类型-->
+        <block wx:elif="{{item.tag == 'li'}}">
+            <view class="{{item.classStr}} wxParse-li">
+                <view class="{{item.classStr}} wxParse-li-inner">
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <view class="{{item.classStr}} wxParse-li-circle"></view>
+                    </view>
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                            <template is="wxParse2" data="{{item}}"/>
+                        </block>
+                    </view>
+                </view>
+            </view>
+        </block>
+
+        <!--video类型-->
+        <block wx:elif="{{item.tag == 'video'}}">
+            <template is="wxParseVideo" data="{{item}}"/>  
+        </block>
+
+        <!--img类型-->
+        <block wx:elif="{{item.tag == 'img'}}">
+            <template is="wxParseImg" data="{{item}}"/>
+        </block>
+
+        <!--a类型-->
+        <block wx:elif="{{item.tag == 'a'}}">
+            <view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}"  style="{{item.styleStr}}">
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse2" data="{{item}}"/>
+                </block>
+            </view>
+        </block>
+        
+        <!--其他块级标签-->
+        <block wx:elif="{{item.tagType == 'block'}}">
+            <view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
+                <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                    <template is="wxParse2" data="{{item}}"/>                 
+                </block>
+            </view>
+        </block>
+
+        <!--内联标签-->
+        <view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
+            <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                <template is="wxParse2" data="{{item}}"/>                 
+            </block>
+        </view>
+
+    </block>
+
+    <!--判断是否是文本节点-->
+    <block wx:elif="{{item.node == 'text'}}">
+        <!--如果是,直接进行-->
+        <template is="WxEmojiView" data="{{item}}"/>
+    </block>
+
+</template>
+
+
+<!--循环模版-->
+<template name="wxParse2">
+    <!--<template is="wxParse3" data="{{item}}" />-->
+    <!--判断是否是标签节点-->
+    <block wx:if="{{item.node == 'element'}}">
+        <block wx:if="{{item.tag == 'button'}}">
+            <button type="default" size="mini" >
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse3" data="{{item}}"/>
+                </block>
+             </button>
+        </block>
+        <!--li类型-->
+        <block wx:elif="{{item.tag == 'li'}}">
+            <view class="{{item.classStr}} wxParse-li">
+                <view class="{{item.classStr}} wxParse-li-inner">
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <view class="{{item.classStr}} wxParse-li-circle"></view>
+                    </view>
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                            <template is="wxParse3" data="{{item}}"/>
+                        </block>
+                    </view>
+                </view>
+            </view>
+        </block>
+
+        <!--video类型-->
+        <block wx:elif="{{item.tag == 'video'}}">
+            <template is="wxParseVideo" data="{{item}}"/>  
+        </block>
+
+        <!--img类型-->
+        <block wx:elif="{{item.tag == 'img'}}">
+            <template is="wxParseImg" data="{{item}}"/>
+        </block>
+
+        <!--a类型-->
+        <block wx:elif="{{item.tag == 'a'}}">
+            <view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}"  style="{{item.styleStr}}">
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse3" data="{{item}}"/>
+                </block>
+            </view>
+        </block>
+        
+        <!--其他块级标签-->
+        <block wx:elif="{{item.tagType == 'block'}}">
+            <view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
+                <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                    <template is="wxParse3" data="{{item}}"/>                 
+                </block>
+            </view>
+        </block>
+
+        <!--内联标签-->
+        <view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
+            <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                <template is="wxParse3" data="{{item}}"/>                 
+            </block>
+        </view>
+
+    </block>
+
+    <!--判断是否是文本节点-->
+    <block wx:elif="{{item.node == 'text'}}">
+        <!--如果是,直接进行-->
+        <template is="WxEmojiView" data="{{item}}"/>
+    </block>
+
+</template>
+
+<!--循环模版-->
+<template name="wxParse3">
+    <!--<template is="wxParse4" data="{{item}}" />-->
+    <!--判断是否是标签节点-->
+    <block wx:if="{{item.node == 'element'}}">
+        <block wx:if="{{item.tag == 'button'}}">
+            <button type="default" size="mini" >
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse4" data="{{item}}"/>
+                </block>
+             </button>
+        </block>
+        <!--li类型-->
+        <block wx:elif="{{item.tag == 'li'}}">
+            <view class="{{item.classStr}} wxParse-li">
+                <view class="{{item.classStr}} wxParse-li-inner">
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <view class="{{item.classStr}} wxParse-li-circle"></view>
+                    </view>
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                            <template is="wxParse4" data="{{item}}"/>
+                        </block>
+                    </view>
+                </view>
+            </view>
+        </block>
+
+        <!--video类型-->
+        <block wx:elif="{{item.tag == 'video'}}">
+            <template is="wxParseVideo" data="{{item}}"/>  
+        </block>
+
+        <!--img类型-->
+        <block wx:elif="{{item.tag == 'img'}}">
+            <template is="wxParseImg" data="{{item}}"/>
+        </block>
+
+        <!--a类型-->
+        <block wx:elif="{{item.tag == 'a'}}">
+            <view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}"  style="{{item.styleStr}}">
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse4" data="{{item}}"/>
+                </block>
+            </view>
+        </block>
+        
+        <!--其他块级标签-->
+        <block wx:elif="{{item.tagType == 'block'}}">
+            <view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
+                <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                    <template is="wxParse4" data="{{item}}"/>                 
+                </block>
+            </view>
+        </block>
+
+        <!--内联标签-->
+        <view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
+            <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                <template is="wxParse4" data="{{item}}"/>                 
+            </block>
+        </view>
+
+    </block>
+
+    <!--判断是否是文本节点-->
+    <block wx:elif="{{item.node == 'text'}}">
+        <!--如果是,直接进行-->
+        <template is="WxEmojiView" data="{{item}}"/>
+    </block>
+
+</template>
+
+<!--循环模版-->
+<template name="wxParse4">
+    <!--<template is="wxParse5" data="{{item}}" />-->
+    <!--判断是否是标签节点-->
+    <block wx:if="{{item.node == 'element'}}">
+        <block wx:if="{{item.tag == 'button'}}">
+            <button type="default" size="mini" >
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse5" data="{{item}}"/>
+                </block>
+             </button>
+        </block>
+        <!--li类型-->
+        <block wx:elif="{{item.tag == 'li'}}">
+            <view class="{{item.classStr}} wxParse-li">
+                <view class="{{item.classStr}} wxParse-li-inner">
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <view class="{{item.classStr}} wxParse-li-circle"></view>
+                    </view>
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                            <template is="wxParse5" data="{{item}}"/>
+                        </block>
+                    </view>
+                </view>
+            </view>
+        </block>
+
+        <!--video类型-->
+        <block wx:elif="{{item.tag == 'video'}}">
+            <template is="wxParseVideo" data="{{item}}"/>  
+        </block>
+
+        <!--img类型-->
+        <block wx:elif="{{item.tag == 'img'}}">
+            <template is="wxParseImg" data="{{item}}"/>
+        </block>
+
+        <!--a类型-->
+        <block wx:elif="{{item.tag == 'a'}}">
+            <view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}"  style="{{item.styleStr}}">
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse5" data="{{item}}"/>
+                </block>
+            </view>
+        </block>
+        
+        <!--其他块级标签-->
+        <block wx:elif="{{item.tagType == 'block'}}">
+            <view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
+                <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                    <template is="wxParse5" data="{{item}}"/>                 
+                </block>
+            </view>
+        </block>
+
+        <!--内联标签-->
+        <view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
+            <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                <template is="wxParse5" data="{{item}}"/>                 
+            </block>
+        </view>
+
+    </block>
+
+    <!--判断是否是文本节点-->
+    <block wx:elif="{{item.node == 'text'}}">
+        <!--如果是,直接进行-->
+        <template is="WxEmojiView" data="{{item}}"/>
+    </block>
+
+</template>
+
+<!--循环模版-->
+<template name="wxParse5">
+    <!--<template is="wxParse6" data="{{item}}" />-->
+    <!--判断是否是标签节点-->
+    <block wx:if="{{item.node == 'element'}}">
+        <block wx:if="{{item.tag == 'button'}}">
+            <button type="default" size="mini" >
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse6" data="{{item}}"/>
+                </block>
+             </button>
+        </block>
+        <!--li类型-->
+        <block wx:elif="{{item.tag == 'li'}}">
+            <view class="{{item.classStr}} wxParse-li">
+                <view class="{{item.classStr}} wxParse-li-inner">
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <view class="{{item.classStr}} wxParse-li-circle"></view>
+                    </view>
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                            <template is="wxParse6" data="{{item}}"/>
+                        </block>
+                    </view>
+                </view>
+            </view>
+        </block>
+
+        <!--video类型-->
+        <block wx:elif="{{item.tag == 'video'}}">
+            <template is="wxParseVideo" data="{{item}}"/>  
+        </block>
+
+        <!--img类型-->
+        <block wx:elif="{{item.tag == 'img'}}">
+            <template is="wxParseImg" data="{{item}}"/>
+        </block>
+
+        <!--a类型-->
+        <block wx:elif="{{item.tag == 'a'}}">
+            <view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}"  style="{{item.styleStr}}">
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse6" data="{{item}}"/>
+                </block>
+            </view>
+        </block>
+        
+        <!--其他块级标签-->
+        <block wx:elif="{{item.tagType == 'block'}}">
+            <view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
+                <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                    <template is="wxParse6" data="{{item}}"/>                 
+                </block>
+            </view>
+        </block>
+
+        <!--内联标签-->
+        <view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
+            <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                <template is="wxParse6" data="{{item}}"/>                 
+            </block>
+        </view>
+
+    </block>
+
+    <!--判断是否是文本节点-->
+    <block wx:elif="{{item.node == 'text'}}">
+        <!--如果是,直接进行-->
+        <template is="WxEmojiView" data="{{item}}"/>
+    </block>
+
+</template>
+
+<!--循环模版-->
+<template name="wxParse6">
+    <!--<template is="wxParse7" data="{{item}}" />-->
+    <!--判断是否是标签节点-->
+    <block wx:if="{{item.node == 'element'}}">
+        <block wx:if="{{item.tag == 'button'}}">
+            <button type="default" size="mini" >
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse7" data="{{item}}"/>
+                </block>
+             </button>
+        </block>
+        <!--li类型-->
+        <block wx:elif="{{item.tag == 'li'}}">
+            <view class="{{item.classStr}} wxParse-li">
+                <view class="{{item.classStr}} wxParse-li-inner">
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <view class="{{item.classStr}} wxParse-li-circle"></view>
+                    </view>
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                            <template is="wxParse7" data="{{item}}"/>
+                        </block>
+                    </view>
+                </view>
+            </view>
+        </block>
+
+        <!--video类型-->
+        <block wx:elif="{{item.tag == 'video'}}">
+            <template is="wxParseVideo" data="{{item}}"/>  
+        </block>
+
+        <!--img类型-->
+        <block wx:elif="{{item.tag == 'img'}}">
+            <template is="wxParseImg" data="{{item}}"/>
+        </block>
+
+        <!--a类型-->
+        <block wx:elif="{{item.tag == 'a'}}">
+            <view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}"  style="{{item.styleStr}}">
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse7" data="{{item}}"/>
+                </block>
+            </view>
+        </block>
+        
+        <!--其他块级标签-->
+        <block wx:elif="{{item.tagType == 'block'}}">
+            <view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
+                <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                    <template is="wxParse7" data="{{item}}"/>                 
+                </block>
+            </view>
+        </block>
+
+        <!--内联标签-->
+        <view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
+            <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                <template is="wxParse7" data="{{item}}"/>                 
+            </block>
+        </view>
+
+    </block>
+
+    <!--判断是否是文本节点-->
+    <block wx:elif="{{item.node == 'text'}}">
+        <!--如果是,直接进行-->
+        <template is="WxEmojiView" data="{{item}}"/>
+    </block>
+
+</template>
+<!--循环模版-->
+<template name="wxParse7">
+    <!--<template is="wxParse8" data="{{item}}" />-->
+    <!--判断是否是标签节点-->
+    <block wx:if="{{item.node == 'element'}}">
+        <block wx:if="{{item.tag == 'button'}}">
+            <button type="default" size="mini" >
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse8" data="{{item}}"/>
+                </block>
+             </button>
+        </block>
+        <!--li类型-->
+        <block wx:elif="{{item.tag == 'li'}}">
+            <view class="{{item.classStr}} wxParse-li">
+                <view class="{{item.classStr}} wxParse-li-inner">
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <view class="{{item.classStr}} wxParse-li-circle"></view>
+                    </view>
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                            <template is="wxParse8" data="{{item}}"/>
+                        </block>
+                    </view>
+                </view>
+            </view>
+        </block>
+
+        <!--video类型-->
+        <block wx:elif="{{item.tag == 'video'}}">
+            <template is="wxParseVideo" data="{{item}}"/>  
+        </block>
+
+        <!--img类型-->
+        <block wx:elif="{{item.tag == 'img'}}">
+            <template is="wxParseImg" data="{{item}}"/>
+        </block>
+
+        <!--a类型-->
+        <block wx:elif="{{item.tag == 'a'}}">
+            <view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}"  style="{{item.styleStr}}">
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse8" data="{{item}}"/>
+                </block>
+            </view>
+        </block>
+        
+        <!--其他块级标签-->
+        <block wx:elif="{{item.tagType == 'block'}}">
+            <view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
+                <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                    <template is="wxParse8" data="{{item}}"/>                 
+                </block>
+            </view>
+        </block>
+
+        <!--内联标签-->
+        <view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
+            <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                <template is="wxParse8" data="{{item}}"/>                 
+            </block>
+        </view>
+
+    </block>
+
+    <!--判断是否是文本节点-->
+    <block wx:elif="{{item.node == 'text'}}">
+        <!--如果是,直接进行-->
+        <template is="WxEmojiView" data="{{item}}"/>
+    </block>
+
+</template>
+
+<!--循环模版-->
+<template name="wxParse8">
+    <!--<template is="wxParse9" data="{{item}}" />-->
+    <!--判断是否是标签节点-->
+    <block wx:if="{{item.node == 'element'}}">
+        <block wx:if="{{item.tag == 'button'}}">
+            <button type="default" size="mini" >
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse9" data="{{item}}"/>
+                </block>
+             </button>
+        </block>
+        <!--li类型-->
+        <block wx:elif="{{item.tag == 'li'}}">
+            <view class="{{item.classStr}} wxParse-li">
+                <view class="{{item.classStr}} wxParse-li-inner">
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <view class="{{item.classStr}} wxParse-li-circle"></view>
+                    </view>
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                            <template is="wxParse9" data="{{item}}"/>
+                        </block>
+                    </view>
+                </view>
+            </view>
+        </block>
+
+        <!--video类型-->
+        <block wx:elif="{{item.tag == 'video'}}">
+            <template is="wxParseVideo" data="{{item}}"/>  
+        </block>
+
+        <!--img类型-->
+        <block wx:elif="{{item.tag == 'img'}}">
+            <template is="wxParseImg" data="{{item}}"/>
+        </block>
+
+        <!--a类型-->
+        <block wx:elif="{{item.tag == 'a'}}">
+            <view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}"  style="{{item.styleStr}}">
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse9" data="{{item}}"/>
+                </block>
+            </view>
+        </block>
+        
+        <!--其他块级标签-->
+        <block wx:elif="{{item.tagType == 'block'}}">
+            <view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
+                <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                    <template is="wxParse9" data="{{item}}"/>                 
+                </block>
+            </view>
+        </block>
+
+        <!--内联标签-->
+        <view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
+            <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                <template is="wxParse9" data="{{item}}"/>                 
+            </block>
+        </view>
+
+    </block>
+
+    <!--判断是否是文本节点-->
+    <block wx:elif="{{item.node == 'text'}}">
+        <!--如果是,直接进行-->
+        <template is="WxEmojiView" data="{{item}}"/>
+    </block>
+
+</template>
+
+<!--循环模版-->
+<template name="wxParse9">
+    <!--<template is="wxParse10" data="{{item}}" />-->
+    <!--判断是否是标签节点-->
+    <block wx:if="{{item.node == 'element'}}">
+        <block wx:if="{{item.tag == 'button'}}">
+            <button type="default" size="mini" >
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse10" data="{{item}}"/>
+                </block>
+             </button>
+        </block>
+        <!--li类型-->
+        <block wx:elif="{{item.tag == 'li'}}">
+            <view class="{{item.classStr}} wxParse-li">
+                <view class="{{item.classStr}} wxParse-li-inner">
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <view class="{{item.classStr}} wxParse-li-circle"></view>
+                    </view>
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                            <template is="wxParse10" data="{{item}}"/>
+                        </block>
+                    </view>
+                </view>
+            </view>
+        </block>
+
+        <!--video类型-->
+        <block wx:elif="{{item.tag == 'video'}}">
+            <template is="wxParseVideo" data="{{item}}"/>  
+        </block>
+
+        <!--img类型-->
+        <block wx:elif="{{item.tag == 'img'}}">
+            <template is="wxParseImg" data="{{item}}"/>
+        </block>
+
+        <!--a类型-->
+        <block wx:elif="{{item.tag == 'a'}}">
+            <view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}"  style="{{item.styleStr}}">
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse10" data="{{item}}"/>
+                </block>
+            </view>
+        </block>
+        
+        <!--其他块级标签-->
+        <block wx:elif="{{item.tagType == 'block'}}">
+            <view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
+                <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                    <template is="wxParse10" data="{{item}}"/>                 
+                </block>
+            </view>
+        </block>
+
+        <!--内联标签-->
+        <view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
+            <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                <template is="wxParse10" data="{{item}}"/>                 
+            </block>
+        </view>
+
+    </block>
+
+    <!--判断是否是文本节点-->
+    <block wx:elif="{{item.node == 'text'}}">
+        <!--如果是,直接进行-->
+        <template is="WxEmojiView" data="{{item}}"/>
+    </block>
+
+</template>
+
+<!--循环模版-->
+<template name="wxParse10">
+    <!--<template is="wxParse11" data="{{item}}" />-->
+    <!--判断是否是标签节点-->
+    <block wx:if="{{item.node == 'element'}}">
+        <block wx:if="{{item.tag == 'button'}}">
+            <button type="default" size="mini" >
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse11" data="{{item}}"/>
+                </block>
+             </button>
+        </block>
+        <!--li类型-->
+        <block wx:elif="{{item.tag == 'li'}}">
+            <view class="{{item.classStr}} wxParse-li">
+                <view class="{{item.classStr}} wxParse-li-inner">
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <view class="{{item.classStr}} wxParse-li-circle"></view>
+                    </view>
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                            <template is="wxParse11" data="{{item}}"/>
+                        </block>
+                    </view>
+                </view>
+            </view>
+        </block>
+
+        <!--video类型-->
+        <block wx:elif="{{item.tag == 'video'}}">
+            <template is="wxParseVideo" data="{{item}}"/>  
+        </block>
+
+        <!--img类型-->
+        <block wx:elif="{{item.tag == 'img'}}">
+            <template is="wxParseImg" data="{{item}}"/>
+        </block>
+
+        <!--a类型-->
+        <block wx:elif="{{item.tag == 'a'}}">
+            <view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}"  style="{{item.styleStr}}">
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse11" data="{{item}}"/>
+                </block>
+            </view>
+        </block>
+        
+        <!--其他块级标签-->
+        <block wx:elif="{{item.tagType == 'block'}}">
+            <view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
+                <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                    <template is="wxParse11" data="{{item}}"/>                 
+                </block>
+            </view>
+        </block>
+
+        <!--内联标签-->
+        <view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
+            <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                <template is="wxParse11" data="{{item}}"/>                 
+            </block>
+        </view>
+
+    </block>
+
+    <!--判断是否是文本节点-->
+    <block wx:elif="{{item.node == 'text'}}">
+        <!--如果是,直接进行-->
+        <template is="WxEmojiView" data="{{item}}"/>
+    </block>
+
+</template>
+
+<!--循环模版-->
+<template name="wxParse11">
+    <!--<template is="wxParse12" data="{{item}}" />-->
+    <!--判断是否是标签节点-->
+    <block wx:if="{{item.node == 'element'}}">
+        <block wx:if="{{item.tag == 'button'}}">
+            <button type="default" size="mini" >
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse12" data="{{item}}"/>
+                </block>
+             </button>
+        </block>
+        <!--li类型-->
+        <block wx:elif="{{item.tag == 'li'}}">
+            <view class="{{item.classStr}} wxParse-li">
+                <view class="{{item.classStr}} wxParse-li-inner">
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <view class="{{item.classStr}} wxParse-li-circle"></view>
+                    </view>
+                    <view class="{{item.classStr}} wxParse-li-text">
+                        <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                            <template is="wxParse12" data="{{item}}"/>
+                        </block>
+                    </view>
+                </view>
+            </view>
+        </block>
+
+        <!--video类型-->
+        <block wx:elif="{{item.tag == 'video'}}">
+            <template is="wxParseVideo" data="{{item}}"/>  
+        </block>
+
+        <!--img类型-->
+        <block wx:elif="{{item.tag == 'img'}}">
+            <template is="wxParseImg" data="{{item}}"/>
+        </block>
+
+        <!--a类型-->
+        <block wx:elif="{{item.tag == 'a'}}">
+            <view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}"  style="{{item.styleStr}}">
+                <block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
+                    <template is="wxParse12" data="{{item}}"/>
+                </block>
+            </view>
+        </block>
+        
+        <!--其他块级标签-->
+        <block wx:elif="{{item.tagType == 'block'}}">
+            <view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
+                <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                    <template is="wxParse12" data="{{item}}"/>                 
+                </block>
+            </view>
+        </block>
+
+        <!--内联标签-->
+        <view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
+            <block  wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">       
+                <template is="wxParse12" data="{{item}}"/>                 
+            </block>
+        </view>
+
+    </block>
+
+    <!--判断是否是文本节点-->
+    <block wx:elif="{{item.node == 'text'}}">
+        <!--如果是,直接进行-->
+        <template is="WxEmojiView" data="{{item}}"/>
+    </block>
+
+</template>

+ 202 - 0
mini-app/lib/wxParse/wxParse.wxss

@@ -0,0 +1,202 @@
+
+/**
+ * author: Di (微信小程序开发工程师)
+ * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
+ *               垂直微信小程序开发交流社区
+ * 
+ * github地址: https://github.com/icindy/wxParse
+ * 
+ * for: 微信小程序富文本解析
+ * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
+ */
+
+.wxParse{
+    margin: 0 5px;
+    font-family: Helvetica,sans-serif;
+    font-size: 28rpx;
+    color: #666;
+    line-height: 1.8;
+}
+view{
+    word-break:break-all; overflow:auto;
+}
+.wxParse-inline{
+    display: inline;
+    margin: 0;
+    padding: 0;
+}
+/*//标题 */
+.wxParse-div{margin: 0;padding: 0;}
+.wxParse-h1{ font-size:2em; margin: .67em 0 }
+.wxParse-h2{ font-size:1.5em; margin: .75em 0 }
+.wxParse-h3{ font-size:1.17em; margin: .83em 0 }
+.wxParse-h4{ margin: 1.12em 0}
+.wxParse-h5 { font-size:.83em; margin: 1.5em 0 }
+.wxParse-h6{ font-size:.75em; margin: 1.67em 0 }
+
+.wxParse-h1 {
+  font-size: 18px;
+  font-weight: 400;
+  margin-bottom: .9em;
+}
+.wxParse-h2 {
+  font-size: 16px;
+  font-weight: 400;
+  margin-bottom: .34em;
+}
+.wxParse-h3 {
+  font-weight: 400;
+  font-size: 15px;
+  margin-bottom: .34em;
+}
+.wxParse-h4 {
+  font-weight: 400;
+  font-size: 14px;
+  margin-bottom: .24em;
+}
+.wxParse-h5 {
+  font-weight: 400;
+  font-size: 13px;
+  margin-bottom: .14em;
+}
+.wxParse-h6 {
+  font-weight: 400;
+  font-size: 12px;
+  margin-bottom: .04em;
+}
+
+.wxParse-h1, .wxParse-h2, .wxParse-h3, .wxParse-h4, .wxParse-h5, .wxParse-h6, .wxParse-b, .wxParse-strong  { font-weight: bolder }
+
+.wxParse-i,.wxParse-cite,.wxParse-em,.wxParse-var,.wxParse-address{font-style:italic}
+.wxParse-pre,.wxParse-tt,.wxParse-code,.wxParse-kbd,.wxParse-samp{font-family:monospace}
+.wxParse-pre{white-space:pre}
+.wxParse-big{font-size:1.17em}
+.wxParse-small,.wxParse-sub,.wxParse-sup{font-size:.83em}
+.wxParse-sub{vertical-align:sub}
+.wxParse-sup{vertical-align:super}
+.wxParse-s,.wxParse-strike,.wxParse-del{text-decoration:line-through}
+/*wxparse-自定义个性化的css样式*/
+/*增加video的css样式*/
+.wxParse-strong,wxParse-s{display: inline}
+.wxParse-a{
+    color: deepskyblue;
+    word-break:break-all;
+    overflow:auto;
+}
+
+.wxParse-video{
+    text-align: center;
+    margin: 10px 0;
+}
+
+.wxParse-video-video{
+    width:100%;
+}
+
+.wxParse-img{
+    background-color: #efefef;
+    overflow: hidden;
+    width:40px;
+    height: 40px;
+}
+
+.wxParse-blockquote {
+    margin: 0;
+    padding:10px 0 10px 5px;
+    font-family:Courier, Calibri,"宋体";
+    background:#f5f5f5;
+    border-left: 3px solid #dbdbdb;
+}
+
+.wxParse-code,.wxParse-wxxxcode-style{
+    display: inline;
+    background:#f5f5f5;
+}
+.wxParse-ul{
+    margin: 20rpx 10rpx;
+}
+
+.wxParse-li,.wxParse-li-inner{
+    display: flex;
+    align-items: baseline;
+    margin: 10rpx 0;
+}
+.wxParse-li-text{
+    
+    align-items: center;
+    line-height: 20px;
+}
+
+.wxParse-li-circle{
+    display: inline-flex;
+    width: 5px;
+    height: 5px;
+    background-color: #333;
+    margin-right: 5px;
+}
+
+.wxParse-li-square{
+    display: inline-flex;
+    width: 10rpx;
+    height: 10rpx;
+    background-color: #333;
+    margin-right: 5px;
+}
+.wxParse-li-ring{
+    display: inline-flex;
+    width: 10rpx;
+    height: 10rpx;
+    border: 2rpx solid #333;
+    border-radius: 50%;
+    background-color: #fff;
+    margin-right: 5px;
+}
+
+/*.wxParse-table{
+    width: 100%;
+    height: 400px;
+}
+.wxParse-thead,.wxParse-tfoot,.wxParse-tr{
+    display: flex;
+    flex-direction: row;
+}
+.wxParse-th,.wxParse-td{
+    display: flex;
+    width: 580px;
+    overflow: auto;
+}*/
+
+.wxParse-u {
+  text-decoration: underline;
+}
+.wxParse-hide{
+    display: none;
+}
+.WxEmojiView{
+    align-items: center;
+}
+.wxEmoji{
+    width: 16px;
+    height:16px;
+}
+.wxParse-tr{
+	display: flex;
+	border-right:1px solid #e0e0e0;
+	border-bottom:1px solid #e0e0e0;
+}
+.wxParse-th,
+.wxParse-td{
+	flex:1;
+	padding:5px;
+	font-size:28rpx;
+	border-left:1px solid #e0e0e0;
+	word-break: break-all;
+}
+.wxParse-td:last{
+	border-top:1px solid #e0e0e0;
+}
+.wxParse-th{
+	background:#f0f0f0;
+	border-top:1px solid #e0e0e0;
+}
+

+ 106 - 0
mini-app/pages/auth/login/login.js

@@ -0,0 +1,106 @@
+var api = require('../../../config/api.js');
+var app = getApp();
+Page({
+  data: {
+    username: '',
+    password: '',
+    code: '',
+    loginErrorCount: 0
+  },
+  onLoad: function (options) {
+    // 页面初始化 options为页面跳转所带来的参数
+    // 页面渲染完成
+
+  },
+  onReady: function () {
+
+  },
+  onShow: function () {
+    // 页面显示
+  },
+  onHide: function () {
+    // 页面隐藏
+
+  },
+  onUnload: function () {
+    // 页面关闭
+
+  },
+  startLogin: function () {
+    var that = this;
+
+    if (that.data.password.length < 1 || that.data.username.length < 1) {
+      wx.showModal({
+        title: '错误信息',
+        content: '请输入用户名和密码',
+        showCancel: false
+      });
+      return false;
+    }
+
+    wx.request({
+      url: api.ApiRootUrl + 'auth/login',
+      data: {
+        username: that.data.username,
+        password: that.data.password
+      },
+      method: 'POST',
+      header: {
+        'content-type': 'application/json'
+      },
+      success: function (res) {
+        if(res.data.code == 200){
+          that.setData({
+            'loginErrorCount': 0
+          });
+          wx.setStorage({
+            key:"token",
+            data: res.data.data.token,
+            success: function(){
+              wx.switchTab({
+                url: '/pages/ucenter/index/index'
+              });
+            }
+          });
+        }
+      }
+    });
+  },
+  bindUsernameInput: function (e) {
+
+    this.setData({
+      username: e.detail.value
+    });
+  },
+  bindPasswordInput: function (e) {
+
+    this.setData({
+      password: e.detail.value
+    });
+  },
+  bindCodeInput: function (e) {
+
+    this.setData({
+      code: e.detail.value
+    });
+  },
+  clearInput: function (e) {
+    switch (e.currentTarget.id) {
+      case 'clear-username':
+        this.setData({
+          username: ''
+        });
+        break;
+      case 'clear-password':
+        this.setData({
+          password: ''
+        });
+        break;
+      case 'clear-code':
+        this.setData({
+          code: ''
+        });
+        break;
+    }
+  }
+})

+ 1 - 0
mini-app/pages/auth/login/login.json

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

+ 30 - 0
mini-app/pages/auth/login/login.wxml

@@ -0,0 +1,30 @@
+<view class="container">
+    <view class="form-box">
+
+    	<view class="form-item">
+    		<input class="username" value="{{username}}" bindinput="bindUsernameInput" placeholder="账号" auto-focus/>
+    		<image wx:if="{{ username.length > 0 }}" id="clear-username" class="clear" src="/static/images/clear_input.png" catchtap="clearInput"></image>
+    	</view>
+
+    	<view class="form-item">
+    		<input class="password" value="{{password}}" password bindinput="bindPasswordInput" placeholder="密码"/>
+    		<image class="clear" id="clear-password" wx:if="{{ password.length > 0 }}" src="/static/images/clear_input.png" catchtap="clearInput"></image>
+    	</view>
+
+		<view class="form-item-code" wx-if="{{loginErrorCount >= 3}}">
+			<view class="form-item code-item">
+				<input class="code" value="{{code}}" bindinput="bindCodeInput" placeholder="验证码"/>
+				<image class="clear" id="clear-code" wx:if="{{ code.length > 0 }}" src="/static/images/clear_input.png" catchtap="clearInput"></image>
+			</view>
+			<image class="code-img" src="https://dl.reg.163.com/cp?pd=yanxuan_web&pkid=SkeBZeG&random=1489903563234"></image>
+		</view>
+
+    	<button type="default" class="login-btn" bindtap="startLogin">登录</button>
+
+    	<view class="form-item-text">
+    		<navigator url="/pages/auth/register/register" class="register">注册账号</navigator>
+			<navigator url="/pages/auth/reset/reset" class="reset">忘记密码</navigator>
+    	</view>
+
+    </view>
+</view>

+ 89 - 0
mini-app/pages/auth/login/login.wxss

@@ -0,0 +1,89 @@
+.form-box{
+    width: 100%;
+    height: auto;
+    overflow: hidden;
+    padding: 0 40rpx;
+    margin-top: 96rpx;
+    background: #fff;
+}
+
+.form-item{
+    position: relative;
+    background: #fff;
+    height: 96rpx;
+    border-bottom: 1px solid #d9d9d9;
+}
+
+.form-item .username, .form-item .password, .form-item .code{
+    position: absolute;
+    top: 26rpx;
+    left: 0;
+    display: block;
+    width: 100%;
+    height: 44rpx;
+    background: #fff;
+    color: #333;
+    font-size: 30rpx;
+}
+
+.form-item-code{
+    margin-top:32rpx;
+    height: auto;
+    overflow: hidden;
+    width: 100%;
+}
+
+.form-item-code .form-item{
+    float: left;
+    width: 350rpx;
+}
+
+.form-item-code .code-img{
+    float: right;
+    margin-top: 4rpx;
+    height: 88rpx;
+    width: 236rpx;
+}
+
+.form-item .clear{
+    position: absolute;
+    top: 26rpx;
+    right: 18rpx;
+    z-index: 2;
+    display: block;
+    background: #fff;
+    height: 44rpx;
+    width: 44rpx;
+}
+
+.login-btn{
+    margin: 60rpx 0 40rpx 0;
+    height: 96rpx;
+    line-height: 96rpx;
+    color: #fff;
+    font-size: 30rpx;
+    width: 100%;
+    background: #b4282d;
+    border-radius: 6rpx;
+}
+
+.form-item-text{
+    height: 35rpx;
+    width: 100%;
+}
+
+.form-item-text .register{
+    display: block;
+    height: 34rpx;
+    float: left;
+    font-size: 28rpx;
+    color: #999;
+}
+
+.form-item-text .reset{
+    display: block;
+    height: 34rpx;
+    float: right;
+    font-size: 28rpx;
+    color: #999;
+}

+ 130 - 0
mini-app/pages/auth/register/register.js

@@ -0,0 +1,130 @@
+var api = require('../../../config/api.js');
+var app = getApp();
+Page({
+  data: {
+    username: '',
+    password: '',
+    confirmPassword: '',
+    code: '',
+    loginErrorCount: 0
+  },
+  onLoad: function (options) {
+    // 页面初始化 options为页面跳转所带来的参数
+    // 页面渲染完成
+
+  },
+  onReady: function () {
+
+  },
+  onShow: function () {
+    // 页面显示
+
+  },
+  onHide: function () {
+    // 页面隐藏
+
+  },
+  onUnload: function () {
+    // 页面关闭
+
+  },
+  startRegister: function () {
+    var that = this;
+
+    if (that.data.password.length < 3 || that.data.username.length < 3) {
+      wx.showModal({
+        title: '错误信息',
+        content: '用户名和密码不得少于3位',
+        showCancel: false
+      });
+      return false;
+    }
+
+    if (that.data.password != that.data.confirmPassword) {
+      wx.showModal({
+        title: '错误信息',
+        content: '确认密码不一致',
+        showCancel: false
+      });
+      return false;
+    }
+
+    wx.request({
+      url: api.ApiRootUrl + 'auth/register',
+      data: {
+        username: that.data.username,
+        password: that.data.password
+      },
+      method: 'POST',
+      header: {
+        'content-type': 'application/json'
+      },
+      success: function (res) {
+        if (res.data.code == 200) {
+          that.setData({
+            'loginErrorCount': 0
+          });
+          wx.setStorage({
+            key: "token",
+            data: res.data.data.token,
+            success: function () {
+              wx.switchTab({
+                url: '/pages/ucenter/index/index'
+              });
+            }
+          });
+
+        }
+        console.log(res.data.data.token)
+      }
+    });
+  },
+  bindUsernameInput: function (e) {
+
+    this.setData({
+      username: e.detail.value
+    });
+  },
+  bindPasswordInput: function (e) {
+
+    this.setData({
+      password: e.detail.value
+    });
+  },
+  bindConfirmPasswordInput: function (e) {
+
+    this.setData({
+      confirmPassword: e.detail.value
+    });
+  },
+  bindCodeInput: function (e) {
+
+    this.setData({
+      code: e.detail.value
+    });
+  },
+  clearInput: function (e) {
+    switch (e.currentTarget.id) {
+      case 'clear-username':
+        this.setData({
+          username: ''
+        });
+        break;
+      case 'clear-password':
+        this.setData({
+          password: ''
+        });
+        break;
+      case 'clear-confirm-password':
+        this.setData({
+          confirmPassword: ''
+        });
+        break;
+      case 'clear-code':
+        this.setData({
+          code: ''
+        });
+        break;
+    }
+  }
+})

+ 1 - 0
mini-app/pages/auth/register/register.json

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

+ 30 - 0
mini-app/pages/auth/register/register.wxml

@@ -0,0 +1,30 @@
+<view class="container">
+    <view class="form-box">
+
+    	<view class="form-item">
+    		<input class="username" value="{{username}}" bindinput="bindUsernameInput" placeholder="用户名" auto-focus/>
+    		<image wx:if="{{ username.length > 0 }}" id="clear-username" class="clear" src="/static/images/clear_input.png" catchtap="clearInput"></image>
+    	</view>
+
+    	<view class="form-item">
+    		<input class="password" value="{{password}}" password bindinput="bindPasswordInput" placeholder="密码"/>
+    		<image class="clear" id="clear-password" wx:if="{{ password.length > 0 }}" src="/static/images/clear_input.png" catchtap="clearInput"></image>
+    	</view>
+
+        <view class="form-item">
+    		<input class="password" value="{{confirmPassword}}" password bindinput="bindConfirmPasswordInput" placeholder="确认密码"/>
+    		<image class="clear" id="clear-confirm-password" wx:if="{{ confirmPassword.length > 0 }}" src="/static/images/clear_input.png" catchtap="clearInput"></image>
+    	</view>
+
+		<view class="form-item-code" >
+			<view class="form-item code-item">
+				<input class="code" value="{{code}}" bindinput="bindCodeInput" placeholder="验证码"/>
+				<image class="clear" id="clear-code" wx:if="{{ code.length > 0 }}" src="/static/images/clear_input.png" catchtap="clearInput"></image>
+			</view>
+			<image class="code-img" src="https://dl.reg.163.com/cp?pd=yanxuan_web&pkid=SkeBZeG&random=1489903563234"></image>
+		</view>
+
+    	<button type="default" class="login-btn" bindtap="startRegister">注册</button>
+
+    </view>
+</view>

+ 89 - 0
mini-app/pages/auth/register/register.wxss

@@ -0,0 +1,89 @@
+.form-box{
+    width: 100%;
+    height: auto;
+    overflow: hidden;
+    padding: 0 40rpx;
+    margin-top: 96rpx;
+    background: #fff;
+}
+
+.form-item{
+    position: relative;
+    background: #fff;
+    height: 96rpx;
+    border-bottom: 1px solid #d9d9d9;
+}
+
+.form-item .username, .form-item .password, .form-item .code{
+    position: absolute;
+    top: 26rpx;
+    left: 0;
+    display: block;
+    width: 100%;
+    height: 44rpx;
+    background: #fff;
+    color: #333;
+    font-size: 30rpx;
+}
+
+.form-item-code{
+    margin-top:32rpx;
+    height: auto;
+    overflow: hidden;
+    width: 100%;
+}
+
+.form-item-code .form-item{
+    float: left;
+    width: 350rpx;
+}
+
+.form-item-code .code-img{
+    float: right;
+    margin-top: 4rpx;
+    height: 88rpx;
+    width: 236rpx;
+}
+
+.form-item .clear{
+    position: absolute;
+    top: 26rpx;
+    right: 18rpx;
+    z-index: 2;
+    display: block;
+    background: #fff;
+    height: 44rpx;
+    width: 44rpx;
+}
+
+.login-btn{
+    margin: 60rpx 0 40rpx 0;
+    height: 96rpx;
+    line-height: 96rpx;
+    color: #fff;
+    font-size: 30rpx;
+    width: 100%;
+    background: #b4282d;
+    border-radius: 6rpx;
+}
+
+.form-item-text{
+    height: 35rpx;
+    width: 100%;
+}
+
+.form-item-text .register{
+    display: block;
+    height: 34rpx;
+    float: left;
+    font-size: 28rpx;
+    color: #999;
+}
+
+.form-item-text .reset{
+    display: block;
+    height: 34rpx;
+    float: right;
+    font-size: 28rpx;
+    color: #999;
+}

+ 56 - 0
mini-app/pages/auth/reset/reset.js

@@ -0,0 +1,56 @@
+var app = getApp();
+Page({
+  data: {
+    username: '',
+    code: ''
+  },
+  onLoad: function (options) {
+    // 页面初始化 options为页面跳转所带来的参数
+    // 页面渲染完成
+    
+  },
+  onReady: function () {
+
+  },
+  onShow: function () {
+    // 页面显示
+
+  },
+  onHide: function () {
+    // 页面隐藏
+
+  },
+  onUnload: function () {
+    // 页面关闭
+
+  },
+  startLogin: function(){
+    var that = this;
+  },
+  bindUsernameInput: function(e){
+    
+    this.setData({
+      username: e.detail.value
+    });
+  },
+  bindCodeInput: function(e){
+    
+    this.setData({
+      code: e.detail.value
+    });
+  },
+  clearInput: function(e){
+    switch (e.currentTarget.id){
+      case 'clear-username':
+        this.setData({
+          username: ''
+        });
+        break;
+        case 'clear-code':
+        this.setData({
+          code: ''
+        });
+        break;
+    }
+  }
+})

+ 1 - 0
mini-app/pages/auth/reset/reset.json

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

+ 20 - 0
mini-app/pages/auth/reset/reset.wxml

@@ -0,0 +1,20 @@
+<view class="container">
+    <view class="form-box">
+
+    	<view class="form-item">
+    		<input class="username" value="{{username}}" bindinput="bindUsernameInput" placeholder="请输入账号" auto-focus/>
+    		<image wx:if="{{ username.length > 0 }}" id="clear-username" class="clear" src="/static/images/clear_input.png" catchtap="clearInput"></image>
+    	</view>
+
+		<view class="form-item-code" >
+			<view class="form-item code-item">
+				<input class="code" value="{{code}}" bindinput="bindCodeInput" placeholder="验证码"/>
+				<image class="clear" id="clear-code" wx:if="{{ code.length > 0 }}" src="/static/images/clear_input.png" catchtap="clearInput"></image>
+			</view>
+			<image class="code-img" src="https://dl.reg.163.com/cp?pd=yanxuan_web&pkid=SkeBZeG&random=1489903563234"></image>
+		</view>
+
+    	<button type="default" class="login-btn" bindtap="startNext">下一步</button>
+
+    </view>
+</view>

+ 68 - 0
mini-app/pages/auth/reset/reset.wxss

@@ -0,0 +1,68 @@
+.form-box{
+    width: 100%;
+    height: auto;
+    overflow: hidden;
+    padding: 0 40rpx;
+    margin-top: 96rpx;
+    background: #fff;
+}
+
+.form-item{
+    position: relative;
+    background: #fff;
+    height: 96rpx;
+    border-bottom: 1px solid #d9d9d9;
+}
+
+.form-item .username, .form-item .code{
+    position: absolute;
+    top: 26rpx;
+    left: 0;
+    display: block;
+    width: 100%;
+    height: 44rpx;
+    background: #fff;
+    color: #333;
+    font-size: 30rpx;
+}
+
+.form-item-code{
+    margin-top:32rpx;
+    height: auto;
+    overflow: hidden;
+    width: 100%;
+}
+
+.form-item-code .form-item{
+    float: left;
+    width: 350rpx;
+}
+
+.form-item-code .code-img{
+    float: right;
+    margin-top: 4rpx;
+    height: 88rpx;
+    width: 236rpx;
+}
+
+.form-item .clear{
+    position: absolute;
+    top: 26rpx;
+    right: 18rpx;
+    z-index: 2;
+    display: block;
+    background: #fff;
+    height: 44rpx;
+    width: 44rpx;
+}
+
+.login-btn{
+    margin: 60rpx 0 40rpx 0;
+    height: 96rpx;
+    line-height: 96rpx;
+    color: #fff;
+    font-size: 30rpx;
+    width: 100%;
+    background: #b4282d;
+    border-radius: 6rpx;
+}

+ 56 - 0
mini-app/pages/brand/brand.js

@@ -0,0 +1,56 @@
+var util = require('../../utils/util.js');
+var api = require('../../config/api.js');
+var app = getApp();
+Page({
+  data: {
+    brandList: [],
+    page: 1,
+    size: 10,
+    totalPages: 1
+  },
+  onLoad: function (options) {
+    // 页面初始化 options为页面跳转所带来的参数
+    this.getBrandList();
+  },
+  getBrandList: function () {
+    wx.showLoading({
+      title: '加载中...',
+    });
+    let that = this;
+    util.request(api.BrandList, { page: that.data.page, size: that.data.size }).then(function (res) {
+      if (res.errno === 0) {
+        that.setData({
+          brandList: that.data.brandList.concat(res.data.data),
+          totalPages: res.data.totalPages
+        });
+      }
+      wx.hideLoading();
+    });
+  },
+  onReachBottom (){
+    if (this.data.totalPages > this.data.page) {
+      this.setData({
+        page: this.data.page + 1
+      });
+    } else {
+      return false;
+    }
+
+    this.getBrandList();
+  },
+  onReady: function () {
+
+  },
+  onShow: function () {
+    // 页面显示
+
+  },
+  onHide: function () {
+    // 页面隐藏
+
+  },
+  onUnload: function () {
+    // 页面关闭
+
+  }
+})

+ 1 - 0
mini-app/pages/brand/brand.json

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

+ 16 - 0
mini-app/pages/brand/brand.wxml

@@ -0,0 +1,16 @@
+<view class="container">
+    <view class="brand-list" >
+        <navigator url="../brandDetail/brandDetail?id={{item.id}}"  class="item" wx:for="{{brandList}}" wx:key="id">
+            <view class="img-bg">
+                <image src="{{item.app_list_pic_url}}" background-size="cover"></image>
+            </view>
+            <view class="txt-box">
+                <view class="line">
+                    <text class="name" >{{item.name}}</text>
+                    <text class="s">|</text>
+                    <text class="price">{{item.floor_price}}元起</text>
+                </view>
+            </view>
+        </navigator >
+    </view>
+</view>

+ 52 - 0
mini-app/pages/brand/brand.wxss

@@ -0,0 +1,52 @@
+.brand-list .item{
+    display: block;
+    width: 750rpx;
+    height: 416rpx;
+    position: relative;
+    margin-bottom: 4rpx;
+}
+
+.brand-list .item .img-bg{
+    position: absolute;
+    left:0;
+    top:0;
+    z-index: 0;
+    width: 750rpx;
+    height: 417rpx;
+    overflow: hidden;
+}
+
+.brand-list .item .img-bg image{
+    width: 750rpx;
+    height: 416rpx;
+}
+
+.brand-list .item .txt-box{
+    position: absolute;
+    left:0;
+    top:0;
+    display: table;
+    z-index: 0;
+    width: 750rpx;
+    height: 417rpx;
+}
+
+.brand-list .item .line{
+    display: table-cell;
+    vertical-align: middle;
+    text-align: center;
+    height: 63rpx;
+    line-height: 63rpx;
+}
+
+.brand-list .item .line text{
+    font-size: 35rpx;
+    font-weight: 700;
+    text-shadow: 1rpx 1rpx rgba(0,0,0,.32);
+    color: #fff;
+}
+
+.brand-list .item .line .s{
+    padding: 0 10rpx;
+    font-size: 40rpx;
+}

+ 63 - 0
mini-app/pages/brandDetail/brandDetail.js

@@ -0,0 +1,63 @@
+var util = require('../../utils/util.js');
+var api = require('../../config/api.js');
+
+
+var app = getApp();
+
+Page({
+  data: {
+    id: 0,
+    brand: {},
+    goodsList: [],
+    page: 1,
+    size: 1000
+  },
+  onLoad: function (options) {
+    // 页面初始化 options为页面跳转所带来的参数
+    var that = this;
+    that.setData({
+      id: parseInt(options.id)
+    });
+    this.getBrand();
+  },
+  getBrand: function () {
+    let that = this;
+    util.request(api.BrandDetail, { id: that.data.id }).then(function (res) {
+      if (res.errno === 0) {
+        that.setData({
+          brand: res.data.brand
+        });
+
+        that.getGoodsList();
+      }
+    });
+  },
+  getGoodsList() {
+    var that = this;
+
+    util.request(api.GoodsList, { brandId: that.data.id, page: that.data.page, size: that.data.size})
+      .then(function (res) {
+        if (res.errno === 0) {
+          that.setData({
+            goodsList: res.data.goodsList
+          });
+        }
+      });
+  },
+  onReady: function () {
+    // 页面渲染完成
+
+  },
+  onShow: function () {
+    // 页面显示
+
+  },
+  onHide: function () {
+    // 页面隐藏
+
+  },
+  onUnload: function () {
+    // 页面关闭
+
+  }
+})

+ 3 - 0
mini-app/pages/brandDetail/brandDetail.json

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

+ 28 - 0
mini-app/pages/brandDetail/brandDetail.wxml

@@ -0,0 +1,28 @@
+<view class="container">
+    <view class="brand-info">
+        <view class="name">
+            <image class="img" src="{{brand.app_list_pic_url}}" background-size="cover"></image>
+            <view class="info-box">
+                <view class="info">
+                    <text class="txt">{{brand.name}}</text>
+                    <text class="line"></text>
+                </view>
+            </view>
+        </view>
+        <view class="desc">
+            {{brand.simple_desc}}
+        </view>
+    </view>
+
+    <view class="cate-item">
+        <view class="b">
+            <block wx:for="{{goodsList}}" wx:for-index="iindex" wx:for-item="iitem">
+            <navigator class="item {{iindex % 2 == 0 ? 'item-b' : ''}}" url="../goods/goods?id={{iitem.id}}">
+                <image class="img" src="{{iitem.list_pic_url}}" background-size="cover"></image>
+                <text class="name">{{iitem.name}}</text>
+                <text class="price">¥{{iitem.retail_price}}</text>
+            </navigator>
+            </block>
+        </view>
+    </view>
+</view>

+ 110 - 0
mini-app/pages/brandDetail/brandDetail.wxss

@@ -0,0 +1,110 @@
+page{
+    background: #f4f4f4;
+}
+.brand-info .name{
+    width: 100%;
+    height: 290rpx;
+    position: relative;
+}
+
+.brand-info .img{
+    position: absolute;
+    top:0;
+    left:0;
+    width: 100%;
+    height: 290rpx;
+}
+
+.brand-info .info-box{
+    position: absolute;
+    top:0;
+    left:0;
+    width: 100%;
+    height: 290rpx;
+    text-align: center;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+}
+
+.brand-info .info{
+    display: block;
+}
+
+.brand-info .txt{
+    display: block;
+    height: 37.5rpx;
+    font-size: 37.5rpx;
+    color: #fff;
+}
+
+.brand-info .line{
+    margin: 0 auto;
+    margin-top: 16rpx;
+    display: block;
+    height: 2rpx;
+    width: 145rpx;
+    background: #fff;
+}
+
+.brand-info .desc{
+    background: #fff;
+    width: 100%;
+    height: auto;
+    overflow: hidden;
+    padding: 41.5rpx 31.25rpx;
+    font-size: 30rpx;
+    color: #666;
+    line-height: 41.5rpx;
+    text-align: center;
+}
+
+.cate-item .b{
+  width: 750rpx;
+  height: auto;
+  overflow: hidden;
+  border-top: 1rpx solid #f4f4f4;
+  margin-top: 20rpx;
+}
+
+.cate-item .b .item{
+  float: left;
+  background: #fff;
+  width: 375rpx;
+  padding-bottom: 33.333rpx;
+  border-bottom: 1rpx solid #f4f4f4;
+  height: auto;
+  overflow: hidden;
+  text-align: center;
+}
+
+.cate-item .b .item-b{
+ border-right: 1rpx solid #f4f4f4;
+}
+
+.cate-item .item .img{
+    margin-top: 10rpx;
+  width: 302rpx;
+  height: 302rpx;
+}
+
+.cate-item .item .name{
+  display: block;
+  width: 365.625rpx;
+  height: 35rpx;
+  padding: 0 20rpx;
+  overflow: hidden;
+  margin: 11.5rpx 0 22rpx 0;
+  text-align: center;
+  font-size: 30rpx;
+  color: #333;
+}
+
+.cate-item .item .price{
+  display: block;
+  width: 365.625rpx;
+  height: 30rpx;
+  text-align: center;
+  font-size: 30rpx;
+  color: #b4282d;
+}

+ 281 - 0
mini-app/pages/cart/cart.js

@@ -0,0 +1,281 @@
+var util = require('../../utils/util.js');
+var api = require('../../config/api.js');
+
+var app = getApp();
+
+Page({
+  data: {
+    cartGoods: [],
+    cartTotal: {
+      "goodsCount": 0,
+      "goodsAmount": 0.00,
+      "checkedGoodsCount": 0,
+      "checkedGoodsAmount": 0.00
+    },
+    isEditCart: false,
+    checkedAllStatus: true,
+    editCartList: []
+  },
+  onLoad: function (options) {
+    // 页面初始化 options为页面跳转所带来的参数
+
+
+  },
+  onReady: function () {
+    // 页面渲染完成
+
+  },
+  onShow: function () {
+    // 页面显示
+    this.getCartList();
+  },
+  onHide: function () {
+    // 页面隐藏
+
+  },
+  onUnload: function () {
+    // 页面关闭
+
+  },
+  getCartList: function () {
+    let that = this;
+    util.request(api.CartList).then(function (res) {
+      if (res.errno === 0) {
+        console.log(res.data);
+        that.setData({
+          cartGoods: res.data.cartList,
+          cartTotal: res.data.cartTotal
+        });
+      }
+
+      that.setData({
+        checkedAllStatus: that.isCheckedAll()
+      });
+    });
+  },
+  isCheckedAll: function () {
+    //判断购物车商品已全选
+    return this.data.cartGoods.every(function (element, index, array) {
+      if (element.checked == true) {
+        return true;
+      } else {
+        return false;
+      }
+    });
+  },
+  checkedItem: function (event) {
+    let itemIndex = event.target.dataset.itemIndex;
+    let that = this;
+
+    if (!this.data.isEditCart) {
+      util.request(api.CartChecked, { productIds: that.data.cartGoods[itemIndex].product_id, isChecked: that.data.cartGoods[itemIndex].checked ? 0 : 1 }, 'POST').then(function (res) {
+        if (res.errno === 0) {
+          console.log(res.data);
+          that.setData({
+            cartGoods: res.data.cartList,
+            cartTotal: res.data.cartTotal
+          });
+        }
+
+        that.setData({
+          checkedAllStatus: that.isCheckedAll()
+        });
+      });
+    } else {
+      //编辑状态
+      let tmpCartData = this.data.cartGoods.map(function (element, index, array) {
+        if (index == itemIndex){
+          element.checked = !element.checked;
+        }
+        
+        return element;
+      });
+
+      that.setData({
+        cartGoods: tmpCartData,
+        checkedAllStatus: that.isCheckedAll(),
+        'cartTotal.checkedGoodsCount': that.getCheckedGoodsCount()
+      });
+    }
+  },
+  getCheckedGoodsCount: function(){
+    let checkedGoodsCount = 0;
+    this.data.cartGoods.forEach(function (v) {
+      if (v.checked === true) {
+        checkedGoodsCount += v.number;
+      }
+    });
+    console.log(checkedGoodsCount);
+    return checkedGoodsCount;
+  },
+  checkedAll: function () {
+    let that = this;
+
+    if (!this.data.isEditCart) {
+      var productIds = this.data.cartGoods.map(function (v) {
+        return v.product_id;
+      });
+      util.request(api.CartChecked, { productIds: productIds.join(','), isChecked: that.isCheckedAll() ? 0 : 1 }, 'POST').then(function (res) {
+        if (res.errno === 0) {
+          console.log(res.data);
+          that.setData({
+            cartGoods: res.data.cartList,
+            cartTotal: res.data.cartTotal
+          });
+        }
+
+        that.setData({
+          checkedAllStatus: that.isCheckedAll()
+        });
+      });
+    } else {
+      //编辑状态
+      let checkedAllStatus = that.isCheckedAll();
+      let tmpCartData = this.data.cartGoods.map(function (v) {
+        v.checked = !checkedAllStatus;
+        return v;
+      });
+
+      that.setData({
+        cartGoods: tmpCartData,
+        checkedAllStatus: that.isCheckedAll(),
+        'cartTotal.checkedGoodsCount': that.getCheckedGoodsCount()
+      });
+    }
+
+  },
+  editCart: function () {
+    var that = this;
+    if (this.data.isEditCart) {
+      this.getCartList();
+      this.setData({
+        isEditCart: !this.data.isEditCart
+      });
+    } else {
+      //编辑状态
+      let tmpCartList = this.data.cartGoods.map(function (v) {
+        v.checked = false;
+        return v;
+      });
+      this.setData({
+        editCartList: this.data.cartGoods,
+        cartGoods: tmpCartList,
+        isEditCart: !this.data.isEditCart,
+        checkedAllStatus: that.isCheckedAll(),
+        'cartTotal.checkedGoodsCount': that.getCheckedGoodsCount()
+      });
+    }
+
+  },
+  updateCart: function (productId, goodsId, number, id) {
+    let that = this;
+
+    util.request(api.CartUpdate, {
+      productId: productId,
+      goodsId: goodsId,
+      number: number,
+      id: id
+    }, 'POST').then(function (res) {
+      if (res.errno === 0) {
+        console.log(res.data);
+        that.setData({
+          //cartGoods: res.data.cartList,
+          //cartTotal: res.data.cartTotal
+        });
+      }
+
+      that.setData({
+        checkedAllStatus: that.isCheckedAll()
+      });
+    });
+
+  },
+  cutNumber: function (event) {
+
+    let itemIndex = event.target.dataset.itemIndex;
+    let cartItem = this.data.cartGoods[itemIndex];
+    let number = (cartItem.number - 1 > 1) ? cartItem.number - 1 : 1;
+    cartItem.number = number;
+    this.setData({
+      cartGoods: this.data.cartGoods
+    });
+    this.updateCart(cartItem.product_id, cartItem.goods_id, number, cartItem.id);
+  },
+  addNumber: function (event) {
+    let itemIndex = event.target.dataset.itemIndex;
+    let cartItem = this.data.cartGoods[itemIndex];
+    let number = cartItem.number + 1;
+    cartItem.number = number;
+    this.setData({
+      cartGoods: this.data.cartGoods
+    });
+    this.updateCart(cartItem.product_id, cartItem.goods_id, number, cartItem.id);
+
+  },
+  checkoutOrder: function () {
+    //获取已选择的商品
+    let that = this;
+
+    var checkedGoods = this.data.cartGoods.filter(function (element, index, array) {
+      if (element.checked == true) {
+        return true;
+      } else {
+        return false;
+      }
+    });
+
+    if (checkedGoods.length <= 0) {
+      return false;
+    }
+
+
+    wx.navigateTo({
+      url: '../shopping/checkout/checkout'
+    })
+  },
+  deleteCart: function () {
+    //获取已选择的商品
+    let that = this;
+
+    let productIds = this.data.cartGoods.filter(function (element, index, array) {
+      if (element.checked == true) {
+        return true;
+      } else {
+        return false;
+      }
+    });
+
+    if (productIds.length <= 0) {
+      return false;
+    }
+
+    productIds = productIds.map(function (element, index, array) {
+      if (element.checked == true) {
+        return element.product_id;
+      }
+    });
+
+
+    util.request(api.CartDelete, {
+      productIds: productIds.join(',')
+    }, 'POST').then(function (res) {
+      if (res.errno === 0) {
+        console.log(res.data);
+        let cartList = res.data.cartList.map(v => {
+          console.log(v);
+          v.checked = false;
+          return v;
+        });
+
+        that.setData({
+          cartGoods: cartList,
+          cartTotal: res.data.cartTotal
+        });
+      }
+
+      that.setData({
+        checkedAllStatus: that.isCheckedAll()
+      });
+    });
+  }
+})

+ 3 - 0
mini-app/pages/cart/cart.json

@@ -0,0 +1,3 @@
+{
+    "backgroundColor": "#f4f4f4"
+}

+ 79 - 0
mini-app/pages/cart/cart.wxml

@@ -0,0 +1,79 @@
+<view class="container">
+  <view class="service-policy">
+    <view class="item">30天无忧退货</view>
+    <view class="item">48小时快速退款</view>
+    <view class="item">满88元免邮费</view>
+  </view>
+  <view class="no-cart" wx:if="{{cartGoods.length <= 0}}">
+    <view class="c">
+      <image src="http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/noCart-a8fe3f12e5.png" />
+      <text>去添加点什么吧</text>
+    </view>
+  </view>
+  <view class="cart-view" wx:if="{{cartGoods.length > 0}}">
+    <view class="list">
+      <view class="group-item">
+        <view class="goods">
+          <view class="item {{isEditCart ? 'edit' : ''}}" wx:for="{{cartGoods}}" wx:key="{{item.id}}">
+            <view class="checkbox {{item.checked ? 'checked' : ''}}" bindtap="checkedItem" data-item-index="{{index}}"></view>
+            <view class="cart-goods">
+              <image class="img" src="{{item.list_pic_url}}"></image>
+              <view class="info">
+                <view class="t">
+                  <text class="name">{{item.goods_name}}</text>
+                  <text class="num">x{{item.number}}</text>
+                </view>
+                <view class="attr">{{ isEditCart ? '已选择:' : ''}}{{item.goods_specifition_name_value}}</view>
+                <view class="b">
+                  <text class="price">¥{{item.retail_price}}</text>
+                  <view class="selnum">
+                    <view class="cut" bindtap="cutNumber" data-item-index="{{index}}">-</view>
+                    <input value="{{item.number}}" class="number" disabled="true" type="number" />
+                    <view class="add" bindtap="addNumber" data-item-index="{{index}}">+</view>
+                  </view>
+                </view>
+              </view>
+            </view>
+          </view>
+        </view>
+      </view>
+
+      <!--<view class="group-item">
+                <view class="header">
+                    <view class="promotion">
+                        <text class="tag">满赠</text>
+                        <text class="txt">再加26元, 3件赠1件蔓越莓干</text>
+                        <image class="icon" src="http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/go-b67cb9718d.png"></image>
+                    </view>
+                    <view class="get">领赠品</view>                
+                </view>
+                <view class="goods">
+                    <view class="item">
+                        <view class="checkbox" ></view>
+                        <view class="cart-goods">
+                            <image class="img" src="http://yanxuan.nosdn.127.net/04e05e9de3a471b1f6479dd137b459a8.png"></image>
+                            <view class="info">
+                                <view class="t">
+                                    <text class="name">秋冬保暖加厚细羊毛被</text>
+                                    <text class="num">x1</text>
+                                </view>
+                                <view class="attr">220*240cm</view>
+                                <view class="b">
+                                    <text class="price">¥199.99</text>
+                                    <view class="open">优惠活动</view>
+                                </view>
+                            </view>
+                        </view>
+                    </view>
+                </view>
+            </view>-->
+    </view>
+    <view class="cart-bottom">
+      <view class="checkbox {{checkedAllStatus ? 'checked' : ''}}" bindtap="checkedAll">全选({{cartTotal.checkedGoodsCount}})</view>
+      <view class="total">{{!isEditCart ? '¥'+cartTotal.checkedGoodsAmount : ''}}</view>
+      <view class="delete" bindtap="editCart">{{!isEditCart ? '编辑' : '完成'}}</view>
+      <view class="checkout" bindtap="deleteCart" wx:if="{{isEditCart}}">删除所选</view>
+      <view class="checkout" bindtap="checkoutOrder" wx:if="{{!isEditCart}}">下单</view>
+    </view>
+  </view>
+</view>

+ 352 - 0
mini-app/pages/cart/cart.wxss

@@ -0,0 +1,352 @@
+page{
+    height: 100%;
+    min-height: 100%;
+    background: #f4f4f4;
+}
+.container{
+    background: #f4f4f4;
+    width: 100%;
+    height: auto;
+    min-height: 100%;
+    overflow: hidden;
+}
+.service-policy{
+    width: 750rpx;
+    height: 73rpx;
+    background: #f4f4f4;
+    padding: 0 31.25rpx;
+    display: flex;
+    flex-flow: row nowrap;
+    align-items: center;
+    justify-content: space-between;
+}
+
+.service-policy .item{
+    background: url(http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/servicePolicyRed-518d32d74b.png) 0 center no-repeat;
+    background-size: 10rpx;
+    padding-left: 15rpx;
+    display: flex;
+    align-items: center;
+    font-size: 25rpx;
+    color: #666;
+}
+
+.no-cart{
+    width: 100%;
+    height: auto;
+    margin: 0 auto;
+}
+
+.no-cart .c{
+    width: 100%;
+    height: auto;
+    margin-top: 200rpx;
+}
+
+.no-cart .c image{
+    margin: 0 auto;
+    display: block;
+    text-align: center;
+    width: 258rpx;
+    height: 258rpx;
+}
+
+.no-cart .c text{
+    margin: 0 auto;
+    display: block;
+    width: 258rpx;
+    height: 29rpx;
+    line-height: 29rpx;
+    text-align: center;
+    font-size: 29rpx;
+    color: #999;
+}
+
+
+.cart-view{
+    width: 100%;
+    height: auto;
+    overflow: hidden;
+    
+}
+
+.cart-view .list{
+    height: auto;
+    width: 100%;
+    overflow: hidden;
+    margin-bottom: 120rpx;
+}
+
+.cart-view .group-item{
+    height: auto;
+    width: 100%;
+    background: #fff;
+    margin-bottom: 18rpx;
+}
+
+.cart-view .item{
+    height: 164rpx;
+    width: 100%;
+    overflow: hidden;
+}
+.cart-view .item .checkbox{
+    float: left;
+    height: 34rpx;
+    width: 34rpx;
+    margin: 65rpx 18rpx 65rpx 26rpx;
+    background: url(http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/checkbox-0e09baa37e.png) no-repeat;
+    background-size: 34rpx;
+}
+
+.cart-view .item .checkbox.checked{
+    background: url(http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/checkbox-checked-822e54472a.png) no-repeat;
+    background-size: 34rpx;
+}
+
+.cart-view .item .cart-goods{
+    float: left;
+    height: 164rpx;
+    width: 672rpx;
+    border-bottom: 1px solid #f4f4f4;
+}
+
+.cart-view .item .img{
+    float: left;
+    height:125rpx;
+    width: 125rpx;
+    background: #f4f4f4;
+    margin: 19.5rpx 18rpx 19.5rpx 0;
+}
+
+.cart-view .item .info{
+    float: left;
+    height:125rpx;
+    width: 503rpx;
+    margin: 19.5rpx 26rpx 19.5rpx 0;
+}
+
+.cart-view .item .t{
+    margin: 8rpx 0;
+    height: 28rpx;
+    font-size: 25rpx;
+    color: #333;
+    overflow: hidden;
+}
+
+
+.cart-view .item .name{
+    height: 28rpx;
+    max-width: 310rpx;
+    line-height: 28rpx;
+    font-size: 25rpx;
+    color: #333;
+    overflow: hidden;
+}
+
+.cart-view .item .num{
+    height: 28rpx;
+    line-height: 28rpx;
+    float: right;
+}
+
+.cart-view .item .attr{
+    margin-bottom: 17rpx;
+    height: 24rpx;
+    line-height: 24rpx;
+    font-size: 22rpx;
+    color: #666;
+    overflow: hidden;
+}
+
+.cart-view .item .b{
+    height: 28rpx;
+    line-height: 28rpx;
+    font-size: 25rpx;
+    color: #333;
+    overflow: hidden;
+}
+
+.cart-view .item .price{
+    float: left;
+}
+
+.cart-view .item .open{
+    height: 28rpx;
+    width: 150rpx;
+    display: block;
+    float: right;
+    background: url(http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/arrowDown-d48093db25.png) right center no-repeat;
+    background-size: 25rpx;
+    font-size: 25rpx;
+    color: #333;
+}
+
+.cart-view .item.edit .t{
+    display: none;
+}
+
+.cart-view .item.edit .attr{
+    text-align: right;
+    background: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/arrow-right1-e9828c5b35.png) right center no-repeat;
+    padding-right: 25rpx;
+    background-size: 12rpx 20rpx;
+    margin-bottom: 24rpx;
+    height: 39rpx;
+    line-height: 39rpx;
+    font-size: 24rpx;
+    color: #999;
+    overflow: hidden;
+}
+
+.cart-view .item.edit .b{
+    display: flex;
+    height: 52rpx;
+    overflow: hidden;
+}
+
+.cart-view .item.edit .price{
+    line-height: 52rpx;
+    height: 52rpx;
+    flex: 1;
+}
+
+.cart-view .item .selnum{
+    display: none;
+}
+
+.cart-view .item.edit .selnum{
+    width: 235rpx;
+    height: 52rpx;
+    border: 1rpx solid #ccc;
+    display: flex;
+}
+
+.selnum .cut{
+    width: 70rpx;
+    height: 100%;
+    text-align: center;
+    line-height: 50rpx;
+}
+
+.selnum .number{
+    flex: 1;
+    height: 100%;
+    text-align: center;
+    line-height: 68.75rpx;
+    border-left: 1px solid #ccc;
+    border-right: 1px solid #ccc;
+    float: left;
+}
+
+.selnum .add{
+    width: 80rpx;
+    height: 100%;
+    text-align: center;
+    line-height: 50rpx;
+}
+
+
+.cart-view .group-item .header{
+    width: 100%;
+    height: 94rpx;
+    line-height: 94rpx;
+    padding: 0 26rpx;
+    border-bottom: 1px solid #f4f4f4;
+}
+
+.cart-view .promotion .icon{
+    display: inline-block;
+    height: 24rpx;
+    width: 15rpx;
+}
+
+.cart-view .promotion{
+    margin-top: 25.5rpx;
+    float: left;
+    height: 43rpx;
+    width: 480rpx;
+    /*margin-right: 84rpx;*/
+    line-height: 43rpx;
+    font-size: 0;
+}
+
+.cart-view .promotion .tag{
+    border: 1px solid #f48f18;
+    height: 37rpx;
+    line-height: 31rpx;
+    padding: 0 9rpx;
+    margin-right: 10rpx;
+    color: #f48f18;
+    font-size: 24.5rpx;
+}
+
+.cart-view .promotion .txt{
+    height: 43rpx;
+    line-height: 43rpx;
+    padding-right: 10rpx;
+    color: #333;
+    font-size: 29rpx;
+    overflow: hidden;
+}
+
+.cart-view .get{
+    margin-top: 18rpx;
+    float: right;
+    height: 58rpx;
+    padding-left: 14rpx;
+    border-left: 1px solid #d9d9d9;
+    line-height: 58rpx;
+    font-size: 29rpx;
+    color: #333;
+}
+
+.cart-bottom{
+    position: fixed;
+    bottom:0;
+    left:0;
+    height: 100rpx;
+    width: 100%;
+    background: #fff;
+    display: flex;
+}
+
+.cart-bottom .checkbox{
+    height: 34rpx;
+
+    padding-left: 60rpx;
+    line-height: 34rpx;
+    margin: 33rpx 18rpx 33rpx 26rpx;
+    background: url(http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/checkbox-0e09baa37e.png) no-repeat;
+    background-size: 34rpx;
+    font-size: 29rpx;
+}
+
+.cart-bottom .checkbox.checked{
+    background: url(http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/checkbox-checked-822e54472a.png) no-repeat;
+    background-size: 34rpx;
+}
+
+.cart-bottom .total{
+    height: 34rpx;
+    flex: 1;
+    margin: 33rpx 10rpx;
+    font-size: 29rpx;
+}
+
+
+.cart-bottom .delete{
+    height: 34rpx;
+    width: auto;
+    margin: 33rpx 18rpx;
+    font-size: 29rpx;
+}
+
+.cart-bottom .checkout{
+    height: 100rpx;
+    width: 210rpx;
+    text-align: center;
+    line-height: 100rpx;
+    font-size: 29rpx;
+    background: #b4282d;
+    color: #fff;
+}

+ 76 - 0
mini-app/pages/catalog/catalog.js

@@ -0,0 +1,76 @@
+var util = require('../../utils/util.js');
+var api = require('../../config/api.js');
+
+Page({
+  data: {
+    navList: [],
+    categoryList: [],
+    currentCategory: {},
+    scrollLeft: 0,
+    scrollTop: 0,
+    goodsCount: 0,
+    scrollHeight: 0
+  },
+  onLoad: function (options) {
+    this.getCatalog();
+  },
+  getCatalog: function () {
+    //CatalogList
+    let that = this;
+    wx.showLoading({
+      title: '加载中...',
+    });
+    util.request(api.CatalogList).then(function (res) {
+        that.setData({
+          navList: res.data.categoryList,
+          currentCategory: res.data.currentCategory
+        });
+        wx.hideLoading();
+      });
+    util.request(api.GoodsCount).then(function (res) {
+      that.setData({
+        goodsCount: res.data.goodsCount
+      });
+    });
+
+  },
+  getCurrentCategory: function (id) {
+    let that = this;
+    util.request(api.CatalogCurrent+"/"+id)
+      .then(function (res) {
+        that.setData({
+          currentCategory: res.data.currentCategory
+        });
+      });
+  },
+  onReady: function () {
+    // 页面渲染完成
+  },
+  onShow: function () {
+    // 页面显示
+  },
+  onHide: function () {
+    // 页面隐藏
+  },
+  onUnload: function () {
+    // 页面关闭
+  },
+  getList: function () {
+    var that = this;
+    util.request(api.ApiRootUrl + 'api/catalog/' + that.data.currentCategory.cat_id)
+      .then(function (res) {
+        that.setData({
+          categoryList: res.data,
+        });
+      });
+  },
+  switchCate: function (event) {
+    var that = this;
+    var currentTarget = event.currentTarget;
+    if (this.data.currentCategory.id == event.currentTarget.dataset.id) {
+      return false;
+    }
+
+    this.getCurrentCategory(event.currentTarget.dataset.id);
+  }
+})

+ 1 - 0
mini-app/pages/catalog/catalog.json

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

+ 29 - 0
mini-app/pages/catalog/catalog.wxml

@@ -0,0 +1,29 @@
+<view class="container">
+  <view class="search">
+    <navigator url="/pages/search/search" class="input">
+      <image class="icon"></image>
+      <text class="txt">商品搜索, 共{{goodsCount}}款好物</text>
+    </navigator>
+  </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>
+    </scroll-view>
+    <scroll-view class="cate" scroll-y="true">
+        <navigator url="url" class="banner">
+            <image class="image" src="https://image.flaticon.com/icons/svg/743/743007.svg"></image>
+        </navigator>
+        <view class="hd">
+            <text class="line"></text>
+            <text class="txt">{{currentCategory.name}}分类</text>
+            <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}}">
+                <image class="icon" src="{{item.wap_banner_url}}"></image>
+                <text class="txt">{{item.name}}</text>
+            </navigator>
+        </view>
+    </scroll-view>
+  </view>
+</view>

+ 166 - 0
mini-app/pages/catalog/catalog.wxss

@@ -0,0 +1,166 @@
+page {
+  height: 100%;
+}
+
+.container {
+  background: #f9f9f9;
+  height: 100%;
+  width: 100%;
+  display: flex;
+  flex-direction: column;
+}
+
+.search {
+  height: 88rpx;
+  width: 100%;
+  padding: 0 30rpx;
+  background: #fff;
+  display: flex;
+  align-items: center;
+}
+
+.search .input {
+  width: 690rpx;
+  height: 56rpx;
+  background: #ededed;
+  border-radius: 8rpx;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+
+.search .icon {
+  background: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/search2-2fb94833aa.png) center no-repeat;
+  background-size: 100%;
+  width: 28rpx;
+  height: 28rpx;
+}
+
+.search .txt {
+  height: 42rpx;
+  line-height: 42rpx;
+  color: #666;
+  padding-left: 10rpx;
+  font-size: 30rpx;
+}
+
+.catalog {
+  flex: 1;
+  width: 100%;
+  background: #fff;
+  display: flex;
+  border-top: 1px solid #fafafa;
+}
+
+.catalog .nav {
+  width: 162rpx;
+  height: 100%;
+}
+
+.catalog .nav .item {
+  text-align: center;
+  line-height: 90rpx;
+  width: 162rpx;
+  height: 90rpx;
+  color: #333;
+  font-size: 28rpx;
+  border-left: 6rpx solid #fff;
+}
+
+.catalog .nav .item.active {
+color:#000;
+font-size:36rpx;
+border-left:6rpx solid #fd9f06;
+
+}
+
+.catalog .cate {
+  border-left: 1px solid #fafafa;
+  flex: 1;
+  height: 100%;
+  padding: 0 30rpx 0 30rpx;
+}
+
+.banner {
+  display: block;
+  height: 222rpx;
+  width: 100%;
+  position: relative;
+}
+
+.banner .image {
+  position: absolute;
+  top: 30rpx;
+  left: 0;
+  border-radius: 4rpx;
+  height: 192rpx;
+  width: 100%;
+}
+
+.banner .txt {
+  position: absolute;
+  top: 30rpx;
+  text-align: center;
+  color: #fff;
+  font-size: 28rpx;
+  left: 0;
+  height: 192rpx;
+  line-height: 192rpx;
+  width: 100%;
+}
+
+.catalog .hd {
+  height: 108rpx;
+  width: 100%;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+}
+
+.catalog .hd .txt {
+  font-size: 24rpx;
+  text-align: center;
+  color: #333;
+  padding: 0 10rpx;
+  width: auto;
+}
+
+.catalog .hd .line {
+  width: 40rpx;
+  height: 1px;
+  background: #d9d9d9;
+}
+
+.catalog .bd {
+  height: auto;
+  width: 100%;
+  overflow: hidden;
+}
+
+.catalog .bd .item {
+  display: block;
+  float: left;
+  height: 216rpx;
+  width: 144rpx;
+  margin-right: 34rpx;
+}
+
+.catalog .bd .item.last {
+  margin-right: 0;
+}
+
+.catalog .bd .item .icon {
+  height:80rpx;
+  width:80rpx;
+  margin-left:17px;
+
+}
+
+.catalog .bd .item .txt {
+  display: block;
+  text-align: center;
+  font-size: 24rpx;
+  color: #333;
+  height: 72rpx;
+  width: 144rpx;
+}

+ 116 - 0
mini-app/pages/category/category.js

@@ -0,0 +1,116 @@
+var util = require('../../utils/util.js');
+var api = require('../../config/api.js');
+
+Page({
+  data: {
+    // text:"这是一个页面"
+    navList: [],
+    goodsList: [],
+    id: 0,
+    currentCategory: {},
+    scrollLeft: 0,
+    scrollTop: 0,
+    scrollHeight: 0,
+    page: 1,
+    size: 10000
+  },
+  onLoad: function (options) {
+    // 页面初始化 options为页面跳转所带来的参数
+    var that = this;
+    if (options.id) {
+      that.setData({
+        id: parseInt(options.id)
+      });
+    }
+
+    wx.getSystemInfo({
+      success: function (res) {
+        that.setData({
+          scrollHeight: res.windowHeight
+        });
+      }
+    });
+
+
+    this.getCategoryInfo();
+
+  },
+  getCategoryInfo: function () {
+    let that = this;
+    util.request(api.GoodsCategory + "/" + this.data.id)
+      .then(function (res) {
+
+        if (res.errno == 0) {
+          that.setData({
+            navList: res.data.brotherCategory,
+            goodsList: res.data.goodsList
+          });
+
+          //nav位置
+          let currentIndex = 0;
+          let navListCount = that.data.navList.length;
+          for (let i = 0; i < navListCount; i++) {
+            currentIndex += 1;
+            if (that.data.navList[i].id == that.data.id) {
+              break;
+            }
+          }
+          if (currentIndex > navListCount / 2 && navListCount > 5) {
+            that.setData({
+              scrollLeft: currentIndex * 60
+            });
+          }
+          //that.getGoodsList();
+
+        } else {
+          //显示错误信息
+        }
+        
+      });
+  },
+  onReady: function () {
+    // 页面渲染完成
+  },
+  onShow: function () {
+    // 页面显示
+    console.log(1);
+  },
+  onHide: function () {
+    // 页面隐藏
+  },
+  getGoodsList: function () {
+    var that = this;
+
+    util.request(api.GoodsList + "/" + that.data.id, { page: that.data.page, size: that.data.size})
+      .then(function (res) {
+        that.setData({
+          goodsList: res.data.goodsList,
+        });
+      });
+  },
+  onUnload: function () {
+    // 页面关闭
+  },
+  switchCate: function (event) {
+    if (this.data.id == event.currentTarget.dataset.id) {
+      return false;
+    }
+    var that = this;
+    var clientX = event.detail.x;
+    var currentTarget = event.currentTarget;
+    if (clientX < 60) {
+      that.setData({
+        scrollLeft: currentTarget.offsetLeft - 60
+      });
+    } else if (clientX > 330) {
+      that.setData({
+        scrollLeft: currentTarget.offsetLeft
+      });
+    }
+    this.setData({
+      id: event.currentTarget.dataset.id
+    });
+
+    this.getGoodsList();
+  }
+})

+ 1 - 0
mini-app/pages/category/category.json

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

+ 23 - 0
mini-app/pages/category/category.wxml

@@ -0,0 +1,23 @@
+<!-- 在分类页选择某个分类之后的页 -->
+<view class="container">
+    <view class="cate-nav">
+        <scroll-view scroll-x="true" class="cate-nav-body" style="width: 750rpx;" scroll-left="{{scrollLeft}}">
+            <view  wx:for="{{navList}}" class="item {{ id == item.id ? 'active' : ''}}" data-id="{{item.id}}" data-index="{{index}}" bindtap="switchCate">
+                <view class="name">{{item.name}}</view>
+            </view>
+        </scroll-view>
+    </view>
+    <scroll-view scroll-y="true" scroll-top="{{scrollTop}}" style="height:{{scrollHeight}};">
+
+    <view class="cate-item">
+        <view class="b">
+            <navigator class="item {{(iindex + 1) % 2 == 0 ? 'item-b' : ''}}"   url="/pages/goods/goods?id={{iitem.id}}" wx:for="{{goodsList}}" wx:for-item="iitem" wx:for-index="iindex" >
+                <image class="img" src="{{iitem.list_pic_url}}" background-size="cover"></image>
+                <text class="name">{{iitem.name}}</text>
+                <text class="price">¥{{iitem.price}}</text>
+            </navigator>
+        </view>
+    </view>
+    <!-- TODO 到底后加载更多 -->
+    </scroll-view>
+</view>

+ 117 - 0
mini-app/pages/category/category.wxss

@@ -0,0 +1,117 @@
+.container{
+    background: #f9f9f9;
+}
+.cate-nav{
+    position: fixed;
+    left:0;
+    top:0;
+    z-index: 1000;
+}
+
+.cate-nav-body{
+    height: 84rpx;
+    white-space: nowrap;   
+    background: #fff;
+    border-top: 1px solid rgba(0,0,0,.15);
+    overflow: hidden;
+}
+
+.cate-nav .item{
+    display: inline-block;
+    height: 84rpx;
+    min-width: 130rpx;
+    padding: 0 15rpx;
+}
+
+.cate-nav .item .name{
+    display: block;
+    height: 84rpx;
+    padding: 0 20rpx;
+    line-height: 84rpx;
+    color: #333;
+    font-size: 30rpx;
+    width: auto;
+}
+
+.cate-nav .item.active .name{
+    color: #ab2b2b;
+    border-bottom: 2px solid #ab2b2b;
+}
+
+.cate-item{
+    margin-top: 94rpx;
+    height: auto;
+    overflow: hidden;
+}
+
+.cate-item .h{
+    height: 145rpx;
+    width: 750rpx;
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    justify-content: center;
+}
+
+.cate-item .h .name{
+    display: block;
+    height: 35rpx;
+    margin-bottom: 18rpx;
+    font-size: 30rpx;
+    color: #333;
+}
+
+.cate-item .h .desc{
+    display: block;
+    height: 24rpx;
+    font-size: 24rpx;
+    color: #999;
+}
+
+.cate-item .b{
+  width: 750rpx;
+  padding: 0 6.25rpx;
+  height: auto;
+  overflow: hidden;
+}
+
+.cate-item .b .item{
+  float: left;
+  background: #fff;
+  width: 365rpx;
+  margin-bottom: 6.25rpx;
+  padding-bottom: 33.333rpx;
+  height: auto;
+  overflow: hidden;
+  text-align: center;
+}
+
+.cate-item .b .item-b{
+  margin-left: 6.25rpx;
+}
+
+.cate-item .item .img{
+  width: 302rpx;
+  height: 302rpx;
+}
+
+.cate-item .item .name{
+  display: block;
+  width: 365.625rpx;
+  height: 35rpx;
+  margin: 11.5rpx 0 22rpx 0;
+  text-align: center;
+  overflow: hidden;
+  padding: 0 20rpx;
+  font-size: 30rpx;
+  color: #333;
+}
+
+.cate-item .item .price{
+  display: block;
+  width: 365.625rpx;
+  height: 30rpx;
+  text-align: center;
+  font-size: 30rpx;
+  color: #b4282d;
+}

+ 115 - 0
mini-app/pages/comment/comment.js

@@ -0,0 +1,115 @@
+var app = getApp();
+var util = require('../../utils/util.js');
+var api = require('../../config/api.js');
+
+Page({
+  data: {
+    comments: [],
+    allCommentList: [],
+    picCommentList: [],
+    typeId: 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, typeId: that.data.typeId}).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, 
+      typeId: that.data.typeId, 
+      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({
+      typeId: options.typeId,
+      valueId: options.valueId
+    });
+    this.getCommentCount();
+    this.getCommentList();
+  },
+  onReady: function () {
+    // 页面渲染完成
+
+  },
+  onShow: function () {
+    // 页面显示
+
+  },
+  onHide: function () {
+    // 页面隐藏
+
+  },
+  onUnload: function () {
+    // 页面关闭
+
+  },
+  switchTab: function () {
+    this.setData({
+      showType: this.data.showType == 1 ? 0 :1
+    });
+
+    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();
+  }
+})

+ 3 - 0
mini-app/pages/comment/comment.json

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

+ 33 - 0
mini-app/pages/comment/comment.wxml

@@ -0,0 +1,33 @@
+<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="{{item.id}}">
+      <view class="info">
+        <view class="user">
+          <image src="{{item.user_info.avatar}}"></image>
+          <text>{{item.user_info.nickname}}</text>
+        </view>
+        <view class="time">{{item.add_time}}</view>
+      </view>
+      <view class="comment">{{item.content}}</view>
+      <view class="imgs" wx:if="{{item.pic_list.length > 0}}">
+        <image class="img" wx:for="{{item.pic_list}}" wx:key="{{pitem.id}}" wx:for-item="pitem" src="{{pitem.pic_url}}"></image>
+      </view>
+      <view class="spec">
+        <!-- <text class="item">白色 2件</text> -->
+      </view>
+      <!--<view class="customer-service" wx:if="{{item.commentReplyVO}}">
+        <text class="u">小选回复:</text>
+        <text class="c">{{item.commentReplyVO.replyContent}}</text>
+      </view>-->
+    </view>
+
+  </view>
+</view>

+ 156 - 0
mini-app/pages/comment/comment.wxss

@@ -0,0 +1,156 @@
+.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,.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,.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;
+}

+ 80 - 0
mini-app/pages/commentPost/commentPost.js

@@ -0,0 +1,80 @@
+var app = getApp();
+var util = require('../../utils/util.js');
+var api = require('../../config/api.js');
+Page({
+  data: {
+    typeId: 0,
+    valueId: 0,
+    content: ''
+  },
+  onLoad: function (options) {
+
+    var that = this;
+    that.setData({
+      typeId: parseInt(options.typeId),
+      valueId: parseInt(options.valueId)
+    });
+
+  },
+  onClose() {
+    wx.navigateBack({
+      delta: 1
+    });
+  },
+  onPost() {
+    let that = this;
+
+    if (!this.data.content) {
+      util.showErrorToast('请填写评论')
+      return false;
+    }
+
+
+    util.request(api.CommentPost, {
+      typeId: that.data.typeId,
+      valueId: that.data.valueId,
+      content: that.data.content
+    }, 'POST').then(function (res) {
+      if (res.errno === 0) {
+        wx.showToast({
+          title: '评论成功',
+          complete: function(){
+            wx.navigateBack({
+              delta: 1
+            });
+          }
+        })
+      }
+      console.log(res)
+    });
+  },
+  bindInpuntValue(event){
+
+    let value = event.detail.value;
+
+    //判断是否超过140个字符
+    if (value && value.length > 140) {
+      return false;
+    }
+
+    this.setData({
+      content: event.detail.value,
+    })
+    console.log(event.detail)
+  },
+  onReady: function () {
+
+  },
+  onShow: function () {
+    // 页面显示
+
+  },
+  onHide: function () {
+    // 页面隐藏
+
+  },
+  onUnload: function () {
+    // 页面关闭
+
+  }
+})

+ 3 - 0
mini-app/pages/commentPost/commentPost.json

@@ -0,0 +1,3 @@
+{
+  "navigationBarTitleText": "填写留言"
+}

+ 12 - 0
mini-app/pages/commentPost/commentPost.wxml

@@ -0,0 +1,12 @@
+<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>
+    </view>
+</view>

+ 63 - 0
mini-app/pages/commentPost/commentPost.wxss

@@ -0,0 +1,63 @@
+page, .container {
+  height: 100%;
+  background: #f4f4f4;
+}
+
+.post-comment {
+  width: 750rpx;
+  height: auto;
+  overflow: hidden;
+  padding: 30rpx;
+}
+
+.post-comment .input-box {
+  height: 337.5rpx;
+  width: 690rpx;
+  position: relative;
+  background: #fff;
+}
+
+.post-comment .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-comment .input-box .count {
+  position: absolute;
+  bottom: 20rpx;
+  right: 20rpx;
+  display: block;
+  height: 30rpx;
+  width: 50rpx;
+  font-size: 29rpx;
+  color: #999;
+}
+
+.post-comment .btns {
+  height: 108rpx;
+}
+
+.post-comment .close {
+  float: left;
+  height: 108rpx;
+  line-height: 108rpx;
+  text-align: left;
+  color: #666;
+  padding: 0 30rpx;
+}
+
+.post-comment .post {
+  float: right;
+  height: 108rpx;
+  line-height: 108rpx;
+  text-align: right;
+  padding: 0 30rpx;
+}

+ 331 - 0
mini-app/pages/goods/goods.js

@@ -0,0 +1,331 @@
+var app = getApp();
+var WxParse = require('../../lib/wxParse/wxParse.js');
+var util = require('../../utils/util.js');
+var api = require('../../config/api.js');
+
+Page({
+  data: {
+    id: 0,
+    goods: {},
+    gallery: [],
+    // attribute: [],
+    // issueList: [],
+    comment: [],
+    // brand: {},
+    // specificationList: [],
+    // productList: [],
+    relatedGoods: [],
+    cartGoodsCount: 0,
+    userHasCollect: 0,
+    number: 1,
+    checkedSpecText: '请选择规格数量',
+    openAttr: false,
+    noCollectImage: "/static/images/detail_star.png",
+    hasCollectImage: "/static/images/detail_star_checked.png",
+    collectBackImage: "/static/images/detail_star.png"
+  },
+  getGoodsInfo: function () {
+    let that = this;
+    util.request(api.GoodsDetail + '/' + that.data.id ).then(function (res) {
+      if (res.errno === 0) {
+        that.setData({
+          goods: res.data.info,
+          gallery: res.data.gallery,
+          // attribute: res.data.attribute,
+          // issueList: res.data.issue,
+          comment: res.data.comment,
+          // brand: res.data.brand,
+          // specificationList: res.data.specificationList,
+          // productList: res.data.productList,
+          userHasCollect: res.data.userHasCollect
+        });
+
+        if (res.data.userHasCollect == 1) {
+          that.setData({
+            'collectBackImage': that.data.hasCollectImage
+          });
+        } else {
+          that.setData({
+            'collectBackImage': that.data.noCollectImage
+          });
+        }
+
+        WxParse.wxParse('goodsDetail', 'html', res.data.info.goods_desc, that);
+
+        that.getGoodsRelated();
+      }
+    });
+
+  },
+  getGoodsRelated: function () {
+    let that = this;
+    util.request(api.GoodsRelated + '/' + that.data.id,).then(function (res) {
+      if (res.errno === 0) {
+        that.setData({
+          relatedGoods: res.data.goodsList,
+        });
+      }
+    });
+
+  },
+  clickSkuValue: function (event) {
+    let that = this;
+    let specNameId = event.currentTarget.dataset.nameId;
+    let specValueId = event.currentTarget.dataset.valueId;
+
+    //判断是否可以点击
+
+    //TODO 性能优化,可在wx:for中添加index,可以直接获取点击的属性名和属性值,不用循环
+    let _specificationList = this.data.specificationList;
+    for (let i = 0; i < _specificationList.length; i++) {
+      if (_specificationList[i].specification_id == specNameId) {
+        for (let j = 0; j < _specificationList[i].valueList.length; j++) {
+          if (_specificationList[i].valueList[j].id == specValueId) {
+            //如果已经选中,则反选
+            if (_specificationList[i].valueList[j].checked) {
+              _specificationList[i].valueList[j].checked = false;
+            } else {
+              _specificationList[i].valueList[j].checked = true;
+            }
+          } else {
+            _specificationList[i].valueList[j].checked = false;
+          }
+        }
+      }
+    }
+    this.setData({
+      'specificationList': _specificationList
+    });
+    //重新计算spec改变后的信息
+    this.changeSpecInfo();
+
+    //重新计算哪些值不可以点击
+  },
+
+  //获取选中的规格信息
+  getCheckedSpecValue: function () {
+    let checkedValues = [];
+    let _specificationList = this.data.specificationList;
+    for (let i = 0; i < _specificationList.length; i++) {
+      let _checkedObj = {
+        nameId: _specificationList[i].specification_id,
+        valueId: 0,
+        valueText: ''
+      };
+      for (let j = 0; j < _specificationList[i].valueList.length; j++) {
+        if (_specificationList[i].valueList[j].checked) {
+          _checkedObj.valueId = _specificationList[i].valueList[j].id;
+          _checkedObj.valueText = _specificationList[i].valueList[j].value;
+        }
+      }
+      checkedValues.push(_checkedObj);
+    }
+
+    return checkedValues;
+
+  },
+  //根据已选的值,计算其它值的状态
+  setSpecValueStatus: function () {
+
+  },
+  //判断规格是否选择完整
+  isCheckedAllSpec: function () {
+    return !this.getCheckedSpecValue().some(function (v) {
+      if (v.valueId == 0) {
+        return true;
+      }
+    });
+  },
+  getCheckedSpecKey: function () {
+    let checkedValue = this.getCheckedSpecValue().map(function (v) {
+      return v.valueId;
+    });
+
+    return checkedValue.join('_');
+  },
+  changeSpecInfo: function () {
+    let checkedNameValue = this.getCheckedSpecValue();
+
+    //设置选择的信息
+    let checkedValue = checkedNameValue.filter(function (v) {
+      if (v.valueId != 0) {
+        return true;
+      } else {
+        return false;
+      }
+    }).map(function (v) {
+      return v.valueText;
+    });
+    if (checkedValue.length > 0) {
+      this.setData({
+        'checkedSpecText': checkedValue.join(' ')
+      });
+    } else {
+      this.setData({
+        'checkedSpecText': '请选择规格数量'
+      });
+    }
+
+  },
+  getCheckedProductItem: function (key) {
+    return this.data.productList.filter(function (v) {
+      if (v.goods_specification_ids == key) {
+        return true;
+      } else {
+        return false;
+      }
+    });
+  },
+  onLoad: function (options) {
+    // 页面初始化 options为页面跳转所带来的参数
+    this.setData({
+      id: parseInt(options.id)
+      // id: 1181000
+    });
+    var that = this;
+    this.getGoodsInfo();
+    util.request(api.CartGoodsCount).then(function (res) {
+      if (res.errno === 0) {
+        that.setData({
+          cartGoodsCount: res.data.cartTotal.goodsCount
+        });
+
+      }
+    });
+  },
+  onReady: function () {
+    // 页面渲染完成
+
+  },
+  onShow: function () {
+    // 页面显示
+
+  },
+  onHide: function () {
+    // 页面隐藏
+
+  },
+  onUnload: function () {
+    // 页面关闭
+
+  },
+  switchAttrPop: function () {
+    if (this.data.openAttr == false) {
+      this.setData({
+        openAttr: !this.data.openAttr
+      });
+    }
+  },
+  closeAttr: function () {
+    this.setData({
+      openAttr: false,
+    });
+  },
+  addCannelCollect: function () {
+    let that = this;
+    //添加或是取消收藏
+    util.request(api.CollectAddOrDelete, { typeId: 0, valueId: this.data.id }, "POST")
+      .then(function (res) {
+        let _res = res;
+        if (_res.errno == 0) {
+          if (_res.data.type == 'add') {
+            that.setData({
+              'collectBackImage': that.data.hasCollectImage
+            });
+          } else {
+            that.setData({
+              'collectBackImage': that.data.noCollectImage
+            });
+          }
+
+        } else {
+          wx.showToast({
+            image: '/static/images/icon_error.png',
+            title: _res.errmsg,
+            mask: true
+          });
+        }
+      });
+  },
+  openCartPage: function () {
+    wx.switchTab({
+      url: '/pages/cart/cart',
+    });
+  },
+  addToCart: function () {
+    var that = this;
+    if (this.data.openAttr === false) {
+      //打开规格选择窗口
+      this.setData({
+        openAttr: !this.data.openAttr
+      });
+    } else {
+
+      //提示选择完整规格
+      if (!this.isCheckedAllSpec()) {
+        wx.showToast({
+          image: '/static/images/icon_error.png',
+          title: '请选择规格',
+          mask: true
+        });
+        return false;
+      }
+
+      //根据选中的规格,判断是否有对应的sku信息
+      let checkedProduct = this.getCheckedProductItem(this.getCheckedSpecKey());
+      if (!checkedProduct || checkedProduct.length <= 0) {
+        //找不到对应的product信息,提示没有库存
+        wx.showToast({
+          image: '/static/images/icon_error.png',
+          title: '库存不足',
+          mask: true
+        });
+        return false;
+      }
+
+      //验证库存
+      if (checkedProduct.goods_number < this.data.number) {
+        //找不到对应的product信息,提示没有库存
+        wx.showToast({
+          image: '/static/images/icon_error.png',
+          title: '库存不足',
+          mask: true
+        });
+        return false;
+      }
+
+      //添加到购物车
+      util.request(api.CartAdd, { goodsId: this.data.goods.id, number: this.data.number, productId: checkedProduct[0].id }, "POST")
+        .then(function (res) {
+          let _res = res;
+          if (_res.errno == 0) {
+            wx.showToast({
+              title: '添加成功'
+            });
+            that.setData({
+              openAttr: !that.data.openAttr,
+              cartGoodsCount: _res.data.cartTotal.goodsCount
+            });
+          } else {
+            wx.showToast({
+              image: '/static/images/icon_error.png',
+              title: _res.errmsg,
+              mask: true
+            });
+          }
+
+        });
+    }
+
+  },
+  cutNumber: function () {
+    this.setData({
+      number: (this.data.number - 1 > 1) ? this.data.number - 1 : 1
+    });
+  },
+  addNumber: function () {
+    this.setData({
+      number: this.data.number + 1
+    });
+  }
+})

+ 1 - 0
mini-app/pages/goods/goods.json

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

+ 237 - 0
mini-app/pages/goods/goods.wxml

@@ -0,0 +1,237 @@
+<view class="container">
+  <swiper class="goodsimgs" indicator-dots="true" autoplay="true" interval="3000" duration="1000">
+    <swiper-item wx:for="{{gallery}}" wx:key="{{item.id}}">
+      <image src="{{item.img_url}}" background-size="cover"></image>
+    </swiper-item>
+  </swiper>
+  <view class="location-time">
+    <view class="icon time">最后编辑 : 2018-10-30 19:12</view>
+    <view class="icon location">地点 : 广东深圳</view>
+  </view>
+  <view class="goods-info">
+    <view class="c">
+      <text class="name">{{goods.name}}</text>
+      <text class="price">¥{{goods.price}}</text>
+      <text wx:if="{{goods.market_price}}" class="market-price">原价 : ¥{{goods.market_price}}</text>
+
+      <text class="desc">{{goods.goods_brief}}</text>
+      <!-- <view class="brand" wx:if="{{brand.name}}">
+        <navigator url="../brandDetail/brandDetail?id={{brand.brandId}}">
+          <text>{{brand.name}}</text>
+        </navigator>
+      </view> -->
+
+    </view>
+  </view>
+  <view class="section-nav section-act">
+    <view class="t">
+      <view class="tag">{{goods.want_count}}人想要</view>
+      <view class="tag">浏览 {{goods.browse_count}}</view>
+    </view>
+  </view>
+
+  <!-- <view class="section-nav section-act">
+    <view class="t">
+      <view class="label">1个促销:</view>
+      <view class="tag">万圣趴</view>
+      <view class="text">全场满499,额外送糖果</view>
+    </view>
+    <image class="i" src="../../static/images/address_right.png" background-size="cover"></image>
+  </view> -->
+
+  <!-- sellername -->
+  <!-- seller avater -->
+  <!-- day -->
+  <!-- history -->
+  <view class="seller-nav section-act">
+    <view class="seller-t">
+      <image class="seller-avatar" src="https://avatars2.githubusercontent.com/u/29662114?s=460&v=4"></image>
+    </view>
+
+    <view class="seller-info">
+      <view class="name">测试用户</view>
+      <view class="history">加入平台第100天,出售过5件宝贝</view>
+    </view>
+
+    <image class="i" src="../../static/images/address_right.png" background-size="cover"></image>
+  </view>
+
+
+
+  <!-- <view class="comments" wx:if="{{comment.count > 0}}">
+    <view class="h">
+      <navigator url="../comment/comment?valueId={{goods.id}}&typeId=0">
+        <text class="t">评价({{comment.count > 999 ? '999+' : comment.count}})</text>
+        <text class="i">查看全部</text>
+      </navigator>
+    </view>
+    <view class="b">
+      <view class="item">
+        <view class="info">
+          <view class="user">
+            <image src="{{comment.data.avatar}}"></image>
+            <text>{{comment.data.nickname}}</text>
+          </view>
+          <view class="time">{{comment.data.add_time}}</view>
+        </view>
+        <view class="content">
+          {{comment.data.content}}
+        </view>
+        <view class="imgs" wx:if="{{comment.data.pic_list.length > 0}}">
+          <image class="img" wx:for="{{comment.data.pic_list}}" wx:key="{{item.id}}" src="{{item.pic_url}}"></image>
+        </view>
+
+      </view>
+    </view>
+  </view> -->
+
+  <view class="comments">
+    <view class="h">
+        <text class="t">留言 (12)</text>
+    </view>
+    <view class="b">
+    <!-- comment -->
+      <view class="item">
+        <view class="info">
+          <view class="user">
+            <image src="https://avatars2.githubusercontent.com/u/29662114?s=460&v=4"></image>
+            <text>nickname</text>
+          </view>
+          <view class="time">2019-12-23 10:12</view>
+        </view>
+        <view class="content">
+          aaaaa
+        </view>
+        <!-- reply -->
+        <view class="reply-info">
+          <view class="reply-user">
+            <image src="https://avatars2.githubusercontent.com/u/29662114?s=460&v=4"></image>
+            <text>nickname</text>
+          </view>
+          <view class="time">2019-12-23 10:12</view>
+        </view>
+        <view class="reply-content">
+          回复@nickname:aaaaa
+        </view>
+        <!-- reoly-end -->
+      </view>
+      <!-- comment-end -->
+
+    </view>
+
+  </view>
+
+
+
+  <!-- <view class="goods-attr">
+    <view class="t">商品参数</view>
+    <view class="l">
+      <view class="item" wx:for="{{attribute}}" wx:key="{{item.name}}">
+        <text class="left">{{item.name}}</text>
+        <text class="right">{{item.value}}</text>
+      </view>
+    </view>
+  </view> -->
+
+  <!-- <view class="detail">
+    <import src="../../lib/wxParse/wxParse.wxml" />
+    <template is="wxParse" data="{{wxParseData:goodsDetail.nodes}}" />
+  </view> -->
+
+
+  <!-- <view class="common-problem">
+    <view class="h">
+      <view class="line"></view>
+      <text class="title">常见问题</text>
+    </view>
+    <view class="b">
+      <view class="item" wx:for="{{issueList}}" wx:key="{{item.id}}">
+        <view class="question-box">
+          <text class="spot"></text>
+          <text class="question">{{item.question}}</text>
+        </view>
+        <view class="answer">
+          {{item.answer}}
+        </view>
+      </view>
+       <view class="item">
+        <view class="question-box">
+          <text class="spot"></text>
+          <text class="question">1111</text>
+        </view>
+        <view class="answer">
+          bbbbb
+        </view>
+      </view>
+    </view>
+  </view> -->
+
+  <view class="related-goods" wx:if="{{relatedGoods.length > 0}}">
+    <view class="h">
+      <view class="line"></view>
+      <text class="title">大家都在看</text>
+    </view>
+    <view class="b">
+      <view class="item" wx:for="{{relatedGoods}}" wx:key="{{item.id}}">
+        <navigator url="/pages/goods/goods?id={{item.id}}">
+          <image class="img" src="{{item.list_pic_url}}" background-size="cover"></image>
+          <text class="name">{{item.name}}</text>
+          <text class="price">¥{{item.price}}</text>
+        </navigator>
+      </view>
+    </view>
+  </view>
+</view>
+
+<!-- <view class="attr-pop-box" hidden="{{!openAttr}}">
+  <view class="attr-pop">
+    <view class="close" bindtap="closeAttr">
+      <image class="icon" src="/static/images/icon_close.png"></image>
+    </view>
+    <view class="img-info">
+      <image class="img" src="{{gallery[0].img_url}}"></image>
+      <view class="info">
+        <view class="c">
+          <view class="p">价格:¥{{goods.price}}</view>
+          <view class="a" wx:if="{{productList.length>0}}">已选择:{{checkedSpecText}}</view>
+        </view>
+      </view>
+    </view>
+    <view class="spec-con">
+      <view class="spec-item" wx:for="{{specificationList}}" wx:key="{{item.specification_id}}">
+        <view class="name">{{item.name}}</view>
+        <view class="values">
+          <view class="value {{vitem.checked ? 'selected' : ''}}" bindtap="clickSkuValue" wx:for="{{item.valueList}}" wx:for-item="vitem" wx:key="{{vitem.id}}" data-value-id="{{vitem.id}}" data-name-id="{{vitem.specification_id}}">{{vitem.value}}</view>
+        </view>
+      </view>
+
+      <view class="number-item">
+        <view class="name">数量</view>
+        <view class="selnum">
+          <view class="cut" bindtap="cutNumber">-</view>
+          <input value="{{number}}" class="number" disabled="true" type="number" />
+          <view class="add" bindtap="addNumber">+</view>
+        </view>
+      </view>
+    </view>
+  </view>
+</view> -->
+
+<view class="bottom-btn">
+  <view class="l" bindtap="addCannelCollect">
+    <image class="icon" src="{{ collectBackImage }}"></image>
+    收藏
+  </view>
+  <view class="l" bindtap="addCannelCollect">
+    <image class="icon" src="/static/images/ic_menu_chat_nor.png"></image>
+    留言
+  </view>
+  <!-- <view class="l l-cart">
+    <view class="box">
+      <text class="cart-count">{{cartGoodsCount}}</text>
+      <image bindtap="openCartPage" class="icon" src="/static/images/ic_menu_shoping_nor.png"></image>
+    </view>
+  </view> -->
+  <!-- <view class="c">立即购买</view> -->
+  <view class="r" bindtap="addToCart">想要</view>
+</view>

+ 875 - 0
mini-app/pages/goods/goods.wxss

@@ -0,0 +1,875 @@
+.container {
+  margin-bottom: 100rpx;
+}
+
+.goodsimgs {
+  width: 750rpx;
+  height: 750rpx;
+}
+
+.goodsimgs image {
+  width: 750rpx;
+  height: 750rpx;
+}
+
+.service-policy {
+  /* width: 750rpx; */
+  height: 73rpx;
+  background: #f4f4f4;
+  padding: 0 31.25rpx;
+  display: flex;
+  flex-flow: row nowrap;
+  align-items: center;
+  justify-content: space-between;
+}
+
+.service-policy .item {
+  background: url(http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/servicePolicyRed-518d32d74b.png) 0 center no-repeat;
+  background-size: 10rpx;
+  padding-left: 15rpx;
+  display: flex;
+  align-items: center;
+  font-size: 25rpx;
+  color: #666;
+}
+
+.goods-info {
+  width: 750rpx;
+  /* height: 306rpx; */
+  overflow: hidden;
+  background: #fff;
+}
+
+.goods-info .c {
+  display: block;
+  width: 718.75rpx;
+  height: 100%;
+  margin-left: 31.25rpx;
+  padding: 38rpx 31.25rpx 38rpx 0;
+  border-bottom: 1px solid #f4f4f4;
+}
+
+.goods-info .c text {
+  display: block;
+  width: 687.5rpx;
+}
+
+.goods-info .name {
+  /* height: 41rpx; */
+  margin-bottom: 5.208rpx;
+  font-size: 41rpx;
+  text-align: center;
+  /* line-height: 41rpx; */
+}
+
+.goods-info .desc {
+  /* height: 43rpx; */
+  margin-bottom: 41rpx;
+  font-size: 24rpx;
+  line-height: 36rpx;
+  color: #999;
+}
+
+.goods-info .price {
+  /* height: 35rpx; */
+  font-size: 40rpx;
+  line-height: 35rpx;
+  color: #f94b4b;
+  margin-top: 30rpx;
+  margin-bottom: 30rpx;
+  text-align: center;
+}
+
+.goods-info .market-price {
+  font-size: 29rpx;
+  line-height: 35rpx;
+  color: #555;
+  margin-top: 30rpx;
+  margin-bottom: 30rpx;
+  text-decoration: line-through;
+  text-align: center;
+}
+
+.goods-info .brand {
+  margin-top: 23rpx;
+  min-height: 40rpx;
+  text-align: center;
+}
+
+.goods-info .brand text {
+  display: inline-block;
+  width: auto;
+  padding: 2px 30rpx 2px 10.5rpx;
+  line-height: 35.5rpx;
+  border: 1px solid #f48f18;
+  font-size: 25rpx;
+  color: #f48f18;
+  border-radius: 4px;
+  background: url(http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/detailTagArrow-18bee52dab.png) 95% center no-repeat;
+  background-size: 10.75rpx 18.75rpx;
+}
+
+.section-nav {
+  width: 750rpx;
+  height: 108rpx;
+  background: #fff;
+  margin-bottom: 20rpx;
+}
+
+.section-nav .t {
+  float: left;
+  width: 600rpx;
+  height: 108rpx;
+  line-height: 108rpx;
+  font-size: 29rpx;
+  color: #333;
+  margin-left: 31.25rpx;
+}
+
+.section-nav .i {
+  float: right;
+  width: 52rpx;
+  height: 52rpx;
+  margin-right: 16rpx;
+  margin-top: 28rpx;
+}
+
+.section-act .t {
+  float: left;
+  display: flex;
+  align-items: center;
+  width: 600rpx;
+  height: 108rpx;
+  overflow: hidden;
+  line-height: 108rpx;
+  font-size: 29rpx;
+  color: #999;
+  margin-left: 31.25rpx;
+}
+
+.section-act .label {
+  color: #999;
+}
+
+.section-act .tag {
+  display: flex;
+  align-items: center;
+  padding: 0 10rpx;
+  border-radius: 3px;
+  height: 37rpx;
+  width: auto;
+  color: #f48f18;
+  overflow: hidden;
+  border: 1px solid #f48f18;
+  font-size: 25rpx;
+  margin: 0 10rpx;
+}
+
+.section-act .text {
+  display: flex;
+  align-items: center;
+  height: 37rpx;
+  width: auto;
+  overflow: hidden;
+  color: #f48f18;
+  font-size: 29rpx;
+}
+
+.comments {
+  width: 100%;
+  height: auto;
+  padding-left: 30rpx;
+  background: #fff;
+  margin: 20rpx 0;
+}
+
+.comments .h {
+  height: 102.5rpx;
+  line-height: 100.5rpx;
+  width: 718.75rpx;
+  padding-right: 16rpx;
+}
+
+.comments .h .t {
+  display: block;
+  float: left;
+  width: 50%;
+  font-size: 38.5rpx;
+  color: #333;
+}
+
+.comments .h .i {
+  display: block;
+  float: right;
+  width: 164rpx;
+  height: 100.5rpx;
+  line-height: 100.5rpx;
+  background: url(http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/address-right-990628faa7.png) right center no-repeat;
+  background-size: 52rpx;
+}
+
+.comments .b {
+  height: auto;
+  width: 720rpx;
+}
+
+.comments .item {
+  height: auto;
+  width: 720rpx;
+  overflow: hidden;
+  border-top: 1px solid #d9d9d9;
+}
+
+.comments .info {
+  width: 100%;
+  padding: 33rpx 0 0 0;
+}
+
+.comments .reply-info {
+  width: 100%;
+}
+
+.comments .user {
+  float: left;
+  width: auto;
+  height: 67rpx;
+  line-height: 67rpx;
+  font-size: 0;
+}
+
+.comments .reply-user {
+  float: left;
+  width: auto;
+  height: 67rpx;
+  line-height: 67rpx;
+  font-size: 0;
+  margin-left: 50rpx;
+}
+
+.comments .reply-user  image {
+  float: left;
+  width: 50rpx;
+  height: 50rpx;
+  margin-right: 17rpx;
+  margin-top: 5rpx;
+  border-radius: 50%;
+}
+.comments .reply-user text {
+  display:inline-block;
+width:auto;
+height:66rpx;
+overflow:hidden;
+font-size:29rpx;
+line-height:66rpx;
+font-weight:bold;
+}
+
+.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;
+  font-weight: bold;
+}
+
+.comments .time {
+  display: block;
+  float: right;
+  width: auto;
+  height: 67rpx;
+  line-height: 67rpx;
+  color: #7f7f7f;
+  font-size: 25rpx;
+  margin-right: 30rpx;
+}
+
+.comments .content {
+  width: 720rpx;
+  padding-right: 30rpx;
+  line-height: 45.8rpx;
+  font-size: 29rpx;
+  margin-bottom: 24rpx;
+  margin-left: 80rpx;
+}
+
+.comments .reply-content {
+  width: 720rpx;
+  padding-right: 30rpx;
+  line-height: 45.8rpx;
+  font-size: 29rpx;
+  margin-bottom: 24rpx;
+  margin-left: 115rpx;
+}
+
+.comments .imgs {
+  width: 720rpx;
+  height: auto;
+  margin-bottom: 25rpx;
+}
+
+.comments .imgs .img {
+  height: 150rpx;
+  width: 150rpx;
+  margin-right: 28rpx;
+}
+
+.comments .spec {
+  width: 720rpx;
+  padding-right: 30rpx;
+  line-height: 30rpx;
+  font-size: 24rpx;
+  color: #999;
+  margin-bottom: 30rpx;
+}
+
+.goods-attr {
+  width: 750rpx;
+  height: auto;
+  overflow: hidden;
+  padding: 0 31.25rpx 25rpx 31.25rpx;
+  background: #fff;
+}
+
+.goods-attr .t {
+  width: 687.5rpx;
+  height: 104rpx;
+  line-height: 104rpx;
+  font-size: 38.5rpx;
+}
+
+.goods-attr .item {
+  width: 687.5rpx;
+  height: 68rpx;
+  padding: 11rpx 20rpx;
+  margin-bottom: 11rpx;
+  background: #f7f7f7;
+  font-size: 38.5rpx;
+}
+
+.goods-attr .left {
+  float: left;
+  font-size: 25rpx;
+  width: 134rpx;
+  height: 45rpx;
+  line-height: 45rpx;
+  overflow: hidden;
+  color: #999;
+}
+
+.goods-attr .right {
+  float: left;
+  font-size: 36.5rpx;
+  margin-left: 20rpx;
+  width: 480rpx;
+  height: 45rpx;
+  line-height: 45rpx;
+  overflow: hidden;
+  color: #333;
+}
+
+.detail {
+  width: 750rpx;
+  height: auto;
+  overflow: hidden;
+}
+
+.detail image {
+  width: 750rpx;
+  display: block;
+}
+
+.common-problem {
+  width: 750rpx;
+  height: auto;
+  overflow: hidden;
+}
+
+.common-problem .h {
+  position: relative;
+  height: 145.5rpx;
+  width: 750rpx;
+  padding: 56.25rpx 0;
+  background: #fff;
+  text-align: center;
+}
+
+.common-problem .h .line {
+  display: inline-block;
+  position: absolute;
+  top: 72rpx;
+  left: 0;
+  z-index: 2;
+  height: 1px;
+  margin-left: 225rpx;
+  width: 300rpx;
+  background: #ccc;
+}
+
+.common-problem .h .title {
+  display: inline-block;
+  position: absolute;
+  top: 56.125rpx;
+  left: 0;
+  z-index: 3;
+  height: 33rpx;
+  margin-left: 285rpx;
+  width: 180rpx;
+  background: #fff;
+}
+
+.common-problem .b {
+  width: 750rpx;
+  height: auto;
+  overflow: hidden;
+  padding: 0rpx 30rpx;
+  background: #fff;
+}
+
+.common-problem .item {
+  height: auto;
+  overflow: hidden;
+  padding-bottom: 25rpx;
+}
+
+.common-problem .question-box .spot {
+  float: left;
+  display: block;
+  height: 8rpx;
+  width: 8rpx;
+  background: #b4282d;
+  border-radius: 50%;
+  margin-top: 11rpx;
+}
+
+.common-problem .question-box .question {
+  float: left;
+  line-height: 30rpx;
+  padding-left: 8rpx;
+  display: block;
+  font-size: 26rpx;
+  padding-bottom: 15rpx;
+  color: #303030;
+}
+
+.common-problem .answer {
+  line-height: 36rpx;
+  padding-left: 16rpx;
+  font-size: 26rpx;
+  color: #787878;
+}
+
+.related-goods {
+  width: 750rpx;
+  height: auto;
+  overflow: hidden;
+}
+
+.related-goods .h {
+  position: relative;
+  height: 145.5rpx;
+  width: 750rpx;
+  padding: 56.25rpx 0;
+  background: #fff;
+  text-align: center;
+  border-bottom: 1px solid #f4f4f4;
+}
+
+.related-goods .h .line {
+  display: inline-block;
+  position: absolute;
+  top: 72rpx;
+  left: 0;
+  z-index: 2;
+  height: 1px;
+  margin-left: 225rpx;
+  width: 300rpx;
+  background: #ccc;
+}
+
+.related-goods .h .title {
+  display: inline-block;
+  position: absolute;
+  top: 56.125rpx;
+  left: 0;
+  z-index: 3;
+  height: 33rpx;
+  margin-left: 285rpx;
+  width: 180rpx;
+  background: #fff;
+}
+
+.related-goods .b {
+  width: 750rpx;
+  height: auto;
+  overflow: hidden;
+}
+
+.related-goods .b .item {
+  float: left;
+  background: #fff;
+  width: 375rpx;
+  height: auto;
+  overflow: hidden;
+  text-align: center;
+  padding: 15rpx 31.25rpx;
+  border-right: 1px solid #f4f4f4;
+  border-bottom: 1px solid #f4f4f4;
+}
+
+.related-goods .item .img {
+  width: 311.45rpx;
+  height: 311.45rpx;
+}
+
+.related-goods .item .name {
+  display: block;
+  width: 311.45rpx;
+  height: 35rpx;
+  margin: 11.5rpx 0 15rpx 0;
+  text-align: center;
+  overflow: hidden;
+  font-size: 30rpx;
+  color: #333;
+}
+
+.related-goods .item .price {
+  display: block;
+  width: 311.45rpx;
+  height: 30rpx;
+  text-align: center;
+  font-size: 30rpx;
+  color: #f94b4b;
+}
+
+.bottom-btn {
+  position: fixed;
+  left: 0;
+  bottom: 0;
+  z-index: 10;
+  width: 750rpx;
+  height: 100rpx;
+  display: flex;
+  background: #fff;
+}
+
+.bottom-btn .l {
+  float: left;
+  height: 100rpx;
+  width: 200rpx;
+  border: 1px solid #f4f4f4;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+
+.bottom-btn .l.l-collect {
+  border-right: none;
+  border-left: none;
+  text-align: center;
+}
+
+.bottom-btn .l.l-cart .box {
+  position: relative;
+  height: 60rpx;
+  width: 60rpx;
+}
+
+.bottom-btn .l.l-cart .cart-count {
+  height: 28rpx;
+  width: 28rpx;
+  z-index: 10;
+  position: absolute;
+  top: 0;
+  right: 0;
+  background: #b4282d;
+  text-align: center;
+  font-size: 18rpx;
+  color: #fff;
+  line-height: 28rpx;
+  border-radius: 50%;
+}
+
+.bottom-btn .l.l-cart .icon {
+  position: absolute;
+  top: 10rpx;
+  left: 0;
+}
+
+.bottom-btn .l .icon {
+  display: block;
+  height: 44rpx;
+  width: 44rpx;
+  margin-right: 10rpx;
+}
+
+.bottom-btn .c {
+  float: left;
+  height: 100rpx;
+  line-height: 96rpx;
+  flex: 1;
+  text-align: center;
+  color: #333;
+  border-top: 1px solid #f4f4f4;
+  border-bottom: 1px solid #f4f4f4;
+}
+
+.bottom-btn .r {
+  border: 1px solid #f94b4b;
+  background: #f94b4b;
+  float: left;
+  height: 100rpx;
+  line-height: 96rpx;
+  flex: 1;
+  text-align: center;
+  color: #fff;
+}
+@import "../../lib/wxParse/wxParse.wxss";
+
+.attr-pop-box {
+  width: 100%;
+  height: 100%;
+  position: fixed;
+  background: rgba(0, 0, 0, 0.5);
+  z-index: 8;
+  bottom: 0;
+  /* display: none; */
+}
+
+.attr-pop {
+  width: 100%;
+  height: auto;
+  max-height: 780rpx;
+  padding: 31.25rpx;
+  background: #fff;
+  position: fixed;
+  z-index: 9;
+  bottom: 100rpx;
+}
+
+.attr-pop .close {
+  position: absolute;
+  width: 48rpx;
+  height: 48rpx;
+  right: 31.25rpx;
+  overflow: hidden;
+  top: 31.25rpx;
+}
+
+.attr-pop .close .icon {
+  width: 48rpx;
+  height: 48rpx;
+}
+
+.attr-pop .img-info {
+  width: 687.5rpx;
+  height: 177rpx;
+  overflow: hidden;
+  margin-bottom: 41.5rpx;
+}
+
+.attr-pop .img {
+  float: left;
+  height: 177rpx;
+  width: 177rpx;
+  background: #f4f4f4;
+  margin-right: 31.25rpx;
+}
+
+.attr-pop .info {
+  float: left;
+  height: 177rpx;
+  display: flex;
+  align-items: center;
+}
+
+.attr-pop .p {
+  font-size: 33rpx;
+  color: #333;
+  height: 33rpx;
+  line-height: 33rpx;
+  margin-bottom: 10rpx;
+}
+
+.attr-pop .a {
+  font-size: 29rpx;
+  color: #333;
+  height: 40rpx;
+  line-height: 40rpx;
+}
+
+.spec-con {
+  width: 100%;
+  height: auto;
+  overflow: hidden;
+}
+
+.spec-con .name {
+  height: 32rpx;
+  margin-bottom: 22rpx;
+  font-size: 29rpx;
+  color: #333;
+}
+
+.spec-con .values {
+  height: auto;
+  margin-bottom: 31.25rpx;
+  font-size: 0;
+}
+
+.spec-con .value {
+  display: inline-block;
+  height: 62rpx;
+  padding: 0 35rpx;
+  line-height: 56rpx;
+  text-align: center;
+  margin-right: 25rpx;
+  margin-bottom: 16.5rpx;
+  border: 1px solid #333;
+  font-size: 25rpx;
+  color: #333;
+}
+
+.spec-con .value.disable {
+  border: 1px solid #ccc;
+  color: #ccc;
+}
+
+.spec-con .value.selected {
+  border: 1px solid #b4282d;
+  color: #b4282d;
+}
+
+.number-item .selnum {
+  width: 322rpx;
+  height: 71rpx;
+  border: 1px solid #ccc;
+  display: flex;
+}
+
+.number-item .cut {
+  width: 93.75rpx;
+  height: 100%;
+  text-align: center;
+  line-height: 65rpx;
+}
+
+.number-item .number {
+  flex: 1;
+  height: 100%;
+  text-align: center;
+  line-height: 68.75rpx;
+  border-left: 1px solid #ccc;
+  border-right: 1px solid #ccc;
+  float: left;
+}
+
+.number-item .add {
+  width: 93.75rpx;
+  height: 100%;
+  text-align: center;
+  line-height: 65rpx;
+}
+
+.location-time .icon {
+  padding-left: 35rpx;
+  display: flex;
+  align-items: center;
+  font-size: 25rpx;
+  color: #666;
+}
+
+.location-time .icon.location {
+  background: url(https://i.postimg.cc/Hkf6dJzv/placeholder-2.png) 0 center no-repeat;
+  background-size: 25rpx;
+}
+
+.location-time .icon.time {
+  background: url(https://i.postimg.cc/nrck0qVr/clock.png) 0 center no-repeat;
+  background-size: 25rpx;
+}
+
+.location-time {
+  /* width: 750rpx; */
+  height: 73rpx;
+  background: #f4f4f4;
+  padding: 0 30rpx;
+  display: flex;
+  flex-flow: row nowrap;
+  align-items: center;
+  justify-content: space-between;
+}
+
+.seller-avatar {
+  float: right;
+  width: 120rpx;
+  height: 120rpx;
+  margin: 0 16rpx 0 8rpx;
+  border-radius: 50%;
+}
+
+.section-act .seller-t {
+  float: left;
+  display: flex;
+  align-items: center;
+  /* width: 600rpx; */
+  height: 188rpx;
+  overflow: hidden;
+  line-height: 108rpx;
+  font-size: 29rpx;
+  color: #999;
+  margin-left: 31.25rpx;
+}
+
+.section-act .seller-info {
+  float: left;
+  align-items: center;
+  /* width: 600rpx; */
+  height: 188rpx;
+  overflow: hidden;
+  line-height: 108rpx;
+  font-size: 29rpx;
+  color: #999;
+  margin-left: 31.25rpx;
+}
+
+.seller-nav {
+  width: 750rpx;
+  height: 188rpx;
+  background: #fff;
+  margin-bottom: 20rpx;
+}
+
+.seller-nav .i {
+  float: right;
+  width: 60rpx;
+  height: 60rpx;
+  margin-right: 30rpx;
+  margin-top: 65rpx;
+}
+
+.seller-nav.seller-info {
+  width: 300rpx;
+  height: 188rpx;
+}
+
+.seller-nav .name {
+  margin-top: 50rpx;
+  font-size: 35rpx;
+  height: 60rpx;
+  line-height: 50rpx;
+}
+
+.seller-nav .history {
+  line-height: 30rpx;
+  font-size: 27rpx;
+}

+ 105 - 0
mini-app/pages/hotGoods/hotGoods.js

@@ -0,0 +1,105 @@
+var util = require('../../utils/util.js');
+var api = require('../../config/api.js');
+var app = getApp();
+
+Page({
+  data: {
+    bannerInfo: {
+      'img_url': '',
+      'name': ''
+    },
+    categoryFilter: false,
+    filterCategory: [],
+    goodsList: [],
+    categoryId: 0,
+    currentSortType: 'default',
+    currentSortOrder: 'desc',
+    page: 1,
+    size: 1000
+  },
+  getData: function () {
+    let that = this;
+    util.request(api.GoodsHot).then(function (res) {
+      if (res.errno === 0) {
+        that.setData({
+          bannerInfo: res.data.bannerInfo,
+        });
+        that.getGoodsList();
+      }
+    });
+  },
+  getGoodsList (){
+    var that = this;
+
+    util.request(api.GoodsList, { isHot: 1, page: that.data.page, size: that.data.size, order: that.data.currentSortOrder, sort: that.data.currentSortType, categoryId: that.data.categoryId})
+      .then(function (res) {
+        if (res.errno === 0) {
+          that.setData({
+            goodsList: res.data.goodsList,
+            filterCategory: res.data.filterCategory
+          });
+        }
+      });
+  },
+  onLoad: function (options) {
+    // 页面初始化 options为页面跳转所带来的参数
+    this.getData();
+  },
+  onReady: function () {
+    // 页面渲染完成
+  },
+  onShow: function () {
+    // 页面显示
+
+  },
+  onHide: function () {
+    // 页面隐藏
+
+  },
+  onUnload: function () {
+    // 页面关闭
+
+  },
+  openSortFilter: function (event) {
+    let currentId = event.currentTarget.id;
+    switch (currentId) {
+      case 'categoryFilter':
+        this.setData({
+          'categoryFilter': !this.data.categoryFilter,
+          'currentSortType': 'category',
+          'currentSortOrder': 'asc'
+        });
+        break;
+      case 'priceSort':
+        let tmpSortOrder = 'asc';
+        if (this.data.currentSortOrder == 'asc') {
+          tmpSortOrder = 'desc';
+        }
+        this.setData({
+          'currentSortType': 'price',
+          'currentSortOrder': tmpSortOrder,
+          'categoryFilter': false
+        });
+
+        this.getData();
+        break;
+      default:
+        //综合排序
+        this.setData({
+          'currentSortType': 'default',
+          'currentSortOrder': 'desc',
+          'categoryFilter': false
+        });
+        this.getData();
+    }
+  },
+  selectCategory: function(event){
+    let currentIndex = event.target.dataset.categoryIndex;
+    this.setData({
+      'categoryFilter': false,
+      'categoryId': this.data.filterCategory[currentIndex].id
+    });
+    this.getData();
+
+  }
+})

+ 3 - 0
mini-app/pages/hotGoods/hotGoods.json

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

+ 40 - 0
mini-app/pages/hotGoods/hotGoods.wxml

@@ -0,0 +1,40 @@
+<view class="container">
+  <view class="brand-info">
+    <view class="name">
+      <image class="img" src="{{bannerInfo.img_url}}" background-size="cover"></image>
+      <view class="info-box">
+        <view class="info">
+          <text class="txt">{{bannerInfo.name}}</text>
+          <text class="line"></text>
+        </view>
+      </view>
+    </view>
+  </view>
+  <view class="sort">
+    <view class="sort-box">
+      <view class="item {{currentSortType == 'default' ? 'active' : ''}}"  bindtap="openSortFilter" id="defaultSort">
+        <text class="txt">综合</text>
+      </view>
+      <view class="item by-price {{currentSortType == 'price' ? 'active' : ''}} {{currentSortOrder == 'asc'  ? 'asc' : 'desc'}}" bindtap="openSortFilter" id="priceSort">
+        <text class="txt">价格</text>
+      </view>
+      <view class="item {{currentSortType == 'category' ? 'active' : ''}}" bindtap="openSortFilter" id="categoryFilter">
+        <text class="txt">分类</text>
+      </view>
+    </view>
+    <view class="sort-box-category" wx-if="{{categoryFilter}}">
+      <view class="item {{item.checked ? 'active' : ''}}" wx:for="{{filterCategory}}" wx:key="cate-{{item.id}}" data-category-index="{{index}}" bindtap="selectCategory">{{item.name}}</view>
+    </view>
+  </view>
+  <view class="cate-item">
+    <view class="b">
+      <block wx:for="{{goodsList}}" wx:for-index="iindex" wx:for-item="iitem" wx:key="unique">
+        <navigator class="item {{iindex % 2 == 0 ? 'item-b' : '' }}" url="../goods/goods?id={{iitem.id}}">
+          <image class="img" src="{{iitem.list_pic_url}}" background-size="cover"></image>
+          <text class="name">{{iitem.name}}</text>
+          <text class="price">¥{{iitem.retail_price}}</text>
+        </navigator>
+      </block>
+    </view>
+  </view>
+</view>

+ 177 - 0
mini-app/pages/hotGoods/hotGoods.wxss

@@ -0,0 +1,177 @@
+page{
+    background: #f4f4f4;
+}
+
+.brand-info .name{
+    width: 100%;
+    height: 278rpx;
+    position: relative;
+}
+
+.brand-info .img{
+    position: absolute;
+    top:0;
+    left:0;
+    width: 100%;
+    height: 278rpx;
+}
+
+.brand-info .info-box{
+    position: absolute;
+    top:0;
+    left:0;
+    width: 100%;
+    height: 278rpx;
+    text-align: center;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+}
+
+.brand-info .info{
+    display: block;
+}
+
+.brand-info .txt{
+    display: block;
+    height: 40rpx;
+    font-size: 37.5rpx;
+    color: #fff;
+}
+
+.brand-info .line{
+    margin: 0 auto;
+    margin-top: 16rpx;
+    display: block;
+    height: 2rpx;
+    width: 145rpx;
+    background: #fff;
+}
+
+.sort{
+    position: relative;
+    background: #fff;
+    width: 100%;
+    height: 78rpx;
+}
+
+.sort-box{
+    background: #fff;
+    width: 100%;
+    height: 78rpx;
+    overflow: hidden;
+    padding: 0 30rpx;
+    display: flex;
+    border-bottom: 1px solid #d9d9d9;
+}
+
+.sort-box .item{
+    height: 78rpx;
+    line-height: 78rpx;
+    text-align: center;
+    flex:1;
+    color: #333;
+    font-size: 30rpx;
+}
+
+.sort-box .item .txt{
+    display: block;
+    width: 100%;
+    height: 100%;
+    color: #333;
+}
+
+.sort-box .item.active .txt{
+    color: #b4282d;
+}
+
+.sort-box .item.by-price{
+    background: url(//yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/no-3127092a69.png) 155rpx center no-repeat;
+    background-size: 15rpx 21rpx;
+}
+
+.sort-box .item.by-price.active.asc{
+    background: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/up-636b92c0a5.png) 155rpx center no-repeat;
+    background-size: 15rpx 21rpx;
+}
+
+.sort-box .item.by-price.active.desc{
+    background: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/down-95e035f3e5.png) 155rpx center no-repeat;
+    background-size: 15rpx 21rpx;
+}
+
+.sort-box-category{
+    background: #fff;
+    width: 100%;
+    height: auto;
+    overflow: hidden;
+    padding: 40rpx 40rpx 0 0;
+    border-bottom: 1px solid #d9d9d9;
+}
+
+.sort-box-category .item{
+    height: 54rpx;
+    line-height: 54rpx;
+    text-align: center;
+    float: left;
+    padding: 0 16rpx;
+    margin: 0 0 40rpx 40rpx;
+    border: 1px solid #666;
+    color: #333;
+    font-size: 24rpx;
+}
+
+.sort-box-category .item.active{
+    color: #b4282d;
+    border: 1px solid #b4282d;
+}
+
+.cate-item .b{
+  width: 750rpx;
+  height: auto;
+  overflow: hidden;
+  border-top: 1rpx solid #f4f4f4;
+  margin-top: 20rpx;
+}
+
+.cate-item .b .item{
+  float: left;
+  background: #fff;
+  width: 375rpx;
+  padding-bottom: 33.333rpx;
+  border-bottom: 1rpx solid #f4f4f4;
+  height: auto;
+  overflow: hidden;
+  text-align: center;
+}
+
+.cate-item .b .item-b{
+ border-right: 1rpx solid #f4f4f4;
+}
+
+.cate-item .item .img{
+    margin-top: 10rpx;
+  width: 302rpx;
+  height: 302rpx;
+}
+
+.cate-item .item .name{
+  display: block;
+  width: 365.625rpx;
+  height: 35rpx;
+  padding: 0 20rpx;
+  overflow: hidden;
+  margin: 11.5rpx 0 22rpx 0;
+  text-align: center;
+  font-size: 30rpx;
+  color: #333;
+}
+
+.cate-item .item .price{
+  display: block;
+  width: 365.625rpx;
+  height: 30rpx;
+  text-align: center;
+  font-size: 30rpx;
+  color: #b4282d;
+}

+ 54 - 84
mini-app/pages/index/index.js

@@ -1,93 +1,63 @@
-//index.js
+const util = require('../../utils/util.js');
+const api = require('../../config/api.js');
+const user = require('../../services/user.js');
+
 //获取应用实例
 const app = getApp()
 Page({
   data: {
-    motto: 'Hello World',
-    userInfo: {},
-    hasUserInfo: false,
-    canIUse: wx.canIUse('button.open-type.getUserInfo')//组件是否可用
+    banner: [],
+    channel: [],
+    indexGoods: []
+    // newGoods: [],
+    // hotGoods: [],
+    // topics: [],
+    // brands: [],
+    // floorGoods: [],
+    // banner: [],
+    // channel: []
   },
-  //事件处理函数
-  bindViewTap: function() {
-    wx.navigateTo({
-      url: '../logs/logs'
-    })
+  onShareAppMessage: function () {
+    return {
+      title: 'NideShop',
+      desc: '仿网易严选微信小程序商城',
+      path: '/pages/index/index'
+    }
   },
-  onLoad: function () {
-    if (app.globalData.userInfo) {
-      this.setData({
-        userInfo: app.globalData.userInfo,
-        hasUserInfo: true
-      })
-    } else if (this.data.canIUse){
-      // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
-      // 所以此处加入 callback 以防止这种情况
-      app.userInfoReadyCallback = res => {
-        console.log("page.userInfoReadyCallback" + res.iv)
-        this.setData({
-          userInfo: res.userInfo,
-          hasUserInfo: true
-        })
+
+  getIndexData: function () {
+    let that = this;
+    util.request(api.IndexUrl).then(function (res) {
+      console.log(res.data)
+      // console.log(res.data.hotGoodsList)
+      // console.log(res.data.categoryList)
+      if (res.errno === 0) {
+        that.setData({
+          // newGoods: res.data.newGoodsList,
+          // hotGoods: res.data.hotGoodsList,
+          // topics: res.data.topicList,
+          // brand: res.data.brandList,
+          // floorGoods: res.data.categoryList,
+          indexGoods: res.data.indexGoodsList,
+          banner: res.data.banner,
+          channel: res.data.channel
+        });
       }
-    } else {
-      // 在没有 open-type=getUserInfo 版本的兼容处理
-      wx.getUserInfo({
-        success: res => {
-          app.globalData.userInfo = res.userInfo
-          this.setData({
-            userInfo: res.userInfo,
-            hasUserInfo: true
-          })
-        }
-      })
-    }
+    });
   },
-  bindGetUserInfo: function(e) {
-    console.log("page.bindGetUserInfo" + e.detail.iv)
-    console.log(e)
-    app.globalData.userInfo = e.detail.userInfo
-    this.setData({
-      userInfo: e.detail.userInfo,
-      hasUserInfo: true
-    })
+  onLoad: function (options) {
+    this.getIndexData();
   },
-  login: function() {
-    // 获取userInfo
-    wx.getUserInfo({
-        success: res => {
-            app.globalData.rawData = res.rawData
-            app.globalData.signature = res.signature
-          console.log(app.globalData.rawData)
-          console.log(app.globalData.signature)
-        }
-      }),
-      wx.login({
-        success(res) {
-          if (res.code) {
-
-            //发起网络请求
-            wx.request({
-              url: app.globalData.host + "/register",
-              data: {
-                jsCode: res.code,
-                rawData: app.globalData.rawData,
-                signature: app.globalData.signature
-              },
-              header: {
-                'content-type': 'application/json' // 默认值
-              },
-              dataType: "json",
-              method: "POST",
-              success(res) {
-                console.log(res.data)
-              }
-            })
-          } else {
-            console.log('登录失败!' + res.errMsg)
-          }
-        }
-      })
-  }
-
-})
+  onReady: function () {
+    // 页面渲染完成
+  },
+  onShow: function () {
+    // 页面显示
+  },
+  onHide: function () {
+    // 页面隐藏
+  },
+  onUnload: function () {
+    // 页面关闭
+  },
+})

+ 135 - 11
mini-app/pages/index/index.wxml

@@ -1,15 +1,139 @@
+
 <!--index.wxml-->
 <view class="container">
-  <view class="userinfo">
-  <!-- 点了之后就会调用wx.getUserInfo, 随后调用bindGetUserInfo -->
-    <button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo"> 点击登录 </button>
-    <!-- <button wx:if="{{true}}" bindtap='login'> 点击登录 </button> -->
-    <block wx:else>
-      <image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
-      <text class="userinfo-nickname">{{userInfo.nickName}}</text>
-    </block>
+  <swiper class="banner" indicator-dots="true" autoplay="true" interval="3000" duration="1000">
+    <swiper-item wx:for="{{banner}}" wx:key="{{item.id}}">
+      <navigator url="{{item.link}}">
+        <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}}">
+      <image src="{{item.icon_url}}" background-size="cover"></image>
+      <text>{{item.name}}</text>
+    </navigator>
   </view>
-  <view class="usermotto">
-    <text class="user-motto">{{motto}}</text>
+
+
+  <!-- 新商品 -->
+  <view class="a-section a-new" wx:if="{{indexGoods.length > 0}}">
+    <view class="h">
+      <view>
+        <navigator url="../newGoods/newGoods">
+          <text class="txt">为你推荐</text>
+        </navigator>
+      </view>
+    </view>
+    <view class="b">
+      <view class="item" wx:for="{{indexGoods}}" wx:for-index="index" wx:for-item="item" wx:key="{{item.id}}">
+        <navigator url="../goods/goods?id={{item.id}}">
+          <image class="img" src="{{item.list_pic_url}}" background-size="cover"></image>
+          <text class="name">{{item.name}}</text>
+          <text class="price">¥{{item.price}}</text>
+        </navigator>
+      </view>
+    </view>
   </view>
-</view>
+
+  <!-- 品牌直供 -->
+  <!-- <view class="a-section a-brand">
+    <view class="h">
+      <navigator url="../brand/brand">
+        <text class="txt">品牌制造商直供</text>
+      </navigator>
+    </view>
+    <view class="b">
+      <view class="item item-1" wx:for="{{brand}}" wx:key="item.id">
+        <navigator url="/pages/brandDetail/brandDetail?id={{item.id}}">
+          <view class="wrap">
+            <image class="img" src="{{item.new_pic_url}}" mode="aspectFill"></image>
+            <view class="mt">
+              <text class="brand">{{item.name}}</text>
+              <text class="price">{{item.floor_price}}</text>
+              <text class="unit">元起</text>
+            </view>
+          </view>
+        </navigator>
+      </view>
+    </view>
+  </view> -->
+
+  <!-- 人气商品 -->
+  <!-- <view class="a-section a-popular" wx:if="{{hotGoods.length > 0}}">
+    <view class="h">
+      <view>
+        <navigator url="../hotGoods/hotGoods">
+          <text class="txt">人气推荐</text>
+        </navigator>
+      </view>
+    </view>
+    <view class="b">
+      <view class="item" wx:for="{{hotGoods}}" wx:for-index="index" wx:for-item="item" wx:key="{{item.id}}">
+        <navigator url="/pages/goods/goods?id={{item.id}}">
+          <image class="img" src="{{item.list_pic_url}}" background-size="cover"></image>
+          <view class="right">
+            <view class="text">
+              <text class="name">{{item.name}}</text>
+              <text class="desc">{{item.goods_brief}}</text>
+              <text class="price">¥{{item.retail_price}}</text>
+            </view>
+          </view>
+        </navigator>
+      </view>
+    </view>
+  </view> -->
+
+  <!-- 专题精选 -->
+  <!-- <view class="a-section a-topic" wx:if="topics.length > 0">
+    <view class="h">
+      <view>
+      <navigator url="../topic/topic" open-type="switchTab">
+        <text class="txt">专题精选</text>
+        </navigator>
+      </view>
+    </view>
+    <view class="b">
+      <scroll-view scroll-x="true" class="list">
+        <view class="item" wx:for="{{topics}}" wx:for-index="index" wx:for-item="item" wx:key="{{item.id}}">
+          <navigator url="../topicDetail/topicDetail?id={{item.id}}">
+            <image class="img" src="{{item.scene_pic_url}}" background-size="cover"></image>
+            <view class="np">
+              <text class="name">{{item.title}}</text>
+              <text class="price">¥{{item.price_info}}元起</text>
+            </view>
+            <text class="desc">{{item.subtitle}}</text>
+          </navigator>
+        </view>
+      </scroll-view>
+    </view>
+  </view> -->
+
+<!-- floorGoods[0].goodList -->
+  <!-- <view class="good-grid" wx:for="{{floorGoods}}" wx:key="{{item.id}}">
+    <view class="h">
+      <view>
+        <text>{{item.name}}</text>
+      </view>
+    </view>
+    <view class="b">
+      <block wx:for="{{item.goodsList}}" wx:for-index="iindex" wx:for-item="iitem" wx:key="{{iitem.id}}">
+        <view class="item {{iindex % 2 == 0 ? '' : 'item-b'}}">
+          <navigator url="../goods/goods?id={{iitem.id}}" class="a">
+            <image class="img" src="{{iitem.list_pic_url}}" background-size="cover"></image>
+            <text class="name">{{iitem.name}}</text>
+            <text class="price">¥{{iitem.retail_price}}</text>
+          </navigator>
+        </view>
+      </block>
+      <view class="item item-b item-more">
+          <navigator url="/pages/category/category?id={{item.id}}" class="more-a">
+            <view class="txt">{{'更多'+item.name+'好物'}}</view>
+            <image class="icon" src="../../static/images/icon_go_more.png" background-size="cover"></image>
+          </navigator>
+      </view>
+    </view>
+  </view> -->
+</view>

+ 370 - 11
mini-app/pages/index/index.wxss

@@ -1,21 +1,380 @@
-/**index.wxss**/
-.userinfo {
+.banner {
+  width: 750rpx;
+  height: 417rpx;
+}
+
+.banner image {
+  width: 100%;
+  height: 417rpx;
+}
+
+.m-menu {
   display: flex;
+  height: 181rpx;
+  width: 750rpx;
+  flex-flow: row nowrap;
+  align-items: center;
+  justify-content: space-between;
+  background-color: #fff;
+}
+
+.m-menu .item {
+  flex: 1;
+  display: block;
+  padding: 20rpx 0;
+}
+
+.m-menu image {
+  display: block;
+  width: 58rpx;
+  height: 58rpx;
+  margin: 0 auto;
+  margin-bottom: 12rpx;
+}
+
+.m-menu text {
+  display: block;
+  font-size: 24rpx;
+  text-align: center;
+  margin: 0 auto;
+  line-height: 1;
+  color: #333;
+}
+
+.a-section {
+  width: 750rpx;
+  height: auto;
+  overflow: hidden;
+  background: #fff;
+  color: #333;
+  margin-top: 20rpx;
+}
+
+.a-section .h {
+  display: flex;
+  flex-flow: row nowrap;
+  align-items: center;
+  justify-content: center;
+  height: 130rpx;
+}
+
+.a-section .h .txt {
+  padding-right: 30rpx;
+  background: url("http://ac-3yr0g9cz.clouddn.com/2cdba05369e10f934e54.png") right 4rpx no-repeat;
+  background-size: 16.656rpx 27rpx;
+  display: inline-block;
+  height: 36rpx;
+  font-size: 33rpx;
+  line-height: 36rpx;
+}
+
+.a-brand .b {
+  width: 750rpx;
+  height: auto;
+  overflow: hidden;
+  position: relative;
+}
+
+.a-brand .wrap {
+  position: relative;
+}
+
+.a-brand .img {
+  position: absolute;
+  left: 0;
+  top: 0;
+}
+
+.a-brand .mt {
+  position: absolute;
+  z-index: 2;
+  padding: 27rpx 31rpx;
+  left: 0;
+  top: 0;
+}
+
+.a-brand .mt .brand {
+  display: block;
+  font-size: 33rpx;
+  height: 43rpx;
+  color: #333;
+}
+
+.a-brand .mt .price, .a-brand .mt .unit {
+  font-size: 25rpx;
+  color: #999;
+}
+
+.a-brand .item-1 {
+  float: left;
+  width: 375rpx;
+  height: 252rpx;
+  overflow: hidden;
+  border-top: 1rpx solid #fff;
+  margin-left: 1rpx;
+}
+
+.a-brand .item-1:nth-child(2n+1){
+  margin-left: 0;
+  width: 374rpx;
+}
+
+.a-brand .item-1 .img {
+  width: 375rpx;
+  height: 253rpx;
+}
+
+.a-new .b {
+  width: 750rpx;
+  height: auto;
+  overflow: hidden;
+  padding: 0 31rpx 45rpx 31rpx;
+}
+
+.a-new .b .item {
+  float: left;
+  width: 302rpx;
+  margin-top: 10rpx;
+  margin-left: 21rpx;
+  margin-right: 21rpx;
+}
+
+.a-new .b .item-b {
+  margin-left: 42rpx;
+}
+
+.a-new .b .img {
+  width: 302rpx;
+  height: 302rpx;
+}
+
+.a-new .b .name {
+  text-align: center;
+  display: block;
+  width: 302rpx;
+  height: 35rpx;
+  margin-bottom: 14rpx;
+  overflow: hidden;
+  font-size: 30rpx;
+  color: #333;
+}
+
+.a-new .b .price {
+  display: block;
+  text-align: center;
+  line-height: 30rpx;
+  font-size: 30rpx;
+  color: #f94b4b;
+}
+
+.a-popular {
+  width: 750rpx;
+  height: auto;
+  overflow: hidden;
+}
+
+.a-popular .b .item {
+  border-top: 1px solid #d9d9d9;
+  margin: 0 20rpx;
+  height: 264rpx;
+  width: 710rpx;
+}
+
+.a-popular .b .img {
+  margin-top: 12rpx;
+  margin-right: 12rpx;
+  float: left;
+  width: 240rpx;
+  height: 240rpx;
+}
+
+.a-popular .b .right {
+  float: left;
+  height: 264rpx;
+  width: 456rpx;
+  display: flex;
+  flex-flow: row nowrap;
+}
+
+.a-popular .b .text {
+  display: flex;
+  flex-wrap: nowrap;
   flex-direction: column;
+  justify-content: center;
+  overflow: hidden;
+  height: 264rpx;
+  width: 456rpx;
+}
+
+.a-popular .b .name {
+  width: 456rpx;
+  display: block;
+  color: #333;
+  line-height: 50rpx;
+  font-size: 30rpx;
+}
+
+.a-popular .b .desc {
+  width: 456rpx;
+  display: block;
+  color: #999;
+  line-height: 50rpx;
+  font-size: 25rpx;
+}
+
+.a-popular .b .price {
+  width: 456rpx;
+  display: block;
+  color: #b4282d;
+  line-height: 50rpx;
+  font-size: 33rpx;
+}
+
+.a-topic .b {
+  height: 533rpx;
+  width: 750rpx;
+  padding: 0 0 48rpx 0;
+}
+
+.a-topic .b .list {
+  height: 533rpx;
+  width: 750rpx;
+  white-space: nowrap;
+}
+
+.a-topic .b .item {
+  display: inline-block;
+  height: 533rpx;
+  width: 680.5rpx;
+  margin-left: 30rpx;
+  overflow: hidden;
+}
+
+.a-topic .b .item:last-child {
+  margin-right: 30rpx;
+}
+
+.a-topic .b .img {
+  height: 387.5rpx;
+  width: 680.5rpx;
+  margin-bottom: 30rpx;
+}
+
+.a-topic .b .np {
+  height: 35rpx;
+  margin-bottom: 13.5rpx;
+  color: #333;
+  font-size: 30rpx;
+}
+
+.a-topic .b .np .price {
+  margin-left: 20.8rpx;
+  color: #b4282d;
+}
+
+.a-topic .b .desc {
+  display: block;
+  height: 30rpx;
+  color: #999;
+  font-size: 24rpx;
+  white-space: nowrap;
+  overflow: hidden;
+  text-overflow:ellipsis;
+}
+
+.good-grid {
+  width: 750rpx;
+  height: auto;
+  overflow: hidden;
+}
+
+.good-grid .h {
+  display: flex;
+  flex-flow: row nowrap;
   align-items: center;
+  justify-content: center;
+  height: 130rpx;
+  font-size: 33rpx;
+  color: #333;
+}
+
+.good-grid .b {
+  width: 750rpx;
+  padding: 0 6.25rpx;
+  height: auto;
+  overflow: hidden;
+}
+
+.good-grid .b .item {
+  float: left;
+  background: #fff;
+  width: 365rpx;
+  margin-bottom: 6.25rpx;
+  height: 452rpx;
+  overflow: hidden;
+  text-align: center;
+}
+
+.good-grid .b .item .a{
+  height: 452rpx;
+  width: 100%;
 }
 
-.userinfo-avatar {
-  width: 128rpx;
-  height: 128rpx;
-  margin: 20rpx;
-  border-radius: 50%;
+.good-grid .b .item-b {
+  margin-left: 6.25rpx;
+}
+
+.good-grid .item .img {
+  margin-top: 20rpx;
+  width: 302rpx;
+  height: 302rpx;
+}
+
+.good-grid .item .name {
+  display: block;
+  width: 365.625rpx;
+  padding: 0 20rpx;
+  overflow: hidden;
+  height: 35rpx;
+  margin: 11.5rpx 0 22rpx 0;
+  text-align: center;
+  font-size: 30rpx;
+  color: #333;
+}
+
+.good-grid .item .price {
+  display: block;
+  width: 365.625rpx;
+  height: 30rpx;
+  text-align: center;
+  font-size: 30rpx;
+  color: #b4282d;
+}
+
+.good-grid .more-item{
+  height: 100%;
+  width: 100%;
+}
+
+.more-a{
+  height: 100%;
+  width: 100%;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: center;
 }
 
-.userinfo-nickname {
-  color: #aaa;
+.good-grid .more-a .txt{
+  height: 33rpx;
+  width: 100%;
+  line-height: 33rpx;
+  color: #333;
+  font-size: 33rpx;
 }
 
-.usermotto {
-  margin-top: 200px;
+.good-grid .more-a .icon{
+  margin: 60rpx auto 0 auto;
+  width: 70rpx;
+  height: 70rpx;
 }

+ 2 - 3
mini-app/pages/logs/logs.js

@@ -1,13 +1,12 @@
 //logs.js
-const util = require('../../utils/util.js')
-
+var util = require('../../utils/util.js')
 Page({
   data: {
     logs: []
   },
   onLoad: function () {
     this.setData({
-      logs: (wx.getStorageSync('logs') || []).map(log => {
+      logs: (wx.getStorageSync('logs') || []).map(function (log) {
         return util.formatTime(new Date(log))
       })
     })

+ 1 - 1
mini-app/pages/logs/logs.json

@@ -1,3 +1,3 @@
 {
-  "navigationBarTitleText": "查看启动日志"
+    "navigationBarTitleText": "查看启动日志"
 }

+ 105 - 0
mini-app/pages/newGoods/newGoods.js

@@ -0,0 +1,105 @@
+var util = require('../../utils/util.js');
+var api = require('../../config/api.js');
+var app = getApp();
+
+Page({
+  data: {
+    bannerInfo: {
+      'img_url': '',
+      'name': ''
+    },
+    categoryFilter: false,
+    filterCategory: [],
+    goodsList: [],
+    categoryId: 0,
+    currentSortType: 'default',
+    currentSortOrder: 'desc',
+    page: 1,
+    size: 1000
+  },
+  getData: function () {
+    let that = this;
+    util.request(api.GoodsHot).then(function (res) {
+      if (res.errno === 0) {
+        that.setData({
+          bannerInfo: res.data.bannerInfo,
+        });
+        that.getGoodsList();
+      }
+    });
+  },
+  getGoodsList() {
+    var that = this;
+
+    util.request(api.GoodsList, { isNew: 1, page: that.data.page, size: that.data.size, order: that.data.currentSortOrder, sort: that.data.currentSortType, categoryId: that.data.categoryId })
+      .then(function (res) {
+        if (res.errno === 0) {
+          that.setData({
+            goodsList: res.data.goodsList,
+            filterCategory: res.data.filterCategory
+          });
+        }
+      });
+  },
+  onLoad: function (options) {
+    // 页面初始化 options为页面跳转所带来的参数
+    this.getData();
+  },
+  onReady: function () {
+    // 页面渲染完成
+  },
+  onShow: function () {
+    // 页面显示
+
+  },
+  onHide: function () {
+    // 页面隐藏
+
+  },
+  onUnload: function () {
+    // 页面关闭
+
+  },
+  openSortFilter: function (event) {
+    let currentId = event.currentTarget.id;
+    switch (currentId) {
+      case 'categoryFilter':
+        this.setData({
+          'categoryFilter': !this.data.categoryFilter,
+          'currentSortType': 'category',
+          'currentSortOrder': 'asc'
+        });
+        break;
+      case 'priceSort':
+        let tmpSortOrder = 'asc';
+        if (this.data.currentSortOrder == 'asc') {
+          tmpSortOrder = 'desc';
+        }
+        this.setData({
+          'currentSortType': 'price',
+          'currentSortOrder': tmpSortOrder,
+          'categoryFilter': false
+        });
+
+        this.getData();
+        break;
+      default:
+        //综合排序
+        this.setData({
+          'currentSortType': 'default',
+          'currentSortOrder': 'desc',
+          'categoryFilter': false
+        });
+        this.getData();
+    }
+  },
+  selectCategory: function (event) {
+    let currentIndex = event.target.dataset.categoryIndex;
+    this.setData({
+      'categoryFilter': false,
+      'categoryId': this.data.filterCategory[currentIndex].id
+    });
+    this.getData();
+
+  }
+})

+ 3 - 0
mini-app/pages/newGoods/newGoods.json

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

+ 40 - 0
mini-app/pages/newGoods/newGoods.wxml

@@ -0,0 +1,40 @@
+<view class="container">
+  <view class="brand-info">
+    <view class="name">
+      <image class="img" src="{{bannerInfo.img_url}}" background-size="cover"></image>
+      <view class="info-box">
+        <view class="info">
+          <text class="txt">{{bannerInfo.name}}</text>
+          <text class="line"></text>
+        </view>
+      </view>
+    </view>
+  </view>
+  <view class="sort">
+    <view class="sort-box">
+      <view class="item {{currentSortType == 'default' ? 'active' : ''}}"  bindtap="openSortFilter" id="defaultSort">
+        <text class="txt">综合</text>
+      </view>
+      <view class="item by-price {{currentSortType == 'price' ? 'active' : ''}} {{currentSortOrder == 'asc'  ? 'asc' : 'desc'}}" bindtap="openSortFilter" id="priceSort">
+        <text class="txt">价格</text>
+      </view>
+      <view class="item {{currentSortType == 'category' ? 'active' : ''}}" bindtap="openSortFilter" id="categoryFilter">
+        <text class="txt">分类</text>
+      </view>
+    </view>
+    <view class="sort-box-category" wx-if="{{categoryFilter}}">
+      <view class="item {{item.checked ? 'active' : ''}}" wx:for="{{filterCategory}}" wx:key="cate-{{item.id}}" data-category-index="{{index}}" bindtap="selectCategory">{{item.name}}</view>
+    </view>
+  </view>
+  <view class="cate-item">
+    <view class="b">
+      <block wx:for="{{goodsList}}" wx:for-index="iindex" wx:for-item="iitem" wx:key="unique">
+        <navigator class="item {{iindex % 2 == 0 ? 'item-b' : '' }}" url="../goods/goods?id={{iitem.id}}">
+          <image class="img" src="{{iitem.list_pic_url}}" background-size="cover"></image>
+          <text class="name">{{iitem.name}}</text>
+          <text class="price">¥{{iitem.retail_price}}</text>
+        </navigator>
+      </block>
+    </view>
+  </view>
+</view>

+ 177 - 0
mini-app/pages/newGoods/newGoods.wxss

@@ -0,0 +1,177 @@
+page{
+    background: #f4f4f4;
+}
+
+.brand-info .name{
+    width: 100%;
+    height: 278rpx;
+    position: relative;
+}
+
+.brand-info .img{
+    position: absolute;
+    top:0;
+    left:0;
+    width: 100%;
+    height: 278rpx;
+}
+
+.brand-info .info-box{
+    position: absolute;
+    top:0;
+    left:0;
+    width: 100%;
+    height: 278rpx;
+    text-align: center;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+}
+
+.brand-info .info{
+    display: block;
+}
+
+.brand-info .txt{
+    display: block;
+    height: 40rpx;
+    font-size: 37.5rpx;
+    color: #fff;
+}
+
+.brand-info .line{
+    margin: 0 auto;
+    margin-top: 16rpx;
+    display: block;
+    height: 2rpx;
+    width: 145rpx;
+    background: #fff;
+}
+
+.sort{
+    position: relative;
+    background: #fff;
+    width: 100%;
+    height: 78rpx;
+}
+
+.sort-box{
+    background: #fff;
+    width: 100%;
+    height: 78rpx;
+    overflow: hidden;
+    padding: 0 30rpx;
+    display: flex;
+    border-bottom: 1px solid #d9d9d9;
+}
+
+.sort-box .item{
+    height: 78rpx;
+    line-height: 78rpx;
+    text-align: center;
+    flex:1;
+    color: #333;
+    font-size: 30rpx;
+}
+
+.sort-box .item .txt{
+    display: block;
+    width: 100%;
+    height: 100%;
+    color: #333;
+}
+
+.sort-box .item.active .txt{
+    color: #b4282d;
+}
+
+.sort-box .item.by-price{
+    background: url(//yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/no-3127092a69.png) 155rpx center no-repeat;
+    background-size: 15rpx 21rpx;
+}
+
+.sort-box .item.by-price.active.asc{
+    background: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/up-636b92c0a5.png) 155rpx center no-repeat;
+    background-size: 15rpx 21rpx;
+}
+
+.sort-box .item.by-price.active.desc{
+    background: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/down-95e035f3e5.png) 155rpx center no-repeat;
+    background-size: 15rpx 21rpx;
+}
+
+.sort-box-category{
+    background: #fff;
+    width: 100%;
+    height: auto;
+    overflow: hidden;
+    padding: 40rpx 40rpx 0 0;
+    border-bottom: 1px solid #d9d9d9;
+}
+
+.sort-box-category .item{
+    height: 54rpx;
+    line-height: 54rpx;
+    text-align: center;
+    float: left;
+    padding: 0 16rpx;
+    margin: 0 0 40rpx 40rpx;
+    border: 1px solid #666;
+    color: #333;
+    font-size: 24rpx;
+}
+
+.sort-box-category .item.active{
+    color: #b4282d;
+    border: 1px solid #b4282d;
+}
+
+.cate-item .b{
+  width: 750rpx;
+  height: auto;
+  overflow: hidden;
+  border-top: 1rpx solid #f4f4f4;
+  margin-top: 20rpx;
+}
+
+.cate-item .b .item{
+  float: left;
+  background: #fff;
+  width: 375rpx;
+  padding-bottom: 33.333rpx;
+  border-bottom: 1rpx solid #f4f4f4;
+  height: auto;
+  overflow: hidden;
+  text-align: center;
+}
+
+.cate-item .b .item-b{
+ border-right: 1rpx solid #f4f4f4;
+}
+
+.cate-item .item .img{
+    margin-top: 10rpx;
+  width: 302rpx;
+  height: 302rpx;
+}
+
+.cate-item .item .name{
+  display: block;
+  width: 365.625rpx;
+  height: 35rpx;
+  padding: 0 20rpx;
+  overflow: hidden;
+  margin: 11.5rpx 0 22rpx 0;
+  text-align: center;
+  font-size: 30rpx;
+  color: #333;
+}
+
+.cate-item .item .price{
+  display: block;
+  width: 365.625rpx;
+  height: 30rpx;
+  text-align: center;
+  font-size: 30rpx;
+  color: #b4282d;
+}

+ 61 - 0
mini-app/pages/pay/pay.js

@@ -0,0 +1,61 @@
+var app = getApp();
+var util = require('../../utils/util.js');
+var api = require('../../config/api.js');
+
+Page({
+  data: {
+    orderId: 0,
+    actualPrice: 0.00
+  },
+  onLoad: function (options) {
+    // 页面初始化 options为页面跳转所带来的参数
+    this.setData({
+      orderId: options.orderId,
+      actualPrice: options.actualPrice
+    })
+  },
+  onReady: function () {
+
+  },
+  onShow: function () {
+    // 页面显示
+
+  },
+  onHide: function () {
+    // 页面隐藏
+
+  },
+  onUnload: function () {
+    // 页面关闭
+
+  },
+  //向服务请求支付参数
+  requestPayParam() {
+    let that = this;
+    util.request(api.PayPrepayId, { orderId: that.data.orderId, payType: 1 }).then(function (res) {
+      if (res.errno === 0) {
+        let payParam = res.data;
+        wx.requestPayment({
+          'timeStamp': payParam.timeStamp,
+          'nonceStr': payParam.timeStamp,
+          'package': payParam.nonceStr,
+          'signType': payParam.signType,
+          'paySign': payParam.paySign,
+          'success': function (res) {
+            wx.redirectTo({
+              url: '/pages/payResult/payResult?status=true',
+            })
+          },
+          'fail': function (res) {
+            wx.redirectTo({
+              url: '/pages/payResult/payResult?status=false',
+            })
+          }
+        })
+      }
+    });
+  },
+  startPay() {
+    this.requestPayParam();
+  }
+})

+ 3 - 0
mini-app/pages/pay/pay.json

@@ -0,0 +1,3 @@
+{
+  "navigationBarTitleText": "支付订单"
+}

+ 29 - 0
mini-app/pages/pay/pay.wxml

@@ -0,0 +1,29 @@
+<view class="container">
+    <view class="total">
+      <view class="label">订单金额</view>
+      <view class="txt">{{actualPrice}}元</view>
+    </view>
+    <view class="pay-list">
+        <view class="h">请选择支付方式</view>
+        <view class="b">
+            <!--<view class="item">
+                <view class="checkbox checked"></view>
+                <view class="icon-alipay"></view>
+                <view class="name">支付宝</view>
+            </view>
+            <view class="item">
+                <view class="checkbox"></view>
+                <view class="icon-net"></view>
+                <view class="name">网易支付</view>
+            </view>-->
+            <view class="item">
+                <view class="checkbox checked"></view>
+                <image src="/static/images/wxpay.png" class="icon"></image>
+                <view class="name">微信支付</view>
+            </view>
+        </view>
+    </view>
+    <view class="tips">小程序只支持微信支付,如需其它支付方式,请在网页版支付</view>
+
+    <view class="pay-btn" bindtap="startPay">确定</view>
+</view>

+ 123 - 0
mini-app/pages/pay/pay.wxss

@@ -0,0 +1,123 @@
+page{
+    min-height: 100%;
+    width: 100%;
+    background: #f4f4f4;
+}
+
+.container{
+  padding-top: 20rpx;
+}
+
+.total{
+  height: 104rpx;
+  background: #fff;
+  width: 100%;
+  line-height: 104rpx;
+  padding-left: 30rpx;
+  padding-right: 30rpx;
+}
+
+.total .label{
+  float: left;
+}
+
+.total .txt{
+  float: right;
+}
+
+.pay-list{
+    margin-top: 30rpx;
+    height: auto;
+    width: 100%;
+    overflow: hidden;
+}
+.pay-list .h{
+    width: 100%;
+    height: 24rpx;
+    line-height: 24rpx;
+    margin-left: 31.25rpx;
+    margin-bottom: 31.25rpx;
+}
+
+.pay-list .item{
+    height: 108rpx;
+    padding-left: 31.25rpx;
+    background: #fff;
+    display: flex;
+    align-items: center;
+    border-bottom: 1px solid #f4f4f4;
+}
+
+.pay-list .checkbox{
+    background: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/sprites/checkbox-sed825af9d3-a6b8540d42.png) 0 -448rpx no-repeat;
+    background-size: 38rpx 486rpx;
+    width: 40rpx;
+    height: 40rpx;
+    display: inline-block;
+    vertical-align: middle;
+    margin-right: 30rpx;
+}
+
+.pay-list .checkbox.checked{
+    background: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/sprites/checkbox-sed825af9d3-a6b8540d42.png) 0 -192rpx no-repeat;
+    background-size: 38rpx 486rpx;
+}
+
+.pay-list .icon-alipay{
+    display: inline-block;
+    vertical-align: middle;
+    background-image: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/sprites/payMethod-s3c1faebee4-d754da9c65.png);
+    background-repeat: no-repeat;
+    background-size: 56.25rpx 189.583rpx;
+    margin-right: 10.5rpx;
+    width: 56.25rpx;
+    height: 56.25rpx;
+}
+
+.pay-list .icon-net{
+    display: inline-block;
+    vertical-align: middle;
+    background: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/sprites/payMethod-s3c1faebee4-d754da9c65.png) 0 -66.7rpx no-repeat;
+    background-size: 56.25rpx 189.583rpx;
+    margin-right: 10.5rpx;
+    width: 56.25rpx;
+    height: 56.25rpx;
+}
+
+.pay-list .icon{
+    display: inline-block;
+    vertical-align: middle;
+    margin-right: 10.5rpx;
+    width: 56.25rpx;
+    height: 56.25rpx;
+}
+
+.pay-list .name{
+    display: inline-block;
+    vertical-align: middle;
+    height: 56.25rpx;
+    line-height: 56.25rpx;
+}
+
+.pay-btn{
+    position: fixed;
+    left: 0;
+    bottom: 0;
+    height: 100rpx;
+    width: 100%;
+    text-align: center;
+    line-height: 100rpx;
+    background: #b4282d;
+    color: #fff;
+    font-size: 30rpx;
+}
+
+.tips{
+  height: 40rpx;
+  width: 100%;
+  font-size: 24rpx;
+  color: #999;
+  line-height: 40rpx;
+  padding-left: 30rpx;
+  padding-right: 30rpx;
+}

+ 42 - 0
mini-app/pages/payResult/payResult.js

@@ -0,0 +1,42 @@
+var util = require('../../utils/util.js');
+var api = require('../../config/api.js');
+const pay = require('../../services/pay.js');
+
+var app = getApp();
+Page({
+  data: {
+    status: false,
+    orderId: 0
+  },
+  onLoad: function (options) {
+    // 页面初始化 options为页面跳转所带来的参数
+    this.setData({
+      orderId: options.orderId || 24,
+      status: options.status
+    })
+  },
+  onReady: function () {
+
+  },
+  onShow: function () {
+    // 页面显示
+
+  },
+  onHide: function () {
+    // 页面隐藏
+
+  },
+  onUnload: function () {
+    // 页面关闭
+
+  },
+  payOrder() {
+    pay.payOrder(parseInt(this.data.orderId)).then(res => {
+      this.setData({
+        status: true
+      });
+    }).catch(res => {
+      util.showErrorToast('支付失败');
+    });
+  }
+})

+ 4 - 0
mini-app/pages/payResult/payResult.json

@@ -0,0 +1,4 @@
+{
+    "navigationBarTitleText": "付款结果",
+    "navigationBarBackgroundColor": "#fafafa"
+}

+ 23 - 0
mini-app/pages/payResult/payResult.wxml

@@ -0,0 +1,23 @@
+<view class="container">
+  <view class="pay-result">
+    <view class="success" wx:if="{{status == true}}">
+      <view class="msg">付款成功</view>
+      <view class="btns">
+        <navigator class="btn" url="/pages/ucenter/order/order" open-type="redirect">查看订单</navigator>
+        <navigator class="btn" url="/pages/index/index" open-type="switchTab">继续逛</navigator>
+      </view>
+    </view>
+    <view class="error" wx:if="{{status != true}}">
+      <view class="msg">付款失败</view>
+      <view class="tips">
+        <view class="p">请在 <text class="time">1小时</text> 内完成付款</view>
+        <view class="p">否则订单将会被系统取消</view>
+      </view>
+      <view class="btns">
+        <navigator class="btn" url="/pages/ucenter/order/order" open-type="redirect">查看订单</navigator>
+        <view class="btn" bindtap='payOrder'>重新付款</view>
+      </view>
+    </view>
+  </view>
+
+</view>

+ 59 - 0
mini-app/pages/payResult/payResult.wxss

@@ -0,0 +1,59 @@
+page {
+  min-height: 100%;
+  width: 100%;
+  background: #fff;
+}
+
+.container {
+  height: 100%;
+  background: #fff;
+}
+
+.pay-result {
+  background: #fff;
+}
+
+.pay-result .msg {
+  text-align: center;
+  margin: 100rpx auto;
+  color: #2bab25;
+  font-size: 36rpx;
+}
+
+.pay-result .btns {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+
+.pay-result .btn {
+  text-align: center;
+  height: 80rpx;
+  margin: 0 20rpx;
+  width: 200rpx;
+  line-height: 78rpx;
+  border: 1px solid #868686;
+  color: #000000;
+  border-radius: 5rpx;
+}
+
+.pay-result .error .msg {
+  color: #b4282d;
+  margin-bottom: 60rpx;
+}
+
+.pay-result .error .tips {
+  color: #7f7f7f;
+  margin-bottom: 70rpx;
+}
+
+.pay-result .error .tips .p {
+  font-size: 24rpx;
+  line-height: 42rpx;
+  text-align: center;
+}
+
+.pay-result .error .tips .p {
+  line-height: 42rpx;
+  text-align: center;
+}

+ 179 - 0
mini-app/pages/search/search.js

@@ -0,0 +1,179 @@
+var util = require('../../utils/util.js');
+var api = require('../../config/api.js');
+
+var app = getApp()
+Page({
+  data: {
+    keywrod: '',
+    searchStatus: false,
+    goodsList: [],
+    helpKeyword: [],
+    historyKeyword: [],
+    categoryFilter: false,
+    currentSortType: 'default',
+    currentSortOrder: '',
+    filterCategory: [],
+    defaultKeyword: {},
+    hotKeyword: [],
+    page: 1,
+    size: 20,
+    currentSortType: 'id',
+    currentSortOrder: 'desc',
+    categoryId: 0
+  },
+  //事件处理函数
+  closeSearch: function () {
+    wx.navigateBack()
+  },
+  clearKeyword: function () {
+    this.setData({
+      keyword: '',
+      searchStatus: false
+    });
+  },
+  onLoad: function () {
+
+    this.getSearchKeyword();
+  },
+
+  getSearchKeyword() {
+    let that = this;
+    util.request(api.SearchIndex).then(function (res) {
+      if (res.errno === 0) {
+        that.setData({
+          historyKeyword: res.data.historyKeywordList,
+          defaultKeyword: res.data.defaultKeyword,
+          hotKeyword: res.data.hotKeywordList
+        });
+      }
+    });
+  },
+
+  inputChange: function (e) {
+
+    this.setData({
+      keyword: e.detail.value,
+      searchStatus: false
+    });
+    this.getHelpKeyword();
+  },
+  getHelpKeyword: function () {
+    let that = this;
+    util.request(api.SearchHelper, { keyword: that.data.keyword }).then(function (res) {
+      if (res.errno === 0) {
+        that.setData({
+          helpKeyword: res.data
+        });
+      }
+    });
+  },
+  inputFocus: function () {
+    this.setData({
+      searchStatus: false,
+      goodsList: []
+    });
+
+    if (this.data.keyword) {
+      this.getHelpKeyword();
+    }
+  },
+  clearHistory: function () {
+    this.setData({
+      historyKeyword: []
+    })
+
+    util.request(api.SearchClearHistory, {}, 'POST')
+      .then(function (res) {
+        console.log('清除成功');
+      });
+  },
+  getGoodsList: function () {
+    let that = this;
+    util.request(api.GoodsList, { keyword: that.data.keyword, page: that.data.page, size: that.data.size, sort: that.data.currentSortType, order: that.data.currentSortOrder, categoryId: that.data.categoryId }).then(function (res) {
+      if (res.errno === 0) {
+        that.setData({
+          searchStatus: true,
+          categoryFilter: false,
+          goodsList: res.data.data,
+          filterCategory: res.data.filterCategory,
+          page: res.data.currentPage,
+          size: res.data.numsPerPage
+        });
+      }
+
+      //重新获取关键词
+      that.getSearchKeyword();
+    });
+  },
+  onKeywordTap: function (event) {
+
+    this.getSearchResult(event.target.dataset.keyword);
+
+  },
+  getSearchResult(keyword) {
+    this.setData({
+      keyword: keyword,
+      page: 1,
+      categoryId: 0,
+      goodsList: []
+    });
+
+    this.getGoodsList();
+  },
+  openSortFilter: function (event) {
+    let currentId = event.currentTarget.id;
+    switch (currentId) {
+      case 'categoryFilter':
+        this.setData({
+          'categoryFilter': !this.data.categoryFilter,
+          'currentSortOrder': 'asc'
+        });
+        break;
+      case 'priceSort':
+        let tmpSortOrder = 'asc';
+        if (this.data.currentSortOrder == 'asc') {
+          tmpSortOrder = 'desc';
+        }
+        this.setData({
+          'currentSortType': 'price',
+          'currentSortOrder': tmpSortOrder,
+          'categoryFilter': false
+        });
+
+        this.getGoodsList();
+        break;
+      default:
+        //综合排序
+        this.setData({
+          'currentSortType': 'default',
+          'currentSortOrder': 'desc',
+          'categoryFilter': false
+        });
+        this.getGoodsList();
+    }
+  },
+  selectCategory: function (event) {
+    let currentIndex = event.target.dataset.categoryIndex;
+    let filterCategory = this.data.filterCategory;
+    let currentCategory = null;
+    for (let key in filterCategory) {
+      if (key == currentIndex) {
+        filterCategory[key].selected = true;
+        currentCategory = filterCategory[key];
+      } else {
+        filterCategory[key].selected = false;
+      }
+    }
+    this.setData({
+      'filterCategory': filterCategory,
+      'categoryFilter': false,
+      categoryId: currentCategory.id,
+      page: 1,
+      goodsList: []
+    });
+    this.getGoodsList();
+  },
+  onKeywordConfirm(event) {
+    this.getSearchResult(event.detail.value);
+  }
+})

+ 3 - 0
mini-app/pages/search/search.json

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

+ 65 - 0
mini-app/pages/search/search.wxml

@@ -0,0 +1,65 @@
+<scroll-view class="container" style="height: 100%;">
+  <view class="search-header">
+    <view class="input-box">
+      <image class="icon" src="http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/search2-2fb94833aa.png"></image>
+      <input name="input" class="keywrod" focus="true" value="{{keyword}}" confirm-type="search" bindinput="inputChange" bindfocus="inputFocus" bindconfirm="onKeywordConfirm" confirm-type="search" placeholder="{{defaultKeyword.keyword}}" />
+      <image class="del" wx:if="{{keyword}}" bindtap="clearKeyword" src="http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/clearIpt-f71b83e3c2.png"></image>
+    </view>
+    <view class="right" bindtap="closeSearch">取消</view>
+  </view>
+  <view class="no-search" wx:if="{{ !searchStatus}}">
+      <view class="serach-keywords search-history" wx:if="{{!keyword  && historyKeyword.length}}">
+    <view class="h">
+      <text class="title">历史记录</text>
+      <image class="icon" bindtap="clearHistory" src="http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/del1-93f0a4add4.png"></image>
+    </view>
+    <view class="b">
+      <view class="item" bindtap="onKeywordTap" data-keyword="{{item}}" wx:for="{{historyKeyword}}" hover-class="navigator-hover">{{item}}</view>
+    </view>
+  </view>
+  <view class="serach-keywords search-hot" wx:if="{{!keyword}}">
+    <view class="h">
+      <text class="title">热门搜索</text>
+    </view>
+    <view class="b">
+      <view class="item {{item.is_hot === 1 ? 'active' : ''}}" hover-class="navigator-hover" bindtap="onKeywordTap" data-keyword="{{item.keyword}}" wx:for="{{hotKeyword}}">{{item.keyword}}</view>
+    </view>
+  </view>
+  <view class="shelper-list" wx:if="{{keyword}}">
+    <view class="item" hover-class="navigator-hover" wx:for="{{helpKeyword}}" bindtap="onKeywordTap" data-keyword="{{item}}">{{item}}</view>
+  </view>
+  </view>
+
+  <view class="search-result" wx:if="{{ searchStatus && goodsList.length}}">
+    <view class="sort">
+    <view class="sort-box">
+      <view class="item {{currentSortType == 'default' ? 'active' : ''}}" bindtap="openSortFilter" id="defaultSort">
+        <text class="txt">综合</text>
+      </view>
+      <view class="item by-price {{currentSortType == 'price' ? 'active' : ''}} {{currentSortOrder == 'asc'  ? 'asc' : 'desc'}}" bindtap="openSortFilter" id="priceSort">
+        <text class="txt">价格</text>
+      </view>
+      <view class="item {{currentSortType == 'category' ? 'active' : ''}}" bindtap="openSortFilter" id="categoryFilter">
+        <text class="txt">分类</text>
+      </view>
+    </view>
+    <view class="sort-box-category" wx-if="{{categoryFilter}}">
+      <view class="item {{item.checked ? 'active' : ''}}" wx:for="{{filterCategory}}" wx:key="cate-{{item.id}}" data-category-index="{{index}}" bindtap="selectCategory">{{item.name}}</view>
+    </view>
+  </view>
+  <view class="cate-item">
+    <view class="b">
+      <navigator class="item {{(iindex + 1) % 2 == 0 ? 'item-b' : ''}}" url="/pages/goods/goods?id={{iitem.id}}" wx:for="{{goodsList}}" wx:for-item="iitem" wx:for-index="iindex">
+        <image class="img" src="{{iitem.list_pic_url}}" background-size="cover"></image>
+        <text class="name">{{iitem.name}}</text>
+        <text class="price">¥{{iitem.retail_price}}</text>
+      </navigator>
+    </view>
+  </view>
+  </view>
+
+  <view class="search-result-empty" wx:if="{{!goodsList.length && searchStatus}}">
+    <image class="icon" src="http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/noSearchResult-7572a94f32.png"></image>
+    <text class="text">您寻找的商品还未上架</text>
+  </view>
+</scroll-view>

+ 336 - 0
mini-app/pages/search/search.wxss

@@ -0,0 +1,336 @@
+page{
+  min-height: 100%;
+  background-color: #f4f4f4;
+}
+
+.container{
+  min-height: 100%;
+  background-color: #f4f4f4;
+}
+
+.search-header{
+    position: fixed;
+    top: 0;
+    width: 750rpx;
+    height: 91rpx;
+    display: flex;
+    background: #fff;
+    border-bottom: 1px solid rgba(0,0,0,.15);
+    padding: 0 31.25rpx;
+    font-size: 29rpx;
+    color: #333;
+}
+
+.search-header .input-box{
+    position: relative;
+    margin-top: 16rpx;
+    float: left;
+    width: 0;
+    flex: 1;
+    height: 59rpx;
+    line-height: 59rpx;
+    padding: 0 20rpx;
+    background: #f4f4f4;
+}
+
+.search-header .icon{
+    position: absolute;
+    top: 14rpx;
+    left: 20rpx;
+    width: 31rpx;
+    height: 31rpx;
+}
+
+.search-header .del{
+    position: absolute;
+    top: 3rpx;
+    right: 10rpx;
+    width: 53rpx;
+    height: 53rpx;
+    z-index: 10;
+}
+
+.search-header .keywrod{
+    position: absolute;
+    top: 0;
+    left: 40rpx;
+    width: 506rpx;
+    height: 59rpx;
+    padding-left: 30rpx;
+}
+
+.search-header .right{
+    margin-top: 24rpx;
+    margin-left: 31rpx;
+    margin-right: 6rpx;
+    width: 58rpx;
+    height: 43rpx;
+    line-height: 43rpx;
+    float: right;
+}
+
+.no-search{
+    height: auto;
+    overflow: hidden;
+    margin-top: 91rpx;
+}
+
+.serach-keywords{
+    background: #fff;
+    width: 750rpx;
+    height: auto;
+    overflow: hidden;
+    margin-bottom: 20rpx;
+}
+
+.serach-keywords .h{
+    padding: 0 31.25rpx;
+    height: 93rpx;
+    line-height: 93rpx;
+    width: 100%;
+    color: #999;
+    font-size: 29rpx;
+}
+
+.serach-keywords .title{
+    display: block;
+    width: 120rpx;
+    float: left;
+}
+
+.serach-keywords .icon{
+    margin-top: 19rpx;
+    float: right;
+    display: block;
+    margin-left: 511rpx;
+    height: 55rpx;
+    width: 55rpx;
+}
+
+.serach-keywords .b{
+    width: 750rpx;
+    height: auto;
+    overflow: hidden;
+    padding-left: 31.25rpx;
+}
+
+.serach-keywords .item{
+    display: inline-block;
+    width: auto;
+    height: 48rpx;
+    line-height: 48rpx;
+    padding:0 15rpx;
+    border: 1px solid #999;
+    margin: 0 31.25rpx 31.25rpx 0;
+    font-size: 24rpx;
+    color: #333;
+}
+
+.serach-keywords .item.active{
+    color: #b4282d;
+    border: 1px solid #b4282d;
+}
+
+.shelper-list{
+    width: 750rpx;
+    height: auto;
+    overflow: hidden;
+    background: #fff;
+    padding: 0 31.25rpx;
+}
+
+.shelper-list .item{
+    height: 93rpx;
+    width: 687.5rpx;
+    line-height: 93rpx;
+    font-size: 24rpx;
+    color: #333;
+    border-bottom: 1px solid #f4f4f4;
+}
+
+
+.sort{
+    position: fixed;
+    top: 91rpx;
+    background: #fff;
+    width: 100%;
+    height: 78rpx;
+}
+
+.sort-box{
+    background: #fff;
+    width: 100%;
+    height: 78rpx;
+    overflow: hidden;
+    padding: 0 30rpx;
+    display: flex;
+    border-bottom: 1px solid #d9d9d9;
+}
+
+.sort-box .item{
+    height: 78rpx;
+    line-height: 78rpx;
+    text-align: center;
+    flex:1;
+    color: #333;
+    font-size: 30rpx;
+}
+
+.sort-box .item .txt{
+    display: block;
+    width: 100%;
+    height: 100%;
+    color: #333;
+}
+
+.sort-box .item.active .txt{
+    color: #b4282d;
+}
+
+.sort-box .item.by-price{
+    background: url(//yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/no-3127092a69.png) 155rpx center no-repeat;
+    background-size: 15rpx 21rpx;
+}
+
+.sort-box .item.by-price.active.asc{
+    background: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/up-636b92c0a5.png) 155rpx center no-repeat;
+    background-size: 15rpx 21rpx;
+}
+
+.sort-box .item.by-price.active.desc{
+    background: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/down-95e035f3e5.png) 155rpx center no-repeat;
+    background-size: 15rpx 21rpx;
+}
+
+.sort-box-category{
+    background: #fff;
+    width: 100%;
+    height: auto;
+    overflow: hidden;
+    padding: 40rpx 40rpx 0 0;
+    border-bottom: 1px solid #d9d9d9;
+}
+
+.sort-box-category .item{
+    height: 54rpx;
+    line-height: 54rpx;
+    text-align: center;
+    float: left;
+    padding: 0 16rpx;
+    margin: 0 0 40rpx 40rpx;
+    border: 1px solid #666;
+    color: #333;
+    font-size: 24rpx;
+}
+
+.sort-box-category .item.active{
+    color: #b4282d;
+    border: 1px solid #b4282d;
+}
+
+.cate-item{
+    margin-top: 175rpx;
+    height: auto;
+    overflow: hidden;
+}
+
+.cate-item .h{
+    height: 145rpx;
+    width: 750rpx;
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    justify-content: center;
+}
+
+.cate-item .h .name{
+    display: block;
+    height: 35rpx;
+    margin-bottom: 18rpx;
+    font-size: 30rpx;
+    color: #333;
+}
+
+.cate-item .h .desc{
+    display: block;
+    height: 24rpx;
+    font-size: 24rpx;
+    color: #999;
+}
+
+.cate-item .b{
+  width: 750rpx;
+  padding: 0 6.25rpx;
+  height: auto;
+  overflow: hidden;
+}
+
+.cate-item .list-filter{
+    height: 80rpx;
+    width: 100%;
+    background: #fff;
+    margin-bottom: 6.25rpx;
+}
+
+.cate-item .b .item{
+  float: left;
+  background: #fff;
+  width: 365rpx;
+  margin-bottom: 6.25rpx;
+  padding-bottom: 33.333rpx;
+  height: auto;
+  overflow: hidden;
+  text-align: center;
+}
+
+.cate-item .b .item-b{
+  margin-left: 6.25rpx;
+}
+
+.cate-item .item .img{
+  width: 302rpx;
+  height: 302rpx;
+}
+
+.cate-item .item .name{
+  display: block;
+  width: 365.625rpx;
+  height: 35rpx;
+  margin: 11.5rpx 0 22rpx 0;
+  text-align: center;
+  overflow: hidden;
+  padding: 0 20rpx;
+  font-size: 30rpx;
+  color: #333;
+}
+
+.cate-item .item .price{
+  display: block;
+  width: 365.625rpx;
+  height: 30rpx;
+  text-align: center;
+  font-size: 30rpx;
+  color: #b4282d;
+}
+
+.search-result-empty{
+    width: 100%;
+    height: 100%;
+    padding-top: 300rpx;
+}
+
+.search-result-empty .icon{
+    margin: 0 auto;
+    display: block;
+    width: 240rpx;
+    height: 240rpx;
+}
+
+.search-result-empty .text{
+    display: block;
+    width: 100%;
+    height: 40rpx;
+    font-size: 28rpx;
+    text-align: center;
+    color: #999;
+}

+ 56 - 0
mini-app/pages/shopping/address/address.js

@@ -0,0 +1,56 @@
+var util = require('../../../utils/util.js');
+var api = require('../../../config/api.js');
+var app = getApp();
+
+Page({
+  data: {
+    addressList: [],
+  },
+  onLoad: function (options) {
+    // 页面初始化 options为页面跳转所带来的参数
+    this.getAddressList();
+  },
+  onReady: function () {
+    // 页面渲染完成
+  },
+  onShow: function () {
+    // 页面显示
+
+  },
+  getAddressList (){
+    let that = this;
+    util.request(api.AddressList).then(function (res) {
+      if (res.errno === 0) {
+        that.setData({
+          addressList: res.data
+        });
+      }
+    });
+  },
+  addressAddOrUpdate (event) {
+    console.log(event)
+    wx.navigateTo({
+      url: '/pages/shopping/addressAdd/addressAdd?id=' + event.currentTarget.dataset.addressId
+    })
+  },
+  selectAddress(event){
+    console.log(event.currentTarget.dataset.addressId);
+
+    try {
+      wx.setStorageSync('addressId', event.currentTarget.dataset.addressId);
+    } catch (e) {
+
+    }
+
+    //选择该收货地址
+    wx.redirectTo({
+      url: '/pages/shopping/checkout/checkout'
+    })
+  },
+  onHide: function () {
+    // 页面隐藏
+  },
+  onUnload: function () {
+    // 页面关闭
+  }
+})

+ 1 - 0
mini-app/pages/shopping/address/address.json

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

+ 22 - 0
mini-app/pages/shopping/address/address.wxml

@@ -0,0 +1,22 @@
+<view class="container">
+    <view class="address-list" wx:if="{{ addressList.length > 0 }}">
+        <view class="item" wx:for="{{addressList}}" wx:key="{{item.id}}" bindtap="selectAddress" data-address-id="{{item.id}}">
+            <view class="l">
+                <view class="name">{{item.name}}</view>
+                <view class="default" wx:if="{{item.is_default}}">默认</view>
+            </view>
+            <view class="c">
+                <view class="mobile">{{item.mobile}}</view>
+                <view class="address">{{item.full_region + item.address}}</view>
+            </view>
+            <view class="r">
+                <image catchtap="addressAddOrUpdate" data-address-id="{{item.id}}" class="del" src="http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/address-edit-7fee7b0d63.png"></image>
+            </view>
+        </view>
+    </view>
+    <view class="empty-view" wx:if="{{ addressList.length <= 0 }}">
+      <image class="icon" src="http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/noAddress-26d570cefa.png"></image>
+      <text class="text">收货地址在哪里</text>
+    </view>
+    <view class="add-address" bindtap="addressAddOrUpdate" data-address-id="0">新建</view>
+</view>

+ 132 - 0
mini-app/pages/shopping/address/address.wxss

@@ -0,0 +1,132 @@
+page{
+    height: 100%;
+    width: 100%;
+    background: #f4f4f4;
+}
+
+.container{
+  height: 100%;
+  width: 100%;
+}
+
+.address-list{
+    padding-left: 31.25rpx;
+    background: #fff url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/address-bg-bd30f2bfeb.png) 0 0 repeat-x;
+    background-size: auto 10.5rpx;
+    margin-bottom: 90rpx;
+}
+
+.address-list .item{
+    height: 156.55rpx;
+    align-items: center;
+    display: flex;
+    border-bottom: 1rpx solid #DCD9D9;
+}
+
+.address-list .item:last-child{
+
+    border-bottom: none;
+}
+
+.address-list .l{
+    width: 125rpx;
+    height: 80rpx;
+    overflow: hidden;
+}
+
+.address-list .name{
+    width: 125rpx;
+    height: 43rpx;
+    font-size: 29rpx;
+    color: #333;
+    margin-bottom: 5.2rpx;
+        text-overflow: ellipsis;
+    white-space: nowrap;
+    overflow: hidden;
+}
+
+.address-list .default{
+    width: 62.5rpx;
+    height: 33rpx;
+    line-height: 28rpx;
+    text-align: center;
+    font-size: 20rpx;
+    color: #b4282d;
+    border: 1rpx solid #b4282d;
+    visibility: visible;
+}
+
+
+.address-list .c{
+    flex: 1;
+    height: auto;
+    overflow: hidden;
+}
+
+.address-list .mobile{
+
+    height: 29rpx;
+    font-size: 29rpx;
+    line-height: 29rpx;
+    overflow: hidden;
+    color: #333;
+    margin-bottom: 6.25rpx;
+}
+
+.address-list .address{
+    height: 37rpx;
+    font-size: 25rpx;
+    line-height: 37rpx;
+    overflow: hidden;
+    color: #666;
+}
+
+.address-list .r{
+    width: 52rpx;
+    height: auto;
+    overflow: hidden;
+    margin-right: 16.5rpx;
+}
+
+.address-list .del{
+    display: block;
+    width: 52rpx;
+    height: 52rpx;
+}
+
+.add-address{
+    background: #b4282d;
+    text-align: center;
+    width: 100%;
+    height: 99rpx;
+    line-height: 99rpx;
+    position: fixed;
+    border-radius: 0;
+    border: none;
+    color: #fff;
+    font-size: 29rpx;
+    bottom: 0;
+    left:0;
+}
+
+.empty-view{
+  height: 100%;
+  width: 100%;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: center;
+}
+
+.empty-view .icon{
+  height: 248rpx;
+  width: 258rpx;
+  margin-bottom: 10rpx;
+}
+
+.empty-view .text{
+  width: auto;
+  font-size: 28rpx;
+  line-height: 35rpx;
+  color: #999;
+}

+ 324 - 0
mini-app/pages/shopping/addressAdd/addressAdd.js

@@ -0,0 +1,324 @@
+var util = require('../../../utils/util.js');
+var api = require('../../../config/api.js');
+var app = getApp();
+Page({
+  data: {
+    address: {
+      id:0,
+      province_id: 0,
+      city_id: 0,
+      district_id: 0,
+      address: '',
+      full_region: '',
+      name: '',
+      mobile: '',
+      is_default: 0
+    },
+    addressId: 0,
+    openSelectRegion: false,
+    selectRegionList: [
+      { id: 0, name: '省份', parent_id: 1, type: 1 },
+      { id: 0, name: '城市', parent_id: 1, type: 2 },
+      { id: 0, name: '区县', parent_id: 1, type: 3 }
+    ],
+    regionType: 1,
+    regionList: [],
+    selectRegionDone: false
+  },
+  bindinputMobile(event) {
+    let address = this.data.address;
+    address.mobile = event.detail.value;
+    this.setData({
+      address: address
+    });
+  },
+  bindinputName(event) {
+    let address = this.data.address;
+    address.name = event.detail.value;
+    this.setData({
+      address: address
+    });
+  },
+  bindinputAddress (event){
+    let address = this.data.address;
+    address.address = event.detail.value;
+    this.setData({
+      address: address
+    });
+  },
+  bindIsDefault(){
+    let address = this.data.address;
+    address.is_default = !address.is_default;
+    this.setData({
+      address: address
+    });
+  },
+  getAddressDetail() {
+    let that = this;
+    util.request(api.AddressDetail, { id: that.data.addressId }).then(function (res) {
+      if (res.errno === 0) {
+        that.setData({
+          address: res.data
+        });
+      }
+    });
+  },
+  setRegionDoneStatus() {
+    let that = this;
+    let doneStatus = that.data.selectRegionList.every(item => {
+      return item.id != 0;
+    });
+
+    that.setData({
+      selectRegionDone: doneStatus
+    })
+
+  },
+  chooseRegion() {
+    let that = this;
+    this.setData({
+      openSelectRegion: !this.data.openSelectRegion
+    });
+
+    //设置区域选择数据
+    let address = this.data.address;
+    if (address.province_id > 0 && address.city_id > 0 && address.district_id > 0) {
+      let selectRegionList = this.data.selectRegionList;
+      selectRegionList[0].id = address.province_id;
+      selectRegionList[0].name = address.province_name;
+      selectRegionList[0].parent_id = 1;
+
+      selectRegionList[1].id = address.city_id;
+      selectRegionList[1].name = address.city_name;
+      selectRegionList[1].parent_id = address.province_id;
+
+      selectRegionList[2].id = address.district_id;
+      selectRegionList[2].name = address.district_name;
+      selectRegionList[2].parent_id = address.city_id;
+
+      this.setData({
+        selectRegionList: selectRegionList,
+        regionType: 3
+      });
+
+      this.getRegionList(address.city_id);
+    } else {
+      this.setData({
+        selectRegionList: [
+          { id: 0, name: '省份', parent_id: 1, type: 1 },
+          { id: 0, name: '城市', parent_id: 1, type: 2 },
+          { id: 0, name: '区县', parent_id: 1, type: 3 }
+        ],
+        regionType: 1
+      })
+      this.getRegionList(1);
+    }
+
+    this.setRegionDoneStatus();
+
+  },
+  onLoad: function (options) {
+    // 页面初始化 options为页面跳转所带来的参数
+    console.log(options)
+    if (options.id) {
+      this.setData({
+        addressId: options.id
+      });
+      this.getAddressDetail();
+    }
+
+    this.getRegionList(1);
+
+  },
+  onReady: function () {
+
+  },
+  selectRegionType(event) {
+    let that = this;
+    let regionTypeIndex = event.target.dataset.regionTypeIndex;
+    let selectRegionList = that.data.selectRegionList;
+
+    //判断是否可点击
+    if (regionTypeIndex + 1 == this.data.regionType || (regionTypeIndex - 1 >= 0 && selectRegionList[regionTypeIndex-1].id <= 0)) {
+      return false;
+    }
+
+    this.setData({
+      regionType: regionTypeIndex + 1
+    })
+    
+    let selectRegionItem = selectRegionList[regionTypeIndex];
+
+    this.getRegionList(selectRegionItem.parent_id);
+
+    this.setRegionDoneStatus();
+
+  },
+  selectRegion(event) {
+    let that = this;
+    let regionIndex = event.target.dataset.regionIndex;
+    let regionItem = this.data.regionList[regionIndex];
+    let regionType = regionItem.type;
+    let selectRegionList = this.data.selectRegionList;
+    selectRegionList[regionType - 1] = regionItem;
+
+
+    if (regionType != 3) {
+      this.setData({
+        selectRegionList: selectRegionList,
+        regionType: regionType + 1
+      })
+      this.getRegionList(regionItem.id);
+    } else {
+      this.setData({
+        selectRegionList: selectRegionList
+      })
+    }
+
+    //重置下级区域为空
+    selectRegionList.map((item, index) => {
+      if (index > regionType - 1) {
+        item.id = 0;
+        item.name = index == 1 ? '城市' : '区县';
+        item.parent_id = 0;
+      }
+      return item;
+    });
+
+    this.setData({
+      selectRegionList: selectRegionList
+    })
+
+
+    that.setData({
+      regionList: that.data.regionList.map(item => {
+
+        //标记已选择的
+        if (that.data.regionType == item.type && that.data.selectRegionList[that.data.regionType - 1].id == item.id) {
+          item.selected = true;
+        } else {
+          item.selected = false;
+        }
+
+        return item;
+      })
+    });
+
+    this.setRegionDoneStatus();
+
+  },
+  doneSelectRegion() {
+    if (this.data.selectRegionDone === false) {
+      return false;
+    }
+
+    let address = this.data.address;
+    let selectRegionList = this.data.selectRegionList;
+    address.province_id = selectRegionList[0].id;
+    address.city_id = selectRegionList[1].id;
+    address.district_id = selectRegionList[2].id;
+    address.province_name = selectRegionList[0].name;
+    address.city_name = selectRegionList[1].name;
+    address.district_name = selectRegionList[2].name;
+    address.full_region = selectRegionList.map(item => {
+      return item.name;
+    }).join('');
+
+    this.setData({
+      address: address,
+      openSelectRegion: false
+    });
+
+  },
+  cancelSelectRegion() {
+    this.setData({
+      openSelectRegion: false,
+      regionType: this.data.regionDoneStatus ? 3 : 1
+    });
+
+  },
+  getRegionList(regionId) {
+    let that = this;
+    let regionType = that.data.regionType;
+    util.request(api.RegionList, { parentId: regionId }).then(function (res) {
+      if (res.errno === 0) {
+        that.setData({
+          regionList: res.data.map(item => {
+
+            //标记已选择的
+            if (regionType == item.type && that.data.selectRegionList[regionType - 1].id == item.id) {
+              item.selected = true;
+            } else {
+              item.selected = false;
+            }
+
+            return item;
+          })
+        });
+      }
+    });
+  },
+  cancelAddress(){
+    wx.reLaunch({
+      url: '/pages/shopping/address/address',
+    })
+  },
+  saveAddress(){
+    console.log(this.data.address)
+    let address = this.data.address;
+
+    if (address.name == '') {
+      util.showErrorToast('请输入姓名');
+
+      return false;
+    }
+
+    if (address.mobile == '') {
+      util.showErrorToast('请输入手机号码');
+      return false;
+    }
+
+
+    if (address.district_id == 0) {
+      util.showErrorToast('请输入省市区');
+      return false;
+    }
+
+    if (address.address == '') {
+      util.showErrorToast('请输入详细地址');
+      return false;
+    }
+
+
+    let that = this;
+    util.request(api.AddressSave, { 
+      id: address.id,
+      name: address.name,
+      mobile: address.mobile,
+      province_id: address.province_id,
+      city_id: address.city_id,
+      district_id: address.district_id,
+      address: address.address,
+      is_default: address.is_default,
+    }, 'POST').then(function (res) {
+      if (res.errno === 0) {
+        wx.reLaunch({
+          url: '/pages/shopping/address/address',
+        })
+      }
+    });
+
+  },
+  onShow: function () {
+    // 页面显示
+
+  },
+  onHide: function () {
+    // 页面隐藏
+
+  },
+  onUnload: function () {
+    // 页面关闭
+
+  }
+})

+ 3 - 0
mini-app/pages/shopping/addressAdd/addressAdd.json

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

+ 39 - 0
mini-app/pages/shopping/addressAdd/addressAdd.wxml

@@ -0,0 +1,39 @@
+<view class="add-address">
+    <view class="add-form">
+        <view class="form-item">
+            <input class="input" bindinput="bindinputName" placeholder="姓名" value="{{address.name}}" auto-focus/>
+        </view>
+        <view class="form-item">
+            <input class="input" bindinput="bindinputMobile" value="{{address.mobile}}" placeholder="手机号码"/>
+        </view>
+        <view class="form-item">
+            <input class="input" value="{{address.full_region}}" disabled="true" bindtap="chooseRegion" placeholder="省份、城市、区县"/>
+        </view>
+        <view class="form-item">
+            <input class="input" bindinput="bindinputAddress" value="{{address.address}}" placeholder="详细地址, 如街道、楼盘号等"/>
+        </view>
+        <view class="form-default">
+            <text bindtap="bindIsDefault" class="default-input {{address.is_default == 1 ? 'selected' : ''}}">设为默认地址</text>
+        </view>
+    </view>
+
+    <view class="btns">
+        <button class="cannel" bindtap="cancelAddress">取消</button>
+        <button class="save" bindtap="saveAddress">保存</button>
+    </view>
+
+    <view class="region-select" wx:if="{{openSelectRegion}}">
+      <view class="hd">
+        <view class="region-selected">
+          <view class="item {{item.id == 0 ? 'disabled' : ''}} {{(regionType -1) === index ? 'selected' : ''}}" bindtap="selectRegionType" data-region-type-index="{{index}}" wx:for="{{selectRegionList}}" wx:key="{{item.id}}">{{item.name}}</view>
+        </view>
+        <view class="done {{selectRegionDone ? '' : 'disabled'}}" bindtap="doneSelectRegion">确定</view>
+      </view>
+      <view class="bd">
+        <view class="region-list">
+          <view class="item {{item.selected ? 'selected' : ''}}" bindtap="selectRegion" data-region-index="{{index}}" wx:for="{{regionList}}" wx:key="{{item.id}}">{{item.name}}</view>
+        </view>
+      </view>
+    </view>
+</view>
+<view class="bg-mask" bindtap="cancelSelectRegion" wx:if="{{openSelectRegion}}"></view>

+ 179 - 0
mini-app/pages/shopping/addressAdd/addressAdd.wxss

@@ -0,0 +1,179 @@
+page{
+    height: 100%;
+    background: #f4f4f4;
+}
+.add-address .add-form{
+    background: #fff;
+    width: 100%;
+    height: auto;
+    overflow: hidden;
+}
+
+.add-address .form-item{
+    height: 116rpx;
+    padding-left: 31.25rpx;
+    border-bottom: 1px solid #d9d9d9;
+    display: flex;
+    align-items: center;
+    padding-right: 31.25rpx;
+}
+
+.add-address .input{
+    flex: 1;
+    height: 44rpx;
+    line-height: 44rpx;
+    overflow: hidden;
+}
+
+.add-address .form-default{
+    border-bottom: 1px solid #d9d9d9;
+    height: 96rpx;
+    background: #fafafa;
+    padding-top: 28rpx;
+    font-size: 28rpx;
+}
+
+.default-input{
+    margin: 0 auto;
+    display: block;
+    width: 240rpx;
+    height: 40rpx;
+    padding-left: 50rpx;
+    line-height: 40rpx;
+    background: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/sprites/checkbox-sed825af9d3-a6b8540d42.png) 1rpx -448rpx no-repeat;
+    background-size: 38rpx 486rpx;
+    font-size: 28rpx;
+}
+
+.default-input.selected{
+    background: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/sprites/checkbox-sed825af9d3-a6b8540d42.png) 0 -192rpx no-repeat;
+    background-size: 38rpx 486rpx;
+}
+
+.add-address .btns{
+    position: fixed;
+    bottom: 0;
+    left: 0;
+    overflow: hidden;
+    display: flex;
+    height: 100rpx;
+    width: 100%;
+}
+
+.add-address .cannel,.add-address .save{
+    flex: 1;
+    height: 100rpx;
+    text-align: center;
+    line-height: 100rpx;
+    font-size: 28rpx;
+    color: #fff;
+    border:none;
+    border-radius: 0;
+}
+
+.add-address .cannel{
+    background: #333;
+}
+
+.add-address .save{
+    background: #b4282d;
+}
+
+
+.region-select{
+  width: 100%;
+  height: 600rpx;
+  background: #fff;
+  position: fixed;
+  z-index: 10;
+  left:0;
+  bottom: 0;
+}
+
+.region-select .hd{
+  height: 108rpx;
+  width: 100%;
+  border-bottom: 1px solid #f4f4f4;
+  padding: 46rpx 30rpx 0 30rpx;
+}
+
+.region-select .region-selected{
+  float: left;
+  height: 60rpx;
+  display: flex;
+}
+
+.region-select .region-selected .item{
+  max-width: 140rpx;
+  margin-right: 30rpx;
+  text-align: left;
+  line-height: 60rpx;
+  height: 100%;
+  color: #333;
+  font-size: 28rpx;
+  overflow: hidden;
+      text-overflow: ellipsis;
+    white-space: nowrap;
+}
+
+.region-select .region-selected .item.disabled{
+  color: #999;
+}
+
+.region-select .region-selected .item.selected{
+  color: #b4282d;
+}
+
+.region-select .done{
+  float: right;
+  height: 60rpx;
+  width: 60rpx;
+  border: none;
+  background: #fff;
+  line-height: 60rpx;
+  text-align: center;
+  color: #333;
+  font-size: 28rpx;
+}
+
+.region-select .done.disabled{
+  color: #999;
+}
+
+
+
+.region-select .bd{
+  height: 492rpx;
+  width: 100%;
+  padding: 0 30rpx;
+}
+
+.region-select .region-list{
+  height: auto;
+  overflow: scroll;
+
+}
+
+.region-select .region-list .item{
+  width: 100%;
+  height: 104rpx;
+  line-height: 104rpx;
+  text-align: left;
+  color: #333;
+  font-size: 28rpx;
+}
+
+.region-select .region-list .item.selected{
+  color: #b4282d;
+}
+
+
+.bg-mask{
+  height: 100%;
+  width: 100%;
+  background: rgba(0, 0, 0, 0.4);
+  position: fixed;
+  top:0;
+  left:0;
+  z-index: 8;
+}

+ 117 - 0
mini-app/pages/shopping/checkout/checkout.js

@@ -0,0 +1,117 @@
+var util = require('../../../utils/util.js');
+var api = require('../../../config/api.js');
+const pay = require('../../../services/pay.js');
+
+var app = getApp();
+
+Page({
+  data: {
+    checkedGoodsList: [],
+    checkedAddress: {},
+    checkedCoupon: [],
+    couponList: [],
+    goodsTotalPrice: 0.00, //商品总价
+    freightPrice: 0.00,    //快递费
+    couponPrice: 0.00,     //优惠券的价格
+    orderTotalPrice: 0.00,  //订单总价
+    actualPrice: 0.00,     //实际需要支付的总价
+    addressId: 0,
+    couponId: 0
+  },
+  onLoad: function (options) {
+
+    // 页面初始化 options为页面跳转所带来的参数
+
+    try {
+      var addressId = wx.getStorageSync('addressId');
+      if (addressId) {
+        this.setData({
+          'addressId': addressId
+        });
+      }
+
+      var couponId = wx.getStorageSync('couponId');
+      if (couponId) {
+        this.setData({
+          'couponId': couponId
+        });
+      }
+    } catch (e) {
+      // Do something when catch error
+    }
+
+
+  },
+  getCheckoutInfo: function () {
+    let that = this;
+    util.request(api.CartCheckout, { addressId: that.data.addressId, couponId: that.data.couponId }).then(function (res) {
+      if (res.errno === 0) {
+        console.log(res.data);
+        that.setData({
+          checkedGoodsList: res.data.checkedGoodsList,
+          checkedAddress: res.data.checkedAddress,
+          actualPrice: res.data.actualPrice,
+          checkedCoupon: res.data.checkedCoupon,
+          couponList: res.data.couponList,
+          couponPrice: res.data.couponPrice,
+          freightPrice: res.data.freightPrice,
+          goodsTotalPrice: res.data.goodsTotalPrice,
+          orderTotalPrice: res.data.orderTotalPrice
+        });
+      }
+      wx.hideLoading();
+    });
+  },
+  selectAddress() {
+    wx.navigateTo({
+      url: '/pages/shopping/address/address',
+    })
+  },
+  addAddress() {
+    wx.navigateTo({
+      url: '/pages/shopping/addressAdd/addressAdd',
+    })
+  },
+  onReady: function () {
+    // 页面渲染完成
+
+  },
+  onShow: function () {
+    // 页面显示
+    wx.showLoading({
+      title: '加载中...',
+    })
+    this.getCheckoutInfo();
+
+  },
+  onHide: function () {
+    // 页面隐藏
+
+  },
+  onUnload: function () {
+    // 页面关闭
+
+  },
+  submitOrder: function () {
+    if (this.data.addressId <= 0) {
+      util.showErrorToast('请选择收货地址');
+      return false;
+    }
+    util.request(api.OrderSubmit, { addressId: this.data.addressId, couponId: this.data.couponId }, 'POST').then(res => {
+      if (res.errno === 0) {
+        const orderId = res.data.orderInfo.id;
+        pay.payOrder(parseInt(orderId)).then(res => {
+          wx.redirectTo({
+            url: '/pages/payResult/payResult?status=1&orderId=' + orderId
+          });
+        }).catch(res => {
+          wx.redirectTo({
+            url: '/pages/payResult/payResult?status=0&orderId=' + orderId
+          });
+        });
+      } else {
+        util.showErrorToast('下单失败');
+      }
+    });
+  }
+})

+ 3 - 0
mini-app/pages/shopping/checkout/checkout.json

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

+ 85 - 0
mini-app/pages/shopping/checkout/checkout.wxml

@@ -0,0 +1,85 @@
+<view class="container">
+    <view class="address-box">
+        <view class="address-item" bindtap="selectAddress" wx:if="{{checkedAddress.id > 0}}">
+            <view class="l">
+                <text class="name">{{checkedAddress.name}}</text>
+                <text class="default" wx:if="{{checkedAddress.is_default === 1}}">默认</text>
+            </view>
+            <view class="m">
+                <text class="mobile">{{checkedAddress.mobile}}</text>
+                <text class="address">{{checkedAddress.full_region + checkedAddress.address}}</text>
+            </view>
+            <view class="r">
+                <image src="/static/images/address_right.png"></image>
+            </view>
+        </view>
+        <view class="address-item address-empty" bindtap="addAddress" wx:if="{{checkedAddress.id <= 0}}">
+            <view class="m">
+               还没有收货地址,去添加
+            </view>
+            <view class="r">
+                <image src="/static/images/address_right.png"></image>
+            </view>
+        </view>
+    </view>
+
+    <view class="coupon-box">
+        <view class="coupon-item">
+            <view class="l">
+                <text class="name">请选择优惠券</text>
+                <text class="txt">{{couponList.length}}张</text>
+            </view>
+            <view class="r">
+                <image src="/static/images/address_right.png"></image>
+            </view>
+        </view>
+    </view>
+
+    <view class="order-box">
+        <view class="order-item">
+            <view class="l">
+                <text class="name">商品合计</text>
+            </view>
+            <view class="r">
+                <text class="txt">¥{{goodsTotalPrice}}</text>
+            </view>
+        </view>
+        <view class="order-item">
+            <view class="l">
+                <text class="name">运费</text>
+            </view>
+            <view class="r">
+                <text class="txt">¥{{freightPrice}}</text>
+            </view>
+        </view>
+        <view class="order-item no-border">
+            <view class="l">
+                <text class="name">优惠券</text>
+            </view>
+            <view class="r">
+                <text class="txt">-¥{{couponPrice}}</text>
+            </view>
+        </view>
+    </view>
+
+    <view class="goods-items">
+        <view class="item" wx:for="{{checkedGoodsList}}" wx:key="{{item.id}}">
+            <view class="img">
+                <image src="{{item.list_pic_url}}"></image>
+            </view>
+            <view class="info">
+                <view class="t">
+                    <text class="name">{{item.goods_name}}</text>
+                    <text class="number">x{{item.number}}</text>
+                </view>
+                <view class="m">{{item.goods_specifition_name_value}}</view>
+                <view class="b">¥{{item.retail_price}}</view>
+            </view>
+        </view>
+    </view>
+
+    <view class="order-total">
+        <view class="l">实付:¥{{actualPrice}}</view>
+        <view class="r" bindtap="submitOrder">去付款</view>
+    </view>
+</view>

+ 295 - 0
mini-app/pages/shopping/checkout/checkout.wxss

@@ -0,0 +1,295 @@
+page{
+    height: 100%;
+    background: #f4f4f4;
+}
+
+.address-box{
+    width: 100%;
+    height: 166.55rpx;
+    background: url('http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/address-bg-bd30f2bfeb.png') 0 0 repeat-x;
+    background-size: 62.5rpx 10.5rpx;
+    margin-bottom: 20rpx;
+    padding-top: 10.5rpx;
+}
+
+.address-item{
+    display: flex;
+    height: 155.55rpx;
+    background: #fff;
+    padding: 41.6rpx 0 41.6rpx 31.25rpx;
+}
+
+.address-item.address-empty{
+  line-height: 75rpx;
+  text-align: center;
+}
+
+.address-box .l{
+    width: 125rpx;
+    height: 100%;
+}
+
+.address-box .l .name{
+    margin-left: 6.25rpx;
+    margin-top: -7.25rpx;
+    display: block;
+    width: 125rpx;
+    height: 43rpx;
+    line-height: 43rpx;
+    font-size: 30rpx;
+    color: #333;
+    margin-bottom: 5rpx;
+
+}
+
+.address-box .l .default{
+    margin-left: 6.25rpx;
+    display: block;
+    width: 62rpx;
+    height: 33rpx;
+    border-radius: 5rpx;
+    border: 1px solid #b4282d;
+    font-size: 20.5rpx;
+    text-align: center;
+    line-height: 29rpx;
+    color: #b4282d;
+}
+
+.address-box .m{
+    flex: 1;
+    height: 72.25rpx;
+    color: #999;
+}
+
+.address-box .mobile{
+    display: block;
+    height: 29rpx;
+    line-height: 29rpx;
+    margin-bottom: 6.25rpx;
+    font-size: 30rpx;
+    color:#333;
+}
+
+.address-box .address{
+    display: block;
+    height: 37.5rpx;
+    line-height: 37.5rpx;
+    font-size: 25rpx;
+    color:#666;
+}
+
+.address-box .r{
+    width: 77rpx;
+    height: 77rpx;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+}
+
+.address-box .r image{
+    width: 52.078rpx;
+    height: 52.078rpx;
+}
+
+.coupon-box{
+    width: 100%;
+    height: auto;
+    overflow: hidden;
+    background: #fff;
+}
+
+.coupon-box .coupon-item{
+    width: 100%;
+    height: 108.3rpx;
+    overflow: hidden;
+    background: #fff;
+    display: flex;
+    padding-left: 31.25rpx;
+}
+
+.coupon-box .l{
+    flex: 1;
+    height: 43rpx;
+    line-height: 43rpx;
+    padding-top: 35rpx;
+}
+
+.coupon-box .l .name{
+    float: left;
+    font-size: 30rpx;
+    color: #666;
+}
+
+.coupon-box .l .txt{
+    float: right;
+    font-size: 30rpx;
+    color: #666;
+}
+
+.coupon-box .r{
+    margin-top: 15.5rpx;
+    width: 77rpx;
+    height: 77rpx;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+}
+
+.coupon-box .r image{
+    width: 52.078rpx;
+    height: 52.078rpx;
+}
+
+.order-box{
+    margin-top: 20rpx;
+    width: 100%;
+    height: auto;
+    overflow: hidden;
+    background: #fff;
+}
+
+.order-box .order-item{
+    height: 104.3rpx;
+    overflow: hidden;
+    background: #fff;
+    display: flex;
+    margin-left: 31.25rpx;
+    padding-right: 31.25rpx;
+    padding-top: 26rpx;
+    border-bottom: 1px solid #d9d9d9;
+}
+
+.order-box .order-item .l{
+    float: left;
+    height: 52rpx;
+    width: 50%;
+    line-height: 52rpx;
+    overflow: hidden;
+}
+
+.order-box .order-item .r{
+    float: right;
+    text-align: right;
+    width: 50%;
+    height: 52rpx;
+    line-height: 52rpx;
+    overflow: hidden;
+}
+
+.order-box .order-item.no-border{
+    border-bottom: none;
+}
+
+.goods-items{
+    margin-top: 20rpx;
+    width: 100%;
+    height: auto;
+    overflow: hidden;
+    background: #fff;
+    padding-left: 31.25rpx;
+    margin-bottom: 120rpx;
+}
+
+.goods-items .item{
+    height: 192rpx;
+    padding-right: 31.25rpx;
+    display: flex;
+    align-items: center;
+    border-bottom: 1px solid rgba(0,0,0,0.15);
+}
+
+.goods-items .item.no-border{
+    border-bottom: none;
+}
+
+
+.goods-items .item:last-child{
+    border-bottom: none;
+}
+
+.goods-items .img{
+    height: 145.83rpx;
+    width: 145.83rpx;
+    background-color: #f4f4f4;
+    margin-right: 20rpx;
+}
+
+.goods-items .img image{
+    height: 145.83rpx;
+    width: 145.83rpx;
+}
+
+.goods-items .info{
+    flex: 1;
+    height: 145.83rpx;
+    padding-top: 5rpx;
+}
+
+.goods-items .t{
+    height:  33rpx;
+    line-height: 33rpx;
+    margin-bottom: 10rpx;
+    overflow: hidden;
+    font-size: 30rpx;
+    color: #333;
+}
+
+.goods-items .t .name{
+    display: block;
+    float: left;
+}
+
+.goods-items .t .number{
+    display: block;
+    float: right;
+    text-align: right;
+}
+
+.goods-items .m {
+    height:  29rpx;
+    overflow: hidden;
+    line-height: 29rpx;
+    margin-bottom: 25rpx;
+    font-size: 25rpx;
+    color: #666;
+}
+
+.goods-items .b {
+    height:  41rpx;
+    overflow: hidden;
+    line-height: 41rpx;
+    font-size: 30rpx;
+    color: #333;
+}
+
+.order-total{
+    position: fixed;
+    left:0;
+    bottom: 0;
+    height: 100rpx;
+    width: 100%;
+    display: flex;
+}
+
+.order-total .l{
+    flex: 1;
+    height: 100rpx;
+    line-height: 100rpx;
+    color: #b4282d;
+    background: #fff;
+    font-size: 33rpx;
+    padding-left: 31.25rpx;
+    border-top: 1rpx solid rgba(0,0,0,0.2);
+    border-bottom: 1rpx solid rgba(0,0,0,0.2);
+}
+
+.order-total .r{
+    width: 233rpx;
+    height: 100rpx;
+    background: #b4282d;
+    border: 1px solid #b4282d;
+    line-height: 100rpx;
+    text-align: center;
+    color: #fff;
+    font-size: 30rpx;
+}

+ 86 - 0
mini-app/pages/topic/topic.js

@@ -0,0 +1,86 @@
+var util = require('../../utils/util.js');
+var api = require('../../config/api.js');
+var app = getApp()
+Page({
+    data: {
+        // text:"这是一个页面"
+        topicList: [],
+        page: 1,
+        size: 10,
+        count: 0,
+        scrollTop: 0,
+        showPage: false
+    },
+    onLoad: function (options) {
+        // 页面初始化 options为页面跳转所带来的参数
+        this.getTopic();
+
+    },
+    onReady: function () {
+        // 页面渲染完成
+    },
+    onShow: function () {
+        // 页面显示
+    },
+    onHide: function () {
+        // 页面隐藏
+    },
+    onUnload: function () {
+        // 页面关闭
+    },
+    nextPage: function (event) {
+      console.log();
+        var that = this;
+        if (this.data.page+1 > that.data.count / that.data.size) {
+            return true;
+        }
+
+        
+        that.setData({
+            "page": parseInt(that.data.page) + 1
+        });
+
+        this.getTopic();
+        
+    },
+    getTopic: function(){
+       
+        let that = this;
+         that.setData({
+            scrollTop: 0,
+            showPage: false,
+            topicList: []
+        });
+        // 页面渲染完成
+        wx.showToast({
+            title: '加载中...',
+            icon: 'loading',
+            duration: 2000
+        });
+
+        util.request(api.TopicList, { page: that.data.page, size: that.data.size }).then(function (res) {
+          if (res.errno === 0) {
+
+            that.setData({
+              scrollTop: 0,
+              topicList: res.data.data,
+              showPage: true,
+              count: res.data.count
+            });
+          }
+          wx.hideToast();
+        });
+        
+    },
+    prevPage: function (event) {
+        if (this.data.page <= 1) {
+            return false;
+        }
+
+        var that = this;
+        that.setData({
+            "page": parseInt(that.data.page) - 1
+        });
+        this.getTopic();
+    }
+})

+ 1 - 0
mini-app/pages/topic/topic.json

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

+ 16 - 0
mini-app/pages/topic/topic.wxml

@@ -0,0 +1,16 @@
+<view class="container">
+    <scroll-view class="topic-list" scroll-y="true" scroll-top="{{scrollTop}}">
+        <navigator class="item" wx:for="{{topicList}}" wx:key="{{item.id}}" url="../topicDetail/topicDetail?id={{item.id}}">
+            <image class="img" src="{{item.scene_pic_url}}"></image>
+            <view class="info">
+                <text class="title">{{item.title}}</text>
+                <text class="desc">{{item.subtitle}}</text>
+                <text class="price">{{item.price_info}}元起</text>
+            </view>
+        </navigator>
+        <view class="page" wx:if="{{showPage}}">
+            <view class="prev {{ page <= 1 ? 'disabled' : ''}}" bindtap="prevPage">上一页</view>
+            <view class="next {{ (count / size) < page +1 ? 'disabled' : ''}}" bindtap="nextPage">下一页</view>
+        </view>
+    </scroll-view>
+</view>

+ 94 - 0
mini-app/pages/topic/topic.wxss

@@ -0,0 +1,94 @@
+page ,.container{
+   width: 750rpx;
+    height: 100%;
+    overflow: hidden;
+    background: #f4f4f4;
+}
+.topic-list{
+    width: 750rpx;
+    height: 100%;
+    overflow: hidden;
+    background: #f4f4f4;
+}
+
+.topic-list .item{
+    width: 100%;
+    height: 625rpx;
+    overflow: hidden;
+    background: #fff;
+    margin-bottom: 20rpx;
+}
+
+.topic-list .img{
+    width: 100%;
+    height: 415rpx;
+}
+
+.topic-list .info{
+    width: 100%;
+    height: 210rpx;
+    overflow: hidden;
+}
+
+.topic-list .title{
+    display: block;
+    text-align: center;
+    width: 100%;
+    height: 33rpx;
+    line-height: 35rpx;
+    color: #333;
+    overflow: hidden;
+    font-size: 35rpx;
+    margin-top: 30rpx;
+}
+
+.topic-list .desc{
+    display: block;
+    text-align: center;
+    position: relative;
+    width: auto;
+    height: 24rpx;
+    line-height: 24rpx;
+    overflow: hidden;
+    color: #999;
+    font-size: 24rpx;
+    margin-top: 16rpx;
+    margin-bottom: 30rpx;
+}
+
+.topic-list .price{
+    display: block;
+    text-align: center;
+    width: 100%;
+    height: 27rpx;
+    line-height: 27rpx;
+    overflow: hidden;
+    color: #b4282d;
+    font-size: 27rpx;
+}
+
+
+.page{
+    width: 750rpx;
+    height: 108rpx;
+    background: #fff;
+    margin-bottom: 20rpx;
+}
+
+.page view{
+    height: 108rpx;
+    width: 50%;
+    float: left;
+    font-size: 29rpx;
+    color: #333;
+    text-align: center;
+    line-height: 108rpx;
+}
+
+.page .prev{
+    border-right: 1px solid #D9D9D9;
+}
+
+.page .disabled{
+    color: #ccc;
+}

+ 116 - 0
mini-app/pages/topicComment/topicComment.js

@@ -0,0 +1,116 @@
+var app = getApp();
+var util = require('../../utils/util.js');
+
+var api = require('../../config/api.js');
+
+Page({
+  data: {
+    comments: [],
+    allCommentList: [],
+    picCommentList: [],
+    typeId: 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, typeId: that.data.typeId}).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, 
+      typeId: that.data.typeId, 
+      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({
+      typeId: options.typeId,
+      valueId: options.valueId
+    });
+    this.getCommentCount();
+    this.getCommentList();
+  },
+  onReady: function () {
+    // 页面渲染完成
+
+  },
+  onShow: function () {
+    // 页面显示
+
+  },
+  onHide: function () {
+    // 页面隐藏
+
+  },
+  onUnload: function () {
+    // 页面关闭
+
+  },
+  switchTab: function () {
+    this.setData({
+      showType: this.data.showType == 1 ? 0 :1
+    });
+
+    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();
+  }
+})

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác