├── src ├── store │ ├── modules │ │ ├── index │ │ │ ├── mutations_types.js │ │ │ └── index.js │ │ └── login │ │ │ ├── mutations_types.js │ │ │ └── index.js │ └── index.js ├── style │ ├── _variables.scss │ ├── common.scss │ └── _mixin.scss ├── assets │ ├── logo.png │ ├── pwd_ico.png │ └── phone_ico.png ├── components │ └── HelloWorld.vue ├── common │ └── wechat │ │ ├── index.js │ │ └── wechat.js ├── api │ └── index.js ├── store.js ├── main.js ├── filters │ └── index.js ├── views │ ├── Home.vue │ ├── About.vue │ └── login.vue ├── App.vue ├── router.js └── axios │ └── http.js ├── .browserslistrc ├── .env ├── babel.config.js ├── public ├── favicon.ico └── index.html ├── .env.production ├── postcss.config.js ├── .editorconfig ├── .gitignore ├── README.md ├── .eslintrc.js ├── package.json └── vue.config.js /src/store/modules/index/mutations_types.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/style/_variables.scss: -------------------------------------------------------------------------------- 1 | $color-main:red; 2 | -------------------------------------------------------------------------------- /.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not ie <= 8 4 | -------------------------------------------------------------------------------- /.env: -------------------------------------------------------------------------------- 1 | NODE_ENV = 'development' 2 | BASE_URL = '/' 3 | VUE_APP_BASE_API = '' -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/app' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /src/store/modules/login/mutations_types.js: -------------------------------------------------------------------------------- 1 | export const LOGIN = 'LOGIN'// 获取用户信息 2 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiuyu303/vue-cli3-H5/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiuyu303/vue-cli3-H5/HEAD/src/assets/logo.png -------------------------------------------------------------------------------- /src/assets/pwd_ico.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiuyu303/vue-cli3-H5/HEAD/src/assets/pwd_ico.png -------------------------------------------------------------------------------- /.env.production: -------------------------------------------------------------------------------- 1 | NODE_ENV = 'production' 2 | BASE_URL = './' 3 | VUE_APP_BASE_API = 'https://easy-mock.com/' -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | autoprefixer: {} 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/assets/phone_ico.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiuyu303/vue-cli3-H5/HEAD/src/assets/phone_ico.png -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.{js,jsx,ts,tsx,vue}] 2 | indent_style = space 3 | indent_size = 4 4 | trim_trailing_whitespace = true 5 | insert_final_newline = true 6 | -------------------------------------------------------------------------------- /src/store/modules/index/index.js: -------------------------------------------------------------------------------- 1 | export default { 2 | namespaced: true, 3 | data: { 4 | }, 5 | mutations: { 6 | 7 | }, 8 | actions: { 9 | }, 10 | getters: { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/components/HelloWorld.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 9 | 14 | -------------------------------------------------------------------------------- /src/common/wechat/index.js: -------------------------------------------------------------------------------- 1 | const wx = require('./wechat.js').wx 2 | const plugin = { 3 | install (Vue) { 4 | Vue.prototype.$wechat = wx 5 | Vue.wechat = wx 6 | }, 7 | $wechat: wx 8 | } 9 | export default plugin 10 | export const install = plugin.install 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw* 22 | -------------------------------------------------------------------------------- /src/api/index.js: -------------------------------------------------------------------------------- 1 | import { get, post } from '@/axios/http.js' 2 | function getIndex (params) { 3 | return get('/mock/5cb48c7ed491cd741c54456f/base/index', params) 4 | } 5 | function login(params) { 6 | return post('/mock/5cb48c7ed491cd741c54456f/base/login', params) 7 | } 8 | export { 9 | getIndex, 10 | login 11 | } 12 | -------------------------------------------------------------------------------- /src/store.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | 4 | Vue.use(Vuex) 5 | 6 | export default new Vuex.Store({ 7 | state: { 8 | direction:'forward' 9 | }, 10 | mutations: { 11 | updateDirection (state, direction) { 12 | state.direction = direction 13 | } 14 | }, 15 | actions: {} 16 | }) 17 | -------------------------------------------------------------------------------- /src/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | import login from './modules/login/index' 4 | import index from './modules/index/index' 5 | Vue.use(Vuex) 6 | export default new Vuex.Store({ 7 | modules: { login, index }, 8 | state: { 9 | direction: 'forward' 10 | }, 11 | mutations: { 12 | updateDirection (state, direction) { 13 | state.direction = direction 14 | } 15 | }, 16 | actions: {} 17 | }) 18 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | import router from './router' 4 | import store from './store/index' 5 | import filters from './filters/index' 6 | import wechat from '@/common/wechat/index' 7 | Vue.use(wechat); 8 | // 注入全局过滤器 9 | Object.keys(filters).forEach(item => { 10 | Vue.filter(item, filters[item]) 11 | }) 12 | // const wx = Vue.wechat; 13 | // wx.config({ 14 | // appId: '', 15 | // nonceStr: '', 16 | // signature: '', 17 | // timestamp: '', 18 | // jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage'] 19 | // }) 20 | Vue.config.productionTip = false 21 | Vue.config.devtools = true 22 | new Vue({ 23 | router, 24 | store, 25 | render: h => h(App) 26 | }).$mount('#app') 27 | -------------------------------------------------------------------------------- /src/filters/index.js: -------------------------------------------------------------------------------- 1 | // 过滤日期格式,传入时间戳,根据参数返回不同格式 2 | const formatTimer = function(val, hours) { 3 | if (val) { 4 | var dateTimer = new Date(val * 1000) 5 | var y = dateTimer.getFullYear() 6 | var M = dateTimer.getMonth() + 1 7 | var d = dateTimer.getDate() 8 | var h = dateTimer.getHours() 9 | var m = dateTimer.getMinutes() 10 | M = M >= 10 ? M : '0' + M 11 | d = d >= 10 ? d : '0' + d 12 | h = h >= 10 ? h : '0' + h 13 | m = m >= 10 ? m : '0' + m 14 | if (hours) { 15 | return y + '-' + M + '-' + d + ' ' + h + ':' + m 16 | } else { 17 | return y + '-' + M + '-' + d 18 | } 19 | } 20 | } 21 | export default { 22 | formatTimer 23 | } 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | #### 升级到vue-cli4配置最新配置 [点我](https://github.com/zhouyupeng/vue-cli3-H5/tree/0.0.1)(2020-11-10) 3 | 4 | 5 | 6 | 文章介绍 7 | 8 | ### [点击前往](https://juejin.im/post/5cbf32bc6fb9a03236393379) 9 | 10 | ### 2019-05-08更新,增加页面切换动画 11 | 12 | > demo地址: [https://zhouyupeng.github.io/vuecli3H5/#/](https://zhouyupeng.github.io/vuecli3H5/#/) 13 | 14 | [利用Jenkins + nginx 实现前端项目自动构建与持续集成](https://juejin.im/post/5cde525b51882525f77dc0e9) 15 | 16 | ## Project setup 17 | ``` 18 | yarn install 19 | ``` 20 | 21 | ### Compiles and hot-reloads for development 22 | ``` 23 | yarn run serve 24 | ``` 25 | 26 | ### Compiles and minifies for production 27 | ``` 28 | yarn run build 29 | ``` 30 | 31 | ### Run your tests 32 | ``` 33 | yarn run test 34 | ``` 35 | ### Lints and fixes files 36 | ``` 37 | yarn run lint 38 | ``` 39 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true 5 | }, 6 | extends: ['plugin:vue/essential', '@vue/standard'], 7 | rules: { 8 | 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', 9 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', 10 | indent: [ 11 | 'error', 12 | 4, 13 | { 14 | SwitchCase: 1 15 | } 16 | ], // 空格缩进 off 关闭 17 | semi: 0, // 不检查结尾分号, 18 | //强制使用单引号 19 | quotes: ['error', 'single'], 20 | //关闭函数名与后面括号间必须空格规则 21 | 'space-before-function-paren': 0, 22 | // 关闭var 声明,每个声明占一行规则。 23 | 'one-var': 0, 24 | "no-console": 0 25 | 26 | }, 27 | parserOptions: { 28 | parser: 'babel-eslint' 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuedemo", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "axios": "^0.18.0", 12 | "core-js": "^2.6.5", 13 | "mint-ui": "^2.2.13", 14 | "normalize.css": "^8.0.1", 15 | "vue": "^2.6.6", 16 | "vue-router": "^3.0.1", 17 | "vuex": "^3.0.1" 18 | }, 19 | "devDependencies": { 20 | "@vue/cli-plugin-babel": "^3.0.5", 21 | "@vue/cli-plugin-eslint": "^3.0.5", 22 | "@vue/cli-service": "^3.0.5", 23 | "@vue/eslint-config-standard": "^4.0.0", 24 | "babel-eslint": "^10.0.1", 25 | "compression-webpack-plugin": "^2.0.0", 26 | "eslint": "^5.8.0", 27 | "eslint-plugin-vue": "^5.0.0", 28 | "node-sass": "^4.9.0", 29 | "postcss-px2rem": "^0.3.0", 30 | "qs": "^6.7.0", 31 | "sass-loader": "^7.1.0", 32 | "uglifyjs-webpack-plugin": "^2.1.2", 33 | "vue-template-compiler": "^2.5.21", 34 | "webpack-bundle-analyzer": "^3.3.0" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | 12 | 13 | 14 | <% for (var i in 15 | htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.css) { %> 16 | 17 | 18 | <% } %> 19 | 20 | vuedemo 21 | 22 | 23 | 24 | 28 |
29 | 30 | <% for (var i in 31 | htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.js) { %> 32 | 33 | <% } %> 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/views/Home.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 54 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 22 | 65 | -------------------------------------------------------------------------------- /src/views/About.vue: -------------------------------------------------------------------------------- 1 | 23 | 24 | 39 | 40 | 41 | 65 | -------------------------------------------------------------------------------- /src/store/modules/login/index.js: -------------------------------------------------------------------------------- 1 | import * as type from './mutations_types' 2 | import { login } from 'api/index' 3 | import { Toast } from 'mint-ui'; 4 | export default { 5 | namespaced: true, 6 | state: { 7 | token: localStorage.getItem('token') || '', 8 | user: JSON.parse(localStorage.getItem('userDate')) || {} 9 | }, 10 | mutations: { 11 | 12 | [type.LOGIN](state, data) { 13 | let userDate = data.data; 14 | state.token = userDate.token; 15 | state.user = userDate; 16 | localStorage.setItem('token', userDate.token) 17 | localStorage.setItem('userDate', JSON.stringify(userDate)) 18 | } 19 | 20 | }, 21 | actions: { 22 | async login(state, data) { 23 | try { 24 | let res = await login({ 25 | username: data.username, 26 | password: data.password 27 | }) 28 | state.commit(type.LOGIN, res); 29 | Toast({ 30 | message: '登录成功', 31 | position: 'middle', 32 | duration: 2000 33 | }); 34 | setTimeout(() => { 35 | const redirect = data.$route.query.redirect || '/'; 36 | data.$router.replace({ 37 | path: redirect 38 | }) 39 | }, 3000); 40 | } catch (error) { 41 | } 42 | } 43 | }, 44 | getters: { 45 | token(state) { 46 | return state.token 47 | }, 48 | user(state) { 49 | console.log('state', state); 50 | return state.user 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/router.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import Home from './views/Home.vue' 4 | import store from 'store/index' 5 | Vue.use(Router) 6 | const router = new Router({ 7 | routes: [ 8 | { 9 | path: '/', 10 | name: 'home', 11 | component: Home, 12 | meta: { 13 | auth: false, // 是否需要登录 14 | keepAlive: false // 是否缓存组件 15 | } 16 | }, 17 | { 18 | path: '/about', 19 | name: 'about', 20 | // route level code-splitting 21 | // this generates a separate chunk (about.[hash].js) for this route 22 | // which is lazy-loaded when the route is visited. 23 | component: () => 24 | import(/* webpackChunkName: "about" */ './views/About.vue'), 25 | meta: { 26 | auth: true, 27 | keepAlive: true 28 | } 29 | }, 30 | { 31 | path: '/login', 32 | name: 'login', 33 | component: () => 34 | import(/* webpackChunkName: "login" */ './views/login.vue'), 35 | meta: { 36 | auth: false, 37 | keepAlive: true 38 | } 39 | }, 40 | { 41 | path: '*', // 未匹配到路由时重定向 42 | redirect: '/', 43 | meta: { 44 | // auth: true, 45 | // keepAlive: true 46 | } 47 | } 48 | ] 49 | }) 50 | // 记录页面跳转历史,以此判断页面左滑跳转还是右滑跳转 51 | const history = window.sessionStorage 52 | history.clear() 53 | let historyCount = history.getItem('count') * 1 || 0 54 | history.setItem('/', 0) 55 | 56 | // 全局路由钩子函数 对全局有效 57 | router.beforeEach((to, from, next) => { 58 | let auth = to.meta.auth 59 | let token = store.getters['login/token']; 60 | // 当跳转时携带指定方向参数则优先使用指定参数 61 | if (to.params.direction) { 62 | store.commit('updateDirection', to.params.direction) 63 | } else { 64 | const toIndex = history.getItem(to.path) 65 | const fromIndex = history.getItem(from.path) 66 | // 判断并记录跳转页面是否访问过,以此判断跳转过渡方式 67 | if (toIndex) { 68 | if (!fromIndex || parseInt(toIndex, 10) > parseInt(fromIndex, 10) || (toIndex === '0' && fromIndex === '0')) { 69 | store.commit('updateDirection', 'forward') 70 | } else { 71 | store.commit('updateDirection', 'back') 72 | } 73 | } else { 74 | ++historyCount 75 | history.setItem('count', historyCount) 76 | to.path !== '/' && history.setItem(to.path, historyCount) 77 | store.commit('updateDirection', 'forward') 78 | } 79 | } 80 | if (auth) { // 需要登录 81 | if (token) { 82 | next() 83 | } else { 84 | next({ 85 | path: '/login', 86 | query: { 87 | redirect: to.fullPath 88 | } 89 | }) 90 | } 91 | } else { 92 | next() 93 | } 94 | }) 95 | export default router 96 | -------------------------------------------------------------------------------- /src/axios/http.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | import qs from 'qs' 3 | import store from 'store/index' 4 | import { Indicator, Toast } from 'mint-ui' 5 | axios.defaults.timeout = 12000 // 请求超时时间 6 | axios.defaults.baseURL = process.env.VUE_APP_BASE_API 7 | 8 | axios.defaults.headers.post['Content-Type'] = 9 | 'application/x-www-form-urlencoded;charset=UTF-8' // post请求头的设置 10 | // axios 请求拦截器 11 | axios.interceptors.request.use( 12 | config => { 13 | // 可在此设置要发送的token 14 | let token = store.getters['login/token']; 15 | token && (config.headers.token = token) 16 | // Indicator.open('数据加载中') 17 | return config 18 | }, 19 | error => { 20 | return Promise.error(error) 21 | } 22 | ) 23 | // axios respone拦截器 24 | axios.interceptors.response.use( 25 | response => { 26 | // 如果返回的状态码为200,说明接口请求成功,可以正常拿到数据 27 | // 否则的话抛出错误 结合自身业务和后台返回的接口状态约定写respone拦截器 28 | Indicator.close() 29 | if (response.status === 200 && response.data.code === 0) { 30 | return Promise.resolve(response) 31 | } else { 32 | Toast({ 33 | message: response.data.msg, 34 | position: 'middle', 35 | duration: 2000 36 | }); 37 | return Promise.reject(response) 38 | } 39 | }, 40 | error => { 41 | Indicator.close() 42 | const responseCode = error.response.status 43 | switch (responseCode) { 44 | // 401:未登录 45 | case 401: 46 | break 47 | // 404请求不存在 48 | case 404: 49 | Toast({ 50 | message: '网络请求不存在', 51 | position: 'middle', 52 | duration: 2000 53 | }); 54 | break 55 | default: 56 | Toast({ 57 | message: error.response.data.message, 58 | position: 'middle', 59 | duration: 2000 60 | }); 61 | } 62 | 63 | return Promise.reject(error.response) 64 | } 65 | ) 66 | /** 67 | * 封装get方法,对应get请求 68 | * @param {String} url [请求的url地址] 69 | * @param {Object} params [请求时携带的参数] 70 | */ 71 | function get (url, params = {}) { 72 | return new Promise((resolve, reject) => { 73 | axios 74 | .get(url, { 75 | params: params 76 | }) 77 | .then(res => { 78 | resolve(res.data) 79 | }) 80 | .catch(err => { 81 | reject(err) 82 | }) 83 | }) 84 | // 或者return axios.get(); 85 | } 86 | /** 87 | * post方法,对应post请求 88 | * @param {String} url [请求的url地址] 89 | * @param {Object} params [请求时携带的参数] 90 | */ 91 | function post (url, params) { 92 | return new Promise((resolve, reject) => { 93 | axios 94 | .post(url, qs.stringify(params)) 95 | .then(res => { 96 | resolve(res.data) 97 | }) 98 | .catch(err => { 99 | reject(err) 100 | }) 101 | }) 102 | // 或者return axios.post(); 103 | } 104 | 105 | export { get, post } 106 | -------------------------------------------------------------------------------- /src/views/login.vue: -------------------------------------------------------------------------------- 1 | 20 | 21 | 61 | 121 | -------------------------------------------------------------------------------- /src/style/common.scss: -------------------------------------------------------------------------------- 1 | html { 2 | font-size: 13.33333vw 3 | } 4 | 5 | @media screen and (max-width: 320px) { 6 | html { 7 | font-size: 42.667PX; 8 | font-size: 13.33333vw 9 | } 10 | } 11 | 12 | @media screen and (min-width: 321px) and (max-width:360px) { 13 | html { 14 | font-size: 48PX; 15 | font-size: 13.33333vw 16 | } 17 | } 18 | 19 | @media screen and (min-width: 361px) and (max-width:375px) { 20 | html { 21 | font-size: 50PX; 22 | font-size: 13.33333vw 23 | } 24 | } 25 | 26 | @media screen and (min-width: 376px) and (max-width:393px) { 27 | html { 28 | font-size: 52.4PX; 29 | font-size: 13.33333vw 30 | } 31 | } 32 | 33 | @media screen and (min-width: 394px) and (max-width:412px) { 34 | html { 35 | font-size: 54.93PX; 36 | font-size: 13.33333vw 37 | } 38 | } 39 | 40 | @media screen and (min-width: 413px) and (max-width:414px) { 41 | html { 42 | font-size: 55.2PX; 43 | font-size: 13.33333vw 44 | } 45 | } 46 | 47 | @media screen and (min-width: 415px) and (max-width:480px) { 48 | html { 49 | font-size: 64PX; 50 | font-size: 13.33333vw 51 | } 52 | } 53 | 54 | @media screen and (min-width: 481px) and (max-width:540px) { 55 | html { 56 | font-size: 72PX; 57 | font-size: 13.33333vw 58 | } 59 | } 60 | 61 | @media screen and (min-width: 541px) and (max-width:640px) { 62 | html { 63 | font-size: 85.33PX; 64 | font-size: 13.33333vw 65 | } 66 | } 67 | 68 | @media screen and (min-width: 641px) and (max-width:720px) { 69 | html { 70 | font-size: 96PX; 71 | font-size: 13.33333vw 72 | } 73 | } 74 | 75 | @media screen and (min-width: 721px) and (max-width:768px) { 76 | html { 77 | font-size: 102.4PX; 78 | font-size: 13.33333vw 79 | } 80 | } 81 | 82 | @media screen and (min-width: 769px) { 83 | html { 84 | font-size: 102.4PX; 85 | #app { 86 | width: 768PX; 87 | margin: 0 auto 88 | } 89 | } 90 | } 91 | 92 | .clearfix:after { 93 | display: block; 94 | clear: both; 95 | content: ""; 96 | visibility: hidden; 97 | height: 0 98 | } 99 | input,button,select,textarea{outline:none} 100 | 101 | /* page change */ 102 | $--transition-time: 350ms; 103 | .back-enter-active, 104 | .back-leave-active, 105 | .forward-enter-active, 106 | .forward-leave-active { 107 | will-change: transform; 108 | transition: all $--transition-time; 109 | position: absolute; 110 | height: 100%; 111 | backface-visibility: hidden; 112 | perspective: 1000; 113 | } 114 | .back-enter { 115 | opacity: 0.75; 116 | transform: translate3d(-35%, 0, 0)!important; 117 | } 118 | .back-enter-active { 119 | z-index: -1!important; 120 | transition: all $--transition-time linear; 121 | } 122 | .back-leave-active { 123 | transform: translate3d(100%, 0, 0)!important; 124 | transition: all $--transition-time linear; 125 | } 126 | .forward-enter { 127 | transform: translate3d(100%, 0, 0)!important; 128 | } 129 | .forward-enter-active { 130 | transition: all $--transition-time linear; 131 | } 132 | .forward-leave-active { 133 | z-index: -1; 134 | opacity: 0.65; 135 | transform: translate3d(-35%, 0, 0)!important; 136 | transition: all $--transition-time linear; 137 | } 138 | 139 | .slide-left-leave-active, 140 | .slide-right-leave-active, 141 | .slide-left-enter-active, 142 | .slide-right-enter-active{ 143 | transition: all $--transition-time; 144 | } 145 | .slide-left-enter, .slide-right-leave-active { 146 | -webkit-transform: translate(100%, 0); 147 | transform: translate(100%, 0); 148 | } 149 | .slide-left-leave-active, .slide-right-enter { 150 | -webkit-transform: translate(-100%, 0); 151 | transform: translate(-100%, 0); 152 | } -------------------------------------------------------------------------------- /vue.config.js: -------------------------------------------------------------------------------- 1 | const CompressionWebpackPlugin = require('compression-webpack-plugin') 2 | const BundleAnalyzerPlugin = require('webpack-bundle-analyzer') 3 | .BundleAnalyzerPlugin 4 | const UglifyJsPlugin = require('uglifyjs-webpack-plugin') 5 | const isProduction = process.env.NODE_ENV === 'production' 6 | // cdn预加载使用 7 | const externals = { 8 | vue: 'Vue', 9 | 'vue-router': 'VueRouter', 10 | vuex: 'Vuex', 11 | 'mint-ui': 'MINT', 12 | axios: 'axios' 13 | 14 | } 15 | 16 | const cdn = { 17 | // 开发环境 18 | dev: { 19 | css: [ 20 | 'https://lib.baomitu.com/mint-ui/2.2.13/style.min.css' 21 | ], 22 | js: [] 23 | }, 24 | // 生产环境 25 | build: { 26 | css: [ 27 | 'https://lib.baomitu.com/mint-ui/2.2.13/style.min.css' 28 | ], 29 | js: [ 30 | 'https://lib.baomitu.com/vue/2.6.6/vue.min.js', 31 | 'https://lib.baomitu.com/vue-router/3.0.1/vue-router.min.js', 32 | 'https://lib.baomitu.com/vuex/3.0.1/vuex.min.js', 33 | 'https://lib.baomitu.com/axios/0.18.0/axios.min.js', 34 | 'https://lib.baomitu.com/mint-ui/2.2.13/index.js' 35 | ] 36 | } 37 | } 38 | 39 | module.exports = { 40 | // 项目部署的基础路径 默认/ 41 | // 放在子目录时使用./或者加你的域名 42 | publicPath: process.env.BASE_URL, 43 | configureWebpack: config => { 44 | if (isProduction) { 45 | // externals里的模块不打包 46 | Object.assign(config, { 47 | externals: externals 48 | }) 49 | // 为生产环境修改配置... 50 | // 上线压缩去除console等信息 51 | config.plugins.push( 52 | new UglifyJsPlugin({ 53 | uglifyOptions: { 54 | warnings: false, 55 | compress: { 56 | drop_console: true, 57 | drop_debugger: false, 58 | pure_funcs: ['console.log'] // 移除console 59 | } 60 | }, 61 | sourceMap: false, 62 | parallel: true 63 | }) 64 | ) 65 | // 开启gzip压缩 66 | const productionGzipExtensions = /\.(js|css|json|txt|html|ico|svg)(\?.*)?$/i 67 | config.plugins.push( 68 | new CompressionWebpackPlugin({ 69 | filename: '[path].gz[query]', 70 | algorithm: 'gzip', 71 | test: productionGzipExtensions, 72 | threshold: 10240, 73 | minRatio: 0.8 74 | }) 75 | ) 76 | // if (process.env.npm_config_report) { 77 | // // 打包后模块大小分析//npm run build --report 78 | // config.plugins.push(new BundleAnalyzerPlugin()) 79 | // } 80 | } else { 81 | // 为开发环境修改配置... 82 | } 83 | }, 84 | chainWebpack: config => { 85 | // 对vue-cli内部的 webpack 配置进行更细粒度的修改。 86 | // 添加CDN参数到htmlWebpackPlugin配置中, 详见public/index.html 修改 87 | config.plugin('html').tap(args => { 88 | if (process.env.NODE_ENV === 'production') { 89 | args[0].cdn = cdn.build 90 | } 91 | if (process.env.NODE_ENV === 'development') { 92 | args[0].cdn = cdn.dev 93 | } 94 | return args 95 | }) 96 | // 设置目录别名alias 97 | config.resolve.alias 98 | .set('assets', '@/assets') 99 | .set('components', '@/components') 100 | .set('view', '@/view') 101 | .set('style', '@/style') 102 | .set('api', '@/api') 103 | .set('store', '@/store') 104 | }, 105 | css: { 106 | // 是否使用css分离插件 ExtractTextPlugin 107 | extract:isProduction ? true:false, 108 | // 开启 CSS source maps? 109 | sourceMap: false, 110 | // css预设器配置项 111 | // 启用 CSS modules for all css / pre-processor files. 112 | modules: false, 113 | loaderOptions: { 114 | postcss: { 115 | // 这是rem适配的配置 116 | plugins: [ 117 | require('postcss-px2rem')({ 118 | remUnit: 100 119 | }) 120 | ] 121 | }, 122 | sass: { 123 | data: '@import "style/_mixin.scss";@import "style/_variables.scss";' // 全局引入 124 | } 125 | } 126 | }, 127 | lintOnSave: true, // default false 128 | // 打包时不生成.map文件 129 | productionSourceMap: false, 130 | devServer: { 131 | open: true, // 启动服务后是否打开浏览器 132 | host: '127.0.0.1', 133 | port: 8088, // 服务端口 134 | https: false, 135 | hotOnly: false, 136 | // 设置代理,用来解决本地开发跨域问题,如果设置了代理,那你本地开发环境的axios的baseUrl要写为 '' ,即空字符串 137 | proxy: 'https://easy-mock.com/' // 设置代理 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /src/style/_mixin.scss: -------------------------------------------------------------------------------- 1 | @mixin center($width: null, $height: null) { 2 | position: absolute; 3 | top: 50%; 4 | left: 50%; 5 | 6 | @if not $width and not $height { 7 | transform: translate(-50%, -50%); 8 | } 9 | 10 | @else if $width and $height { 11 | width: $width; 12 | height: $height; 13 | margin: -($height / 2) #{0 0} -($width / 2); 14 | } 15 | 16 | @else if not $height { 17 | width: $width; 18 | margin-left: -($width / 2); 19 | transform: translateY(-50%); 20 | } 21 | 22 | @else { 23 | height: $height; 24 | margin-top: -($height / 2); 25 | transform: translateX(-50%); 26 | } 27 | } 28 | 29 | 30 | 31 | @mixin opacity($opacity) { 32 | opacity: $opacity; 33 | $opacity-ie: $opacity * 100; 34 | filter: alpha(opacity=$opacity-ie); 35 | } 36 | 37 | @mixin ell() { 38 | // 39 | overflow: hidden; 40 | -ms-text-overflow: ellipsis; 41 | text-overflow: ellipsis; 42 | white-space: nowrap; 43 | } 44 | 45 | //多行超出省略号 46 | @mixin ell2() { 47 | word-break: break-all; 48 | text-overflow: ellipsis; 49 | display: -webkit-box; 50 | -webkit-box-orient: vertical; 51 | -webkit-line-clamp: 2; 52 | overflow: hidden; 53 | } 54 | 55 | //.arrow{ 56 | // @include arrow(bottom,10px,#F00); 57 | // 58 | @mixin arrow($direction, $size, $color) { 59 | width: 0; 60 | height: 0; 61 | line-height: 0; 62 | font-size: 0; 63 | overflow: hidden; 64 | border-width: $size; 65 | cursor: pointer; 66 | 67 | @if $direction==top { 68 | border-style: dashed dashed solid dashed; 69 | border-color: transparent transparent $color transparent; 70 | border-top: none; 71 | } 72 | 73 | @else if $direction==bottom { 74 | border-style: solid dashed dashed dashed; 75 | border-color: $color transparent transparent transparent; 76 | border-bottom: none; 77 | } 78 | 79 | @else if $direction==right { 80 | border-style: dashed dashed dashed solid; 81 | border-color: transparent transparent transparent $color; 82 | border-right: none; 83 | } 84 | 85 | @else if $direction==left { 86 | border-style: dashed solid dashed dashed; 87 | border-color: transparent $color transparent transparent; 88 | border-left: none; 89 | } 90 | } 91 | 92 | // clearfix 93 | @mixin clr { 94 | &:after { 95 | clear: both; 96 | content: '.'; 97 | display: block; 98 | height: 0; 99 | line-height: 0; 100 | overflow: hidden; 101 | } 102 | 103 | *height: 1%; 104 | } 105 | 106 | /*渐变(从上到下)*/ 107 | @mixin linear-gradient($direction:bottom, $color1:transparent, $color2:#306eff, $color3:transparent) { 108 | //background: -webkit-linear-gradient($direction,$colorTop, $colorCenter, $colorBottom); /* Safari 5.1 - 6.0 */ 109 | background: -o-linear-gradient($direction, $color1, $color2, $color3); 110 | /* Opera 11.1 - 12.0 */ 111 | background: -moz-linear-gradient($direction, $color1, $color2, $color3); 112 | /* Firefox 3.6 - 15 */ 113 | background: linear-gradient(to $direction, $color1, $color2, $color3); 114 | /* 标准的语法 */ 115 | 116 | } 117 | 118 | /* 行高 */ 119 | @mixin line-height($height:30px, $line-height:30px) { 120 | @if ($height !=null) { 121 | height: $height; 122 | } 123 | 124 | @if ($line-height !=null) { 125 | line-height: $line-height; 126 | } 127 | } 128 | 129 | /* 定义滚动条样式 圆角和阴影不需要则传入null */ 130 | @mixin scrollBar($width:10px, $height:10px, $outColor:$bgColor, $innerColor:$bgGrey, $radius:5px, $shadow:null) { 131 | 132 | /*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/ 133 | &::-webkit-scrollbar { 134 | width: $width; 135 | height: $height; 136 | background-color: $outColor; 137 | } 138 | 139 | /*定义滚动条轨道 内阴影+圆角*/ 140 | &::-webkit-scrollbar-track { 141 | @if ($shadow !=null) { 142 | -webkit-box-shadow: $shadow; 143 | } 144 | 145 | @if ($radius !=null) { 146 | border-radius: $radius; 147 | } 148 | 149 | background-color: $outColor; 150 | } 151 | 152 | /*定义滑块 内阴影+圆角*/ 153 | &::-webkit-scrollbar-thumb { 154 | @if ($shadow !=null) { 155 | -webkit-box-shadow: $shadow; 156 | } 157 | 158 | @if ($radius !=null) { 159 | border-radius: $radius; 160 | } 161 | 162 | background-color: $innerColor; 163 | border: 1px solid $innerColor; 164 | } 165 | } 166 | 167 | /* css3动画 默认3s宽度到200px */ 168 | @mixin animation($from:(width:0px), $to:(width:200px), $name:mymove, $animate:mymove 2s 1 linear infinite) { 169 | -webkit-animation: $animate; 170 | -o-animation: $animate; 171 | animation: $animate; 172 | 173 | @keyframes #{$name} { 174 | from { 175 | 176 | @each $key, 177 | $value in $from { 178 | #{$key}: #{$value}; 179 | } 180 | } 181 | 182 | to { 183 | 184 | @each $key, 185 | $value in $to { 186 | #{$key}: #{$value}; 187 | } 188 | } 189 | } 190 | 191 | @-webkit-keyframes #{$name} { 192 | from { 193 | 194 | @each $key, 195 | $value in $from { 196 | $key: $value; 197 | } 198 | } 199 | 200 | to { 201 | 202 | @each $key, 203 | $value in $to { 204 | $key: $value; 205 | } 206 | } 207 | } 208 | } -------------------------------------------------------------------------------- /src/common/wechat/wechat.js: -------------------------------------------------------------------------------- 1 | /** 2 | * v-1.3.0 3 | */ 4 | /* eslint-disable */ 5 | let wx 6 | !function (e, n) { 7 | wx = n(e) 8 | }(window, function (e, n) { 9 | function i(n, i, t) { 10 | e.WeixinJSBridge ? WeixinJSBridge.invoke(n, o(i), function (e) { 11 | c(n, e, t) 12 | }) : u(n, t) 13 | } 14 | 15 | function t(n, i, t) { 16 | e.WeixinJSBridge ? WeixinJSBridge.on(n, function (e) { 17 | t && t.trigger && t.trigger(e), c(n, e, i) 18 | }) : t ? u(n, t) : u(n, i) 19 | } 20 | 21 | function o(e) { 22 | return e = e || {}, e.appId = C.appId, e.verifyAppId = C.appId, e.verifySignType = "sha1", e.verifyTimestamp = C.timestamp + "", e.verifyNonceStr = C.nonceStr, e.verifySignature = C.signature, e 23 | } 24 | 25 | function r(e) { 26 | return { 27 | timeStamp: e.timestamp + "", 28 | nonceStr: e.nonceStr, 29 | package: e.package, 30 | paySign: e.paySign, 31 | signType: e.signType || "SHA1" 32 | } 33 | } 34 | 35 | function a(e) { 36 | return e.postalCode = e.addressPostalCode, delete e.addressPostalCode, e.provinceName = e.proviceFirstStageName, delete e.proviceFirstStageName, e.cityName = e.addressCitySecondStageName, delete e.addressCitySecondStageName, e.countryName = e.addressCountiesThirdStageName, delete e.addressCountiesThirdStageName, e.detailInfo = e.addressDetailInfo, delete e.addressDetailInfo, e 37 | } 38 | 39 | function c(e, n, i) { 40 | "openEnterpriseChat" == e && (n.errCode = n.err_code), delete n.err_code, delete n.err_desc, delete n.err_detail; 41 | var t = n.errMsg; 42 | t || (t = n.err_msg, delete n.err_msg, t = s(e, t), n.errMsg = t), (i = i || {})._complete && (i._complete(n), delete i._complete), t = n.errMsg || "", C.debug && !i.isInnerInvoke && alert(JSON.stringify(n)); 43 | var o = t.indexOf(":"); 44 | switch (t.substring(o + 1)) { 45 | case "ok": 46 | i.success && i.success(n); 47 | break; 48 | case "cancel": 49 | i.cancel && i.cancel(n); 50 | break; 51 | default: 52 | i.fail && i.fail(n) 53 | } 54 | i.complete && i.complete(n) 55 | } 56 | 57 | function s(e, n) { 58 | var i = e, 59 | t = v[i]; 60 | t && (i = t); 61 | var o = "ok"; 62 | if (n) { 63 | var r = n.indexOf(":"); 64 | "confirm" == (o = n.substring(r + 1)) && (o = "ok"), "failed" == o && (o = "fail"), -1 != o.indexOf("failed_") && (o = o.substring(7)), -1 != o.indexOf("fail_") && (o = o.substring(5)), "access denied" != (o = (o = o.replace(/_/g, " ")).toLowerCase()) && "no permission to execute" != o || (o = "permission denied"), "config" == i && "function not exist" == o && (o = "ok"), "" == o && (o = "fail") 65 | } 66 | return n = i + ":" + o 67 | } 68 | 69 | function d(e) { 70 | if (e) { 71 | for (var n = 0, i = e.length; n < i; ++n) { 72 | var t = e[n], 73 | o = h[t]; 74 | o && (e[n] = o) 75 | } 76 | return e 77 | } 78 | } 79 | 80 | function u(e, n) { 81 | if (!(!C.debug || n && n.isInnerInvoke)) { 82 | var i = v[e]; 83 | i && (e = i), n && n._complete && delete n._complete, console.log('"' + e + '",', n || "") 84 | } 85 | } 86 | 87 | function l(e) { 88 | if (!(w || T || C.debug || x < "6.0.2" || A.systemType < 0)) { 89 | var n = new Image; 90 | A.appId = C.appId, A.initTime = V.initEndTime - V.initStartTime, A.preVerifyTime = V.preVerifyEndTime - V.preVerifyStartTime, N.getNetworkType({ 91 | isInnerInvoke: !0, 92 | success: function (e) { 93 | A.networkType = e.networkType; 94 | var i = "https://open.weixin.qq.com/sdk/report?v=" + A.version + "&o=" + A.isPreVerifyOk + "&s=" + A.systemType + "&c=" + A.clientVersion + "&a=" + A.appId + "&n=" + A.networkType + "&i=" + A.initTime + "&p=" + A.preVerifyTime + "&u=" + A.url; 95 | n.src = i 96 | } 97 | }) 98 | } 99 | } 100 | 101 | function p() { 102 | return (new Date).getTime() 103 | } 104 | 105 | function f(n) { 106 | k && (e.WeixinJSBridge ? "preInject" === I.__wxjsjs__isPreInject ? I.addEventListener && I.addEventListener("WeixinJSBridgeReady", n, !1) : n() : I.addEventListener && I.addEventListener("WeixinJSBridgeReady", n, !1)) 107 | } 108 | 109 | function m() { 110 | N.invoke || (N.invoke = function (n, i, t) { 111 | e.WeixinJSBridge && WeixinJSBridge.invoke(n, o(i), t) 112 | }, N.on = function (n, i) { 113 | e.WeixinJSBridge && WeixinJSBridge.on(n, i) 114 | }) 115 | } 116 | 117 | function g(e) { 118 | if ("string" == typeof e && e.length > 0) { 119 | var n = e.split("?")[0], 120 | i = e.split("?")[1]; 121 | return n += ".html", void 0 !== i ? n + "?" + i : n 122 | } 123 | } 124 | if (!e.jWeixin) { 125 | var h = { 126 | config: "preVerifyJSAPI", 127 | onMenuShareTimeline: "menu:share:timeline", 128 | onMenuShareAppMessage: "menu:share:appmessage", 129 | onMenuShareQQ: "menu:share:qq", 130 | onMenuShareWeibo: "menu:share:weiboApp", 131 | onMenuShareQZone: "menu:share:QZone", 132 | previewImage: "imagePreview", 133 | getLocation: "geoLocation", 134 | openProductSpecificView: "openProductViewWithPid", 135 | addCard: "batchAddCard", 136 | openCard: "batchViewCard", 137 | chooseWXPay: "getBrandWCPayRequest", 138 | openEnterpriseRedPacket: "getRecevieBizHongBaoRequest", 139 | startSearchBeacons: "startMonitoringBeacons", 140 | stopSearchBeacons: "stopMonitoringBeacons", 141 | onSearchBeacons: "onBeaconsInRange", 142 | consumeAndShareCard: "consumedShareCard", 143 | openAddress: "editAddress" 144 | }, 145 | v = function () { 146 | var e = {}; 147 | for (var n in h) e[h[n]] = n; 148 | return e 149 | }(), 150 | I = e.document, 151 | S = I.title, 152 | y = navigator.userAgent.toLowerCase(), 153 | _ = navigator.platform.toLowerCase(), 154 | w = !(!_.match("mac") && !_.match("win")), 155 | T = -1 != y.indexOf("wxdebugger"), 156 | k = -1 != y.indexOf("micromessenger"), 157 | M = -1 != y.indexOf("android"), 158 | P = -1 != y.indexOf("iphone") || -1 != y.indexOf("ipad"), 159 | x = function () { 160 | var e = y.match(/micromessenger\/(\d+\.\d+\.\d+)/) || y.match(/micromessenger\/(\d+\.\d+)/); 161 | return e ? e[1] : "" 162 | }(), 163 | V = { 164 | initStartTime: p(), 165 | initEndTime: 0, 166 | preVerifyStartTime: 0, 167 | preVerifyEndTime: 0 168 | }, 169 | A = { 170 | version: 1, 171 | appId: "", 172 | initTime: 0, 173 | preVerifyTime: 0, 174 | networkType: "", 175 | isPreVerifyOk: 1, 176 | systemType: P ? 1 : M ? 2 : -1, 177 | clientVersion: x, 178 | url: encodeURIComponent(location.href) 179 | }, 180 | C = {}, 181 | L = { 182 | _completes: [] 183 | }, 184 | B = { 185 | state: 0, 186 | data: {} 187 | }; 188 | f(function () { 189 | V.initEndTime = p() 190 | }); 191 | var O = !1, 192 | E = [], 193 | N = { 194 | config: function (e) { 195 | C = e, u("config", e); 196 | var n = !1 !== C.check; 197 | f(function () { 198 | if (n) i(h.config, { 199 | verifyJsApiList: d(C.jsApiList) 200 | }, function () { 201 | L._complete = function (e) { 202 | V.preVerifyEndTime = p(), B.state = 1, B.data = e 203 | }, L.success = function (e) { 204 | A.isPreVerifyOk = 0 205 | }, L.fail = function (e) { 206 | L._fail ? L._fail(e) : B.state = -1 207 | }; 208 | var e = L._completes; 209 | return e.push(function () { 210 | l() 211 | }), L.complete = function (n) { 212 | for (var i = 0, t = e.length; i < t; ++i) e[i](); 213 | L._completes = [] 214 | }, L 215 | }()), V.preVerifyStartTime = p(); 216 | else { 217 | B.state = 1; 218 | for (var e = L._completes, t = 0, o = e.length; t < o; ++t) e[t](); 219 | L._completes = [] 220 | } 221 | }), m() 222 | }, 223 | ready: function (e) { 224 | 0 != B.state ? e() : (L._completes.push(e), !k && C.debug && e()) 225 | }, 226 | error: function (e) { 227 | x < "6.0.2" || (-1 == B.state ? e(B.data) : L._fail = e) 228 | }, 229 | checkJsApi: function (e) { 230 | var n = function (e) { 231 | var n = e.checkResult; 232 | for (var i in n) { 233 | var t = v[i]; 234 | t && (n[t] = n[i], delete n[i]) 235 | } 236 | return e 237 | }; 238 | i("checkJsApi", { 239 | jsApiList: d(e.jsApiList) 240 | }, (e._complete = function (e) { 241 | if (M) { 242 | var i = e.checkResult; 243 | i && (e.checkResult = JSON.parse(i)) 244 | } 245 | e = n(e) 246 | }, e)) 247 | }, 248 | onMenuShareTimeline: function (e) { 249 | t(h.onMenuShareTimeline, { 250 | complete: function () { 251 | i("shareTimeline", { 252 | title: e.title || S, 253 | desc: e.title || S, 254 | img_url: e.imgUrl || "", 255 | link: e.link || location.href, 256 | type: e.type || "link", 257 | data_url: e.dataUrl || "" 258 | }, e) 259 | } 260 | }, e) 261 | }, 262 | onMenuShareAppMessage: function (e) { 263 | t(h.onMenuShareAppMessage, { 264 | complete: function () { 265 | i("sendAppMessage", { 266 | title: e.title || S, 267 | desc: e.desc || "", 268 | link: e.link || location.href, 269 | img_url: e.imgUrl || "", 270 | type: e.type || "link", 271 | data_url: e.dataUrl || "" 272 | }, e) 273 | } 274 | }, e) 275 | }, 276 | onMenuShareQQ: function (e) { 277 | t(h.onMenuShareQQ, { 278 | complete: function () { 279 | i("shareQQ", { 280 | title: e.title || S, 281 | desc: e.desc || "", 282 | img_url: e.imgUrl || "", 283 | link: e.link || location.href 284 | }, e) 285 | } 286 | }, e) 287 | }, 288 | onMenuShareWeibo: function (e) { 289 | t(h.onMenuShareWeibo, { 290 | complete: function () { 291 | i("shareWeiboApp", { 292 | title: e.title || S, 293 | desc: e.desc || "", 294 | img_url: e.imgUrl || "", 295 | link: e.link || location.href 296 | }, e) 297 | } 298 | }, e) 299 | }, 300 | onMenuShareQZone: function (e) { 301 | t(h.onMenuShareQZone, { 302 | complete: function () { 303 | i("shareQZone", { 304 | title: e.title || S, 305 | desc: e.desc || "", 306 | img_url: e.imgUrl || "", 307 | link: e.link || location.href 308 | }, e) 309 | } 310 | }, e) 311 | }, 312 | startRecord: function (e) { 313 | i("startRecord", {}, e) 314 | }, 315 | stopRecord: function (e) { 316 | i("stopRecord", {}, e) 317 | }, 318 | onVoiceRecordEnd: function (e) { 319 | t("onVoiceRecordEnd", e) 320 | }, 321 | playVoice: function (e) { 322 | i("playVoice", { 323 | localId: e.localId 324 | }, e) 325 | }, 326 | pauseVoice: function (e) { 327 | i("pauseVoice", { 328 | localId: e.localId 329 | }, e) 330 | }, 331 | stopVoice: function (e) { 332 | i("stopVoice", { 333 | localId: e.localId 334 | }, e) 335 | }, 336 | onVoicePlayEnd: function (e) { 337 | t("onVoicePlayEnd", e) 338 | }, 339 | uploadVoice: function (e) { 340 | i("uploadVoice", { 341 | localId: e.localId, 342 | isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1 343 | }, e) 344 | }, 345 | downloadVoice: function (e) { 346 | i("downloadVoice", { 347 | serverId: e.serverId, 348 | isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1 349 | }, e) 350 | }, 351 | translateVoice: function (e) { 352 | i("translateVoice", { 353 | localId: e.localId, 354 | isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1 355 | }, e) 356 | }, 357 | chooseImage: function (e) { 358 | i("chooseImage", { 359 | scene: "1|2", 360 | count: e.count || 9, 361 | sizeType: e.sizeType || ["original", "compressed"], 362 | sourceType: e.sourceType || ["album", "camera"] 363 | }, (e._complete = function (e) { 364 | if (M) { 365 | var n = e.localIds; 366 | n && (e.localIds = JSON.parse(n)) 367 | } 368 | }, e)) 369 | }, 370 | getLocation: function (e) {}, 371 | previewImage: function (e) { 372 | i(h.previewImage, { 373 | current: e.current, 374 | urls: e.urls 375 | }, e) 376 | }, 377 | uploadImage: function (e) { 378 | i("uploadImage", { 379 | localId: e.localId, 380 | isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1 381 | }, e) 382 | }, 383 | downloadImage: function (e) { 384 | i("downloadImage", { 385 | serverId: e.serverId, 386 | isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1 387 | }, e) 388 | }, 389 | getLocalImgData: function (e) { 390 | !1 === O ? (O = !0, i("getLocalImgData", { 391 | localId: e.localId 392 | }, (e._complete = function (e) { 393 | if (O = !1, E.length > 0) { 394 | var n = E.shift(); 395 | wx.getLocalImgData(n) 396 | } 397 | }, e))) : E.push(e) 398 | }, 399 | getNetworkType: function (e) { 400 | var n = function (e) { 401 | var n = e.errMsg; 402 | e.errMsg = "getNetworkType:ok"; 403 | var i = e.subtype; 404 | if (delete e.subtype, i) e.networkType = i; 405 | else { 406 | var t = n.indexOf(":"), 407 | o = n.substring(t + 1); 408 | switch (o) { 409 | case "wifi": 410 | case "edge": 411 | case "wwan": 412 | e.networkType = o; 413 | break; 414 | default: 415 | e.errMsg = "getNetworkType:fail" 416 | } 417 | } 418 | return e 419 | }; 420 | i("getNetworkType", {}, (e._complete = function (e) { 421 | e = n(e) 422 | }, e)) 423 | }, 424 | openLocation: function (e) { 425 | i("openLocation", { 426 | latitude: e.latitude, 427 | longitude: e.longitude, 428 | name: e.name || "", 429 | address: e.address || "", 430 | scale: e.scale || 28, 431 | infoUrl: e.infoUrl || "" 432 | }, e) 433 | }, 434 | getLocation: function (e) { 435 | e = e || {}, i(h.getLocation, { 436 | type: e.type || "wgs84" 437 | }, (e._complete = function (e) { 438 | delete e.type 439 | }, e)) 440 | }, 441 | hideOptionMenu: function (e) { 442 | i("hideOptionMenu", {}, e) 443 | }, 444 | showOptionMenu: function (e) { 445 | i("showOptionMenu", {}, e) 446 | }, 447 | closeWindow: function (e) { 448 | i("closeWindow", {}, e = e || {}) 449 | }, 450 | hideMenuItems: function (e) { 451 | i("hideMenuItems", { 452 | menuList: e.menuList 453 | }, e) 454 | }, 455 | showMenuItems: function (e) { 456 | i("showMenuItems", { 457 | menuList: e.menuList 458 | }, e) 459 | }, 460 | hideAllNonBaseMenuItem: function (e) { 461 | i("hideAllNonBaseMenuItem", {}, e) 462 | }, 463 | showAllNonBaseMenuItem: function (e) { 464 | i("showAllNonBaseMenuItem", {}, e) 465 | }, 466 | scanQRCode: function (e) { 467 | i("scanQRCode", { 468 | needResult: (e = e || {}).needResult || 0, 469 | scanType: e.scanType || ["qrCode", "barCode"] 470 | }, (e._complete = function (e) { 471 | if (P) { 472 | var n = e.resultStr; 473 | if (n) { 474 | var i = JSON.parse(n); 475 | e.resultStr = i && i.scan_code && i.scan_code.scan_result 476 | } 477 | } 478 | }, e)) 479 | }, 480 | openAddress: function (e) { 481 | i(h.openAddress, {}, (e._complete = function (e) { 482 | e = a(e) 483 | }, e)) 484 | }, 485 | openProductSpecificView: function (e) { 486 | i(h.openProductSpecificView, { 487 | pid: e.productId, 488 | view_type: e.viewType || 0, 489 | ext_info: e.extInfo 490 | }, e) 491 | }, 492 | addCard: function (e) { 493 | for (var n = e.cardList, t = [], o = 0, r = n.length; o < r; ++o) { 494 | var a = n[o], 495 | c = { 496 | card_id: a.cardId, 497 | card_ext: a.cardExt 498 | }; 499 | t.push(c) 500 | } 501 | i(h.addCard, { 502 | card_list: t 503 | }, (e._complete = function (e) { 504 | var n = e.card_list; 505 | if (n) { 506 | for (var i = 0, t = (n = JSON.parse(n)).length; i < t; ++i) { 507 | var o = n[i]; 508 | o.cardId = o.card_id, o.cardExt = o.card_ext, o.isSuccess = !!o.is_succ, delete o.card_id, delete o.card_ext, delete o.is_succ 509 | } 510 | e.cardList = n, delete e.card_list 511 | } 512 | }, e)) 513 | }, 514 | chooseCard: function (e) { 515 | i("chooseCard", { 516 | app_id: C.appId, 517 | location_id: e.shopId || "", 518 | sign_type: e.signType || "SHA1", 519 | card_id: e.cardId || "", 520 | card_type: e.cardType || "", 521 | card_sign: e.cardSign, 522 | time_stamp: e.timestamp + "", 523 | nonce_str: e.nonceStr 524 | }, (e._complete = function (e) { 525 | e.cardList = e.choose_card_info, delete e.choose_card_info 526 | }, e)) 527 | }, 528 | openCard: function (e) { 529 | for (var n = e.cardList, t = [], o = 0, r = n.length; o < r; ++o) { 530 | var a = n[o], 531 | c = { 532 | card_id: a.cardId, 533 | code: a.code 534 | }; 535 | t.push(c) 536 | } 537 | i(h.openCard, { 538 | card_list: t 539 | }, e) 540 | }, 541 | consumeAndShareCard: function (e) { 542 | i(h.consumeAndShareCard, { 543 | consumedCardId: e.cardId, 544 | consumedCode: e.code 545 | }, e) 546 | }, 547 | chooseWXPay: function (e) { 548 | i(h.chooseWXPay, r(e), e) 549 | }, 550 | openEnterpriseRedPacket: function (e) { 551 | i(h.openEnterpriseRedPacket, r(e), e) 552 | }, 553 | startSearchBeacons: function (e) { 554 | i(h.startSearchBeacons, { 555 | ticket: e.ticket 556 | }, e) 557 | }, 558 | stopSearchBeacons: function (e) { 559 | i(h.stopSearchBeacons, {}, e) 560 | }, 561 | onSearchBeacons: function (e) { 562 | t(h.onSearchBeacons, e) 563 | }, 564 | openEnterpriseChat: function (e) { 565 | i("openEnterpriseChat", { 566 | useridlist: e.userIds, 567 | chatname: e.groupName 568 | }, e) 569 | }, 570 | launchMiniProgram: function (e) { 571 | i("launchMiniProgram", { 572 | targetAppId: e.targetAppId, 573 | path: g(e.path), 574 | envVersion: e.envVersion 575 | }, e) 576 | }, 577 | miniProgram: { 578 | navigateBack: function (e) { 579 | i("invokeMiniProgramAPI", { 580 | name: "navigateBack", 581 | arg: { 582 | delta: (e = e || {}).delta || 1 583 | } 584 | }, e) 585 | }, 586 | navigateTo: function (e) { 587 | i("invokeMiniProgramAPI", { 588 | name: "navigateTo", 589 | arg: { 590 | url: e.url 591 | } 592 | }, e) 593 | }, 594 | redirectTo: function (e) { 595 | i("invokeMiniProgramAPI", { 596 | name: "redirectTo", 597 | arg: { 598 | url: e.url 599 | } 600 | }, e) 601 | }, 602 | switchTab: function (e) { 603 | i("invokeMiniProgramAPI", { 604 | name: "switchTab", 605 | arg: { 606 | url: e.url 607 | } 608 | }, e) 609 | }, 610 | reLaunch: function (e) { 611 | i("invokeMiniProgramAPI", { 612 | name: "reLaunch", 613 | arg: { 614 | url: e.url 615 | } 616 | }, e) 617 | } 618 | } 619 | }, 620 | b = 1, 621 | R = {}; 622 | return I.addEventListener("error", function (e) { 623 | if (!M) { 624 | var n = e.target, 625 | i = n.tagName, 626 | t = n.src; 627 | if (("IMG" == i || "VIDEO" == i || "AUDIO" == i || "SOURCE" == i) && -1 != t.indexOf("wxlocalresource://")) { 628 | e.preventDefault(), e.stopPropagation(); 629 | var o = n["wx-id"]; 630 | if (o || (o = b++, n["wx-id"] = o), R[o]) return; 631 | R[o] = !0, wx.ready(function () { 632 | wx.getLocalImgData({ 633 | localId: t, 634 | success: function (e) { 635 | n.src = e.localData 636 | } 637 | }) 638 | }) 639 | } 640 | } 641 | }, !0), I.addEventListener("load", function (e) { 642 | if (!M) { 643 | var n = e.target, 644 | i = n.tagName; 645 | n.src; 646 | if ("IMG" == i || "VIDEO" == i || "AUDIO" == i || "SOURCE" == i) { 647 | var t = n["wx-id"]; 648 | t && (R[t] = !1) 649 | } 650 | } 651 | }, !0), n && (e.wx = e.jWeixin = N), N 652 | } 653 | }); 654 | 655 | export { 656 | wx 657 | } 658 | --------------------------------------------------------------------------------