diff --git a/app.js b/app.js
index 8fe40c3..3dfbb50 100644
--- a/app.js
+++ b/app.js
@@ -20,5 +20,8 @@ App({
console.log(user);
console.log(AV.User.current());
});
+ wx.cloud.init({
+ env: 'test-tkkvk'
+ })
}
});
\ No newline at end of file
diff --git a/app.json b/app.json
index acf2136..f5a417a 100644
--- a/app.json
+++ b/app.json
@@ -1,6 +1,5 @@
{
"pages": [
-
"pages/classes/classes",
"pages/changeuser/changeuser",
"pages/index/index",
@@ -14,7 +13,8 @@
"pages/classroom/classroom",
"pages/setting/setting",
"pages/user/user",
- "pages/addclass/addclass"
+ "pages/addclass/addclass",
+ "pages/classdetail/classdetail"
],
"window": {
"backgroundTextStyle": "light",
diff --git a/model/file.js b/model/file.js
new file mode 100644
index 0000000..74a080a
--- /dev/null
+++ b/model/file.js
@@ -0,0 +1,37 @@
+const AV = require("../lib/av-live-query-weapp-min")
+
+class File extends AV.Object{
+ get url(){
+ return this.get("url");
+ }
+ set url(value){
+ this.set("url", value);
+ }
+ get fileid(){
+ return this.get("fileid");
+ }
+ set fileid(value){
+ this.set("fileid", value);
+ }
+ get class(){
+ return this.get("class");
+ }
+ set class(value){
+ this.set("class", value);
+ }
+ get filename(){
+ return this.get("filename");
+ }
+ set filename(value){
+ this.set("filename", value);
+ }
+ get uploader(){
+ return this.get("uploader");
+ }
+ set uploader(value){
+ this.set("uploader", value);
+ }
+}
+
+AV.Object.register(File, "File_");
+module.exports = File;
\ No newline at end of file
diff --git a/pages/classdetail/classdetail.js b/pages/classdetail/classdetail.js
new file mode 100644
index 0000000..ea05dc9
--- /dev/null
+++ b/pages/classdetail/classdetail.js
@@ -0,0 +1,203 @@
+// pages/classdetail/classdetail.js
+const AV = require("../../lib/av-live-query-weapp-min")
+const File = require("../../model/file")
+const Class = require("../../model/class")
+const { jsonify } = require('../../utils/leancloudutils');
+
+Page({
+ /**
+ * 页面的初始数据
+ */
+ class: null,
+ pic_urls: [],
+ data: {
+ files:[]
+ },
+
+ preview_pic:function(event){
+ wx.showLoading({
+ title: '加载中',
+ })
+ fileid = event.currentTarget.dataset.fileid;
+ wx.previewImage({
+ urls: [fileid],
+ current: this.pic_urls,
+ complete:wx.hideLoading
+ })
+ },
+ del_file: function(event){
+
+ },
+ download: function(event){
+ console.log(event);
+ fileid = event.currentTarget.dataset.fileid;
+ wx.showLoading({
+ title: '下载中',
+ })
+ wx.cloud.downloadFile({
+ fileID: fileid,
+ success: res => {
+ // 返回临时文件路径
+ console.log(res.tempFilePath);
+ wx.openDocument({
+ filePath: res.tempFilePath,
+ success: function (res) {
+ console.log('打开文档成功')
+ },
+ fail:console.error,
+ complete:wx.hideLoading
+ })
+ // wx.saveFile({
+ // tempFilePath: res.tempFilePath,
+ // success(res) {
+ // const savedFilePath = res.savedFilePath;
+ // console.log(savedFilePath);
+ // }
+ // })
+
+ },
+ fail: console.error
+ })
+
+ },
+ upload: function(event){
+ console.log(event)
+ pull_files = this.pull_files.bind(this);
+ class_ = this.class;
+ wx.showToast({
+ title: '请选择聊天文件',
+ icon:"none"
+ })
+ wx.chooseMessageFile({
+ count: 1,
+ success(res){
+ const tempFile = res.tempFiles[0];
+ const filename = tempFile.name;
+ const filepath = tempFile.path;
+ const cloudpath = tempFile.time+"/" + filename;
+ console.log(res);
+ wx.showLoading({
+ title: '上传中',
+ })
+ wx.cloud.uploadFile({
+ cloudPath: cloudpath,
+ filePath: filepath,
+ success: res => {
+ // 返回文件 ID
+ fileid = res.fileID;
+ file = new File({
+ filename: filename,
+ class: class_,
+ uploader: AV.User.current(),
+ fileid: fileid
+ }).save().then(()=>{
+ wx.hideLoading();
+ pull_files();
+ wx.showToast({
+ title: '上传成功',
+ })
+ },
+ ()=>{
+ wx.hideLoading();
+ wx.showToast({
+ title: "上传失败",
+ icon: "none"
+ })
+ }).catch(console.error);
+ console.log(res.fileID);
+ },
+ fail: error=>{
+ console.error(error);
+ wx.hideLoading();
+ wx.showToast({
+ title: '上传失败',
+ icon:"none"
+ })
+ }
+ })
+ }
+ })
+ },
+
+ pull_files:function(){
+ query = new AV.Query("File_");
+ query.equalTo("class", this.class);
+ query.include("uploader");
+ query.find().then(this.set_files);
+ },
+ set_files: function(files){
+ files = files.map(file=>{
+ uploader = file.get("uploader");
+ file.set("uploader_name", uploader.get("name"));
+ file.set("uploader_username", uploader.get("username"));
+ filename = file.get("filename");
+ if(filename.endsWith(".png") || filename.endsWith(".jpg")){
+ file.set("ispic", true);
+ this.pic_urls.push(file.get("fileid"));
+ console.log(this.pic_urls);
+ }else{
+ file.set("ispic", false);
+ }
+ return file;
+ })
+ this.setData(jsonify({files}));
+ console.log(this.data);
+ },
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad: function (options) {
+ class_id = options.class_id;
+ this.class = AV.Object.createWithoutData("Class_", class_id);
+ this.pull_files();
+ },
+
+ /**
+ * 生命周期函数--监听页面初次渲染完成
+ */
+ onReady: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面隐藏
+ */
+ onHide: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面卸载
+ */
+ onUnload: function () {
+
+ },
+
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh: function () {
+ this.pull_files();
+ },
+
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom: function () {
+
+ },
+
+ /**
+ * 用户点击右上角分享
+ */
+ onShareAppMessage: function () {
+
+ }
+})
\ No newline at end of file
diff --git a/pages/classdetail/classdetail.json b/pages/classdetail/classdetail.json
new file mode 100644
index 0000000..7360326
--- /dev/null
+++ b/pages/classdetail/classdetail.json
@@ -0,0 +1,4 @@
+{
+ "usingComponents": {},
+ "enablePullDownRefresh": true
+}
\ No newline at end of file
diff --git a/pages/classdetail/classdetail.wxml b/pages/classdetail/classdetail.wxml
new file mode 100644
index 0000000..a5f1014
--- /dev/null
+++ b/pages/classdetail/classdetail.wxml
@@ -0,0 +1,18 @@
+
+
+
+ 课堂资源
+
+
+
+
+
+ {{file.filename}}
+ 上传者:{{file.uploader_username}}
+
+
+
+
+
+
+
diff --git a/pages/classdetail/classdetail.wxss b/pages/classdetail/classdetail.wxss
new file mode 100644
index 0000000..a0f0361
--- /dev/null
+++ b/pages/classdetail/classdetail.wxss
@@ -0,0 +1,24 @@
+/* pages/classdetail/classdetail.wxss */
+.file-list{
+ display: flex;
+ flex-direction: column;
+ margin: 0 -12px
+}
+.file-item{
+ background: white;
+ border-bottom: 1px solid #eee;
+ padding: 16rpx 16px;
+ position: relative;
+}
+
+.file-item text{
+ vertical-align: middle;
+}
+
+.file-uploader{
+ font-size: 10px;
+}
+
+button{
+ margin: 10px 36px;
+}
\ No newline at end of file
diff --git a/pages/classes/classes.js b/pages/classes/classes.js
index 300d570..3533bdc 100644
--- a/pages/classes/classes.js
+++ b/pages/classes/classes.js
@@ -34,7 +34,7 @@ Page({
success(res) {
if (res.confirm) {
wx.showLoading({
- title: '',
+ title: '请稍候',
})
presence.destroy().then(() => {
pull_classes();
diff --git a/pages/classes/classes.wxml b/pages/classes/classes.wxml
index 51ff800..6179a52 100644
--- a/pages/classes/classes.wxml
+++ b/pages/classes/classes.wxml
@@ -9,13 +9,36 @@ classes: 课程列表 type: Array
你还没有加入任何课堂
-
+
{{class.name}}
+
+ # 项目简介
+
+ ## 学员可以在点击右下角”加入课堂”选择课程加入,教员可以在“加入课堂中”新建课程
+
+ ## 长按相应课程可以退出学习
+
+ ## 进入课堂界面会显示在位,头像为彩色,若退出课堂界面则会显示灰色头像
+
+ ## 教员在课堂界面中可以直观地看到学员在位情况,可以选择学员让其起立回答问题,并且对学员可以进行加分、减分操作
+
+ ## 学员可以收到教员让其起立提问、回答的提示,还可以点击“我要提问、回答”
+
+ ## 在课堂界面右下角进入“更多”可以查看本课堂的课程文件资源
+
+ ## 其他
+
+ ### 用户可以在设置中更改姓名、用户名
+
+ ### 为方便测试,在设置中可以选择测试用户登陆
+
+
+
-
diff --git a/pages/classroom/classroom.wxss b/pages/classroom/classroom.wxss
index ccd02b4..a4a9a3c 100644
--- a/pages/classroom/classroom.wxss
+++ b/pages/classroom/classroom.wxss
@@ -80,12 +80,16 @@
padding: 0 12px;
position: absolute;
}
+
+.class-detail{
+ right: 0;
+}
+
button{
margin: 10px 36px;
}
.footer {
- background: white;
position: fixed;
bottom: 0;
height: 44px;
@@ -96,3 +100,7 @@ button{
font-size: 16px;
text-align: center;
}
+
+.white{
+ background: white;
+}