zhashaonan il y a 7 ans
Parent
commit
9c9c7c2c95

+ 2 - 1
app.json

@@ -8,7 +8,8 @@
     "pages/details/details",
     "pages/webView/webView",
     "pages/special/special",
-    "pages/brand/brand"
+    "pages/brand/brand",
+    "pages/comments/comments"
   ],
   "window": {
     "backgroundTextStyle": "dark",

+ 15 - 1
app.wxss

@@ -69,7 +69,7 @@ body {
   position: relative;
 }
 
-.vux-1px-b:after {
+.vux-1px-b::after {
   content: " ";
   position: absolute;
   left: 0;
@@ -83,3 +83,17 @@ body {
   -webkit-transform: scaleY(0.5);
   transform: scaleY(0.5);
 }
+.comment-1px-b::after {
+  content: " ";
+  position: absolute;
+  left: 24rpx;
+  bottom: 0;
+  right: 0;
+  height: 1px;
+  border-bottom: 1px solid #c7c7c7;
+  color: #c7c7c7;
+  -webkit-transform-origin: 0 100%;
+  transform-origin: 0 100%;
+  -webkit-transform: scaleY(0.5);
+  transform: scaleY(0.5);
+}

+ 116 - 0
pages/comments/comments.js

@@ -0,0 +1,116 @@
+// pages/comments/comments.js
+const getReq = require('./../../config.js').getReq
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    comments: [],
+    hasmore: '',
+    curpage: 1,
+    common_id: '',
+    addtimes: []
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    this.setData({
+      common_id: options.common_id
+    })
+    this.getDatas(options.common_id, this.data.curpage)
+  },
+  getDatas(common_id, curpage) {
+    wx.showLoading({
+      title: '加载中'
+    })
+    var self = this
+    getReq({
+      act: 'goods_common',
+      op: 'comments',
+      goods_commonid: 3398,
+      curpage,
+      page: 10
+    }, function (res) {
+      if (res.code == 200) {
+        wx.hideLoading()
+        self.getAddTimes(res.datas.comments)
+        self.setData({
+          comments: self.data.comments.concat(res.datas.comments),
+          hasmore: res.datas.mobile_page.hasmore
+        })
+      }
+    })
+  },
+  getAddTimes(comments) {
+    let arr = []
+    comments.map(item => {
+      let addtime = item.addtime || ''
+      if (addtime) {
+        let date = new Date(addtime * 1000);
+        let year = date.getFullYear();
+        let month = date.getMonth() + 1;
+        let day = date.getDate();
+        addtime = `${year}.${month}.${day}`
+      }
+      arr.push(addtime)
+    })
+    this.setData({
+      addtimes: this.data.addtimes.concat(arr)
+    })
+  },
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+    if (!this.data.hasmore) {
+      return
+    }
+    this.data.curpage++
+    this.getDatas(3398, this.data.curpage)
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 1 - 0
pages/comments/comments.json

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

+ 23 - 0
pages/comments/comments.wxml

@@ -0,0 +1,23 @@
+<!--pages/comments/comments.wxml-->
+<view>
+  <view class="comment comment-1px-b" wx:for="{{comments}}" wx:for-index="index" wx:key="index">
+    <view class="user">
+      <view class="member_avatar f_left">
+         <image src="{{item.member_avatar}}">
+        </image> 
+      </view>
+      <view class="f28 f_left">{{item.nickname}}</view>
+       <view class="scores f_right">
+         <view class="flex-stars">
+          <image wx:for="{{item.scores}}" wx:for-index="idx" wx:key="idx" class="star" src="../../../../image/star.png"></image>
+        </view> 
+         <view class="comment_time">{{addtimes[index]}}</view> 
+      </view> 
+    </view>
+    <view class="spec">规格:{{item.goods_spec}}</view>
+    <view class="content">{{item.content}}</view>
+    <view wx:if="{{item.images.length}}">
+      <image class="content_img" mode="widthFix" src="{{item}}" wx:for="{{item.images}}" wx:for-index="imgIndex" wx:key="imgIndex"></image>
+    </view>
+  </view>
+</view>

+ 9 - 0
pages/comments/comments.wxss

@@ -0,0 +1,9 @@
+/* pages/comments/comments.wxss */
+@import "../details/details.wxss";
+.content_img {
+  display: inline-block;
+  width: 116rpx;
+  margin-left: 24rpx;
+  margin-bottom: 24rpx;
+  vertical-align: middle
+}

+ 11 - 6
pages/details/details.js

@@ -22,10 +22,13 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    let webViewUrl = `https://passport.lrlz.com/mobile/index.php?act=goods_common&op=detail&goods_id=${options.goods_id}&client_type=ios`
+    this.setData({
+      webViewUrl
+    })
     this.getDatas(options.goods_id)
   },
   getDatas(goods_id) {
-    let webViewUrl = `https://passport.lrlz.com/mobile/index.php?act=goods_common&op=detail&goods_id=${goods_id}&client_type=ios`
     var self = this
     getReq({
       act: 'goods_common',
@@ -33,25 +36,27 @@ Page({
       goods_id
     }, function (res) {
       if (res.code == 200) {
-        console.log(res)
         let getOneSummary = res.datas.summary.filter((item, index) => {
           return item.goods_id == goods_id
         })
         console.log('---')
-        
-        console.log(res.datas.common_info.attrs)
         console.log(getOneSummary[0])
 
         self.setData({
           datas: res.datas,
           getOneSummary: getOneSummary[0],
-          imgUrls: res.datas.common_info.images,
-          webViewUrl
+          imgUrls: res.datas.common_info.images
         })
         
       }
     })
   },
+  toWebView() {
+    let webViewUrl = encodeURIComponent(this.data.webViewUrl)
+    wx.navigateTo({
+      url: `/pages/webView/webView?url=${webViewUrl}`
+    })
+  },
 
   /**
    * 生命周期函数--监听页面初次渲染完成

+ 6 - 4
pages/details/details.wxml

@@ -29,8 +29,8 @@
     </view>
 
     <view class="goods_desc">
-      <text wx:if="{{getOneSummary['act_type'] == 0}}" decode="{{true}}" style="display:inline">红包抵{{getOneSummary.goods_price - getOneSummary.bonus_price}}元&nbsp;/</text>
-      <text decode="{{true}}" style="display:inline">已售{{getOneSummary.goods_salenum}}件&nbsp;/&nbsp;库存{{getOneSummary.goods_storage}}件</text>
+      <text wx:if="{{getOneSummary['act_type'] == 0}}" decode="{{true}}">红包抵{{getOneSummary.goods_price - getOneSummary.bonus_price}}元&nbsp;/</text>
+      <text decode="{{true}}">已售{{getOneSummary.goods_salenum}}件&nbsp;/&nbsp;库存{{getOneSummary.goods_storage}}件</text>
     </view>
   </view>
 
@@ -60,7 +60,9 @@
     <view>用户评价
       <text class="colef524d">({{datas.common_info.comments}})</text>
     </view>
-    <view class="f24">查看全部评论 > </view>
+    <navigator url="/pages/comments/comments?common_id={{datas.comment.common_id}}">
+         <view class="f24">查看全部评论 > </view>
+      </navigator>
   </view>
 
   <view class="comment">
@@ -96,5 +98,5 @@
   </view>
 
   <view class="place-bac247"></view>
-
+  <button style="width: 60%;" type="primary" plain="true" bindtap="toWebView">查看更多详情</button>
 </view>

+ 13 - 6
pages/details/details.wxss

@@ -18,15 +18,17 @@
   font-size: 24rpx;
 }
 
- .comment_content {
+.comment_content {
   max-width: 220rpx;
   display: inline-block;
   vertical-align: middle;
-} 
+}
+
 .nickname {
   display: inline-block;
   vertical-align: middle;
 }
+
 .comment_swiper image {
   width: 40rpx;
   height: 40rpx;
@@ -79,13 +81,13 @@
 
 .goods_desc {
   font-size: 24rpx;
-   display: -webkit-box;
+  display: -webkit-box;
   -webkit-box-orient: vertical;
   -webkit-line-clamp: 2;
   overflow: hidden;
   color: #7e7e7e;
   min-height: 56rpx;
-  line-height: 28rpx; 
+  line-height: 28rpx;
 }
 
 .congratulation_text {
@@ -181,6 +183,7 @@
   overflow: hidden;
   margin-bottom: 18rpx;
   padding: 0 24rpx;
+  line-height: 1.6;
 }
 
 .member_avatar {
@@ -194,13 +197,17 @@
   display: block;
 }
 
+.flex-stars {
+  display: flex;
+  align-items: center;
+  height: 44rpx;
+}
+
 .star {
   display: inline-block;
   width: 24rpx;
   height: 24rpx;
   margin-left: 4rpx;
-  /* background: url(../../image/star.png) no-repeat center;
-  background-size: contain; */
   vertical-align: middle;
 }
 

+ 11 - 5
project.config.json

@@ -21,22 +21,28 @@
 			"current": -1,
 			"list": []
 		},
-		"plugin": {
-			"current": -1,
-			"list": []
-		},
 		"game": {
 			"currentL": -1,
 			"list": []
 		},
-		"miniprogram": {
+		"plugin": {
 			"current": -1,
+			"list": []
+		},
+		"miniprogram": {
+			"current": 1,
 			"list": [
 				{
 					"id": 0,
 					"name": "details",
 					"pathName": "pages/details/details",
 					"query": ""
+				},
+				{
+					"id": 1,
+					"name": "comments",
+					"pathName": "pages/comments/comments",
+					"query": ""
 				}
 			]
 		}