第一次上传

This commit is contained in:
Ls
2026-03-09 16:39:03 +08:00
commit 3d9efaf15c
924 changed files with 326227 additions and 0 deletions

View File

@@ -0,0 +1,338 @@
import { HttpRequest, StoreAssist, UploadAssist, ResultData } from '@/common/Common';
import { BaseConfig } from './BaseConfig';
export class Service extends BaseConfig {
//获取API地址
static ApiUrl(path : string) {
return `${this.servesUrl}${path}`;
}
//获取图标地址
static GetIconImg(path : string) {
return path
console.log(path);
if (path.startsWith('http') || path.startsWith('https')) {
return path;
} else {
return `${this.payuploadUrl}${path}`;
}
}
//获取图片地址
static GetpayImg(path : string) {
if (path.startsWith('http') || path.startsWith('https')) {
return path;
} else {
return `${this.payuploadUrl}${path}`;
}
}
//获取图片地址
static GetMateUrlByImg(path : string) {
if(path=='' || path==null ){
return '/static/index/none.png'
}
if (path.startsWith('http') || path.startsWith('https')) {
return path;
} else {
return `${this.imgUrl}${path}`;
}
}
//获取音视频地址
static GetMateUrlByMedia(path : string) {
if (path.startsWith('http') || path.startsWith('https')) {
return path;
} else {
return `${this.mediaUrl}${path}`;
}
}
//获取登录账号token
static GetUserToken() {
return Service.GetStorageCache('token');
}
// 获取登录状态
static GetUserIsLogin() {
var token = this.GetUserToken();
if (token == null || token == '') {
return false;
} else {
return true;
}
}
//设置登录账户Token
static SetUserToken(token : string) {
this.SetStorageCache('token', token);
}
//清理登录账户Token
static OffUserToken() {
Service.DelStorageCache('token');
uni.$emit('ImComOff', 'user');
this.ClearUserStateData();
}
//获取登录账号状态信息
static GetUserStateData() {
return Service.GetStorageCache('StateDomain');
}
//设置当前登录账号状态信息
static SetUserStateData() {
return Service.GetStorageCache('StateDomain');
}
//清理当前登录账号状态信息
static ClearUserStateData() {
Service.DelStorageCache('StateDomain');
}
//获取缓存
static GetStorageCache(key : string) {
return StoreAssist.Get(key);
}
//删除缓存
static DelStorageCache(key : string) {
StoreAssist.Delete(key);
}
//设置缓存
static SetStorageCache(key : string, data : any) {
StoreAssist.Set(key, data);
}
/*****以下是基础方法调用与拦截器*****/
static Request(url : string, method : 'GET' | 'POST' | 'PUT' | undefined, data : object | any) {
const token = Service.GetUserToken();
const _url = Service.ApiUrl(url);
var result = HttpRequest.RequestWithToken(_url, method, token, data).then((retResult : any) => {
if (retResult.statusCode == '200') {
var obj = retResult.data;
if (obj.code == 401) {
//过期
this.OffUserToken();
this.Msg('登录过期,请重新登录')
this.GoPage('/pages/index/index')
return Promise.reject();
} else if (obj.code == 40101) {
//失效
this.OffUserToken();
this.GoPageDelse('/pages/index/index');
return Promise.reject();
} else if (obj.code == 1004) {
//资源不存在
this.GoPageDelse('/pages/AppSet/404/404');
return Promise.reject();
// return new ResultData(-1, '', '');
} else if (obj.code == 40188) {
//无权限
this.GoPageDelse('/pages/AppSet/40188/40188');
return Promise.reject();
// return new ResultData(-1, '', '');
} else if (obj.code == 1008) {
//业务提示
return new ResultData(obj.code, obj.msg, obj.data);
} else {
return new ResultData(obj.code, obj.msg, obj.data);
}
} else {
return new ResultData(-1, '', '');
}
});
return result;
}
/*****以下是腾讯云oss上传*****/
static UpLoadMedia(code : string, fileName : string, desire : string, path : string) {
var result = this.Request(this.uploadUrl, 'GET', { code, fileName, desire }).then((retResult) => {
if (retResult.code == 0) {
var upOk = UploadAssist.Upload(retResult.data.url, path, retResult.data.cosData).then((upRet : any) => {
if (upRet.statusCode == 200) {
const retData : any = { code: retResult.data.code, file: retResult.data.file, cache: retResult.data.cache };
return new ResultData(0, '上传成功!', retData);
} else {
this.Msg('上传失败!');
return new ResultData(-1, '', '');
}
});
return upOk;
} else {
this.Msg('上传失败!');
return new ResultData(-1, retResult.msg,retResult.data);
}
});
return result;
}
/***********消息操作**************/
static Msg(message : any, icon ?: any) : void {
if (icon != null) {
uni.showToast({
title: message,
icon: icon
});
} else {
uni.showToast({
title: message,
icon: 'none'
});
}
}
static Alert(msg : string, cb ?: any) {
uni.showModal({
title: '提示',
content: msg,
showCancel: false,
cancelText: '取消',
confirmText: '确定',
success: res => {
if (res.confirm) {
cb && cb();
}
}
})
}
static LoadIng(text : any) : void {
uni.showLoading({
title: text,
icon: 'none'
});
}
static LoadClose() : void {
uni.hideLoading();
}
/**********跳转操作*********/
static GoPageTab(path : string) : void {
uni.switchTab({
url: path
});
}
/**********跳转操作*********/
static GoPage(path : string) : void {
uni.navigateTo({
url: path, //跳转的页面
success: function (res) {
// 通过eventChannel向被打开页面传送数据
}
});
}
/**********跳转并删除当前页面操作*********/
static GoPageDelse(path : string) : void {
uni.redirectTo({
url: path //跳转的页面
});
}
/**********返回上一页*********/
static GoPageBack() : void {
uni.navigateBack({ delta: 1 });
}
/*****获取图片base64*****/
static UpLoadMediaBase64(path : string) {
return new Promise(function (resolve, reject) {
uni.uploadFile({
url: 'http://cloud.pccsh.com/DefUp/UploadFileImgBase64', //仅为示例,非真实的接口地址
filePath: path,
name: 'file',
success: (uploadFileRes) => {
resolve(uploadFileRes);
},
fail: (err) => {
reject(err);
}
});
});
}
/*****获取图片位置信息*****/
//获取时间戳
static GetTimeSpan(milliSecond : number) {
return Date.now() + milliSecond;
}
// 时间戳处理
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 `${hours}:${minutes}`;
} else if (type == 4) {
return `${year}${month}${day}`;
}
else {
return `${hours}:${minutes}`;
}
}
/*****节流*****/
static throttle(fn: () => void, time: number) {
let canRun: boolean = true;
return function () {
if (!canRun) return;
canRun = false;
setTimeout(() => {
fn(); //可以不执行
canRun = true;
}, time);
};
}
/*****防抖*****/
static debounce<T extends (...args: any[]) => void>(fn: T, time: number): (...args: Parameters<T>) => void {
let timerId: NodeJS.Timeout | null = null;
return (...args: Parameters<T>) => {
if (timerId) {
clearTimeout(timerId);
}
timerId = setTimeout(() => {
fn(...args); // 执行传入的函数
timerId = null; // 清除定时器ID
}, time);
};
}
// 普通图片上传
static uploadH5(path, dic, callback) {
console.log(this.payuploadUrl,'xxx')
uni.uploadFile({
url: this.payuploadUrl+'/Upload/Upload',
method: "POST",
header: {
'Authorization': 'Bearer ' + Service.GetUserToken(),
},
formData: {
"path": dic,
},
filePath: path,
name: 'file',
success: (data) => {
let info = data.data
callback(info)
}
})
}
}

View File

@@ -0,0 +1,108 @@
import { Service } from '@/Service/Service';
/*****用户*****/
class vpUserService {
private static GetUserInfoPath : string = '/User/GetUserInfo';
/*****获取用户信息*****/
static GetUserInfo() {
var result = Service.Request(this.GetUserInfoPath, 'GET', {});
return result;
}
private static GetUserAccInfoPath : string = '/User/GetUserAccInfo';
/*****获取用户账户信息*****/
static GetUserAccInfo(page : number ,code:string) {
var result = Service.Request(this.GetUserAccInfoPath, 'GET', { page , code });
return result;
}
private static UpdateUserPath : string = '/User/UpdateUser';
/*****修改用户信息*****/
static UpdateUser(headImg:string,nick:string,sex:string,phone:string) {
var result = Service.Request(this.UpdateUserPath, 'POST', { headImg,nick,sex,phone });
return result;
}
private static PayMerchPath : string = '/Order/PayMerch';
/*****支付*****/
static PayMerch(merchId:string,amount:number,payway:string,openId:string,udId:string) {
var result = Service.Request(this.PayMerchPath, 'POST', { merchId,amount,payway,openId,udId });
return result;
}
private static GetShareEwmPath : string = '/User/GetShareEwm';
/*****获取用户二维码*****/
static GetShareEwm() {
var result = Service.Request(this.GetShareEwmPath, 'GET', { });
return result;
}
private static GetAddressInfoPath : string = '/User/GetAddressInfo';
/*****根据经纬度获取地址*****/
static GetAddressInfo(lon:number,lat:number) {
var result = Service.Request(this.GetAddressInfoPath, 'GET', {lon ,lat});
return result;
}
private static CollectMerchPath : string = '/User/CollectMerch';
/*****用户收藏*****/
static CollectMerch(merchId:string) {
var result = Service.Request(this.CollectMerchPath, 'POST', {merchId});
return result;
}
private static GetUserCollectListPath : string = '/User/GetUserCollectList';
/*****用户收藏列表*****/
static GetUserCollectList(lon:Number,lat:Number,page:number) {
var result = Service.Request(this.GetUserCollectListPath, 'GET', {lon,lat,page});
return result;
}
private static GetUseRemListPath : string = '/User/GetUseRemList';
/*****用户推广列表*****/
static GetUseRemList(page:number) {
var result = Service.Request(this.GetUseRemListPath, 'GET', {page});
return result;
}
private static ExchangeCardPath : string = '/Card/ExchangeCard';
/*****绑定联盟卡*****/
static ExchangeCard(logId:string,pwd:string) {
var result = Service.Request(this.ExchangeCardPath, 'POST', {logId,pwd});
return result;
}
private static GetUserCodePath : string = '/User/GetUserCode';
/*****获取会员码*****/
static GetUserCode() {
var result = Service.Request(this.GetUserCodePath, 'GET', {});
return result;
}
private static GetNumberPhonePath : string = '/Login/GetNumberPhone';
/*****获取wx手机号*****/
static GetNumberPhone(code:string) {
var result = Service.Request(this.GetNumberPhonePath, 'GET', {code});
return result;
}
private static GetZfbPhoneNumberPath : string = '/Login/GetZfbPhoneNumber';
/*****获取zfb手机号*****/
static GetZfbPhoneNumber(content:string) {
var result = Service.Request(this.GetZfbPhoneNumberPath, 'POST', {content});
return result;
}
private static UpdateUserPhonePath : string = '/User/UpdateUserPhone';
/*****绑定用户手机号*****/
static UpdateUserPhone(phone:string) {
var result = Service.Request(this.UpdateUserPhonePath, 'POST', {phone});
return result;
}
}
export { Service, vpUserService };

View File

@@ -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) + '分钟';
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB