first commit
This commit is contained in:
1
滴滴淘/h5(1)/src/core/.pydio
Normal file
1
滴滴淘/h5(1)/src/core/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
fa1cac3b-74e7-40ce-92f2-991ec64862dd
|
||||
7
滴滴淘/h5(1)/src/core/class-component-hooks.ts
Normal file
7
滴滴淘/h5(1)/src/core/class-component-hooks.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import Component from 'vue-class-component';
|
||||
|
||||
Component.registerHooks([
|
||||
'beforeRouteEnter',
|
||||
'beforeRouteLeave',
|
||||
'beforeRouteUpdate'
|
||||
])
|
||||
1
滴滴淘/h5(1)/src/core/config/.pydio
Normal file
1
滴滴淘/h5(1)/src/core/config/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
7c4a4e64-72aa-49d8-ab93-234dd6ba1b4a
|
||||
277
滴滴淘/h5(1)/src/core/config/index.ts
Normal file
277
滴滴淘/h5(1)/src/core/config/index.ts
Normal file
@@ -0,0 +1,277 @@
|
||||
import VueRouter from 'vue-router';
|
||||
|
||||
// vue 插件配置
|
||||
import 'amfe-flexible/index.js';
|
||||
import Vant from 'vant';
|
||||
import 'vant/lib/index.css';
|
||||
|
||||
// 自定义的非vue插件
|
||||
import Service from "../service/imports";
|
||||
import {Utils} from '../utils';
|
||||
|
||||
// 消息提示文字js
|
||||
// const Message = window.Message
|
||||
|
||||
export class config {
|
||||
/**
|
||||
* 接口配置,测试环境,正式环境,具体接口
|
||||
*/
|
||||
public static AjaxConfig: any = {
|
||||
DevUrl: 'http://new.gddh999.com/',
|
||||
ProdUrl: 'http://api.alkid888.com/',
|
||||
WsDevUrl: 'ws://118.25.189.247:2345',
|
||||
WsProdUrl: 'ws://ws.alkid888.com:2345',
|
||||
ApiList: {
|
||||
reg: '/index/reg/index', //注册买家
|
||||
login: '/index/login/index', //登录买家
|
||||
captcha: '/api/Sms/captcha', //注册验证码
|
||||
getvantcity: '/api/address/getvantcity', //省市区地址接口
|
||||
accountlist: '/index/index/accountAndAddressInfo', //买号列表
|
||||
accountTagInfo: '/index/buyer_accounts/accountTagInfo', //添加买号标签
|
||||
saveaccount: '/index/buyer_accounts/saveaccount', //买号添加
|
||||
modifyAccount: '/index/buyer_accounts/modifyAccount', //审核未通过修改买号
|
||||
uploadImg: '/index/api/upload', //买家图片上传
|
||||
referMoney: '/index/index/referMoney', //我的页面推广的资金
|
||||
financeInfo: '/index/index/financeInfo', //我的页面账户余额
|
||||
memberInfo: '/index/index/memberInfo', //我的页面用户信息
|
||||
saveAccountAddress: '/index/buyer_accounts/saveAccountAddress', //账号地址修改
|
||||
accountListByPlatform: '/index/buyer_accounts/accountInfoById', //查询买号详情
|
||||
cashout: '/index/finance/cashout', // 提现操作
|
||||
saveidcard: '/index/authentication/saveidcard', //实名认证添加修改
|
||||
banklist: '/index/authentication/banklist', //銀行列表
|
||||
idCardBankInfo: '/index/authentication/idCardBankInfo', //实名认证信息渲染
|
||||
getTaskAccount: '/index/Task/getTaskAccount', // 获取接单账号列表
|
||||
getTaskList: '/index/task/tasklist', //任务列表
|
||||
orderTask: 'index/Task/orderTask',
|
||||
commitTask: 'index/Task/commitTask',
|
||||
announceInfoById: 'index/index/announceInfoById', //公告详细内容
|
||||
announceList: 'index/index/announceList', //公告列表,
|
||||
messageList: 'index/message/messageList', // 消息列表
|
||||
taskDetail: '/index/Task/taskDetail', //任务详情
|
||||
setComparePrice: '/index/Task/setComparePrice', //确认货比信息
|
||||
verifyShop: '/index/Task/verifyShop', //验证店铺
|
||||
purchaseDone: '/index/Task/purchaseDone', //选购完成
|
||||
buyerOrder: '/index/Task/buyerOrder', //买家下单/付款
|
||||
confirmAccept: '/index/Task/confirmAccept', //买家确认收货
|
||||
financelist: '/index/finance/financelist', //资金列表
|
||||
commissionList: '/index/finance/commissionList', //佣金列表
|
||||
cashlist: '/index/cash_out/cashlist', //提现列表
|
||||
getMemberInfo: '/index/member/getMemberInfo', //获取用户信息
|
||||
forget: '/index/login/forget',
|
||||
referinfo: '/index/refer/referinfo', //推广信息
|
||||
index: '/index/index/index', //首页基础信息
|
||||
cancelTask: '/index/Task/cancelTask', //取消任务
|
||||
nextStep: '/index/Task/nextStep', //任务进入下一步
|
||||
setTaskTag: '/index/Task/setTaskTag', //任务打标
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* 需要控制未登录跳转的路由
|
||||
*/
|
||||
public static isRouter: Array<string> = ['/']
|
||||
|
||||
/**
|
||||
* 浏览器本地缓存的前缀
|
||||
*/
|
||||
public static prefix: string = 'h5_'
|
||||
|
||||
/**
|
||||
* 需要被挂载的节点
|
||||
*/
|
||||
public static mountElement: string = '#app';
|
||||
|
||||
/**
|
||||
* 非Vue插件
|
||||
*/
|
||||
public static NotVuePlugs: Array<Object> = [
|
||||
{n: '$http', f: Service},
|
||||
{n: '$utils', f: Utils},
|
||||
{n: '$config', f: config}
|
||||
];
|
||||
|
||||
/**
|
||||
* Vue插件
|
||||
*/
|
||||
public static VuePlugs: Array<any> = [VueRouter, Vant];
|
||||
|
||||
/**
|
||||
* Vue-router 配置
|
||||
*/
|
||||
public static RouterConfigUrl: Object = {
|
||||
routes: [
|
||||
{
|
||||
path: '/',
|
||||
name: 'index',
|
||||
component: Utils.AsyncComponentHook("subject/subject"),
|
||||
redirect: {
|
||||
name: 'home'
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'home',
|
||||
name: 'home',
|
||||
component: Utils.AsyncComponentHook("subject/index"),
|
||||
meta: {
|
||||
title: '首页',
|
||||
alive: false
|
||||
}
|
||||
},{
|
||||
path: 'task',
|
||||
name: 'task',
|
||||
component: Utils.AsyncComponentHook("subject/Task"),
|
||||
meta: {
|
||||
title: '任务',
|
||||
alive: false
|
||||
}
|
||||
},{
|
||||
path: 'news',
|
||||
name: 'news',
|
||||
component: Utils.AsyncComponentHook("subject/News"),
|
||||
meta: {
|
||||
title: '消息',
|
||||
alive: false
|
||||
}
|
||||
},{
|
||||
path: 'my',
|
||||
name: 'my',
|
||||
component: Utils.AsyncComponentHook("subject/My"),
|
||||
meta: {
|
||||
title: '我的',
|
||||
alive: false
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/taskInfo',
|
||||
name: 'taskinfo',
|
||||
component: Utils.AsyncComponentHook("TaskInfo"),
|
||||
meta: {
|
||||
title: '任务详情'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/taskHall',
|
||||
name: 'taskhall',
|
||||
component: Utils.AsyncComponentHook("TaskHall"),
|
||||
meta: {
|
||||
title: '任务大厅'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
name: '登录',
|
||||
component: Utils.AsyncComponentHook("Login"),
|
||||
meta: {
|
||||
title: '登录'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/register',
|
||||
name: 'register',
|
||||
component: Utils.AsyncComponentHook("Register"),
|
||||
meta: {
|
||||
title: '注册'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/fund',
|
||||
name: 'fund',
|
||||
component: Utils.AsyncComponentHook("Fund"),
|
||||
meta: {
|
||||
title: '资金管理'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/collection',
|
||||
name: 'collection',
|
||||
component: Utils.AsyncComponentHook("CollectionRecords"),
|
||||
meta: {
|
||||
title: '佣金记录'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/feedback',
|
||||
name: 'feedback',
|
||||
component: Utils.AsyncComponentHook("Feedback"),
|
||||
meta: {
|
||||
title: '意见反馈'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/extension',
|
||||
name: 'extension',
|
||||
component: Utils.AsyncComponentHook("Extension"),
|
||||
meta: {
|
||||
title: '推广赚钱'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/addAccount',
|
||||
name: 'addAccount',
|
||||
component: Utils.AsyncComponentHook("AddAccount"),
|
||||
meta: {
|
||||
title: '添加买号'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/authentication',
|
||||
name: 'authentication',
|
||||
component: Utils.AsyncComponentHook("Authentication"),
|
||||
meta: {
|
||||
title: '买号认证'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/modifyAddress',
|
||||
name: 'modifyAddress',
|
||||
component: Utils.AsyncComponentHook("ModifyAddress"),
|
||||
meta: {
|
||||
title: '修改地址'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/realName',
|
||||
name: 'realName',
|
||||
component: Utils.AsyncComponentHook("RealName"),
|
||||
meta: {
|
||||
title: '实名认证'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/forget',
|
||||
name: 'forget',
|
||||
component: Utils.AsyncComponentHook("Forget"),
|
||||
meta: {
|
||||
title: '修改密码'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/cashwithdrawal',
|
||||
name: 'cashwithdrawal',
|
||||
component: Utils.AsyncComponentHook("Cashwithdrawal"),
|
||||
meta: {
|
||||
title: '提现记录'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/principalRecord',
|
||||
name: 'principalRecord',
|
||||
component: Utils.AsyncComponentHook("PrincipalRecord"),
|
||||
meta: {
|
||||
title: '本金记录'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/noticeInfo',
|
||||
name: 'noticeInfo',
|
||||
component: Utils.AsyncComponentHook("NoticeInfo"),
|
||||
meta: {
|
||||
title: '公告详细内容'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
1
滴滴淘/h5(1)/src/core/dao/.pydio
Normal file
1
滴滴淘/h5(1)/src/core/dao/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
0c33df44-42a1-4d79-9e5f-cb1363eaaf83
|
||||
152
滴滴淘/h5(1)/src/core/dao/index.ts
Normal file
152
滴滴淘/h5(1)/src/core/dao/index.ts
Normal file
@@ -0,0 +1,152 @@
|
||||
import {Utils} from '../utils';
|
||||
import axios, {AxiosInstance} from 'axios';
|
||||
import {Dialog, Toast} from 'vant';
|
||||
|
||||
export class Axios {
|
||||
private instance: AxiosInstance;
|
||||
private Utils: Utils = new Utils()
|
||||
|
||||
// @ts-ignore
|
||||
public async constructor() {
|
||||
this.instance = axios.create({
|
||||
baseURL: Utils.CheckAjaxUrl(),
|
||||
timeout: 3000
|
||||
});
|
||||
this.ResponseInterceptor();
|
||||
this.RequestInterceptor();
|
||||
console.log(Utils.CheckAjaxUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 请求
|
||||
* 请求参数请参考接口:RequestParams
|
||||
* @param params
|
||||
*/
|
||||
public async get(params: { url: string, data: Object }): Promise<Object> {
|
||||
try {
|
||||
return await this.instance.get(params.url, {params: params.data})
|
||||
} catch (e) {
|
||||
return e.message
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Post 请求
|
||||
* 请求参数请参考接口:RequestParams
|
||||
* @param params
|
||||
*/
|
||||
public async post(params: { url: string, data: Object, header?: Object }): Promise<Object> {
|
||||
try {
|
||||
return await this.instance.post(params.url, params.data, {
|
||||
headers: Object.assign({}, params.header)
|
||||
})
|
||||
} catch (e) {
|
||||
return e.message
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Put 请求
|
||||
* 请求参数请参考接口:RequestParams
|
||||
* @param params
|
||||
*/
|
||||
public async put(params: { url: string, data: Object }): Promise<Object> {
|
||||
try {
|
||||
return await this.instance.put(params.url, params.data)
|
||||
} catch (e) {
|
||||
return e.message
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* delete 请求
|
||||
* 请求参数请参考接口:RequestParams
|
||||
* @param params
|
||||
*/
|
||||
public async delete(params: { url: string, data: Object }): Promise<Object> {
|
||||
try {
|
||||
return await this.instance.delete(params.url, {params: params.data})
|
||||
} catch (e) {
|
||||
return e.message
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加响应拦截器
|
||||
* @constructor
|
||||
*/
|
||||
public async ResponseInterceptor(): Promise<any> {
|
||||
this.instance.interceptors.response.use( async response => {
|
||||
this.CloseLoadingData();
|
||||
switch (response.data.code) {
|
||||
case 0:
|
||||
switch (response.data.status) {
|
||||
case 1:
|
||||
if(response.data.data !== null && response.data.data !== void 0){
|
||||
return response.data.data;
|
||||
}else{
|
||||
Toast(response.data.msg)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
await Dialog.alert({
|
||||
message: `[${response.data.status}]${response.data.msg}`
|
||||
})
|
||||
return -1
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1001:
|
||||
Dialog.alert({
|
||||
message: response.data.msg
|
||||
}).then(() => {
|
||||
this.Utils.delStorage('access_token')
|
||||
window.location.href = `${window.location.origin}${window.location.pathname}#/login`
|
||||
});
|
||||
break;
|
||||
default:
|
||||
alert(`[${response.data.code}]${response.data.msg}`)
|
||||
break;
|
||||
}
|
||||
}, function (error) {
|
||||
return Promise.reject(error)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加请求拦截器
|
||||
* @constructor
|
||||
*/
|
||||
public async RequestInterceptor(): Promise<any> {
|
||||
this.instance.interceptors.request.use(config => {
|
||||
// 添加token
|
||||
Object.assign(config.headers,{
|
||||
'authorization': this.Utils.getToken()
|
||||
})
|
||||
this.OpenLoadingData();
|
||||
return config
|
||||
}, function (error) {
|
||||
return Promise.reject(error)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示加载进度
|
||||
* @constructor
|
||||
*/
|
||||
private OpenLoadingData(): void {
|
||||
Toast.loading({
|
||||
message: '加载中...',
|
||||
forbidClick: true,
|
||||
loadingType: 'circular'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除加载进度条
|
||||
*/
|
||||
private CloseLoadingData(): void {
|
||||
Toast.clear();
|
||||
}
|
||||
|
||||
}
|
||||
1
滴滴淘/h5(1)/src/core/run/.pydio
Normal file
1
滴滴淘/h5(1)/src/core/run/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
32b784bd-1a75-43f8-9b0b-565c56d600fc
|
||||
60
滴滴淘/h5(1)/src/core/run/init.ts
Normal file
60
滴滴淘/h5(1)/src/core/run/init.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import Vue, {VueConstructor} from 'vue';
|
||||
import App from '@/App.vue';
|
||||
import VueRouter from 'vue-router';
|
||||
import '../class-component-hooks';
|
||||
import {config} from '../config'
|
||||
|
||||
/**
|
||||
* 初始化Vue需要的插件和构造Vue启动参数
|
||||
*/
|
||||
export class init {
|
||||
private initVuePlugsArray: Array<any> = config.VuePlugs;
|
||||
private initOtherPlugsArray: Array<Object> = config.NotVuePlugs;
|
||||
protected router: any;
|
||||
protected Vues: any = Vue;
|
||||
public static App: VueConstructor = App;
|
||||
|
||||
|
||||
constructor() {
|
||||
this.Vues.config.productionTip = false;
|
||||
this.initPlugs();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化Vue和非Vue插件
|
||||
*/
|
||||
private initPlugs(): void {
|
||||
// @ts-ignore
|
||||
this.initOtherPlugsArray.forEach(v => this.Vues.prototype[v['n']] = new (v['f'])());
|
||||
this.initVuePlugsArray.forEach(v => this.Vues.use(v));
|
||||
this.InitVueRouter();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化配置全局路由
|
||||
* @constructor
|
||||
*/
|
||||
private InitVueRouter(): void {
|
||||
this.router = new VueRouter(config.RouterConfigUrl);
|
||||
// 重写路由Push
|
||||
const routerPush = VueRouter.prototype.push
|
||||
VueRouter.prototype.push = function push(location: any): any {
|
||||
// @ts-ignore
|
||||
return routerPush.call(this, location).catch((error: any) => error)
|
||||
}
|
||||
|
||||
this.router.beforeEach((to: any, from: any, next: any) => {
|
||||
if (to.meta.title) {
|
||||
document.title = to.meta.title;
|
||||
}
|
||||
// 如果用户未登录跳转至登录页
|
||||
if(!localStorage.getItem(`${config.prefix}access_token`) && config.isRouter.indexOf(to.path) !== -1){
|
||||
next('/login')
|
||||
}else{
|
||||
next();
|
||||
}
|
||||
// next();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
20
滴滴淘/h5(1)/src/core/run/run.ts
Normal file
20
滴滴淘/h5(1)/src/core/run/run.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import {init} from './init';
|
||||
import {config} from '../config';
|
||||
import store from '../store/index'
|
||||
|
||||
/**
|
||||
* Vue项目的启动文件
|
||||
*/
|
||||
class Run extends init {
|
||||
|
||||
public initApp(): void {
|
||||
const router = this.router;
|
||||
new this.Vues({
|
||||
router,
|
||||
store,
|
||||
render: (h: (arg0: any) => void): any => h(init.App)
|
||||
}).$mount(config.mountElement);
|
||||
}
|
||||
}
|
||||
|
||||
(new Run()).initApp();
|
||||
1
滴滴淘/h5(1)/src/core/service/.pydio
Normal file
1
滴滴淘/h5(1)/src/core/service/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
e44ecb30-2f2c-4ec3-b47e-63ecc51c9842
|
||||
14
滴滴淘/h5(1)/src/core/service/HomeService.ts
Normal file
14
滴滴淘/h5(1)/src/core/service/HomeService.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import * as ServeTypes from '../types/ServeTypes'
|
||||
|
||||
export interface HomeService {
|
||||
register(data: ServeTypes.registerType): Promise<Object[]>;
|
||||
login(data: ServeTypes.registerType): Promise<Object[]>;
|
||||
captcha(cellphone: string): Promise<Object[]>;
|
||||
saveaccount(data: ServeTypes.buyNumber): Promise<Object[]>;
|
||||
accountTagInfo(type: number): Promise<Object[]>;
|
||||
referMoney(): Promise<Object[]>;
|
||||
financeInfo(): Promise<Object[]>;
|
||||
memberInfo(): Promise<Object[]>;
|
||||
forget(data: ServeTypes.forget): Promise<Object[]>;
|
||||
getIndex(): Promise<Object[]>
|
||||
}
|
||||
5
滴滴淘/h5(1)/src/core/service/NewsService.ts
Normal file
5
滴滴淘/h5(1)/src/core/service/NewsService.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export interface NewsService {
|
||||
announceList(data: object): Promise<any>;
|
||||
announceInfoById(data: object): Promise<any>;
|
||||
messageList(data: object): Promise<any>;
|
||||
}
|
||||
7
滴滴淘/h5(1)/src/core/service/PublicService.ts
Normal file
7
滴滴淘/h5(1)/src/core/service/PublicService.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import * as ServeTypes from '../types/ServeTypes'
|
||||
|
||||
export interface PublicService {
|
||||
getvantcity(): Promise<Object[]>
|
||||
uploadImg(data: ServeTypes.imageType): Promise<Object[]>
|
||||
banklist(): Promise<Object[]>
|
||||
}
|
||||
17
滴滴淘/h5(1)/src/core/service/TaskService.ts
Normal file
17
滴滴淘/h5(1)/src/core/service/TaskService.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import * as ServeTypes from '../types/ServeTypes'
|
||||
|
||||
export interface TaskService {
|
||||
getTaskAccount(data: { platform_id: string }): Promise<any>;
|
||||
getTaskList(data: object): Promise<any>;
|
||||
orderTask(data: object): Promise<any>;
|
||||
commitTask(data: object): Promise<any>;
|
||||
taskDetail(id: string): Promise<any>;
|
||||
setComparePrice(data: ServeTypes.setComparePriceType): Promise<any>;
|
||||
verifyShop(data: ServeTypes.verifyShopType): Promise<any>;
|
||||
purchaseDone(data: ServeTypes.purchaseDoneType): Promise<any>;
|
||||
buyerOrder(data: ServeTypes.buyerOrderType): Promise<any>;
|
||||
confirmAccept(id: string): Promise<any>;
|
||||
cancelTask(id: string): Promise<any>;
|
||||
nextStep(id: string): Promise<any>;
|
||||
setTaskTag(data: ServeTypes.TaskTagType): Promise<any>;
|
||||
}
|
||||
16
滴滴淘/h5(1)/src/core/service/UserService.ts
Normal file
16
滴滴淘/h5(1)/src/core/service/UserService.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import * as ServeTypes from '../types/ServeTypes'
|
||||
|
||||
export interface UserService {
|
||||
getAccountlist(): Promise<Object[]>
|
||||
saveAccountAddress(data: ServeTypes.saveAddress): Promise<Object[]>
|
||||
accountListByPlatform(id: string): Promise<Object[]>
|
||||
modifyAccount(data: ServeTypes.buyNumber): Promise<Object[]>
|
||||
cashout(type: number): Promise<Object[]>
|
||||
saveidcard(data: ServeTypes.realNameType): Promise<Object[]>
|
||||
idCardBankInfo(): Promise<Object[]>
|
||||
financelist(data: ServeTypes.paging): Promise<Object[]>
|
||||
commissionList(data: ServeTypes.paging): Promise<Object[]>
|
||||
cashlist(data: ServeTypes.paging): Promise<Object[]>
|
||||
getMemberInfo(): Promise<Object[]>
|
||||
referinfo(data: ServeTypes.paging): Promise<Object[]>
|
||||
}
|
||||
1
滴滴淘/h5(1)/src/core/service/impl/.pydio
Normal file
1
滴滴淘/h5(1)/src/core/service/impl/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
aa3cef1a-23ef-4f83-8be1-790da8f42bfe
|
||||
91
滴滴淘/h5(1)/src/core/service/impl/HomeServiceImpl.ts
Normal file
91
滴滴淘/h5(1)/src/core/service/impl/HomeServiceImpl.ts
Normal file
@@ -0,0 +1,91 @@
|
||||
import {HomeService} from "../HomeService"
|
||||
import {Axios} from "../../dao";
|
||||
import {config} from "../../config";
|
||||
import * as ServeTypes from '../../types/ServeTypes'
|
||||
|
||||
export class HomeServiceImpl extends Axios implements HomeService {
|
||||
|
||||
// 买家注册接口
|
||||
public async register(data: ServeTypes.registerType): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.reg,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// 买家登录接口
|
||||
public async login(data: ServeTypes.registerType): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.login,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// 注册的时候验证码
|
||||
public async captcha(cellphone: string): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.captcha,
|
||||
data: {
|
||||
'cellphone': cellphone,
|
||||
'template_id': '1'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 添加买号
|
||||
public async saveaccount(data: ServeTypes.buyNumber): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.saveaccount,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// 添加买号标签
|
||||
public async accountTagInfo(type: number): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.accountTagInfo,
|
||||
data: {
|
||||
platform: type
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 我的页面推广的资金
|
||||
public async referMoney(): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.referMoney,
|
||||
data: {}
|
||||
});
|
||||
}
|
||||
|
||||
// 我的页面账户余额
|
||||
public async financeInfo(): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.financeInfo,
|
||||
data: {}
|
||||
});
|
||||
}
|
||||
|
||||
// 我的页面个人信息
|
||||
public async memberInfo(): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.memberInfo,
|
||||
data: {}
|
||||
});
|
||||
}
|
||||
|
||||
// 忘记密码
|
||||
public async forget(data: ServeTypes.forget): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.forget,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
// 忘记密码
|
||||
public async getIndex(): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.index,
|
||||
data: {}
|
||||
});
|
||||
}
|
||||
}
|
||||
30
滴滴淘/h5(1)/src/core/service/impl/NewsServiceImpl.ts
Normal file
30
滴滴淘/h5(1)/src/core/service/impl/NewsServiceImpl.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Axios } from "../../dao";
|
||||
import { NewsService } from "../NewsService";
|
||||
import { config } from "../../config";
|
||||
|
||||
export class NewsServiceImpl extends Axios implements NewsService {
|
||||
|
||||
// 公共列表
|
||||
public async announceList(data: object): Promise<any> {
|
||||
return await this.get({
|
||||
url: config.AjaxConfig.ApiList.announceList,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// 公告详情
|
||||
public async announceInfoById(data: object): Promise<any> {
|
||||
return await this.get({
|
||||
url: config.AjaxConfig.ApiList.announceInfoById,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// 消息列表
|
||||
public async messageList(data: object): Promise<any> {
|
||||
return await this.get({
|
||||
url: config.AjaxConfig.ApiList.messageList,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
}
|
||||
33
滴滴淘/h5(1)/src/core/service/impl/PublicServiceImpl.ts
Normal file
33
滴滴淘/h5(1)/src/core/service/impl/PublicServiceImpl.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { PublicService } from '../PublicService'
|
||||
import {Axios} from "../../dao";
|
||||
import {config} from "../../config";
|
||||
import * as ServeTypes from '../../types/ServeTypes'
|
||||
|
||||
export class PublicServiceImpl extends Axios implements PublicService {
|
||||
|
||||
public async getvantcity(): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.getvantcity,
|
||||
data: {}
|
||||
});
|
||||
}
|
||||
|
||||
// 买家图片上传
|
||||
public async uploadImg(data: ServeTypes.imageType): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.uploadImg,
|
||||
data: data,
|
||||
header: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 银行卡列表
|
||||
public async banklist(): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.banklist,
|
||||
data: {}
|
||||
});
|
||||
}
|
||||
}
|
||||
105
滴滴淘/h5(1)/src/core/service/impl/TaskServiceImpl.ts
Normal file
105
滴滴淘/h5(1)/src/core/service/impl/TaskServiceImpl.ts
Normal file
@@ -0,0 +1,105 @@
|
||||
import { TaskService } from '../TaskService'
|
||||
import {Axios} from "../../dao";
|
||||
import {config} from "../../config";
|
||||
import * as ServeTypes from '../../types/ServeTypes'
|
||||
|
||||
export class TaskServiceImpl extends Axios implements TaskService {
|
||||
public async getTaskAccount(data: { platform_id: string }): Promise<any> {
|
||||
return await this.get({
|
||||
url: config.AjaxConfig.ApiList.getTaskAccount,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
public async getTaskList(data: object): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.getTaskList,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
public async orderTask(data: object): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.orderTask,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
public async commitTask(data: object): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.commitTask,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
public async taskDetail(id: string): Promise<any> {
|
||||
return await this.get({
|
||||
url: config.AjaxConfig.ApiList.taskDetail,
|
||||
data: {
|
||||
task_id: id
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public async setComparePrice(data: ServeTypes.setComparePriceType): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.setComparePrice,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
public async verifyShop(data: ServeTypes.verifyShopType): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.verifyShop,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
public async purchaseDone(data: ServeTypes.purchaseDoneType): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.purchaseDone,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
public async buyerOrder(data: ServeTypes.buyerOrderType): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.buyerOrder,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
public async confirmAccept(id: string): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.confirmAccept,
|
||||
data: {
|
||||
task_id: id
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public async cancelTask(id: string): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.cancelTask,
|
||||
data: {
|
||||
task_id: id
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public async nextStep(id: string): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.nextStep,
|
||||
data: {
|
||||
task_id: id
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public async setTaskTag(data: ServeTypes.TaskTagType): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.setTaskTag,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
}
|
||||
108
滴滴淘/h5(1)/src/core/service/impl/UserServiceImpl.ts
Normal file
108
滴滴淘/h5(1)/src/core/service/impl/UserServiceImpl.ts
Normal file
@@ -0,0 +1,108 @@
|
||||
import { UserService } from '../UserService'
|
||||
import {Axios} from "../../dao";
|
||||
import {config} from "../../config";
|
||||
import * as ServeTypes from '../../types/ServeTypes'
|
||||
|
||||
export class UserServiceImpl extends Axios implements UserService {
|
||||
|
||||
// 买号列表
|
||||
public async getAccountlist(): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.accountlist,
|
||||
data: {}
|
||||
});
|
||||
}
|
||||
|
||||
// 修改买号地址
|
||||
public async saveAccountAddress(data: ServeTypes.saveAddress): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.saveAccountAddress,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// 获取当前买号信息
|
||||
public async accountListByPlatform(id: string): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.accountListByPlatform,
|
||||
data: {
|
||||
id: id
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 修改买号
|
||||
public async modifyAccount(data: ServeTypes.buyNumber): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.modifyAccount,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// 提现
|
||||
public async cashout(type: number): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.cashout,
|
||||
data: {
|
||||
type_id: type
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 实名认证
|
||||
public async saveidcard(data: ServeTypes.realNameType): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.saveidcard,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// 实名认证查询
|
||||
public async idCardBankInfo(): Promise<any> {
|
||||
return await this.post({
|
||||
url: config.AjaxConfig.ApiList.idCardBankInfo,
|
||||
data: {}
|
||||
});
|
||||
}
|
||||
|
||||
// 资金列表
|
||||
public async financelist(data: ServeTypes.paging): Promise<any> {
|
||||
return await this.get({
|
||||
url: config.AjaxConfig.ApiList.financelist,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// 佣金列表
|
||||
public async commissionList(data: ServeTypes.paging): Promise<any> {
|
||||
return await this.get({
|
||||
url: config.AjaxConfig.ApiList.commissionList,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// 提现列表
|
||||
public async cashlist(data: ServeTypes.paging): Promise<any> {
|
||||
return await this.get({
|
||||
url: config.AjaxConfig.ApiList.cashlist,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// 获取用户信息
|
||||
public async getMemberInfo(): Promise<any> {
|
||||
return await this.get({
|
||||
url: config.AjaxConfig.ApiList.getMemberInfo,
|
||||
data: {}
|
||||
});
|
||||
}
|
||||
|
||||
// 推广信息
|
||||
public async referinfo(data: ServeTypes.paging): Promise<any> {
|
||||
return await this.get({
|
||||
url: config.AjaxConfig.ApiList.referinfo,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
13
滴滴淘/h5(1)/src/core/service/imports.ts
Normal file
13
滴滴淘/h5(1)/src/core/service/imports.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import {HomeServiceImpl} from "./impl/HomeServiceImpl";
|
||||
import {PublicServiceImpl} from "./impl/PublicServiceImpl";
|
||||
import {UserServiceImpl} from "./impl/UserServiceImpl";
|
||||
import {TaskServiceImpl} from "./impl/TaskServiceImpl";
|
||||
import {NewsServiceImpl} from "./impl/NewsServiceImpl";
|
||||
|
||||
export default class Imports {
|
||||
public HomeService = new HomeServiceImpl()
|
||||
public PublicService = new PublicServiceImpl()
|
||||
public UserService = new UserServiceImpl()
|
||||
public TaskService = new TaskServiceImpl()
|
||||
public NewsService = new NewsServiceImpl()
|
||||
}
|
||||
1
滴滴淘/h5(1)/src/core/store/.pydio
Normal file
1
滴滴淘/h5(1)/src/core/store/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
2d824815-2536-4b1e-a089-96dda5ed23c6
|
||||
7
滴滴淘/h5(1)/src/core/store/actions.ts
Normal file
7
滴滴淘/h5(1)/src/core/store/actions.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Commit } from 'vuex'
|
||||
|
||||
export default {
|
||||
NEWSNUM(context: { commit: Commit }, n: Object){
|
||||
context.commit('SET_NEWSNUM', n)
|
||||
}
|
||||
}
|
||||
5
滴滴淘/h5(1)/src/core/store/getters.ts
Normal file
5
滴滴淘/h5(1)/src/core/store/getters.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export default {
|
||||
getNewsNum: (state:any) => {
|
||||
return state.newsNum
|
||||
}
|
||||
}
|
||||
21
滴滴淘/h5(1)/src/core/store/index.ts
Normal file
21
滴滴淘/h5(1)/src/core/store/index.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
import mutations from './mutations'
|
||||
import actions from './actions'
|
||||
import getters from './getters'
|
||||
|
||||
Vue.use(Vuex)
|
||||
|
||||
|
||||
|
||||
const store = new Vuex.Store({
|
||||
state:{
|
||||
newsNum: 0, // 任务角标
|
||||
},
|
||||
actions,
|
||||
mutations,
|
||||
getters
|
||||
})
|
||||
|
||||
export default store
|
||||
1
滴滴淘/h5(1)/src/core/store/modules/.pydio
Normal file
1
滴滴淘/h5(1)/src/core/store/modules/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
70091933-524c-4d73-a89f-5c3d0bd021d8
|
||||
5
滴滴淘/h5(1)/src/core/store/mutations.ts
Normal file
5
滴滴淘/h5(1)/src/core/store/mutations.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export default {
|
||||
SET_NEWSNUM (state:any, n: Object) {
|
||||
state.newsNum = n
|
||||
}
|
||||
}
|
||||
1
滴滴淘/h5(1)/src/core/types/.pydio
Normal file
1
滴滴淘/h5(1)/src/core/types/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
28eee31e-8881-4fd1-87fb-de52da83c8e4
|
||||
199
滴滴淘/h5(1)/src/core/types/ServeTypes.ts
Normal file
199
滴滴淘/h5(1)/src/core/types/ServeTypes.ts
Normal file
@@ -0,0 +1,199 @@
|
||||
export type registerType = {
|
||||
// 手机号
|
||||
cellphone: string
|
||||
|
||||
// 密码(8-25位数组字母组合)
|
||||
password: string
|
||||
|
||||
// 验证码(暂未做验证(4位))
|
||||
verifyCode?: string
|
||||
|
||||
// 短信模板ID,此处为1,注册验证码
|
||||
templateId?: string
|
||||
|
||||
// 邀请码
|
||||
inviteCode?: string
|
||||
}
|
||||
|
||||
export type buyNumber = {
|
||||
|
||||
// 买号id修改买号时需要
|
||||
id?: string
|
||||
// 账号
|
||||
account: string
|
||||
|
||||
// 账号性别
|
||||
account_gender: number
|
||||
|
||||
// 账号等级
|
||||
account_rate: number
|
||||
|
||||
// 账号年龄
|
||||
account_ages: number
|
||||
|
||||
// 账号积分(淘气值,京享值,拼多多没有 )
|
||||
account_points: number
|
||||
|
||||
// 上传id
|
||||
image_id: number
|
||||
|
||||
// 姓名
|
||||
full_name: string
|
||||
|
||||
// 手机号码
|
||||
cellphone: string
|
||||
|
||||
// 地区id
|
||||
area_id: string
|
||||
|
||||
// 详细地址
|
||||
detail: string
|
||||
|
||||
// 标签id(1,2,3) 最多三个
|
||||
category_id: string
|
||||
|
||||
// 账号类型(1淘宝2京东3拼多多)
|
||||
account_type: string
|
||||
|
||||
}
|
||||
|
||||
// 上传图片接口
|
||||
export type imageType = {
|
||||
file: File
|
||||
imageType: string
|
||||
}
|
||||
|
||||
export type saveAddress = {
|
||||
|
||||
// 买号id
|
||||
id: string
|
||||
|
||||
// 姓名
|
||||
full_name: string
|
||||
|
||||
// 手机号码
|
||||
cellphone: string
|
||||
|
||||
// 地区id
|
||||
area_id: string
|
||||
|
||||
// 详情
|
||||
detail: string
|
||||
}
|
||||
|
||||
export type realNameType = {
|
||||
// 姓名
|
||||
username: string
|
||||
|
||||
// 省份证卡号
|
||||
id_card: string
|
||||
|
||||
// 上传身份证图片id
|
||||
id_card_image_id: string
|
||||
|
||||
// 手势图片id
|
||||
user_image_id: string
|
||||
|
||||
// 银行账号
|
||||
account: string
|
||||
|
||||
// 银行id
|
||||
bank_id: string
|
||||
|
||||
// 支行名称(开户行)
|
||||
bank_name: string
|
||||
|
||||
// 地区id
|
||||
bank_area_id: string
|
||||
}
|
||||
|
||||
export type setComparePriceType = {
|
||||
|
||||
// 任务ID
|
||||
task_id: string
|
||||
|
||||
// 淘口令
|
||||
compare_item_value: string
|
||||
|
||||
// 货比信息的主键ID,没有则表示新增货比信息 编辑时需传
|
||||
compare_price_id?: string
|
||||
}
|
||||
|
||||
export type verifyShopType = {
|
||||
// 任务ID
|
||||
task_id: string
|
||||
|
||||
// 店铺名或淘口令
|
||||
verify_value: string
|
||||
|
||||
// 图片id
|
||||
image_id: string
|
||||
}
|
||||
|
||||
export type purchaseDoneType = {
|
||||
|
||||
// 任务ID
|
||||
task_id: string
|
||||
|
||||
// 加购物车
|
||||
item_cart: 'no' | 1 | ''
|
||||
|
||||
// 宝贝收藏
|
||||
item_collect: 'no' | 1 | ''
|
||||
|
||||
// 拍前假聊
|
||||
item_chat: 'no' | 1 | ''
|
||||
|
||||
// 宝贝浏览
|
||||
item_scan: 'no' | 1 | ''
|
||||
|
||||
}
|
||||
|
||||
export type buyerOrderType = {
|
||||
// 任务ID
|
||||
task_id: string
|
||||
|
||||
// 淘宝/京东/PDD订单号
|
||||
trade_num: string
|
||||
|
||||
// 实付金额
|
||||
amount: string
|
||||
}
|
||||
|
||||
export type paging = {
|
||||
// 当前页
|
||||
page: number
|
||||
|
||||
// 分页大小
|
||||
limit: number
|
||||
}
|
||||
|
||||
// 忘记密码
|
||||
export type forget = {
|
||||
// 手机号
|
||||
cellphone: string
|
||||
|
||||
// 验证码
|
||||
verify_code: string
|
||||
|
||||
// 模板id
|
||||
template_id: string
|
||||
|
||||
// 密码
|
||||
password: string
|
||||
|
||||
// 确认密码
|
||||
repassword: string
|
||||
}
|
||||
|
||||
// 任务打标
|
||||
export type TaskTagType = {
|
||||
// 任务id
|
||||
task_id: string
|
||||
|
||||
// 任务详情接口种的参数
|
||||
process_id: string
|
||||
|
||||
// 图片上传后返回的id
|
||||
tag_image: number
|
||||
}
|
||||
1
滴滴淘/h5(1)/src/core/utils/.pydio
Normal file
1
滴滴淘/h5(1)/src/core/utils/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
34dc31dd-011b-4cc8-b29e-abd8f67f862a
|
||||
210
滴滴淘/h5(1)/src/core/utils/index.ts
Normal file
210
滴滴淘/h5(1)/src/core/utils/index.ts
Normal file
@@ -0,0 +1,210 @@
|
||||
import { config } from '../config';
|
||||
import { Toast } from 'vant';
|
||||
import { format } from 'timeago.js';
|
||||
|
||||
export class Utils {
|
||||
/**
|
||||
* 检测当前环境,动态返回ajax接口的对应的URL地址
|
||||
* @constructor
|
||||
*/
|
||||
public static CheckAjaxUrl(): string {
|
||||
if (process.env.NODE_ENV.replace(/^\s+|\s+$/g, '') == 'production') {
|
||||
return config.AjaxConfig.ProdUrl;
|
||||
} else {
|
||||
return config.AjaxConfig.DevUrl;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测当前环境,动态返回socket对应的URL地址
|
||||
* @constructor
|
||||
*/
|
||||
public static CheckWsUrl(): string {
|
||||
if (process.env.NODE_ENV.replace(/^\s+|\s+$/g, '') == 'production') {
|
||||
return config.AjaxConfig.WsProdUrl;
|
||||
} else {
|
||||
return config.AjaxConfig.WsDevUrl;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步加载组件,仅限 pages 中组件
|
||||
* @param fileName 组件的文件名称
|
||||
* @constructor
|
||||
*/
|
||||
public static AsyncComponentHook(fileName: String): Function {
|
||||
const component = import(/* webpackChunkName: "[request]" */ `@/pages/${fileName}.vue`);
|
||||
component.catch(e => console.error(`组件加载失败: ${e}`));
|
||||
return () => component;
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态设置网页title
|
||||
* @param title
|
||||
*/
|
||||
public setTitle(title: string): void {
|
||||
document.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地存储
|
||||
* @param key 存储的名称
|
||||
* @param value 存储的数据
|
||||
*/
|
||||
public setStorage(key: string, value: any): void {
|
||||
try {
|
||||
if (typeof key !== 'string') {
|
||||
throw "key必须为字符串";
|
||||
}
|
||||
localStorage.setItem(config.prefix + key, JSON.stringify(value))
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本地存储
|
||||
* @param key 存储的名称
|
||||
*/
|
||||
public getStorage(key: string): any {
|
||||
try {
|
||||
let value: string = localStorage.getItem(config.prefix + key) as string
|
||||
if (value !== void 0 && value !== null) {
|
||||
return JSON.parse(value)
|
||||
} else {
|
||||
throw `获取key:${key}的本地缓存数据失败`
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除本地存储
|
||||
* @param key 存储的名称
|
||||
*/
|
||||
public delStorage(key: string): void {
|
||||
return localStorage.removeItem(config.prefix + key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取token
|
||||
*/
|
||||
public getToken(): void {
|
||||
return this.getStorage('access_token')
|
||||
}
|
||||
|
||||
/**
|
||||
* id 身份证号
|
||||
* 身份证验证
|
||||
*/
|
||||
public isIdentity(id: string): boolean{
|
||||
let str: RegExp = /^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
|
||||
return str.test(id)
|
||||
}
|
||||
/**
|
||||
* id 手机号
|
||||
* 手机号证验证
|
||||
*/
|
||||
public isTel(id: string): boolean{
|
||||
let str: RegExp = /^1[3456789]\d{9}$/
|
||||
return str.test(id)
|
||||
}
|
||||
|
||||
// 计算倒计时
|
||||
public leftTimer(time: number): string{
|
||||
//3.获取现在的时间
|
||||
let presentDate = new Date();
|
||||
//4.获取时间戳
|
||||
let funtureTime = time * 1000;
|
||||
let presenTime = presentDate.getTime();
|
||||
//5.获取剩余的时间戳
|
||||
let allTime = funtureTime - presenTime;
|
||||
//6.把毫秒转换为秒
|
||||
let allSecond: any = (allTime / 1000)
|
||||
//7.获取剩余多少天
|
||||
let day = this.size((allSecond / 3600 / 24))
|
||||
//8.获取剩余多少小时
|
||||
let hour = this.size((allSecond / 3600 % 24))
|
||||
//9.获取剩余多少分钟
|
||||
let minute = this.size((allSecond / 60 % 60));
|
||||
//10.获取剩余多少秒
|
||||
let second = this.size((allSecond % 60));
|
||||
if(second >= 0){
|
||||
return `${parseInt(hour)}时 ${parseInt(minute)}分 ${parseInt(second)}秒`
|
||||
}else{
|
||||
return '任务已超时'
|
||||
}
|
||||
}
|
||||
private size(num: any) {
|
||||
return num < 10 && num >= 0 ? '0' + num : num;
|
||||
}
|
||||
|
||||
// 时间戳转正常时间
|
||||
public formatDate(data: number): string {
|
||||
let now=new Date(data*1000);
|
||||
let year=now.getFullYear();
|
||||
let month=now.getMonth()+1;
|
||||
let date=now.getDate();
|
||||
let hour=now.getHours();
|
||||
let minute=now.getMinutes();
|
||||
let second=now.getSeconds();
|
||||
return year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second;
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间戳 转最近时间 转换后 类如(1天前)
|
||||
* @param time 时间戳
|
||||
*/
|
||||
public formatAge(time: number): string {
|
||||
return format(time*1000, 'zh_CN')
|
||||
}
|
||||
|
||||
// 复制到粘贴板
|
||||
public copy(str: string): void {
|
||||
var tag = document.createElement('input');
|
||||
tag.setAttribute('id', 'cp_hgz_input');
|
||||
tag.value = str;
|
||||
document.getElementsByTagName('body')[0].appendChild(tag);
|
||||
// @ts-ignore
|
||||
document.getElementById('cp_hgz_input').select();
|
||||
document.execCommand('copy');
|
||||
// @ts-ignore
|
||||
document.getElementById('cp_hgz_input').remove();
|
||||
Toast('复制成功')
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于把 单位为分 转换成 单位为元
|
||||
* @param m 后端返回被处理成 单位为分 的钱
|
||||
*/
|
||||
public conversionMoney(m: number): string {
|
||||
return (m/10/10).toFixed(2)
|
||||
}
|
||||
|
||||
/**
|
||||
* 使元素在可视区域内
|
||||
* @param event
|
||||
*/
|
||||
public onFocus(event: Event): void {
|
||||
try {
|
||||
// 获取对应事件的 input dom
|
||||
const inputDom: any = event.target;
|
||||
setTimeout(() => {
|
||||
// px to rem 的比例
|
||||
const rate = (window.screen.width || document.documentElement.clientWidth) / 375;
|
||||
// 底部按钮 375基准 的高度为 56,根据 rate 计算实际高度
|
||||
const bottomFixHeight = 56 * rate;
|
||||
// 高度计算
|
||||
const clientHeight = document.documentElement.clientHeight;
|
||||
const top = inputDom.getBoundingClientRect().top;
|
||||
const diff = clientHeight - top;
|
||||
// scrollIntoViewIfNeeded方法使 元素滚动到浏览器窗口的可视区域内
|
||||
inputDom.scrollIntoViewIfNeeded(true);
|
||||
inputDom.scrollIntoView(true)
|
||||
}, 200);
|
||||
} catch (error) {
|
||||
new Error(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
159
滴滴淘/h5(1)/src/core/utils/socket.ts
Normal file
159
滴滴淘/h5(1)/src/core/utils/socket.ts
Normal file
@@ -0,0 +1,159 @@
|
||||
import {Utils} from './index'
|
||||
import store from '../store/index'
|
||||
|
||||
interface wxConfig {
|
||||
// 链接的通道的地址
|
||||
url: string
|
||||
|
||||
// 心跳时间间隔
|
||||
heartTime: number
|
||||
|
||||
// 心跳信息,默认为'ping'
|
||||
heartMsg: any
|
||||
|
||||
// 是否自动重连
|
||||
isReconnect: boolean
|
||||
|
||||
// 重连时间间隔
|
||||
reconnectTime: number
|
||||
|
||||
// 重连次数 -1 则不限制
|
||||
reconnectCount: number
|
||||
}
|
||||
|
||||
export class Socket {
|
||||
|
||||
private Utils: Utils = new Utils()
|
||||
|
||||
private ws!: WebSocket
|
||||
|
||||
private wxConfig: wxConfig = {
|
||||
url: Utils.CheckWsUrl(),
|
||||
heartTime: 40000,
|
||||
heartMsg: {dataType:'ping'},
|
||||
isReconnect: true,
|
||||
reconnectTime: 5000,
|
||||
reconnectCount: 5
|
||||
}
|
||||
|
||||
// 重连定时器
|
||||
private restartTime!: number
|
||||
|
||||
// 销毁定时器
|
||||
private closeTime!: number
|
||||
|
||||
constructor(option?: any){
|
||||
Object.assign(this.wxConfig, option)
|
||||
this.create()
|
||||
}
|
||||
|
||||
// 启动心跳
|
||||
private start() {
|
||||
// 开启定时器
|
||||
this.restartTime = setTimeout(() => {
|
||||
this.send(this.wxConfig.heartMsg)
|
||||
// 如果发送消息返回失败则触发关闭
|
||||
this.closeTime = setTimeout(() => {
|
||||
console.error('服务器长时间无响应,尝试重启服务');
|
||||
this.destroy()
|
||||
this.create()
|
||||
}, this.wxConfig.heartTime);
|
||||
}, this.wxConfig.heartTime);
|
||||
}
|
||||
|
||||
// 重启心跳
|
||||
private restart() {
|
||||
clearTimeout(this.restartTime) // 清除重连定时器
|
||||
clearTimeout(this.closeTime) // 清除销毁定时器
|
||||
this.start()
|
||||
}
|
||||
|
||||
// 创建链接
|
||||
private create() {
|
||||
if (!('WebSocket' in window)) {
|
||||
new Error('当前浏览器不支持,无法使用')
|
||||
return
|
||||
}
|
||||
if (!this.wxConfig.url) {
|
||||
new Error('地址不存在,无法建立通道')
|
||||
return
|
||||
}
|
||||
this.ws = new WebSocket(this.wxConfig.url)
|
||||
this.start()
|
||||
this.onopen()
|
||||
this.onmessage()
|
||||
this.onerror()
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义连接成功事件
|
||||
*/
|
||||
onopen () {
|
||||
this.ws.onopen = (event) => {
|
||||
let login = {
|
||||
dataType: 'login',
|
||||
token: this.Utils.getToken()
|
||||
}
|
||||
this.send(login)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义关闭事件
|
||||
*/
|
||||
onclose () {
|
||||
this.ws.onclose = (event) => {
|
||||
console.log(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义错误事件
|
||||
*/
|
||||
onerror () {
|
||||
this.ws.onerror = (event) => {
|
||||
console.log(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义消息监听事件
|
||||
*/
|
||||
onmessage () {
|
||||
this.ws.onmessage = (event) => {
|
||||
this.restart()
|
||||
let data = JSON.parse(event.data)
|
||||
// if(data.status == -1){
|
||||
// this.destroy()
|
||||
// this.create()
|
||||
// }
|
||||
// 如果返回的数据中有data存在则保存 消息数量
|
||||
if(data.data !== void 0){
|
||||
store.commit('SET_NEWSNUM', data.data.msg_num)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义发送消息事件
|
||||
* @param {any} msg 发送的文本
|
||||
*/
|
||||
send (msg: any) {
|
||||
if (this.ws.readyState !== this.ws.OPEN) {
|
||||
new Error('没有连接到服务器,无法推送')
|
||||
return
|
||||
}
|
||||
console.log(msg);
|
||||
let str: string = JSON.stringify(msg)
|
||||
this.ws.send(str)
|
||||
}
|
||||
|
||||
/**
|
||||
* 销毁
|
||||
*/
|
||||
destroy () {
|
||||
this.restart()
|
||||
clearTimeout(this.restartTime) // 清除重连定时器
|
||||
this.ws.close()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user