Browse Source

Fixed bug on phone

Z1hgq 7 năm trước cách đây
mục cha
commit
279ddce126

BIN
Furniture/images/like.png


BIN
Furniture/images/like1.png


BIN
Furniture/images/no.png


BIN
Furniture/images/no1.png


BIN
Furniture/images/normal.png


BIN
Furniture/images/normal1.png


BIN
Furniture/images/展开全文按钮.png


BIN
Furniture/images/已赞.png


BIN
Furniture/images/赞.png


BIN
Furniture/images/赞1.png


+ 272 - 26
Furniture/page/homePage/detail/conment/conment.js

xqd
@@ -1,78 +1,324 @@
 // page/homePage/detail/conment/conment.js
+const app = getApp()
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-    zan:false
+    next_page_url: '',
+    newsid: '',
+    reply_id: 0,
+    reply_content: '',
+    replys: []
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
-  onLoad: function (options) {
-  
+  onLoad: function(options) {
+    var id = options.id
+    var newsid = options.newsid
+    var that = this
+    that.setData({
+      reply_id: id,
+      newsid: newsid
+    })
+    app.request({
+      url: 'https://t6.9026.com/api/furniture/getmorecomments',
+      data: {
+        store_id: 1,
+        id: id
+      },
+      method: 'get',
+      success: function(res) {
+        console.log(res.data)
+        that.setData({
+          next_page_url: res.data.data.comments_replys.next_page_url,
+          comments: res.data.data.comments,
+          comments_replys: res.data.data.comments_replys,
+          replys: res.data.data.comments_replys.data,
+        })
+        var c = that.data.replys
+        for (var i = 0; i < c.length; i++) {
+          console.log(c[i].created_at)
+          var d = new Date(c[i].created_at).getTime()
+          var n = new Date().getTime()
+          var t = n - d
+          if (t < 60000) {
+            var x = Math.round(t / 1000)
+            c[i].created_at = '' + x + '秒前'
+          } else if (t >= 60000 && t < 3600000) {
+            var x = Math.round(t / 60000)
+            c[i].created_at = '' + x + '分钟前'
+          } else if (t >= 3600000 && t < 86400000) {
+            var x = Math.round(t / 3600000)
+            c[i].created_at = '' + x + '小时前'
+          } else if (t >= 86400000 && t < 86400000 * 3) {
+            var x = Math.round(t / 86400000)
+            c[i].created_at = '' + x + '天前'
+          } else {
+            var e = new Date(d)
+            var x = '' + e.getFullYear() + '-' + (e.getMonth() + 1) + '-' + e.getDate()
+            c[i].created_at = '' + x
+          }
+        }
+        that.setData({
+          replys: c
+        })
+        that.comments_time()
+      }
+    })
+  },
+  comments_time:function(){
+    var that = this
+    var cc = that.data.comments
+    var d = new Date(cc.created_at).getTime()
+    var n = new Date().getTime()
+    var t = n - d
+    if (t < 60000) {
+      var x = Math.round(t / 1000)
+      cc.created_at = '' + x + '秒前'
+    } else if (t >= 60000 && t < 3600000) {
+      var x = Math.round(t / 60000)
+      cc.created_at = '' + x + '分钟前'
+    } else if (t >= 3600000 && t < 86400000) {
+      var x = Math.round(t / 3600000)
+      cc.created_at = '' + x + '小时前'
+    } else if (t >= 86400000 && t < 86400000 * 3) {
+      var x = Math.round(t / 86400000)
+      cc.created_at = '' + x + '天前'
+    } else {
+      var e = new Date(d)
+      var x = '' + e.getFullYear() + '-' + (e.getMonth() + 1) + '-' + e.getDate()
+      cc.created_at = '' + x
+    }
+    that.setData({
+      comments: cc
+    })
   },
-
   /**
    * 生命周期函数--监听页面初次渲染完成
    */
-  onReady: function () {
-  
+  onReady: function() {
+
   },
 
   /**
    * 生命周期函数--监听页面显示
    */
-  onShow: function () {
-  
+  onShow: function() {
+
   },
 
   /**
    * 生命周期函数--监听页面隐藏
    */
-  onHide: function () {
-  
+  onHide: function() {
+
   },
 
   /**
    * 生命周期函数--监听页面卸载
    */
-  onUnload: function () {
-  
+  onUnload: function() {
+
   },
 
   /**
    * 页面相关事件处理函数--监听用户下拉动作
    */
-  onPullDownRefresh: function () {
-  
+  onPullDownRefresh: function() {
+
   },
 
   /**
    * 页面上拉触底事件的处理函数
    */
-  onReachBottom: function () {
-  
+  onReachBottom: function() {
+    var that = this
+    if (that.data.next_page_url) {
+      app.request({
+        url: that.data.next_page_url,
+        data: {
+          store_id: 1,
+          id: that.data.reply_id
+        },
+        method: 'get',
+        success: function(res) {
+          console.log(res.data)
+          that.setData({
+            comments: res.data.data.comments,
+            next_page_url: res.data.data.comments_replys.next_page_url,
+            comments_replys: res.data.data.comments_replys,
+          })
+          var c = res.data.data.comments_replys.data
+          for (var i = 0; i < c.length; i++) {
+            console.log(c[i].created_at)
+            var d = new Date(c[i].created_at).getTime()
+            var n = new Date().getTime()
+            var t = n - d
+            if (t < 60000) {
+              var x = Math.round(t / 1000)
+              c[i].created_at = '' + x + '秒前'
+            } else if (t >= 60000 && t < 3600000) {
+              var x = Math.round(t / 60000)
+              c[i].created_at = '' + x + '分钟前'
+            } else if (t >= 3600000 && t < 86400000) {
+              var x = Math.round(t / 3600000)
+              c[i].created_at = '' + x + '小时前'
+            } else if (t >= 86400000 && t < 86400000 * 3) {
+              var x = Math.round(t / 86400000)
+              c[i].created_at = '' + x + '天前'
+            } else {
+              var e = new Date(d)
+              var x = '' + e.getFullYear() + '-' + (e.getMonth() + 1) + '-' + e.getDate()
+              c[i].created_at = '' + x
+            }
+          }
+          that.setData({
+            replys: [...that.data.replys.concat(c)],
+          })
+          that.comments_time()
+        }
+      })
+    } else {
+      wx.showToast({
+        title: '已经没有更多了',
+        icon: 'none',
+        duration: 1000
+      })
+    }
   },
 
   /**
    * 用户点击右上角分享
    */
-  onShareAppMessage: function () {
-  
+  onShareAppMessage: function() {
+
   },
-  zan: function () {
+  reply: function(e) {
     var that = this
-    if (that.data.zan == true) {
-      that.setData({
-        zan: false
+    var text = e.detail.value
+    if (text != '') {
+      app.request({
+        url: 'https://t6.9026.com/api/furniture/add_comments',
+        data: {
+          store_id: 1,
+          news_id: that.data.newsid,
+          content: text,
+          comments_id: that.data.reply_id
+        },
+        method: 'post',
+        success: function(res) {
+          if (res.data == 'Unauthorized .') {
+            that.setData({
+              is_login: true
+            })
+          } else {
+            app.request({
+              url: 'https://t6.9026.com/api/furniture/getmorecomments',
+              data: {
+                store_id: 1,
+                id: that.data.reply_id
+              },
+              method: 'get',
+              success: function(res) {
+                console.log(res.data)
+                that.setData({
+                  comments: res.data.data.comments,
+                  next_page_url: res.data.data.comments_replys.next_page_url,
+                  reply_content: '',
+                  comments_replys: res.data.data.comments_replys,
+                  replys: res.data.data.comments_replys.data,
+                })
+                var c = that.data.replys
+                for (var i = 0; i < c.length; i++) {
+                  console.log(c[i].created_at)
+                  var d = new Date(c[i].created_at).getTime()
+                  var n = new Date().getTime()
+                  var t = n - d
+                  if (t < 60000) {
+                    var x = Math.round(t / 1000)
+                    c[i].created_at = '' + x + '秒前'
+                  } else if (t >= 60000 && t < 3600000) {
+                    var x = Math.round(t / 60000)
+                    c[i].created_at = '' + x + '分钟前'
+                  } else if (t >= 3600000 && t < 86400000) {
+                    var x = Math.round(t / 3600000)
+                    c[i].created_at = '' + x + '小时前'
+                  } else if (t >= 86400000 && t < 86400000 * 3) {
+                    var x = Math.round(t / 86400000)
+                    c[i].created_at = '' + x + '天前'
+                  } else {
+                    var e = new Date(d)
+                    var x = '' + e.getFullYear() + '-' + (e.getMonth() + 1) + '-' + e.getDate()
+                    c[i].created_at = '' + x
+                  }
+                }
+                that.setData({
+                  replys: c
+                })
+                that.comments_time()
+              }
+            })
+          }
+        }
       })
-    } else {
-      that.setData({
-        zan: true
+    }
+  },
+  close_login: function() {
+    this.setData({
+      is_login: false
+    })
+  },
+  userLogin: function(e) {
+    this.setData({
+      is_login: false
+    })
+    wx.showLoading({
+      title: '登录中',
+    })
+    console.log(e.detail)
+    var un = JSON.parse(e.detail.rawData)
+    var that = this
+    try {
+      wx.login({
+        success: function(res) {
+          let code = res.code
+          console.log(code)
+          let tx = un.avatarUrl
+          let nn = un.nickName
+          app.request({
+            url: 'https://t6.9026.com/api/furniture/service_login',
+            method: 'POST',
+            data: {
+              code: code,
+              avatar: tx,
+              nickName: nn,
+              store_id: 1
+            },
+            success: function(res) {
+              console.log(res.data)
+              wx.setStorageSync("token", res.data.data.token)
+              wx.setStorageSync('key', res.data.data.session_key)
+              wx.setStorageSync("user", res.data.data.user);
+              wx.setStorageSync('ma', 0)
+              wx.setStorageSync('pa', 0)
+              wx.setStorageSync('us', 0)
+              wx.hideLoading();
+              wx.showToast({
+                title: '登录成功',
+                icon: 'success',
+                duration: 1000,
+
+              })
+            }
+          })
+        }
       })
+    } catch (e) {
+      console.log(e.message)
     }
-  }
+  },
 })

+ 24 - 75
Furniture/page/homePage/detail/conment/conment.wxml

xqd
@@ -1,97 +1,46 @@
 <!--page/homePage/detail/conment/conment.wxml-->
 <!--page/homePage/detail/detail.wxml-->
+<include src="/pages/login/login.wxml" />
 <view class="page" style='background-color:white'>
   <view class="page__bd">
     <view class="conment" style='margin:20rpx'>
-      <view class='container' style='margin-left:0rpx;margin-top:-20rpx'>
-        <image src='../../../../images/people.png' style='width:80rpx;height:80rpx'></image>
+      <view class='container1' style='margin-left:0rpx;margin-top:0rpx'>
+        <image src='{{comments.avatar}}' style='width:80rpx;height:80rpx'></image>
       </view>
-      <view class='container' style='margin-top:8rpx'>
-        <text style='margin-left:540rpx'>20</text>
-        <image src='../../../../images/点赞.png' style='width:30rpx;height:30rpx;margin-left:10rpx;margin-top:8rpx' bindtap='zan' wx:if="{{!zan}}"></image>
-        <image src='../../../../images/已赞.png' style='width:30rpx;height:30rpx;margin-left:10rpx;margin-top:8rpx' bindtap='zan' wx:if="{{zan}}"></image>
-      </view>
-      <view class="weui-article__title" style='margin-left:100rpx'>梦星羽</view>
-
+      <view class="weui-article__title" style='margin-left:100rpx'>{{comments.username}}</view>
 
-      <view style='font-size:35rpx;margin-left:0rpx;margin-top:10rpx'>
-        评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内
+      <view class='container1' style='margin-left:100rpx;margin-top:5rpx;font-size:24rpx;color:#d3d3d3'>
+        {{comments.created_at}}
       </view>
-      <view style='border-bottom: 2rpx #D3D3D3 solid'>
-      <view class='container' style='margin-left:0rpx;margin-top:5rpx;font-size:24rpx;color:#d3d3d3'>
-        6小时前
-      </view>
-      <view style='margin:0;margin-left:0rpx'>
-        <image src='../../../../images/回复按钮.png' style='width:60rpx;height:30rpx;margin-left:100rpx;margin-top:10rpx'></image>
+      <view style='font-size:35rpx;margin-left:0rpx;margin-top:50rpx;word-break:break-all;'>
+        {{comments.content}}
       </view>
+      <view style='border-bottom: 2rpx #D3D3D3 solid;margin-top:20rpx'>
       </view>
       <view style='margin-top:10rpx;'>
-        全部回复(21)
+        全部回复({{comments_replys.total}})
       </view>
     </view>
-    <view class='conment' style='margin:20rpx'>
-      <view class='container' style='margin-left:0rpx;margin-top:-20rpx'>
-        <image src='../../../../images/people.png' style='width:80rpx;height:80rpx'></image>
-      </view>
-      <view class='container' style='margin-top:8rpx'>
-        <text style='margin-left:540rpx'>20</text>
-        <image src='../../../../images/点赞.png' style='width:30rpx;height:30rpx;margin-left:10rpx;margin-top:8rpx' bindtap='zan' wx:if="{{!zan}}"></image>
-        <image src='../../../../images/已赞.png' style='width:30rpx;height:30rpx;margin-left:10rpx;margin-top:8rpx' bindtap='zan' wx:if="{{zan}}"></image>
+    <view class='conment' style='margin:20rpx;margin-top:50rpx' wx:for='{{replys}}'>
+      <view class='container1' style='margin-left:0rpx;margin-top:0rpx'>
+        <image src='{{item.avatar}}' style='width:80rpx;height:80rpx'></image>
       </view>
-      <view class="weui-article__title" style='margin-left:100rpx'>梦星羽</view>
-
-
-      <view style='font-size:35rpx;margin-left:100rpx'>
-        评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内
+      <view class="weui-article__title" style='margin-left:100rpx'>{{item.username}}</view>
+      <view class='container1' style='margin-left:100rpx;margin-top:5rpx;font-size:24rpx;color:#d3d3d3'>
+        {{item.created_at}}
       </view>
-      <view class='container' style='margin-top:10rpx'>
-        <image src='../../../../images/展开全文按钮.png' style='width:60rpx;height:30rpx;margin-left:20rpx'></image>
+      <view style='font-size:35rpx;margin-left:100rpx;margin-top:50rpx;word-break:break-all;'>
+        {{item.content}}
       </view>
-
-      <view class='container' style='margin-left:100rpx;margin-top:55rpx;font-size:24rpx;color:#d3d3d3'>
-        6小时前
+      <view style='margin-top:5rpx;background-color:#f5f5f5;margin-left:100rpx;height:50rpx;padding:5rpx' id='{{item.id}}' bindtap='toConment' wx:if='{{item.replys.total != 0}}'>
+        <text style='color:#1E90FF;font-size:30rpx' decode="{{true}}" space="{{true}}">共{{item.replys.total}}条回复  ></text>
       </view>
-      <view style='margin:0;margin-left:100rpx'>
-        <image src='../../../../images/回复按钮.png' style='width:60rpx;height:30rpx;margin-left:100rpx;margin-top:60rpx'></image>
-      </view>
-
-      <view style='margin-top:5rpx;background-color:#f5f5f5;margin-left:100rpx;'>
-        <view style='margin-left:10rpx'>
-          <text style='font-size:30rpx;font-famaily:"黑体"'>梦星羽:</text>
-          <text style=' font-size:30rpx;color:#606060'>评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评</text>
-        </view>
-
-        <view class='container ' style='margin-top:10rpx'>
-          <image src='../../../../images/展开全文按钮.png ' style='width:60rpx;height:30rpx;margin-left:-70rpx;margin-top:0rpx'></image>
-        </view>
-
-        <view style='margin-top:50rpx;margin-left:10rpx'>
-          <text style='font-size:30rpx;font-famaily:"黑体"'>梦星羽:</text>
-          <text style=' font-size:30rpx;color:#606060'>评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评</text>
-        </view>
-
-        <view class='container ' style='margin-top:10rpx'>
-          <image src='../../../../images/展开全文按钮.png ' style='width:60rpx;height:30rpx;margin-left:-70rpx;margin-top:0rpx'></image>
-        </view>
-
-        <view style='margin-top:50rpx;height:1rpx'>
-        </view>
-        <view class='container' style='margin-top:0rpx'>
-          <image src='../../../../images/查看全部回复按钮.png ' style='width:160rpx;height:25rpx;margin-left:-70rpx;margin-top:0rpx'></image>
-        </view>
-        <view style='margin-top:50rpx;height:1rpx'>
-        </view>
-        <view class='container' style='margin-top:0rpx;margin-left:0rpx'>
-          <image src='../../../../images/回复与回复之间的分割线.png ' style='width:81%;height:2rpx;margin-top:0rpx;margin-left:0rpx'></image>
-        </view>
+      <view class='container1' style='margin-top:0rpx;margin-left:100rpx'>
+        <image src='/images/回复与回复之间的分割线.png ' style='width:630rpx;height:1rpx;margin-top:0rpx;margin-left:0rpx'></image>
       </view>
     </view>
-
-    <view class='textInput'>
-      <view class="relative">
-        <image class="pic_background" src="../../../../images/底部栏评论1.png"></image>
-        <view class='container' style='margin-top:25rpx;margin-left:60rpx;font-size:30rpx;color:#a9a9a9'>说点什么...</view>
-      </view>
+    <view class='sousuo'>
+      <input class='findit' placeholder='说点什么...' bindblur='reply' value='{{reply_content}}'></input>
     </view>
   </view>
 </view>

+ 19 - 3
Furniture/page/homePage/detail/conment/conment.wxss

xqd xqd
@@ -1,8 +1,7 @@
 /* page/homePage/detail/conment/conment.wxss */
 /* page/homePage/detail/detail.wxss */
-.container {
-  height: 100%;
-  width:100%;
+@import '/pages/login/login.wxss';
+.container1 {
   flex-direction: column;
   color:#515151;
   font-size: 26rpx;
@@ -32,4 +31,21 @@
   height: 100%;
   width: 100%;
   position:absolute;
+}
+.sousuo{
+  background-color: #fff;
+  width: 100%;
+  height: 100rpx;
+  bottom: 0;
+  position: fixed;
+  display: flex;
+  font-size: 32rpx;
+}
+.sousuo .findit{
+  width: 700rpx;
+  height: 70rpx;
+  background: #eee;
+  margin: 15rpx 0 15rpx 15rpx;
+  border-radius:35rpx; 
+  padding-left: 25rpx;
 }

+ 362 - 53
Furniture/page/homePage/detail/detail.js

xqd xqd xqd xqd
@@ -7,13 +7,16 @@ Page({
    * 页面的初始数据
    */
   data: {
-    time: '2018-06-26 9:06',
+    is_login:false,
+    reply_id:0,
+    focus:false,
+    placeholder:'随便说些什么...',
+    is_reply:false,
+    comment_content:'',
     like: true,
-    normal: true,
-    dislike: true,
-    zan: false,
     news:{},
     news_comments:{},
+    comments:[],
   },
 
   /**
@@ -32,15 +35,44 @@ Page({
       },
       success:function(res){
         that.setData({
+          next_page_url: res.data.data.news_comments.next_page_url,
           news:res.data.data.news,
-          news_comments:res.data.data.news_comments
+          news_comments:res.data.data.news_comments,
+          comments: res.data.data.news_comments.data
         })
+        var c = that.data.comments
+        for(var i = 0;i<c.length;i++){
+          console.log(c[i].created_at)
+          var d = new Date(c[i].created_at).getTime()
+          var n = new Date().getTime()
+          var t = n - d
+          if(t < 60000){
+            var x = Math.round(t / 1000)
+            c[i].created_at = ''+x+ '秒前'
+          }else if(t >= 60000 && t < 3600000){
+            var x = Math.round(t / 60000)
+            c[i].created_at = '' + x + '分钟前'
+          } else if (t >= 3600000 && t < 86400000){
+            var x = Math.round(t / 3600000)
+            c[i].created_at = '' + x + '小时前'
+          } else if (t >= 86400000 && t < 86400000*3){
+            var x = Math.round(t / 86400000)
+            c[i].created_at = '' + x + '天前'
+          } else {
+            var e = new Date(d)
+            var x = ''+e.getFullYear()+'-'+(e.getMonth()+1)+'-'+e.getDate()
+            c[i].created_at = '' + x
+          }
+        }
+        that.setData({
+          comments:c
+        })
+        that.news_time()
         var article = that.data.news.content
         WxParse.wxParse('article', 'html', article, that, 5)
       }
     })
   },
-
   /**
    * 生命周期函数--监听页面初次渲染完成
    */
@@ -80,7 +112,57 @@ Page({
    * 页面上拉触底事件的处理函数
    */
   onReachBottom: function () {
-
+    var that = this
+    if(that.data.next_page_url){
+      app.request({
+        url: that.data.next_page_url,
+        method: 'get',
+        data: {
+          store_id: 1,
+          newsid: that.data.news.id
+        },
+        success: function (res) {
+          that.setData({
+            next_page_url: res.data.data.news_comments.next_page_url,
+            news: res.data.data.news,
+          })
+          var c = res.data.data.news_comments.data
+          for (var i = 0; i < c.length; i++) {
+            console.log(c[i].created_at)
+            var d = new Date(c[i].created_at).getTime()
+            var n = new Date().getTime()
+            var t = n - d
+            if (t < 60000) {
+              var x = Math.round(t / 1000)
+              c[i].created_at = '' + x + '秒前'
+            } else if (t >= 60000 && t < 3600000) {
+              var x = Math.round(t / 60000)
+              c[i].created_at = '' + x + '分钟前'
+            } else if (t >= 3600000 && t < 86400000) {
+              var x = Math.round(t / 3600000)
+              c[i].created_at = '' + x + '小时前'
+            } else if (t >= 86400000 && t < 86400000 * 3) {
+              var x = Math.round(t / 86400000)
+              c[i].created_at = '' + x + '天前'
+            } else {
+              var e = new Date(d)
+              var x = '' + e.getFullYear() + '-' + (e.getMonth() + 1) + '-' + e.getDate()
+              c[i].created_at = '' + x
+            }
+          }
+          that.setData({
+            comments: [...that.data.comments.concat(c)]
+          })
+          that.news_time()
+        }
+      })
+    }else{
+      wx.showToast({
+        title: '已经没有更多了',
+        icon:'none',
+        duration:1000
+      })
+    }
   },
 
   /**
@@ -91,69 +173,296 @@ Page({
   },
   like: function () {
     var that = this
-    console.log('hahhahhah')
     if (that.data.like == true) {
       that.setData({
         like: false,
-        normal: true,
-        dislike: true
+      })
+      app.request({
+        url:'https://t6.9026.com/api/furniture/addtolike',
+        data:{
+          store_id:1,
+          newsid:that.data.news.id,
+          like:1
+        },
+        method:'get',
+        success:()=>{
+
+        }
       })
     } else {
-      that.setData({
-        like: true,
-        normal: true,
-        dislike: true
+      wx.showToast({
+        title: '已经喜欢过了呦~',
+        icon:'none',
+        duration:1000
       })
     }
   },
-  normal: function () {
+  set_is_reply_false:function(){
     var that = this
-    if (that.data.normal == true) {
-      that.setData({
-        like: true,
-        normal: false,
-        dislike: true
-      })
-    } else {
-      that.setData({
-        like: true,
-        normal: true,
-        dislike: true
-      })
+    that.setData({
+      focus:true,
+      is_reply:false,
+      placeholder:'随便说些什么'
+    })
+  },
+  toConment: function (e) {
+    var that = this
+    console.log(e)
+    var id = e.currentTarget.id
+    wx.navigateTo({
+      url: 'conment/conment?id='+id+'&newsid='+that.data.news.id,
+    })
+  },
+  reply:function(e){
+    console.log(e)
+    var that = this
+    that.setData({
+      focus:true,
+      is_reply:true,
+      reply_id:e.currentTarget.id,
+      placeholder:'回复 '+e.currentTarget.dataset.name
+    })
+  },
+  comment:function(e){
+    var that = this
+    var text = e.detail.value
+    if(that.data.is_reply == false){
+      if(text != ''){
+        app.request({
+          url: 'https://t6.9026.com/api/furniture/add_comments',
+          data: {
+            store_id: 1,
+            news_id: that.data.news.id,
+            content: text,
+            comment_id: 0
+          },
+          method: 'post',
+          success: function (res) {
+            console.log(res.data)
+            if (res.data == 'Unauthorized .'){
+              that.setData({
+                is_login:true
+              })
+            }else{
+              app.request({
+                url: 'https://t6.9026.com/api/furniture/news_detail',
+                method: 'get',
+                data: {
+                  store_id: 1,
+                  newsid: that.data.news.id
+                },
+                success: function (res) {
+                  that.setData({
+                    news: res.data.data.news,
+                    next_page_url: res.data.data.news_comments.next_page_url,
+                    news_comments: res.data.data.news_comments,
+                    comments: res.data.data.news_comments.data,
+                    comment_content: ''
+                  })
+                  var c = that.data.comments
+                  for (var i = 0; i < c.length; i++) {
+                    console.log(c[i].created_at)
+                    var d = new Date(c[i].created_at).getTime()
+                    var n = new Date().getTime()
+                    var t = n - d
+                    if (t < 60000) {
+                      var x = Math.round(t / 1000)
+                      c[i].created_at = '' + x + '秒前'
+                    } else if (t >= 60000 && t < 3600000) {
+                      var x = Math.round(t / 60000)
+                      c[i].created_at = '' + x + '分钟前'
+                    } else if (t >= 3600000 && t < 86400000) {
+                      var x = Math.round(t / 3600000)
+                      c[i].created_at = '' + x + '小时前'
+                    } else if (t >= 86400000 && t < 86400000 * 3) {
+                      var x = Math.round(t / 86400000)
+                      c[i].created_at = '' + x + '天前'
+                    } else {
+                      var e = new Date(d)
+                      var x = '' + e.getFullYear() + '-' + (e.getMonth() + 1) + '-' + e.getDate()
+                      c[i].created_at = '' + x
+                    }
+                  }
+                  that.setData({
+                    comments: c
+                  })
+                  that.news_time()
+                  wx.showToast({
+                    title: '评论成功',
+                    icon: 'success',
+                    duration: 1000
+                  })
+                }
+              })
+            }
+          }
+        })
+      }
+    }else if(that.data.is_reply == true){
+      console.log(that.data.reply_id)
+      if (text != '') {
+        app.request({
+          url: 'https://t6.9026.com/api/furniture/add_comments',
+          data: {
+            store_id: 1,
+            news_id: that.data.news.id,
+            content: text,
+            comments_id: that.data.reply_id
+          },
+          method: 'post',
+          success: function (res) {
+            if (res.data == 'Unauthorized .') {
+              that.setData({
+                is_login: true
+              })
+            }else{
+              app.request({
+                url: 'https://t6.9026.com/api/furniture/news_detail',
+                method: 'get',
+                data: {
+                  store_id: 1,
+                  newsid: that.data.news.id
+                },
+                success: function (res) {
+                  var id = that.data.reply_id
+                  that.setData({
+                    news: res.data.data.news,
+                    next_page_url: res.data.data.news_comments.next_page_url,
+                    is_reply: false,
+                    reply_id: 0,
+                    placeholder: '随便说些什么...',
+                    news_comments: res.data.data.news_comments,
+                    comments: res.data.data.news_comments.data,
+                    comment_content: ''
+                  })
+                  var c = that.data.comments
+                  for (var i = 0; i < c.length; i++) {
+                    console.log(c[i].created_at)
+                    var d = new Date(c[i].created_at).getTime()
+                    var n = new Date().getTime()
+                    var t = n - d
+                    if (t < 60000) {
+                      var x = Math.round(t / 1000)
+                      c[i].created_at = '' + x + '秒前'
+                    } else if (t >= 60000 && t < 3600000) {
+                      var x = Math.round(t / 60000)
+                      c[i].created_at = '' + x + '分钟前'
+                    } else if (t >= 3600000 && t < 86400000) {
+                      var x = Math.round(t / 3600000)
+                      c[i].created_at = '' + x + '小时前'
+                    } else if (t >= 86400000 && t < 86400000 * 3) {
+                      var x = Math.round(t / 86400000)
+                      c[i].created_at = '' + x + '天前'
+                    } else {
+                      var e = new Date(d)
+                      var x = '' + e.getFullYear() + '-' + (e.getMonth() + 1) + '-' + e.getDate()
+                      c[i].created_at = '' + x
+                    }
+                  }
+                  that.setData({
+                    comments: c
+                  })
+                  that.news_time
+                  wx.showToast({
+                    title: '回复成功',
+                    icon: 'success',
+                    duration: 1000
+                  })
+                  wx.navigateTo({
+                    url: 'conment/conment?id=' + id + '&newsid=' + that.data.news.id,
+                  })
+                }
+              })
+            }
+          }
+        })
+      }else{
+        that.setData({
+          is_reply: false,
+          reply_id: 0,
+          placeholder: '随便说些什么...',
+        })
+      }
     }
   },
-  dislike: function () {
+  news_time: function () {
     var that = this
-    if (that.data.dislike == true) {
-      that.setData({
-        like: true,
-        normal: true,
-        dislike: false
-      })
+    var cc = that.data.news
+    var d = new Date(cc.created_at).getTime()
+    var n = new Date().getTime()
+    var t = n - d
+    if (t < 60000) {
+      var x = Math.round(t / 1000)
+      cc.created_at = '' + x + '秒前'
+    } else if (t >= 60000 && t < 3600000) {
+      var x = Math.round(t / 60000)
+      cc.created_at = '' + x + '分钟前'
+    } else if (t >= 3600000 && t < 86400000) {
+      var x = Math.round(t / 3600000)
+      cc.created_at = '' + x + '小时前'
+    } else if (t >= 86400000 && t < 86400000 * 3) {
+      var x = Math.round(t / 86400000)
+      cc.created_at = '' + x + '天前'
     } else {
-      that.setData({
-        like: true,
-        normal: true,
-        dislike: true
-      })
+      var e = new Date(d)
+      var x = '' + e.getFullYear() + '-' + (e.getMonth() + 1) + '-' + e.getDate()
+      cc.created_at = '' + x
     }
+    that.setData({
+      news: cc
+    })
+  },
+  close_login: function () {
+    this.setData({
+      is_login: false
+    })
   },
-  zan: function () {
+  userLogin: function (e) {
+    this.setData({
+      is_login: false
+    })
+    wx.showLoading({
+      title: '登录中',
+    })
+    console.log(e.detail)
+    var un = JSON.parse(e.detail.rawData)
     var that = this
-    if (that.data.zan == true) {
-      that.setData({
-        zan: false
-      })
-    } else {
-      that.setData({
-        zan: true
+    try {
+      wx.login({
+        success: function (res) {
+          let code = res.code
+          console.log(code)
+          let tx = un.avatarUrl
+          let nn = un.nickName
+          app.request({
+            url: 'https://t6.9026.com/api/furniture/service_login',
+            method: 'POST',
+            data: {
+              code: code,
+              avatar: tx,
+              nickName: nn,
+              store_id: 1
+            },
+            success: function (res) {
+              console.log(res.data)
+              wx.setStorageSync("token", res.data.data.token)
+              wx.setStorageSync('key', res.data.data.session_key)
+              wx.setStorageSync("user", res.data.data.user);
+              wx.setStorageSync('ma', 0)
+              wx.setStorageSync('pa', 0)
+              wx.setStorageSync('us', 0)
+              wx.hideLoading();
+              wx.showToast({
+                title: '登录成功',
+                icon: 'success',
+                duration: 1000,
+              })
+            }
+          })
+        }
       })
+    } catch (e) {
+      console.log(e.message)
     }
   },
-  toConment: function (e) {
-    console.log(e)
-    // wx.navigateTo({
-    //   url: 'conment/conment?',
-    // })
-  }
 })

+ 41 - 53
Furniture/page/homePage/detail/detail.wxml

xqd xqd xqd
@@ -1,16 +1,17 @@
 <!--page/homePage/detail/detail.wxml-->
+<include src="/pages/login/login.wxml" />
 <view class="page" style='background-color:white'>
   <view class="page__bd">
     <view class="weui-article">
-      <view class="weui-article__h1" style='font-size:42rpx'>{{news.title}}</view>
+      <view class="weui-article__h1" style='font-size:42rpx;word-break:break-all;'>{{news.title}}</view>
       <view class='container1' style='margin-left:0rpx;margin-top:0rpx'>
-        <image src='{{news.avatar}}' style='width:80rpx;height:80rpx'></image>
+        <image src='' style='width:80rpx;height:80rpx'></image>
       </view>
       <view class="weui-article__section">
         <view class="weui-article__title" style='margin-left:100rpx'>天天家居惠</view>
         <view class="weui-article__section">
           <view class="weui-article__h3" style='margin-left:100rpx'>{{news.created_at}}</view>
-          <view class="weui-article__p" style='font-size:35rpx'>
+          <view class="weui-article__p" style='font-size:35rpx;word-break:break-all;'>
             <import src="../../../wxParse/wxParse.wxml" />
             <template is="wxParse" data="{{wxParseData:article.nodes}}" />
           </view>
@@ -19,47 +20,39 @@
           </view>
         </view>
       </view>
-      <view style='height:80rpx;width:100%;position:relative'>
-        <view class='container1'>{{news.viewed}}</view>
-        <image src='../../../images/eyes.png' style='width:50rpx;height:50rpx;margin-top:15rpx'></image>
-      </view>
-      <view class='weui-flex'>
-        <!-- <view class='weui-flex__item'>
-          <image src='../../../images/like.png' style='width:50%;height:110rpx;margin-left:25%' bindtap='like' wx:if="{{like}}"></image>
-          <image src='../../../images/like1.png' style='width:50%;height:110rpx;margin-left:25%' bindtap='like' wx:if="{{!like}}"></image>
+
+      <view style='height:80rpx;width:100%;position:relative;display:flex'>
+        <view class='container1' style='margin-top:45rpx'>{{news.viewed}}</view>
+        <image src='../../../images/eyes.png' style='width:50rpx;height:50rpx;margin-top:40rpx'></image>
+
+        <view class='like' bindtap='like' wx:if="{{like}}">
+          <view style='margin-top:10rpx'>
+            <image src='../../../images/like1.png' style='width:60rpx;height:60rpx;margin-left:20rpx'></image>
+          </view>
+          <view style='margin:15rpx 0 15rpx 20rpx;border-right:1px solid #EA6F5A;padding:0 20rpx 0 0'>喜欢</view>
+          <view style='margin:15rpx 0 15rpx 20rpx'>
+            {{news.like}}
+          </view>
         </view>
-        <view class='weui-flex__item'>
-          <image src='../../../images/normal.png' style='width:50%;height:110rpx;margin-left:25%' bindtap='normal' wx:if="{{normal}}"></image>
-          <image src='../../../images/normal1.png' style='width:50%;height:110rpx;margin-left:25%' bindtap='normal' wx:if="{{!normal}}"></image>
+
+        <view class='like1' bindtap='like' wx:if="{{!like}}">
+          <view style='margin-top:10rpx'>
+            <image src='../../../images/like.png' style='width:60rpx;height:60rpx;margin-left:20rpx'></image>
+          </view>
+          <view style='margin:15rpx 0 15rpx 20rpx;border-right:1px solid white;padding:0 20rpx 0 0'>喜欢</view>
+          <view style='margin:15rpx 0 15rpx 20rpx'>
+            {{news.like+1}}
+          </view>
         </view>
-        <view class='weui-flex__item'>
-          <image src='../../../images/no.png' style='width:50%;height:110rpx;margin-left:25%' bindtap='dislike' wx:if="{{dislike}}"></image>
-          <image src='../../../images/no1.png' style='width:50%;height:110rpx;margin-left:25%' bindtap='dislike' wx:if="{{!dislike}}"></image>
-        </view> -->
-      </view>
-      <view class='container1' style='margin-left:55rpx;margin-top: 0rpx;' wx:if="{{like}}">
-        喜欢({{news.like}})
-      </view>
-      <view class='container1' style='margin-left:290rpx;margin-top: 0rpx;' wx:if="{{normal}}">
-        一般({{news.commonly}})
-      </view>
-      <view class='container1' style='margin-left:520rpx;margin-top: 0rpx;' wx:if="{{dislike}}">
-        淘汰({{news.bad}})
-      </view>
-      <view class='container1' style='margin-left:55rpx;margin-top: 0rpx;color:#d81e06;' wx:if="{{!like}}">
-        喜欢({{news.like+1}})
-      </view>
-      <view class='container1' style='margin-left:290rpx;margin-top: 0rpx;color:#d81e06;' wx:if="{{!normal}}">
-        一般({{news.commonly+1}})
-      </view>
-      <view class='container1' style='margin-left:520rpx;margin-top: 0rpx;color:#d81e06;' wx:if="{{!dislike}}">
-        淘汰({{news.bad+1}})
       </view>
+
+
+
       <view style='margin-top:80rpx;'>
         全部评论({{news_comments.total}})
       </view>
     </view>
-    <view class='conment' wx:for='{{news_comments.data}}'>
+    <view class='conment' wx:for='{{comments}}'>
       <view class='container1' style='margin-left:0rpx;margin-top:0rpx'>
         <image src='{{item.avatar}}' style='width:80rpx;height:80rpx'></image>
       </view>
@@ -67,28 +60,23 @@
       <view class='container1' style='margin-left:100rpx;margin-top:5rpx;font-size:24rpx;color:#d3d3d3'>
         {{item.created_at}}
       </view>
-      <view style='font-size:35rpx;margin-left:100rpx;margin-top:50rpx'>
+      <view style='font-size:35rpx;margin-left:100rpx;margin-top:50rpx;word-break:break-all;' id='{{item.id}}' bindtap='reply' data-name='{{item.username}}'>
         {{item.content}}
       </view>
-      <view style='margin-top:5rpx;background-color:#f5f5f5;margin-left:100rpx;height:50rpx;padding:5rpx' id='{{item.id}}' bindtap='toConment' wx:if='{{item.replys.total != 0}}' >
-      <text style='color:#1E90FF;font-size:30rpx' decode="{{true}}" space="{{true}}">共{{item.replys.total}}条回复  ></text>
+      <view style='margin-top:5rpx;background-color:#f5f5f5;margin-left:100rpx;height:50rpx;padding:5rpx' id='{{item.id}}' bindtap='toConment' wx:if='{{item.replys.total != 0}}'>
+        <text style='color:#1E90FF;font-size:30rpx' decode="{{true}}" space="{{true}}">共{{item.replys.total}}条回复  ></text>
       </view>
-
       <view class='container1' style='margin-top:0rpx;margin-left:100rpx'>
-          <image src='../../../../images/回复与回复之间的分割线.png ' style='width:81%;height:2rpx;margin-top:0rpx;margin-left:0rpx'></image>
+        <image src='/images/回复与回复之间的分割线.png ' style='width:630rpx;height:1rpx;margin-top:0rpx;margin-left:0rpx;'></image>
       </view>
     </view>
-
-    <view class='textInput'>
-      <view class="relative">
-        <image class="pic_background" src="../../../images/底部栏评论.png"></image>
-        <view class='container1'>
-          <image src="../../../images/查看评论按钮.png" style='width:6%;height:42%;margin-left:520rpx;margin-top:15rpx'> </image>
-        </view>
-        <view class='container1'>
-          <image src="../../../images/分享按钮.png" style='width:6%;height:42%;margin-left:600rpx;margin-top:15rpx'> </image>
-        </view>
-        <view class='container1' style='margin-top:25rpx;margin-left:60rpx;font-size:30rpx;color:#a9a9a9'>说点什么...</view>
+    <view class='sousuo'>
+      <input class='findit' placeholder='{{placeholder}}' bindblur='comment' value='{{comment_content}}' focus='{{focus}}'></input>
+      <view class='sweep' bindtap='set_is_reply_false'>
+        <image src='/images/查看评论按钮.png'></image>
+      </view>
+      <view class='sweep' bindtap=''>
+        <image src='/images/分享按钮.png'></image>
       </view>
     </view>
   </view>

+ 50 - 2
Furniture/page/homePage/detail/detail.wxss

xqd xqd
@@ -1,7 +1,9 @@
 /* page/homePage/detail/detail.wxss */
+@import '/pages/login/login.wxss';
+.page{
+  overflow-x: hidden;
+}
 .container1 {
-  height: 100%;
-  width:100%;
   flex-direction: column;
   color:#515151;
   font-size: 26rpx;
@@ -32,4 +34,50 @@
   height: 100%;
   width: 100%;
   position:absolute;
+}
+.sousuo{
+  background-color: #fff;
+  width: 100%;
+  height: 100rpx;
+  bottom: 0;
+  position: fixed;
+  display: flex;
+  font-size: 32rpx;
+}
+.sousuo .findit{
+  width: 520rpx;
+  height: 70rpx;
+  background: #eee;
+  margin: 15rpx 0 15rpx 15rpx;
+  border-radius:35rpx; 
+  padding-left: 25rpx;
+}
+.sousuo .sweep{
+  width: 70rpx;
+  height: 70rpx;
+  margin: 15rpx;
+}
+.sousuo .sweep image{
+  width:60rpx;
+  height: 60rpx;
+  margin-top: 5rpx;
+}
+.like{
+  margin-left: 350rpx;
+  width: 250rpx;
+  height: 80rpx;
+  color:#EA6F5A;
+  border:1px solid #EA6F5A;
+  border-radius: 50rpx;
+  display: flex;
+}
+.like1{
+  margin-left: 350rpx;
+  background-color: #EA6F5A;
+  width: 250rpx;
+  height: 80rpx;
+  color:#fff;
+  border:1px solid #EA6F5A;
+  border-radius: 50rpx;
+  display: flex;
 }

+ 30 - 36
Furniture/pages/index/index.js

xqd
@@ -320,52 +320,46 @@ Page({
       is_login: false
     })
   },
-  userLogin: function() {
+  userLogin: function (e) {
     this.setData({
-      is_login:false
+      is_login: false
     })
     wx.showLoading({
       title: '登录中',
     })
+    console.log(e.detail)
+    var un = JSON.parse(e.detail.rawData)
     var that = this
     try {
       wx.login({
-        success: function(res) {
+        success: function (res) {
           let code = res.code
           console.log(code)
-          wx.getUserInfo({
-            success: function(res) {
-              let tx = res.userInfo.avatarUrl
-              let nn = res.userInfo.nickName
-              app.request({
-                url: 'https://t6.9026.com/api/furniture/service_login',
-                method: 'POST',
-                data: {
-                  code: code,
-                  avatar: tx,
-                  nickName: nn,
-                  store_id: 1
-                },
-                success: function(res) {
-                  console.log(res.data)
-                  wx.setStorageSync("token", res.data.data.token)
-                  wx.setStorageSync('key', res.data.data.session_key)
-                  wx.setStorageSync("user", res.data.data.user);
-                  wx.setStorageSync('ma', 0)
-                  wx.setStorageSync('pa', 0)
-                  wx.setStorageSync('us', 0)
-                  wx.hideLoading();
-                  wx.showToast({
-                    title: '登录成功',
-                    icon: 'success',
-                    duration: 1000,
-                    // success:()=>{
-                    //   wx.redirectTo({
-                    //     url: '../make/make',
-                    //   })
-                    // }
-                  })
-                }
+          let tx = un.avatarUrl
+          let nn = un.nickName
+          app.request({
+            url: 'https://t6.9026.com/api/furniture/service_login',
+            method: 'POST',
+            data: {
+              code: code,
+              avatar: tx,
+              nickName: nn,
+              store_id: 1
+            },
+            success: function (res) {
+              console.log(res.data)
+              wx.setStorageSync("token", res.data.data.token)
+              wx.setStorageSync('key', res.data.data.session_key)
+              wx.setStorageSync("user", res.data.data.user);
+              wx.setStorageSync('ma', 0)
+              wx.setStorageSync('pa', 0)
+              wx.setStorageSync('us', 0)
+              wx.hideLoading();
+              wx.showToast({
+                title: '登录成功',
+                icon: 'success',
+                duration: 1000,
+
               })
             }
           })

+ 1 - 1
Furniture/project.config.json

xqd
@@ -11,7 +11,7 @@
 		"newFeature": true
 	},
 	"compileType": "miniprogram",
-	"libVersion": "2.2.0",
+	"libVersion": "2.2.2",
 	"appid": "wx18494553a568fbd1",
 	"projectname": "天天家居惠",
 	"condition": {