|
@@ -1,6 +1,7 @@
|
|
|
// pages/makePiano/makePiano.js
|
|
|
const app = getApp()
|
|
|
const util = require("../../utils/util")
|
|
|
+const urlDef = require("../../utils/urls")
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
@@ -9,17 +10,17 @@ Page({
|
|
|
data: {
|
|
|
animationBox: {},
|
|
|
animationBg: {},
|
|
|
- weekList:[],
|
|
|
- curIndex:0,
|
|
|
+ weekList: [],
|
|
|
+ curIndex: 0,
|
|
|
array: [
|
|
|
'全部时间',
|
|
|
- '08:00 ~ 10:00',
|
|
|
- '10:00 ~ 12:00',
|
|
|
- '12:00 ~ 14:00',
|
|
|
- '14:00 ~ 16:00',
|
|
|
- '16:00 ~ 18:00',
|
|
|
- '18:00 ~ 20:00',
|
|
|
- '20:00 ~ 22:00',
|
|
|
+ '08:00 ~ 10:00',
|
|
|
+ '10:00 ~ 12:00',
|
|
|
+ '12:00 ~ 14:00',
|
|
|
+ '14:00 ~ 16:00',
|
|
|
+ '16:00 ~ 18:00',
|
|
|
+ '18:00 ~ 20:00',
|
|
|
+ '20:00 ~ 22:00',
|
|
|
],
|
|
|
objectArray: [
|
|
|
{
|
|
@@ -56,21 +57,23 @@ Page({
|
|
|
}
|
|
|
],
|
|
|
index: 0,
|
|
|
- schoolList:[
|
|
|
- {},
|
|
|
- {},
|
|
|
- {},
|
|
|
- {},
|
|
|
- {},
|
|
|
+ schoolList: [
|
|
|
],
|
|
|
- loading:'上拉加载',
|
|
|
- flag:0,
|
|
|
+ loading: '上拉加载',
|
|
|
+ flag: 0,
|
|
|
+ curStu: null,
|
|
|
+ pageNum: 0,
|
|
|
+ hasNextPage: true,
|
|
|
+ schoolIndex: 0
|
|
|
},
|
|
|
|
|
|
- getWeek:function(e){
|
|
|
+ getWeek: function (e) {
|
|
|
this.setData({
|
|
|
- curIndex : e.currentTarget.dataset.index
|
|
|
+ curIndex: e.currentTarget.dataset.index,
|
|
|
+ pageNum: 0,
|
|
|
+ schoolList: [],
|
|
|
})
|
|
|
+ this.queryList();
|
|
|
},
|
|
|
|
|
|
bindPickerChange: function (e) {
|
|
@@ -84,10 +87,11 @@ Page({
|
|
|
wx.getLocation({
|
|
|
type: 'wgs84',
|
|
|
success(res) {
|
|
|
- console.log(res)
|
|
|
+ // console.log(res)
|
|
|
wx.setStorageSync('latlng', res)
|
|
|
+ that.queryList()
|
|
|
},
|
|
|
- fail(res){
|
|
|
+ fail(res) {
|
|
|
wx.hideLoading({
|
|
|
success: (res) => {
|
|
|
wx.showModal({
|
|
@@ -100,14 +104,14 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- showSelect:function(){
|
|
|
+ showSelect: function () {
|
|
|
var animation = wx.createAnimation({
|
|
|
timingFunction: 'linear',
|
|
|
})
|
|
|
this.animation = animation
|
|
|
var num = 0
|
|
|
var opacity = 0
|
|
|
- if(this.data.yFlag == false){
|
|
|
+ if (this.data.yFlag == false) {
|
|
|
num = 165
|
|
|
opacity = 0.4
|
|
|
this.setData({
|
|
@@ -122,7 +126,7 @@ Page({
|
|
|
}
|
|
|
animation.translateY(num).step()
|
|
|
this.setData({
|
|
|
- animationBox:animation.export()
|
|
|
+ animationBox: animation.export()
|
|
|
})
|
|
|
|
|
|
var animation2 = wx.createAnimation({
|
|
@@ -132,22 +136,23 @@ Page({
|
|
|
|
|
|
animation2.opacity(opacity).step()
|
|
|
this.setData({
|
|
|
- animationBg:animation2.export()
|
|
|
+ animationBg: animation2.export()
|
|
|
})
|
|
|
-
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
var list = []
|
|
|
- for(var i = 0; i < 7; i++){
|
|
|
+ for (var i = 0; i < 7; i++) {
|
|
|
var date = util.fun_date(i)
|
|
|
var week = util.fun_week(date)
|
|
|
var json = {
|
|
|
- date: date.substring(5,date.length),
|
|
|
+ date: date.substring(5, date.length),
|
|
|
+ ds: date, // 日期 y-m-d
|
|
|
+ ws: new Date(date).getDay(), // 星期
|
|
|
week: week
|
|
|
}
|
|
|
list.push(json)
|
|
@@ -197,29 +202,10 @@ Page({
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom: function () {
|
|
|
- if(this.data.flag == 0){
|
|
|
- this.setData({
|
|
|
- loading: '加载中',
|
|
|
- flag: 1
|
|
|
- })
|
|
|
- setTimeout(() => {
|
|
|
- this.setData({
|
|
|
- schoolList:[
|
|
|
- {},
|
|
|
- {},
|
|
|
- {},
|
|
|
- {},
|
|
|
- {},
|
|
|
- {},
|
|
|
- {},
|
|
|
- {},
|
|
|
- {},
|
|
|
- {},
|
|
|
- ],
|
|
|
- loading: '没有更多数据',
|
|
|
- flag: 2
|
|
|
- })
|
|
|
- }, 2000);
|
|
|
+ if (this.data.hasNextPage) {
|
|
|
+ let pn = this.data.pageNum
|
|
|
+ this.setData({ loading: '加载中', 'pageNum': ++pn })
|
|
|
+ this.queryList()
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -228,5 +214,102 @@ Page({
|
|
|
*/
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
+ },
|
|
|
+ queryList: function () {
|
|
|
+ const urls = urlDef.urls;
|
|
|
+ let stu = wx.getStorageSync('student');
|
|
|
+ if (stu) {
|
|
|
+ this.setData({ curStu: stu })
|
|
|
+ let latlng = wx.getStorageSync('latlng')
|
|
|
+ let latitude = latlng.latitude //30.55473
|
|
|
+ let longitude = latlng.longitude
|
|
|
+ let countyCode = '420101'
|
|
|
+ let params = { 'q.coordinate': longitude + ',' + latitude, 'q.studentId': stu.studentId };
|
|
|
+ // 'q.regionId': countyCode.substring(0, 4) + '00'
|
|
|
+ params['q.regionId'] = countyCode.substring(0, 4) + '00'
|
|
|
+ params.pageNum = this.data.pageNum
|
|
|
+ util.apiPost(urls.get_near_school, params).then(rs => {
|
|
|
+
|
|
|
+ let list = rs.list;
|
|
|
+ list.map(s => {
|
|
|
+ s.dist = this.showDist(s.distance)
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ 'hasNextPage': rs.hasNextPage,
|
|
|
+ 'loading': rs.hasNextPage ? '下拉刷新' : '没有更多数据',
|
|
|
+ 'schoolList': this.data.schoolList.concat(list)
|
|
|
+ })
|
|
|
+
|
|
|
+ // 默认查询第一个学校的课程
|
|
|
+ if (list && list.length > 0) {
|
|
|
+ this.queryClassesList(list[0].id)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ showDist(d) {
|
|
|
+ if (d <= 0) {
|
|
|
+ return '无法定位';
|
|
|
+ }
|
|
|
+ if (d > 1000) {
|
|
|
+ return (d / 1000).toFixed(2) + 'km';
|
|
|
+ }
|
|
|
+ return d + 'm';
|
|
|
+ },
|
|
|
+ selectSchool: function (e) {
|
|
|
+ let index = e.currentTarget.dataset.index;
|
|
|
+ let id = e.currentTarget.dataset.id;
|
|
|
+
|
|
|
+ this.setData({ 'schoolIndex': index })
|
|
|
+ this.queryClassesList(id)
|
|
|
+ },
|
|
|
+ collectSchool: function (e) {
|
|
|
+ let id = e.currentTarget.dataset.id;
|
|
|
+ const urls = urlDef.urls;
|
|
|
+ util.apiPost(urls.collect_school + '?q.orgId=' + id + '&q.studentId=' + this.data.curStu.studentId).then((rs) => {
|
|
|
+ this.setData({
|
|
|
+ pageNum: 0,
|
|
|
+ schoolList: []
|
|
|
+ })
|
|
|
+ this.queryList()
|
|
|
+ });
|
|
|
+ },
|
|
|
+ queryClassesList: function (sid) {
|
|
|
+ const urls = urlDef.urls;
|
|
|
+
|
|
|
+ let sl = this.data.schoolList;
|
|
|
+ let s = sl.filter(o => o.id == sid)[0];
|
|
|
+
|
|
|
+ let w = this.data.weekList[this.data.curIndex];
|
|
|
+
|
|
|
+ let date = w.ds
|
|
|
+ let week = w.ws
|
|
|
+
|
|
|
+ let params = { 'q.orgId': sid, 'q.studentId': this.data.curStu.studentId, 'q.date': date, 'q.week': week }
|
|
|
+ // params['q.timeScope'] = ''; 时段
|
|
|
+ util.apiPost(urls.query_school_attence, params).then(rs => {
|
|
|
+ s.items = rs
|
|
|
+ this.setData({ schoolList: sl })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ doAppointment: function (e) {
|
|
|
+ let id = e.currentTarget.dataset.id;
|
|
|
+ const urls = urlDef.urls;
|
|
|
+ let w = this.data.weekList[this.data.curIndex];
|
|
|
+ util.apiPost(urls.do_appointment + '?q.studentId=' + this.data.curStu.studentId + '&q.planId=' + id + '&q.orgId=' + this.data.curStu.orgId + '&q.visitDate=' + w.ds).then(rs => {
|
|
|
+ if (rs.success > 0) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '预约成功'
|
|
|
+ })
|
|
|
+ this.queryClassesList(this.data.curStu.orgId)
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: rs.msg,
|
|
|
+ icon: 'none',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
})
|