购物车逻辑完善

个人信息存储优化
团购支付
This commit is contained in:
2024-03-31 17:22:14 +08:00
parent 1fc0aa432b
commit b502385272
19 changed files with 859 additions and 141 deletions

View File

@@ -41,3 +41,41 @@ export function goPath(path: string) {
}).then(r => {
});
}
export function formatTimeWithZeroPad(num: number): string {
return num < 10 ? '0' + num : num + '';
}
export function sortASCII(obj: any, isSort = true) {
let arr: any[] = [];
Object.keys(obj).forEach(item => arr.push(item));
let sortArr = isSort ? arr.sort() : arr.sort().reverse();
let sortObj: any = {};
for (let i in sortArr) {
sortObj[sortArr[i]] = obj[sortArr[i]];
}
return sortObj;
}
Array.prototype.contains = function(obj: any) {
let i = this.length;
while (i--) {
if(this[i] === obj) {
return true;
}
}
return false;
};
export function parseParameter(obj: any) {
if(obj === null || obj === undefined) return '';
const arr = [];
const keys: string[] = Object.keys(obj);
const entries: any[] = Object.entries(obj);
for (const [key, value] of entries) {
if(keys.contains(key) && !key.startsWith('function')) {
arr.push(key + '=' + value);
}
}
return arr.join('&');
}