Browse Source

课程等页面

Rorschach 6 years ago
parent
commit
f33d8ae79f

+ 1 - 0
app.json

@@ -2,6 +2,7 @@
   "pages": [
     "pages/index/index",
     "pages/social/works/works",
+    "pages/social/replyDetail/replyDetail",
     "pages/main/class/class",
     "pages/main/books/books",
     "pages/main/singleBook/singleBook",

+ 1 - 1
component/follow/follow.wxml

@@ -1,6 +1,6 @@
 <template name="follow">
   <view class="followWares" style="flex-direction:row;">
-    <view wx:for="{{followData.wareCards}}" wx:key="{{index}}" class="followWareCard" bindtap="openWorks" data-classId="{{item.classId}}" data-title="{{item.title}}">
+    <view wx:for="{{followData.wareCards}}" wx:key="{{index}}" class="followWareCard" bindtap="openWorks" data-uid="{{item.classId}}" data-title="{{item.title}}">
       <view class="userCard">
         <image class="avatar" src="{{item.avatar}}" />
         <view class="nameCross">

+ 2 - 2
component/hot/hot.js

@@ -79,10 +79,10 @@ export const hotInit = (that) => {
     }
     // 打开用户作品页面
     that.openWorks = (e) =>{
-      let classId = e.currentTarget.dataset.classid;
+      let uid = e.currentTarget.dataset.uid;
       let title = e.currentTarget.dataset.title;
       wx.navigateTo({
-        url: `../social/works/works?id=${classId}&title=${title}`
+        url: `../social/works/works?id=${uid}&title=${title}`
       })
     }
     that.getIndex = (uid)=>{

+ 1 - 1
component/hot/hot.wxml

@@ -47,7 +47,7 @@
             </view>
         </view>
         <view class="hotWares" style="flex-direction:row;">
-            <view wx:for="{{hotData.wareCards}}" wx:key="{{index}}" class="hotWareCard" bindtap="openWorks" data-classId="{{item.classId}}" data-title="{{item.title}}">
+            <view wx:for="{{hotData.wareCards}}" wx:key="{{index}}" class="hotWareCard" bindtap="openWorks" data-uid="{{item.classId}}" data-title="{{item.title}}">
                 <image class="wareCardImg" src="{{item.img}}" />
                 <text class="wareCardTitle">{{item.title}}</text>
                 <view class="bottomData">

+ 1 - 1
pages/main/class/class.js

@@ -104,7 +104,7 @@ Page({
   },
   goToWorks: function (e) {
     console.log(e);
-    let readId = e.target.dataset.readId;
+    let readId = e.target.dataset.uid;
     let title = this.data.title;
     wx.navigateTo({
       url: `../../social/works/works?id=${readId}&tilte=${title}`

+ 1 - 1
pages/main/class/class.wxml

@@ -5,7 +5,7 @@
             <image class="peoplesIcon" src="../../../static/image/peoples.png" />
             <view class="title">共有12345人完成了录音</view>
         </view>
-        <view class="workCard" wx:for="{{works}}" wx:key="{{index}}" bindtap="goToWorks" data-uid="{{item.readId}}">
+        <view class="workCard" wx:for="{{works}}" wx:key="{{index}}" bindtap="goToWorks" data-uid="{{item.uid}}">
             <image class="avatar" src="{{item.avatar}}" />
             <view class="name">
                 <text class="nickName">{{item.nickName}}</text>

+ 1 - 0
pages/main/searchResult/searchResult.json

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

+ 89 - 0
pages/social/replyDetail/replyDetail.js

@@ -0,0 +1,89 @@
+import httpRequestApi from '../../../utils/APIClient';
+Page({
+    data: {
+        class1: 'commentItem commentItemFirst',
+        classNormal: 'commentItem',
+        comment:[
+            {
+                name: '阿尔萨斯',
+                text: '总有一天我将死去而你我儿子啊将加冕为王加冕为王加冕为王加冕为王加冕为王加冕为王加冕为王',
+                time: '10-18 09:56',
+                likes: '165',
+                avatar: '../../../static/image/timg.jpg'
+            },
+            {
+                name: '古尔丹',
+                text: '你读的是个求',
+                time: '10-18 09:56',
+                likes: '165',
+                avatar: '../../../static/image/timg.jpg'
+            },
+            {
+                name: '阿尔萨斯',
+                text: '圣光将照耀我',
+                time: '10-18 09:56',
+                likes: '165',
+                avatar: '../../../static/image/timg.jpg'
+            },
+        ]
+        
+    },
+    onLoad: function (option) {
+        console.log(option)
+
+        wx.setNavigationBarTitle({
+            title: option.num + '条回复'//页面标题为路由参数
+        })
+
+
+    },
+    goToReading: function () {
+        let id = this.data.id;
+        let title = this.data.title;
+        wx.navigateTo({
+            url: `../../main/reading/reading?id=${id}&title=${title}`
+        })
+    },
+    onShareAppMessage: function (res) {
+        if (res.from === 'button') {
+            // 来自页面内转发按钮
+            console.log(res.target)
+        }
+        return {
+            title: '测试',
+            path: '/pages/social/works/works'
+        }
+    },
+    follow: function () {
+        let uid = 1;
+        let followUid = 2;
+        httpRequestApi.followUser(uid, followUid).success((res) => {
+            console.log(res)
+        });
+    },
+    // 去其他用户的作品页
+    goToOthers: function (e) {
+        wx.navigateTo({
+            url: `../../main/reading/reading?id=${id}&title=${title}`
+        })
+    },
+    // 查询回复
+    getReply: function () {
+        let uid = 1;
+        let columnId = 1001;
+        let pageNo = 1;
+        let pageSize = 10;
+        httpRequestApi.getReply(uid, columnId, pageNo, pageSize).success((res) => {
+            console.log(res);
+        });
+    },
+    // 打开回复详情页
+    goToDetail: function (e) {
+        let id = e.currentTarget.dataset.id;
+        let num = e.currentTarget.dataset.num;
+        console.log(e);
+        wx.navigateTo({
+            url: `../../social/replyDetail/replyDetail?id=${id}&num=${num}`
+        })
+    }
+})

+ 16 - 0
pages/social/replyDetail/replyDetail.wxml

@@ -0,0 +1,16 @@
+ <view class="commentArea">
+        <view class="{{index === 0? class1 : classNormal}}" wx:for="{{comment}}" wx:key="{{index}}" >
+            <image class="avatar" src="{{item.avatar}}" />
+            <view class="commentCore">
+                <text class="nickName">{{item.name}}</text>
+                <text class="time">{{item.time}}</text>
+                <text class="gut">{{item.text}}</text>
+            </view>
+            <view class="btnWrapper">
+                <image class="commentBtn" src="../../../static/image/comment.png" wx:if="{{index===0}}" />
+                <text class="commentText" wx:if="{{index===0}}">评论</text>
+                <image class="likeBtn" src="../../../static/image/like.png" />
+                <text class="likeText">{{item.likes}}</text>
+            </view>
+        </view>
+    </view>

+ 90 - 0
pages/social/replyDetail/replyDetail.wxss

@@ -0,0 +1,90 @@
+.commentArea {
+    width: 100%;
+}
+
+.commentArea .commentItem {
+    width: 100%;
+    padding: 0 0 0 23rpx;
+    height: 100%;
+    border-bottom: solid 2rpx #979797;
+    /* margin: 0 auto 10; */
+    display: flex;
+    position: relative;
+    background: #f0f1f5;
+}
+.commentArea  .commentItemFirst{
+    background: #fff;
+    border-bottom: none;
+    min-height: 200rpx;
+}
+.commentItem .commentCore {
+    margin-left: 14rpx;
+    width: 600rpx;
+    height: 100%;
+    display: flex;
+    flex-direction: column;
+}
+
+.commentItem .avatar {
+    border-radius: 50%;
+    width: 96rpx;
+    height: 96rpx;
+    margin-top: 18rpx;
+}
+
+.commentItem .nickName {
+    margin-top: 18rpx;
+    height: 44rpx;
+    font-size: 32rpx;
+    color: #000;
+    font-family: PingFangSC-Regular;
+}
+
+.commentItem .time {
+    width: 200rpx;
+    height: 44rpx;
+    font-size: 32rpx;
+    color: #686868;
+}
+
+.commentItem .gut {
+    margin-top: 12rpx;
+    width: 420rpx;
+    /* height: 44rpx; */
+    line-height: 44rpx;
+    font-size: 32rpx;
+    color: #000;
+    /* overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap; */
+}
+
+.commentItem .btnWrapper {
+    position: absolute;
+    top: 10rpx;
+    right: 30rpx;
+    display: flex;
+    align-items: center;
+}
+
+.btnWrapper .commentBtn {
+    width: 32rpx;
+    height: 30rpx;
+    margin-left: 8rpx;
+}
+
+.btnWrapper .commentText,
+.likeText {
+    width: 58rpx;
+    height: 40rpx;
+    color: #545454;
+    font-size: 28rpx;
+    line-height: 40rpx;
+    margin-left: 8rpx;
+}
+
+.btnWrapper .likeBtn {
+    width: 32rpx;
+    height: 28rpx;
+    margin-left: 8rpx;
+}

+ 65 - 14
pages/social/works/works.js

@@ -53,9 +53,11 @@ Page({
                 image: '../../../static/image/timg.jpg',
             }
         ],
+        inputValue: 'smdx',
         text: '总有一天我将实质性操作死去而你我的\xa0\xa0\xa0\xa0\xa0\xa0\xa0儿子自行车在啊实打实大苏打撒旦将加冕为王'
     },
     onLoad: function (option) {
+        console.log(option)
         if (option.title) {
             wx.setNavigationBarTitle({
                 title: option.title //页面标题为路由参数
@@ -66,8 +68,9 @@ Page({
             })
         }
         let uid = 1;
-        httpRequestApi.getWorksDetail(uid,option.uid).success((res)=>{
+        httpRequestApi.getWorksDetail(uid, option.id).success((res) => {
             console.log(res);
+            this.getReply();
         });
     },
     goToReading: function () {
@@ -79,25 +82,73 @@ Page({
     },
     onShareAppMessage: function (res) {
         if (res.from === 'button') {
-          // 来自页面内转发按钮
-          console.log(res.target)
+            // 来自页面内转发按钮
+            console.log(res.target)
         }
         return {
-          title: '测试',
-          path: '/pages/social/works/works'
+            title: '测试',
+            path: '/pages/social/works/works'
         }
-      },
-      follow: function(){
-          let uid = 1;
-          let followUid = 2;
-        httpRequestApi.followUser(uid,followUid).success((res)=>{
+    },
+    follow: function () {
+        let uid = 1;
+        let followUid = 2;
+        httpRequestApi.followUser(uid, followUid).success((res) => {
             console.log(res)
         });
-      },
-      // 去其他用户的作品页
-      goToOthers: function (e){
+    },
+    // 去其他用户的作品页
+    goToOthers: function (e) {
         wx.navigateTo({
             url: `../../main/reading/reading?id=${id}&title=${title}`
         })
-      }
+    },
+    // 查询回复
+    getReply: function () {
+        let uid = 1;
+        let columnId = 1001;
+        let pageNo = 1;
+        let pageSize = 10;
+        httpRequestApi.getReply(uid, columnId, pageNo, pageSize).success((res) => {
+            console.log(res);
+        });
+    },
+    // 打开回复详情页
+    goToDetail: function (e) {
+        let id = e.currentTarget.dataset.id;
+        let num = e.currentTarget.dataset.num;
+        console.log(e);
+        wx.navigateTo({
+            url: `../../social/replyDetail/replyDetail?id=${id}&num=${num}`
+        })
+    },
+    //  绑定输入框内容
+    inputValue: function (e) {
+        this.setData({
+            inputValue: e.detail.value
+        });
+    },
+    // 发布回复
+    sendHandler: function () {
+        console.log(this.data.inputValue);
+        if (this.data.inputValue !== '') {
+            // let uid = 1;
+            // let data = {
+            //     "postId": 1,
+            //     "content": this.data.inputValue
+            // }
+            // httpRequestApi.postReplyComment(uid, data).success(res => {
+            //     console.log(res);
+            // });
+            let uid = 1;
+            let data = {
+                "columnId": '1541403885738293',
+                colunmNames: '金色巴掌',
+                "detailDesc": this.data.inputValue
+            }
+            httpRequestApi.postReply(uid, data).success(res => {
+                console.log(res);
+            });
+        }
+    }
 })

+ 3 - 3
pages/social/works/works.wxml

@@ -26,16 +26,16 @@
     </view>
     <view class="commentSection">
         <view class="title">评论(38)</view>
-        <view class="commentInput">听了这么多,说点什么吧</view>
+        <input class="commentInput" bindconfirm="sendHandler" confirm-type="send" placeholder="听了这么多,说点什么吧" bindinput="inputValue"></input>
     </view>
     <view class="commentArea">
-        <view class="commentItem">
+        <view class="commentItem" >
             <image class="avatar" src="../../../static/image/timg.jpg" />
             <view class="commentCore">
                 <text class="nickName">阿尔萨斯</text>
                 <text class="time">10-18 09:56</text>
                 <text class="gut">{{text}}</text>
-                <view class="commentAll">共有123条评论</view>
+                <view class="commentAll" bindtap="goToDetail" data-id="1" data-num="8">共有123条评论</view>
             </view>
             <view class="btnWrapper">
                 <image class="commentBtn" src="../../../static/image/comment.png" />

+ 7 - 1
project.config.json

@@ -36,7 +36,7 @@
 			"list": []
 		},
 		"miniprogram": {
-			"current": 1,
+			"current": 2,
 			"list": [
 				{
 					"id": 0,
@@ -49,6 +49,12 @@
 					"name": "edit",
 					"pathName": "pages/user/myEdit/myEdit",
 					"query": ""
+				},
+				{
+					"id": -1,
+					"name": "作品页",
+					"pathName": "pages/social/works/works",
+					"query": "id=1001&title=铺满色巴掌的水泥道1"
 				}
 			]
 		}

+ 26 - 1
utils/APIClient.js

@@ -109,5 +109,30 @@ module.exports = {
 			pageNo: pageNo,
 			pageSize: pageSize
 		}).send();
-	}
+	},
+	// 获取回复信息
+	getReply(uid, columnId, pageNo, pageSize){
+		let url = getBaseUrl(`wx/posts/reply`);
+		return request.getInstance().header({
+			uid
+		}).url(url).data({
+			columnId: columnId,
+			pageNo: pageNo,
+			pageSize: pageSize
+		}).send();
+	},
+	// 发布回复(楼中楼)
+	postReplyComment(uid, data){
+		let url = getBaseUrl(`wx/reply`);
+		return request.getInstance().header({
+			uid
+		}).url(url).data(data).method('POST').send();
+	},
+	// 发布讨论
+	postReply(uid, data){
+		let url = getBaseUrl(`wx/posts`);
+		return request.getInstance().header({
+			uid
+		}).url(url).data(data).method('POST').send();
+	},
 }