From a0a27529d38911ab26698f62c99ba649cc11cc15 Mon Sep 17 00:00:00 2001 From: Juria <2304110814@qq.com> Date: Mon, 7 Oct 2024 20:31:09 +0800 Subject: [PATCH] test --- .eslintrc.js | 31 +++ .gitignore | 14 ++ app.js | 19 ++ app.json | 22 ++ app.wxss | 1 + pages/add_stu/add_stu.js | 157 +++++++++++++++ pages/add_stu/add_stu.json | 3 + pages/add_stu/add_stu.wxml | 12 ++ pages/add_stu/add_stu.wxss | 111 +++++++++++ pages/call_roll/call_roll.js | 175 ++++++++++++++++ pages/call_roll/call_roll.json | 3 + pages/call_roll/call_roll.wxml | 17 ++ pages/call_roll/call_roll.wxss | 111 +++++++++++ pages/classSelector/classSelector.js | 37 ++++ pages/classSelector/classSelector.json | 4 + pages/classSelector/classSelector.wxml | 13 ++ pages/classSelector/classSelector.wxss | 33 +++ pages/class_manage/class_manage.js | 266 +++++++++++++++++++++++++ pages/class_manage/class_manage.json | 3 + pages/class_manage/class_manage.wxml | 31 +++ pages/class_manage/class_manage.wxss | 139 +++++++++++++ pages/class_message/class_message.js | 66 ++++++ pages/class_message/class_message.json | 3 + pages/class_message/class_message.wxml | 10 + pages/class_message/class_message.wxss | 38 ++++ pages/function/function.js | 119 +++++++++++ pages/function/function.json | 4 + pages/function/function.wxml | 18 ++ pages/function/function.wxss | 70 +++++++ pages/images/add_stu.png | Bin 0 -> 253839 bytes pages/images/arrow_icon.png | Bin 0 -> 2285 bytes pages/images/call_roll.png | Bin 0 -> 357521 bytes pages/images/class_manage.png | Bin 0 -> 223698 bytes pages/images/class_message.png | Bin 0 -> 298224 bytes pages/images/function.png | Bin 0 -> 30385 bytes pages/images/record.png | Bin 0 -> 321717 bytes pages/images/welcome.png | Bin 0 -> 108189 bytes pages/index/index.js | 49 +++++ pages/index/index.json | 4 + pages/index/index.wxml | 27 +++ pages/index/index.wxss | 62 ++++++ pages/logs/logs.js | 18 ++ pages/logs/logs.json | 4 + pages/logs/logs.wxml | 6 + pages/logs/logs.wxss | 16 ++ pages/record/record.js | 66 ++++++ pages/record/record.json | 3 + pages/record/record.wxml | 13 ++ pages/record/record.wxss | 49 +++++ pages/welcome/welcome.js | 9 + pages/welcome/welcome.json | 3 + pages/welcome/welcome.wxml | 5 + pages/welcome/welcome.wxss | 21 ++ project.config.json | 28 +++ project.private.config.json | 8 + sitemap.json | 7 + utils/util.js | 19 ++ 57 files changed, 1947 insertions(+) create mode 100644 .eslintrc.js create mode 100644 .gitignore create mode 100644 app.js create mode 100644 app.json create mode 100644 app.wxss create mode 100644 pages/add_stu/add_stu.js create mode 100644 pages/add_stu/add_stu.json create mode 100644 pages/add_stu/add_stu.wxml create mode 100644 pages/add_stu/add_stu.wxss create mode 100644 pages/call_roll/call_roll.js create mode 100644 pages/call_roll/call_roll.json create mode 100644 pages/call_roll/call_roll.wxml create mode 100644 pages/call_roll/call_roll.wxss create mode 100644 pages/classSelector/classSelector.js create mode 100644 pages/classSelector/classSelector.json create mode 100644 pages/classSelector/classSelector.wxml create mode 100644 pages/classSelector/classSelector.wxss create mode 100644 pages/class_manage/class_manage.js create mode 100644 pages/class_manage/class_manage.json create mode 100644 pages/class_manage/class_manage.wxml create mode 100644 pages/class_manage/class_manage.wxss create mode 100644 pages/class_message/class_message.js create mode 100644 pages/class_message/class_message.json create mode 100644 pages/class_message/class_message.wxml create mode 100644 pages/class_message/class_message.wxss create mode 100644 pages/function/function.js create mode 100644 pages/function/function.json create mode 100644 pages/function/function.wxml create mode 100644 pages/function/function.wxss create mode 100644 pages/images/add_stu.png create mode 100644 pages/images/arrow_icon.png create mode 100644 pages/images/call_roll.png create mode 100644 pages/images/class_manage.png create mode 100644 pages/images/class_message.png create mode 100644 pages/images/function.png create mode 100644 pages/images/record.png create mode 100644 pages/images/welcome.png create mode 100644 pages/index/index.js create mode 100644 pages/index/index.json create mode 100644 pages/index/index.wxml create mode 100644 pages/index/index.wxss create mode 100644 pages/logs/logs.js create mode 100644 pages/logs/logs.json create mode 100644 pages/logs/logs.wxml create mode 100644 pages/logs/logs.wxss create mode 100644 pages/record/record.js create mode 100644 pages/record/record.json create mode 100644 pages/record/record.wxml create mode 100644 pages/record/record.wxss create mode 100644 pages/welcome/welcome.js create mode 100644 pages/welcome/welcome.json create mode 100644 pages/welcome/welcome.wxml create mode 100644 pages/welcome/welcome.wxss create mode 100644 project.config.json create mode 100644 project.private.config.json create mode 100644 sitemap.json create mode 100644 utils/util.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..115cc02 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,31 @@ +/* + * Eslint config file + * Documentation: https://eslint.org/docs/user-guide/configuring/ + * Install the Eslint extension before using this feature. + */ +module.exports = { + env: { + es6: true, + browser: true, + node: true, + }, + ecmaFeatures: { + modules: true, + }, + parserOptions: { + ecmaVersion: 2018, + sourceType: 'module', + }, + globals: { + wx: true, + App: true, + Page: true, + getCurrentPages: true, + getApp: true, + Component: true, + requirePlugin: true, + requireMiniProgram: true, + }, + // extends: 'eslint:recommended', + rules: {}, +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..14ea590 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +# Windows +[Dd]esktop.ini +Thumbs.db +$RECYCLE.BIN/ + +# macOS +.DS_Store +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes + +# Node.js +node_modules/ diff --git a/app.js b/app.js new file mode 100644 index 0000000..1ed57c4 --- /dev/null +++ b/app.js @@ -0,0 +1,19 @@ +// app.js +App({ + onLaunch() { + // 展示本地存储能力 + const logs = wx.getStorageSync('logs') || [] + logs.unshift(Date.now()) + wx.setStorageSync('logs', logs) + + // 登录 + wx.login({ + success: res => { + // 发送 res.code 到后台换取 openId, sessionKey, unionId + } + }) + }, + globalData: { + userInfo: null + } +}) diff --git a/app.json b/app.json new file mode 100644 index 0000000..e1d58d9 --- /dev/null +++ b/app.json @@ -0,0 +1,22 @@ +{ + "pages": [ + "pages/welcome/welcome", + "pages/call_roll/call_roll", + "pages/function/function", + "pages/class_manage/class_manage", + "pages/add_stu/add_stu", + "pages/class_message/class_message", + "pages/record/record", + "pages/index/index", + "pages/logs/logs" + ], + "window": { + "navigationBarTextStyle": "black", + "navigationBarTitleText": "Weixin", + "navigationBarBackgroundColor": "#ffffff" + }, + "style": "v2", + "componentFramework": "glass-easel", + "sitemapLocation": "sitemap.json", + "lazyCodeLoading": "requiredComponents" +} \ No newline at end of file diff --git a/app.wxss b/app.wxss new file mode 100644 index 0000000..75f4fde --- /dev/null +++ b/app.wxss @@ -0,0 +1 @@ +/**app.wxss**/ diff --git a/pages/add_stu/add_stu.js b/pages/add_stu/add_stu.js new file mode 100644 index 0000000..5451af8 --- /dev/null +++ b/pages/add_stu/add_stu.js @@ -0,0 +1,157 @@ +// pages/addStudent/addStudent.js +Page({ + data: { + className:"K班", + input: "", + students:[ + + ] + }, + + onLoad: function(options) { + console.log(options); + // options 参数包含了从上一个页面传递过来的数据 + const receivedClassName = options.className; // 获取传递过来的 className,默认为空字符串 + + // 更新页面的数据 + this.setData({ + className: receivedClassName // 将接收到的 className 赋值给页面的 data 属性 + }); + console.log(this.data.className); + }, + + //获取输入框内容 + onInput: function(e) { + console.log(e.detail.value) + this.setData({ + input: e.detail.value//保存输入 + }); + }, + + // Excel文件导入 + importExcel: function() { + const that = this; + wx.chooseMessageFile({ + count: 1, // 默认为1,设置选择文件的数量 + type: 'file', + extension: ['xlsx'], // 指定文件的后缀名 + success(res) { + const tempFiles = res.tempFiles; // 临时文件路径 + const filePath = tempFiles[0].path; // 获取文件的路径 + console.log(tempFiles); + that.readExcel(filePath); // 读取文件内容 + }, + fail(err) { + console.error('选择文件失败:', err); + } + }); + }, + + // 读取Excel文件内容 + readExcel(filePath) { + // 可以使用微信小程序的API或将文件上传到服务器解析 + const that = this; + wx.uploadFile({ + url: '暂无', // 你的服务器上传地址 + filePath: filePath, + name: 'file', + success: uploadRes => { + // 假设服务器返回解析后的 JSON 数据 + const data = JSON.parse(uploadRes.data); + that.addStudents(data.students); + }, + fail: uploadErr => { + console.error('文件上传失败:', uploadErr); + } + }); + }, + + // 将解析后的学生数据添加到现有数组中 + addStudents(newStudents) { + const currentStudents = this.data.students; + const allStudents = currentStudents.concat(newStudents); // 合并数组 + this.setData({ + students: allStudents + }); + }, + + //点击输入框提示可以输入 + focus: function(){ + wx.showToast({ + title: '可以开始输入了', + icon: 'none', + duration: 2000 + }); + }, + + cantNull: function(){ + wx.showToast({ + title: '输入框不可为空', + icon: 'none', + duration: 2000 + }); + }, + + addProcess: function(){ + if(this.data.input != ""){ + //分割字符串为数组 + let firstArray = this.data.input.split("|"); + console.log(firstArray); + let secondArray = firstArray.map(str => str.split(" ")); + console.log(secondArray) + //遍历secondArray + secondArray.forEach(subArray => { + // 结构法从子数组中提取id和name + //等同于 const id = subArray[0]; const name = subArray[1]; + const { [0]: id, [1]: name } = subArray; + + // 创建一个新的对象来存储这些信息 + const newStu = { + id: id, + name: name, + point: 10, + clazz: this.data.className, + }; + const isDuplicate = this.data.students.some(stu => stu.id === id); + if(!isDuplicate){ + // 将新对象发送到后端服务器 + const classstu = newStu; + //classstu.className = this.data.className;//此时 classstu = {id:"102201",name:"Jhon", className:`${this.data.className}` } + wx.request({ + url: 'http://192.168.152.1:8090/student/set', + method: 'POST', // 请求方法,通常是POST用于发送数据 + header: { + 'Content-Type': 'application/json' // 设置请求头,指定数据格式为JSON + }, + data: newStu, // 要发送的数据,这里直接传入对象,wx.request会自动将其转换为JSON字符串(后端接收json字符串) + success: function(res) { + // 处理后端返回的响应 + console.log('请求成功', res.data); + // 根据需要更新小程序页面的数据或执行其他操作 + }, + fail: function(err) { + // 处理请求失败的情况 + console.error('请求失败', err); + // 可以向用户显示错误信息或执行其他错误处理操作 + } + }); + // 将新对象添加到data.stu数组中 + this.setData({ + ['students[' + this.data.students.length + ']']: newStu //直接将新对象加在数组后面 + }); + } else { + console.log('id重复:${id}'); + } + }) + console.log(this.data.students); + } else { + this.cantNull(); + } + }, + + goToclass_manage: function(){ + wx.navigateTo({ + url: '/pages/class_manage/class_manage' + }); + } +}); \ No newline at end of file diff --git a/pages/add_stu/add_stu.json b/pages/add_stu/add_stu.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/add_stu/add_stu.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/add_stu/add_stu.wxml b/pages/add_stu/add_stu.wxml new file mode 100644 index 0000000..8676f44 --- /dev/null +++ b/pages/add_stu/add_stu.wxml @@ -0,0 +1,12 @@ + + + + + 添加学生 + (添加学生学号 姓名用“|”隔开) +