diff --git a/.gitignore b/.gitignore
index e43b0f9..6e8821b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-.DS_Store
+.DS_Store
diff --git a/app.json b/app.json
index 3a08a57..748dd3c 100644
--- a/app.json
+++ b/app.json
@@ -1,46 +1,46 @@
-{
- "pages": [
- "pages/index/index",
- "pages/iclass/iclass",
- "pages/document/document",
- "pages/my/my",
- "pages/feedback/feedback",
- "pages/webview/webview",
- "pages/aboutus/aboutus",
- "pages/homework/homework",
- "pages/myFavor/myFavor"
- ],
- "window": {
- "backgroundTextStyle": "light",
- "navigationBarBackgroundColor": "#ffffff",
- "navigationBarTitleText": "我的北方",
- "navigationBarTextStyle": "black"
- },
- "tabBar": {
- "color": "#a9b7b7",
- "selectedColor": "#000000",
- "borderStyle": "black",
- "list": [
- {
- "selectedIconPath": "imgs/index/teach_y.png",
- "iconPath": "imgs/index/teach_n.png",
- "pagePath": "pages/index/index",
- "text": "教务"
- },
- {
- "selectedIconPath": "imgs/index/model_y.png",
- "iconPath": "imgs/index/model_n.png",
- "pagePath": "pages/iclass/iclass",
- "text": "多模式"
- },
- {
- "selectedIconPath": "imgs/index/my_y.png",
- "iconPath": "imgs/index/my_n.png",
- "pagePath": "pages/my/my",
- "text": "我的"
- }
- ]
- },
- "sitemapLocation": "sitemap.json",
- "resizable": true
+{
+ "pages": [
+ "pages/index/index",
+ "pages/iclass/iclass",
+ "pages/document/document",
+ "pages/my/my",
+ "pages/feedback/feedback",
+ "pages/webview/webview",
+ "pages/aboutus/aboutus",
+ "pages/homework/homework",
+ "pages/myFavor/myFavor"
+ ],
+ "window": {
+ "backgroundTextStyle": "light",
+ "navigationBarBackgroundColor": "#ffffff",
+ "navigationBarTitleText": "我的北方",
+ "navigationBarTextStyle": "black"
+ },
+ "tabBar": {
+ "color": "#a9b7b7",
+ "selectedColor": "#000000",
+ "borderStyle": "black",
+ "list": [
+ {
+ "selectedIconPath": "imgs/index/teach_y.png",
+ "iconPath": "imgs/index/teach_n.png",
+ "pagePath": "pages/index/index",
+ "text": "教务"
+ },
+ {
+ "selectedIconPath": "imgs/index/model_y.png",
+ "iconPath": "imgs/index/model_n.png",
+ "pagePath": "pages/iclass/iclass",
+ "text": "多模式"
+ },
+ {
+ "selectedIconPath": "imgs/index/my_y.png",
+ "iconPath": "imgs/index/my_n.png",
+ "pagePath": "pages/my/my",
+ "text": "我的"
+ }
+ ]
+ },
+ "sitemapLocation": "sitemap.json",
+ "resizable": true
}
\ No newline at end of file
diff --git a/imgs/iclass/refresh.png b/imgs/iclass/refresh.png
new file mode 100644
index 0000000..8ca4d5e
Binary files /dev/null and b/imgs/iclass/refresh.png differ
diff --git a/pages/document/document.js b/pages/document/document.js
index 9ffae38..fddb98a 100644
--- a/pages/document/document.js
+++ b/pages/document/document.js
@@ -11,6 +11,10 @@ import {
offFavor
} from "../../utils/document.js"
+import {
+ mySearch,
+} from "../../utils/search.js"
+
const app = getApp()
Page({
@@ -22,7 +26,9 @@ Page({
courseList: '',
course_code: '',
course_name: '',
- status: ''
+ inform_loading:true,
+ // searchBan: false,
+ searchInfo:false,
},
@@ -59,6 +65,12 @@ Page({
else{
that.setData({
courseList: res.data,
+ inform_loading:false,
+ // searchBan:true
+ })
+ wx.setStorage({
+ key: 'courseList',
+ data: that.data.courseList,
})
}
}
@@ -115,5 +127,9 @@ Page({
courseList: that.data.courseList
})
offFavor(that.data.courseList[index])
- }
+ },
+
+ search: function (e) { //搜索
+ mySearch(this, e)
+ },
})
\ No newline at end of file
diff --git a/pages/document/document.wxml b/pages/document/document.wxml
index 9b6fcc5..6703117 100644
--- a/pages/document/document.wxml
+++ b/pages/document/document.wxml
@@ -1,4 +1,4 @@
-
+
我们不生产课件
我们只是知识的搬运工
@@ -6,31 +6,39 @@
-
-
-
-
-
- {{item.file_name}}
-
-
-
+
+
+
+
+
+ ---无相关内容---
+
+
+
+
+
+
+ {{item.file_name}}
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
\ No newline at end of file
diff --git a/pages/document/document.wxss b/pages/document/document.wxss
index 964c036..b8df64a 100644
--- a/pages/document/document.wxss
+++ b/pages/document/document.wxss
@@ -1,8 +1,8 @@
.inform {
- position: absolute;
- z-index: 0;
+ /* position: absolute;
+ z-index: 0; */
width: 100%;
- height: 50%;
+ margin-top: 250rpx;
display: flex;
flex-direction: column;
justify-content: center;
@@ -16,13 +16,44 @@
width: 80%;
}
-.main {
- position: absolute;
- z-index: 1;
- left: 3%;
+.main {
background-color: #fff;
}
+.mySearch {
+ margin: 0 auto;
+ display: flex;
+ flex-direction: row;
+ justify-content: center;
+ align-items: center;
+ width: 70%;
+ height: 40rpx;
+ background-color: whitesmoke;
+ /* margin-top: 30rpx; */
+ border: 10rpx solid whitesmoke;
+ border-radius: 35px;
+ /* font-size: 15rpx; */
+}
+
+.place-holder {
+ font-size: 12px;
+}
+
+.search_inform {
+ margin: 0 auto;
+ width: 100%;
+ margin-top: 100rpx;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+}
+
+.txtInfo {
+ color: rgb(163, 159, 159);
+ font-size: 32rpx;
+}
+
.coursewareBlock {
height: 180rpx;
width: 704rpx;
diff --git a/pages/homework/homework.js b/pages/homework/homework.js
index 7ad5513..1ca27e7 100644
--- a/pages/homework/homework.js
+++ b/pages/homework/homework.js
@@ -1,42 +1,42 @@
-// pages/homework/homework.js
-import {
- myURL
-} from "../../setting.js"
-const app = getApp()
-
-Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- // homeList_all:'',
- homeList: '',
- course_name: '',
- // joint: '',
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- let that = this
- // console.log(options.homeList_all)
- that.setData({
- course_name: options.course_name,
- homeList_all: JSON.parse(options.homeList_all)
- })
- wx.setNavigationBarTitle({
- title: that.data.course_name,
- })
- for (var key in that.data.homeList_all) {
- if (that.data.course_name == key) {
- that.setData({
- homeList: that.data.homeList_all[key],
- // end_date: that.data.homeList_all[key].end_date
- })
- break
- }
- }
- },
+// pages/homework/homework.js
+import {
+ myURL
+} from "../../setting.js"
+const app = getApp()
+
+Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+ // homeList_all:'',
+ homeList: '',
+ course_name: '',
+ // joint: '',
+ },
+
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad: function (options) {
+ let that = this
+ // console.log(options.homeList_all)
+ that.setData({
+ course_name: options.course_name,
+ homeList_all: JSON.parse(options.homeList_all)
+ })
+ wx.setNavigationBarTitle({
+ title: that.data.course_name,
+ })
+ for (var key in that.data.homeList_all) {
+ if (that.data.course_name == key) {
+ that.setData({
+ homeList: that.data.homeList_all[key],
+ // end_date: that.data.homeList_all[key].end_date
+ })
+ break
+ }
+ }
+ },
})
\ No newline at end of file
diff --git a/pages/homework/homework.json b/pages/homework/homework.json
index 8835af0..6f5247b 100644
--- a/pages/homework/homework.json
+++ b/pages/homework/homework.json
@@ -1,3 +1,3 @@
-{
- "usingComponents": {}
+{
+ "usingComponents": {}
}
\ No newline at end of file
diff --git a/pages/homework/homework.wxml b/pages/homework/homework.wxml
index 246f124..9e283e4 100644
--- a/pages/homework/homework.wxml
+++ b/pages/homework/homework.wxml
@@ -1,31 +1,31 @@
-
-
-
-
-
- {{item.assignment_name}}
-
-
-
-
-
-
-
-
-
- 截止时间:{{item.end_date}}
-
-
-
-
-
+
+
+
+
+
+ {{item.assignment_name}}
+
+
+
+
+
+
+
+
+
+ 截止时间:{{item.end_date}}
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/iclass/iclass.js b/pages/iclass/iclass.js
index 563fc96..bcb0514 100644
--- a/pages/iclass/iclass.js
+++ b/pages/iclass/iclass.js
@@ -19,7 +19,7 @@ Page({
* 页面的初始数据
*/
data: {
- authed:true,
+ authed: true,
courseList: null,
},
@@ -88,23 +88,22 @@ Page({
console.log('没作业')
}
})
- }//end if
+ } //end if
},
-toAuth:function(){
- goAuth()
-},
+ toAuth: function() {
+ goAuth()
+ },
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
- onPullDownRefresh: function() {
- // wx.showNavigationBarLoading();
+ doRefresh: function() {
+ wx.startPullDownRefresh()
let that = this
wx.request({
url: myURL + '/courselist',
- // url:"http://v.ncut.edu.cn/course?sno=17152010120",
data: {
openid: app.globalData.openid
},
diff --git a/pages/iclass/iclass.wxml b/pages/iclass/iclass.wxml
index 7eaa10f..d42749e 100644
--- a/pages/iclass/iclass.wxml
+++ b/pages/iclass/iclass.wxml
@@ -7,7 +7,10 @@
课程列表
+
+
+
diff --git a/pages/iclass/iclass.wxss b/pages/iclass/iclass.wxss
index da3d7ee..ca10ee7 100755
--- a/pages/iclass/iclass.wxss
+++ b/pages/iclass/iclass.wxss
@@ -6,11 +6,15 @@
z-index: 1;
width: 100%;
box-shadow: 0px 4px 30px 4px #fff;
+ display: flex;
+ flex-direction: row;
+ justify-content: center;
+ align-items: center;
}
.blackBG {
width: 275rpx;
height: 70rpx;
- background-color: #000;
+ /* background-color: #000; */
display: flex;
justify-content: center;
align-items: center;
@@ -19,10 +23,20 @@
}
.title {
- color: #fff;
+ color: #000;
display: inline-block;
font-size: 40rpx;
+ font-weight: bold;
}
+.freshView{
+ background-color: rgb(173, 80, 80);
+}
+.fresh_img{
+ margin-left: 28rpx;
+ width: 30rpx;
+ height: 30rpx;
+}
+
.topView{
position: absolute;
z-index: 0;
diff --git a/pages/myFavor/myFavor.js b/pages/myFavor/myFavor.js
index 34ed34d..5be7edb 100644
--- a/pages/myFavor/myFavor.js
+++ b/pages/myFavor/myFavor.js
@@ -1,95 +1,113 @@
-// pages/myFavor/myFavor.js
-var util = require('../../utils/util.js')
-import {
- myURL
-} from "../../setting.js"
-
-import {
- lookFile,
- downloadFile,
- onFavor,
- offFavor
-} from "../../utils/document.js"
-
-const app = getApp()
-
-Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- favorList: [],
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- wx.setNavigationBarTitle({
- title: "我的收藏",
- })
- let that = this
- wx.request({
- url: myURL + '/favourite/get',
- data: {
- openid: app.globalData.openid
- },
- success(res) {
- console.log(res.data)
- that.setData({
- favorList: res.data
- })
- }
- })
- },
-
- onShareAppMessage: function (res) {
- var courseware = this.data.favorList[res.target.dataset.index]
- if (res.from === 'button') {
- return {
- title: courseware.file_name,
- path: '/pages/iclass/iclass?courseware=' + JSON.stringify(courseware),
- imageUrl: "../../imgs/share.png"
- }
- }
- },
-
- lookFile: function (e) {
- var that = this
- var index = e.currentTarget.dataset.index
- if (that.data.favorList[index].type === 'dir') {
- wx.navigateTo({
- url: '/pages/document/document?code=' + course_code + 'item' + that.data.favorList[index].sign
- })
- } else {
- lookFile(that.data.favorList[index])
- }
- },
-
- downFile: function (e) { //下载课件
- let that = this
- var index = e.currentTarget.dataset.index
- downloadFile(that.data.favorList[index])
- },
-
- favourites: function (e) {
- var index = e.currentTarget.dataset.index
- var that = this
- that.data.favorList[index].favourite = true
- that.setData({
- favorList: that.data.favorList
- })
- onFavor(that.data.favorList[index])
- },
-
- unfavourites: function (e) {
- var index = e.currentTarget.dataset.index
- var that = this
- that.data.favorList[index].favourite = false
- that.setData({
- favorList: that.data.favorList
- })
- offFavor(that.data.favorList[index])
- },
+// pages/myFavor/myFavor.js
+var util = require('../../utils/util.js')
+import {
+ myURL
+} from "../../setting.js"
+
+import {
+ lookFile,
+ downloadFile,
+ onFavor,
+ offFavor
+} from "../../utils/document.js"
+
+import {
+ mySearch,
+} from "../../utils/search.js"
+
+const app = getApp()
+
+Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+ courseList: [],
+ searchInfo: false
+ },
+
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad: function(options) {
+ wx.setNavigationBarTitle({
+ title: "我的收藏",
+ })
+ },
+
+ onShow: function(res) {
+ let that = this
+ wx.request({
+ url: myURL + '/favourite/get',
+ data: {
+ openid: app.globalData.openid
+ },
+ success(res) {
+ console.log(res.data)
+ that.setData({
+ courseList: res.data
+ })
+ wx.setStorage({
+ key: 'courseList',
+ data: that.data.courseList,
+ })
+ }
+ })
+ },
+
+ onShareAppMessage: function(res) {
+ var courseware = this.data.courseList[res.target.dataset.index]
+ if (res.from === 'button') {
+ return {
+ title: courseware.file_name,
+ path: '/pages/iclass/iclass?courseware=' + JSON.stringify(courseware),
+ imageUrl: "../../imgs/share.png"
+ }
+ }
+ },
+
+ lookFile: function(e) {
+ var that = this
+ var index = e.currentTarget.dataset.index
+ if (that.data.courseList[index].type === 'dir') {
+ wx.navigateTo({
+ url: '/pages/document/document?code=' + course_code + 'item' + that.data.courseList[index].sign
+ })
+ } else {
+ lookFile(that.data.courseList[index])
+ }
+ },
+
+ downFile: function(e) { //下载课件
+ let that = this
+ var index = e.currentTarget.dataset.index
+ downloadFile(that.data.courseList[index])
+ },
+
+ favourites: function(e) {
+ var index = e.currentTarget.dataset.index
+ var that = this
+ that.data.courseList[index].favourite = true
+ that.setData({
+ courseList: that.data.courseList
+ })
+ onFavor(that.data.courseList[index])
+ },
+
+ unfavourites: function(e) {
+ var index = e.currentTarget.dataset.index
+ var that = this
+ that.data.courseList[index].favourite = false
+ that.setData({
+ courseList: that.data.courseList
+ })
+ offFavor(that.data.courseList[index])
+ },
+
+
+ search: function(e) { //搜索
+ mySearch(this,e)
+ },
+
})
\ No newline at end of file
diff --git a/pages/myFavor/myFavor.json b/pages/myFavor/myFavor.json
index 8835af0..6f5247b 100644
--- a/pages/myFavor/myFavor.json
+++ b/pages/myFavor/myFavor.json
@@ -1,3 +1,3 @@
-{
- "usingComponents": {}
+{
+ "usingComponents": {}
}
\ No newline at end of file
diff --git a/pages/myFavor/myFavor.wxml b/pages/myFavor/myFavor.wxml
index 3a91fcf..4afb660 100644
--- a/pages/myFavor/myFavor.wxml
+++ b/pages/myFavor/myFavor.wxml
@@ -1,36 +1,44 @@
-
-
- ---无收藏内容---
-
-
-
-
-
-
-
-
-
- {{item.file_name}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ ---您的收藏夹是空的---
+
+
+
+
+
+
+
+
+ ---无相关内容---
+
+
+
+
+
+
+
+
+ {{item.file_name}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/myFavor/myFavor.wxss b/pages/myFavor/myFavor.wxss
index d5ab7d4..d5e1731 100644
--- a/pages/myFavor/myFavor.wxss
+++ b/pages/myFavor/myFavor.wxss
@@ -2,25 +2,37 @@
position: absolute;
z-index: 0;
width: 100%;
- height: 50%;
+ margin-top: 100rpx;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
-.informIMGview {
- height: 500rpx;
- /* background-color: rgb(172, 16, 16); */
- display: flex;
- margin: 0 auto;
-}
-
.txtInfo {
color: rgb(163, 159, 159);
font-size: 32rpx;
}
+.mySearch {
+ margin: 0 auto;
+ display: flex;
+ flex-direction: row;
+ justify-content: center;
+ align-items: center;
+ width: 70%;
+ height: 40rpx;
+ background-color: whitesmoke;
+ /* margin-top: 5%; */
+ border: 10rpx solid whitesmoke;
+ border-radius: 35px;
+ /* font-size: 15rpx; */
+}
+
+.place-holder {
+ font-size: 12px;
+}
+
.main {
position: absolute;
z-index: 1;
diff --git a/templates/authView/authView.wxml b/templates/authView/authView.wxml
index d4dd284..3c5247d 100644
--- a/templates/authView/authView.wxml
+++ b/templates/authView/authView.wxml
@@ -1,18 +1,18 @@
-
-
-
-
- 亲爱的
-
-
- 欢迎来到“我的北方”
-
- 您需要
- 认证
- 方可正常使用此小程序
-
-
-
- 点击前往认证
-
+
+
+
+
+ 亲爱的
+
+
+ 欢迎来到“我的北方”
+
+ 您需要
+ 认证
+ 方可正常使用此小程序
+
+
+
+ 点击前往认证
+
\ No newline at end of file
diff --git a/templates/authView/authView.wxss b/templates/authView/authView.wxss
index 32ffbfe..6787c5e 100644
--- a/templates/authView/authView.wxss
+++ b/templates/authView/authView.wxss
@@ -1,56 +1,56 @@
-.authView {
- width: 100%;
- padding-top: 250rpx;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- background-color: #fff;
-}
-
-.authView-word {
- width: 548rpx;
-}
-
-.authView-line {
- font-size: 30rpx;
- margin-bottom: 10rpx;
-}
-
-.authView-line2 {
- margin-top: 15rpx;
- font-size: 35rpx;
- font-weight: bold;
-}
-
-.authView-renzheng {
- color: #118562;
-}
-
-.authView-img {
- margin-top: 50rpx;
- width: 584rpx;
- height: 278rpx;
-}
-
-.authView-btn {
- width: 400rpx;
- height: 98rpx;
- font-size: 35rpx;
- box-shadow: 0rpx 0rpx 20rpx 0rpx #e4e3e3;
- background-color: #ffffff;
- color: rgb(85, 83, 83);
- border-radius: 20rpx;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- margin-top: 50rpx;
-}
-
-.authView-btnhover {
- background-color: #ebe7e7;
- border-radius: 20rpx;
- opacity: 0.8;
- transform: scale(0.9, 0.9);
+.authView {
+ width: 100%;
+ padding-top: 250rpx;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ background-color: #fff;
+}
+
+.authView-word {
+ width: 548rpx;
+}
+
+.authView-line {
+ font-size: 30rpx;
+ margin-bottom: 10rpx;
+}
+
+.authView-line2 {
+ margin-top: 15rpx;
+ font-size: 35rpx;
+ font-weight: bold;
+}
+
+.authView-renzheng {
+ color: #118562;
+}
+
+.authView-img {
+ margin-top: 50rpx;
+ width: 584rpx;
+ height: 278rpx;
+}
+
+.authView-btn {
+ width: 400rpx;
+ height: 98rpx;
+ font-size: 35rpx;
+ box-shadow: 0rpx 0rpx 20rpx 0rpx #e4e3e3;
+ background-color: #ffffff;
+ color: rgb(85, 83, 83);
+ border-radius: 20rpx;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ margin-top: 50rpx;
+}
+
+.authView-btnhover {
+ background-color: #ebe7e7;
+ border-radius: 20rpx;
+ opacity: 0.8;
+ transform: scale(0.9, 0.9);
}
\ No newline at end of file
diff --git a/utils/document.js b/utils/document.js
index 2c34707..dea743b 100644
--- a/utils/document.js
+++ b/utils/document.js
@@ -1,98 +1,98 @@
-import { myURL } from "../setting.js"
-const app = getApp()
-
-export function lookFile(courseware) {
- wx.showLoading({
- title: '加载中',
- mask: true
- })
- wx.downloadFile({
- url: myURL + '/courseware?openid=' + app.globalData.openid + '&courseware=' + JSON.stringify(courseware),
-
- success(res) {
- const filePath = res.tempFilePath
- var fileType = courseware.type
- wx.openDocument({
- filePath,
- fileType: fileType,
- success(res) {
- wx.hideLoading()
- console.log('打开文档成功')
- },
- fail(res) {
- wx.showToast({
- title: '该文件类型不支持预览,请下载',
- icon: 'none',
- })
- console.log('打开文档失败')
- }
- })
- },
- })
-}
-
-export function downloadFile(courseware) {
- wx.request({
- url: myURL + '/reqdownload',
- data: {
- openid: app.globalData.openid,
- courseware: JSON.stringify(courseware)
- },
- success(res) {
- console.log(res.data)
- var wareURL = myURL + '/download?id=' + res.data
- wx.showModal({
- title: '复制以下链接到浏览器下载',
- content: wareURL,
- confirmText: '复制',
- success(res) {
- if (res.confirm) {
- wx.setClipboardData({
- data: wareURL,
- success() {
- wx.showToast({
- title: '复制成功',
- icon: 'success'
- })
- }
- })
- }
- }
- })
- },
- fail(res) {
- wx.showToast({
- title: '下载链接消失了',
- icon: 'none',
- })
- }
- })
-}
-
-export function onFavor(courseware){
- wx.request({
- url: myURL + '/favourite/courseware',
- data: {
- openid: app.globalData.openid,
- courseware: JSON.stringify(courseware),
- mode: 'add'
- },
- success: function (res) {
- console.log(res.data)
- }
- })
-}
-
-export function offFavor(courseware){
- wx.request({
- url: myURL + '/favourite/courseware',
- data: {
- openid: app.globalData.openid,
- courseware: JSON.stringify(courseware),
- mode: 'del',
- },
- success: function (res) {
- console.log(res.data)
- }
- })
+import { myURL } from "../setting.js"
+const app = getApp()
+
+export function lookFile(courseware) {
+ wx.showLoading({
+ title: '加载中',
+ mask: true
+ })
+ wx.downloadFile({
+ url: myURL + '/courseware?openid=' + app.globalData.openid + '&courseware=' + JSON.stringify(courseware),
+
+ success(res) {
+ const filePath = res.tempFilePath
+ var fileType = courseware.type
+ wx.openDocument({
+ filePath,
+ fileType: fileType,
+ success(res) {
+ wx.hideLoading()
+ console.log('打开文档成功')
+ },
+ fail(res) {
+ wx.showToast({
+ title: '该文件类型不支持预览,请下载',
+ icon: 'none',
+ })
+ console.log('打开文档失败')
+ }
+ })
+ },
+ })
+}
+
+export function downloadFile(courseware) {
+ wx.request({
+ url: myURL + '/reqdownload',
+ data: {
+ openid: app.globalData.openid,
+ courseware: JSON.stringify(courseware)
+ },
+ success(res) {
+ console.log(res.data)
+ var wareURL = myURL + '/download?id=' + res.data
+ wx.showModal({
+ title: '复制以下链接到浏览器下载',
+ content: wareURL,
+ confirmText: '复制',
+ success(res) {
+ if (res.confirm) {
+ wx.setClipboardData({
+ data: wareURL,
+ success() {
+ wx.showToast({
+ title: '复制成功',
+ icon: 'success'
+ })
+ }
+ })
+ }
+ }
+ })
+ },
+ fail(res) {
+ wx.showToast({
+ title: '下载链接消失了',
+ icon: 'none',
+ })
+ }
+ })
+}
+
+export function onFavor(courseware){
+ wx.request({
+ url: myURL + '/favourite/courseware',
+ data: {
+ openid: app.globalData.openid,
+ courseware: JSON.stringify(courseware),
+ mode: 'add'
+ },
+ success: function (res) {
+ console.log(res.data)
+ }
+ })
+}
+
+export function offFavor(courseware){
+ wx.request({
+ url: myURL + '/favourite/courseware',
+ data: {
+ openid: app.globalData.openid,
+ courseware: JSON.stringify(courseware),
+ mode: 'del',
+ },
+ success: function (res) {
+ console.log(res.data)
+ }
+ })
}
\ No newline at end of file
diff --git a/utils/search.js b/utils/search.js
new file mode 100644
index 0000000..04b6686
--- /dev/null
+++ b/utils/search.js
@@ -0,0 +1,41 @@
+const app = getApp()
+
+export function mySearch(that, e) { //搜索
+ var courseList_tmp = []
+ wx.getStorage({
+ key: 'courseList',
+ success: function(res) {
+ courseList_tmp = res.data
+ if (courseList_tmp.length != 0) {
+ if (e.detail.value.length == 0) {
+ that.setData({
+ searchInfo: false,
+ courseList: courseList_tmp,
+ })
+ } else {
+ var queryList = []
+ var inputValue = e.detail.value
+ for (var i = 0; i < courseList_tmp.length; i++) {
+ var name = courseList_tmp[i].file_name
+ for (var j = 0; j <= name.length - inputValue.length; j++) {
+ if (name.substr(j, inputValue.length) == inputValue) {
+ queryList.push(courseList_tmp[i])
+ break
+ }
+ }
+ }
+ if (queryList.length == 0) {
+ that.setData({
+ searchInfo: true
+ })
+ } else {
+ that.setData({
+ searchInfo: false,
+ courseList: queryList,
+ })
+ }
+ }
+ }
+ },
+ })
+}
\ No newline at end of file