提高高内聚
This commit is contained in:
parent
4682a78993
commit
88fd1bf329
@ -24,6 +24,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import Common from '../../static/js/common'
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
card_menu: {
|
card_menu: {
|
||||||
@ -56,7 +57,7 @@
|
|||||||
this.swiper.index = e.detail.current;
|
this.swiper.index = e.detail.current;
|
||||||
},
|
},
|
||||||
toUrl(url){
|
toUrl(url){
|
||||||
this.$Common.navigateTo(url);
|
Common.navigateTo(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -124,6 +124,7 @@ import dataOne from '../../static/json/finance/1.json';
|
|||||||
import expendDetail from '../../static/json/finance/2.json';
|
import expendDetail from '../../static/json/finance/2.json';
|
||||||
|
|
||||||
import Config from '../../static/js/config'
|
import Config from '../../static/js/config'
|
||||||
|
import Common from '../../static/js/common'
|
||||||
let _now = new Date();
|
let _now = new Date();
|
||||||
let now_time = {};
|
let now_time = {};
|
||||||
now_time.year = _now.getFullYear()
|
now_time.year = _now.getFullYear()
|
||||||
@ -255,7 +256,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
gotoBack() {
|
gotoBack() {
|
||||||
this.$Common.navigateBack("/index/index");
|
Common.navigateBack("/index/index");
|
||||||
},
|
},
|
||||||
getImage(index) {
|
getImage(index) {
|
||||||
switch (index) {
|
switch (index) {
|
||||||
|
|||||||
@ -58,6 +58,7 @@ import UserHealthy from "../../components/data-center/user-healthy.vue"
|
|||||||
import UserServer from "../../components/data-center/user-server.vue"
|
import UserServer from "../../components/data-center/user-server.vue"
|
||||||
|
|
||||||
import Config from '../../static/js/config'
|
import Config from '../../static/js/config'
|
||||||
|
import Common from "../../static/js/common"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -80,9 +81,9 @@ export default {
|
|||||||
topBar: 17, //导航高
|
topBar: 17, //导航高
|
||||||
top: '180', //下拉栏位置
|
top: '180', //下拉栏位置
|
||||||
scrollHeight: "100%", //数据展示体高度
|
scrollHeight: "100%", //数据展示体高度
|
||||||
nowDate: this.$Common.getNowDate(), //现在日期
|
nowDate: Common.getNowDate(), //现在日期
|
||||||
endDate: this.$Common.getNowDate(), //日历可选日期范围的结束时间
|
endDate: Common.getNowDate(), //日历可选日期范围的结束时间
|
||||||
startDate: this.$Common.getPreMonth(this.$Common.getNowDate()), //日历可选日期范围的开始时间,
|
startDate: Common.getPreMonth(Common.getNowDate()), //日历可选日期范围的开始时间,
|
||||||
showCalendar: false,
|
showCalendar: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -99,7 +100,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
gotoBack() {
|
gotoBack() {
|
||||||
this.$Common.navigateBack("/index/index");
|
Common.navigateBack("/index/index");
|
||||||
},
|
},
|
||||||
changDrop(index) {
|
changDrop(index) {
|
||||||
if (index == 1 && this.$refs.companyDrop.showList) {
|
if (index == 1 && this.$refs.companyDrop.showList) {
|
||||||
@ -119,7 +120,7 @@ export default {
|
|||||||
this.$refs.caleDrop.selectAuto();
|
this.$refs.caleDrop.selectAuto();
|
||||||
this.nowDate = e.fulldate;
|
this.nowDate = e.fulldate;
|
||||||
this.showDataTime = e.fulldate.replace(/-/g, "");
|
this.showDataTime = e.fulldate.replace(/-/g, "");
|
||||||
this.$Common.tipMsg("当前时间:" + this.showDataTime)
|
Common.tipMsg("当前时间:" + this.showDataTime)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//下拉选择时间
|
//下拉选择时间
|
||||||
@ -129,15 +130,15 @@ export default {
|
|||||||
} else if (this.showDataTime != e.value) {
|
} else if (this.showDataTime != e.value) {
|
||||||
this.showDataTime = e.value;
|
this.showDataTime = e.value;
|
||||||
this.showCalendar = false;
|
this.showCalendar = false;
|
||||||
this.$Common.tipMsg("当前时间:" + this.showDataTime)
|
Common.tipMsg("当前时间:" + this.showDataTime)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
changeLocation(e) {
|
changeLocation(e) {
|
||||||
this.$Common.tipMsg("当前选中平台:" + e.text)
|
Common.tipMsg("当前选中平台:" + e.text)
|
||||||
},
|
},
|
||||||
//获取设备信息
|
//获取设备信息
|
||||||
async getTelephoneInfo() {
|
async getTelephoneInfo() {
|
||||||
var telephoneInfo = await this.$Common.getTelephoneInfo();
|
var telephoneInfo = await Common.getTelephoneInfo();
|
||||||
let hasHeight = 0;
|
let hasHeight = 0;
|
||||||
if (telephoneInfo.top >= 40) {
|
if (telephoneInfo.top >= 40) {
|
||||||
this.top = telephoneInfo.statusBarHeight * 2 + 150;
|
this.top = telephoneInfo.statusBarHeight * 2 + 150;
|
||||||
|
|||||||
@ -55,6 +55,7 @@ import ProductRateData from '../../static/json/school/2.json';
|
|||||||
import RadarModel from '../../static/json/school/3.json';
|
import RadarModel from '../../static/json/school/3.json';
|
||||||
import friendTrand from '../../static/json/school/4.json';
|
import friendTrand from '../../static/json/school/4.json';
|
||||||
import Config from '../../static/js/config'
|
import Config from '../../static/js/config'
|
||||||
|
import Common from '../../static/js/common'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -91,11 +92,11 @@ export default {
|
|||||||
}, 1000)
|
}, 1000)
|
||||||
},
|
},
|
||||||
gotoBack() {
|
gotoBack() {
|
||||||
this.$Common.navigateBack("/index/index");
|
Common.navigateBack("/index/index");
|
||||||
},
|
},
|
||||||
//获取设备信息
|
//获取设备信息
|
||||||
async getTelephoneInfo() {
|
async getTelephoneInfo() {
|
||||||
var telephoneInfo = await this.$Common.getTelephoneInfo();
|
var telephoneInfo = await Common.getTelephoneInfo();
|
||||||
let hasHeight = 0;
|
let hasHeight = 0;
|
||||||
if (telephoneInfo.top >= 40) {
|
if (telephoneInfo.top >= 40) {
|
||||||
this.top = telephoneInfo.statusBarHeight * 2 + 150;
|
this.top = telephoneInfo.statusBarHeight * 2 + 150;
|
||||||
|
|||||||
@ -144,6 +144,7 @@ import heartRateRangeData from "../../static/json/sport/2.json"
|
|||||||
import speedRankData from "../../static/json/sport/3.json"
|
import speedRankData from "../../static/json/sport/3.json"
|
||||||
import speedAndRateData from "../../static/json/sport/4.json"
|
import speedAndRateData from "../../static/json/sport/4.json"
|
||||||
import Config from '../../static/js/config'
|
import Config from '../../static/js/config'
|
||||||
|
import Common from '../../static/js/common'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -245,7 +246,7 @@ export default {
|
|||||||
return new Date(date).getTime()
|
return new Date(date).getTime()
|
||||||
},
|
},
|
||||||
gotoBack() {
|
gotoBack() {
|
||||||
this.$Common.navigateBack("/index/index");
|
Common.navigateBack("/index/index");
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,170 +0,0 @@
|
|||||||
let isReadyLogin = 1
|
|
||||||
let loginFlag = 1
|
|
||||||
export default {
|
|
||||||
//提示窗
|
|
||||||
tipMsg: function (title, icon, time, mask,callback) {
|
|
||||||
title = title == undefined ? "系统繁忙" : title;
|
|
||||||
icon = icon == undefined ? "none" : icon;
|
|
||||||
time = time == undefined ? 1300 : time;
|
|
||||||
mask = mask == undefined ? true : mask;
|
|
||||||
uni.showToast({
|
|
||||||
title: title,
|
|
||||||
icon: icon,
|
|
||||||
mask: mask,
|
|
||||||
duration: time,
|
|
||||||
success() {
|
|
||||||
if(callback){
|
|
||||||
setTimeout(()=>{
|
|
||||||
callback()
|
|
||||||
},time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
getTelephoneInfo(){
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
var data = uni.getStorageSync("telephoneInfo");
|
|
||||||
if(!data){
|
|
||||||
// 获取右上角胶囊的位置信息
|
|
||||||
//#ifndef H5
|
|
||||||
let btn = wx.getMenuButtonBoundingClientRect();
|
|
||||||
uni.getSystemInfo({
|
|
||||||
success: e => {
|
|
||||||
let info = {
|
|
||||||
screenHeight:e.screenHeight,
|
|
||||||
statusBarHeight:e.statusBarHeight,
|
|
||||||
windowWidth:e.windowWidth,
|
|
||||||
top:btn.top
|
|
||||||
}
|
|
||||||
uni.setStorageSync("telephoneInfo",info);
|
|
||||||
resolve(info);
|
|
||||||
},
|
|
||||||
fail: (err) => {
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
//#endif
|
|
||||||
}else{
|
|
||||||
resolve(data);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
// 获取当前年月日
|
|
||||||
getNowDate(){
|
|
||||||
let date = new Date;
|
|
||||||
let now = date.getFullYear() + "-" + (date.getMonth()+1) + "-" + date.getDate();
|
|
||||||
return now;
|
|
||||||
},
|
|
||||||
// 获取上个月的年月日
|
|
||||||
getPreMonth(date) {
|
|
||||||
var arr = date.split('-');
|
|
||||||
var year = arr[0]; //获取当前日期的年份
|
|
||||||
var month = arr[1]; //获取当前日期的月份
|
|
||||||
var day = arr[2]; //获取当前日期的日
|
|
||||||
var days = new Date(year, month, 0);
|
|
||||||
days = days.getDate(); //获取当前日期中月的天数
|
|
||||||
var year2 = year;
|
|
||||||
var month2 = parseInt(month) - 1;
|
|
||||||
if (month2 == 0) {
|
|
||||||
year2 = parseInt(year2) - 1;
|
|
||||||
month2 = 12;
|
|
||||||
}
|
|
||||||
var day2 = day;
|
|
||||||
var days2 = new Date(year2, month2, 0);
|
|
||||||
days2 = days2.getDate();
|
|
||||||
if (day2 > days2) {
|
|
||||||
day2 = days2;
|
|
||||||
}
|
|
||||||
if (month2 < 10) {
|
|
||||||
month2 = '0' + month2;
|
|
||||||
}
|
|
||||||
var t2 = year2 + '-' + month2 + '-' + "01";
|
|
||||||
return t2;
|
|
||||||
},
|
|
||||||
//检测小程序更新
|
|
||||||
checkUpdateVersion(){
|
|
||||||
//新版本更新
|
|
||||||
if (uni.canIUse('getUpdateManager')) {
|
|
||||||
//判断当前微信版本是否支持版本更新
|
|
||||||
const updateManager = uni.getUpdateManager();
|
|
||||||
updateManager.onCheckForUpdate(function (res) {
|
|
||||||
if (res.hasUpdate) {
|
|
||||||
// 请求完新版本信息的回调
|
|
||||||
updateManager.onUpdateReady(function () {
|
|
||||||
uni.showModal({
|
|
||||||
title: '更新提示',
|
|
||||||
content: '已更新版本,是否重启小程序?',
|
|
||||||
showCancel:false,
|
|
||||||
cancelColor:'#eeeeee',
|
|
||||||
confirmColor:'#40A2ED',
|
|
||||||
success: function (res) {
|
|
||||||
if (res.confirm) {
|
|
||||||
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|
||||||
updateManager.applyUpdate();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
// 新的版本下载失败
|
|
||||||
updateManager.onUpdateFailed(function () {
|
|
||||||
uni.showModal({
|
|
||||||
title: '更新失败',
|
|
||||||
content: '请检查网络设置,若仍更新失败,重新搜索打开',
|
|
||||||
success(res) {
|
|
||||||
if (res.confirm) {
|
|
||||||
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|
||||||
updateManager.applyUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
uni.showModal({
|
|
||||||
// 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
|
|
||||||
title: '提示',
|
|
||||||
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* @param {string} url 目标页面的路由
|
|
||||||
* @param {Object} param 传递给目标页面的参数
|
|
||||||
* @description 处理目标页面的参数,转成json字符串传递给param字段,在目标页面通过JSON.parse(options.param)接收
|
|
||||||
*/
|
|
||||||
navigateTo(url, param = {},flag) {
|
|
||||||
if(isReadyLogin<=0 && !flag){
|
|
||||||
this.loginTip();
|
|
||||||
}else{
|
|
||||||
let part = '';
|
|
||||||
for(var item in param){
|
|
||||||
part += '&' + item + '=' + param[item];
|
|
||||||
}
|
|
||||||
url = url + part.replace('&','?');
|
|
||||||
uni.navigateTo({
|
|
||||||
url: url,
|
|
||||||
fail:err=> {
|
|
||||||
this.tipMsg('页面正在火速开发中,敬请期待!');
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
navigateBack(url, param = {}) {
|
|
||||||
if (loginFlag <= 0) {
|
|
||||||
this.tipMsg("很抱歉,你没有权限!");
|
|
||||||
} else {
|
|
||||||
let part = '';
|
|
||||||
for (var item in param) {
|
|
||||||
part += '&' + item + '=' + param[item];
|
|
||||||
}
|
|
||||||
url = "/pages" + url + part.replace('&', '?');
|
|
||||||
uni.navigateBack({
|
|
||||||
url: url,
|
|
||||||
fail: err => {
|
|
||||||
this.tipMsg('暂未开放该功能!');
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@ -1,13 +1,11 @@
|
|||||||
import tab from './tab'
|
import tab from './tab'
|
||||||
import auth from './auth'
|
import auth from './auth'
|
||||||
import modal from './modal'
|
import modal from './modal'
|
||||||
import common from './common'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
install(app) {
|
install(app) {
|
||||||
app.config.globalProperties.$tab = tab
|
app.config.globalProperties.$tab = tab
|
||||||
app.config.globalProperties.$auth = auth
|
app.config.globalProperties.$auth = auth
|
||||||
app.config.globalProperties.$modal = modal
|
app.config.globalProperties.$modal = modal
|
||||||
app.config.globalProperties.$Common = common
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,10 +18,8 @@ export function wildcardCompare(str: string, pattern: string): boolean {
|
|||||||
return regexPattern.test(str);
|
return regexPattern.test(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 日期格式化
|
|
||||||
/**
|
/**
|
||||||
*
|
* 日期格式化
|
||||||
* @param {*} time 时间(Date对象、时间戳、时间字符串)
|
* @param {*} time 时间(Date对象、时间戳、时间字符串)
|
||||||
* @param {*} pattern 格式模板 默认'{y}-{m}-{d} {h}:{i}:{s}' y:年 m:月 d:日 h:时 i:分 s:秒 a:星期
|
* @param {*} pattern 格式模板 默认'{y}-{m}-{d} {h}:{i}:{s}' y:年 m:月 d:日 h:时 i:分 s:秒 a:星期
|
||||||
* @returns 按照模板格式的时间字符串
|
* @returns 按照模板格式的时间字符串
|
||||||
@ -57,11 +55,11 @@ export function parseTime(time: string | Date | number, pattern: string) {
|
|||||||
}
|
}
|
||||||
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result: any, key: keyof typeof formatObj) => {
|
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result: any, key: keyof typeof formatObj) => {
|
||||||
let value = formatObj[key]
|
let value = formatObj[key]
|
||||||
if (key === 'a') {
|
if (key === 'a') {
|
||||||
return ['日', '一', '二', '三', '四', '五', '六'][value]
|
return ['日', '一', '二', '三', '四', '五', '六'][value]
|
||||||
}
|
}
|
||||||
if (result.length > 0 && value < 10) {
|
if (result.length > 0 && value < 10) {
|
||||||
return '0' + value
|
return '0' + value
|
||||||
}
|
}
|
||||||
return String(value || 0)
|
return String(value || 0)
|
||||||
})
|
})
|
||||||
@ -71,40 +69,40 @@ export function parseTime(time: string | Date | number, pattern: string) {
|
|||||||
/**
|
/**
|
||||||
* 编码请求参数
|
* 编码请求参数
|
||||||
* @param params 要编码的参数
|
* @param params 要编码的参数
|
||||||
* @returns
|
* @returns 编码后的字符串
|
||||||
*/
|
*/
|
||||||
export function tansParams(params:any) {
|
export function tansParams(params: any) {
|
||||||
let result = ''
|
let result = ''
|
||||||
for (const propName of Object.keys(params)) {
|
for (const propName of Object.keys(params)) {
|
||||||
const value = params[propName];
|
const value = params[propName];
|
||||||
var part = encodeURIComponent(propName) + "=";
|
var part = encodeURIComponent(propName) + "=";
|
||||||
if (value !== null && typeof (value) !== "undefined") {
|
if (value !== null && typeof (value) !== "undefined") {
|
||||||
if (typeof value === 'object') {
|
if (typeof value === 'object') {
|
||||||
for (const key of Object.keys(value)) {
|
for (const key of Object.keys(value)) {
|
||||||
if (value[key] !== null && typeof (value[key]) !== 'undefined') {
|
if (value[key] !== null && typeof (value[key]) !== 'undefined') {
|
||||||
let params = propName + '[' + key + ']';
|
let params = propName + '[' + key + ']';
|
||||||
var subPart = encodeURIComponent(params) + "=";
|
var subPart = encodeURIComponent(params) + "=";
|
||||||
result += subPart + encodeURIComponent(value[key]) + "&";
|
result += subPart + encodeURIComponent(value[key]) + "&";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result += part + encodeURIComponent(value) + "&";
|
result += part + encodeURIComponent(value) + "&";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解码请求参数
|
* 解码请求参数
|
||||||
* @param str 要解码的字符串
|
* @param str 要解码的字符串
|
||||||
* @returns
|
* @returns 解码后的对象
|
||||||
*/
|
*/
|
||||||
export function untansParams(str:string){
|
export function untansParams(str: string) {
|
||||||
const params = {}
|
const params = {}
|
||||||
const pairs = decodeURIComponent(str).split('&');
|
const pairs = decodeURIComponent(str).split('&');
|
||||||
for (const pair of pairs) {
|
for (const pair of pairs) {
|
||||||
if(pair == '') continue
|
if (pair == '') continue
|
||||||
let [k, v] = pair.split('=');
|
let [k, v] = pair.split('=');
|
||||||
let o = undefined
|
let o = undefined
|
||||||
if (k.indexOf('[')) {
|
if (k.indexOf('[')) {
|
||||||
@ -115,15 +113,37 @@ export function untansParams(str:string){
|
|||||||
k = match[2];
|
k = match[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(o == undefined){
|
if (o == undefined) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
params[k] = v
|
params[k] = v
|
||||||
}else{
|
} else {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if(params[o] == undefined)params[o] = {}
|
if (params[o] == undefined) params[o] = {}
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
params[o][k] = v
|
params[o][k] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return params
|
return params
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 深度复制
|
||||||
|
* @param obj 待复制的对象
|
||||||
|
* @returns 复制的对象
|
||||||
|
*/
|
||||||
|
export function deepClone(obj: any) {
|
||||||
|
if (obj == null || typeof obj !== 'object') {
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
let result;
|
||||||
|
if (Array.isArray(obj)) {
|
||||||
|
result = [];
|
||||||
|
} else {
|
||||||
|
result = new Map();
|
||||||
|
}
|
||||||
|
for (let [key, value] of Object.entries(obj)) {
|
||||||
|
// @ts-ignore
|
||||||
|
result[key] = deepClone(value);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
@ -2,7 +2,6 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"forceConsistentCasingInFileNames":true,
|
"forceConsistentCasingInFileNames":true,
|
||||||
"outFile": "dist/main.js",
|
|
||||||
"outDir": "dist/compiled",
|
"outDir": "dist/compiled",
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"lib": ["es2015"],
|
"lib": ["es2015"],
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user