Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
严立
/
cd-bid
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b14fe58b
authored
Feb 22, 2021
by
严立
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
列表查看公告详情方式优化 | 添加中标信息类型 | 供应商地址异常处理
parent
2da8c6e0
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
242 additions
and
233 deletions
src/common/js/request/interceptors.js
src/common/js/request/request.js
src/view/home.vue
src/view/personal/supplier-info.vue
src/view/personal/supplier-notice.vue
src/view/personal/supplier-orders-detail.vue
src/view/register-supplier.vue
src/common/js/request/interceptors.js
View file @
b14fe58b
import
iVue
from
'../../../main.js'
import
iHost
from
'../host.js'
let
timerClose
=
0
let
loading
=
null
let
loadingFilter
=
[
'bid/order/queryState'
,
// 查询支付状态
'bid/common/getImgCode'
,
// 获取图片验证
]
let
output
=
{
/**
* 请求拦截器
* @function
* @param {object} funcConfigure - 请求配置
* @returns {boolean}
*/
request
:
function
(
funXmlHttpRequest
,
funcConfigure
,
funcUrl
)
{
funcUrl
=
funcUrl
.
replace
(
iHost
.
base
,
''
)
// 只有不被过滤的接口才会显示加载动画
if
(
loadingFilter
.
indexOf
(
funcUrl
)
===
-
1
)
{
if
(
loading
===
null
)
{
loading
=
iVue
.
$loading
({
lock
:
false
,
text
:
'Loading'
,
spinner
:
'el-icon-loading'
,
background
:
'rgba(255, 255, 255, 0.7)'
})
}
if
(
timerClose
!==
0
)
{
clearTimeout
(
timerClose
)
}
}
// 默认添加 token 属性
if
(
funcConfigure
.
isToken
)
{
funXmlHttpRequest
.
setRequestHeader
(
'token'
,
localStorage
.
getItem
(
'token'
))
}
},
/**
* 响应拦截器
* @function
* @param {object} funcConfigure - 请求配置
* @param {object} funcResult - 响应数据
* @returns {boolean}
*/
response
:
function
(
funcConfigure
,
funcResult
)
{
if
(
loading
)
{
timerClose
=
setTimeout
(()
=>
{
if
(
loading
)
{
loading
.
close
()
}
loading
=
null
clearTimeout
(
timerClose
)
},
500
)
}
let
funcDataType
=
''
try
{
JSON
.
parse
(
funcResult
)
funcDataType
=
'object'
}
catch
(
funcError
)
{
funcDataType
=
'other'
}
if
(
funcDataType
===
'object'
)
{
let
funcResultData
=
JSON
.
parse
(
funcResult
)
switch
(
Number
(
funcResultData
.
code
))
{
case
10001
:
console
.
log
(
'token overdue'
)
this
.
$store
.
commit
(
'isSignIn'
,
false
)
this
.
$store
.
commit
(
'redirectPath'
,
null
)
localStorage
.
clear
()
iVue
.
$router
.
push
(
'/'
)
return
{
state
:
false
,
response
:
{
message
:
funcResultData
.
msg
}}
break
// 请求正常直接返回 data 内容
case
200
:
return
{
state
:
true
,
response
:
funcResultData
.
data
}
break
// 请求正常直接返回 data 内容
case
400
:
return
{
state
:
false
,
response
:
{
message
:
funcResultData
.
msg
,
data
:
funcResultData
.
data
}}
break
// 请求异常返回 msg 错误提示
default
:
return
{
state
:
false
,
response
:
{
message
:
funcResultData
.
msg
}}
break
}
}
return
funcResult
}
}
export
default
output
import
iVue
from
'../../../main.js'
import
iHost
from
'../host.js'
let
timerClose
=
0
let
loading
=
null
let
loadingFilter
=
[
'bid/order/queryState'
,
// 查询支付状态
'bid/common/getImgCode'
,
// 获取图片验证
]
let
output
=
{
/**
* 请求拦截器
* @function
* @param {object} funcConfigure - 请求配置
* @returns {boolean}
*/
request
:
function
(
funXmlHttpRequest
,
funcConfigure
,
funcUrl
)
{
funcUrl
=
funcUrl
.
replace
(
iHost
.
base
,
''
)
// 只有不被过滤的接口才会显示加载动画
if
(
loadingFilter
.
indexOf
(
funcUrl
)
===
-
1
)
{
if
(
loading
===
null
)
{
loading
=
iVue
.
$loading
({
lock
:
false
,
text
:
'Loading'
,
spinner
:
'el-icon-loading'
,
background
:
'rgba(255, 255, 255, 0.7)'
})
}
if
(
timerClose
!==
0
)
{
clearTimeout
(
timerClose
)
}
}
// 默认添加 token 属性
if
(
funcConfigure
.
isToken
)
{
funXmlHttpRequest
.
setRequestHeader
(
'token'
,
localStorage
.
getItem
(
'token'
))
}
},
/**
* 响应拦截器
* @function
* @param {object} funcConfigure - 请求配置
* @param {object} funcResult - 响应数据
* @returns {boolean}
*/
response
:
function
(
funcConfigure
,
funcResult
)
{
if
(
loading
)
{
timerClose
=
setTimeout
(()
=>
{
if
(
loading
)
{
loading
.
close
()
}
loading
=
null
clearTimeout
(
timerClose
)
},
500
)
}
let
funcDataType
=
''
try
{
JSON
.
parse
(
funcResult
)
funcDataType
=
'object'
}
catch
(
funcError
)
{
funcDataType
=
'other'
}
if
(
funcDataType
===
'object'
)
{
let
funcResultData
=
JSON
.
parse
(
funcResult
)
switch
(
Number
(
funcResultData
.
code
))
{
case
10001
:
console
.
log
(
'token overdue'
)
this
.
$store
.
commit
(
'isSignIn'
,
false
)
this
.
$store
.
commit
(
'redirectPath'
,
null
)
localStorage
.
clear
()
iVue
.
$router
.
push
(
'/'
)
return
{
state
:
false
,
response
:
{
message
:
funcResultData
.
msg
}}
break
// 请求正常直接返回 data 内容
case
200
:
if
(
funcResultData
.
msg
===
'登录失效'
)
{
return
{
state
:
false
,
response
:
{
message
:
funcResultData
.
msg
}}
}
return
{
state
:
true
,
response
:
funcResultData
.
data
}
break
// 请求正常直接返回 data 内容
case
400
:
return
{
state
:
false
,
response
:
{
message
:
funcResultData
.
msg
,
data
:
funcResultData
.
data
}}
break
// 请求异常返回 msg 错误提示
default
:
return
{
state
:
false
,
response
:
{
message
:
funcResultData
.
msg
}}
break
}
}
return
funcResult
}
}
export
default
output
src/common/js/request/request.js
View file @
b14fe58b
import
iHeader
from
'./header.js'
import
iDataform
from
'./dataform.js'
import
iConfigure
from
'./configure.js'
import
iInterceptors
from
'./interceptors.js'
import
iVue
from
'../../../main.js'
let
output
=
{
/**
* 通用请求函数
* @function
* @param {string} funcUrl - 完整请求路径
* @param {object} funcData - 请求数据
* @param {string} funcType - 请求数据类型
* @param {string} funcMethod - 请求方法
* @param {object} funcOther - 其他配置
*/
request
:
function
(
funcUrl
,
funcData
,
funcSendType
,
funcMethod
,
funcOther
)
{
// 获取默认请求设置
let
funcConfigure
=
JSON
.
parse
(
JSON
.
stringify
(
iConfigure
))
Object
.
assign
(
funcConfigure
,
funcOther
)
// 检查数据发放方式有效性
if
(
funcSendType
&&
iConfigure
.
sendTypeEnumeration
.
indexOf
(
funcSendType
.
toLowerCase
())
>=
0
)
{
funcConfigure
.
sendType
=
funcSendType
.
toLowerCase
()
}
// 检查请求方法字段有效性
if
(
funcMethod
&&
iConfigure
.
methodEnumeration
.
indexOf
(
funcMethod
)
>=
0
)
{
funcConfigure
.
method
=
funcMethod
}
// get 请求需要将参数转换为 url 形式
if
(
funcConfigure
.
method
===
'get'
)
{
// 设置数据类型
funcData
=
iDataform
(
funcData
,
'url'
)
let
funcPromise
=
new
Promise
(
function
(
funcResolve
,
funcReject
)
{
let
funcXMLHttpRequest
=
new
XMLHttpRequest
()
funcXMLHttpRequest
.
open
(
funcConfigure
.
method
,
funcUrl
+
funcData
,
true
)
// 请求之前修改
iHeader
(
funcXMLHttpRequest
,
funcConfigure
)
iInterceptors
.
request
(
funcXMLHttpRequest
,
funcConfigure
,
funcUrl
)
funcXMLHttpRequest
.
send
()
funcXMLHttpRequest
.
onreadystatechange
=
function
()
{
if
(
funcXMLHttpRequest
.
readyState
!==
4
)
{
return
}
let
funStatus
=
funcXMLHttpRequest
.
status
if
((
funStatus
>=
200
&&
funStatus
<
300
)
||
funStatus
===
304
)
{
let
funcInterceptorsResponse
=
iInterceptors
.
response
(
funcConfigure
,
funcXMLHttpRequest
.
responseText
)
if
(
funcInterceptorsResponse
.
state
)
{
funcResolve
(
funcInterceptorsResponse
.
response
)
}
else
{
iVue
.
$message
.
error
(
funcInterceptorsResponse
.
response
.
message
)
}
}
else
{
let
funcInterceptorsResponse
=
iInterceptors
.
response
(
funcConfigure
,
funcXMLHttpRequest
.
responseText
)
if
(
funcInterceptorsResponse
.
state
)
{
funcResolve
(
funcInterceptorsResponse
.
response
)
}
else
{
iVue
.
$message
.
error
(
funcInterceptorsResponse
.
response
.
message
)
}
}
}
})
return
funcPromise
}
if
(
funcConfigure
.
method
===
'post'
)
{
// 设置数据类型
funcData
=
iDataform
(
funcData
,
funcConfigure
.
sendType
)
let
funcPromise
=
new
Promise
(
function
(
funcResolve
,
funcReject
)
{
let
funcXMLHttpRequest
=
new
XMLHttpRequest
()
funcXMLHttpRequest
.
open
(
funcConfigure
.
method
,
funcUrl
,
true
)
// 请求之前修改
iHeader
(
funcXMLHttpRequest
,
funcConfigure
)
iInterceptors
.
request
(
funcXMLHttpRequest
,
funcConfigure
,
funcUrl
)
funcXMLHttpRequest
.
send
(
funcData
)
funcXMLHttpRequest
.
onreadystatechange
=
function
()
{
if
(
funcXMLHttpRequest
.
readyState
!==
4
)
{
return
}
let
funStatus
=
funcXMLHttpRequest
.
status
if
((
funStatus
>=
200
&&
funStatus
<
300
)
||
funStatus
===
304
)
{
let
funcInterceptorsResponse
=
iInterceptors
.
response
(
funcConfigure
,
funcXMLHttpRequest
.
responseText
)
if
(
funcInterceptorsResponse
.
state
)
{
funcResolve
(
funcInterceptorsResponse
.
response
)
}
else
{
console
.
log
(
'funcReject'
)
iVue
.
$message
.
error
(
funcInterceptorsResponse
.
response
.
message
)
funcReject
(
funcInterceptorsResponse
.
response
)
}
}
else
{
let
funcInterceptorsResponse
=
iInterceptors
.
response
(
funcConfigure
,
funcXMLHttpRequest
.
responseText
)
if
(
funcInterceptorsResponse
.
state
)
{
funcResolve
(
funcInterceptorsResponse
.
response
)
}
else
{
iVue
.
$message
.
error
(
funcInterceptorsResponse
.
response
.
message
)
}
}
}
})
return
funcPromise
}
},
}
import
iHeader
from
'./header.js'
import
iDataform
from
'./dataform.js'
import
iConfigure
from
'./configure.js'
import
iInterceptors
from
'./interceptors.js'
import
iVue
from
'../../../main.js'
let
output
=
{
/**
* 通用请求函数
* @function
* @param {string} funcUrl - 完整请求路径
* @param {object} funcData - 请求数据
* @param {string} funcType - 请求数据类型
* @param {string} funcMethod - 请求方法
* @param {object} funcOther - 其他配置
*/
request
:
function
(
funcUrl
,
funcData
,
funcSendType
,
funcMethod
,
funcOther
)
{
// 获取默认请求设置
let
funcConfigure
=
JSON
.
parse
(
JSON
.
stringify
(
iConfigure
))
Object
.
assign
(
funcConfigure
,
funcOther
)
// 检查数据发放方式有效性
if
(
funcSendType
&&
iConfigure
.
sendTypeEnumeration
.
indexOf
(
funcSendType
.
toLowerCase
())
>=
0
)
{
funcConfigure
.
sendType
=
funcSendType
.
toLowerCase
()
}
// 检查请求方法字段有效性
if
(
funcMethod
&&
iConfigure
.
methodEnumeration
.
indexOf
(
funcMethod
)
>=
0
)
{
funcConfigure
.
method
=
funcMethod
}
// get 请求需要将参数转换为 url 形式
if
(
funcConfigure
.
method
===
'get'
)
{
// 设置数据类型
funcData
=
iDataform
(
funcData
,
'url'
)
let
funcPromise
=
new
Promise
(
function
(
funcResolve
,
funcReject
)
{
let
funcXMLHttpRequest
=
new
XMLHttpRequest
()
funcXMLHttpRequest
.
open
(
funcConfigure
.
method
,
funcUrl
+
funcData
,
true
)
// 请求之前修改
iHeader
(
funcXMLHttpRequest
,
funcConfigure
)
iInterceptors
.
request
(
funcXMLHttpRequest
,
funcConfigure
,
funcUrl
)
funcXMLHttpRequest
.
send
()
funcXMLHttpRequest
.
onreadystatechange
=
function
()
{
if
(
funcXMLHttpRequest
.
readyState
!==
4
)
{
return
}
let
funStatus
=
funcXMLHttpRequest
.
status
if
((
funStatus
>=
200
&&
funStatus
<
300
)
||
funStatus
===
304
)
{
let
funcInterceptorsResponse
=
iInterceptors
.
response
(
funcConfigure
,
funcXMLHttpRequest
.
responseText
)
if
(
funcInterceptorsResponse
.
state
)
{
funcResolve
(
funcInterceptorsResponse
.
response
)
}
else
{
iVue
.
$message
.
error
(
funcInterceptorsResponse
.
response
.
message
)
}
}
else
{
let
funcInterceptorsResponse
=
iInterceptors
.
response
(
funcConfigure
,
funcXMLHttpRequest
.
responseText
)
if
(
funcInterceptorsResponse
.
state
)
{
funcResolve
(
funcInterceptorsResponse
.
response
)
}
else
{
iVue
.
$message
.
error
(
funcInterceptorsResponse
.
response
.
message
)
}
}
}
})
return
funcPromise
}
if
(
funcConfigure
.
method
===
'post'
)
{
// 设置数据类型
funcData
=
iDataform
(
funcData
,
funcConfigure
.
sendType
)
let
funcPromise
=
new
Promise
(
function
(
funcResolve
,
funcReject
)
{
let
funcXMLHttpRequest
=
new
XMLHttpRequest
()
funcXMLHttpRequest
.
open
(
funcConfigure
.
method
,
funcUrl
,
true
)
// 请求之前修改
iHeader
(
funcXMLHttpRequest
,
funcConfigure
)
iInterceptors
.
request
(
funcXMLHttpRequest
,
funcConfigure
,
funcUrl
)
funcXMLHttpRequest
.
send
(
funcData
)
funcXMLHttpRequest
.
onreadystatechange
=
function
()
{
if
(
funcXMLHttpRequest
.
readyState
!==
4
)
{
return
}
let
funStatus
=
funcXMLHttpRequest
.
status
if
((
funStatus
>=
200
&&
funStatus
<
300
)
||
funStatus
===
304
)
{
let
funcInterceptorsResponse
=
iInterceptors
.
response
(
funcConfigure
,
funcXMLHttpRequest
.
responseText
)
if
(
funcInterceptorsResponse
.
state
)
{
funcResolve
(
funcInterceptorsResponse
.
response
)
}
else
{
if
(
funcInterceptorsResponse
.
response
.
message
!==
'登录失效'
)
{
iVue
.
$message
.
error
(
funcInterceptorsResponse
.
response
.
message
)
}
funcReject
(
funcInterceptorsResponse
.
response
)
}
}
else
{
let
funcInterceptorsResponse
=
iInterceptors
.
response
(
funcConfigure
,
funcXMLHttpRequest
.
responseText
)
if
(
funcInterceptorsResponse
.
state
)
{
funcResolve
(
funcInterceptorsResponse
.
response
)
}
else
{
iVue
.
$message
.
error
(
funcInterceptorsResponse
.
response
.
message
)
}
}
}
})
return
funcPromise
}
},
}
export
default
output
\ No newline at end of file
src/view/home.vue
View file @
b14fe58b
...
...
@@ -1103,7 +1103,7 @@
}
.bidding-news-detail-html
{
width
:
100%
;
height
:
40
px
;
height
:
38
px
;
margin-top
:
20px
;
font-size
:
@
fontSize01
!important
;
overflow
:
hidden
;
...
...
src/view/personal/supplier-info.vue
View file @
b14fe58b
...
...
@@ -230,11 +230,13 @@
'examineReason'
:
funcResponse
.
reason
,
}
// 判断地址数据类型,同时兼容字符串与数组类型
if
(
Object
.
prototype
.
toString
.
call
(
funcResponse
.
receiveArea
)
===
'[object String]'
)
{
this
.
formInfo
.
receiveArea
=
JSON
.
parse
(
funcResponse
.
receiveArea
).
join
(
' '
)
}
else
{
this
.
formInfo
.
receiveArea
=
funcResponse
.
receiveArea
.
join
(
' '
)
if
(
funcResponse
.
receiveArea
)
{
// 判断地址数据类型,同时兼容字符串与数组类型
if
(
Object
.
prototype
.
toString
.
call
(
funcResponse
.
receiveArea
)
===
'[object String]'
)
{
this
.
formInfo
.
receiveArea
=
JSON
.
parse
(
funcResponse
.
receiveArea
).
join
(
' '
)
}
else
{
this
.
formInfo
.
receiveArea
=
funcResponse
.
receiveArea
.
join
(
' '
)
}
}
console
.
log
(
this
.
formInfo
)
...
...
src/view/personal/supplier-notice.vue
View file @
b14fe58b
...
...
@@ -852,7 +852,6 @@
* @returns
*/
onQuoteSubmit
:
function
()
{
console
.
log
(
JSON
.
stringify
(
this
.
tableQuote
))
if
(
this
.
tableQuote
.
length
===
0
)
{
this
.
$message
.
error
(
'请填写完整报价信息'
)
return
...
...
@@ -893,7 +892,8 @@
'biddingOffers'
:
JSON
.
stringify
(
funcQuoteData
)
}
let
funcOther
=
iRequest
.
request
(
iHost
.
base
+
'bid/zBiddingProject/biddingOffer'
,
funcParam
,
'json'
,
'post'
)
console
.
log
(
'promise begin'
)
iRequest
.
request
(
iHost
.
base
+
'bid/zBiddingProject/biddingOffer'
,
funcParam
,
'json'
,
'post'
)
.
then
((
funcResponse
)
=>
{
this
.
winQuote
=
false
this
.
$message
({
message
:
'报价成功!'
,
type
:
'success'
})
...
...
src/view/personal/supplier-orders-detail.vue
View file @
b14fe58b
...
...
@@ -283,25 +283,26 @@
if
(
funcResponse
.
orderBilling
)
{
this
.
isReceive
=
!
Boolean
(
Number
(
funcResponse
.
orderBilling
.
receiveType
))
this
.
componentReceive
=
{
'name'
:
funcResponse
.
orderBilling
.
name
,
'phone'
:
funcResponse
.
orderBilling
.
phone
,
'area'
:
''
,
'address'
:
funcResponse
.
orderBilling
.
address
,
}
if
(
this
.
isReceive
)
{
this
.
componentReceive
=
{
'name'
:
funcResponse
.
orderBilling
.
name
?
funcResponse
.
orderBilling
.
name
:
'暂无'
,
'phone'
:
funcResponse
.
orderBilling
.
phone
?
funcResponse
.
orderBilling
.
phone
:
'暂无'
,
'area'
:
''
,
'address'
:
funcResponse
.
orderBilling
.
address
?
funcResponse
.
orderBilling
.
address
:
'暂无'
,
}
// 判断地址数据类型,同时兼容字符串与数组类型
if
(
Object
.
prototype
.
toString
.
call
(
funcResponse
.
orderBilling
.
area
)
===
'[object String]'
)
{
this
.
componentReceive
.
area
=
JSON
.
parse
(
funcResponse
.
orderBilling
.
area
).
join
(
' '
)
}
else
{
this
.
componentReceive
.
area
=
funcResponse
.
orderBilling
.
area
.
join
(
' '
)
// 判断地址数据类型,同时兼容字符串与数组类型
if
(
funcResponse
.
orderBilling
.
area
)
{
if
(
Object
.
prototype
.
toString
.
call
(
funcResponse
.
orderBilling
.
area
)
===
'[object String]'
)
{
this
.
componentReceive
.
area
=
JSON
.
parse
(
funcResponse
.
orderBilling
.
area
).
join
(
' '
)
}
else
{
this
.
componentReceive
.
area
=
funcResponse
.
orderBilling
.
area
.
join
(
' '
)
}
}
}
}
else
{
this
.
isReceive
=
false
}
console
.
log
(
this
.
isReceive
)
console
.
log
(
this
.
componentProject
.
isPackage
)
if
(
this
.
componentProject
.
isPackage
)
{
// 多个合同
let
funcRawData
=
funcResponse
.
order
.
tenderPackages
...
...
@@ -313,6 +314,7 @@
'price'
:
funcRawData
[
i
].
price
,
}
this
.
componentContract
.
push
(
funcItem
)
console
.
log
(
'this.componentContract'
,
this
.
componentContract
)
}
}
else
{
this
.
componentContract
.
push
({
'price'
:
funcResponse
.
order
.
price
})
...
...
src/view/register-supplier.vue
View file @
b14fe58b
...
...
@@ -469,7 +469,7 @@
* @returns
*/
reset
:
function
()
{
this
.
state
=
3
this
.
state
=
1
this
.
formRegister
=
{
// 基本信息
companyName
:
''
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment