🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

wapx-lib

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wapx-lib - npm Package Compare versions

Comparing version
0.1.3
to
1.0.0
+5
.idea/codeStyles/codeStyleConfig.xml
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/wapx-lib.iml" filepath="$PROJECT_DIR$/.idea/wapx-lib.iml" />
</modules>
</component>
</project>

Sorry, the diff of this file is not supported yet

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="d80a15ec-d038-4925-9d27-dc85fbf51a3e" name="默认的" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ProjectId" id="1lAui5pb26Li1oUydc9sHPh54Rm" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="vue.rearranger.settings.migration" value="true" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$" />
<recent name="$PROJECT_DIR$/utils" />
</key>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="d80a15ec-d038-4925-9d27-dc85fbf51a3e" name="默认的" comment="" />
<created>1607052340694</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1607052340694</updated>
<workItem from="1607052341704" duration="495000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
</project>
import router from "@/router";
const commons = {};
commons.api_host = "https://api.kumob.cn/jobs";
// 云简历相关接口文档
// https://docs.apipost.cn/view/6cf90d41de0528dd
// 密码: $RFV5tgb
commons.template_list = commons.api_host + "/api/template/list" //模版列表,基本信息,不含模版内容 {"user_id": "sys"} //用户ID,sys为系统模版
commons.base_model_list = commons.api_host + "/api/model/list" //读取系统基本模块列表
commons.base_model_load = commons.api_host + "/api/model/load" //读取系统基本模块信息 {"id": "edu"} //模块ID
commons.template_create = commons.api_host + "/api/template/create" //根据已有模版,创建新模版。 {"template_id": "sys_001","user_id": "[userID]"}
commons.template_cv_review=commons.api_host+"/api/out/doc" //简历预览 {template_id:""}
commons.template_set = commons.api_host + "/api/template/set_template" //修改模版名称。 {"template_id": "","title": ""}
commons.template_delete = commons.api_host + "/api/template/delete" //删除模版,数据不删除。 {"template_id": ""}
commons.template_model_add = commons.api_host + "/api/template/add_model" //添加一个模块到模版中,不含数据 {"template_id": "96C5707663020CCC76DFF67BD6D4A31A","model_id": "intern","user_id": "[userID]"}
commons.template_model_list = commons.api_host + "/api/template/load" //读取模版模块结构,含排序信息。 {"template_id": "96C5707663020CCC76DFF67BD6D4A31A"}
commons.template_model_delete = commons.api_host + "/api/template/delete_model" //删除模版中的某一个模块 {"template_id": "96C5707663020CCC76DFF67BD6D4A31A","model_id": "intern"}
commons.template_model_set = commons.api_host + "/api/template/set_model" //重新设置模块名称 {template_id:'',model_id:'',title:''}
commons.template_model_data_load = commons.api_host + "/api/template/data/load" //读取某一模版下某一模块的数据列表,row_id可指定读出一行数据。 "template_id": "96C5707663020CCC76DFF67BD6D4A31A","model_id": "intern","row_id": "222222"}
commons.template_model_data_create = commons.api_host + "/api/template/data/create" //创建某模版下某模块的数据结构,不创建数据 {"template_id": "96C5707663020CCC76DFF67BD6D4A31A","model_id": "intern","user_id":"[userID]"}
commons.template_model_data_save = commons.api_host + "/api/template/data/save" //保存某模版下某一模块数据 提交数据局在create接口返回基础上加 fieldValue,以及user_id, user_id必须有
commons.template_model_data_delete = commons.api_host + "/api/template/data/delete" //删除某一模版下某一模块下的指定行数据 {"template_id": "96C5707663020CCC76DFF67BD6D4A31A","model_id": "intern","row_id": "111111"}
//照片上传地址 https://api.wapg.cn/jobs/commons/image/upload
commons.upload_img_url = commons.api_host + "/commons/image/upload";
commons.get_wx_user_info_url = "https://api.kumob.cn/wx/api/user/web_user_info/quick";
commons.get_wx_id_info_url = "https://api.kumob.cn/wx/api/user/open_id";
commons.jobs_corp_info = commons.api_host + "/api/corp/info" //{id:""} 企业主信息
commons.jobs_list = commons.api_host + "/api/jobs/list" //{corp_id:""} 招聘职位列表
commons.jobs_view_list = commons.api_host + "/api/jobs/view_list" //{corp_id:""} 招聘职位列表
commons.jobs_info = commons.api_host + "/api/jobs/info" //{id:""} 招聘职位信息
commons.jobs_view_info = commons.api_host + "/api/jobs/view_info" //{id:""} 招聘职位信息
commons.jobs_cv_submit = commons.api_host + "/api/jobs/cv_submit" //{corp_id:"",job_id:"",user_id:'',cv_id:'',doc_url:''} 招聘职位信息
commons.jobs_doc_upload = commons.api_host + "/api/file/upload"
//格式化时间
commons.dateFormat = function (fmt, date) {
//author: meizz
var o = {
"M+": date.getMonth() + 1, //月份
"d+": date.getDate(), //日
"h+": date.getHours(), //小时
"m+": date.getMinutes(), //分
"s+": date.getSeconds(), //秒
"q+": Math.floor((date.getMonth() + 3) / 3), //季度
S: date.getMilliseconds(), //毫秒
};
if (/(y+)/.test(fmt))
fmt = fmt.replace(
RegExp.$1,
(date.getFullYear() + "").substr(4 - RegExp.$1.length)
);
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt))
fmt = fmt.replace(
RegExp.$1,
RegExp.$1.length === 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)
);
return fmt;
};
commons.getUrlKey = function (name) {
return (
decodeURIComponent(
(new RegExp("[?|&]" + name + "=" + "([^&;]+?)(&|#|;|$)").exec(
location.href
) || ['', ""])[1].replace(/\+/g, "%20")
) || null
);
};
commons.getUrlKey2 = function (url, name) {
return (
decodeURIComponent(
(new RegExp("[?|&]" + name + "=" + "([^&;]+?)(&|#|;|$)").exec(
url
) || ['', ""])[1].replace(/\+/g, "%20")
) || null
);
};
commons.goto = function (page) {
router.push(page);
}
/**
* 获取重定向url(编码后)
*/
commons.getRedirectUrl = function (url) {
//redirect_url
return encodeURIComponent(url)
};
//js对象复制,排除空值和-1的
commons.copyObj = function (obj) {
let _data = {};
for (let k in obj) {
let keyType = typeof (obj[k]);
let keyValue = obj[k];
// let isCopy = false;
if (keyType === 'number' && keyValue > -1) {
// isCopy = true;
_data[k] = parseInt(keyValue);
}
if (keyType === 'string' && keyValue && keyValue.length > 0) {
// isCopy = true;
_data[k] = keyValue;
}
if (keyType === 'object') {
_data[k] = keyValue;
}
if (keyType === 'boolean') {
_data[k] = keyValue;
}
}
return _data;
};
export default commons;
const DateUtils={}
export default DateUtils
import axios from 'axios';
axios.defaults.timeout = 20000;
axios.defaults.baseURL = '';
//http request 拦截器
axios.interceptors.request.use(
config => {
// const token = getCookie('名称');注意使用的时候需要引入cookie方法,推荐js-cookie
// config.headers = {
// 'Content-Type': 'application/x-www-form-urlencoded'
// // 'Content-Type': 'application/json;charset=UTF-8'
// };
// if(token){
// config.params = {'token':token}
// }
// console.log(config.headers)
config.headers['Device-Data'] = {};
// config.headers['Accept'] = 'text/html, text/plain';
// config.headers = {
// 'Device-Data': store.state.device_data,//加入设备信息数据
// };
return config;
},
error => {
return Promise.reject(error);
}
);
//http response 拦截器
// axios.interceptors.response.use(
// response => {
// if (response.data.errCode == 2) {
// router.push({
// path: "/login",
// querry: {redirect: router.currentRoute.fullPath}//从哪个页面跳转
// })
// }
// return response;
// },
// error => {
// return Promise.reject(error)
// }
// );
/**
* 封装get方法
* @param url
* @param data
* @returns {Promise}
*/
export function getUrl(url, params = {}) {
return new Promise((resolve, reject) => {
axios.defaults.timeout = 60000;
axios.get(url, {
params: params
})
.then(response => {
resolve(response.data);
})
.catch(err => {
reject(err)
})
})
}
/**
* 封装post请求
* @param url
* @param data
* @returns {Promise}
*/
export function post(url, data = {}) {
return new Promise((resolve, reject) => {
axios.defaults.timeout = 15000;
axios.post(url, data)
.then(response => {
resolve(response.data);
}, err => {
reject(err)
})
})
}
export function postJsonUrl(url, data) {
return new Promise((resolve, reject) => {
axios.defaults.timeout = 15000;
// let _data= JSON.parse(data);
axios.post(url, data, config => {
config.headers = {
'Content-Type': 'application/json',
};
return config;
})
.then(response => {
resolve(response.data);
}, err => {
reject(err)
})
})
}
export function postDataUrl(url, data) {
return new Promise((resolve, reject) => {
axios.defaults.timeout = 15000;
let _data = transformData(data);
axios.post(url, _data, config => {
config.data = _data;
config.headers = {
'Content-Type': 'application/x-www-form-urlencoded'
};
return config;
})
.then(response => {
resolve(response.data);
}, err => {
reject(err)
})
})
}
export function postFormUrl(url, data = {}) {
return new Promise((resolve, reject) => {
axios.defaults.timeout = 15000;
// data: JSON.stringify(data),
axios.post(url, data, config => {
config.data = JSON.stringify(data);
config.headers = {
'Content-Type': 'application/x-www-form-urlencoded'
};
return config;
})
.then(response => {
resolve(response.data);
}, err => {
reject(err)
})
})
}
/**
* 封装patch请求
* @param url
* @param data
* @returns {Promise}
*/
export function patch(url, data = {}) {
return new Promise((resolve, reject) => {
axios.patch(url, data)
.then(response => {
resolve(response.data);
}, err => {
reject(err)
})
})
}
/**
* 封装put请求
* @param url
* @param data
* @returns {Promise}
*/
export function put(url, data = {}) {
return new Promise((resolve, reject) => {
axios.put(url, data)
.then(response => {
resolve(response.data);
}, err => {
reject(err)
})
})
}
export function postFileUrl(url, data) {
return new Promise((resolve, reject) => {
axios.defaults.timeout = 30000;
// withCredentials: true 使得后台可以接收表单数据 跨域请求
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
axios.post(url, data, config => {
config.headers = {
'Content-Type': 'multipart/form-data',
'enctype': 'multipart/form-data'
// 'Content-Type':'application/x-www-form-urlencoded'
};
return config;
})
.then(response => {
resolve(response.data);
}, err => {
reject(err)
})
// let config = {
// headers: {
// 'Content-Type': 'multipart/form-data'
// }
// }
//
// axios.post(url,data, config).then(res => {
// // success callback
// resolve(res.data);
// }).catch(err => {
// // error callback
// reject(err)
// });
})
}
function transformData(data) {
let ret = '';
for (let key in data) {
ret += encodeURIComponent(key) + '=' + encodeURIComponent(data[key]) + '&';
}
return ret;
}
export function get(url, fn) {
getUrl(url).then(function (response) {
if (fn) {
fn(response)
}
})
}
export function postJson(url, data, fn) {
postJsonUrl(url, data).then(function (response) {
if (fn) {
fn(response)
}
})
}
export function postData(url, data, fn) {
postDataUrl(url, data).then(function (response) {
if (fn) {
fn(response)
}
})
}
export function postForm(url, data, fn) {
postFormUrl(url, data).then(function (response) {
if (fn) {
fn(response)
}
})
}
export function postImage(url, data, fn) {
postFileUrl(url, data).then(function (response) {
if (fn) {
fn(response)
}
})
}
export function postFile(url, data, fn) {
postFileUrl(url, data).then(function (response) {
if (fn) {
fn(response)
}
})
}
const StringUtils={}
export default StringUtils
const test = {};
test.callback=function (fn){
if(fn){
fn('==回调测试==')
}
}
export default test;
+5
-6
import Vue from 'vue'
import utils from './src/js/commons/commons.js' //引入公用js
import utils from './utils/commons' //引入公用js
import {

@@ -11,5 +11,4 @@ postJson,

get,
} from "./src/js/commons/http.js";
import test from './src/js/commons/test.js'
import wx_test from "./src/components/TestUI.vue";
} from "./utils/http";
import test from './utils/test'

@@ -25,5 +24,4 @@ Vue.prototype.$utils = utils;

const Components = {
wx_test,
test,
utils,

@@ -38,2 +36,3 @@ postJson,

Object.keys(Components).forEach(name => {

@@ -40,0 +39,0 @@ Vue.component(name, Components[name])

{
"name": "wapx-lib",
"version": "0.1.3",
"private": false,
"version": "1.0.0",
"description": "基础js类库",
"main": "index.js",
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"build-public": "vue-cli-service build --target lib --name cloud_cv ./index.js"
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"js",
"lib"
],
"author": "金小光",
"license": "ISC",
"dependencies": {
"axios": "^0.21.0",
"core-js": "^3.6.5",
"vue": "^2.6.11",
"vue-router": "^3.2.0",
"vuex": "^3.4.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"vue-template-compiler": "^2.6.11"
"vue": "^2.6.12",
"vuex": "^3.6.0"
}
}

@@ -17,2 +17,2 @@ 1. 登录

5. 撤销发布
npm unpublish game_offer --force --registry http://registry.npmjs.org
npm unpublish [package_name] --force --registry http://registry.npmjs.org

Sorry, the diff of this file is not supported yet

module.exports = {
root: true,
env: {
node: true
},
'extends': [
'plugin:vue/essential',
'eslint:recommended'
],
parserOptions: {
parser: 'babel-eslint'
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
}
}
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}

Sorry, the diff of this file is not supported yet

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
<template>
<div id="app">
<div id="nav">
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</div>
<router-view/>
</div>
</template>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
}
#nav {
padding: 30px;
}
#nav a {
font-weight: bold;
color: #2c3e50;
}
#nav a.router-link-exact-active {
color: #42b983;
}
</style>

Sorry, the diff of this file is not supported yet

<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-router" target="_blank" rel="noopener">router</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-vuex" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
<template>
<div>
测试UI
<div>
{{ res }}
</div>
</div>
</template>
<script>
export default {
name: "wx_test",
data() {
return {
res: {}
}
},
created() {
this.testUrl()
},
methods: {
testUrl() {
let url = "https://api.wapg.cn/jd_union/recommend/rate_recommend?rate_start=10&rate_end=50&filter=true&page=1&size=20"
this.$get(url, res => {
this.res = res;
})
}
}
}
</script>
import router from "@/router";
const commons = {};
commons.api_host = "https://api.kumob.cn/jobs";
// 云简历相关接口文档
// https://docs.apipost.cn/view/6cf90d41de0528dd
// 密码: $RFV5tgb
commons.template_list = commons.api_host + "/api/template/list" //模版列表,基本信息,不含模版内容 {"user_id": "sys"} //用户ID,sys为系统模版
commons.base_model_list = commons.api_host + "/api/model/list" //读取系统基本模块列表
commons.base_model_load = commons.api_host + "/api/model/load" //读取系统基本模块信息 {"id": "edu"} //模块ID
commons.template_create = commons.api_host + "/api/template/create" //根据已有模版,创建新模版。 {"template_id": "sys_001","user_id": "[userID]"}
commons.template_cv_review=commons.api_host+"/api/out/doc" //简历预览 {template_id:""}
commons.template_set = commons.api_host + "/api/template/set_template" //修改模版名称。 {"template_id": "","title": ""}
commons.template_delete = commons.api_host + "/api/template/delete" //删除模版,数据不删除。 {"template_id": ""}
commons.template_model_add = commons.api_host + "/api/template/add_model" //添加一个模块到模版中,不含数据 {"template_id": "96C5707663020CCC76DFF67BD6D4A31A","model_id": "intern","user_id": "[userID]"}
commons.template_model_list = commons.api_host + "/api/template/load" //读取模版模块结构,含排序信息。 {"template_id": "96C5707663020CCC76DFF67BD6D4A31A"}
commons.template_model_delete = commons.api_host + "/api/template/delete_model" //删除模版中的某一个模块 {"template_id": "96C5707663020CCC76DFF67BD6D4A31A","model_id": "intern"}
commons.template_model_set = commons.api_host + "/api/template/set_model" //重新设置模块名称 {template_id:'',model_id:'',title:''}
commons.template_model_data_load = commons.api_host + "/api/template/data/load" //读取某一模版下某一模块的数据列表,row_id可指定读出一行数据。 "template_id": "96C5707663020CCC76DFF67BD6D4A31A","model_id": "intern","row_id": "222222"}
commons.template_model_data_create = commons.api_host + "/api/template/data/create" //创建某模版下某模块的数据结构,不创建数据 {"template_id": "96C5707663020CCC76DFF67BD6D4A31A","model_id": "intern","user_id":"[userID]"}
commons.template_model_data_save = commons.api_host + "/api/template/data/save" //保存某模版下某一模块数据 提交数据局在create接口返回基础上加 fieldValue,以及user_id, user_id必须有
commons.template_model_data_delete = commons.api_host + "/api/template/data/delete" //删除某一模版下某一模块下的指定行数据 {"template_id": "96C5707663020CCC76DFF67BD6D4A31A","model_id": "intern","row_id": "111111"}
//照片上传地址 https://api.wapg.cn/jobs/commons/image/upload
commons.upload_img_url = commons.api_host + "/commons/image/upload";
commons.get_wx_user_info_url = "https://api.kumob.cn/wx/api/user/web_user_info/quick";
commons.get_wx_id_info_url = "https://api.kumob.cn/wx/api/user/open_id";
commons.jobs_corp_info = commons.api_host + "/api/corp/info" //{id:""} 企业主信息
commons.jobs_list = commons.api_host + "/api/jobs/list" //{corp_id:""} 招聘职位列表
commons.jobs_view_list = commons.api_host + "/api/jobs/view_list" //{corp_id:""} 招聘职位列表
commons.jobs_info = commons.api_host + "/api/jobs/info" //{id:""} 招聘职位信息
commons.jobs_view_info = commons.api_host + "/api/jobs/view_info" //{id:""} 招聘职位信息
commons.jobs_cv_submit = commons.api_host + "/api/jobs/cv_submit" //{corp_id:"",job_id:"",user_id:'',cv_id:'',doc_url:''} 招聘职位信息
commons.jobs_doc_upload = commons.api_host + "/api/file/upload"
//格式化时间
commons.dateFormat = function (fmt, date) {
//author: meizz
var o = {
"M+": date.getMonth() + 1, //月份
"d+": date.getDate(), //日
"h+": date.getHours(), //小时
"m+": date.getMinutes(), //分
"s+": date.getSeconds(), //秒
"q+": Math.floor((date.getMonth() + 3) / 3), //季度
S: date.getMilliseconds(), //毫秒
};
if (/(y+)/.test(fmt))
fmt = fmt.replace(
RegExp.$1,
(date.getFullYear() + "").substr(4 - RegExp.$1.length)
);
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt))
fmt = fmt.replace(
RegExp.$1,
RegExp.$1.length === 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)
);
return fmt;
};
commons.getUrlKey = function (name) {
return (
decodeURIComponent(
(new RegExp("[?|&]" + name + "=" + "([^&;]+?)(&|#|;|$)").exec(
location.href
) || ['', ""])[1].replace(/\+/g, "%20")
) || null
);
};
commons.getUrlKey2 = function (url, name) {
return (
decodeURIComponent(
(new RegExp("[?|&]" + name + "=" + "([^&;]+?)(&|#|;|$)").exec(
url
) || ['', ""])[1].replace(/\+/g, "%20")
) || null
);
};
commons.goto = function (page) {
router.push(page);
}
/**
* 获取重定向url(编码后)
*/
commons.getRedirectUrl = function (url) {
//redirect_url
return encodeURIComponent(url)
};
//js对象复制,排除空值和-1的
commons.copyObj = function (obj) {
let _data = {};
for (let k in obj) {
let keyType = typeof (obj[k]);
let keyValue = obj[k];
// let isCopy = false;
if (keyType === 'number' && keyValue > -1) {
// isCopy = true;
_data[k] = parseInt(keyValue);
}
if (keyType === 'string' && keyValue && keyValue.length > 0) {
// isCopy = true;
_data[k] = keyValue;
}
if (keyType === 'object') {
_data[k] = keyValue;
}
if (keyType === 'boolean') {
_data[k] = keyValue;
}
}
return _data;
};
export default commons;
import axios from 'axios';
import store from '../../store/index'
axios.defaults.timeout = 20000;
axios.defaults.baseURL = '';
//http request 拦截器
axios.interceptors.request.use(
config => {
// const token = getCookie('名称');注意使用的时候需要引入cookie方法,推荐js-cookie
// config.headers = {
// 'Content-Type': 'application/x-www-form-urlencoded'
// // 'Content-Type': 'application/json;charset=UTF-8'
// };
// if(token){
// config.params = {'token':token}
// }
// console.log(config.headers)
config.headers['Device-Data'] = JSON.stringify(store.state.device_data);
// config.headers['Accept'] = 'text/html, text/plain';
// config.headers = {
// 'Device-Data': store.state.device_data,//加入设备信息数据
// };
return config;
},
error => {
return Promise.reject(error);
}
);
//http response 拦截器
// axios.interceptors.response.use(
// response => {
// if (response.data.errCode == 2) {
// router.push({
// path: "/login",
// querry: {redirect: router.currentRoute.fullPath}//从哪个页面跳转
// })
// }
// return response;
// },
// error => {
// return Promise.reject(error)
// }
// );
/**
* 封装get方法
* @param url
* @param data
* @returns {Promise}
*/
export function getUrl(url, params = {}) {
return new Promise((resolve, reject) => {
axios.defaults.timeout = 60000;
axios.get(url, {
params: params
})
.then(response => {
resolve(response.data);
})
.catch(err => {
reject(err)
})
})
}
/**
* 封装post请求
* @param url
* @param data
* @returns {Promise}
*/
export function post(url, data = {}) {
return new Promise((resolve, reject) => {
axios.defaults.timeout = 15000;
axios.post(url, data)
.then(response => {
resolve(response.data);
}, err => {
reject(err)
})
})
}
export function postJsonUrl(url, data) {
return new Promise((resolve, reject) => {
axios.defaults.timeout = 15000;
// let _data= JSON.parse(data);
axios.post(url, data, config => {
config.headers = {
'Content-Type': 'application/json',
};
return config;
})
.then(response => {
resolve(response.data);
}, err => {
reject(err)
})
})
}
export function postDataUrl(url, data) {
return new Promise((resolve, reject) => {
axios.defaults.timeout = 15000;
let _data = transformData(data);
axios.post(url, _data, config => {
config.data = _data;
config.headers = {
'Content-Type': 'application/x-www-form-urlencoded'
};
return config;
})
.then(response => {
resolve(response.data);
}, err => {
reject(err)
})
})
}
export function postFormUrl(url, data = {}) {
return new Promise((resolve, reject) => {
axios.defaults.timeout = 15000;
// data: JSON.stringify(data),
axios.post(url, data, config => {
config.data = JSON.stringify(data);
config.headers = {
'Content-Type': 'application/x-www-form-urlencoded'
};
return config;
})
.then(response => {
resolve(response.data);
}, err => {
reject(err)
})
})
}
/**
* 封装patch请求
* @param url
* @param data
* @returns {Promise}
*/
export function patch(url, data = {}) {
return new Promise((resolve, reject) => {
axios.patch(url, data)
.then(response => {
resolve(response.data);
}, err => {
reject(err)
})
})
}
/**
* 封装put请求
* @param url
* @param data
* @returns {Promise}
*/
export function put(url, data = {}) {
return new Promise((resolve, reject) => {
axios.put(url, data)
.then(response => {
resolve(response.data);
}, err => {
reject(err)
})
})
}
export function postFileUrl(url, data) {
return new Promise((resolve, reject) => {
axios.defaults.timeout = 30000;
// withCredentials: true 使得后台可以接收表单数据 跨域请求
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
axios.post(url, data, config => {
config.headers = {
'Content-Type': 'multipart/form-data',
'enctype': 'multipart/form-data'
// 'Content-Type':'application/x-www-form-urlencoded'
};
return config;
})
.then(response => {
resolve(response.data);
}, err => {
reject(err)
})
// let config = {
// headers: {
// 'Content-Type': 'multipart/form-data'
// }
// }
//
// axios.post(url,data, config).then(res => {
// // success callback
// resolve(res.data);
// }).catch(err => {
// // error callback
// reject(err)
// });
})
}
function transformData(data) {
let ret = '';
for (let key in data) {
ret += encodeURIComponent(key) + '=' + encodeURIComponent(data[key]) + '&';
}
return ret;
}
export function get(url, fn) {
getUrl(url).then(function (response) {
if (fn) {
fn(response)
}
})
}
export function postJson(url, data, fn) {
postJsonUrl(url, data).then(function (response) {
if (fn) {
fn(response)
}
})
}
export function postData(url, data, fn) {
postDataUrl(url, data).then(function (response) {
if (fn) {
fn(response)
}
})
}
export function postForm(url, data, fn) {
postFormUrl(url, data).then(function (response) {
if (fn) {
fn(response)
}
})
}
export function postImage(url, data, fn) {
postFileUrl(url, data).then(function (response) {
if (fn) {
fn(response)
}
})
}
export function postFile(url, data, fn) {
postFileUrl(url, data).then(function (response) {
if (fn) {
fn(response)
}
})
}
const test = {};
test.callback=function (fn){
if(fn){
fn('==回调测试==')
}
}
export default test;
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
Vue.config.productionTip = false
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')
import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
Vue.use(VueRouter)
const routes = [
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/about',
name: 'About',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
}
]
const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes
})
export default router
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
state: {
},
mutations: {
},
actions: {
},
modules: {
}
})
<template>
<div class="about">
<h1>This is an about page</h1>
</div>
</template>
<template>
<div class="home">
<img alt="Vue logo" src="../assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
</div>
</template>
<script>
// @ is an alias to /src
import HelloWorld from '@/components/HelloWorld.vue'
export default {
name: 'Home',
components: {
HelloWorld
}
}
</script>