Browse Source

调接口

Rorschach 6 years ago
parent
commit
5cd1c2f1bc

+ 2 - 1
app.json

@@ -7,7 +7,8 @@
     "pages/main/singleBook/singleBook",
     "pages/main/reading/reading",
     "pages/user/myEdit/myEdit",
-    "pages/discount-group/discount-group"
+    "pages/discount-group/discount-group",
+    "pages/main/searchResult/searchResult"
   ],
   "window": {
     "backgroundTextStyle": "light",

+ 27 - 10
component/follow/follow.js

@@ -1,11 +1,11 @@
-export const followInit =  (that) => {
+import httpRequestApi from '../../utils/APIClient';
+export const followInit = (that) => {
   that.setData({
     followData: {
       title: '关注',
-      wareCards:[
-        {
-          title:"铺满色巴掌的水泥道",
-          grade:"一年级 上学期",
+      wareCards: [{
+          title: "铺满色巴掌的水泥道",
+          grade: "一年级 上学期",
           img: "../../static/image/timg.jpg",
           plays: "1",
           likes: "2",
@@ -15,8 +15,8 @@ export const followInit =  (that) => {
           time: '11-01 14:14'
         },
         {
-          title:"铺满色巴掌的水泥道",
-          grade:"一年级 上学期",
+          title: "铺满色巴掌的水泥道",
+          grade: "一年级 上学期",
           img: "../../static/image/timg.jpg",
           plays: "1",
           likes: "2",
@@ -26,8 +26,8 @@ export const followInit =  (that) => {
           time: '11-01 14:14'
         },
         {
-          title:"铺满色巴掌的水泥道",
-          grade:"一年级 上学期",
+          title: "铺满色巴掌的水泥道",
+          grade: "一年级 上学期",
           img: "../../static/image/timg.jpg",
           plays: "1",
           likes: "2",
@@ -40,5 +40,22 @@ export const followInit =  (that) => {
     }
   })
   //请求数据封装
-
+  that.getWorks = (uid, pageNo, pageSize) => {
+    httpRequestApi.getFollowWorks(uid, pageNo, pageSize).success(res => {
+      const followData = res.data.data.list;
+      const followTemp = [];
+      followData.forEach(item => {
+        const temp = {};
+        temp.nickName = item.user.wechatName;
+        temp.avatar = item.user.avatar;
+        temp.plays = item.userRead.playAmount;
+        temp.likes = item.userRead.likeAmount;
+        temp.id = item.userRead.id;
+        // 还差一些字段
+        followTemp.push(temp);
+      });
+      console.log(followTemp);
+    });
+  }
+  that.getWorks(1, 1, 10);
 }

+ 14 - 9
component/hot/hot.js

@@ -18,28 +18,28 @@ export const hotInit = (that) => {
         hotSearch: '鹅鹅鹅',
         wareCards:[
           {
-            title:"铺满色巴掌的水泥道",
+            title:"铺满色巴掌的水泥道1",
             grade:"一年级 上学期",
             img: "../../static/image/timg.jpg",
             plays: "1",
             likes: "2",
-            classId: "1"
+            classId: "1001"
           },
           {
-            title:"铺满金色巴掌的水泥道",
+            title:"铺满金色巴掌的水泥道2",
             grade:"一年级 上学期",
             img: "../../static/image/timg.jpg",
             plays: "12345",
             likes: "54321",
-            classId: "2"
+            classId: "1002"
           },
           {
-            title:"铺满金色巴掌的水泥道",
+            title:"铺满金色巴掌的水泥道3",
             grade:"一年级 上学期",
             img: "../../static/image/timg.jpg",
             plays: "12345",
             likes: "54321",
-            classId: "2"
+            classId: "1003"
           },
         ]
       }
@@ -48,6 +48,12 @@ export const hotInit = (that) => {
     that.searchHandler = () => {
       console.log('搜索按钮')
       console.log(that.data.hotInput);
+      if(that.data.hotInput.lenght !== 0){
+        wx.navigateTo({
+          url: `../main/searchResult/searchResult?keyWords=${that.data.hotInput}`
+        })
+      }
+      
     },
     // 输入框输入
     that.inputHandler = (e) => {
@@ -65,10 +71,10 @@ export const hotInit = (that) => {
     
     // 打开课程页面
     that.openClass = (e) =>{
-      let classId = e.currentTarget.dataset.classid;
+      let id = e.currentTarget.dataset.classid;
       let title = e.currentTarget.dataset.title;
       wx.navigateTo({
-        url: `../main/class/class?id=${classId}&title=${title}`
+        url: `../main/class/class?id=${id}&title=${title}`
       })
     }
     // 打开用户作品页面
@@ -87,7 +93,6 @@ export const hotInit = (that) => {
       })
     }
     that.getHotRecommend = (uid,pageNo,pageSize)=>{
-      console.log(pageNo)
       httpRequestApi.getHotRecommend(
         uid,
         pageNo,

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

@@ -6,6 +6,7 @@ Page({
     gesture: true,
     videoUrl: '',
     title: '',
+    poster: '',
     works: [{
         nickName: '萝莉小猫咪',
         time: '10-18 09:56',
@@ -75,6 +76,7 @@ Page({
     ]
   },
   onLoad: function (option) {
+    console.log(option);
     wx.setNavigationBarTitle({
       title: option.title //页面标题为路由参数
     })
@@ -97,7 +99,7 @@ Page({
     let id = this.data.id;
     let title = this.data.title;
     wx.navigateTo({
-      url: `../../main/reading/reading?id=${id}&title=${'战狼撤侨归来'}`
+      url: `../../main/reading/reading?id=${id}&title=${this.data.title}&img=${this.data.img}`
     })
   },
   goToWorks: function (e) {

File diff suppressed because it is too large
+ 51 - 12
pages/main/reading/reading.js


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

@@ -28,7 +28,7 @@
             <image class="microphone" src="{{recordFlag === 1 ? recordingGif :microphonePng}}" />
             <text>我要朗读</text>
         </view>
-        <view class="shareBtn footerBtn" wx:if="{{btnFlag}}">
+        <view class="shareBtn footerBtn" wx:if="{{btnFlag}}" bindtap="upload">
             <image src="../../../static/image/upload.png" />
             <text>上传</text>
         </view>

+ 73 - 0
pages/main/searchResult/searchResult.js

@@ -0,0 +1,73 @@
+import httpRequestApi from '../../../utils/APIClient';
+Page({
+  data: {
+    wareCards:[
+        {
+          title:"铺满色巴掌的水泥道1",
+          grade:"一年级 上学期",
+          img: "../../../static/image/timg.jpg",
+          plays: "1",
+          likes: "2",
+          classId: "1001"
+        },
+        {
+          title:"铺满金色巴掌的水泥道2",
+          grade:"一年级 上学期",
+          img: "../../../static/image/timg.jpg",
+          plays: "12345",
+          likes: "54321",
+          classId: "1002"
+        },
+        {
+          title:"铺满金色巴掌的水泥道3",
+          grade:"一年级 上学期",
+          img: "../../../static/image/timg.jpg",
+          plays: "12345",
+          likes: "54321",
+          classId: "1003"
+        },
+      ]
+  },
+  onLoad: function (option) {
+    console.log(option);
+    wx.setNavigationBarTitle({
+      title: '搜索' //页面标题为路由参数
+    })
+    console.log(option.keyWords)
+    this.search(option.keyWords);
+    // httpRequestApi.getClassDetail(uid, option.id).success(res => {
+    //     console.log(res);
+    //     this.setData({
+    //       title: res.data.data.title,
+    //       videoUrl:res.data.data.playUrl
+    //     })
+    // })
+  },
+  search: function(key){
+    httpRequestApi.getSearchResult(1,key,1,10).success(res =>{
+        console.log(res);
+        const result = res.data.data.list;
+        const resultTemp = [];
+        result.forEach(item => {
+            console.log(item)
+            const temp = {};
+            temp.title = item.lesson.title;
+            temp.grade = item.lesson.gradeClassify;
+            temp.img = item.lesson.iconImg;
+            temp.classId = item.lesson.id
+            resultTemp .push(temp);
+        });
+        this.setData({
+            wareCards: resultTemp
+        })
+        console.log(this.data.wareCards)
+    });
+  },
+  openClass: (e) =>{
+    let id = e.currentTarget.dataset.classid;
+    let title = e.currentTarget.dataset.title;
+    wx.navigateTo({
+      url: `../class/class?id=${id}&title=${title}`
+    })
+  }
+})

+ 9 - 0
pages/main/searchResult/searchResult.wxml

@@ -0,0 +1,9 @@
+<view class="hotWares" style="flex-direction:row;">
+            <view wx:for="{{wareCards}}" wx:key="{{index}}" class="hotWareCard" bindtap="openClass" data-classId="{{item.classId}}" data-title="{{item.title}}">
+                <image class="wareCardImg" src="{{item.img}}" />
+                <text class="wareCardTitle">{{item.title}}</text>
+                <view class="bottomData">
+                    <text class="wareCardTip">{{item.grade}}</text>
+                </view>
+            </view>
+        </view>

+ 52 - 0
pages/main/searchResult/searchResult.wxss

@@ -0,0 +1,52 @@
+.hotWares .hotWareCard {
+    position: relative;
+    overflow: hidden;
+    width: 704rpx;
+    height: 402rpx;
+    margin: 0 auto 20rpx;
+}
+.hotWareCard .wareCardImg {
+    width: 100%;
+    height: 290rpx;
+    border-radius: 20rpx;
+}
+
+
+
+.hotWareCard .wareCardTitle {
+    /* margin: 0 auto; */
+    width: 100%;
+    height: 46rpx;
+    display: block;
+    /* text-align: left; */
+    color: #414141;
+    font-size: 32rpx;
+    letter-spacing: 4rpx;
+    font-family: MicrosoftYaHei;
+}
+.hotWareCard .bottomData {
+    height: 34rpx;
+    margin-top: 10rpx;
+    display: flex;
+    /* flex-direction: row; */
+    justify-content: space-between;
+    align-items: center;
+}
+
+.hotWareCard .bottomData .wareCardPlays {
+    width: 100rpx;
+    margin-left: 270rpx;
+    display: flex;
+    flex-direction: row;
+    align-items: center;
+}
+
+.hotWareCard .wareCardTip {
+
+    width: 178rpx;
+    height: 40rpx;
+    display: block;
+    text-align: center;
+    color: #414141;
+    font-size: 24rpx;
+}

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

@@ -24,7 +24,7 @@ Page({
                 const temp = {};
                 temp.id = item.id;
                 temp.title = item.title;
-                // 少个阅读数
+                temp.readNum = item.readCount;
                 lessonTemp.push(temp);
             });
             this.setData({

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

@@ -10,7 +10,7 @@
     <view class="listSection">
         <view class="classItem" wx:for="{{lessonList}}" wx:key="{{index}}" data-id="{{item.id}}" data-title="{{item.title}}" bindtap="goToClass">
             <text class="classTitle">{{item.title}}</text>
-            <text class="readingNum">{{item.readingNum}}1232朗读 ></text>
+            <text class="readingNum">{{item.readingNum}}朗读 ></text>
         </view>
     </view>
     <view class="footerSection">

+ 49 - 9
utils/APIClient.js

@@ -37,15 +37,6 @@ module.exports = {
 			uid
 		}).url(url).send();
 	},
-	// 关注用户 
-	followUser(uid, followUid) {
-		let url = getBaseUrl(`wx/fans`);
-		return request.getInstance().header({
-			uid
-		}).url(url).data({
-			"uid": followUid
-		}).method('POST').send();
-	},
 	// 获取全部课本
 	getAllBooks(uid,pageNo,pageSize) {
 		let url = getProductUrl('wx/product');
@@ -69,5 +60,54 @@ module.exports = {
 		return request.getInstance().header({
 			uid
 		}).url(url).send();
+	},
+	// 发布作品
+	postWork(uid, data) {
+		console.log(data);
+		let url = getBaseUrl(`wx/userRead`);
+		return request.getInstance().header({
+			uid
+		}).url(url).data(data).method('POST').send();
+	},
+	// 关注用户 
+	followUser(uid, followUid) {
+		let url = getBaseUrl(`wx/fans`);
+		return request.getInstance().header({
+			uid
+		}).url(url).data({
+			"uid": followUid
+		}).method('POST').send();
+	},
+	//获取关注的用户列表
+	getFollowUsers(uid, pageNo, pageSize) {
+		let url = getBaseUrl(`wx/fans`);
+		return request.getInstance().header({
+			uid
+		}).url(url).data({
+			pageNo: pageNo,
+			pageSize: pageSize
+		}).send();
+	},
+	// 获取关注用户的作品列表
+	getFollowWorks(uid, pageNo, pageSize) {
+		let url = getBaseUrl(`wx/fans/interest`);
+		return request.getInstance().header({
+			uid
+		}).url(url).data({
+			pageNo: pageNo,
+			pageSize: pageSize
+		}).send();
+	},
+	// 搜索
+	getSearchResult(uid,key,pageNo,pageSize){
+		let url = getProductUrl(`wx/lesson`);
+		return request.getInstance().header({
+			uid
+		}).url(url).data({
+			title:key,
+			productId: '',
+			pageNo: pageNo,
+			pageSize: pageSize
+		}).send();
 	}
 }