Commit 15262b30 authored by gengshaojing's avatar gengshaojing

add: git commit hooks

add: 优化打包构建
update: eslint prettier 规则
parent 5885f7ff
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false
\ No newline at end of file
...@@ -7,4 +7,3 @@ public ...@@ -7,4 +7,3 @@ public
dist dist
.prettierrc.js .prettierrc.js
.eslintrc.js .eslintrc.js
server/
...@@ -3,23 +3,13 @@ module.exports = { ...@@ -3,23 +3,13 @@ module.exports = {
env: { env: {
node: true, node: true,
}, },
extends: ['plugin:vue/vue3-essential', 'eslint:recommended', '@vue/prettier'], extends: ["plugin:vue/vue3-essential", "eslint:recommended", "@vue/prettier"],
parserOptions: { parserOptions: {
parser: 'babel-eslint', parser: "babel-eslint",
}, },
rules: { rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', "no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
"prettier/prettier": "error",
}, },
overrides: [
{
files: [
'**/__tests__/*.{j,t}s?(x)',
'**/tests/unit/**/*.spec.{j,t}s?(x)',
],
env: {
jest: true,
},
},
],
}; };
...@@ -7,7 +7,6 @@ dist ...@@ -7,7 +7,6 @@ dist
# Editor directories and files # Editor directories and files
.idea .idea
.vscode
*.suo *.suo
*.ntvs* *.ntvs*
*.njsproj *.njsproj
......
// https://prettier.io/docs/en/options.html
module.exports = {
printWidth: 180,
tabWidth: 4,
semi: true,
singleQuote: false,
trailingComma: "all",
bracketSpacing: true,
jsxBracketSameLine: false,
htmlWhitespaceSensitivity: "ignore",
endOfLine: "auto",
vueIndentScriptAndStyle: true,
};
{
// 保存自动格式化
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
// For ESLint
"source.fixAll.eslint": true
},
"eslint.validate": [
"vue",
"javascript",
"javascriptreact"
],
// 设置全部语言的默认格式化程序为prettier
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[less]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
module.exports = { module.exports = {
presets: ['@vue/cli-plugin-babel/preset'], presets: ["@vue/cli-plugin-babel/preset"],
}; };
This diff is collapsed.
...@@ -11,11 +11,11 @@ ...@@ -11,11 +11,11 @@
"web-dev": "cross-env NODE_ENV=development vue-cli-service serve", "web-dev": "cross-env NODE_ENV=development vue-cli-service serve",
"web-test": "cross-env NODE_ENV=test vue-cli-service build", "web-test": "cross-env NODE_ENV=test vue-cli-service build",
"web-build": "cross-env NODE_ENV=production vue-cli-service build", "web-build": "cross-env NODE_ENV=production vue-cli-service build",
"web-build-report": "cross-env NODE_ENV=production vue-cli-service build --report",
"test:unit": "vue-cli-service test:unit", "test:unit": "vue-cli-service test:unit",
"lint": "vue-cli-service lint" "lint": "vue-cli-service lint"
}, },
"dependencies": { "dependencies": {
"@types/qr-image": "^3.2.4",
"axios": "^0.21.1", "axios": "^0.21.1",
"core-js": "^3.6.5", "core-js": "^3.6.5",
"dayjs": "^1.10.6", "dayjs": "^1.10.6",
...@@ -31,34 +31,28 @@ ...@@ -31,34 +31,28 @@
"moment": "^2.29.1", "moment": "^2.29.1",
"qr-image": "^3.2.0", "qr-image": "^3.2.0",
"request": "^2.88.2", "request": "^2.88.2",
"uglifyjs-webpack-plugin": "^2.2.0",
"uuid": "^8.3.2", "uuid": "^8.3.2",
"vue": "3.0.11", "vue": "3.0.11",
"vue-router": "^4.0.0-beta.12", "vue-router": "^4.0.0-beta.12",
"vuex": "^4.0.0-beta.4" "vuex": "^4.0.0-beta.4"
}, },
"devDependencies": { "devDependencies": {
"@testing-library/vue": "^6.4.2",
"@vue/cli-plugin-babel": "^4.5.6", "@vue/cli-plugin-babel": "^4.5.6",
"@vue/cli-plugin-eslint": "^4.5.6", "@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-unit-jest": "^4.5.6",
"@vue/cli-service": "^4.5.6", "@vue/cli-service": "^4.5.6",
"@vue/compiler-sfc": "^3.0.0-beta.1", "@vue/compiler-sfc": "^3.0.0-beta.1",
"@vue/eslint-config-prettier": "^6.0.0", "@vue/eslint-config-prettier": "^6.0.0",
"@vue/test-utils": "^2.0.0-alpha.1",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
"babel-jest": "^27.0.6",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"eslint": "^6.7.2", "eslint": "^6.7.2",
"eslint-plugin-prettier": "^3.1.3", "eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-vue": "^7.0.0-alpha.0", "eslint-plugin-vue": "^7.17.0",
"jest": "^27.0.6",
"less": "^3.0.4", "less": "^3.0.4",
"less-loader": "^5.0.0", "less-loader": "^5.0.0",
"lint-staged": "^11.1.2",
"nodemon": "^2.0.7", "nodemon": "^2.0.7",
"pm2": "3.5.1", "pm2": "3.5.1",
"prettier": "^1.19.1", "prettier": "^2.2.1"
"vue3-jest": "^27.0.0-alpha.1"
}, },
"browserslist": [ "browserslist": [
"> 1%", "> 1%",
...@@ -67,5 +61,18 @@ ...@@ -67,5 +61,18 @@
"iOS >= 8", "iOS >= 8",
"Android >= 4.1" "Android >= 4.1"
], ],
"license": "YIDIAN" "license": "YIDIAN",
"gitHooks": {
"pre-commit": "lint-staged"
},
"lint-staged": {
"src/**/*.{js,vue}": [
"prettier --write",
"eslint --fix"
],
"server/**/*.js": [
"prettier --write",
"eslint --fix"
]
}
} }
const Router = require("koa-router"); const Router = require("koa-router");
const static = require("./controllers/static-router"); const staticRouter = require("./controllers/static-router");
const system = require("./controllers/system"); const system = require("./controllers/system");
const user = require("./controllers/user"); const user = require("./controllers/user");
const enterprise = require("./controllers/enterprise"); const enterprise = require("./controllers/enterprise");
const role = require('./controllers/role') const role = require("./controllers/role");
const life = require('./controllers/life-no'); const life = require("./controllers/life-no");
const goods = require('./controllers/goods'); const goods = require("./controllers/goods");
const activity = require('./controllers/activity'); const activity = require("./controllers/activity");
const withdrawal = require('./controllers/withdrawal'); const withdrawal = require("./controllers/withdrawal");
const groupmeal = require('./controllers/groupmeal'); const groupmeal = require("./controllers/groupmeal");
const qr_code = require('./controllers/qr-code'); const qr_code = require("./controllers/qr-code");
const router = Router(); const router = Router();
const API_VERSION = "/api/v1"; const API_VERSION = "/api/v1";
router.get(/^\/op.*/, static.index) router.get(/^\/op.*/, staticRouter.index);
router.get(`${API_VERSION}/qr_code`, qr_code.gen_qr_code); router.get(`${API_VERSION}/qr_code`, qr_code.gen_qr_code);
router.get(`${API_VERSION}/fetch_user`, system.fetch_user); router.get(`${API_VERSION}/fetch_user`, system.fetch_user);
router.get(`${API_VERSION}/user/:type`, user.query) router.get(`${API_VERSION}/user/:type`, user.query);
router.post(`${API_VERSION}/J_login`, system.J_login); router.post(`${API_VERSION}/J_login`, system.J_login);
router.post(`${API_VERSION}/YD_login`, system.YD_login); router.post(`${API_VERSION}/YD_login`, system.YD_login);
router.get(`${API_VERSION}/users`, user.user_list); router.get(`${API_VERSION}/users`, user.user_list);
...@@ -26,12 +26,12 @@ router.get(`${API_VERSION}/users/detail`, user.user_detail); ...@@ -26,12 +26,12 @@ router.get(`${API_VERSION}/users/detail`, user.user_detail);
router.post(`${API_VERSION}/users/edit`, user.user_edit); router.post(`${API_VERSION}/users/edit`, user.user_edit);
router.post(`${API_VERSION}/users/new`, user.user_new); router.post(`${API_VERSION}/users/new`, user.user_new);
router.post(`${API_VERSION}/merchant/authority/role_list`, role.getRole_list) router.post(`${API_VERSION}/merchant/authority/role_list`, role.getRole_list);
router.post(`${API_VERSION}/merchant/authority/add_role`, role.getAdd_role) router.post(`${API_VERSION}/merchant/authority/add_role`, role.getAdd_role);
router.post(`${API_VERSION}/merchant/authority/update_role`, role.getUpdate_role) router.post(`${API_VERSION}/merchant/authority/update_role`, role.getUpdate_role);
router.post(`${API_VERSION}/merchant/authority/get_role_list`, role.getAll_role_list) router.post(`${API_VERSION}/merchant/authority/get_role_list`, role.getAll_role_list);
router.post(`${API_VERSION}/merchant/authority/get_role_info`, role.get_role_info) router.post(`${API_VERSION}/merchant/authority/get_role_info`, role.get_role_info);
router.post(`${API_VERSION}/merchant/authority/delete_role`, role.getDelete_role) router.post(`${API_VERSION}/merchant/authority/delete_role`, role.getDelete_role);
/* 企业认证 */ /* 企业认证 */
router.post(`${API_VERSION}/certification`, enterprise.auditList); router.post(`${API_VERSION}/certification`, enterprise.auditList);
router.post(`${API_VERSION}/send_code`, enterprise.sendCode); router.post(`${API_VERSION}/send_code`, enterprise.sendCode);
...@@ -39,7 +39,7 @@ router.post(`${API_VERSION}/check_code`, enterprise.checkCode); ...@@ -39,7 +39,7 @@ router.post(`${API_VERSION}/check_code`, enterprise.checkCode);
router.post(`${API_VERSION}/get_record_info`, enterprise.getRecordInfo); router.post(`${API_VERSION}/get_record_info`, enterprise.getRecordInfo);
router.post(`${API_VERSION}/get_log`, enterprise.getLog); router.post(`${API_VERSION}/get_log`, enterprise.getLog);
router.post(`${API_VERSION}/audit`, enterprise.postAudit); router.post(`${API_VERSION}/audit`, enterprise.postAudit);
router.post(`${API_VERSION}/business`, enterprise.postBusiness) router.post(`${API_VERSION}/business`, enterprise.postBusiness);
router.post(`${API_VERSION}/op_commit`, enterprise.opCommit); router.post(`${API_VERSION}/op_commit`, enterprise.opCommit);
router.post(`${API_VERSION}/op_business_update`, enterprise.opBusinessUpdate); router.post(`${API_VERSION}/op_business_update`, enterprise.opBusinessUpdate);
...@@ -54,29 +54,29 @@ router.post(`${API_VERSION}/goods/background/check_goods_name`, goods.checkGoods ...@@ -54,29 +54,29 @@ router.post(`${API_VERSION}/goods/background/check_goods_name`, goods.checkGoods
router.post(`${API_VERSION}/goods/background/audit_reject`, goods.auditReject); router.post(`${API_VERSION}/goods/background/audit_reject`, goods.auditReject);
router.get(`${API_VERSION}/shop/background/shop_list`, goods.getShopsList); router.get(`${API_VERSION}/shop/background/shop_list`, goods.getShopsList);
router.post(`${API_VERSION}/shop/background/add_shop`, goods.addShop); router.post(`${API_VERSION}/shop/background/add_shop`, goods.addShop);
router.post(`${API_VERSION}/goods/background/edit_goods`, goods.editGoods) router.post(`${API_VERSION}/goods/background/edit_goods`, goods.editGoods);
// 营销活动 // 营销活动
router.post(`${API_VERSION}/get_marketing_list`, goods.getMarketingList) router.post(`${API_VERSION}/get_marketing_list`, goods.getMarketingList);
router.post(`${API_VERSION}/get_addmarketing_list`, goods.getAddMarketingList) router.post(`${API_VERSION}/get_addmarketing_list`, goods.getAddMarketingList);
router.post(`${API_VERSION}/get_find_goods_list`, goods.getFindGoodsList) router.post(`${API_VERSION}/get_find_goods_list`, goods.getFindGoodsList);
router.post(`${API_VERSION}/get_marketing_info`, goods.getMarketingInfo) router.post(`${API_VERSION}/get_marketing_info`, goods.getMarketingInfo);
router.post(`${API_VERSION}/update_marketing_list`, goods.updateMarketingList) router.post(`${API_VERSION}/update_marketing_list`, goods.updateMarketingList);
//生活号 //生活号
router.post(`${API_VERSION}/merchant/lifeinner/life_info`, life.get_life_info) router.post(`${API_VERSION}/merchant/lifeinner/life_info`, life.get_life_info);
router.get(`${API_VERSION}/merchant/lifeinner/life_list`, life.get_life_list) router.get(`${API_VERSION}/merchant/lifeinner/life_list`, life.get_life_list);
//用户 //用户
router.post(`${API_VERSION}/merchant/authority/get_user_info`, user.getUser_detail) router.post(`${API_VERSION}/merchant/authority/get_user_info`, user.getUser_detail);
// 后台运营管理 // 后台运营管理
router.get(`${API_VERSION}/marketing/background/marketing_list`, activity.getActivityList) router.get(`${API_VERSION}/marketing/background/marketing_list`, activity.getActivityList);
router.get(`${API_VERSION}/order/background/pindan_marketing_info_data_statistics`, activity.checkActivityDetailInfo) router.get(`${API_VERSION}/order/background/pindan_marketing_info_data_statistics`, activity.checkActivityDetailInfo);
router.post(`${API_VERSION}/goods/background/edit_goods`, activity.editGoodsDetail) router.post(`${API_VERSION}/goods/background/edit_goods`, activity.editGoodsDetail);
router.post(`${API_VERSION}/marketing/background/update_marketing_online_status`, activity.updateActivity) router.post(`${API_VERSION}/marketing/background/update_marketing_online_status`, activity.updateActivity);
router.post(`${API_VERSION}/marketing/background/marketing_info`, activity.checkActivityDetail) router.post(`${API_VERSION}/marketing/background/marketing_info`, activity.checkActivityDetail);
// //
router.get(`${API_VERSION}/marketing/background/take_place_list`, activity.getPlaceList) router.get(`${API_VERSION}/marketing/background/take_place_list`, activity.getPlaceList);
router.post(`${API_VERSION}/marketing/background/add_take_place`, activity.addPlace) router.post(`${API_VERSION}/marketing/background/add_take_place`, activity.addPlace);
router.post(`${API_VERSION}/marketing/background/delete_take_place`, activity.deletePlace) router.post(`${API_VERSION}/marketing/background/delete_take_place`, activity.deletePlace);
router.get(`${API_VERSION}/goods/background/ota_list`, activity.getBusinessList); router.get(`${API_VERSION}/goods/background/ota_list`, activity.getBusinessList);
router.post(`${API_VERSION}/goods/background/add_goods`, activity.addGoods); router.post(`${API_VERSION}/goods/background/add_goods`, activity.addGoods);
router.get(`${API_VERSION}/goods/background/pindan_goods`, activity.pindanGoods); router.get(`${API_VERSION}/goods/background/pindan_goods`, activity.pindanGoods);
...@@ -86,12 +86,11 @@ router.post(`${API_VERSION}/marketing/background/add_marketing`, activity.addMar ...@@ -86,12 +86,11 @@ router.post(`${API_VERSION}/marketing/background/add_marketing`, activity.addMar
router.post(`${API_VERSION}/marketing/background/marketing_info`, activity.marketingInfo); router.post(`${API_VERSION}/marketing/background/marketing_info`, activity.marketingInfo);
router.post(`${API_VERSION}/marketing/background/update_marketing`, activity.updateMarketing); router.post(`${API_VERSION}/marketing/background/update_marketing`, activity.updateMarketing);
// 团餐运营--配送 // 团餐运营--配送
router.post(`${API_VERSION}/order/deliverer/list_day_deliverer_conf`, groupmeal.getList) router.post(`${API_VERSION}/order/deliverer/list_day_deliverer_conf`, groupmeal.getList);
router.post(`${API_VERSION}/order/deliverer/list_day_deliverer`, groupmeal.getDelivererList) router.post(`${API_VERSION}/order/deliverer/list_day_deliverer`, groupmeal.getDelivererList);
router.post(`${API_VERSION}/order/deliverer/add_deliverer`, groupmeal.getAddDeliverer) router.post(`${API_VERSION}/order/deliverer/add_deliverer`, groupmeal.getAddDeliverer);
router.post(`${API_VERSION}/order/deliverer/save_day_deliverer`, groupmeal.getSaveDeliverer) router.post(`${API_VERSION}/order/deliverer/save_day_deliverer`, groupmeal.getSaveDeliverer);
// 老订单管理 // 老订单管理
router.get(`${API_VERSION}/order/oldbackground/order_list`, groupmeal.getOrderList); router.get(`${API_VERSION}/order/oldbackground/order_list`, groupmeal.getOrderList);
...@@ -118,15 +117,15 @@ router.get(`${API_VERSION}/order/background/order_refund_reject`, groupmeal.newO ...@@ -118,15 +117,15 @@ router.get(`${API_VERSION}/order/background/order_refund_reject`, groupmeal.newO
router.post(`${API_VERSION}/order/background/order_refund`, groupmeal.newOrderRefund); router.post(`${API_VERSION}/order/background/order_refund`, groupmeal.newOrderRefund);
// 钱包提现审核 // 钱包提现审核
router.get(`${API_VERSION}/get_withdrawal_apply_list`, withdrawal.getApplyList) router.get(`${API_VERSION}/get_withdrawal_apply_list`, withdrawal.getApplyList);
router.post(`${API_VERSION}/get_withdrawal_black_list`, withdrawal.getBlackList) router.post(`${API_VERSION}/get_withdrawal_black_list`, withdrawal.getBlackList);
router.post(`${API_VERSION}/get_withdraw_audit`, withdrawal.getWithdrawAudit) router.post(`${API_VERSION}/get_withdraw_audit`, withdrawal.getWithdrawAudit);
router.post(`${API_VERSION}/get_freezing_fund`, withdrawal.getFreezingFund) router.post(`${API_VERSION}/get_freezing_fund`, withdrawal.getFreezingFund);
router.get(`${API_VERSION}/get_apply_detail`, withdrawal.getApplyDetail) router.get(`${API_VERSION}/get_apply_detail`, withdrawal.getApplyDetail);
// 钱包账户 // 钱包账户
router.get(`${API_VERSION}/get_account_list`, withdrawal.getAccountList) router.get(`${API_VERSION}/get_account_list`, withdrawal.getAccountList);
router.get(`${API_VERSION}/get_record_list`, withdrawal.getRecordList) router.get(`${API_VERSION}/get_record_list`, withdrawal.getRecordList);
router.post(`${API_VERSION}/get_account_black_list`, withdrawal.getAccountBlackList) router.post(`${API_VERSION}/get_account_black_list`, withdrawal.getAccountBlackList);
router.post(`${API_VERSION}/get_reblack_list`, withdrawal.getReblackList) router.post(`${API_VERSION}/get_reblack_list`, withdrawal.getReblackList);
module.exports = router; module.exports = router;
...@@ -10,27 +10,27 @@ ...@@ -10,27 +10,27 @@
</template> </template>
<script> <script>
import { getCookie, redirectToLogin } from '@/utils/util'; import { getCookie, redirectToLogin } from "@/utils/util";
import { fetchCurrentUser } from './service/user'; import { fetchCurrentUser } from "./service/user";
export default { export default {
async mounted() { async mounted() {
if (this.$store.state.permissions && this.$store.state.userInfo) return; if (this.$store.state.permissions && this.$store.state.userInfo) return;
if (!getCookie('username') && window.location.pathname != '/op/login') { if (!getCookie("username") && window.location.pathname != "/op/login") {
this.$message('请先登录'); this.$message("请先登录");
return redirectToLogin(); return redirectToLogin();
} }
if (!this.$store.state.permissions) { if (!this.$store.state.permissions) {
const { status, user } = await fetchCurrentUser(); const { status, user } = await fetchCurrentUser();
if (status === 'success') { if (status === "success") {
this.$store.commit('updateUserInfo', user); this.$store.commit("updateUserInfo", user);
await this.$store.dispatch('updateUserPermission', { email: user.email }); await this.$store.dispatch("updateUserPermission", { email: user.email });
this.$store.dispatch('fetchPermission', { this.$store.dispatch("fetchPermission", {
appId: 'merchant-op-auditing' appId: "merchant-op-auditing",
}); });
} }
} }
} },
}; };
</script> </script>
......
@import './styles/reset.less'; @import "./styles/reset.less";
@import './styles/loading.less'; @import "./styles/loading.less";
html, html,
body, body,
#root, #root,
#app { #app {
height: 100%; height: 100%;
} }
body { body {
margin: 0; margin: 0;
} }
...@@ -3,18 +3,12 @@ import { handlerSuccessResponse } from "@/utils/handlerResponse"; ...@@ -3,18 +3,12 @@ import { handlerSuccessResponse } from "@/utils/handlerResponse";
// 获取主页配送员列表 // 获取主页配送员列表
export async function getList(params) { export async function getList(params) {
const res = await axios.post( const res = await axios.post("/api/v1/order/deliverer/list_day_deliverer_conf", params);
"/api/v1/order/deliverer/list_day_deliverer_conf",
params
);
return res; return res;
} }
// 获取分配配送员列表 // 获取分配配送员列表
export async function getDelivererList(params) { export async function getDelivererList(params) {
const res = await axios.post( const res = await axios.post("/api/v1/order/deliverer/list_day_deliverer", params);
"/api/v1/order/deliverer/list_day_deliverer",
params
);
return res; return res;
} }
// 添加配送员 // 添加配送员
...@@ -24,10 +18,7 @@ export async function getAddDeliverer(params) { ...@@ -24,10 +18,7 @@ export async function getAddDeliverer(params) {
} }
// 分配配送员 // 分配配送员
export async function getSaveDeliverer(params) { export async function getSaveDeliverer(params) {
const res = await axios.post( const res = await axios.post("/api/v1/order/deliverer/save_day_deliverer", params);
"/api/v1/order/deliverer/save_day_deliverer",
params
);
return res; return res;
} }
// 下载配送路线 -lh // 下载配送路线 -lh
...@@ -47,7 +38,7 @@ export async function getEmailRecords(params) { ...@@ -47,7 +38,7 @@ export async function getEmailRecords(params) {
// 获取订单列表 // 获取订单列表
export async function getOrderList(params) { export async function getOrderList(params) {
const res = await axios.get("/api/v1/order/oldbackground/order_list", { const res = await axios.get("/api/v1/order/oldbackground/order_list", {
params params,
}); });
return res; return res;
} }
...@@ -61,7 +52,7 @@ export async function getMarketingList() { ...@@ -61,7 +52,7 @@ export async function getMarketingList() {
// 获取商品名称 // 获取商品名称
export async function getGoodsList(params) { export async function getGoodsList(params) {
const res = await axios.get("/api/v1/order/oldbackground/goods_list", { const res = await axios.get("/api/v1/order/oldbackground/goods_list", {
params params,
}); });
return res; return res;
} }
...@@ -69,7 +60,7 @@ export async function getGoodsList(params) { ...@@ -69,7 +60,7 @@ export async function getGoodsList(params) {
// 获取自提点 // 获取自提点
export async function getSubShopList(params) { export async function getSubShopList(params) {
const res = await axios.get("/api/v1/order/oldbackground/sub_shop_list", { const res = await axios.get("/api/v1/order/oldbackground/sub_shop_list", {
params params,
}); });
return res; return res;
} }
...@@ -77,7 +68,7 @@ export async function getSubShopList(params) { ...@@ -77,7 +68,7 @@ export async function getSubShopList(params) {
// 导出订单 // 导出订单
export async function orderExport(params) { export async function orderExport(params) {
const res = await axios.get("/api/v1/order/oldbackground/order_export", { const res = await axios.get("/api/v1/order/oldbackground/order_export", {
params params,
}); });
return res; return res;
} }
...@@ -85,7 +76,7 @@ export async function orderExport(params) { ...@@ -85,7 +76,7 @@ export async function orderExport(params) {
// 打印订单 // 打印订单
export async function orderPrint(params) { export async function orderPrint(params) {
const res = await axios.get("/api/v1/order/oldbackground/order_print", { const res = await axios.get("/api/v1/order/oldbackground/order_print", {
params params,
}); });
return res; return res;
} }
...@@ -93,7 +84,7 @@ export async function orderPrint(params) { ...@@ -93,7 +84,7 @@ export async function orderPrint(params) {
// 订单退款列表 // 订单退款列表
export async function orderItemList(params) { export async function orderItemList(params) {
const res = await axios.get("/api/v1/order/oldbackground/order_item_list", { const res = await axios.get("/api/v1/order/oldbackground/order_item_list", {
params params,
}); });
return res; return res;
} }
...@@ -106,31 +97,28 @@ export async function refundOrder(orderId, itemsToRefund) { ...@@ -106,31 +97,28 @@ export async function refundOrder(orderId, itemsToRefund) {
// }; // };
const res = await axios.post("/api/v1/order/oldbackground/order_refund", { const res = await axios.post("/api/v1/order/oldbackground/order_refund", {
order_id: orderId, order_id: orderId,
refund_list: itemsToRefund refund_list: itemsToRefund,
}); });
return res; return res;
} }
// 订单驳回 // 订单驳回
export async function orderRefundReject(params) { export async function orderRefundReject(params) {
const res = await axios.get( const res = await axios.get("/api/v1/order/oldbackground/order_refund_reject", {
"/api/v1/order/oldbackground/order_refund_reject", params,
{ });
params
}
);
return res; return res;
} }
// 导出订单 // 导出订单
export function getOrderExportURL(eventId, type) { export function getOrderExportURL(eventId, type) {
var ENV; var ENV;
if(process.env.NODE_ENV == "development"){ if (process.env.NODE_ENV == "development") {
ENV = "http://bp-dev.ini.yidian-inc.com/" ENV = "http://bp-dev.ini.yidian-inc.com/";
}else if(process.env.NODE_ENV == "test"){ } else if (process.env.NODE_ENV == "test") {
ENV = "http://bp-test.ini.yidian-inc.com/" ENV = "http://bp-test.ini.yidian-inc.com/";
}else{ } else {
ENV = "http://bp.int.yidian-inc.com/" ENV = "http://bp.int.yidian-inc.com/";
} }
return `${ENV}order/oldbackground/order_export?marketing_id=${eventId}&type=${type}`; return `${ENV}order/oldbackground/order_export?marketing_id=${eventId}&type=${type}`;
} }
...@@ -140,45 +128,37 @@ export function getOrderExportURL(eventId, type) { ...@@ -140,45 +128,37 @@ export function getOrderExportURL(eventId, type) {
// 获取订单列表 // 获取订单列表
export async function newGetOrderList(params) { export async function newGetOrderList(params) {
const res = await axios.get("/api/v1/order/background/order_list", { const res = await axios.get("/api/v1/order/background/order_list", {
params params,
}); });
return res; return res;
} }
// 获取活动名称 // 获取活动名称
export async function newGetMarketingList() { export async function newGetMarketingList() {
const res = await axios.get( const res = await axios.get("/api/v1/order/background/order_condition_marketing_list");
"/api/v1/order/background/order_condition_marketing_list"
);
return res; return res;
} }
// 获取商品名称 // 获取商品名称
export async function newGetGoodsList(params) { export async function newGetGoodsList(params) {
const res = await axios.get( const res = await axios.get("/api/v1/order/background/order_condition_goods_list", {
"/api/v1/order/background/order_condition_goods_list", params,
{ });
params
}
);
return res; return res;
} }
// 获取自提点 // 获取自提点
export async function newGetSubShopList(params) { export async function newGetSubShopList(params) {
const res = await axios.get( const res = await axios.get("/api/v1/order/background/order_condition_take_place_list", {
"/api/v1/order/background/order_condition_take_place_list", params,
{ });
params
}
);
return res; return res;
} }
// 打印订单 // 打印订单
export async function newOrderPrint(params) { export async function newOrderPrint(params) {
const res = await axios.get("/api/v1/order/background/order_print", { const res = await axios.get("/api/v1/order/background/order_print", {
params params,
}); });
return res; return res;
} }
...@@ -186,7 +166,7 @@ export async function newOrderPrint(params) { ...@@ -186,7 +166,7 @@ export async function newOrderPrint(params) {
// 订单退款列表 // 订单退款列表
export async function newOrderItemList(params) { export async function newOrderItemList(params) {
const res = await axios.get("/api/v1/order/background/order_item_list", { const res = await axios.get("/api/v1/order/background/order_item_list", {
params params,
}); });
return res; return res;
} }
...@@ -195,7 +175,7 @@ export async function newOrderItemList(params) { ...@@ -195,7 +175,7 @@ export async function newOrderItemList(params) {
export async function newRefundOrder(orderId, itemsToRefund) { export async function newRefundOrder(orderId, itemsToRefund) {
const res = await axios.post("/api/v1/order/background/order_refund", { const res = await axios.post("/api/v1/order/background/order_refund", {
order_id: orderId, order_id: orderId,
refund_list: itemsToRefund refund_list: itemsToRefund,
}); });
return res; return res;
} }
...@@ -203,7 +183,7 @@ export async function newRefundOrder(orderId, itemsToRefund) { ...@@ -203,7 +183,7 @@ export async function newRefundOrder(orderId, itemsToRefund) {
// 订单驳回 // 订单驳回
export async function newOrderRefundReject(params) { export async function newOrderRefundReject(params) {
const res = await axios.get("/api/v1/order/background/order_refund_reject", { const res = await axios.get("/api/v1/order/background/order_refund_reject", {
params params,
}); });
return res; return res;
} }
...@@ -211,12 +191,12 @@ export async function newOrderRefundReject(params) { ...@@ -211,12 +191,12 @@ export async function newOrderRefundReject(params) {
// 导出订单 // 导出订单
export function newGetOrderExportURL(eventId, type) { export function newGetOrderExportURL(eventId, type) {
var ENV; var ENV;
if(process.env.NODE_ENV == "development"){ if (process.env.NODE_ENV == "development") {
ENV = "http://bp-dev.ini.yidian-inc.com/" ENV = "http://bp-dev.ini.yidian-inc.com/";
}else if(process.env.NODE_ENV == "test"){ } else if (process.env.NODE_ENV == "test") {
ENV = "http://bp-test.ini.yidian-inc.com/" ENV = "http://bp-test.ini.yidian-inc.com/";
}else{ } else {
ENV = "http://bp.int.yidian-inc.com/" ENV = "http://bp.int.yidian-inc.com/";
} }
return `${ENV}order/background/order_export?marketing_id=${eventId}&type=${type}`; return `${ENV}order/background/order_export?marketing_id=${eventId}&type=${type}`;
} }
const path = require("path"); const path = require("path");
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const isProduction = process.env.NODE_ENV === 'production';
const isDev = process.env.NODE_ENV === "development"; const IS_PROD = process.env.NODE_ENV === "production";
const plugins = [];
let externalObj = {}; // CDN 链接配置
if(isProduction) { const CDN = {
externalObj = { externals: {
'element-plus': 'ElementPlus', "element-plus": "ElementPlus",
vue: "Vue", vue: "Vue",
"vue-router": "VueRouter", "vue-router": "VueRouter",
vuex: "Vuex", vuex: "Vuex",
axios: "axios" axios: "axios",
}
}
if (process.env.NODE_ENV === 'production') {
plugins.push(new UglifyJsPlugin({
uglifyOptions: {
warnings: false
},
sourceMap: false,
parallel: true,
}));
}
const cdn = {
// 开发环境
dev: {
css: [],
js: []
}, },
// 生产环境
build: { build: {
css: [ css: ["https://unpkg.com/element-plus/lib/theme-chalk/index.css"],
"https://unpkg.com/element-plus/lib/theme-chalk/index.css"
],
js: [ js: [
'https://cdn.bootcdn.net/ajax/libs/vue/3.0.11/vue.global.js', "https://cdn.bootcdn.net/ajax/libs/vue/3.0.11/vue.global.js",
'https://cdn.bootcdn.net/ajax/libs/vue-router/4.0.6/vue-router.global.js', "https://cdn.bootcdn.net/ajax/libs/vue-router/4.0.6/vue-router.global.js",
'https://cdn.bootcdn.net/ajax/libs/vuex/4.0.0/vuex.global.js', "https://cdn.bootcdn.net/ajax/libs/vuex/4.0.0/vuex.global.js",
'https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.js', "https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.js",
'https://cdn.bootcdn.net/ajax/libs/element-plus/1.0.2-beta.44/index.full.js', "https://cdn.bootcdn.net/ajax/libs/element-plus/1.0.2-beta.44/index.full.js",
'https://cdn.bootcdn.net/ajax/libs/element-plus/1.0.2-beta.44/umd/locale/zh-cn.js', "https://cdn.bootcdn.net/ajax/libs/element-plus/1.0.2-beta.44/umd/locale/zh-cn.js",
'https://unpkg.com/dayjs/locale/zh-cn.js' "https://unpkg.com/dayjs/locale/zh-cn.js",
] ],
} },
} };
module.exports = { module.exports = {
outputDir: isDev ? "./dist" : path.resolve("./public/dist/"), outputDir: !IS_PROD ? "./dist" : path.resolve("./public/dist/"),
publicPath: isDev ? "/" : "/dist", publicPath: !IS_PROD ? "/" : "/dist",
indexPath: './index.html', lintOnSave: !IS_PROD,
lintOnSave: false, productionSourceMap: false, // 去掉生成环境的 sourceMap
configureWebpack: {
devServer: { devServer: {
proxy: "http://127.0.0.1:8055", //http://localhost:8055 proxy: "http://127.0.0.1:8055", //http://localhost:8055
hot: true, hot: true,
disableHostCheck: true, disableHostCheck: true,
}, },
resolve: { configureWebpack: config => {
// 配置解析规则 if (IS_PROD) {
alias: { config.externals = CDN.externals;
'@': path.join(__dirname, 'src') // 使用@别名简写src目录所在的绝对路径 }
},
}, //打包文件大小配置
externals: externalObj, config["performance"] = {
plugins, maxEntrypointSize: 10000000,
maxAssetSize: 30000000,
};
}, },
chainWebpack: config => { chainWebpack: config => {
// 默认不开启 prefetch // 默认不开启 prefetch
...@@ -72,18 +53,46 @@ module.exports = { ...@@ -72,18 +53,46 @@ module.exports = {
// 默认不开启 preload // 默认不开启 preload
config.plugins.delete("preload"); config.plugins.delete("preload");
// 别名 alias
config.resolve.alias.set("@", path.resolve("src"));
// 修改页面 title // 修改页面 title
config.plugin("html").tap(args => { config.plugin("html").tap(args => {
args[0].title = "运营管理系统"; args[0].title = "运营管理系统";
if (isProduction) { if (IS_PROD) {
args[0].cdn = cdn.build args[0].cdn = CDN.build;
} }
// if (!isProduction) {
// args[0].cdn = cdn.dev
// }
return args; return args;
}); });
// 分包
config.when(IS_PROD, config => {
config.optimization.splitChunks({
chunks: "all",
cacheGroups: {
libs: {
name: "chunk-libs",
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: "initial", // 只打包初始时依赖的第三方
},
elementPlus: {
name: "chunk-elementPlus", // 单独将 elementPlus 拆包
priority: 20, // 数字大权重到,满足多个 cacheGroups 的条件时候分到权重高的
test: /[\\/]node_modules[\\/]_?element-plus(.*)/,
}, },
productionSourceMap: false, commons: {
name: "chunk-commons",
test: path.resolve("src/components"),
minChunks: 3, // 被至少用三次以上打包分离
priority: 5, // 优先级
reuseExistingChunk: true, // 表示是否使用已有的 chunk,如果为 true 则表示如果当前的 chunk 包含的模块已经被抽取出去了,那么将不会重新生成新的。
},
},
});
});
config.optimization.runtimeChunk("single");
},
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment