123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- // pages/shell_device/shell_device.js
- const { formatDate, formatTime2, formatDateZyb, getDateDiff } = require('../../utils/util.js')
- var app=getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- thumbnail: app.globalData.thumbnail,
- baseImgUrl: app.globalData.baseImgUrl,
- hiddenModel:false,
- isTime:false,
- bindType:1,
- list: [
- // {
- // "beginDate": "2018.09.02",
- // "endDate": "2018.10.02",
- // "leagueName": "深圳共享馆",
- // "status": 1
- // },
- // {
- // "beginDate": "2018.09.02",
- // "endDate": "2018.10.02",
- // "leagueName": "深圳共享馆1",
- // "status": 2
- // }
- ]
-
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- options.parentVipLiIdx = app.getGlobalAttributeValue(`parentVipLiIdx-${app.getGlobalAttributeValue(`userId`)}`)
- console.log(options)
- var times = options.commuEndDate;
- var messageTime = formatDateZyb(times, 'Y-M-D')
- var nowTime = new Date().getTime();
- var today = formatDateZyb(nowTime / 1000, 'Y-M-D');
- var day1 = new Date(today);
- var day2 = new Date(messageTime);
- var differDay = (day2 - day1) / (1000 * 60 * 60 * 24);
- console.log(differDay)
- if (0 <= differDay) {
- this.setData({ isTime: true, dateTime: messageTime })
- } else if (differDay < 0) {
- this.setData({ isTime: false })
- }
-
- this.setData(options)
- if (options.isShell==0) {
- wx.setNavigationBarTitle({
- title: `小塾设备`,
- })
- }else {
- wx.setNavigationBarTitle({
- title: `学习系统服务`,
- })
- }
-
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- const { isShell}=this.data;
- this.getInformation();
- if (isShell==1){
- this.chatHomeworkTime();
- }
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- /**
- * 路由跳转
- */
- redirectCtl: app.redirectCtl,
- /**
- * 路由跳转
- */
- navigateCtl: app.navigateCtl,
- /**
- * 提示框隐藏
- */
- allShowModel: function () {
- this.setData({ hiddenModel: false })
- },
- /**
- * 解绑弹框
- */
- changeShell:function(){
- this.setData({ hiddenModel: true })
- },
- /**
- * 贝壳解绑
- */
- setShell:function(){
- const { derver}=this.data;
- const postData = { fn: this.setShell, param: { ...arguments } }
- app.post('/api/parents/parents/V2/untieDerver', { derver}, 0, postData).then(res => {
- wx.showToast({
- title: '解绑成功',
- icon: 'none'
- })
- this.setData({ derver: '', hiddenModel: false})
- this.getInformation()
- })
- },
- /**
- * 查询作业吧服务时间
- */
- chatHomeworkTime:function(){
- const { vipId } = this.data;
- const postData = { fn: this.chatHomeworkTime, param: { ...arguments } }
- app.post('/api/parents/parents/V2/service/findZybServiceList', { vipId}, 0, postData).then(res => {
- const { list}=res.data;
- this.setData({list});
- })
- },
-
- /**
- * 获取定位经纬度
- */
- getLocation: function () {
- app.getWxUserLocationSetting(res => {
- wx.showLoading({
- title: '定位中'
- })
- wx.getLocation({
- type: 'wgs84',
- success: res => {
- this.setData({
- longitude: res.longitude, // '113.36403' ||
- latitude: res.latitude // '23.14203' ||
- })
- this.addChildCtl();
- },
- fail: res => {
- setTimeout(() => {
- wx.showToast({
- title: '定位失败',
- icon: 'none'
- })
- }, 10)
- setTimeout(() => {
- wx.navigateBack({
- delta: 1
- })
- }, 1000)
- },
- complete: res => {
- wx.hideLoading()
- }
- })
- })
- },
- /**
- * 绑定孩子二维码
- */
- addChildCtl: function () {
- const postData = { fn: this.addChildCtl, param: { ...arguments } }
- const { vipId } = this.data;
- const { longitude, latitude } = this.data;
- if (!longitude) {
- wx.showToast({
- title: '请允许授权获取地理位置',
- icon: 'none'
- })
- return
- }
- wx.scanCode({
- // onlyFromCamera: true,
- success: (e) => {
- // if (e.result.indexOf('https://xt.sharingschool.com') != -1) {
- app.post('/api/parents/parents/V2/newSwipeQrCode', {
- vipId,
- longitude,
- latitude,
- qrCode: e.result
- }, 0, postData).then(res => {
- const { derver} = res.data
- // this.setData({ derver});
- this.bindAddChildCtl(derver);
- })
- // } else {
- // wx.showToast({
- // title: '二维码不正确',
- // icon: 'none',
- // duration: 1000
- // })
- // }
- }
- })
- },
- /**
- * 绑定孩子
- */
- bindAddChildCtl: function (str) {
- const postData = { fn: this.bindAddChildCtl, param: { ...arguments } }
- const { vipId, derver, bindType, longitude, latitude} = this.data;
- app.post('/api/parents/parents/V2/bindConch', {
- vipId,
- longitude,
- latitude,
- derver:str,
- type: bindType
- }, 0, postData).then(res => {
- this.setData({ derver:str});
- wx.showToast({
- title: '绑定成功',
- icon: 'success',
- duration: 1000
- });
- this.getInformation();
- })
-
- },
- /**
- * 获取个人信息
- */
- getInformation: function () {
- const postData = { fn: this.getInformation, param: { ...arguments } }
- const { vipId} = this.data
- app.post('/api/parents/parents/V2/getMyChildInfo', { vipId }, 0, postData).then(res => {
- const { derver, commuEndDate, childName, imgUrl, zybEndDate, derverType, isMain}=res.data;
- var times = commuEndDate;
- var messageTime = formatDateZyb(times, 'Y-M-D')
- var nowTime = new Date().getTime();
- var today = formatDateZyb(nowTime / 1000, 'Y-M-D');
- var day1 = new Date(today);
- var day2 = new Date(messageTime);
- var differDay = (day2 - day1) / (1000 * 60 * 60 * 24);
- console.log(differDay)
- if (0 <= differDay) {
- this.setData({ isTime: true, dateTime: messageTime })
- } else if (differDay < 0) {
- this.setData({ isTime: false })
- }
- this.setData({ derver, childName, imgUrl, zybEndDate, derverType, isMain});
-
- })
- },
- })
|