提高高内聚

This commit is contained in:
D 2023-08-27 19:38:56 +08:00
parent 4682a78993
commit 88fd1bf329
9 changed files with 72 additions and 220 deletions

View File

@ -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);
} }
} }
} }

View File

@ -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) {

View File

@ -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;

View File

@ -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;

View File

@ -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");
}, },
}, },

View File

@ -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('暂未开放该功能!');
},
})
}
},
}

View File

@ -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
} }
} }

View File

@ -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
@ -71,7 +69,7 @@ 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 = ''
@ -98,7 +96,7 @@ export function tansParams(params:any) {
/** /**
* *
* @param str * @param str
* @returns * @returns
*/ */
export function untansParams(str: string) { export function untansParams(str: string) {
const params = {} const params = {}
@ -127,3 +125,25 @@ export function untansParams(str:string){
} }
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;
}

View File

@ -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"],