Commit 0fe4bc1c by 杨北旺

第一次提交

0 parents
> 1%
last 2 versions
# http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
NODE_ENV='development'
# must start with VUE_APP_
VUE_APP_ENV = 'development'
NODE_ENV='production'
# must start with VUE_APP_
VUE_APP_ENV = 'production'
\ No newline at end of file
NODE_ENV='production'
# must start with VUE_APP_
VUE_APP_ENV = 'staging'
build/*.js
src/assets
src/config
public
dist
module.exports = {
root: true,
env: {
node: true
},
extends: ['plugin:vue/essential', 'eslint:recommended'],
parserOptions: {
parser: 'babel-eslint'
},
rules: {
'vue/max-attributes-per-line': [
2,
{
singleline: 10,
multiline: {
max: 1,
allowFirstLine: false
}
}
],
'vue/singleline-html-element-content-newline': 'off',
'vue/multiline-html-element-content-newline': 'off',
'vue/name-property-casing': ['error', 'PascalCase'],
'vue/no-v-html': 'off',
'accessor-pairs': 2,
'arrow-spacing': [
2,
{
before: true,
after: true
}
],
'block-spacing': [2, 'always'],
'brace-style': [
2,
'1tbs',
{
allowSingleLine: true
}
],
camelcase: [
0,
{
properties: 'always'
}
],
'comma-dangle': [2, 'never'],
'comma-spacing': [
2,
{
before: false,
after: true
}
],
'comma-style': [2, 'last'],
'constructor-super': 2,
curly: [2, 'multi-line'],
'dot-location': [2, 'property'],
'eol-last': 2,
eqeqeq: ['error', 'always', { null: 'ignore' }],
'generator-star-spacing': [
2,
{
before: true,
after: true
}
],
'handle-callback-err': [2, '^(err|error)$'],
indent: [
2,
2,
{
SwitchCase: 1
}
],
'jsx-quotes': [2, 'prefer-single'],
'key-spacing': [
2,
{
beforeColon: false,
afterColon: true
}
],
'keyword-spacing': [
2,
{
before: true,
after: true
}
],
'new-cap': [
2,
{
newIsCap: true,
capIsNew: false
}
],
'new-parens': 2,
'no-array-constructor': 2,
'no-caller': 2,
'no-console': 'off',
'no-class-assign': 2,
'no-cond-assign': 2,
'no-const-assign': 2,
'no-control-regex': 0,
'no-delete-var': 2,
'no-dupe-args': 2,
'no-dupe-class-members': 2,
'no-dupe-keys': 2,
'no-duplicate-case': 2,
'no-empty-character-class': 2,
'no-empty-pattern': 2,
'no-eval': 2,
'no-ex-assign': 2,
'no-extend-native': 2,
'no-extra-bind': 2,
'no-extra-boolean-cast': 2,
'no-extra-parens': [2, 'functions'],
'no-fallthrough': 2,
'no-floating-decimal': 2,
'no-func-assign': 2,
'no-implied-eval': 2,
'no-inner-declarations': [2, 'functions'],
'no-invalid-regexp': 2,
'no-irregular-whitespace': 2,
'no-iterator': 2,
'no-label-var': 2,
'no-labels': [
2,
{
allowLoop: false,
allowSwitch: false
}
],
'no-lone-blocks': 2,
'no-mixed-spaces-and-tabs': 2,
'no-multi-spaces': 2,
'no-multi-str': 2,
'no-multiple-empty-lines': [
2,
{
max: 1
}
],
'no-native-reassign': 2,
'no-negated-in-lhs': 2,
'no-new-object': 2,
'no-new-require': 2,
'no-new-symbol': 2,
'no-new-wrappers': 2,
'no-obj-calls': 2,
'no-octal': 2,
'no-octal-escape': 2,
'no-path-concat': 2,
'no-proto': 2,
'no-redeclare': 2,
'no-regex-spaces': 2,
'no-return-assign': [2, 'except-parens'],
'no-self-assign': 2,
'no-self-compare': 2,
'no-sequences': 2,
'no-shadow-restricted-names': 2,
'no-spaced-func': 2,
'no-sparse-arrays': 2,
'no-this-before-super': 2,
'no-throw-literal': 2,
'no-trailing-spaces': 2,
'no-undef': 2,
'no-undef-init': 2,
'no-unexpected-multiline': 2,
'no-unmodified-loop-condition': 2,
'no-unneeded-ternary': [
2,
{
defaultAssignment: false
}
],
'no-unreachable': 2,
'no-unsafe-finally': 2,
'no-unused-vars': [
2,
{
vars: 'all',
args: 'none'
}
],
'no-useless-call': 2,
'no-useless-computed-key': 2,
'no-useless-constructor': 2,
'no-useless-escape': 0,
'no-whitespace-before-property': 2,
'no-with': 2,
'one-var': [
2,
{
initialized: 'never'
}
],
'operator-linebreak': [
2,
'after',
{
overrides: {
'?': 'before',
':': 'before'
}
}
],
'padded-blocks': [2, 'never'],
quotes: [
2,
'single',
{
avoidEscape: true,
allowTemplateLiterals: true
}
],
semi: [2, 'never'],
'semi-spacing': [
2,
{
before: false,
after: true
}
],
'space-before-blocks': [2, 'always'],
'space-before-function-paren': [2, 'never'],
'space-in-parens': [2, 'never'],
'space-infix-ops': 2,
'space-unary-ops': [
2,
{
words: true,
nonwords: false
}
],
'spaced-comment': [
2,
'always',
{
markers: ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
}
],
'template-curly-spacing': [2, 'never'],
'use-isnan': 2,
'valid-typeof': 2,
'wrap-iife': [2, 'any'],
'yield-star-spacing': [2, 'both'],
yoda: [2, 'never'],
'prefer-const': 2,
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'object-curly-spacing': [
2,
'always',
{
objectsInObjects: false
}
],
'array-bracket-spacing': [2, 'never']
}
}
.DS_Store
node_modules
/dist
/docs
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
package-lock.json
yarn.lock
\ No newline at end of file
// https://github.com/michael-ciniawsky/postcss-load-config
module.exports = {
plugins: {
autoprefixer: {
overrideBrowserslist: ['Android 4.1', 'iOS 7.1', 'Chrome > 31', 'ff > 31', 'ie >= 8']
},
// 'postcss-pxtorem': {
// rootValue: 37.5,
// propList: ['*'],
// selectorBlackList: ['van-','ignore','ign-','.hairlines']
// },
'postcss-px-to-viewport': {
viewportWidth: 375, // 视窗的宽度,对应的是我们设计稿的宽度,一般是750
unitPrecision: 3, // 指定`px`转换为视窗单位值的小数位数(很多时候无法整除)
viewportUnit: 'vw', // 指定需要转换成的视窗单位,建议使用vw
selectorBlackList: ['.ignore', '.hairlines', 'ign-'], // 指定不转换为视窗单位的类,可以自定义,可以无限添加,建议定义一至两个通用的类名
minPixelValue: 1, // 小于或等于`1px`不转换为视窗单位,你也可以设置为你想要的值
mediaQuery: false // 允许在媒体查询中转换`px`
}
}
}
\ No newline at end of file
{
"printWidth": 200,
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "none",
"semi": false,
"wrap_line_length": 120,
"wrap_attributes": "auto",
"proseWrap": "always",
"arrowParens": "avoid",
"bracketSpacing": true,
"htmlWhitespaceSensitivity": "ignore",
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"jsxBracketSameLine": true,
"files.insertFinalNewline": true,
"useTabs": false,
"eslintIntegration": true,
"overrides": [
{
"files": ".prettierrc",
"options": {
"parser": "json"
}
}
],
"endOfLine": "auto"
}
File mode changed
This diff is collapsed. Click to expand it.
// 获取 VUE_APP_ENV 非 NODE_ENV,测试环境依然 console
const IS_PROD = ['production', 'prod'].includes(process.env.VUE_APP_ENV)
const plugins = [
[
'import',
{
libraryName: 'vant',
libraryDirectory: 'es',
style: true
},
'vant'
]
]
// 去除 console.log
if (IS_PROD) {
plugins.push('transform-remove-console')
}
module.exports = {
presets: [['@vue/cli-plugin-babel/preset', { useBuiltIns: 'usage', corejs: 3 }]],
plugins
}
{
"name": "upload-images-h5",
"version": "1.0.0",
"description": "GH Hall By Work WeChat",
"author": "limin <limin.mail@qq.com>",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --open",
"build": "vue-cli-service build",
"stage": "vue-cli-service build --mode staging",
"lint": "vue-cli-service lint --fix",
"dev": "npm run serve"
},
"dependencies": {
"autoprefixer": "^8.0.0",
"core-js": "^3.6.4",
"glsx-common": "^1.4.8",
"postcss-loader": "^6.2.0",
"sass-loader": "^7.3.1",
"sha1": "^1.1.1",
"storejs": "^1.1.0",
"vant": "^2.12.21",
"vconsole": "^3.7.0",
"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",
"babel-plugin-import": "^1.13.0",
"babel-plugin-transform-remove-console": "^6.9.4",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"node-sass": "^4.14.1",
"postcss-px-to-viewport": "^1.1.1",
"postcss-pxtorem": "^5.1.1",
"script-ext-html-webpack-plugin": "^2.1.4",
"vue-loader": "^15.9.8",
"vue-template-compiler": "^2.6.11",
"webpack-bundle-analyzer": "^3.8.0"
}
}
No preview for this file type
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<% for (var i in htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.css) { %>
<link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="preload" as="style" />
<link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="stylesheet" />
<% } %>
<title>
<%= webpackConfig.name %>
</title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= webpackConfig.name %> doesn't work properly without JavaScript enabled. Please enable it
to continue.</strong>
</noscript>
<div id="app"></div>
<script src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js"></script>
<!-- 使用CDN加速的JS文件,配置在vue.config.js下 -->
<% for (var i in htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.js) { %>
<script src="<%= htmlWebpackPlugin.options.cdn.js[i] %>"></script>
<% } %>
<!-- built files will be auto injected -->
</body>
</html>
<template>
<div id="app">
<template v-if="showWindow">
<transition name="fade">
<keep-alive v-if="$route.meta.keepAlive">
<router-view></router-view>
</keep-alive>
</transition>
<transition name="fade">
<router-view v-if="!$route.meta.keepAlive"></router-view>
</transition>
</template>
</div>
</template>
<script>
export default {
name: 'App',
data() {
return {
showWindow: false
}
},
watch: {
watchFlag: {
immediate: true,
handler(newval) {
this.showWindow = newval
this.hideLoading()
}
}
},
computed: {
watchFlag() {
return this.$store.state.app.showWindow
}
}
}
</script>
<style lang="scss"></style>
/*
* @Descripttion:API 统一外部调用入口
* @version: 1.0.0
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-17 18:23:27
*/
import upload from './upload'
export {
upload,
}
\ No newline at end of file
const url = '/rop-scrm-equity/router'
export default {
/**获取员工销售的无忧卡订单列表 */
orderListApi(data) {
data.method = 'scrm.api.equity.service.h5.service.order.get'
return window.$HTTP({
url,
data,
returnAll: false
})
},
/**获取列表总数 */
orderCountApi(data){
data.method = 'scrm.api.equity.service.h5.service.order.dataprefection.count'
return window.$HTTP({
url,
data,
returnAll: false
})
},
/**获取附件值 */
fileDataApi(data) {
data.method = 'scrm.api.equity.service.package.order.attachments.value.get.multiple'
return window.$HTTP({
url,
data,
returnAll: true
})
},
/**获取附件信息 */
fileInfoApi(data) {
data.method = 'scrm.api.equity.service.package.order.attachment.get'
return window.$HTTP({
url,
data,
returnAll: true
})
},
/**上传附件 */
uploadFileApi(data) {
data.method = 'scrm.api.equity.service.order.attachment.add'
return window.$HTTP({
url,
data,
returnAll: true
})
},
/**删除附件 */
deleteFileApi(data) {
data.method = 'scrm.api.equity.service.order.attachment.delete'
return window.$HTTP({
url,
data,
returnAll: true
})
},
/**上传图片 */
uploadImageApi(data){
data.method = 'scrm.api.equity.common.upload.image'
return window.$HTTP({
url,
data,
returnAll: true,
sign: true,
noSignAttr: ['file'],
})
}
}
@import './normalize.scss';
*{
margin: 0;
padding: 0;
}
html,
body .app {
color: #333333;
font-family: Arial, Helvetica, 'STHeiti STXihei', 'Microsoft YaHei', Tohoma, sans-serif;
background-color: #fff;
-webkit-overflow-scrolling: touch;
height: 100%;
// overflow: hidden;
}
img {
width: 100%;
height: 100%;
vertical-align: top;
}
.flex {
display: flex;
align-items: center;
}
.text-hide {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.text-two-line {
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 2;
display: -webkit-box;
-webkit-box-orient: vertical;
word-break: break-all;
}
.text-center {
display: flex;
align-items: center;
justify-content: center;
}
.x-center {
position: absolute;
left: 50%;
transform: translateX(-50%);
}
.y-center {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.sticky {
position: static;
}
<template>
<van-empty class="custom-image" :image="empty" :description="description" />
</template>
<script>
export default {
name: 'empty',
data() {
return {
empty: require('../assets/images/empty.png')
}
},
props: {
description: {
type: String,
default: '暂无数据'
}
}
}
</script>
<style lang="scss" scoped>
.custom-image {
padding-top: 79px;
}
.custom-image /deep/ .van-empty__image {
width: 88px;
height: 56px;
}
</style>
\ No newline at end of file
<template>
<div class="hint-tip">
<div class="tip-title">{{ title }}</div>
<div class="tip-date" v-if="time">{{ time }}</div>
</div>
</template>
<script>
export default {
name: 'tip',
data() {
return {
time: this.date
}
},
props: {
title: {
type: String,
default: ''
},
date: {
type: String,
default: ''
}
},
methods: {}
}
</script>
<style lang="scss" scoped>
.hint-tip {
margin: 0 16px;
height: 40px;
line-height: 40px;
background: #f7f7f7;
box-shadow: 0px 1px 0px 0px #e9e9e9;
box-sizing: border-box;
display: flex;
justify-content: center;
justify-content: space-between;
.tip-title {
color: #545454;
font-size: 16px;
text-align: left;
letter-spacing: 0px;
}
.tip-date {
font-size: 12px;
font-weight: 500;
color: #545454;
line-height: 20px;
}
}
</style>
\ No newline at end of file
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-08 19:20:13
* @LastEditors: limin
* @LastEditTime: 2021-06-25 18:09:28
*/
import Vue from 'vue'
const componentsFiles = require.context(`./`, true, /.vue$/)
componentsFiles.keys().forEach(path => {
const component = componentsFiles(path).default
Vue.component(component.name, component)
})
// export default [Icon, NavBar, TabBar, Organization, CustomerList, CustomerDetail, OrderList, OrderDetail, TimerTabs, CarType, RadioCell, CheckBoxCell, ValidateField]
\ No newline at end of file
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-08 16:55:43
*/
// 根据环境引入不同配置 process.env.VUE_APP_ENV
const environment = process.env.VUE_APP_ENV || 'production'
let config = require('./env.' + environment)
module.exports = config
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-28 10:13:38
*/
// 本地环境配置
module.exports = {
title: '图片上传',
request: {
// baseURL: 'http://scrm.test.glsx.com.cn/scrm-wechat' // 测试项目地址
baseURL: 'http://192.168.1.5:8083/scrm-wechat' // 测试项目地址
},
APPID: 'xxx',
APPSECRET: 'xxx',
cdn: 'https://www.xxx.cn/static'
}
\ No newline at end of file
module.exports = {
title: '图片上传',
request: {
// baseURL: 'http://ghwx.cgacar.com/scrm-wechat' // 生产
baseURL: 'http://cim.chinagrandauto.com/scrm-wechat' // 生产
// baseURL: 'http://cim.chinagrandauto.com' // 生产
},
APPID: 'xxx',
APPSECRET: 'xxx',
cdn: 'https://www.xxx.cn/static'
}
\ No newline at end of file
module.exports = {
title: '图片上传',
request: {
baseURL: 'http://xxxxx' // 项目地址
},
APPID: 'xxx',
APPSECRET: 'xxx',
cdn: 'https://www.xxx.cn/static'
}
\ No newline at end of file
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-30 11:23:25
*/
// 根据环境引入不同配置 process.env.VUE_APP_ENV
let config = require('./conf.js')
let timeout = 30000 //超时时间
export const fetchConfig = function(isEnv = true) {
if (isEnv) {
let { request } = config
Object.assign(request, { timeout })
return Promise.resolve(config)
}
return window.fetch('https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=file-uploader').then(res => res.json())
}
export const cfg = {
install(vue, config) {
vue.prototype.$config = config
}
}
\ No newline at end of file
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-29 15:35:47
*/
// 兼容 IE
// https://github.com/zloirock/core-js/blob/master/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md#babelpolyfill
// import 'core-js/stable'
// import 'regenerator-runtime/runtime'
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import api from './api'
import { fetchConfig, cfg } from '@/config'
import '@/assets/css/index.scss'
import { bus, store as local, util } from './utils'
import './utils/util'
import 'components'
import { components } from '@/plugins/vant'
components.forEach(component => Vue.use(component))
Vue.prototype.api = api
Vue.prototype.bus = bus
Vue.prototype.local = local
Vue.prototype.to = function (name, params) {
if (name === -1) {
router.go(-1)
return
}
router.push({ name, params })
}
// 移动端适配 rem
// import 'lib-flexible/flexible.js'
Vue.config.productionTip = false
import VConsole from 'vconsole'
const isMock = true
fetchConfig(!isMock).then(res => {
// 添加本地修改配置
// 从配置服务器获取动态配置
// 设置 js中可以访问 $cdn
Vue.use(cfg)
window.$fetchConfig = res.data
if (res.data.vconsole) new VConsole()
/**登录过期 重新登录 */
window.reLogin = () => {
util.clearSessionId()
store.dispatch('navigation')
}
window.vm = new Vue({
el: '#app',
router,
store,
render: h => h(App)
})
})
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-23 11:44:59
*/
// 按需全局引入 vant组件
import {
Button,
NavBar,
Image as VanImage,
Field,
Uploader,
Icon,
Empty,
Dialog,
Overlay,
loading,
} from 'vant'
export const components = [
Button,
NavBar,
VanImage,
Field,
Uploader,
Icon,
Empty,
Dialog,
Overlay,
loading,
]
\ No newline at end of file
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-09 17:11:43
*/
import router from './router'
import { keeps } from './routes'
export const keepAlives = keeps
export default router
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-09 10:59:50
* @LastEditors: limin
* @LastEditTime: 2021-06-29 14:51:39
*/
import Vue from 'vue'
import Router from 'vue-router'
import routes from './routes'
import store from '@/store'
// hack router push callback
const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) {
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
return originalPush.call(this, location).catch(err => err)
}
Vue.use(Router)
const router = createRouter()
function createRouter() {
return new Router({
// mode: 'history', // 如果是 history模式 需要配置vue.config.js publicPath
base: process.env.BASE_URL,
scrollBehavior: function(to, from, savedPosition) {
return savedPosition || { x: 0, y: 0 }
},
routes
})
}
// http://scrm.dev.glsx.com.cn/dj-scrm-wx-work-attachment-activity/
router.beforeEach((to, from, next) => {
/* 路由发生变化修改页面title */
if (to.meta.title) {
store.dispatch('setPageMeta', to.meta)
} else {
store.dispatch('setPageMeta', { title: '图片上传' })
}
store.commit('SET_LAST_PATH', to.name)
/* 路由发生变化修改页面背景色 */
document.documentElement.style.backgroundColor = to.meta.backgroundColor || '#fff'
if (to.matched.some(recode => recode.meta.noAuth)) {
store.state.app.showWindow = true
} else {
store.dispatch('navigation')
}
next()
})
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
const newRouter = createRouter()
router.matcher = newRouter.matcher // reset router
}
export default router
\ No newline at end of file
const pages = {
upload:[{
name:'index',
meta:{
title:'图片上传',
backgroundColor:'#F7F7F7',
}
}]
}
const redirect = 'upload'
let routes = []
const keepAlives = []
Object.keys(pages).map(parent => {
pages[parent].map(val => {
const isIndex = parent == redirect && val.name == 'index'
let childrenPath = `${parent}/${val.name}`
let { meta } = val
const path = isIndex ?
'/' :
`/${val.name == 'index' ? parent : childrenPath}`
const name = val.name == 'index' ? parent : childrenPath.replace('/', '.')
if (meta && meta.keepAlive) keepAlives.push(name)
let route = {
component: resolve => require([`views/${childrenPath}.vue`], resolve),
path,
name,
meta
}
routes.push(route)
})
})
export const keeps = keepAlives
export default routes
\ No newline at end of file
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-20 12:49:54
* @FilePath: \gh-hall\src\store\getters.js
*/
const getters = {
app: state => state.app
}
export default getters
import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
import app from './modules/app'
// import createPersistedState from "vuex-persistedstate"
Vue.use(Vuex)
const store = new Vuex.Store({
modules: {
app
},
getters
// plugins: [createPersistedState({
// //指定存储模式
// storage: window.sessionStorage
// })]
})
export default store
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-07-06 12:02:21
*/
import { store, util } from 'utils'
import { Http } from 'glsx-common'
import { Notify } from 'vant'
const state = {
pageMeta: '',
keepAlives: [],
lastPath: ''
}
const mutations = {
SET_PAGE_META(state, meta) {
state.pageMeta = meta
},
PUSH_KEEP(state, name) {
if (!state.keepAlives.includes(name)) {
state.keepAlives.push(name)
}
},
REMOVE_KEEP(state, names) {
state.keepAlives = state.keepAlives.reduce((arr, name) => {
if (!names.includes(name)) {
return arr.push(name)
}
return arr
}, [])
},
SET_LAST_PATH(state, path) {
state.lastPath = path
}
}
const actions = {
setPageMeta({ commit }, meta) {
document.title = meta.title
commit('SET_PAGE_META', meta)
},
setLoginToken({ commit }, val) {
commit('SET_LOGIN_TOKEN', val)
},
setAccountList({ commit }, list) {
commit('SET_ACCOUNT_LIST', list)
},
pushKeep({ commit }, name) {
commit('PUSH_KEEP', name)
},
removeKeep({ commit }, names) {
commit('REMOVE_KEEP', names)
},
login({ dispatch }) {
},
navigation({ dispatch }) {
state.showWindow = true
},
registerHttp({}, sessionId = '') {
window.$HTTP = new Http({ ...window.$fetchConfig, alert: Notify, headers: { token: sessionId } })
}
}
const getParams = name => {
let [url, paramsList] = window.location.href.split('?')
if (!paramsList) return name ? null : {}
let param = paramsList.split('&')
let obj = {}
param.map(e => {
let [key, value] = e.split('=')
obj[key] = value
})
return name ? obj[name] : obj
}
export default {
state,
mutations,
actions
}
\ No newline at end of file
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-20 12:49:11
*/
import util from './util'
import store from './store'
export { store ,util}
\ No newline at end of file
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-15 14:46:31
* @LastEditors: limin
* @LastEditTime: 2021-06-20 12:49:04
*/
import store from 'storejs'
export default {
...store,
exp: {
set: function(key, val, exp = 24 * 60 * 60 * 1000) {
store.set(key, { val: val, exp: exp, time: new Date().getTime() })
},
get: function(key) {
var info = store.get(key)
if (!info) {
return null
}
if (new Date().getTime() - info.time > info.exp) {
store.remove(key)
return null
}
return info.val
}
},
consts: {
USER_KEY: 'USER_KEY',
}
}
\ No newline at end of file
import Vue from 'vue'
import {
Toast,
Dialog
} from 'vant'
/**
* 日期格式化
* let time = new Date().format('yyyy-MM-dd hh:mm:ss')
*/
Date.prototype.format = function(fmt) {
let o = {
'M+': this.getMonth() + 1, //月份
'd+': this.getDate(), //日
'h+': this.getHours(), //小时
'm+': this.getMinutes(), //分
's+': this.getSeconds(), //秒
//季度
'q+': Math.floor((this.getMonth() + 3) / 3),
'S': this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
}
for (let 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
}
/**防止重复点击 */
const showLoading = (title = '加载中...') => {
Toast({
type: 'loading',
message: title,
forbidClick: true,
duration: 0
})
}
const hideLoading = () => {
Toast.clear()
}
const showToast = (message = '', callBack) => {
let params = {
message,
forbidClick: true,
duration: 1500
}
Toast(params)
if (callBack && typeof callBack == 'function') {
setTimeout(() => {
callBack()
}, 1500)
}
}
const setSessionId = val => {
window.localStorage.setItem('dj_scrm_session_id', val)
}
const getSessionId = () => {
return window.localStorage.getItem('dj_scrm_session_id')
}
const clearSessionId = () => {
window.localStorage.removeItem('dj_scrm_session_id')
}
const setLocalStorage = (key, item) => {
window.localStorage.setItem(key, JSON.stringify(item))
}
const getLocalStorage = key => {
return JSON.parse(window.localStorage.getItem(key))
}
const removeLocalStorage = key => {
window.localStorage.removeItem(key)
}
const dialog = (params = {}) => {
if (!params.confirmButtonColor) params.confirmButtonColor = '#FF7336'
return Dialog.confirm(params)
}
const getParams = () => {
return window.vm.$route.params
}
const getQuery = () => {
return window.vm.$route.query
}
const utils = {
removeLocalStorage,
setLocalStorage,
getLocalStorage,
clearSessionId,
setSessionId,
getSessionId,
showLoading,
hideLoading,
showToast,
getParams,
dialog,
getQuery
}
Object.keys(utils).map(key => {
Vue.prototype[key] = utils[key]
})
export default utils
\ No newline at end of file
<template>
<div class="app-container">
<div class="layout-content">
<!-- <NavBar :meta="app.pageMeta"> -->
<!-- <keep-alive v-if="$route.meta.keepAlive">
<router-view></router-view>
</keep-alive>
<router-view v-else></router-view> -->
<!--缓存想要缓存的页面,实现后退不刷新-->
<!--加上v-if的判断,可以自定义想要缓存的组件,自定义在router里面-->
<div class="container">
<transition
:name="app.transitionName"
mode="out-in"
>
<keep-alive :include="app.keepAlives">
<router-view />
</keep-alive>
</transition>
</div>
<!-- </NavBar> -->
</div>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
name: 'AppLayout',
computed: {
...mapGetters(['app'])
}
}
</script>
<style lang="scss" scoped>
// .app-container {
// .layout-content {
// .container {
// height: calc(100vh - 46px);
// }
// }
// }
</style>
<template>
<div class="contaienr">
<div class="upload_box_wrapper">
<div class="title flex_scb">
<span class="require">*</span>
<span>基础资料</span>
</div>
<div class="main_pannel" @click="toClickUpoload()">
<van-uploader
:before-delete="beforeDelete"
v-on:click-upload="beforeRead"
:before-read="checkRead"
:after-read="afterRread"
:preview-size="size"
max-count="4"
>
<div class="box_wrap flex_ccc" :style="{ width: size, height: size }">
<van-icon name="add-o" size="20px" color="#999999" />
<p>添加</p>
</div>
</van-uploader>
</div>
</div>
</div>
</template>
<script>
import { upload } from '@/api'
const baseImg = 'https://img01.glsx.com.cn/weapp/resource/equity-h5-new/mini/'
export default {
data() {
return {
imgBase: baseImg,
fileList: [
{
url: 'http://qcimg01.glsx.com.cn/group1/M00/00/6F/wKgD3mINtxWAV8xYAAF0Ps_hc1c683.png',
isImage: true
}
],
uploadList: [],
fileURL: {},
loadingFinish: false,
size: '102px'
}
},
created() {
this.computedWidth()
},
mounted() {
},
methods: {
getQuery() {
return window.vm.$route.query
},
// 根据手机屏幕宽度计算图片宽度
computedWidth() {
const screen = window.screen.width
const imageW = (screen - (16 * 2 + 10 * 2 + 8 * 3)) / 3
this.size = `${imageW}px`
},
// 获取附件信息
getFileInof(packageCode, contractNo) {
upload.fileInfoApi({ packageCode }).then(res => {
this.uploadList = res.data
this.getFileValue(contractNo, res.data)
})
},
// 获取附件信息的值
getFileValue(contractNo, list) {
upload.fileDataApi({ contractNo }).then(res => {
if (res.code == 0) {
this.fileURL = {}
res.data.forEach(el => {
list.forEach(item => {
if (el.attachmentCode === item.attachmentCode) {
let name = `${item.attachmentCode}`
let newArr = []
el.attachmentFiles.forEach(str => {
let temp = {
url: str,
isImage: true
}
newArr.push(temp)
})
let obj = {
[name]: newArr
}
this.fileURL = Object.assign(this.fileURL, obj)
}
})
})
this.loadingFinish = true
}
})
},
// 获取当前点击的位置
toClickUpoload() {
},
beforeRead(e) {
},
checkRead(file) {
if (file.size > 1024) {
this.showLoading()
return true
}
return true
},
afterRread(file, e) {
this.uploadImage(file)
},
beforeDelete(file, e) {
this.currentDelImg = file.url
this.deleteFile()
},
// 上传图片
uploadImage(file) {
const imgFile = file.content
//两种写法
// 1.substring字符串截取 2.split方法截取 比如:let temp = file.name.split('.');temp = temp[temp.length-1]
let fileName = file.file.name
let index = fileName.lastIndexOf('.')
fileName = fileName.substring(index + 1, fileName.length)
const base64 = fileName + '@' + imgFile.split(',')[1]
let para = {
file: base64,
fileType: 'image'
}
this.hideLoading()
// this.showLoading()
// upload.uploadImageApi(para).then(res => {
// if (res.code == 0) {
// this.uploadFile(res.data)
// } else {
// this.showToast(res.message)
// }
// })
},
// 上传附件
uploadFile(url) {
let para = {
contractNo: this.contractNo,
attachmentCode: this.currentItem.attachmentCode,
attachmentType: this.currentItem.attachmentType,
attachmentFile: url
}
upload.uploadFileApi(para).then(res => {
this.hideLoading()
this.getFileInof(this.packageCode, this.contractNo)
})
},
// 删除附件
deleteFile() {
let para = {
contractNo: this.contractNo,
attachmentFile: this.currentDelImg
}
upload.deleteFileApi(para).then(res => {
this.getFileInof(this.packageCode, this.contractNo)
})
}
}
}
</script>
<style lang="scss" scoped>
.flex_ccc {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.flex_scb {
display: flex;
align-items: center;
}
.contaienr {
padding: 10px 16px;
.upload_box_wrapper {
width: 100%;
min-height: 156px;
padding-bottom: 16px;
background: #ffffff;
box-shadow: 0px 4px 8px 0px rgba(224, 224, 224, 0.5);
border-radius: 4px;
margin-bottom: 10px;
.title {
box-sizing: border-box;
padding: 16px 10px;
font-size: 16px;
color: #333333;
font-weight: 600;
.require {
font-size: 16px;
color: #fe4b00;
font-weight: 500;
}
}
.main_pannel {
box-sizing: border-box;
padding: 0 10px;
display: flex;
flex-wrap: wrap;
.box_wrap {
width: 102px;
height: 102px;
background: #f5f6fa;
> p {
font-size: 16px;
color: #999999;
font-weight: 400;
margin-top: 10px;
}
}
.deleteWrap {
position: absolute;
left: 0;
top: 0;
height: 20px;
width: 20px;
z-index: 999;
> img {
height: 20px;
width: 20px;
}
}
}
.main_pannel /deep/ .van-uploader__preview-delete {
left: 0;
width: 20px;
height: 20px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
background: #3975c6;
background-image: url('https://img01.glsx.com.cn/weapp/resource/equity-h5-new/mini/deleteIcon.png');
background-size: 20px 20px;
> i {
display: none;
}
}
}
}
</style>
'use strict'
const path = require('path')
const defaultSettings = require('./src/config/conf.js')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const resolve = dir => path.join(__dirname, dir)
// page title
const name = defaultSettings.title || 'vue mobile template'
// 生产环境,测试和正式
const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV)
// externals
// const externals = {
// vue: 'Vue',
// 'vue-router': 'VueRouter',
// vuex: 'Vuex',
// vant: 'vant',
// axios: 'axios'
// }
// CDN外链,会插入到index.html中
// const cdn = {
// // 开发环境
// dev: {
// css: [],
// js: []
// },
// // 生产环境
// build: {
// css: ['https://cdn.jsdelivr.net/npm/vant@2.4.7/lib/index.css'],
// js: [
// 'https://cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js',
// 'https://cdn.jsdelivr.net/npm/vue-router@3.1.5/dist/vue-router.min.js',
// 'https://cdn.jsdelivr.net/npm/axios@0.19.2/dist/axios.min.js',
// 'https://cdn.jsdelivr.net/npm/vuex@3.1.2/dist/vuex.min.js',
// 'https://cdn.jsdelivr.net/npm/vant@2.4.7/lib/index.min.js'
// ]
// }
// }
/**
* 雪碧图插件
*/
// const SpritesmithPlugin = require('webpack-spritesmith')
// const spritesmithFunction = data => {
// let { spritesheet, sprites } = data
// let shared = `.sprite-icon { background-image: url(${data.sprites[0].image});background-size: ${spritesheet.width / 2}px ${spritesheet.height / 2}px;}`
// let perSprite = sprites.map(sprite => {
// let { name, width, height, offset_x, offset_y } = sprite
// return `.icon-${name} { width: ${width / 2}px; height: ${height / 2}px; background-position: ${offset_x / 2}px ${offset_y / 2}px;}`
// }).join('\n')
// return `${shared}\n${perSprite}`
// }
module.exports = {
// publicPath: IS_PROD ? './' : '/dj-scrm-wx-group-chat/', // 署应用包时的基本 URL。 vue-router hash 模式使用
// publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-main-test/', // 署应用包时的基本 URL。 vue-router hash 模式使用
// publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-attachment-customer/', // 署应用包时的基本 URL。 vue-router hash 模式使用
// publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-file-upload/', // 署应用包时的基本 URL。 vue-router hash 模式使用
publicPath: '/dj-scrm-wx-work-main-bw/', // 署应用包时的基本 URL。 vue-router history模式使用
outputDir: 'dist', // 生产环境构建文件的目录
assetsDir: 'static', // outputDir的静态资源(js、css、img、fonts)目录
lintOnSave: !IS_PROD,
productionSourceMap: false, // 如果不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
devServer: {
disableHostCheck: true,
port: 9527, // 端口
open: false, // 启动后打开浏览器
overlay: {
// 当出现编译器错误或警告时,在浏览器中显示全屏覆盖层
warnings: false,
errors: true
}
// proxy: {
// //配置跨域
// '/api': {
// target: "https://test.xxx.com",
// // ws:true,
// changOrigin:true,
// pathRewrite:{
// '^/api':'/'
// }
// }
// }
},
css: {
extract: IS_PROD, // 是否将组件中的 CSS 提取至一个独立的 CSS 文件中 (而不是动态注入到 JavaScript 中的 inline 代码)。
sourceMap: false,
loaderOptions: {
scss: {
// 向全局sass样式传入共享的全局变量, $src可以配置图片cdn前缀
// 详情: https://cli.vuejs.org/guide/css.html#passing-options-to-pre-processor-loaders
prependData: `
$cdn: "${defaultSettings.cdn}";
`
}
}
},
configureWebpack: config => {
config.name = name
// config.resolve.modules = ['node_modules', './src/assets/spritesmith']
const Plugins = [
// new SpritesmithPlugin({
// // 引入图片文件夹
// src: {
// cwd: path.resolve(__dirname, './src/assets/spritesmith'),
// glob: ['*.png', '*.jpg']
// },
// // 生成图片的路径
// target: {
// image: path.resolve(__dirname, './src/assets/images/sprite.png'),
// // 生成SCSS
// css: [
// [path.resolve(__dirname, './src/assets/css/sprite.scss'), {
// format: 'function_based_template'
// }]
// ]
// },
// // customTemplates: {
// // 'function_based_template': spritesmithFunction,
// // },
// //background引用路径
// apiOptions: {
// cssImageRef: '../images/sprite.png'
// },
// // 每个图片间距
// spritesmithOptions: {
// padding: 20
// }
// })
]
config.plugins = [...config.plugins, ...Plugins]
// 为生产环境修改配置...
// if (IS_PROD) {
// // externals
// config.externals = externals
// }
},
chainWebpack: config => {
config.plugins.delete('preload') // TODO: need test
config.plugins.delete('prefetch') // TODO: need test
// 别名 alias
config.resolve.alias
.set('@', resolve('src'))
.set('assets', resolve('src/assets'))
.set('api', resolve('src/api'))
.set('views', resolve('src/views'))
.set('components', resolve('src/components'))
.set('plugins', resolve('src/components'))
.set('utils', resolve('src/utils'))
/**
* 添加CDN参数到htmlWebpackPlugin配置中
*/
// config.plugin('html').tap(args => {
// if (IS_PROD) {
// args[0].cdn = cdn.build
// } else {
// args[0].cdn = cdn.dev
// }
// return args
// })
/**
* 设置保留空格
*/
config.module
.rule('vue')
.use('vue-loader')
.loader('vue-loader')
.tap(options => {
options.compilerOptions.preserveWhitespace = true
return options
})
.end()
/**
* 打包分析
*/
if (IS_PROD) {
config.plugin('webpack-report').use(BundleAnalyzerPlugin, [{
analyzerMode: 'static'
}])
}
config
// https://webpack.js.org/configuration/devtool/#development
.when(!IS_PROD, config => config.devtool('cheap-source-map'))
config.when(IS_PROD, config => {
config
.plugin('ScriptExtHtmlWebpackPlugin')
.after('html')
.use('script-ext-html-webpack-plugin', [{
// 将 runtime 作为内联引入不单独存在
inline: /runtime\..*\.js$/
}])
.end()
config.optimization.splitChunks({
chunks: 'all',
cacheGroups: {
// cacheGroups 下可以可以配置多个组,每个组根据test设置条件,符合test条件的模块
commons: {
name: 'chunk-commons',
test: resolve('src/components'),
minChunks: 3, // 被至少用三次以上打包分离
priority: 5, // 优先级
reuseExistingChunk: true // 表示是否使用已有的 chunk,如果为 true 则表示如果当前的 chunk 包含的模块已经被抽取出去了,那么将不会重新生成新的。
},
node_vendors: {
name: 'chunk-libs',
chunks: 'initial', // 只打包初始时依赖的第三方
test: /[\\/]node_modules[\\/]/,
priority: 10
},
vantUI: {
name: 'chunk-vantUI', // 单独将 vantUI 拆包
priority: 20, // 数字大权重到,满足多个 cacheGroups 的条件时候分到权重高的
test: /[\\/]node_modules[\\/]_?vant(.*)/
}
}
})
config.optimization.runtimeChunk('single')
})
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!