Commit 7ddf710a authored by 张杰's avatar 张杰

no message

parent f9d72738
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
......@@ -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) {
// 保存登录结果
......@@ -301,3 +302,63 @@ 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
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,
......
{
"pages":[
"pages/login/index",
"pages/home/teacher/index",
"pages/home/reviewer/index",
......
// 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'
})
}
})
}
})
},
......@@ -131,7 +164,7 @@ Page({
})
},
// 调用接口获取数据
// 调用接口获取数据
getRecord: function() {
let studentIds = this.data.studentIds
console.log(studentIds)
......@@ -244,7 +277,7 @@ 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
}
......@@ -363,11 +396,18 @@ Page({
}
req.setRecord(arrRecordList).then(res => {
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) {
......
......@@ -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,7 +23,24 @@ Page({
*/
onLoad: function(options) {
const that = this
let resData = this.data.testData
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({
student:student
})
request.queryStudentRecord(that.data.page, that.data.pageSize, studentId).then(res => {
console.log(res)
let resData = res
var record = resData['records']
......@@ -155,6 +61,12 @@ Page({
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 + "次"
}
}
// 睡觉
......@@ -183,49 +95,7 @@ Page({
page: resData['paging']['page']
})
// 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]
// // 饮食
// var dietRecords = item['dietRecord']
// 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]
// }
// console.log(item)
// templist.push(item)
// }
// this.setData({
// records: templist,
// page: resData['paging']['page']
// })
// })
})
},
......
......@@ -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>
......
......@@ -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'>
......
// 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
// 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() {
},
/**
......
......@@ -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>
......
// 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
{
"navigationBarTitleText": "手机号登录"
}
\ No newline at end of file
<!--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>
/* pages/login/index.wxss */
\ No newline at end of file
......@@ -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>
......
......@@ -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
......@@ -181,7 +181,7 @@ const getAccessToken = () => {
}
const uploadPath = () => {
return `${request.DOMAIN}/wxmall/wxsite/file/upload`
return `${request.DOMAIN}/wxsite/file/upload.do`
}
module.exports = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment