diff --git a/.env.development b/.env.development index 887ece9..8739bbb 100644 --- a/.env.development +++ b/.env.development @@ -4,7 +4,5 @@ VUE_APP_ENV = 'development' #base url BASE_URL = 'https://www.xxx.com/' #appid -VUE_APP_WECHAT_APPID='wxc6086549532e9a60' -# base api -VUE_APP_BASE_API = '/dev-api' +VUE_APP_WECHAT_APPID='12345678' VUE_CLI_BABEL_TRANSPILE_MODULES = true diff --git a/.env.production b/.env.production index 5a83263..331fdd1 100644 --- a/.env.production +++ b/.env.production @@ -2,9 +2,8 @@ NODE_ENV='production' # must start with VUE_APP_ VUE_APP_ENV = 'production' #base url -BASE_URL = https://www.top1buyer.com/ +BASE_URL = 'https://www.xxx.com/' #appid -VUE_APP_WECHAT_APPID='wx6bb2125514b4c1ff' -# base api -VUE_APP_BASE_API = '/prod-api' +VUE_APP_WECHAT_APPID='1234567890' + diff --git a/.env.staging b/.env.staging index 1d8a5fc..f57840b 100644 --- a/.env.staging +++ b/.env.staging @@ -2,10 +2,7 @@ NODE_ENV='production' # must start with VUE_APP_ VUE_APP_ENV = 'staging' #base url -BASE_URL = https://www.top1buyer.com/ +BASE_URL = 'https://www.xxx.com/' #appid - -VUE_APP_WECHAT_APPID='wx6bb2125514b4c1ff' -# base api -VUE_APP_BASE_API = '/stage-api' - +VUE_APP_WECHAT_APPID='12345678' + diff --git a/src/api/coupon.js b/src/api/coupon.js deleted file mode 100644 index 8d813ae..0000000 --- a/src/api/coupon.js +++ /dev/null @@ -1,15 +0,0 @@ -import qs from 'qs' -import request from '@/utils/request' -import { api } from '@/config' -// 签名 -import _bale from '@/utils/package' -// api - -// 查询我的优惠券 -export function getCouponList(params) { - return request({ - url: '/coupon/selectMyCoupon', - method: 'post', - data: qs.stringify(_bale('selectMyCoupon', params)) - }) -} diff --git a/src/api/user.js b/src/api/user.js index f4a41b8..abbf06b 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -1,25 +1,15 @@ import qs from 'qs' import request from '@/utils/request' -// 签名 -import _bale from '@/utils/package' -// api -// 登录 -export function login(params) { - return request({ - url: '/wechat/login.do', - method: 'post', - data: qs.stringify(_bale('login', params)) - }) -} + /** * 登录接口请求token与userinfo - * @param params + * @param params {code: code} */ export function loginByCode(params) { return request({ url: '/wechat/auth2', method: 'post', - data: qs.stringify(_bale('auth2', params)) + data: qs.stringify(params) }) } /** @@ -30,54 +20,19 @@ export function getUserInfo(params) { return request({ url: '/user/get_user', method: 'post', - data: qs.stringify(_bale('get_user', params)) + data: qs.stringify(params) }) } /** - * 公众号会员中心 - * @param params + * 默认请求url import { api } from '@/config' 的 base_api + /wechat/auth2 + * 请求common_api打头的参照如下示例: + * import { api } from '@/config' + * export function loginByCode(params) { + * return request({ + * url:api.common_api+ '/wechat/auth2', + * method: 'post', + * data: qs.stringify(params) + * }) + * } */ -export function getAccountInfo(params) { - return request({ - url: '/wechat/selectVipUserInfo', - method: 'post', - data: qs.stringify(_bale('selectVipUserInfo', params)) - }) -} - -/** - * 发送手机验证码 - * @param params - */ -export function sendCode(params) { - return request({ - url: '/wechat/send_phone_code', - method: 'post', - data: qs.stringify(_bale('send_phone_code', params)) - }) -} - -/** - * 微信公众号添加手机号 - * @param params - */ -export function bindPhoneNumber(params) { - return request({ - url: '/wechat/addPhoneNumber', - method: 'post', - data: qs.stringify(_bale('addPhoneNumber', params)) - }) -} - -/** - * 获取门禁二维码值 - * @param params - */ -export function getDoorKey(params) { - return request({ - url: '/user/getDoorKey', - method: 'post', - data: qs.stringify(_bale('getDoorKey', params)) - }) -} diff --git a/src/assets/css/index.scss b/src/assets/css/index.scss index de54bc7..20151ae 100644 --- a/src/assets/css/index.scss +++ b/src/assets/css/index.scss @@ -1,5 +1,6 @@ @import './variables.scss'; @import './mixin.scss'; + body, div, span, @@ -40,6 +41,7 @@ figcaption { box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; + &:hover { outline: none; } @@ -115,54 +117,4 @@ div:focus { } // main-container global css -.app-container { -} -.van-hairline--top-bottom::after { - border-width: 0 !important; -} -.van-cell { - line-height: 30px !important; - .van-cell__title { - font-size: 15px; - color: #333333; - font-weight: 500; - } - .van-cell__left-icon, - .van-cell__right-icon { - line-height: 30px; - color: #999999; - } - &:not(:last-child)::after { - left: 0 !important; - } -} -//模态框 -.modal-popup { - width: 100%; - height: 100%; - max-width: 10rem; - min-width: 10rem; -} -.my-header { - position: relative; - width: 100%; - background: #fff; - border-bottom:1px solid #E9E9E9; - .back-icon { - position: absolute; - width: 44px; - height: 44px; - box-sizing: border-box; - background: url('../../assets/images/arrow-left.png') no-repeat center - center; - background-size: 70% 70%; - } - .header-title { - font-size: 17px; - font-weight: 600; - height: 44px; - line-height: 44px; - text-align: center; - - } -} +.app-container {} diff --git a/src/assets/images/account/s-conpon@2x.png b/src/assets/images/account/s-conpon@2x.png deleted file mode 100644 index ea475e2..0000000 Binary files a/src/assets/images/account/s-conpon@2x.png and /dev/null differ diff --git a/src/assets/images/account/s-ticket-qrcode@2x.png b/src/assets/images/account/s-ticket-qrcode@2x.png deleted file mode 100644 index 423d926..0000000 Binary files a/src/assets/images/account/s-ticket-qrcode@2x.png and /dev/null differ diff --git a/src/assets/images/account/s-ticket@2x.png b/src/assets/images/account/s-ticket@2x.png deleted file mode 100644 index d415c00..0000000 Binary files a/src/assets/images/account/s-ticket@2x.png and /dev/null differ diff --git a/src/assets/images/arrow-left.png b/src/assets/images/arrow-left.png deleted file mode 100644 index 70d2031..0000000 Binary files a/src/assets/images/arrow-left.png and /dev/null differ diff --git a/src/assets/images/coupon/s-coupon-detail-down@2x.png b/src/assets/images/coupon/s-coupon-detail-down@2x.png deleted file mode 100644 index 86dbb98..0000000 Binary files a/src/assets/images/coupon/s-coupon-detail-down@2x.png and /dev/null differ diff --git a/src/assets/images/coupon/s-coupon-detail-up@2x.png b/src/assets/images/coupon/s-coupon-detail-up@2x.png deleted file mode 100644 index 7ac7e28..0000000 Binary files a/src/assets/images/coupon/s-coupon-detail-up@2x.png and /dev/null differ diff --git a/src/assets/images/coupon/s-coupon-empty@2x.png b/src/assets/images/coupon/s-coupon-empty@2x.png deleted file mode 100644 index fe74de1..0000000 Binary files a/src/assets/images/coupon/s-coupon-empty@2x.png and /dev/null differ diff --git a/src/assets/images/coupon/s-coupon-item@2x.png b/src/assets/images/coupon/s-coupon-item@2x.png deleted file mode 100644 index 7149a8a..0000000 Binary files a/src/assets/images/coupon/s-coupon-item@2x.png and /dev/null differ diff --git a/src/config/env.development.js b/src/config/env.development.js index f53ebf8..5937d0e 100644 --- a/src/config/env.development.js +++ b/src/config/env.development.js @@ -1,12 +1,9 @@ // 本地 module.exports = { - title: '蚁小宝', - baseUrl:'http://localhost:9018', + title: '微信网页授权demo', + baseUrl: 'http://localhost:9018', api: { - base_api: 'https://test.top1buyer.com/wx', - common_api: 'https://test.top1buyer.com/wx' - }, - // package appid,appSecret - APPID: 'Pc690487e95992c395633866b', - APPSECRET: '01d552de9b864547b7e67d44568caeb9' + base_api: 'https://www.xxx.com/', + common_api: 'https://www.xxx.com/common' + } } diff --git a/src/config/env.production.js b/src/config/env.production.js index 794d45e..1f66bd7 100644 --- a/src/config/env.production.js +++ b/src/config/env.production.js @@ -1,12 +1,9 @@ // 正式 module.exports = { - title: '蚁小宝', - baseUrl:'http://localhost:9018', + title: '微信网页授权demo', + baseUrl: 'http://localhost:9018', api: { - base_api: 'https://xxx.xxx.com/admin', - common_api: 'https://xxx.xxx.com/common' - }, - // package appid,appSecret - APPID: 'Pc690487e95992c395633866b', - APPSECRET: '01d552de9b864547b7e67d44568caeb9' + base_api: 'https://www.xxx.com/', + common_api: 'https://www.xxx.com/common' + } } diff --git a/src/config/env.staging.js b/src/config/env.staging.js index c2ba975..ef52568 100644 --- a/src/config/env.staging.js +++ b/src/config/env.staging.js @@ -1,11 +1,8 @@ module.exports = { - title: '蚁小宝', + title: '微信网页授权demo', baseUrl: 'https://test.top1buyer.com', api: { - base_api: 'https://test.top1buyer.com/wx', - common_api: 'https://test.top1buyer.com/wx' - }, - // package appid,appSecret - APPID: 'Pc690487e95992c395633866b', - APPSECRET: '01d552de9b864547b7e67d44568caeb9' + base_api: 'https://www.xxx.com/', + common_api: 'https://www.xxx.com/common' + } } diff --git a/src/filters/filter.js b/src/filters/filter.js index 508fda6..e6583a9 100644 --- a/src/filters/filter.js +++ b/src/filters/filter.js @@ -8,10 +8,7 @@ export function formatDate(time, fmt) { } const date = new Date(time) if (/(y+)/.test(fmt)) { - fmt = fmt.replace( - RegExp.$1, - (date.getFullYear() + '').substr(4 - RegExp.$1.length) - ) + fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)) } const o = { 'M+': date.getMonth() + 1, @@ -23,10 +20,7 @@ export function formatDate(time, fmt) { for (const k in o) { if (new RegExp(`(${k})`).test(fmt)) { const str = o[k] + '' - fmt = fmt.replace( - RegExp.$1, - RegExp.$1.length === 1 ? str : padLeftZero(str) - ) + fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : padLeftZero(str)) } } return fmt @@ -43,38 +37,3 @@ export function encodeUnicode(str) { } return '\\u' + res.join('\\u') } - -// 解码 -export function decodeUnicode(str) { - if (str === undefined || '') { - return - } - str = str.replace(/\\/g, '%') - return unescape(str) -} -/* - * 格式化金钱 - */ -export function formatMoney(value) { - return Number(value).toFixed(2) -} -export function formatCentMoney(value) { - if (value === undefined || '') { - return - } - return Number(value / 100).toFixed(2) -} -// 昵称解码 -export function formatName(nickname) { - if (!nickname) return '' - return decodeURIComponent(nickname) -} -// 折扣转换 -export function formatPercent(percent_off) { - if (!percent_off) return '' - if (percent_off == 1) { - return '原价' - } - // 解决精度丢失问题 - return Math.round(percent_off * 100) / 10 -} diff --git a/src/filters/index.js b/src/filters/index.js index 534ccbf..22808c8 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -4,9 +4,3 @@ import * as filter from './filter' Object.keys(filter).forEach(k => Vue.filter(k, filter[k])) Vue.prototype.$formatDate = Vue.filter('formatDate') -Vue.prototype.$encodeUnicode = Vue.filter('encodeUnicode') -Vue.prototype.$decodeUnicode = Vue.filter('decodeUnicode') -Vue.prototype.$formatMoney = Vue.filter('formatMoney') -Vue.prototype.$formatCentMoney = Vue.filter('formatCentMoney') -Vue.prototype.$formatName = Vue.filter('formatName') -Vue.prototype.$formatPercent = Vue.filter('formatPercent') diff --git a/src/main.js b/src/main.js index 9b39ec6..edfcc8d 100644 --- a/src/main.js +++ b/src/main.js @@ -10,10 +10,11 @@ import '@/filters' // filters import '@/utils/directives' // directives import '@/permission' // permission control import wechatAuth from './plugins/wechatAuth' // 微信登录插件 - +// 设置appid Vue.use(wechatAuth, { appid: process.env.VUE_APP_WECHAT_APPID }) +// 手机端调试工具 import VCconsole from 'vconsole' Vue.use(VCconsole) Vue.config.productionTip = false diff --git a/src/permission.js b/src/permission.js index 2ea698f..0a50ee1 100644 --- a/src/permission.js +++ b/src/permission.js @@ -5,11 +5,10 @@ import wechatAuth from './plugins/wechatAuth' // 微信登录插件 const qs = require('qs') router.beforeEach((to, from, next) => { - // store.dispatch('user/fedLogOut').then(() => { - // }) const loginStatus = Number(store.getters.loginStatus) console.log('loginStatus=' + loginStatus) console.log('token=' + store.getters.token) + // 页面标题 document.title = getPageTitle(to.meta.title) if (loginStatus === 0) { // 微信未授权登录跳转到授权登录页面 @@ -24,33 +23,35 @@ router.beforeEach((to, from, next) => { } else { loginUrl = url } - // alert(loginUrl) + // 设置微信授权回调地址 wechatAuth.redirect_uri = loginUrl // 无论拒绝还是授权都设置成1 store.dispatch('user/setLoginStatus', 1) + // 跳转到微信授权页面 window.location.href = wechatAuth.authUrl } else if (loginStatus === 1) { - // 微信已经授权回调获取code + // 用户已授权,获取code try { + // 通过回调链接设置code status wechatAuth.returnFromWechat(to.fullPath) } catch (err) { + // 失败,设置状态未登录,刷新页面 store.dispatch('user/setLoginStatus', 0) location.reload() - // next() } // 同意授权 to.fullPath 携带code参数,拒绝授权没有code参数 - // alert(to.fullPath) - // 重新赋值,不然获取不到code const code = wechatAuth.code - // alert(code) if (code) { + // 拿到code 访问服务端的登录接口 store .dispatch('user/loginWechatAuth', code) .then(res => { + // 成功设置已登录状态 store.dispatch('user/setLoginStatus', 2) next() }) .catch(() => { + // 失败,设置状态未登录,刷新页面 store.dispatch('user/setLoginStatus', 0) location.reload() }) @@ -59,7 +60,7 @@ router.beforeEach((to, from, next) => { location.reload() } } else { - // alert(to.fullPath) + // 已登录直接进入 next() } }) diff --git a/src/router/index.js b/src/router/index.js index b301ade..b4d1c9e 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -5,26 +5,9 @@ Vue.use(Router) export const constantRoutes = [ { path: '/', - redirect: '/account' - }, - { - path: '/account', - name: 'account', - component: () => import('@/views/account/index'), - meta: { - title: '个人中心', - keepAlive: false - } - }, - { - path: '/coupon', - name: 'coupon', - component: () => import('@/views/account/coupon'), - meta: { - title: '优惠券', - keepAlive: false - } + redirect: '/home' }, + { path: '/home', name: 'home', @@ -38,7 +21,7 @@ export const constantRoutes = [ const createRouter = () => new Router({ mode: 'history', // require service support - base: '/antpublic', + base: '/app/', scrollBehavior: () => ({ y: 0 }), routes: constantRoutes }) diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 3c247e6..26395b0 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -1,4 +1,3 @@ -import { login } from '@/api/user' import { loginByCode } from '@/api/user' import { saveToken, @@ -30,27 +29,15 @@ const mutations = { } const actions = { - loginUrl({ commit }, path) { - // const url = baseUrl + path - return new Promise((resolve, reject) => { - login({ redirectUri: path }) - .then(response => { - resolve(response) - }) - .catch(error => { - reject(error) - }) - }) - }, - // 登录相关 - loginWechatAuth({ commit, state }, code) { + // 登录相关,通过code获取token和用户信息 + loginWechatAuth({ commit }, code) { const data = { code: code } return new Promise((resolve, reject) => { loginByCode(data) .then(res => { - console.log(res) + // 存用户信息,token commit('SET_USERINFO', saveUserInfo(res.data.user)) commit('SET_TOKEN', saveToken(res.data.token)) resolve(res) @@ -61,20 +48,18 @@ const actions = { }) }, // 设置状态 - setLoginStatus({ commit, state }, query) { + setLoginStatus({ commit }, query) { if (query === 0 || query === 1) { - // 上线打开注释,本地调试注释掉 + // 上线打开注释,本地调试注释掉,保持信息最新 removeToken() removeUserInfo() } + // 设置不同的登录状态 commit('SET_LOGIN_STATUS', saveLoginStatus(query)) }, - // 保存用户个人信息 - setUserInfo({ commit, state }, query) { - commit('SET_USERINFO', saveUserInfo(query)) - }, // 登出 - fedLogOut({ commit, state }, query) { + fedLogOut() { + // 删除token,用户信息,登陆状态 removeToken() removeUserInfo() removeLoginStatus() diff --git a/src/utils/cache.js b/src/utils/cache.js index 72ee85b..1a42c26 100644 --- a/src/utils/cache.js +++ b/src/utils/cache.js @@ -1,66 +1,46 @@ import cookies from 'js-cookie' import storage from 'good-storage' - const LoginStatusKey = 'Login-Status' // 登录态 0未授权未登录 1授权未登录 2 登陆成功 const TokenKey = 'Access-Token' // token const UserInfoKey = 'User-Info' // 用户信息 {} {...} - +// 获取登录状态 export function loadLoginStatus() { return cookies.get(LoginStatusKey) || 0 - // var arr - // var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)') - // if ((arr = document.cookie.match(reg))) return unescape(arr[2]) - // else return null } - -// export function saveLoginStatus(status) { -// cookies.set(LoginStatusKey, status, { expires: 7 }) -// return status -// } - +// 保持登录状态 export function saveLoginStatus(status) { - // storage.set(LoginStatusKey, status) - var date = new Date() - date.setTime(date.getTime() + 5 * 60 * 1000) // 设置date为当前时间+5分 - document.cookie = LoginStatusKey + '=' + status + '; expires=' + date.toGMTString() // 将date赋值给expires - // var exp = new Date() - // exp.setTime(exp.getTime() + 5 * 60 * 1000) - // document.cookie = LoginStatusKey + '=' + escape(status) + ';expires=' + exp.toGMTString() + cookies.set(LoginStatusKey, status, { expires: 7 }) return status } - +// 删除登录状态 export function removeLoginStatus() { - // var exp = new Date() - // exp.setTime(exp.getTime() - 1) - // var cval = saveLoginStatus(LoginStatusKey) - // if (cval != null) document.cookie = LoginStatusKey + '=' + cval + ';expires=' + exp.toGMTString() cookies.remove(LoginStatusKey) return '' } - +// 获取token export function loadToken() { return storage.get(TokenKey, '') } - +// 保存token export function saveToken(token) { storage.set(TokenKey, token) return token } - +// 删除token export function removeToken() { storage.remove(TokenKey) return '' } - +// 获取用户信息 export function loadUserInfo() { return storage.get(UserInfoKey, {}) } - +// 保存用户信息 export function saveUserInfo(userInfo) { storage.set(UserInfoKey, userInfo) return userInfo } - +// 删除用户信息 export function removeUserInfo() { storage.remove(UserInfoKey) return {} diff --git a/src/utils/get-page-title.js b/src/utils/get-page-title.js index 122e5b6..4d0a141 100644 --- a/src/utils/get-page-title.js +++ b/src/utils/get-page-title.js @@ -1,4 +1,4 @@ -const title = '蚁小宝' +const title = '微信网页授权demo' export default function getPageTitle(pageTitle) { if (pageTitle) { return `${pageTitle} - ${title}` diff --git a/src/utils/package.js b/src/utils/package.js deleted file mode 100644 index 5016d9c..0000000 --- a/src/utils/package.js +++ /dev/null @@ -1,124 +0,0 @@ -/* - * @Author: sunnie.Song - * @Date: 2019-05-27 10:01:46 - * @Description: 接口签名说明文档 - */ - -import { APPID, APPSECRET } from '../config/index' -import CryptoJS from 'crypto-js' -/** - *对排序后的key值取值并生成 - */ -function objKeySort(obj) { - // 将obj中的所有key取出放入数组中,并按照ASCII排序 返回排序后的数组 - var newKey = Object.keys(obj).sort() - - var sortString = '' - // 将obj转化为排序后的键值对使用'key=value&key=value'方式转为字符串 - for (var i = 0; i < newKey.length; i++) { - sortString = sortString + newKey[i] + '=' + obj[newKey[i]] + '&' - } - // 返回字符串去除最有一个'&' - return sortString.substring(0, sortString.length - 1) -} -/* 参数编码序列*/ -function serializeParams(obj) { - const arr = [] - // key的vaule为空的时候,删除该key - const params = Object.assign({}, obj) - for (const key in params) { - if (!params[key]) { - delete params[key] - } - } - Object.keys(params).forEach(key => { - let value = params[key] - // 如果值为undefined,置空 - if (typeof value === 'undefined') { - value = '' - } - // 对于需要编码的文本(比如说中文)我们要进行编码 - arr.push([key, encodeURIComponent(value)].join('=')) - }) - return arr.join('&') -} -function isChineseChar(str) { - var reg = /[\u4E00-\u9FA5\uF900-\uFA2D]|[\u3002|\uff1f|\uff01|\uff0c|\u3001|\uff1b|\uff1a|\u201c|\u201d|\u2018|\u2019|\uff08|\uff09|\u300a|\u300b|\u3008|\u3009|\u3010|\u3011|\u300e|\u300f|\u300c|\u300d|\ufe43|\ufe44|\u3014|\u3015|\u2026|\u2014|\uff5e|\ufe4f|\uffe5]/ - - return reg.test(str) -} -function encodeParams(obj) { - // const arr = [] - // key的vaule为空的时候,删除该key - const params = Object.assign({}, obj) - // for (const key in params) { - // if (!params[key]) { - // delete params[key] - // } - // } - Object.keys(params).forEach(key => { - let value = params[key] - // 如果值为undefined,置空 - if (typeof value === 'undefined') { - value = '' - } - // 如果有汉子 - if (isChineseChar(value)) { - params[key] = encodeURIComponent(value) - } else { - params[key] = value - } - }) - return params -} -/** - * 将参数打包 - * apiName: 接口名称 - * param: 参数obj 可选 - * isReturnStr: Boolean 可选 post是否返回string - */ - -function baleParams(apiName, param, isReturnStr) { - // 获取系统当前时间戳(精确到毫秒13位) //1511257250001 - var timestamp = new Date().valueOf() - /** - * appId : 10010 系统账号 (参与签名) - * appSecret :10011 系统账号密码(参与签名) - * apiName :接口名称(参与签名) - * params : 接口参数json格式 (参与签名,没有则不参与) - */ - - const paramObj = { - appId: APPID, - appSecret: APPSECRET, - apiName: apiName, - timeStamp: timestamp - } - // 参数 - if (param !== undefined) { - // 将参数转为json字符串 - const encode = encodeParams(param) - paramObj.params = JSON.stringify(encode) - } - // 参数按ASCII排序,返回使用'=','&'拼接的字符串 - const sort = objKeySort(paramObj) - // 将排序好的字符串使用MD5签名,并返回大写字符串 - // const sign = MD5.hexMD5(sort).toLocaleUpperCase() - var sign = CryptoJS.MD5(sort) - .toString(CryptoJS.enc.Hex) - .toLocaleUpperCase() - // 将appid, apiname, 时间戳 ,签名 重新作为参数传给服务器 - let parameters = { - appId: paramObj.appId, - timeStamp: timestamp, - apiName: apiName, - sign: sign, - params: paramObj.params - } - // 是否序列表 - if (isReturnStr === true) { - parameters = serializeParams(parameters) - } - return parameters -} -export default baleParams diff --git a/src/utils/request.js b/src/utils/request.js index b23b48d..7b61fbe 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -20,7 +20,7 @@ service.interceptors.request.use( }) } if (store.getters.token) { - config.headers['ukey'] = store.getters.token + config.headers['token'] = store.getters.token } return config }, @@ -35,6 +35,7 @@ service.interceptors.response.use( response => { Toast.clear() const res = response.data + // 这里注意修改成你访问的服务端接口规则 if (res.status && res.status !== 200) { Toast({ message: res.info diff --git a/vue.config.js b/vue.config.js index 345edf2..90f60a9 100644 --- a/vue.config.js +++ b/vue.config.js @@ -11,8 +11,7 @@ const externals = { 'vue-router': 'VueRouter', vuex: 'Vuex', vant: 'vant', - axios: 'axios', - 'crypto-js': 'CryptoJS' + axios: 'axios' } // cdn const cdn = { @@ -30,15 +29,13 @@ const cdn = { 'https://cdnjs.cloudflare.com/ajax/libs/vue-router/3.0.6/vue-router.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/vuex/3.1.1/vuex.min.js', - 'https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.min.js', 'https://cdn.jsdelivr.net/npm/vant@beta/lib/vant.min.js' ] } } module.exports = { - publicPath: process.env.NODE_ENV === 'production' ? '/antpublic/' : '/', + publicPath: process.env.NODE_ENV === 'development' ? '/' : '/app/', // 需要根据环境设置,不然会报错 outputDir: 'dist', - // outputDir: '../../../phpStudy/PHPTutorial/WWW/antpublic', assetsDir: 'static', lintOnSave: process.env.NODE_ENV === 'development', productionSourceMap: false, @@ -57,7 +54,6 @@ module.exports = { // externals里的模块不打包 Object.assign(config, { name: defaultSettings.title, - // entry: ['@babel/polyfill', './src/main.js'], externals: externals, optimization: { minimize: false // 换行 @@ -104,9 +100,7 @@ module.exports = { config // https://webpack.js.org/configuration/devtool/#development - .when(process.env.NODE_ENV === 'development', config => - config.devtool('cheap-source-map') - ) + .when(process.env.NODE_ENV === 'development', config => config.devtool('cheap-source-map')) config.when(process.env.NODE_ENV !== 'development', config => { config