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

增加对登录状态的判断

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