zhengkaixin 2 年之前
父节点
当前提交
4383f26d98
共有 4 个文件被更改,包括 140 次插入4 次删除
  1. 2 1
      apis/utils/init.js
  2. 130 0
      apis/utils/mixin-student.js
  3. 1 1
      apis/utils/mixin.js
  4. 7 2
      main.js

+ 2 - 1
apis/utils/init.js

@@ -1,4 +1,5 @@
-import carhelp from '@/apis/utils/mixin.js'
+import carhelp from '@/apis/utils/mixin.js'
+
 import * as API_WeiXin from '@/apis/weixin.js'
 
 import {

+ 130 - 0
apis/utils/mixin-student.js

@@ -0,0 +1,130 @@
+var prefix = 'jp-education-student-' + process.car.NODE_ENV + '_';
+
+var app = {
+	getGzDate : (key) => {
+		var tdate=new Date( ).toJSON().substr(0,10).replace("T"," ")
+		var date= uni.getStorageSync( prefix + "is_gz_date")
+		
+		if(tdate==date){
+			return false
+		}else{
+			return  true;
+		}
+		
+	},
+	
+	setGzDate : () => uni.setStorageSync(prefix + "is_gz_date", new Date( ).toJSON().substr(0,10).replace("T"," ") ),
+	
+	getGunIdCharge :()=>{
+
+		var date= uni.getStorageSync( prefix + "GunId_Date_charge")
+		var now=new Date().getTime()
+		if(date+5*60*1000>now){
+			return  uni.getStorageSync(prefix +  "GunId_Date_Show_charge")
+		}else{
+			return "";
+		}
+	},
+	
+	setGunIdCharge : ( value) => {
+		uni.setStorageSync(prefix + "GunId_Date_Show_charge", value)
+		uni.setStorageSync(prefix + "GunId_Date_charge", new Date().getTime())
+		
+	},
+	// getGunId :()=>{
+	// 	var date= uni.get( "GunId_Date")
+	// 	var now=new Date().getTime()
+	// 	if(date+5*60*1000<now){
+	// 		return  uni.get( "GunId_Date_Show")
+	// 	}else{
+	// 		return "";
+	// 	}
+	// },
+	
+	// setGunId : ( value) => {
+	// 	uni.setStorageSync(prefix + "GunId_Date_Show", value)
+	// 	uni.setStorageSync(prefix + "GunId_Date", new Date().getTime())
+		
+	// },
+	
+	getPrefix:()=> prefix,
+	get : key =>  uni.getStorageSync(prefix + key),
+
+	set : (key, value) => uni.setStorageSync(prefix + key, value),
+	remove: key =>  uni.removeStorageSync(prefix + key),
+	setConfig : (value) => uni.setStorageSync(prefix + '_config_$', value),
+	getConfig : () => {
+		var config = uni.getStorageSync(prefix + '_config_$')
+		var configure={}
+		if(config){
+			for(var  i in config){
+				var con=config[i];
+				configure[con.key]=con.value
+			}
+		}
+		 return configure;
+	},
+	
+	setConfigMessage : (value) => uni.setStorageSync(prefix + '_config_tips_$', value),
+	getConfigMessage : () => {
+		var config = uni.getStorageSync(prefix + '_config_tips_$')
+		if(!config){
+			config=[]
+		}
+		 return config;
+	},
+	
+	logoff:()=>{
+		uni.removeStorageSync(prefix + 'token_tdate')
+		uni.removeStorageSync(prefix + 'token')
+		uni.removeStorageSync(prefix  + 'personInfo');
+		uni.removeStorageSync(prefix + 'personInfoPlus');
+		uni.removeStorageSync(prefix + 'getElderModeClass');
+		//uni.removeStorageSync(prefix+'wx_openId');
+		
+	},
+	
+	getPersonInfo : () => {
+		 return uni.getStorageSync(prefix + 'personInfo')
+	},
+	getPersonInfoPlus : () => {
+		 return uni.getStorageSync(prefix + 'personInfoPlus')
+	},
+	signOut:()=>  uni.removeStorageSync(prefix  + 'personInfo'),
+	getOpenId : () =>   uni.getStorageSync(prefix + 'wx_openId'+process.car.VUE_APP_WXAPPID),
+	setOpenId : (value) => uni.setStorageSync(prefix + 'wx_openId'+process.car.VUE_APP_WXAPPID, value),
+	
+	getOpenIdALI : () =>   uni.getStorageSync(prefix + 'ali_openId'+process.car.VUE_APP_WXAPPID),
+	setOpenIdALI : (value) => uni.setStorageSync(prefix + 'ali_openId'+process.car.VUE_APP_WXAPPID, value),
+	
+	getUserInfo : () => {
+		 return uni.getStorageSync(prefix + 'xpgj_wx_user_info')
+	},
+
+	setPersonInfo : (value) => uni.setStorageSync(prefix + 'personInfo', value),
+	setPersonInfoPlus : (value) => uni.setStorageSync(prefix + 'personInfoPlus', value),
+	
+	setUserInfo : (value) => uni.setStorageSync(prefix + 'xpgj_wx_user_info', value),
+	
+	getToken : (options) => {
+		//不同权限 ,不同token
+	
+		return uni.getStorageSync(prefix + 'token')
+	},
+	setToken : (value) => {
+		uni.setStorageSync(prefix + 'token', value)
+		
+		if(value){
+			var tdate=new Date( +new Date() + 8 * 3600 * 1000 ).toJSON().substr(0,15).replace("T"," ")
+			uni.setStorageSync(prefix + 'token_tdate', tdate)
+		}
+	}
+	,
+	getGetElderModeClass : () => {
+		 return uni.getStorageSync(prefix + 'getElderModeClass')
+	},
+	setGetElderModeClass : (value) => uni.setStorageSync(prefix + 'getElderModeClass', value),
+	
+}
+
+module.exports = app

+ 1 - 1
apis/utils/mixin.js

@@ -1,4 +1,4 @@
-var prefix = 'jp-education-' + process.car.NODE_ENV + '_';
+var prefix = 'jp-education-teacher' + process.car.NODE_ENV + '_';
 
 var app = {
 	getGzDate : (key) => {

+ 7 - 2
main.js

@@ -13,8 +13,13 @@ if (IS_ALI) {
 	getOpenId.init()
 }
 
-import mixin from './apis/utils/mixin.js'
-Vue.prototype.carhelp = mixin
+import mixin from './apis/utils/mixin.js'
+import carhelpStudent from './apis/utils/mixin-student.js'
+
+
+Vue.prototype.carhelp = mixin
+Vue.prototype.carhelpStudent = carhelpStudent
+
 import Vconsole from 'vconsole'
 //import uView from "uview-ui";
 import uView from '@/uni_modules/uview-ui'