提高高内聚
This commit is contained in:
parent
4682a78993
commit
88fd1bf329
@ -24,6 +24,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Common from '../../static/js/common'
|
||||
export default {
|
||||
props: {
|
||||
card_menu: {
|
||||
@ -56,7 +57,7 @@
|
||||
this.swiper.index = e.detail.current;
|
||||
},
|
||||
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 Config from '../../static/js/config'
|
||||
import Common from '../../static/js/common'
|
||||
let _now = new Date();
|
||||
let now_time = {};
|
||||
now_time.year = _now.getFullYear()
|
||||
@ -255,7 +256,7 @@ export default {
|
||||
}
|
||||
},
|
||||
gotoBack() {
|
||||
this.$Common.navigateBack("/index/index");
|
||||
Common.navigateBack("/index/index");
|
||||
},
|
||||
getImage(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 Config from '../../static/js/config'
|
||||
import Common from "../../static/js/common"
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@ -80,9 +81,9 @@ export default {
|
||||
topBar: 17, //导航高
|
||||
top: '180', //下拉栏位置
|
||||
scrollHeight: "100%", //数据展示体高度
|
||||
nowDate: this.$Common.getNowDate(), //现在日期
|
||||
endDate: this.$Common.getNowDate(), //日历可选日期范围的结束时间
|
||||
startDate: this.$Common.getPreMonth(this.$Common.getNowDate()), //日历可选日期范围的开始时间,
|
||||
nowDate: Common.getNowDate(), //现在日期
|
||||
endDate: Common.getNowDate(), //日历可选日期范围的结束时间
|
||||
startDate: Common.getPreMonth(Common.getNowDate()), //日历可选日期范围的开始时间,
|
||||
showCalendar: false,
|
||||
};
|
||||
},
|
||||
@ -99,7 +100,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
gotoBack() {
|
||||
this.$Common.navigateBack("/index/index");
|
||||
Common.navigateBack("/index/index");
|
||||
},
|
||||
changDrop(index) {
|
||||
if (index == 1 && this.$refs.companyDrop.showList) {
|
||||
@ -119,7 +120,7 @@ export default {
|
||||
this.$refs.caleDrop.selectAuto();
|
||||
this.nowDate = e.fulldate;
|
||||
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) {
|
||||
this.showDataTime = e.value;
|
||||
this.showCalendar = false;
|
||||
this.$Common.tipMsg("当前时间:" + this.showDataTime)
|
||||
Common.tipMsg("当前时间:" + this.showDataTime)
|
||||
}
|
||||
},
|
||||
changeLocation(e) {
|
||||
this.$Common.tipMsg("当前选中平台:" + e.text)
|
||||
Common.tipMsg("当前选中平台:" + e.text)
|
||||
},
|
||||
//获取设备信息
|
||||
async getTelephoneInfo() {
|
||||
var telephoneInfo = await this.$Common.getTelephoneInfo();
|
||||
var telephoneInfo = await Common.getTelephoneInfo();
|
||||
let hasHeight = 0;
|
||||
if (telephoneInfo.top >= 40) {
|
||||
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 friendTrand from '../../static/json/school/4.json';
|
||||
import Config from '../../static/js/config'
|
||||
import Common from '../../static/js/common'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@ -91,11 +92,11 @@ export default {
|
||||
}, 1000)
|
||||
},
|
||||
gotoBack() {
|
||||
this.$Common.navigateBack("/index/index");
|
||||
Common.navigateBack("/index/index");
|
||||
},
|
||||
//获取设备信息
|
||||
async getTelephoneInfo() {
|
||||
var telephoneInfo = await this.$Common.getTelephoneInfo();
|
||||
var telephoneInfo = await Common.getTelephoneInfo();
|
||||
let hasHeight = 0;
|
||||
if (telephoneInfo.top >= 40) {
|
||||
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 speedAndRateData from "../../static/json/sport/4.json"
|
||||
import Config from '../../static/js/config'
|
||||
import Common from '../../static/js/common'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@ -245,7 +246,7 @@ export default {
|
||||
return new Date(date).getTime()
|
||||
},
|
||||
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 auth from './auth'
|
||||
import modal from './modal'
|
||||
import common from './common'
|
||||
|
||||
export default {
|
||||
install(app) {
|
||||
app.config.globalProperties.$tab = tab
|
||||
app.config.globalProperties.$auth = auth
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
// 日期格式化
|
||||
/**
|
||||
*
|
||||
* 日期格式化
|
||||
* @param {*} time 时间(Date对象、时间戳、时间字符串)
|
||||
* @param {*} pattern 格式模板 默认'{y}-{m}-{d} {h}:{i}:{s}' y:年 m:月 d:日 h:时 i:分 s:秒 a:星期
|
||||
* @returns 按照模板格式的时间字符串
|
||||
@ -71,9 +69,9 @@ export function parseTime(time: string | Date | number, pattern: string) {
|
||||
/**
|
||||
* 编码请求参数
|
||||
* @param params 要编码的参数
|
||||
* @returns
|
||||
* @returns 编码后的字符串
|
||||
*/
|
||||
export function tansParams(params:any) {
|
||||
export function tansParams(params: any) {
|
||||
let result = ''
|
||||
for (const propName of Object.keys(params)) {
|
||||
const value = params[propName];
|
||||
@ -98,13 +96,13 @@ export function tansParams(params:any) {
|
||||
/**
|
||||
* 解码请求参数
|
||||
* @param str 要解码的字符串
|
||||
* @returns
|
||||
* @returns 解码后的对象
|
||||
*/
|
||||
export function untansParams(str:string){
|
||||
export function untansParams(str: string) {
|
||||
const params = {}
|
||||
const pairs = decodeURIComponent(str).split('&');
|
||||
for (const pair of pairs) {
|
||||
if(pair == '') continue
|
||||
if (pair == '') continue
|
||||
let [k, v] = pair.split('=');
|
||||
let o = undefined
|
||||
if (k.indexOf('[')) {
|
||||
@ -115,15 +113,37 @@ export function untansParams(str:string){
|
||||
k = match[2];
|
||||
}
|
||||
}
|
||||
if(o == undefined){
|
||||
if (o == undefined) {
|
||||
// @ts-ignore
|
||||
params[k] = v
|
||||
}else{
|
||||
} else {
|
||||
// @ts-ignore
|
||||
if(params[o] == undefined)params[o] = {}
|
||||
if (params[o] == undefined) params[o] = {}
|
||||
// @ts-ignore
|
||||
params[o][k] = v
|
||||
}
|
||||
}
|
||||
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": {
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames":true,
|
||||
"outFile": "dist/main.js",
|
||||
"outDir": "dist/compiled",
|
||||
"allowJs": true,
|
||||
"lib": ["es2015"],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user