Browse Source

我的朗读页面渲染

孙志雷 6 years atrás
parent
commit
b8a202878f
3 changed files with 98 additions and 90 deletions
  1. 83 74
      pages/user/myread/myread.js
  2. 13 14
      pages/user/myread/myread.wxml
  3. 2 2
      project.config.json

+ 83 - 74
pages/user/myread/myread.js

@@ -6,81 +6,89 @@ 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: "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: "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: "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: "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: "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: "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: "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: "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: "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: "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: "1",
+        avatar: '../../static/image/timg.jpg',
+        nickName: '喔喔',
+        time: '10-18 09:56'
+      }
     ]
   },
 
+  toWork: function (e) {
+    let lessonId = e.currentTarget.dataset.lessonid;
+    let title = e.currentTarget.dataset.title;
+    wx.navigateTo({
+      url: `../../social/works/works?id=${lessonId}&title=${title}`
+    });
+  },
+
   /**
    * 生命周期函数--监听页面加载
    */
@@ -95,9 +103,10 @@ Page({
       });
     }
     APIClient.myRead().success(res => {
-      console.log(res);
+      console.log(res.data.data.list);
+      debugger;
       this.setData({
-        // wareCards: res.data.data.data.list
+        wareCards: res.data.data.list
       });
     }).fail(err => {
       console.log(err);

+ 13 - 14
pages/user/myread/myread.wxml

@@ -1,34 +1,33 @@
+<wxs module="wxs">
+  function formatDate(time) {
+    var timeTemp = getDate(time);
+    var timeString = timeTemp.toLocaleDateString() + timeTemp.toLocaleTimeString();
+    return timeString.replace('/','-').replace('/','-').replace('上午',' ').replace('下午',' ');
+  }
+  module.exports.formatDate = formatDate;
+</wxs>
 <view class='my-read'>
-  <view class='read-article' wx:for="{{ wareCards }}" wx:key="{{ index }}">
-    <view class='read-top'>
-      <view class='top-img'>
-        <image src='{{ item.avatarUrl }}'></image>
-      </view>
-      <view class='read-info'>
-        <view class='title'>{{ item.nickName }}</view>
-        <view class='date'>{{ item.time }}</view>
-      </view>
-    </view>
+  <view class='read-article' wx:for="{{ wareCards }}" wx:key="{{ index }}" bindtap='toWork' data-lessonId='{{ item.id }}' data-title='{{ item.title }}'>
     <view class='video-preview'>
-      <image src='{{ item.previewUrl }}'></image>
+      <image src='{{ item.iconImg }}'></image>
     </view>
     <view class='content-title'>
       {{ item.title }}
     </view>
     <view class='content-detail'>
-      <view class='left'>{{ item.grade }}</view>
+      <view class='left'>{{ item.summary }}</view>
       <view class='right'>
         <view class='right-detail'>
           <view class='play-img'>
             <image src='../../../static/image/hotPlays.png'></image>
           </view>
-          <text>{{ item.plays }}</text>
+          <text>{{ item.playAmount }}</text>
         </view>
         <view class='right-detail'>
           <view class='point-img'>
             <image src='../../../static/image/like.png'></image>
           </view>
-          <text>{{ item.likes }}</text>
+          <text>{{ item.likeAmount }}</text>
         </view>
       </view>
     </view>

+ 2 - 2
project.config.json

@@ -36,12 +36,12 @@
 			"list": []
 		},
 		"miniprogram": {
-			"current": 20,
+			"current": 0,
 			"list": [
 				{
 					"id": 0,
 					"name": "edit",
-					"pathName": "pages/user/myEdit/myEdit",
+					"pathName": "pages/user/myread/myread",
 					"query": ""
 				},
 				{