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://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~ # @Author: Aimee~
# @Date: 2023-05-11 11:17:32 # @Date: 2023-05-11 11:17:32
# @LastEditTime: 2023-07-05 11:08:59 # @LastEditTime: 2023-07-28 09:49:14
# @LastEditors: Aimee # @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 # @FilePath: /douhuo-agent/.env.development
# @Description: 正式环境测试环境更改 # @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://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~ # @Author: Aimee~
# @Date: 2023-05-11 11:17:32 # @Date: 2023-05-11 11:17:32
# @LastEditTime: 2023-07-05 11:08:51 # @LastEditTime: 2023-07-28 10:09:13
# @LastEditors: Aimee # @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 # @FilePath: /douhuo-agent/.env.preview
# @Description: # @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://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' import request from '@/utils/request'
const userApi = { const userApi = {
SendSms: '/staff/verify', SendSms: '/staff/verify',
Login: '/auth/sms', Login: '/auth/sms',
Logout: '/auth/logout', Logout: '/auth/logout',
CommonLogin: '/staff/login', CommonLogin: '/middles/auth/login', // 登录接口
forgetPassword: '/staff/forget/password', forgetPassword: '/staff/forget/password',
password: '/staff/password', password: '/staff/password',
// get my info // get my info
UserPermission: '/staff', middleUser: '/middles/user', // 获取经销商信息
getScanCode: '/staff/scan_code', getScanCode: '/staff/scan_code',
getVerifyScanCode: '/staff/verify_subscribe' getVerifyScanCode: '/staff/verify_subscribe'
} }
@@ -59,9 +67,9 @@ export function getSmsCaptcha (parameter) {
}) })
} }
export function getPermission () { export function getMiddleUser () {
return request({ return request({
url: userApi.UserPermission, url: userApi.middleUser,
method: 'get' method: 'get'
}) })
} }

View File

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

View File

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