Commit 2b579026 authored by 张杰's avatar 张杰

增加对登录状态的判断

parent 5620a6f3
......@@ -11,14 +11,14 @@ const ERR_NOT_ACCESS_TOKEN = 21;
var DEF_APP_CONFIG = {
appId: "wxe19b38d5dbc061c6", // 勾芒小程序测试号
// 开发环境
domain: 'https://dev.gomoretech.com/preschool',
baseUrl: "https://dev.gomoretech.com/preschool"
// domain: 'https://dev.gomoretech.com/preschool',
// baseUrl: "https://dev.gomoretech.com/preschool"
// 川哥本地环境
// domain: 'http://192.168.199.230:8080/preschool',
// baseUrl: "http://192.168.199.230:8080/preschool",
// // 谢贝本地环境
// domain: 'http://192.168.199.153:9090',
// baseUrl: "http://192.168.199.153:9090/wxmall/wxsite"
// 正式环境
domain: 'https://preschool.gomoretech.com/preschool',
baseUrl: "https://preschool.gomoretech.com/preschool"
}
const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : DEF_APP_CONFIG;
const APP_ID = extConfig.appId || DEF_APP_CONFIG.appId;
......
//app.js
App({
onLaunch: function () {
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
// 获取用户信息
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
this.globalData.userInfo = res.userInfo
onLaunch: function() {
setTimeout(function () {
this.checkLoginState()
}.bind(this), 1000)
},
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
}
})
}
}
})
checkLoginState: function() {
var pages = getCurrentPages() //获取加载的页面
var currentPage = pages[pages.length - 1] //获取当前页面的对象
var url = currentPage.route //当前页面url
if (url != "pages/login/index" && this.globalData.isLogin == false) {
wx.redirectTo({
url: '/pages/login/index',
})
}
},
globalData: {
isLogin: false,
userInfo: null,
//一些默认值
operate_btn_height: 80,
......@@ -55,7 +39,11 @@ App({
"normal": "正常",
"more": "多"
},
studentPaymentTypes: { 'nursery_all': '全托', 'nursery_morning': '上午托', 'nursery_afternoon': '下午托', }
studentPaymentTypes: {
'nursery_all': '全托',
'nursery_morning': '上午托',
'nursery_afternoon': '下午托',
}
}
})
\ No newline at end of file
......@@ -37,7 +37,7 @@
<image src='{{picItem}}' class='home-student-picture' catchtap='previewPic' data-index='{{index}}' data-picIndex='{{picIndex}}' mode='aspectFill'></image>
</view>
</view>
<text class='kg-text-light-gray' style='margin-left:60rpx;margin-right:45rpx;'>{{item.pictureRemark ? item.pictureRemark : ''}}</text>
<text class='kg-text-light-gray' style='margin-left:60rpx;margin-right:35rpx;'>{{item.pictureRemark ? item.pictureRemark : ''}}</text>
<view class='kg-separater' style='height:2rpx;margin-left:80rpx;margin-right:0rpx;'></view>
......@@ -78,7 +78,7 @@
<text class='kg-text-normal-gray' >{{wcItem.value ? wcItem.value : '0'}}次</text>
</view>
</view>
<text class='kg-text-light-gray' style='margin-left:60rpx;margin-right:45rpx;'>{{item.remark ? item.remark : ''}}</text>
<text class='kg-text-light-gray' style='margin-left:60rpx;margin-right:35rpx;'>{{item.remark ? item.remark : ''}}</text>
</view>
</view>
......
......@@ -58,7 +58,7 @@
.timeline-content-detail {
margin-left:60rpx;
margin-right:60rpx;
margin-right:38rpx;
margin-bottom:10rpx;
}
......
<!--pages/login/index.wxml-->
<import src='/template/operate_btn/index.wxml'></import>
<view class='kg-separater' style='height:2rpx;'></view>
<image class='login_logo' src='/src/img/login_logo.png'></image>
<view style='padding:16px;margin-top:50rpx;'>
<image class='login_logo' src=''></image>
<view class='login-board'>
<view class='kg-text-normal-gray'>手机号</view>
<input placeholder='请输入手机号登录' style='margin:30rpx 0rpx;' bindinput='inputAction' value='{{mobile}}'></input>
<view class='kg-separater' style='height:2rpx;'></view>
......
This diff is collapsed.
......@@ -29,7 +29,7 @@
<view wx:if="{{dietIndex == 0}}">
<template is='imgTextView' data="{{img:'eat',text:'饮食'}}"> </template>
</view>
<view class='kg-flex-row timeline-content-detail'>
<view class='kg-flex-row timeline-content-detail' style='margin-right:60rpx;'>
<text class='kg-text-normal-gray'>{{dietItem.z_recordType}}</text>
<text class='kg-text-normal-gray'>{{dietItem.z_eatState}}</text>
</view>
......@@ -41,7 +41,7 @@
<view class='kg-separater' style='height:2rpx;margin-left:80rpx;margin-right:0rpx;'></view>
<template is='imgTextView' data="{{img:'sleep',text:'睡眠'}}"> </template>
</view>
<view class='kg-flex-row timeline-content-detail'>
<view class='kg-flex-row timeline-content-detail' style='margin-right:60rpx;'>
<text class='kg-text-normal-gray'>午睡</text>
<text class='kg-text-normal-gray'>{{sleepItem.value ? sleepItem.value : '0'}}分钟</text>
</view>
......@@ -53,7 +53,7 @@
<view class='kg-separater' style='height:2rpx;margin-left:80rpx;margin-right:0rpx;'></view>
<template is='imgTextView' data="{{img:'wc',text:'大小便'}}"> </template>
</view>
<view class='kg-flex-row timeline-content-detail'>
<view class='kg-flex-row timeline-content-detail' style='margin-right:60rpx;'>
<text class='kg-text-normal-gray'>{{wcItem.z_recordType}}</text>
<text class='kg-text-normal-gray'>{{wcItem.value ? wcItem.value : '0'}}次</text>
</view>
......
......@@ -4,7 +4,7 @@
"ignore": []
},
"setting": {
"urlCheck": false,
"urlCheck": true,
"es6": true,
"postcss": true,
"minified": true,
......@@ -36,8 +36,14 @@
"list": []
},
"miniprogram": {
"current": 0,
"current": 1,
"list": [
{
"id": -1,
"name": "教师首页",
"pathName": "pages/home/teacher/index",
"query": ""
},
{
"id": -1,
"name": "教师首页",
......
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