123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- import {
- encode
- } from '@/access/base64.js';
- /**
- * 判断是否登陆
- * returns {boolean}
- */
- export function isLogin() {
- return !!uni.getStorageSync('token')
- }
- /**
- * 判断当前系统
- */
- export function source() {
- // #ifdef H5
- const app = navigator.appVersion;
- const ua = navigator.userAgent.toLowerCase(); //获取判断用的对象
- //在微信浏览器中打开
- if (ua.match(/MicroMessenger/i) == 'micromessenger') {
- return 9
- } else {
- return 5
- }
- return 5;
- // #endif
- // #ifdef MP-WEIXIN
- return 3;
- // #endif
- // #ifdef MP-TOUTIAO
- return 8;
- // #endif
- // #ifdef APP-PLUS
- const res = uni.getSystemInfoSync();
- return res.platform === 'ios' ? 1 : 2;
- // #endif
- }
- /**
- * 获取用户信息
- */
- export function getUserInfo() {
- const session = JSON.parse(uni.getStorageSync('userInfo')) || {}
- return session
- }
- /**
- * 获取登录过期时间
- */
- export function getExpireTime() {
- const session = uni.getStorageSync('expireTime') || ''
- return session
- }
- /**
- * 获取用户登录token
- */
- export function getToken() {
- const token = uni.getStorageSync('token') || ''
- return token
- }
- // 获取微信小程序用户的图像
- export function getAvator() {
- const avator = uni.getStorageSync('avator') || ''
- return avator
- }
- // 获取微信小程序用户昵称
- export function getName() {
- const NickName = uni.getStorageSync('NickName') || ''
- return NickName
- }
- // 获取微信小程序session_key
- export function getkey() {
- const session_key = uni.getStorageSync('session_key') || ''
- return session_key
- }
- // 获取微信小程序getUnionId
- export function getUnionId() {
- const unionId = uni.getStorageSync('unionid') || ''
- return unionId
- }
- // 一键登录的手机号
- export function getphoneNumber() {
- const phoneNumber = uni.getStorageSync('phoneNumber') || ''
- return phoneNumber
- }
- /**
- * 获取企业token
- */
- export function getEnToken() {
- // return '35e97bca34dab476692d2ad8cc47954b' //dev
- // return 'b8ca10e4ce35fded735c980403dfedf7' //master
- // #ifdef MP
- // const entoken = uni.getExtConfigSync().token || ''
- return "931544405107da76ca2ec31cd63fae49"
- // return "fa4c7dee4c8c37d41204a9c1e11f3e43"
- // return entoken
- // #endif
- // #ifdef H5||APP-PLUS
- // return "fa4c7dee4c8c37d41204a9c1e11f3e43"
- return "931544405107da76ca2ec31cd63fae49"
- // #endif
- }
- // 获取openid
- export function getOpenid() {
- const openid = uni.getStorageSync('openid') || '';
- return openid;
- }
- // 获取 请求头 定位信息
- export function getLocation() {
- const location = uni.getStorageSync('locationObj') || '';
- return encode(location);
- }
|