Browse Source

商学院

xiaohaizhao 2 years ago
parent
commit
5240f8bb3f

+ 35 - 0
components/Yl_FloatingButton/index.js

@@ -0,0 +1,35 @@
+Component({
+  properties: {
+    radius: Number, //半径 单位px
+    useSlot: Boolean
+  },
+  data: {
+    top: "550px",
+    left: "345px",
+    viewHeight: null
+  },
+  lifetimes: {
+    attached: function () {
+      let that = this;
+      wx.getSystemInfo({
+        success: (res => that.setData({
+          viewHeight: res.windowHeight
+        }))
+      });
+    },
+  },
+  methods: {
+    viewTouchMove(e) {
+      let left = e.touches[0].pageX;
+      if (left > (375 - this.data.radius)) left = 375 - (this.data.radius / 2);
+      if (left < 0 + this.data.radius) left = 0 + this.data.radius;
+      let top = e.touches[0].pageY;
+      if (top < 0 + this.data.radius) top = 0 + this.data.radius;
+      if (top > this.data.viewHeight - this.data.radius) top = this.data.viewHeight - this.data.radius;
+      this.setData({
+        left: left + 'px',
+        top: top + 'px'
+      })
+    }
+  }
+})

+ 4 - 0
components/Yl_FloatingButton/index.json

@@ -0,0 +1,4 @@
+{
+    "component": true,
+    "usingComponents": {}
+}

+ 4 - 0
components/Yl_FloatingButton/index.scss

@@ -0,0 +1,4 @@
+.float-box{
+    position: fixed;
+    z-index: 99;
+}

+ 4 - 0
components/Yl_FloatingButton/index.wxml

@@ -0,0 +1,4 @@
+<view class="float-box" style="top: {{top}}; left: {{left}};" catchtouchmove="viewTouchMove">
+  <slot wx:if="{{useSlot}}" />
+  <image wx:else style="width: 160rpx; height: 160rpx; transform: translate(-50%,-50%);" src='../../static/image/add.png' data-title="新建线索" />
+</view>

+ 71 - 0
pages/classroom/detail.js

@@ -138,5 +138,76 @@ Page({
                 })
             }
         })
+    },
+    toExam() {
+        let that = this;
+        _Http.basic({
+            "classname": "saletool.courseware.coursewaretest",
+            "method": "queryTestList",
+            "content": {
+                "pageNumber": 1,
+                "pageSize": 999,
+                sat_coursewareid,
+                "where": {
+                    "status": ""
+                }
+            }
+        }).then(res => {
+            if (res.msg != '成功') return wx.showToast({
+                title: res.msg,
+                icon: "none"
+            });
+            if (res.data.length == 0) {
+                this.createTest();
+            } else {
+                let status = res.data[res.data.length - 1].status;
+                if (status == '已完成') {
+                    wx.showModal({
+                        title: '提示',
+                        content: '当前课程已完成考试,是否进入新的考试?',
+                        confirmText: "进入考试",
+                        complete: ({
+                            confirm
+                        }) => {
+                            if (confirm) that.createTest();
+                        }
+                    });
+                } else if (status == '未完成') {
+                    wx.showModal({
+                        title: '提示',
+                        content: '上一次考试未完成,是否继续考试?',
+                        confirmText: "继续",
+                        cancelText: "重新考试",
+                        complete: ({
+                            cancel,
+                            confirm
+                        }) => {
+                            if (cancel) that.createTest();
+                            if (confirm) wx.navigateTo({
+                                url: '/pages/exam/detail?id=' + res.data[res.data.length - 1].sat_courseware_testid,
+                            })
+                        }
+                    })
+                }
+            }
+        })
+    },
+    createTest() {
+        _Http.basic({
+            "classname": "saletool.courseware.coursewaretest",
+            "method": "createTest",
+            "content": {
+                sat_coursewareid
+            }
+        }).then(s => {
+            console.log("开始考试", s)
+            if (s.msg != '成功') return wx.showToast({
+                title: s.msg,
+                icon: "none"
+            })
+            wx.navigateTo({
+                url: '/pages/exam/detail?id=' + s.data.sat_courseware_testid,
+            })
+        })
     }
 })

+ 2 - 1
pages/classroom/detail.json

@@ -1,6 +1,7 @@
 {
     "usingComponents": {
-        "My_empty":"/components/My_empty/index"
+        "My_empty":"/components/My_empty/index",
+        "float":"./modules/float/index"
     },
     "navigationBarTitleText": "课程详情"
 }

+ 2 - 1
pages/classroom/detail.wxml

@@ -32,4 +32,5 @@
             <van-tag wx:else type="danger">{{item.status}}</van-tag>
         </view>
     </van-tab>
-</van-tabs>
+</van-tabs>
+<float bindtap="toExam" />

+ 6 - 1
pages/classroom/index.js

@@ -28,7 +28,7 @@ Page({
             "method": "queryReadLog",
             "content": {
                 "pageNumber": 1,
-                "pageSize": 10,
+                "pageSize": 15,
                 "where": {
                     "condition": ""
                 }
@@ -47,4 +47,9 @@ Page({
     onShow() {
         this.getList()
     },
+    toExam() {
+        wx.navigateTo({
+            url: '/pages/exam/index',
+        })
+    }
 })

+ 2 - 1
pages/classroom/index.json

@@ -1,6 +1,7 @@
 {
     "usingComponents": {
-		"list":"./modules/list/index"
+        "list":"./modules/list/index",
+        "float":"./modules/float/index"
     },
     "navigationBarTitleText": "商学院"
 }

+ 1 - 1
pages/classroom/index.scss

@@ -1,4 +1,4 @@
-.main {
+.main-1 {
     display: flex;
     flex-wrap: wrap;
     justify-content: space-between;

+ 6 - 3
pages/classroom/index.wxml

@@ -1,6 +1,6 @@
 <van-tabs class="tabs" tab-class='tab-class' color='#3874F6' title-active-color='#3874F6' bind:change="tabsChange">
     <van-tab title="课程列表">
-        <view class="main">
+        <view class="main-1">
             <navigator url="./list?id={{item.sat_courseware_classid}}" class="item" wx:for="{{list}}" wx:key="sat_courseware_classid">
                 <view class="img" wx:if="{{item.attinfos[0]}}">
                     <image src="{{item.attinfos[0].subfiles[0].url}}" mode="aspectFill" />
@@ -16,6 +16,9 @@
     </van-tab>
     <van-tab title="学习足迹">
         <view style="height: 20rpx;" />
-        <list list="{{history}}" />
+        <view style="width: 100vw;overflow: hidden;">
+            <list list="{{history}}" />
+        </view>
     </van-tab>
-</van-tabs>
+</van-tabs>
+<float bindtap="toExam" />

+ 54 - 49
pages/classroom/list.js

@@ -1,54 +1,59 @@
 const _Http = getApp().globalData.http,
-	getHeight = require("../../utils/getRheRemainingHeight");
+    getHeight = require("../../utils/getRheRemainingHeight");
 let content = null;
 Page({
-	data: {
+    data: {
 
-	},
-	onLoad(options) {
-		content = {
-			nacache: true,
-			pageNumber: 1,
-			pageSize: 999,
-			where: {
-				condition: "",
-				sat_courseware_classid: options.id,
-				learnstatus: "未学习"
-			}
-		}
-		this.getList()
-	},
-	getList() {
-		_Http.basic({
-			"classname": "saletool.courseware.courseware",
-			"method": "selectList",
-			content
-		}).then(res => {
-			console.log('课程列表', res)
-			this.selectComponent('#ListBox').RefreshToComplete();
-			if (res.msg != '成功') return wx.showToast({
-				title: res.msg,
-				icon: "none"
-			});
-			this.setData({
-				list: res.data,
-				total: res.total
-			})
-		})
-	},
-	tabsChange(e){
-		content.where.learnstatus = e.detail.title;
-		this.getList();
-	},
-	onSearch({
-		detail
-	}) {
-		content.where.condition = detail;
-		this.getList();
-	},
-	onReady() {
-		getHeight.getHeight('.head', this).then(scrollHeight => this.setData({
-			scrollHeight
-		}))
-	},
+    },
+    onLoad(options) {
+        content = {
+            nacache: true,
+            pageNumber: 1,
+            pageSize: 999,
+            where: {
+                condition: "",
+                sat_courseware_classid: options.id,
+                learnstatus: "未学习"
+            }
+        }
+        this.getList()
+    },
+    getList() {
+        _Http.basic({
+            "classname": "saletool.courseware.courseware",
+            "method": "selectList",
+            content
+        }).then(res => {
+            console.log('课程列表', res)
+            this.selectComponent('#ListBox').RefreshToComplete();
+            if (res.msg != '成功') return wx.showToast({
+                title: res.msg,
+                icon: "none"
+            });
+            this.setData({
+                list: res.data,
+                total: res.total
+            })
+        })
+    },
+    tabsChange(e) {
+        content.where.learnstatus = e.detail.title;
+        this.getList();
+    },
+    onSearch({
+        detail
+    }) {
+        content.where.condition = detail;
+        this.getList();
+    },
+    onReady() {
+        getHeight.getHeight('.head', this).then(scrollHeight => this.setData({
+            scrollHeight
+        }))
+    },
+    toExam() {
+        wx.navigateTo({
+            url: '/pages/exam/index',
+        })
+    }
 })

+ 2 - 1
pages/classroom/list.json

@@ -1,6 +1,7 @@
 {
 	"usingComponents": {
-		"list":"./modules/list/index"
+        "list":"./modules/list/index",
+        "float":"./modules/float/index"
 	},
 	"navigationBarTitleText": "课程列表"
 }

+ 3 - 1
pages/classroom/list.wxml

@@ -9,4 +9,6 @@
 <My_listBox id='ListBox' height='{{scrollHeight}}' bind:getlist='getList'>
 	<view class="unread">课程数:{{total}}个</view>
 	<list list="{{list}}" />
-</My_listBox>
+</My_listBox>
+
+<float bindtap="toExam" />

+ 23 - 0
pages/classroom/modules/float/index.js

@@ -0,0 +1,23 @@
+// pages/classroom/modules/float/index.js
+Component({
+    /**
+     * 组件的属性列表
+     */
+    properties: {
+
+    },
+
+    /**
+     * 组件的初始数据
+     */
+    data: {
+
+    },
+
+    /**
+     * 组件的方法列表
+     */
+    methods: {
+
+    }
+})

+ 6 - 0
pages/classroom/modules/float/index.json

@@ -0,0 +1,6 @@
+{
+    "component": true,
+    "usingComponents": {
+        "Yl_FloatingButton": "/components/Yl_FloatingButton/index"
+    }
+}

+ 24 - 0
pages/classroom/modules/float/index.scss

@@ -0,0 +1,24 @@
+.flot {
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    width: 112rpx;
+    height: 112rpx;
+    background: linear-gradient(90deg, #4481EB 0%, #04BEFE 100%);
+    box-shadow: 0px 6rpx 12rpx 2rpx rgba(76, 163, 244, 0.4);
+    border-radius: 50%;
+    transform: translate(-50%, -50%);
+
+    image {
+        width: 40rpx;
+        height: 40rpx;
+        margin-top: 16rpx;
+    }
+
+    text {
+        font-size: 20rpx;
+        font-family: PingFang SC-Regular, PingFang SC;
+        color: #FFFFFF;
+        margin-top: 6rpx;
+    }
+}

+ 6 - 0
pages/classroom/modules/float/index.wxml

@@ -0,0 +1,6 @@
+<Yl_FloatingButton useSlot>
+    <view class="flot">
+        <image src="/static/image/exam4.png" />
+        <text>进入考试</text>
+    </view>
+</Yl_FloatingButton>

+ 1 - 2
pages/classroom/modules/list/index.scss

@@ -1,8 +1,7 @@
 .main {
 	padding: 20rpx 30rpx;
 	width: 100vw;
-	background-color: #fff;
-
+    background-color: #fff;
 	.item {
 		position: relative;
 		display: flex;

+ 18 - 3
pages/exam/detail.js

@@ -106,7 +106,22 @@ Page({
             dataShow: false
         })
     },
-    onReady() {
-
-    },
+    onUnload() {
+        const page = getCurrentPages().find(v => v.__route__ == 'pages/exam/index');
+        if (!page) return;
+        let content = JSON.parse(JSON.stringify(page.data.content));
+        content.pageSize = (content.pageNumber - 1) * content.pageSize;
+        content.pageNumber = 1;
+        _Http.basic({
+            "classname": "saletool.courseware.coursewaretest",
+            "method": "queryTestList",
+            content
+        }).then(res => {
+            console.log("更新市场活动列表", res);
+            if (res.msg == '成功') page.setData({
+                list: res.data,
+                total: res.total
+            })
+        })
+    }
 })

+ 2 - 2
pages/exam/detail.wxml

@@ -6,8 +6,8 @@
         <van-tag color="#FA8C16">{{detail.status}}</van-tag>
     </view>
     <view class="exp">
-        <text class="line-1">发布人: --</text>
-        <text>发布时间:{{detail.createdate}}</text>
+        <text class="line-1">发布人:{{detail.coursewarecreateby ||" --"}}</text>
+        <text>发布时间:{{detail.coursewarecreatedate}}</text>
     </view>
     <view class="bottom" wx:if="{{detail.status=='未完成'}}">
         <view class="left">试卷总分:{{detail.totalscore}}</view>

+ 0 - 6
pages/tabbar/home/index.js

@@ -120,12 +120,6 @@ Page({
                     subassembly: []
                 })
             }
-            gridList.push({
-                name: "考试",
-                path: "/pages/exam/index",
-                icon: "icon-xiaochengxu_xiaoshoumubiao",
-                apps: {}
-            })
             this.setData({
                 gridList,
                 subassembly

BIN
static/image/exam4.png