|
@@ -2,18 +2,25 @@
|
|
|
const app = getApp()
|
|
|
const util = require("../../utils/util")
|
|
|
const urlDef = require("../../utils/urls")
|
|
|
+
|
|
|
+const key = 'FCLBZ-ZQ2Y3-DC23W-3EXRK-LUKX6-W7F6Z'; // 使用在腾讯位置服务申请的key
|
|
|
+const referer = '艾克斯朗学生端'; // 调用插件的app的名称
|
|
|
+const hotCitys = '武汉'; // 用户自定义的的热门城市
|
|
|
+const citySelector = requirePlugin('citySelector');
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
+ refreshFlag: 1,
|
|
|
+ homeName: '',
|
|
|
animationBox: {},
|
|
|
animationBg: {},
|
|
|
weekList: [],
|
|
|
curIndex: 0,
|
|
|
array: [
|
|
|
- '全部时间',
|
|
|
+ // '全部时间',
|
|
|
'08:00 ~ 10:00',
|
|
|
'10:00 ~ 12:00',
|
|
|
'12:00 ~ 14:00',
|
|
@@ -22,10 +29,9 @@ Page({
|
|
|
'18:00 ~ 20:00',
|
|
|
'20:00 ~ 22:00',
|
|
|
],
|
|
|
- index: 0,
|
|
|
- schoolList: [
|
|
|
- ],
|
|
|
- loading: '上拉加载',
|
|
|
+ index: -1,
|
|
|
+ schoolList: [],
|
|
|
+ loading: '加载中...',
|
|
|
flag: 0,
|
|
|
curStu: null,
|
|
|
pageNum: 0,
|
|
@@ -35,6 +41,19 @@ Page({
|
|
|
yFlag: false
|
|
|
},
|
|
|
|
|
|
+ getTimeDate:function(e){
|
|
|
+ if(e.currentTarget.dataset.value == this.data.index){
|
|
|
+ this.setData({
|
|
|
+ index: -1,
|
|
|
+ })
|
|
|
+ } else{
|
|
|
+ this.setData({
|
|
|
+ index: e.currentTarget.dataset.value,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
getWeek: function (e) {
|
|
|
this.setData({
|
|
|
curIndex: e.currentTarget.dataset.index,
|
|
@@ -51,10 +70,12 @@ Page({
|
|
|
},
|
|
|
selectTime: function () {
|
|
|
let timeScope = '0,0'
|
|
|
- if (this.data.index > 0) {
|
|
|
- timeScope = this.data.array[this.data.index].replace(/\s*/g, '').replace('~', ',').replace(/:00/g,'')
|
|
|
+ if (this.data.index >= 0) {
|
|
|
+ timeScope = this.data.array[this.data.index].replace(/\s*/g, '').replace('~', ',').replace(/:00/g, '')
|
|
|
}
|
|
|
- this.setData({ timeScope: timeScope })
|
|
|
+ this.setData({
|
|
|
+ timeScope: timeScope
|
|
|
+ })
|
|
|
this.showSelect()
|
|
|
|
|
|
this.setData({
|
|
@@ -64,21 +85,22 @@ Page({
|
|
|
this.queryList()
|
|
|
},
|
|
|
|
|
|
- resetTime:function(){
|
|
|
+ resetTime: function () {
|
|
|
let timeScope = '0,0'
|
|
|
- this.setData({ timeScope , index: 0})
|
|
|
+ this.setData({
|
|
|
+ timeScope,
|
|
|
+ index: -1,
|
|
|
+ })
|
|
|
this.showSelect()
|
|
|
this.queryList()
|
|
|
},
|
|
|
|
|
|
localtionMethod: function () {
|
|
|
- var that = this
|
|
|
+ const that = this
|
|
|
wx.getLocation({
|
|
|
type: 'wgs84',
|
|
|
success(res) {
|
|
|
- // console.log(res)
|
|
|
- wx.setStorageSync('latlng', res)
|
|
|
- that.queryList()
|
|
|
+ that.locationAfter()
|
|
|
},
|
|
|
fail(res) {
|
|
|
wx.hideLoading({
|
|
@@ -86,6 +108,23 @@ Page({
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: "定位失败,请检查手机'位置服务'或GPS功能已开启并授权小程序位置信息",
|
|
|
+ success(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ wx.openSetting({
|
|
|
+ success(res) {
|
|
|
+ console.log(res.authSetting)
|
|
|
+ // res.authSetting = {
|
|
|
+ // "scope.userInfo": true,
|
|
|
+ // "scope.userLocation": true
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.navigateBack({
|
|
|
+ delta: 1,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
})
|
|
@@ -101,19 +140,19 @@ Page({
|
|
|
var num = 0
|
|
|
var opacity = 0
|
|
|
if (this.data.yFlag == false) {
|
|
|
- num = 165
|
|
|
+ num = -300
|
|
|
opacity = 0.4
|
|
|
this.setData({
|
|
|
yFlag: true
|
|
|
})
|
|
|
} else {
|
|
|
- num = -360
|
|
|
+ num = 165
|
|
|
opacity = 0
|
|
|
this.setData({
|
|
|
yFlag: false
|
|
|
})
|
|
|
}
|
|
|
- animation.translateY(num).step()
|
|
|
+ animation.translateX(num).step()
|
|
|
this.setData({
|
|
|
animationBox: animation.export()
|
|
|
})
|
|
@@ -147,9 +186,10 @@ Page({
|
|
|
list.push(json)
|
|
|
}
|
|
|
this.setData({
|
|
|
- weekList: list
|
|
|
+ weekList: list,
|
|
|
+ homeName: wx.getStorageSync('wxLocalName')
|
|
|
})
|
|
|
- this.localtionMethod()
|
|
|
+
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -163,7 +203,41 @@ Page({
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
- this.queryList()
|
|
|
+ this.localtionMethod()
|
|
|
+ },
|
|
|
+ locationAfter: function () {
|
|
|
+ const selectedCity = citySelector.getCity();
|
|
|
+ if (selectedCity) {
|
|
|
+ this.setData({
|
|
|
+ homeName: selectedCity.fullname,
|
|
|
+ schoolList: []
|
|
|
+ })
|
|
|
+ wx.setStorageSync('latlng', selectedCity.location)
|
|
|
+ wx.setStorageSync('adCode', selectedCity.id)
|
|
|
+ wx.setStorageSync('wxLocalName', selectedCity.fullname)
|
|
|
+ } else {
|
|
|
+ if (wx.getStorageSync('latlng')) {
|
|
|
+ this.setData({
|
|
|
+ homeName: wx.getStorageSync('wxLocalName')
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.selectCity()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(this.data.refreshFlag == 1){
|
|
|
+ this.setData({
|
|
|
+ schoolList: [],
|
|
|
+ refreshFlag: 0
|
|
|
+ })
|
|
|
+ this.queryList()
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ selectCity: function () {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `plugin://citySelector/index?key=${key}&referer=${referer}&hotCitys=${hotCitys}`,
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -193,7 +267,10 @@ Page({
|
|
|
onReachBottom: function () {
|
|
|
if (this.data.hasNextPage) {
|
|
|
let pn = this.data.pageNum
|
|
|
- this.setData({ loading: '加载中', 'pageNum': ++pn })
|
|
|
+ this.setData({
|
|
|
+ loading: '加载中',
|
|
|
+ 'pageNum': ++pn
|
|
|
+ })
|
|
|
this.queryList()
|
|
|
}
|
|
|
},
|
|
@@ -208,12 +285,18 @@ Page({
|
|
|
const urls = urlDef.urls;
|
|
|
let stu = wx.getStorageSync('student');
|
|
|
if (stu) {
|
|
|
- this.setData({ curStu: 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 };
|
|
|
+ // let countyCode = '420101'
|
|
|
+ let countyCode = wx.getStorageSync('adCode')
|
|
|
+ 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
|
|
@@ -224,11 +307,12 @@ Page({
|
|
|
s.dist = this.showDist(s.distance)
|
|
|
})
|
|
|
|
|
|
-
|
|
|
+ const schoolNum = "("+list.length+")"
|
|
|
this.setData({
|
|
|
'hasNextPage': rs.hasNextPage,
|
|
|
- 'loading': rs.hasNextPage ? '下拉刷新' : '没有更多数据',
|
|
|
- 'schoolList': this.data.schoolList.concat(list)
|
|
|
+ 'loading': rs.hasNextPage ? '上拉加载' : '没有更多数据',
|
|
|
+ 'schoolList': this.data.schoolList.concat(list),
|
|
|
+ schoolNum
|
|
|
})
|
|
|
|
|
|
// 默认查询第一个学校的课程
|
|
@@ -249,10 +333,23 @@ Page({
|
|
|
},
|
|
|
selectSchool: function (e) {
|
|
|
let index = e.currentTarget.dataset.index;
|
|
|
- let id = e.currentTarget.dataset.id;
|
|
|
+ // let id = e.currentTarget.dataset.id;
|
|
|
+
|
|
|
+ // this.setData({
|
|
|
+ // 'schoolIndex': index
|
|
|
+ // })
|
|
|
+ // this.queryClassesList(id)
|
|
|
+ let moreFlag = 'schoolList['+index+'].moreFlag'
|
|
|
+ if(this.data.schoolList[index].moreFlag){
|
|
|
+ this.setData({
|
|
|
+ [moreFlag] : false
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ [moreFlag] : true
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
- this.setData({ 'schoolIndex': index })
|
|
|
- this.queryClassesList(id)
|
|
|
},
|
|
|
collectSchool: function (e) {
|
|
|
let id = e.currentTarget.dataset.id;
|
|
@@ -269,19 +366,40 @@ Page({
|
|
|
const urls = urlDef.urls;
|
|
|
|
|
|
let sl = this.data.schoolList;
|
|
|
- let s = sl.filter(o => o.id == this.data.schoolList[this.data.schoolIndex].id)[0];
|
|
|
+ for (var i in sl) {
|
|
|
+ let s = sl.filter(o => o.id == this.data.schoolList[i].id)[0];
|
|
|
|
|
|
- let w = this.data.weekList[this.data.curIndex];
|
|
|
+ let w = this.data.weekList[this.data.curIndex];
|
|
|
|
|
|
- let date = w.ds
|
|
|
- let week = w.ws + 1;
|
|
|
+ let date = w.ds
|
|
|
+ let week = w.ws + 1;
|
|
|
|
|
|
- let params = { 'q.orgId': this.data.schoolList[this.data.schoolIndex].id, 'q.studentId': this.data.curStu.studentId, 'q.date': date, 'q.week': week, 'q.timeScope': this.data.timeScope }
|
|
|
- // params['q.timeScope'] = ''; 时段
|
|
|
- util.apiPost(urls.query_school_attence, params).then(rs => {
|
|
|
- s.items = rs
|
|
|
- this.setData({ schoolList: sl })
|
|
|
- })
|
|
|
+ let params = {
|
|
|
+ 'q.orgId': this.data.schoolList[i].id,
|
|
|
+ 'q.studentId': this.data.curStu.studentId,
|
|
|
+ 'q.date': date,
|
|
|
+ 'q.week': week,
|
|
|
+ 'q.timeScope': this.data.timeScope
|
|
|
+ }
|
|
|
+ // params['q.timeScope'] = ''; 时段
|
|
|
+ util.apiPost(urls.query_school_attence, params).then(rs => {
|
|
|
+ for (var j in rs) {
|
|
|
+ if (rs[j].studentVisitNum > 0 || rs[j].studentWaitNum > 0) {
|
|
|
+ s.moreFlag = true
|
|
|
+ break
|
|
|
+ } else {
|
|
|
+ s.moreFlag = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(s.collect == 1){
|
|
|
+ s.moreFlag = true
|
|
|
+ }
|
|
|
+ s.items = rs
|
|
|
+ this.setData({
|
|
|
+ schoolList: sl
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
doAppointment: function (e) {
|
|
|
wx.showLoading({
|
|
@@ -292,7 +410,7 @@ Page({
|
|
|
const index = e.currentTarget.dataset.index
|
|
|
const cIndex = e.currentTarget.dataset.cindex
|
|
|
|
|
|
- if(this.data.schoolList[index].items[cIndex].hasVisitNum >= this.data.schoolList[index].items[cIndex].maxNum){
|
|
|
+ if (this.data.schoolList[index].items[cIndex].hasVisitNum >= this.data.schoolList[index].items[cIndex].maxNum) {
|
|
|
wx.hideLoading({
|
|
|
success: (res) => {
|
|
|
wx.showToast({
|
|
@@ -308,7 +426,7 @@ Page({
|
|
|
const urls = urlDef.urls;
|
|
|
let w = this.data.weekList[this.data.curIndex];
|
|
|
let sid = this.data.schoolList[this.data.schoolIndex].id
|
|
|
- util.apiPost(urls.do_appointment + '?q.studentId=' + this.data.curStu.studentId + '&q.planId=' + id + '&q.orgId=' + sid + '&q.visitDate=' + w.ds).then(rs => {
|
|
|
+ util.apiPost(urls.do_appointment + '?q.studentId=' + this.data.curStu.studentId + '&q.planId=' + id + '&q.orgId=' + sid + '&q.visitDate=' + w.ds).then(rs => {
|
|
|
if (rs.success > 0) {
|
|
|
wx.showToast({
|
|
|
title: '预约成功'
|
|
@@ -319,15 +437,18 @@ Page({
|
|
|
title: rs.msg,
|
|
|
icon: 'none',
|
|
|
})
|
|
|
+ this.queryList()
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
toQueueUp(e) {
|
|
|
let id = e.currentTarget.dataset.id;
|
|
|
+ let index = e.currentTarget.dataset.index
|
|
|
let w = this.data.weekList[this.data.curIndex];
|
|
|
- let sid = this.data.schoolList[this.data.schoolIndex].id
|
|
|
+ let sid = this.data.schoolList[index].id
|
|
|
+
|
|
|
wx.navigateTo({
|
|
|
- url: '/pages/queue/queue?planId=' + id + '&orgId=' + sid + '&visitDate=' + w.ds
|
|
|
+ url: '/pages/queue/queue?planId=' + id + '&orgId=' + sid + '&visitDate=' + w.ds
|
|
|
})
|
|
|
}
|
|
|
})
|