yitisheng-mini-app/common/js/commonTool.js

69 lines
2.3 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Request from '@/common/request';
import ENV_CONFIG from '@/config/env.js';
import ApiConstant from "../ApiConstant";
let request = new Request()
export default {
//调试vip信息
checkVipInfo(e){
if (e && e.skuCode) {
e.vipFlag = true
uni.setStorageSync('vipInfo',e)
}else{
uni.setStorageSync('vipInfo',{vipFlag:false})
}
},
//刷新vip信息
reloadVipInfo() {
request.get(ApiConstant.VIP.vipInfo,{},{showLoad:false}).then(r => {
console.log(r)
if (r.success) {
this.checkVipInfo(r.result)
}
}).catch(err => {
}).finally(() => {
});
},
async loadStaticConfig(key){
return request.post('/api/static/data/getJson',{key:key},{showLoad:false}).then(r => {
console.log(r)
if (r.success) {
return r.result
}
}).catch(err => {
return {}
}).finally(() => {
});
},
async loadStaticConfigParams(key,params){
return request.post('/api/static/data/getJson',{key:key,...params},{showLoad:false}).then(r => {
console.log(r)
if (r.success) {
return r.result
}
}).catch(err => {
return {}
}).finally(() => {
});
},
//格式化处理
dateFormatYYYYMMDD(time) {
let date = new Date(time.replace(/-/g,'/'));
let year = date.getFullYear();
// 在日期格式中月份是从0开始的因此要加0使用三元表达式在小于10的前面加0以达到格式统一 如 09:11:05
let month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
let hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
let minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
let seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
// 拼接
// return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
return year + "-" + month + "-" + day;
},
getSystemName(){
return ENV_CONFIG[process.env.NAME].name
},
getPlayerType(){
return this.getSystemName()==='体育志愿宝'?'体育类':'艺术类'
},
}