# ncu-lab **Repository Path**: willwong/ncu-lab ## Basic Information - **Project Name**: ncu-lab - **Description**: 基于微信小程序的实验室综合服务系统,技术: MINA框架、vant weapp、color ui、云开发、 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-05-24 - **Last Updated**: 2021-05-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 简介 ncu-lab 是一个基于微信小程序的实验室综合服务系统,**功能**:登录功能、分类查看实验室列表、实验室导航、分类查看实验操作、报修和处理报修、上传和下载文件、查看仪器物品、查看课程表功能、失物招领、调查问卷功能、查看实验相关周边资讯 ## 技术 - MINA框架、 - vant weapp、 - color ui、 - 云开发、 - 等等。 ## 功能 - 登录功能、 - 分类查看实验室列表、 - 实验室导航、 - 分类查看实验操作、 - 报修和处理报修、 - 上传和下载文件、 - 查看仪器物品、 - 查看课程表功能、 - 失物招领、 - 调查问卷功能、 - 查看实验相关周边资讯等功能。 ## 知识 - 模糊查询、多字段模糊搜索 模糊查询实际上利用的就是正则表达式(regular expression)匹配 **db.RegExp**, 多字段模糊查询需要利用 **db.command**, 参考:1, [数据库多字段的模糊搜索](https://cloud.tencent.com/developer/article/1533972), 2, [Database.RegExp](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/Database.RegExp.html) 3,[正则表达式语法](https://www.runoob.com/regexp/regexp-syntax.html) 举个例子: ``` const _ = db.command // …… db.collection("docList").where( _.and([ { category } , _.or( [ { fileName: db.RegExp({ regexp: '.*' + name, options: 'i', }) }, { submitter: db.RegExp({ regexp: '.*' + submitter, options: 'i', }) } ]) ]) ).get() } ``` ## 报修功能 1,判断身份 -> 学生显示 表单, 老师显示列表 2, ## 模糊查询、多字段模糊搜索 ## this.setData 给数组动态赋值 ## 上传文件 ## fileID 转真实的URL ## 页面跳转 ## 轻提示 ## primise && Promise.All ## 参考文章 - [JavaScript等待所有异步任务完成后才执行](https://www.jianshu.com/p/d14e2331b7cb) - [小程序云开发模糊查询,实现数据库多字段的模糊搜索](https://cloud.tencent.com/developer/article/1533972) --- ## 校园资讯 数据库:schoolNews 点击某一条数据进入资讯详情,点击时传 _id值,在详情页用 _id ## 实验室列表 ## 参考 - [问卷](https://github.com/Chris0527/questionare) ## 优化 ``` getUrl(){ let promiseArr = []; // 1, 将图片插到 云存储 this.data.imgList.forEach((item,idx) => { let p = new Promise((resolve, reject)=>{ wx.cloud.uploadFile({ cloudPath: "lost-img/" + Date.now() + '.jpg', filePath: item }).then( res=> { // console.log(res.fileID) wx.cloud.getTempFileURL({ fileList: [{ fileID: res.fileID, maxAge: 60 * 60, // one hour }] }).then(res => { // get temp file URL // console.log(res.fileList[0].tempFileURL) // imgListUrl = this.data.imgListUrl imgListUrl.push(res.fileList[0].tempFileURL) // console.log(res.fileList[0].tempFileURL) this.setData({ imgListUrl }) resolve() }) } ) }) promiseArr.push(p) }) Promise.all(promiseArr).then(res => { // console.log(imgListUrl) this.addRepairList() }) }, ``` ## 节流和防抖 ## calc 的使用