diff --git a/api/promisify.js b/api/promisify.js new file mode 100644 index 0000000000000000000000000000000000000000..04f2c25abd0a7c172a0c852ccc35dea6381d2afd --- /dev/null +++ b/api/promisify.js @@ -0,0 +1,7 @@ +module.exports = (api) => { + return (options, ...params) => { + return new Promise((resolve, reject) => { + api(Object.assign({}, options, { success: resolve, fail: reject }), ...params); + }); + } +} \ No newline at end of file diff --git a/api/request.js b/api/request.js index b6269afb8097e7d497daa08c8b2cee6c5d06791e..dd90c5bba6bc5fd98c2387c1456a66aa67e4a494 100644 --- a/api/request.js +++ b/api/request.js @@ -11,11 +11,11 @@ const ERR_NOT_ACCESS_TOKEN = 21; var DEF_APP_CONFIG = { appId: "wxfc3355043e579968", // 勾芒å°ç¨‹åºæµ‹è¯•å· // å¼€å‘环境 - domain: 'http://192.168.1.130:8080/preschool', - baseUrl: "http://192.168.1.130:8080/preschool" + domain: 'http://dev.gomoretech.com/preschool-test', + baseUrl: "http://dev.gomoretech.com/preschool-test" // å·å“¥æœ¬åœ°çŽ¯å¢ƒ - // domain: 'http://192.168.199.198:8080', - // baseUrl: "http://192.168.199.198:8080/wxmall/wxsite", + // domain: 'http://192.168.1.130:8080/preschool', + // baseUrl: "http://192.168.1.130:8080/preschool", // è°¢è´æœ¬åœ°çŽ¯å¢ƒ // domain: 'http://192.168.199.153:9090', // baseUrl: "http://192.168.199.153:9090/wxmall/wxsite" @@ -239,7 +239,7 @@ function wx_getUserInfo() { * @param decryptUserInfo 是å¦è§£å¯†ç”¨æˆ·ä¿¡æ¯ * @return 用户信æ¯ï¼Œå¦‚果返回的 #memberå—æ®µä¸ºç©ºï¼Œè¯´æ˜Žå½“å‰ç²‰ä¸æ²¡æœ‰ç»‘定手机å·ï¼Œ è¿˜ä¸æ˜¯ä¼šå‘˜ã€‚ */ -module.exports.kg_login = function (decryptUserInfo = true) { +module.exports.kg_login = function (decryptUserInfo = true, mobile) { var self = this; var loginCode = ''; return wx_login() @@ -256,9 +256,10 @@ module.exports.kg_login = function (decryptUserInfo = true) { var req = { appid: APP_ID, code: loginCode, + mobile: mobile, encryptedUserInfo: encryptedUserInfo }; - return self.post('/wxa/user/login', req); + return self.post('/wxsite/wxa/user/login.do', req); }) .then(function (data) { // ä¿å˜ç™»å½•结果 @@ -300,4 +301,64 @@ module.exports.delete = function (url, data) { */ module.exports.config = function () { return DEF_APP_CONFIG +} + +module.exports.upload = function(options) { + var url = options.url, + path = options.path, + name = options.name, + // data = options.data, + extra = options.extra, + success = options.success, + progress = options.progress, + fail = options.fail + + console.log("upload url:" + url) + const uploadTask = wx.uploadFile({ + url: url, + filePath: path, + name: name, + formData: extra, + success: function (res) { + console.log(res); + + var data = res.data + try { + data = JSON.parse(res.data) + console.log(data) + } + catch (e) { + console.log(data) + throw (e) + } + + // data.code == 1000需è¦åŽ»æŽ‰ï¼Œè¿™é‡Œæ˜¯æ ¹æ®è‡ªå·±çš„返回数æ®åšç›¸åº”åˆ¤æ– + if (res.statusCode == 200) { + if (success) { + success(data) + } + } + else { + if (fail) { + fail(data) + } + } + + }, + fail: function (res) { + console.log(res) + if (fail) { + fail(res) + } + } + }) + + uploadTask.onProgressUpdate((res) => { + console.log('ä¸Šä¼ è¿›åº¦', res.progress) + console.log('å·²ç»ä¸Šä¼ 的数æ®é•¿åº¦', res.totalBytesSent) + console.log('预期需è¦ä¸Šä¼ çš„æ•°æ®æ€»é•¿åº¦', res.totalBytesExpectedToSend) + if (progress) ( + progress(res) + ) + }) } \ No newline at end of file diff --git a/api/teacher.js b/api/teacher.js index 28baf2cfd27707a7c687aac114dee15c434bf02e..b0b49442e3d383faaaecea9f4782a58f3aa10a5f 100644 --- a/api/teacher.js +++ b/api/teacher.js @@ -1,17 +1,7 @@ var request = require('./request.js') module.exports = { - - /** - * 用户登录 - * - * @param decryptUserInfo 是å¦è§£å¯†ç”¨æˆ·ä¿¡æ¯ - * @return 用户信æ¯ï¼Œå¦‚果返回的 #memberå—æ®µä¸ºç©ºï¼Œè¯´æ˜Žå½“å‰ç²‰ä¸æ²¡æœ‰ç»‘定手机å·ï¼Œ è¿˜ä¸æ˜¯ä¼šå‘˜ã€‚ - */ - kg_login(decryptUserInfo = true) { - return request.kg_login(decryptUserInfo) - }, - +// 查询当天ç¾åˆ°è®°å½• querySignSummary(teacherId, classId) { var params = { teacherId: teacherId, diff --git a/app.json b/app.json index 5d87be17ecd6523ea66539fa1160c59cb62c4215..3a76dc0b985cb0c2931489ee0a4d66a1f1cc6952 100644 --- a/app.json +++ b/app.json @@ -1,5 +1,6 @@ { "pages":[ + "pages/login/index", "pages/home/teacher/index", "pages/home/reviewer/index", diff --git a/pages/add_record/index.js b/pages/add_record/index.js index 03fe70936162a0179c910d9b6b59138a1d6cdd98..7cbd6bf8c7d774707c05a0f18f19aee58241edee 100644 --- a/pages/add_record/index.js +++ b/pages/add_record/index.js @@ -1,6 +1,7 @@ // pages/add_record/index.js const req = require('../../api/teacher.js') +const utils = require('../../utils/util.js') const app = getApp() Page({ @@ -44,7 +45,9 @@ Page({ eatRecord: [], sleepRecord: [], wcRecord: [], - hidePhoto: false + hidePhoto: false, + pictureId: [], + pictureUrl:[] }, @@ -53,16 +56,46 @@ Page({ var that = this; // 选择图片 wx.chooseImage({ + count: 1, sizeType: ['original', 'compressed'], // å¯ä»¥æŒ‡å®šæ˜¯åŽŸå›¾è¿˜æ˜¯åŽ‹ç¼©å›¾ï¼Œé»˜è®¤äºŒè€…éƒ½æœ‰ sourceType: ['album', 'camera'], // å¯ä»¥æŒ‡å®šæ¥æºæ˜¯ç›¸å†Œè¿˜æ˜¯ç›¸æœºï¼Œé»˜è®¤äºŒè€…都有 success: function(res) { - // 返回选定照片的本地文件路径列表,tempFilePathå¯ä»¥ä½œä¸ºimgæ ‡ç¾çš„src属性显示图片 - for (var i in res.tempFilePaths) { - that.data.selectPic.push(res.tempFilePaths[i]) - } + //选ä¸çš„图片路径 + let temPath = res.tempFilePaths[0] + that.data.selectPic.push(temPath) that.setData({ selectPic: that.data.selectPic }); + + wx.uploadFile({ + url: utils.uploadPath(), + filePath: temPath, + name: 'file', + header: { + 'access-token': utils.getAccessToken() + }, + success(res) { + const resData = JSON.parse(res.data) + // èŽ·å–æœåŠ¡ç«¯å›¾ç‰‡id + that.data.pictureId.push(resData.obj) + that.data.pictureUrl.push(utils.handleImgShow(resData.obj)) + if (resData.obj) { + that.setData({ + pictureId: that.data.pictureId, + pictureUrl: that.data.pictureUrl + }) + } else { + throw new Error({ msg: 'å›¾ç‰‡ä¸Šä¼ å¤±è´¥' }) + } + }, + fail(err) { + wx.showToast({ + title: err.msg, + icon: 'none' + }) + } + }) + } }) }, @@ -130,8 +163,8 @@ Page({ categorys: categorys }) }, - -// 调用接å£èŽ·å–æ•°æ® + + // 调用接å£èŽ·å–æ•°æ® getRecord: function() { let studentIds = this.data.studentIds console.log(studentIds) @@ -204,7 +237,7 @@ Page({ sleepRecord: res }) } else if (this.data.controlIndex == 2) { - + for (var i = 0; i < res.length; i++) { var item = res[i] var pee = '0' @@ -244,10 +277,10 @@ Page({ var item = records[cellIndex].recordItems[0] if (this.data.controlIndex == 2) { records[cellIndex].optionIndex = e.currentTarget.dataset.optionindex - }else{ + } else { item.optionIndex = e.currentTarget.dataset.optionindex } - + if (this.data.controlIndex == 0) { @@ -363,11 +396,18 @@ Page({ } req.setRecord(arrRecordList).then(res => { - this.getRecord() + wx.showToast({ + title: 'ä¿å˜æˆåŠŸ~', + duration: 1500 + }) + setTimeout(() => { + this.getRecord() + }, 1500) + }) }, - onLoad: function (options) { + onLoad: function(options) { this.data.studentIds = JSON.parse(options.studentIds) console.log(this.data.studentIds) if (this.data.studentIds.length > 1) { diff --git a/pages/home/parents/index.js b/pages/home/parents/index.js index 9e39c0b4369de727df511349fe3bcbc6b0f9222c..0a3eec1853f91e2bb226110fd17f570d72bd8665 100644 --- a/pages/home/parents/index.js +++ b/pages/home/parents/index.js @@ -14,119 +14,8 @@ Page({ pageSize: 15, records: [], recordTypes: app.globalData.recordTypes, - eatStates: app.globalData.eatStates, - testData: { - "paging": { - "page": 0, - "pageSize": 15, - "pageCount": 1, - "recordCount": 2 - }, - "records": [ - { - "teacher": null, - "recordDate": "2018-12-25 00:00:00", - "pictures": "4028e38165fac6cb0165fac9d151000a,4028e38165fac6cb0165fac9d314000b,", - "dietRecord": [ - { - "id": "4028048267c974b60167c974b6c00000", - "createName": null, - "createBy": null, - "createDate": null, - "updateName": null, - "updateBy": null, - "updateDate": "2018-12-24 14:25:40", - "sysOrgCode": null, - "sysCompanyCode": null, - "recordCategory": "diet", - "recordType": "diet_morning", - "eatState": "more", - "value": null, - "signSummaryId": "4028048267e4213c0167e423f84f0002" - }, - { - "id": "4028048267c974b60167c9751bd30001", - "createName": null, - "createBy": null, - "createDate": null, - "updateName": "管ç†å‘˜", - "updateBy": "admin", - "updateDate": "2018-12-20 10:33:20", - "sysOrgCode": null, - "sysCompanyCode": null, - "recordCategory": "diet", - "recordType": "diet_afternoon", - "eatState": "normal", - "value": null, - "signSummaryId": "4028048267e4213c0167e423f84f0002" - }, - { - "id": "4028048267c974b60167c97660120002", - "createName": "管ç†å‘˜", - "createBy": "admin", - "createDate": "2018-12-20 10:33:57", - "updateName": null, - "updateBy": null, - "updateDate": null, - "sysOrgCode": "A03", - "sysCompanyCode": "A03", - "recordCategory": "diet", - "recordType": "diet_milk", - "eatState": "normal", - "value": "300", - "signSummaryId": "4028048267e4213c0167e423f84f0002" - } - ], - "sleepRecord": [ - { - "id": "4028048267c974b60167c976bc210003", - "createName": "管ç†å‘˜", - "createBy": "admin", - "createDate": "2018-12-20 10:34:21", - "updateName": null, - "updateBy": null, - "updateDate": null, - "sysOrgCode": "A03", - "sysCompanyCode": "A03", - "recordCategory": "sleep", - "recordType": "sleep_time", - "eatState": "normal", - "value": "60", - "signSummaryId": "4028048267e4213c0167e423f84f0002" - } - ], - "wcRecord": [ - { - "id": "4028048267c974b60167c97706930004", - "createName": "管ç†å‘˜", - "createBy": "admin", - "createDate": "2018-12-20 10:34:40", - "updateName": "管ç†å‘˜", - "updateBy": "admin", - "updateDate": "2018-12-20 10:43:55", - "sysOrgCode": "A03", - "sysCompanyCode": "A03", - "recordCategory": "wc", - "recordType": "wc_pee", - "eatState": "normal", - "value": "3", - "signSummaryId": "4028048267e4213c0167e423f84f0002" - } - ] - }, - { - "teacher": null, - "recordDate": "2018-12-21 00:00:00", - "pictures": null, - "dietRecord": [ - ], - "sleepRecord": [ - ], - "wcRecord": [ - ] - } - ] - } + eatStates: app.globalData.eatStates + }, /** @@ -134,98 +23,79 @@ Page({ */ onLoad: function(options) { const that = this - let resData = this.data.testData - - - var record = resData['records'] - var templist = this.data.records - for (var i = 0; i < record.length; i++) { - var item = record[i] - - var dateStr = item.recordDate.substr(0, 10) - let show_day = new Array('周日', '周一', '周二', '周三', '周四', '周五', '周å…'); - let date = new Date(dateStr); - var num = date.getDay() - item.recordDate = dateStr + " " + show_day[date.getDay()] - - // 饮食 - var dietRecords = item['dietRecord'] - - for (var j = 0; j < dietRecords.length; j++) { - var diet = dietRecords[j] - diet.z_recordType = that.data.recordTypes[diet.recordType] - diet.z_eatState = that.data.eatStates[diet.eatState] - } - - // ç¡è§‰ - var sleepRecord = item["sleepRecord"] - for (var j = 0; j < sleepRecord.length; j++) { - var r = sleepRecord[j] - r.z_recordType = that.data.recordTypes[r.recordType] - - } - - // wc - var wcRecord = item["wcRecord"] - for (var j = 0; j < wcRecord.length; j++) { - var r = wcRecord[j] - r.z_recordType = that.data.recordTypes[r.recordType] - - } - - console.log(item) - templist.push(item) + + + if (app.globalData.login.students.length == 0) { + wx.showToast({ + title: 'æ— å¦ç”Ÿä¿¡æ¯, 请è”系管ç†å‘˜', + icon: 'none' + }) + return } - - + let student = app.globalData.login.students[0] + var studentId = student.id this.setData({ - records: templist, - page: resData['paging']['page'] + student:student }) - // request.queryStudentRecord(that.data.page, that.data.pageSize, '4028048267c0236e0167c02b63100004').then(res => { - // console.log(res) - // let resData = this.data.testData - - - // var record = resData['records'] - // var templist = this.data.records - // for (var i = 0; i < record.length; i++) { - // var item = record[i] + request.queryStudentRecord(that.data.page, that.data.pageSize, studentId).then(res => { + console.log(res) + let resData = res + + + var record = resData['records'] + var templist = this.data.records + for (var i = 0; i < record.length; i++) { + var item = record[i] + + var dateStr = item.recordDate.substr(0, 10) + let show_day = new Array('周日', '周一', '周二', '周三', '周四', '周五', '周å…'); + let date = new Date(dateStr); + var num = date.getDay() + item.recordDate = dateStr + " " + show_day[date.getDay()] + + // 饮食 + var dietRecords = item['dietRecord'] + + for (var j = 0; j < dietRecords.length; j++) { + var diet = dietRecords[j] + diet.z_recordType = that.data.recordTypes[diet.recordType] + diet.z_eatState = that.data.eatStates[diet.eatState] + if (diet.recordType == 'diet_milk') { + diet.z_eatState = diet.value + "毫å‡" + } + if (diet.recordType == 'diet_water') { + diet.z_eatState = diet.value + "次" + } + } - // // 饮食 - // var dietRecords = item['dietRecord'] + // ç¡è§‰ + var sleepRecord = item["sleepRecord"] + for (var j = 0; j < sleepRecord.length; j++) { + var r = sleepRecord[j] + r.z_recordType = that.data.recordTypes[r.recordType] - // for (var j = 0; j < dietRecords.length; j++) { - // var diet = dietRecords[j] - // diet.z_recordType = that.data.recordTypes[diet.recordType] - // } + } - // // ç¡è§‰ - // var sleepRecord = item["sleepRecord"] - // for (var j = 0; j < sleepRecord.length; j++) { - // var r = sleepRecord[j] - // r.z_recordType = that.data.recordTypes[r.recordType] - // } + // wc + var wcRecord = item["wcRecord"] + for (var j = 0; j < wcRecord.length; j++) { + var r = wcRecord[j] + r.z_recordType = that.data.recordTypes[r.recordType] - // // wc - // var wcRecord = item["wcRecord"] - // for (var j = 0; j < wcRecord.length; j++) { - // var r = wcRecord[j] - // r.z_recordType = that.data.recordTypes[r.recordType] - // } + } - // console.log(item) - // templist.push(item) - // } + console.log(item) + templist.push(item) + } - // this.setData({ - // records: templist, - // page: resData['paging']['page'] - // }) + this.setData({ + records: templist, + page: resData['paging']['page'] + }) - // }) + }) }, diff --git a/pages/home/parents/index.wxml b/pages/home/parents/index.wxml index 7e866c27003b036b1e3c9a7d7e88392937c62487..3fa4f7a03dc569b20ae4f68e424478f3527d03d5 100644 --- a/pages/home/parents/index.wxml +++ b/pages/home/parents/index.wxml @@ -3,7 +3,7 @@ <view class='kg-separater' style='height:2rpx;'></view> <view class='kg-home-header kg-flex-row'> - <template is='userInfo' data="{{userImg:'/src/img/defaut_teacher_icon.png',title:'å¼ å°åŽ',subTitle:'呿—¥è‘µå°ç',sex:'m'}}"></template> + <template is='userInfo' data="{{userImg:'/src/img/defaut_teacher_icon.png',title:student.name,subTitle:student.className,sex:'male'}}"></template> <view></view> </view> <view class='kg-separater'></view> @@ -18,7 +18,7 @@ <view class='kg-quantity-cell timeline-content'> <view class='kg-flex-row' style='margin-bottom:20rpx;'> <text class='kg-text-title'>{{item.recordDate}}</text> - <text class='kg-text-normal-gray'>{{item.teacher ? item.teacher : ""}}记录</text> + <text class='kg-text-normal-gray'>{{item.teacher ? item.teacher.realName : ""}}记录</text> </view> @@ -41,7 +41,7 @@ <template is='imgTextView' data="{{img:'sleep',text:'ç¡è§‰'}}"> </template> </view> <view class='kg-flex-row timeline-content-detail'> - <text class='kg-text-normal-gray'>{{sleepItem.z_recordType}}</text> + <text class='kg-text-normal-gray'>åˆç¡</text> <text class='kg-text-normal-gray'>{{sleepItem.value}}分钟</text> </view> </view> diff --git a/pages/home/reviewer/index.wxml b/pages/home/reviewer/index.wxml index 28b7b813e76e8085213aaac4973b316e522adde0..95a622b05c5456214c5d09c589ddb06597ec1fb0 100644 --- a/pages/home/reviewer/index.wxml +++ b/pages/home/reviewer/index.wxml @@ -3,7 +3,7 @@ <view class='kg-separater' style='height:2rpx;'></view> <view class='kg-home-header kg-flex-row'> - <template is='userInfo' data="{{userImg:'/src/img/defaut_teacher_icon.png',title:'å®¡æ ¸è€å¸ˆ',subTitle:'呿—¥è‘µå¹¼å„¿å›',sex:'m'}}"></template> + <template is='userInfo' data="{{userImg:'/src/img/defaut_teacher_icon.png',title:'å®¡æ ¸è€å¸ˆ',subTitle:'呿—¥è‘µå¹¼å„¿å›',sex:'male'}}"></template> <view></view> </view> <view class='kg-separater'></view> @@ -22,7 +22,7 @@ <!-- åå— --> <view class='home-student-name'> <view class='kg-text-normal-dark'>{{item.signStudentName}}</view> - <template is="sex" data="{{sex:item.signStudentSex == '0' ? 'm' : 'f'}}"></template> + <template is="sex" data="{{sex:item.signStudentSex == '0' ? 'male' : 'female'}}"></template> </view> <!-- 图片 --> <view class='home-student-picture-item'> diff --git a/pages/home/sign/index.js b/pages/home/sign/index.js index 806e2123507cb9048b2affcf61335862ca6067b2..9df42e431822a301e0c481919089ecb842d5973b 100644 --- a/pages/home/sign/index.js +++ b/pages/home/sign/index.js @@ -1,32 +1,35 @@ // pages/home/sign/index.js const req = require('../../../api/teacher.js') +const app = getApp() Page({ /** * 页é¢çš„åˆå§‹æ•°æ® */ data: { - selectTags:{} - + selectTags: {}, + classId: "" }, /** * 生命周期函数--监å¬é¡µé¢åŠ è½½ */ - onLoad: function (options) { - req.getAllStudent('001').then(res=>{ + onLoad: function(options) { + let classId = options.classId + req.getAllStudent(classId).then(res => { console.log(res) this.setData({ - records: res + records: res, + classId:classId }) }) }, - tapBox: function (e) { + tapBox: function(e) { console.log(e) let selected = !e.currentTarget.dataset.check let tags = this.data.selectTags @@ -37,9 +40,9 @@ Page({ }) }, - operateTap: function (event) { + operateTap: function(event) { console.log(event._relatedInfo.anchorTargetText) - let records= this.data.records + let records = this.data.records var studentIds = [] for (var i = 0; i < records.length; i++) { @@ -50,10 +53,9 @@ Page({ } console.log(studentIds) - req.signIn('4028048267a65d0f0167a69ae1910058', '001', studentIds).then(res=>{ + req.signIn(app.globalData.login.user.id, this.data.classId, studentIds).then(res => { wx.showToast({ title: 'ç¾åˆ°æˆåŠŸ~', - icon: 'none', duration: 1500 }) setTimeout(() => { @@ -67,49 +69,49 @@ Page({ /** * 生命周期函数--监å¬é¡µé¢åˆæ¬¡æ¸²æŸ“å®Œæˆ */ - onReady: function () { + onReady: function() { }, /** * 生命周期函数--监å¬é¡µé¢æ˜¾ç¤º */ - onShow: function () { + onShow: function() { }, /** * 生命周期函数--监å¬é¡µé¢éšè— */ - onHide: function () { + onHide: function() { }, /** * 生命周期函数--监å¬é¡µé¢å¸è½½ */ - onUnload: function () { + onUnload: function() { }, /** * 页é¢ç›¸å…³äº‹ä»¶å¤„ç†å‡½æ•°--监å¬ç”¨æˆ·ä¸‹æ‹‰åŠ¨ä½œ */ - onPullDownRefresh: function () { + onPullDownRefresh: function() { }, /** * 页é¢ä¸Šæ‹‰è§¦åº•事件的处ç†å‡½æ•° */ - onReachBottom: function () { + onReachBottom: function() { }, /** * 用户点击å³ä¸Šè§’分享 */ - onShareAppMessage: function () { + onShareAppMessage: function() { } }) \ No newline at end of file diff --git a/pages/home/teacher/index.js b/pages/home/teacher/index.js index f58d7000c9743ba573b87aa5dab6fddf015a161d..fbc997dd72a351da493879abc6a23d4c9c2a30cf 100644 --- a/pages/home/teacher/index.js +++ b/pages/home/teacher/index.js @@ -1,6 +1,7 @@ // pages/home/teacher/index.js const request = require('../../../api/teacher.js') const utils = require('../../../utils/util.js') +const app = getApp() Page({ /** @@ -34,8 +35,16 @@ Page({ }, signTap: function(e) { + if (app.globalData.login.classes.length == 0) { + wx.showToast({ + title: 'æ— ç级信æ¯, 请è”系管ç†å‘˜', + icon: 'none' + }) + return + } + var signSummary = app.globalData.login.classes[0].id wx.navigateTo({ - url: '/pages/home/sign/index', + url: '/pages/home/sign/index?classId=' + signSummary, }) }, @@ -43,6 +52,20 @@ Page({ * 生命周期函数--监å¬é¡µé¢åŠ è½½ */ onLoad: function(options) { + + }, + + /** + * 生命周期函数--监å¬é¡µé¢åˆæ¬¡æ¸²æŸ“å®Œæˆ + */ + onReady: function() { + + }, + + /** + * 生命周期函数--监å¬é¡µé¢æ˜¾ç¤º + */ + onShow: function() { // 设置日期 let date = new Date() let dateStr = utils.formatDate(date) @@ -50,11 +73,17 @@ Page({ dateStr: dateStr }) - request.kg_login() - - + if (app.globalData.login.classes.length == 0) { + wx.showToast({ + title: 'æ— ç级信æ¯, 请è”系管ç†å‘˜', + icon: 'none' + }) + return + } + var signSummary = app.globalData.login.classes[0].id - request.querySignSummary("4028048267a65d0f0167a69ae1910058", "4028048267a5969b0167a5b22f3807f8").then(res => { + // request.querySignSummary("4028048267a65d0f0167a69ae1910058", "4028048267a5969b0167a5b22f3807f8").then(res => { + request.querySignSummary(app.globalData.login.user.id, signSummary).then(res => { console.log(res) for (var i = 0; i < res.length; i++) { @@ -67,22 +96,6 @@ Page({ }) - - - }, - - /** - * 生命周期函数--监å¬é¡µé¢åˆæ¬¡æ¸²æŸ“å®Œæˆ - */ - onReady: function() { - - }, - - /** - * 生命周期函数--监å¬é¡µé¢æ˜¾ç¤º - */ - onShow: function() { - }, /** diff --git a/pages/home/teacher/index.wxml b/pages/home/teacher/index.wxml index 4757814d1788122cfd035b03c1b2e40311e7e06f..4aa69027d69b612582149da98319e6aec6f45265 100644 --- a/pages/home/teacher/index.wxml +++ b/pages/home/teacher/index.wxml @@ -17,7 +17,7 @@ <!-- åå— --> <view class='home-student-name'> <view class='kg-text-normal-dark'>{{item.signStudentName}}</view> - <template is="sex" data="{{sex:item.signStudentSex == '0' ? 'm' : 'f'}}"></template> + <template is="sex" data="{{sex:item.signStudentSex == '0' ? 'male' : 'female'}}"></template> </view> <!-- 图片 --> <view class='home-student-picture-item'> @@ -27,9 +27,9 @@ </view> <!-- 行为 --> <view class='home-student-name' style='justify-content: space-between;margin:0rpx 30rpx;'> - <template is='imgTextView' data="{{img:'eat',text:item.eatCount }}"> </template> - <template is='imgTextView' data="{{img:'sleep',text:item.sleepTotal }}"> </template> - <template is='imgTextView' data="{{img:'wc',text:item.wcCount }}"> </template> + <template is='imgTextView' data="{{img:'eat',text:(item.eatCount ? item.eatCount : '0')}}"> </template> + <template is='imgTextView' data="{{img:'sleep',text:(item.sleepTotal ? item.sleepTotal : '0')}}"> </template> + <template is='imgTextView' data="{{img:'wc',text:(item.wcCount ? item.wcCount : '0')}}"> </template> </view> </view> </view> diff --git a/pages/login/index.js b/pages/login/index.js new file mode 100644 index 0000000000000000000000000000000000000000..6de647c9d8cb90cd458aa2b968942c541324ccdf --- /dev/null +++ b/pages/login/index.js @@ -0,0 +1,110 @@ +// pages/login/index.js +var request = require('../../api/request.js') +const app = getApp() + +Page({ + + /** + * 页é¢çš„åˆå§‹æ•°æ® + */ + data: { + mobile: '' + + }, + + /** + * 生命周期函数--监å¬é¡µé¢åŠ è½½ + */ + onLoad: function (options) { + + }, + + inputAction: function (e) { + console.log(e.detail.value) + this.setData({ + mobile: e.detail.value + }) + }, + + operateTap: function (event) { + request.kg_login(true, this.data.mobile).then(res=>{ + console.log(res) + app.globalData.login = res + //1是è€å¸ˆ,2是家长 + + if (res.user.userType == 1) { + //å®¡æ ¸è€å¸ˆ + if (res.user.isAudit == "Y"){ + wx.redirectTo({ + url: '/pages/home/reviewer/index', + }) + // 带çè€å¸ˆ + }else{ + wx.redirectTo({ + url: '/pages/home/teacher/index', + }) + } + }else if (res.user.userType == 2) { + wx.redirectTo({ + url: '/pages/home/parents/index', + }) + }else{ + wx.showToast({ + title: '错误的用户类型', + icon: 'none' + }) + } + + }) + + }, + + /** + * 生命周期函数--监å¬é¡µé¢åˆæ¬¡æ¸²æŸ“å®Œæˆ + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监å¬é¡µé¢æ˜¾ç¤º + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监å¬é¡µé¢éšè— + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监å¬é¡µé¢å¸è½½ + */ + onUnload: function () { + + }, + + /** + * 页é¢ç›¸å…³äº‹ä»¶å¤„ç†å‡½æ•°--监å¬ç”¨æˆ·ä¸‹æ‹‰åŠ¨ä½œ + */ + onPullDownRefresh: function () { + + }, + + /** + * 页é¢ä¸Šæ‹‰è§¦åº•事件的处ç†å‡½æ•° + */ + onReachBottom: function () { + + }, + + /** + * 用户点击å³ä¸Šè§’分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/pages/login/index.json b/pages/login/index.json new file mode 100644 index 0000000000000000000000000000000000000000..fa7fdf8af611c762e6c9347e462fbfdd01bbecac --- /dev/null +++ b/pages/login/index.json @@ -0,0 +1,3 @@ +{ + "navigationBarTitleText": "手机å·ç™»å½•" +} \ No newline at end of file diff --git a/pages/login/index.wxml b/pages/login/index.wxml new file mode 100644 index 0000000000000000000000000000000000000000..732e31eaf0efb05b1d46628f345585142004566b --- /dev/null +++ b/pages/login/index.wxml @@ -0,0 +1,8 @@ +<!--pages/login/index.wxml--> +<import src='/template/operate_btn/index.wxml'></import> +<view style='padding:16px;'> +<view class='kg-text-normal-gray'>手机å·</view> +<input placeholder='请输入手机å·ç™»å½•' style='margin:30rpx 0rpx;' bindinput='inputAction'></input> +<view class='kg-separater' style='height:2rpx;'></view> +</view> +<template is="operate_btn" data="{{title:'登录'}}"></template> diff --git a/pages/login/index.wxss b/pages/login/index.wxss new file mode 100644 index 0000000000000000000000000000000000000000..06818180a47c3c60ef18a22ec816a95b9fb68058 --- /dev/null +++ b/pages/login/index.wxss @@ -0,0 +1 @@ +/* pages/login/index.wxss */ \ No newline at end of file diff --git a/pages/review_student/index.wxml b/pages/review_student/index.wxml index 01b7dd6d71a813b84a2273ac4e12fc029b4e496e..287e90cbff3821374f43f544af7e2340f9a1f936 100644 --- a/pages/review_student/index.wxml +++ b/pages/review_student/index.wxml @@ -3,7 +3,7 @@ <view class='kg-separater' style='height:2rpx;'></view> <view class='kg-home-header kg-flex-row'> - <template is='userInfo' data="{{userImg:'/src/img/defaut_teacher_icon.png',title:'å®¡æ ¸è€å¸ˆ',subTitle:'呿—¥è‘µå¹¼å„¿å›',sex:'m'}}"></template> + <template is='userInfo' data="{{userImg:'/src/img/defaut_teacher_icon.png',title:'å®¡æ ¸è€å¸ˆ',subTitle:'呿—¥è‘µå¹¼å„¿å›',sex:'male'}}"></template> <view></view> </view> <view class='kg-separater'></view> diff --git a/template/operate_btn/index.wxml b/template/operate_btn/index.wxml index 95a5aa7623e1a9f0eb1278c6ae584fd40311f49c..aa84f2a4b7777e5d1df90681c869dc124a5915b5 100644 --- a/template/operate_btn/index.wxml +++ b/template/operate_btn/index.wxml @@ -74,10 +74,10 @@ sex:性别 f/m (女性/男性) --> <template name='sex'> <view class='kg-flex-row'> - <view wx:if="{{sex == 'f'}}"> + <view wx:if="{{sex == 'female'}}"> <image class='kg-sex-icon' src='/src/img/female.png' mode='aspectFit'></image> </view> - <view wx:elif="{{sex == 'm'}}"> + <view wx:elif="{{sex == 'male'}}"> <image class='kg-sex-icon' src='/src/img/male.png' mode='aspectFit'></image> </view> </view> @@ -87,6 +87,6 @@ sex:性别 f/m (女性/男性) <template name='imgTextView'> <view class='kg-flex-row' style='justify-content: flex-start;height:60rpx;'> <image src='/src/img/{{img}}.png' style='width: 50rpx;height: 40rpx;'></image> - <text class='kg-text-normal-dark' style='margin-left:10rpx'>{{text}}</text> + <text class='kg-text-normal-dark' style='margin-left:10rpx'>{{text ? text : ""}}</text> </view> </template> \ No newline at end of file diff --git a/utils/util.js b/utils/util.js index 6a52652cee97733b1e238232d521ecfc2d8a915c..5f6fbd4b88d7df8257c6214cdfd393bbc55b8b1d 100644 --- a/utils/util.js +++ b/utils/util.js @@ -181,7 +181,7 @@ const getAccessToken = () => { } const uploadPath = () => { - return `${request.DOMAIN}/wxmall/wxsite/file/upload` + return `${request.DOMAIN}/wxsite/file/upload.do` } module.exports = {