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

40 lines
1.5 KiB
JavaScript
Raw 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 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(() => {
});
},
//格式化处理
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;
},
}