Browse Source

user works done

dongyuan0658 5 years ago
parent
commit
ab274c514b

+ 2 - 1
app.json

@@ -20,7 +20,8 @@
     "pages/user/mycourse/mycourse",
     "pages/user/myread/myread",
     "pages/user/mycollection/mycollection",
-    "pages/user/walletDetails/walletDetails"
+    "pages/user/walletDetails/walletDetails",
+    "pages/user/myworks/myworks"
   ],
   "window": {
     "backgroundTextStyle": "light",

+ 1 - 2
pages/social/works/works.js

@@ -26,10 +26,9 @@ Page({
         // shareFlag: false
     },
     onLoad: function (option) {
-        console.log(option)
+        console.log(option.title);
         // debugger;
         let id = option.id ? option.id : option.scene.replace('QR', '')
-
         wx.setNavigationBarTitle({
             title: option.title //页面标题为路由参数
         })

+ 3 - 2
pages/user/myconcern/myconcern.js

@@ -10,9 +10,10 @@ Page({
       fanList:[]
   },
   toUserDetails: function(e){
-    let fanId = e.currentTarget.dataset.fanId;
+    let uid = e.currentTarget.dataset.uid;
+    console.log(uid);
     wx.navigateTo({
-      url: `../../social/works/works?fanId=${fanId}`
+      url: `../myworks/myworks?uid=${uid}`
     });
   },
   /**

+ 10 - 4
pages/user/myconcern/myconcern.wxml

@@ -1,14 +1,20 @@
 <wxs module="wxs">
   function formatDate(time) {
-    var timeTemp = getDate(time);
-    var timeString = timeTemp.toLocaleDateString() + timeTemp.toLocaleTimeString();
-    return timeString.replace('/','-').replace('/','-').replace('上午',' ').replace('下午',' ');
+    console.log(time);
+    var t = getDate(time); 
+    var tf = function(i){return (i < 10 ? '0' : '') + i};
+    var year = t.getFullYear();
+    var month = tf(t.getMonth() + 1);
+    var day = tf(t.getDate());
+    var hour = tf(t.getHours());
+    var minute = tf(t.getMinutes());
+    return month + '-' + day + ' ' + hour + ':' + minute;
   }
   module.exports.formatDate = formatDate;
 </wxs>
 <view class='my-concern'>
   <view class="concern-center">
-    <view class='concern-info' wx:for="{{ fanList }}" wx:key="{{ index }}" bindtap='toUserDetails' data-fanId='{{ item.fans.fanId }}'>
+    <view class='concern-info' wx:for="{{ fanList }}" wx:key="{{ index }}" bindtap='toUserDetails' data-uid='{{ item.user.uid }}' data-fanId='{{ item.fans.fanId }}'>
       <view class='avatar-box'>
         <image class='avatar-image' src="{{ item.user.avatar }}" />
       </view>

+ 174 - 0
pages/user/myworks/myworks.js

@@ -0,0 +1,174 @@
+// pages/user/myworks/myworks.js
+import APIClient from '../../../utils/APIClient.js'
+import { formatDate } from '../../../utils/util.js'
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    wareCards: [
+      {
+        title: "古诗词诵读(一)江南",
+        grade: "一年级(上学期)",
+        avatarUrl: '../../../static/image/timg.jpg',
+        previewUrl: "../../../static/image/timg.jpg",
+        plays: "17230",
+        likes: "71230",
+        classId: "1",
+        avatar: '../../static/image/timg.jpg',
+        nickName: '喔喔',
+        time: '10-18 09:56'
+      },
+      {
+        title: "古诗词诵读(一)江南",
+        grade: "一年级(上学期)",
+        avatarUrl: '../../../static/image/timg.jpg',
+        previewUrl: "../../../static/image/timg.jpg",
+        plays: "17230",
+        likes: "71230",
+        classId: "2",
+        avatar: '../../static/image/timg.jpg',
+        nickName: '喔喔',
+        time: '10-18 09:56'
+      },
+      {
+        title: "古诗词诵读(一)江南",
+        grade: "一年级(上学期)",
+        avatarUrl: '../../../static/image/timg.jpg',
+        previewUrl: "../../../static/image/timg.jpg",
+        plays: "17230",
+        likes: "71230",
+        classId: "3",
+        avatar: '../../static/image/timg.jpg',
+        nickName: '喔喔',
+        time: '10-18 09:56'
+      },
+      {
+        title: "古诗词诵读(一)江南",
+        grade: "一年级(上学期)",
+        avatarUrl: '../../../static/image/timg.jpg',
+        previewUrl: "../../../static/image/timg.jpg",
+        plays: "17230",
+        likes: "71230",
+        classId: "4",
+        avatar: '../../static/image/timg.jpg',
+        nickName: '喔喔',
+        time: '10-18 09:56'
+      },
+      {
+        title: "古诗词诵读(一)江南",
+        grade: "一年级(上学期)",
+        avatarUrl: '../../../static/image/timg.jpg',
+        previewUrl: "../../../static/image/timg.jpg",
+        plays: "17230",
+        likes: "71230",
+        classId: "5",
+        avatar: '../../static/image/timg.jpg',
+        nickName: '喔喔',
+        time: '10-18 09:56'
+      },
+      {
+        title: "古诗词诵读(一)江南",
+        grade: "一年级(上学期)",
+        avatarUrl: '../../../static/image/timg.jpg',
+        previewUrl: "../../../static/image/timg.jpg",
+        plays: "17230",
+        likes: "71230",
+        classId: "6",
+        avatar: '../../static/image/timg.jpg',
+        nickName: '喔喔',
+        time: '10-18 09:56'
+      }
+    ],
+    pageNo: 1,
+    totalNo: 0,
+    uid: ''
+  },
+  toMyWorks: function(e){
+    let id = e.currentTarget.dataset.id;
+    let title = e.currentTarget.dataset.title;
+    wx.navigateTo({
+      url: `../../social/works/works?id=${id}&title=${title}`
+    });
+  },
+  getResults(){
+    let pageNo = this.data.pageNo;
+    let pageSize = 3;
+    let uid = this.data.uid;
+    console.log('用户身份',uid);
+    APIClient.userWorks(uid, pageNo, pageSize).success(res => {
+      // debugger;
+      this.setData({
+        wareCards: res.data.data.list
+      });
+    }).fail(err => {
+      console.log(err);
+    });
+  },
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    this.setData({
+      uid: options.uid
+    },() => {
+      console.log(options.uid);
+    });
+    this.getResults();
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+    this.setData({
+      pageNo: this.data.pageNo + 1
+    })
+    if (this.data.pageNo <= this.data.totalNo) {
+      this.getResults();
+    }
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 1 - 0
pages/user/myworks/myworks.json

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

+ 51 - 0
pages/user/myworks/myworks.wxml

@@ -0,0 +1,51 @@
+<!--pages/user/myworks/myworks.wxml-->
+<wxs module="wxs">
+  function formatDate(time) {
+    console.log(time);
+    var t = getDate(time); 
+    var tf = function(i){return (i < 10 ? '0' : '') + i};
+    var year = t.getFullYear();
+    var month = tf(t.getMonth() + 1);
+    var day = tf(t.getDate());
+    var hour = tf(t.getHours());
+    var minute = tf(t.getMinutes());
+    return month + '-' + day + ' ' + hour + ':' + minute;
+  }
+  module.exports.formatDate = formatDate;
+</wxs>
+<view class='user-works'>
+  <view class='works-article' wx:for="{{ wareCards }}" wx:key="{{ index }}">
+    <view class='user-info'>
+      <view class='avatar-img'>
+        <image src='{{ item.user.avatar }}'></image>
+      </view>
+      <view>
+        <view class='user-name'>{{ item.user.wechatName }}</view>
+        <view class='user-time'>{{ wxs.formatDate(item.userRead.gmtCreated) }}</view>
+      </view>
+    </view>
+    <view class='video-preview' bindtap='toMyWorks' data-id='{{ item.userRead.id }}' data-title='{{ item.userRead.title }}'>
+      <image src='{{ item.userRead.iconImg }}'></image>
+    </view>
+    <view class='content-title'>
+      {{ item.userRead.title }}
+    </view>
+    <view class='content-detail'>
+      <view class='left'>{{ item.userRead.summary }}</view>
+      <view class='right'>
+        <view class='right-detail'>
+          <view class='play-img'>
+            <image src='../../../static/image/hotPlays.png'></image>
+          </view>
+          <text>{{ item.userRead.playAmount }}</text>
+        </view>
+        <view class='right-detail'>
+          <view class='point-img'>
+            <image src='../../../static/image/like.png'></image>
+          </view>
+          <text>{{ item.userRead.likeAmount }}</text>
+        </view>
+      </view>
+    </view>
+  </view>
+</view>

+ 108 - 0
pages/user/myworks/myworks.wxss

@@ -0,0 +1,108 @@
+/* pages/user/myworks/myworks.wxss */
+.user-works{
+  width: 750rpx;
+  background: #F0F1F5;
+}
+
+.works-article{
+  margin-top: 4rpx;
+  box-sizing: border-box;
+  width: 100%;
+  padding: 0 23rpx;
+  background: #FFFFFF;
+}
+
+.user-info{
+  width: 100%;
+  height: 120rpx;
+  font-size:32rpx;
+  display: flex;
+  align-items: center;
+}
+
+.avatar-img{
+  margin-right: 14rpx;
+  width: 96rpx;
+  height: 96rpx;
+  border-radius: 50%;
+}
+
+.avatar-img>image{
+  width: 100%;
+  height: 100%;
+  border-radius: 50%;
+}
+
+.user-name{
+  color: #000000;
+  font-weight: 500;
+}
+
+.user-time{
+  color: #686868;
+  font-weight: lighter;
+}
+
+.video-preview{
+  margin-top: 10rpx;
+  width: 100%;
+  height: 290rpx;
+  border-radius: 20rpx;
+}
+
+.video-preview>image{
+  width: 100%;
+  height: 100%;
+  border-radius: 20rpx;
+}
+
+.content-title{
+  margin-top: 10rpx;
+  width: 100%;
+  height: 40rpx;
+  font-size: 32rpx;
+  font-weight: 500;
+  color: #414141;
+}
+
+.content-detail{
+  margin-top: 30rpx;
+  width: 100%;
+  height: 50rpx;
+  display: flex;
+  justify-content: space-between;
+  font-size: 24rpx;
+}
+
+.left{
+  width: 200rpx;
+}
+
+.right{
+  width: 150rpx;
+  height: 100%;
+  display: flex;
+  justify-content: space-between;
+}
+
+.right image{
+  width: 100%;
+  height: 100%;
+}
+
+.play-img{
+  width: 20rpx;
+  height: 20rpx;
+}
+
+.point-img{
+  width: 26rpx;
+  height: 24rpx;
+}
+
+.right-detail{
+  width: 50rpx;
+  display: flex;
+  justify-content: space-between;
+  align-items: flex-start;
+}

+ 7 - 1
project.config.json

@@ -36,7 +36,7 @@
 			"list": []
 		},
 		"miniprogram": {
-			"current": 7,
+			"current": 8,
 			"list": [
 				{
 					"id": 0,
@@ -86,6 +86,12 @@
 					"name": "replydetails",
 					"pathName": "pages/social/replyDetail/replyDetail",
 					"query": ""
+				},
+				{
+					"id": 8,
+					"name": "works",
+					"pathName": "pages/user/myworks/myworks",
+					"query": ""
 				}
 			]
 		}

+ 11 - 0
utils/APIClient.js

@@ -322,4 +322,15 @@ module.exports = {
       uid: wx.getStorageSync('uid')
     }).url(url).send();
   },
+  // 获取 用户朗读的作品
+  userWorks(followUid, pageNo, pageSize){
+    let url = getBaseUrl('wx/userRead');
+    return request.getInstance().header({
+      uid: wx.getStorageSync('uid')
+    }).data({
+      uid: followUid,
+      pageNo: pageNo,
+      pageSize: pageSize
+    }).url(url).send();
+  },
 }