This commit is contained in:
JasonChen
2023-07-28 10:53:32 +08:00
parent 6e8230e4c8
commit 628af5cef7
6 changed files with 98 additions and 73 deletions

3
.env
View File

@@ -4,4 +4,5 @@ VUE_APP_PREVIEW=false
# VUE_APP_API_BASE_URL=https://douhuo.douhuofalv.com/agent
# <!-- // 水感应测试-->
VUE_APP_API_BASE_URL=https://api.douhuotest.douhuofalv.com/agent
# VUE_APP_API_BASE_URL=https://api.douhuotest.douhuofalv.com/agent
VUE_APP_API_BASE_URL=https://shuitest.shuiganying.com/api

View File

@@ -1,8 +1,8 @@
###
# @Author: Aimee~
# @Date: 2023-05-11 11:17:32
# @LastEditTime: 2023-07-05 11:08:59
# @LastEditors: Aimee
# @LastEditTime: 2023-07-28 09:49:14
# @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
# @FilePath: /douhuo-agent/.env.development
# @Description: 正式环境测试环境更改
###
@@ -12,4 +12,5 @@ VUE_APP_PREVIEW=true
# VUE_APP_API_BASE_URL=https://douhuo.douhuofalv.com/agent
# <!-- //水感应测试-->
VUE_APP_API_BASE_URL=https://api.douhuotest.douhuofalv.com/agent
# VUE_APP_API_BASE_URL=https://api.douhuotest.douhuofalv.com/agent
VUE_APP_API_BASE_URL=https://shuitest.shuiganying.com/api

View File

@@ -1,8 +1,8 @@
###
# @Author: Aimee~
# @Date: 2023-05-11 11:17:32
# @LastEditTime: 2023-07-05 11:08:51
# @LastEditors: Aimee
# @LastEditTime: 2023-07-28 10:09:13
# @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
# @FilePath: /douhuo-agent/.env.preview
# @Description:
###
@@ -12,4 +12,5 @@ VUE_APP_PREVIEW=true
# VUE_APP_API_BASE_URL=https://douhuo.douhuofalv.com/agent
# <!-- //水感应测试-->
VUE_APP_API_BASE_URL=https://api.douhuotest.douhuofalv.com/agent
# VUE_APP_API_BASE_URL=https://api.douhuotest.douhuofalv.com/agent
VUE_APP_API_BASE_URL=https://shuitest.shuiganying.com/api

View File

@@ -1,14 +1,22 @@
/*
* @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
* @Date: 2023-07-07 14:02:05
* @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
* @LastEditTime: 2023-07-28 10:28:12
* @FilePath: /water_dealer-agent/src/api/login.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import request from '@/utils/request'
const userApi = {
SendSms: '/staff/verify',
Login: '/auth/sms',
Logout: '/auth/logout',
CommonLogin: '/staff/login',
CommonLogin: '/middles/auth/login', // 登录接口
forgetPassword: '/staff/forget/password',
password: '/staff/password',
// get my info
UserPermission: '/staff',
middleUser: '/middles/user', // 获取经销商信息
getScanCode: '/staff/scan_code',
getVerifyScanCode: '/staff/verify_subscribe'
}
@@ -59,9 +67,9 @@ export function getSmsCaptcha (parameter) {
})
}
export function getPermission () {
export function getMiddleUser () {
return request({
url: userApi.UserPermission,
url: userApi.middleUser,
method: 'get'
})
}

View File

@@ -1,5 +1,5 @@
import storage from 'store'
import { getPermission, login, commonLogin } from '@/api/login'
import { getMiddleUser, login, commonLogin } from '@/api/login'
import { ACCESS_TOKEN } from '@/store/mutation-types'
const user = {
@@ -50,7 +50,7 @@ const user = {
login(userInfo).then(response => {
storage.set(ACCESS_TOKEN, 'Bearer ' + response.access_token, 7 * 24 * 60 * 60 * 1000)
commit('SET_TOKEN', 'Bearer ' + response.access_token)
dispatch('GetPermission')
dispatch('GetMiddleUser')
resolve(response.is_company)
}).catch(error => {
reject(error)
@@ -62,15 +62,18 @@ const user = {
return new Promise((resolve, reject) => {
commonLogin(userInfo).then(response => {
// 实名允许登录
if (response.real_name_status) {
// 实名且关注公众号让登录
// if (response.is_subscribe) {
storage.set(ACCESS_TOKEN, 'Bearer ' + response.access_token, 7 * 24 * 60 * 60 * 1000)
commit('SET_TOKEN', 'Bearer ' + response.access_token)
dispatch('GetPermission')
resolve(response)
return
}
// if (response.real_name_status) {
// // 实名且关注公众号让登录
// // if (response.is_subscribe) {
// storage.set(ACCESS_TOKEN, 'Bearer ' + response.access_token, 7 * 24 * 60 * 60 * 1000)
// commit('SET_TOKEN', 'Bearer ' + response.access_token)
// dispatch('GetMiddleUser')
// resolve(response)
// return
// }
storage.set(ACCESS_TOKEN, 'Bearer ' + response.access_token, 7 * 24 * 60 * 60 * 1000)
commit('SET_TOKEN', 'Bearer ' + response.access_token)
dispatch('GetMiddleUser')
resolve(response)
}).catch(error => {
reject(error)
@@ -79,16 +82,17 @@ const user = {
},
// 获取用户信息
GetPermission ({ commit }) {
GetMiddleUser ({ commit }) {
return new Promise((resolve, reject) => {
getPermission().then(res => {
storage.set('userid', res.staff_id)
commit('SET_USER_ID', res.staff_id)
commit('SET_USERTYPE', res.type)
getMiddleUser().then(res => {
console.log(res)
// storage.set('middleground_id', res.middleground_id)
commit('SET_USER_ID', res.middleground_id)
// commit('SET_USERTYPE', res.type)
commit('SET_USERNAME', res.username)
commit('SET_NICKNAME', res.name)
commit('SET_AVATAR', res.avatar || '')
commit('SET_INFO', res || '')
// commit('SET_AVATAR', res.avatar || '')
// commit('SET_INFO', res || '')
resolve(res)
}).catch(error => {
reject(error)

View File

@@ -69,7 +69,10 @@ import {
} from '@/utils/util'
import storage from 'store'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { getScanCode, getVerifyScanCode } from '@/api/login'
import {
// getScanCode,
getVerifyScanCode
} from '@/api/login'
export default {
name: 'Login',
@@ -109,6 +112,7 @@ export default {
password: this.postData.password
})
.then((res) => {
console.log(res)
this.loginSuccess(res)
})
.catch((err) => {
@@ -116,46 +120,55 @@ export default {
})
},
loginSuccess (res) {
if (res.is_company === false) {
this.$notification['error']({
message: '错误',
description: '不是供应商,不能登录供应商平台',
duration: 4
})
} else {
if (!res.real_name_status) {
this.$confirm({
content: '当前用户还没有完成实名认证,请先完成实名认证',
onOk: () => {
window.location.href = res.auth_url
},
cancelText: '再想想'
})
return
}
if (res.real_name_status && !res.is_subscribe) {
getScanCode()
.then((res) => {
this.subscribeUrl = res.code
this.showScan = true
})
.catch((err) => {
this.$notification.error(err)
})
return
}
storage.set('is_subscribe', true)
// 延迟 1 秒显示欢迎信息
setTimeout(() => {
this.$notification.success({
// if (res.is_company === false) {
// this.$notification['error']({
// message: '错误',
// description: '不是供应商,不能登录供应商平台',
// duration: 4
// })
// } else {
// // if (!res.real_name_status) {
// // this.$confirm({
// // content: '当前用户还没有完成实名认证,请先完成实名认证',
// // onOk: () => {
// // window.location.href = res.auth_url
// // },
// // cancelText: '再想想'
// // })
// // return
// // }
// // if (res.real_name_status && !res.is_subscribe) {
// // getScanCode()
// // .then((res) => {
// // this.subscribeUrl = res.code
// // this.showScan = true
// // })
// // .catch((err) => {
// // this.$notification.error(err)
// // })
// // return
// // }
// // storage.set('is_subscribe', true)
// // 延迟 1 秒显示欢迎信息
// setTimeout(() => {
// this.$notification.success({
// message: '欢迎',
// description: `${ timeFix() },欢迎回来`
// })
// this.$router.replace({
// path: '/'
// })
// }, 500)
// }
this.$notification.success({
message: '欢迎',
description: `${ timeFix() },欢迎回来`
})
setTimeout(() => {
this.$router.replace({
path: '/'
})
}, 300)
}
path: '/'
})
}, 1000)
},
OnSubCancel () {
storage.set(ACCESS_TOKEN, '')
@@ -164,18 +177,15 @@ export default {
getVerifyScanCode()
.then((res1) => {
storage.set('is_subscribe', res1.is_subscribe)
if (res1.is_subscribe) {
this.commonLogin({
username: this.postData.phone,
password: this.postData.password
}).then((res) => {
this.loginSuccess(res)
}).catch((err) => {
this.requestFailed(err)
})
.then((res) => {
this.loginSuccess(res)
})
.catch((err) => {
this.requestFailed(err)
})
} else {
this.$notification.warn({
message: '温馨提醒',