From c58013bb91ed380ca17b2dbd5e8c400a5f26aab4 Mon Sep 17 00:00:00 2001
From: yuchen <924761163@qq.com>
Date: Tue, 12 Nov 2019 17:16:25 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=AF=BE=E8=A1=A8=E5=88=86?=
=?UTF-8?q?=E5=91=A8=E6=AC=A1=E6=98=BE=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app.js | 47 +++++++++++
pages/curriculum/curriculum.js | 132 +++++++++++++++++++++++++++++--
pages/curriculum/curriculum.wxml | 12 ++-
pages/library/library.wxml | 4 +-
4 files changed, 185 insertions(+), 10 deletions(-)
diff --git a/app.js b/app.js
index eba3ea4..b368b97 100644
--- a/app.js
+++ b/app.js
@@ -2,6 +2,46 @@
var util = require("./utils/util.js")
App({
onLaunch: function () {
+
+
+
+ if (wx.canIUse('getUpdateManager')) {
+ const updateManager = wx.getUpdateManager()
+ updateManager.onCheckForUpdate(function (res) {
+ // 请求完新版本信息的回调
+ if (res.hasUpdate) {
+ updateManager.onUpdateReady(function () {
+ wx.showModal({
+ title: '更新提示',
+ content: '新版本已经准备好,是否重启应用?',
+ success: function (res) {
+ if (res.confirm) {
+ // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
+ updateManager.applyUpdate()
+ }
+ }
+ })
+ })
+ updateManager.onUpdateFailed(function () {
+ // 新的版本下载失败
+ wx.showModal({
+ title: '已有新版本',
+ content: '检查到有新版本,但下载失败,请检查网络设置',
+ })
+ })
+ }
+ })
+ } else {
+ // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
+ wx.showModal({
+ title: '提示',
+ content: '当前QQ版本过低,无法使用该功能,请升级到最新QQ版本后重试。'
+ })
+ }
+
+
+
+
var openid = wx.getStorageSync("openid")
if(openid == ""){
qq.login({
@@ -42,6 +82,13 @@ App({
})
}else{
}
+
+
+
+
+
+
+
},
globalData: {
}
diff --git a/pages/curriculum/curriculum.js b/pages/curriculum/curriculum.js
index bdfbc3c..3fda9ba 100644
--- a/pages/curriculum/curriculum.js
+++ b/pages/curriculum/curriculum.js
@@ -7,9 +7,96 @@ Page({
*/
data: {
colorArrays: ["#85B8CF", "#90C652", "#D8AA5A", "#FC9F9D", "#0A9A84", "#61BC69", "#12AEF3", "#E29AAD"],
- wlist: []
+ wlist: [],
+ months: [],
+ term_start_month:8, // this need change
+ term_start_day:26, // this need change
+ current_week:null,
+ ifleapyear:null,
+ daysofmonth: [31, -1, 31, 30, 31, 30, 31,31,30,31,30,31],
+ wlistbkp: []
},
+ toLastWeek:function(){
+ var _cw = this.data.current_week
+ _cw -= 1
+ if(_cw < 1){
+ return
+ }
+ this.setData({
+ current_week: _cw
+ })
+ this.updateCurriculum(_cw)
+ },
+
+ toNextWeek:function(){
+ var _cw = this.data.current_week
+ _cw += 1
+ if(_cw > 20){
+ return
+ }
+ this.setData({
+ current_week: _cw
+ })
+ this.updateCurriculum(_cw)
+ },
+
+ timeInit:function(){
+ var timestamp = Date.parse(new Date());
+ var date = new Date(timestamp);
+
+ var year =date.getFullYear();
+
+ // console.log(year)
+
+ var dayoffebruary
+
+ if(year%4==0&&year%100!=0||year%400==0){
+ console.log("今年是闰年")
+ this.setData({
+ ifleapyear: true
+ })
+ dayoffebruary = 29
+ }
+ else{
+ this.setData({
+ ifleapyear: false
+ })
+ console.log("今年不是闰年")
+ dayoffebruary = 28
+ }
+
+ // 设置二月天数
+ var _daysofmonth = this.data.daysofmonth
+ _daysofmonth[1] = dayoffebruary
+
+ this.setData({
+ daysofmonth: _daysofmonth
+ })
+
+ // console.log(this.data.daysofmonth)
+ //计算 current week
+
+ // 获取当前月份
+ var month = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
+ //获取当日日期
+ var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
+ // console.log(month, day)
+
+ // 计算学期第一天到今天的天数
+ var days = 0
+ for(var a = this.data.term_start_month + 1; a < month; a++)
+ {
+ days += _daysofmonth[a - 1];
+ }
+ days += day + _daysofmonth[this.data.term_start_month-1] - this.data.term_start_day + 1
+
+ this.setData({
+ current_week: Math.ceil(days/7)
+ })
+ // console.log(Math.ceil(days/7))
+ },
+
showCardView: function(e){
console.log(e.currentTarget.dataset.index)
wx.navigateTo({
@@ -20,7 +107,8 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
- onLoad: function (options) {
+ onShow: function (options) {
+
},
/**
@@ -33,10 +121,12 @@ Page({
/**
* 生命周期函数--监听页面显示
*/
- onShow: function () {
+ onLoad: function () {
+ this.timeInit()
+
var that = this
-
+
var ifbind = wx.getStorageSync("ifbind")
if(ifbind == ""){
wx.showToast({
@@ -61,15 +151,45 @@ Page({
url: 'https://www.neumark.top/lesson/get',
method: "POST",
success: (res) => {
- console.log(res.data)
that.setData({
- wlist: res.data
+ wlistbkp: res.data
+ })
+ // console.log(res.data)
+ var _wlist = []
+
+ for(var j = 0; j < res.data.length; j++) {
+ for(var k = 0; k < res.data[j]['time'].length; k++){
+ // console.log(res.data[j]['time'][k]['上课周次'].split('、'))
+ if(-1 != res.data[j]['time'][k]['上课周次'].split('、').indexOf(this.data.current_week + '')){
+ _wlist.push(res.data[j])
+ break;
+ }
+ }
+ }
+
+ that.setData({
+ wlist: _wlist
})
}
})
}
},
+ updateCurriculum: function(current_week){
+ var _wlist = []
+ for(var j = 0; j < this.data.wlistbkp.length; j++) {
+ for(var k = 0; k < this.data.wlistbkp[j]['time'].length; k++){
+ if(-1 != this.data.wlistbkp[j]['time'][k]['上课周次'].split('、').indexOf(current_week + '')){
+ _wlist.push(this.data.wlistbkp[j])
+ break;
+ }
+ }
+ }
+ this.setData({
+ wlist: _wlist
+ })
+ },
+
/**
* 生命周期函数--监听页面隐藏
*/
diff --git a/pages/curriculum/curriculum.wxml b/pages/curriculum/curriculum.wxml
index 731c7db..86f159a 100644
--- a/pages/curriculum/curriculum.wxml
+++ b/pages/curriculum/curriculum.wxml
@@ -1,9 +1,17 @@
+
+
+ 第{{current_week}}周
+
+
+
+
+
周{{item}}
-
+
{{item}}
@@ -17,7 +25,7 @@
-
+
{{item.kcmc}}
diff --git a/pages/library/library.wxml b/pages/library/library.wxml
index 9ddb938..07bae78 100644
--- a/pages/library/library.wxml
+++ b/pages/library/library.wxml
@@ -7,11 +7,11 @@
-
+