Commit 61ac71151b86c93e1124e1eccc184e081be3da71
1 parent
98cfd1c0
接口地址修改
Showing
2 changed files
with
10 additions
and
9 deletions
project-wl-kuaidiyuan-uniapp-vue3/pages/login/user.vue
| @@ -52,7 +52,6 @@ import { userLogins } from '../api/user.js'; | @@ -52,7 +52,6 @@ import { userLogins } from '../api/user.js'; | ||
| 52 | // 导入接口 | 52 | // 导入接口 |
| 53 | import { getHomeInfo } from '@/pages/api/index.js'; | 53 | import { getHomeInfo } from '@/pages/api/index.js'; |
| 54 | 54 | ||
| 55 | -import { encrypt, decrypt } from '@/utils/crypto.js' | ||
| 56 | 55 | ||
| 57 | // ------定义变量------ | 56 | // ------定义变量------ |
| 58 | const store = useStore(); //vuex获取储存数据 | 57 | const store = useStore(); //vuex获取储存数据 |
| @@ -94,7 +93,7 @@ onMounted(() => { | @@ -94,7 +93,7 @@ onMounted(() => { | ||
| 94 | const accountHistory = uni.getStorageSync('accountHistory') | 93 | const accountHistory = uni.getStorageSync('accountHistory') |
| 95 | if(accountHistory) { | 94 | if(accountHistory) { |
| 96 | fromInfo.account = accountHistory.account | 95 | fromInfo.account = accountHistory.account |
| 97 | - fromInfo.password = decrypt(accountHistory.password) | 96 | + fromInfo.password = accountHistory.password |
| 98 | // console.log(accountHistory) | 97 | // console.log(accountHistory) |
| 99 | } | 98 | } |
| 100 | 99 | ||
| @@ -115,6 +114,7 @@ const handleSubmit = async () => { | @@ -115,6 +114,7 @@ const handleSubmit = async () => { | ||
| 115 | },500) | 114 | },500) |
| 116 | await userLogins(fromInfo) | 115 | await userLogins(fromInfo) |
| 117 | .then(async res => { | 116 | .then(async res => { |
| 117 | + console.log('success', res) | ||
| 118 | if (res.code === 200) { | 118 | if (res.code === 200) { |
| 119 | // 操作成功后清除loading | 119 | // 操作成功后清除loading |
| 120 | setTimeout(function () { | 120 | setTimeout(function () { |
| @@ -126,7 +126,7 @@ const handleSubmit = async () => { | @@ -126,7 +126,7 @@ const handleSubmit = async () => { | ||
| 126 | store.commit('user/setToken', res.data.token); | 126 | store.commit('user/setToken', res.data.token); |
| 127 | 127 | ||
| 128 | //存储用户账号和密码,密码加密存储 | 128 | //存储用户账号和密码,密码加密存储 |
| 129 | - const data = { account: fromInfo.account, password: encrypt(fromInfo.password) } | 129 | + const data = { account: fromInfo.account, password: fromInfo.password } |
| 130 | uni.setStorageSync('accountHistory', data) | 130 | uni.setStorageSync('accountHistory', data) |
| 131 | // // 通过vuex获取用户信息 | 131 | // // 通过vuex获取用户信息 |
| 132 | store.dispatch('user/GetUsersInfo'); | 132 | store.dispatch('user/GetUsersInfo'); |
| @@ -147,6 +147,7 @@ const handleSubmit = async () => { | @@ -147,6 +147,7 @@ const handleSubmit = async () => { | ||
| 147 | } | 147 | } |
| 148 | }) | 148 | }) |
| 149 | .catch(err => { | 149 | .catch(err => { |
| 150 | + console.log('error', err) | ||
| 150 | // uni.showToast({ | 151 | // uni.showToast({ |
| 151 | // title: err.msg, | 152 | // title: err.msg, |
| 152 | // duration: 15000, | 153 | // duration: 15000, |
project-wl-kuaidiyuan-uniapp-vue3/utils/request.js
| 1 | -// import { baseUrl } from "./env"; | 1 | +import { baseUrl } from "./env"; |
| 2 | // 参数: url:请求地址 param:请求参数 method:请求方式 callBack:回调函数 | 2 | // 参数: url:请求地址 param:请求参数 method:请求方式 callBack:回调函数 |
| 3 | +// import { } from '' | ||
| 4 | + | ||
| 3 | export function request({ url = "", params = {}, method = "GET" }) { | 5 | export function request({ url = "", params = {}, method = "GET" }) { |
| 4 | // baseUrl改为可配置地址 | 6 | // baseUrl改为可配置地址 |
| 5 | - if (!uni.getStorageSync('baseUrl')){ | ||
| 6 | - uni.setStorageSync('baseUrl', 'https://tms-gateway.zrpfsc.com/courier') | ||
| 7 | - } | ||
| 8 | - let baseUrl = uni.getStorageSync('baseUrl') | ||
| 9 | - | 7 | + console.log('baseUrl', baseUrl) |
| 10 | // 获取token | 8 | // 获取token |
| 11 | const token = uni.getStorageSync("token"); | 9 | const token = uni.getStorageSync("token"); |
| 12 | let header = { | 10 | let header = { |
| @@ -19,6 +17,7 @@ export function request({ url = "", params = {}, method = "GET" }) { | @@ -19,6 +17,7 @@ export function request({ url = "", params = {}, method = "GET" }) { | ||
| 19 | header['Content-Type'] = 'application/x-www-form-urlencoded' | 17 | header['Content-Type'] = 'application/x-www-form-urlencoded' |
| 20 | } | 18 | } |
| 21 | const requestRes = new Promise((resolve, reject) => { | 19 | const requestRes = new Promise((resolve, reject) => { |
| 20 | + console.log('fullUrl:', baseUrl + url) | ||
| 22 | uni.request({ | 21 | uni.request({ |
| 23 | url: baseUrl + url, | 22 | url: baseUrl + url, |
| 24 | data: params, | 23 | data: params, |
| @@ -63,6 +62,7 @@ export function request({ url = "", params = {}, method = "GET" }) { | @@ -63,6 +62,7 @@ export function request({ url = "", params = {}, method = "GET" }) { | ||
| 63 | reject(res.data); | 62 | reject(res.data); |
| 64 | } | 63 | } |
| 65 | }).catch((err)=>{ | 64 | }).catch((err)=>{ |
| 65 | + console.log('request error:', err) | ||
| 66 | const error = { data: { msg: err.data } }; | 66 | const error = { data: { msg: err.data } }; |
| 67 | reject(error); | 67 | reject(error); |
| 68 | }); | 68 | }); |