first commit
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
export class StringAssist {
|
||||
static NoHtml(html: string): string {
|
||||
return html;
|
||||
}
|
||||
|
||||
|
||||
static PhoneToStr (e:string) {
|
||||
return e.substring(0,3)+'****'+e.substring((e.length-2),(e.length))
|
||||
}
|
||||
// 数量过万处理
|
||||
static NumToStr (sum:number) {
|
||||
if(sum>=10000){
|
||||
return (sum/10000).toFixed('2')+'w'
|
||||
}else{
|
||||
return sum
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 帖子距离现在多久
|
||||
static DiffTimeTostring(dateTime: string): string {
|
||||
let result = 0;
|
||||
let time = Date.parse(dateTime);
|
||||
let timestamp = Date.parse(new Date().toString());
|
||||
if ((timestamp - time) / 1000 < 60) {
|
||||
result = (timestamp - time) / 1000;
|
||||
result = result < 0 ? 0 : result;
|
||||
return result.toFixed(0) + '秒前';
|
||||
} else if ((timestamp - time) / 1000 / 60 < 60) {
|
||||
return ((timestamp - time) / 1000 / 60).toFixed(0) + '分钟前';
|
||||
} else if ((timestamp - time) / 1000 / 60 / 60 < 24) {
|
||||
return ((timestamp - time) / 1000 / 60 / 60).toFixed(0) + '小时前';
|
||||
} else if ((timestamp - time) / 1000 / 60 / 60 / 24 < 31) {
|
||||
return ((timestamp - time) / 1000 / 60 / 60 / 24).toFixed(0) + '天前';
|
||||
} else {
|
||||
return this.formatDate(time, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private static formatDate(time:any,type:number):string
|
||||
{
|
||||
const date = new Date(time);
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,所以加1,并用0填充
|
||||
const day = String(date.getDate()).padStart(2, '0'); // 用0填充
|
||||
const hours = String(date.getHours()).padStart(2, '0'); // 用0填充
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0'); // 用0填充
|
||||
const seconds = String(date.getSeconds()).padStart(2, '0'); // 用0填充
|
||||
if(type==0)
|
||||
{
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
||||
}
|
||||
else if(type==1)
|
||||
{
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}`;
|
||||
}else if(type==2)
|
||||
{
|
||||
return `${year}-${month}-${day}`;
|
||||
}else if(type==3){
|
||||
return `${month}-${day} ${hours}:${minutes}`;
|
||||
}
|
||||
|
||||
else{
|
||||
return `${hours}:${minutes}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 聊天时间显示
|
||||
static ChatTimeTostring(dateTime: string,upTime:string): string {
|
||||
let time = Date.parse(dateTime);
|
||||
let timestamp = Date.parse(upTime);
|
||||
if (( time - timestamp) / 1000 / 60 < 10) {
|
||||
return '0';
|
||||
} else{
|
||||
return this.formatDate(time, 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 去除两侧的空格
|
||||
|
||||
static trim(str:string){
|
||||
const reg = /^\s+|\s+$/g;
|
||||
return str.replace(reg,'');
|
||||
}
|
||||
|
||||
// 计算两个时分秒差值
|
||||
static timesfm(dateTime: string,upTime:string){
|
||||
|
||||
let time = Date.parse('2000-01-01 '+dateTime);
|
||||
let timestamp = Date.parse('2000-01-01 '+upTime);
|
||||
return ((timestamp - time) / 1000 / 60).toFixed(0) + '分钟';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import { Service } from '@/Service/Service';
|
||||
/*****公共接口*****/
|
||||
class NvpPubService {
|
||||
private static GetIndexPath: string = '/Pub/GetIndex';
|
||||
/*****主页信息*****/
|
||||
static GetIndex() {
|
||||
var result = Service.Request(this.GetIndexPath, "GET", "");
|
||||
return result;
|
||||
}
|
||||
|
||||
private static GetIndexDataPath: string = '/Pub/GetIndexData';
|
||||
/*****获取首页数据*****/
|
||||
static GetIndexData(lon: number, lat: number, city: string, county: string, sort: number, page: number) {
|
||||
var result = Service.Request(this.GetIndexDataPath, "GET", { lon, lat, city, county, sort, page });
|
||||
return result;
|
||||
}
|
||||
|
||||
private static GetMenuDataPath: string = '/Pub/GetMenuData';
|
||||
/*****获取分类*****/
|
||||
static GetMenuData(type: string, parent: string) {
|
||||
var result = Service.Request(this.GetMenuDataPath, "GET", { type, parent });
|
||||
return result;
|
||||
}
|
||||
|
||||
private static GetMerchDataPath: string = '/Pub/GetMerchData';
|
||||
/*****获取店铺*****/
|
||||
static GetMerchData(code: string, serch: string, assId: string, lon: number, lat: number, city: string, county: string, sort: number, page: number, limit: number) {
|
||||
var result = Service.Request(this.GetMerchDataPath, "GET", { code, serch, assId, lon, lat, city, county, sort, page, limit });
|
||||
return result;
|
||||
}
|
||||
|
||||
private static GetRandomMerchPath: string = '/Pub/GetRandomMerch';
|
||||
/*****随机获取商家*****/
|
||||
static GetRandomMerch(count: number, lon: number, lat: number, city: string, county: string) {
|
||||
var result = Service.Request(this.GetRandomMerchPath, "GET", { count, lon, lat, city, county });
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
export {
|
||||
Service,
|
||||
NvpPubService
|
||||
}
|
||||
Reference in New Issue
Block a user