Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mes-pda-scan
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ximai
mes-pda-scan
Commits
f0f9f313
Commit
f0f9f313
authored
Jul 09, 2024
by
沈翠玲
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
http://git.local.topsunit.com/mes/mes-pda
into dev
parents
3ea7d446
a807ea0e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
411 additions
and
232 deletions
+411
-232
pages.json
pages.json
+7
-0
confirComplete.vue
pages/confirComplete/confirComplete.vue
+6
-8
index.vue
pages/factoryTransfer/index.vue
+143
-0
index.vue
pages/index/index.vue
+5
-0
packing.vue
pages/packing/packing.vue
+8
-5
index.vue
pages/sendOutGoodsOff/index.vue
+41
-30
index.js
uview-ui/libs/request/index.js
+201
-189
No files found.
pages.json
View file @
f0f9f313
...
@@ -82,6 +82,13 @@
...
@@ -82,6 +82,13 @@
"enablePullDownRefresh"
:
false
"enablePullDownRefresh"
:
false
}
}
},
},
{
"path"
:
"pages/factoryTransfer/index"
,
"style"
:
{
"navigationBarTitleText"
:
"工厂间调拨"
,
"enablePullDownRefresh"
:
false
}
},
{
{
"path"
:
"pages/salesReturns/salesReturns"
,
"path"
:
"pages/salesReturns/salesReturns"
,
"style"
:
{
"style"
:
{
...
...
pages/confirComplete/confirComplete.vue
View file @
f0f9f313
...
@@ -2,16 +2,16 @@
...
@@ -2,16 +2,16 @@
<view
class=
"page"
>
<view
class=
"page"
>
<StickyNavBar>
<StickyNavBar>
<NavBar
title=
"完工入库扫描"
></NavBar>
<NavBar
title=
"完工入库扫描"
></NavBar>
<FactorySelect
v-model=
"
warehouseCode
"
/>
<FactorySelect
v-model=
"
LGOBE"
@
change=
"actionSheetCallback
"
/>
<view
class=
"selectSheet"
>
<
!--
<
view
class=
"selectSheet"
>
<u-row
>
<u-row
>
<u-col
span=
"12"
>
<u-col
span=
"12"
>
<u-picker
v-model=
"depotShow"
mode=
"selector"
:default-selector=
"[0]"
range-key=
"text"
:range=
"depotLists"
@
confirm=
"actionSheetCallback"
></u-picker>
<u-picker
v-model=
"depotShow"
mode=
"selector"
:default-selector=
"[0]"
range-key=
"text"
:range=
"depotLists"
@
confirm=
"actionSheetCallback"
></u-picker>
<u-input
v-model=
"LGOBE"
placeholder=
"请选择仓库别"
:type=
"type"
:border=
"border"
@
click=
"depotShow = true"
/>
<u-input
v-model=
"LGOBE"
placeholder=
"请选择仓库别"
:type=
"type"
:border=
"border"
@
click=
"depotShow = true"
/>
</u-col>
</u-col>
</u-row>
</u-row>
</view>
</view>
-->
<view
class=
"btn"
>
<view
class=
"btn"
>
<uni-easyinput
prefixIcon=
"search"
class=
"topSearch"
v-model=
"nlpla"
focus
placeholder=
"请扫描库位"
@
change=
"handleInputNlpla"
></uni-easyinput>
<uni-easyinput
prefixIcon=
"search"
class=
"topSearch"
v-model=
"nlpla"
focus
placeholder=
"请扫描库位"
@
change=
"handleInputNlpla"
></uni-easyinput>
<uni-easyinput
<uni-easyinput
...
@@ -94,7 +94,7 @@ export default {
...
@@ -94,7 +94,7 @@ export default {
};
};
},
},
created
()
{
created
()
{
this
.
getDepotLists
();
//
this.getDepotLists();
// 二维码包含:10位物料号(右对齐不足补充为0)物料号12位生产单号(右对齐不足补充为0),
// 二维码包含:10位物料号(右对齐不足补充为0)物料号12位生产单号(右对齐不足补充为0),
// 10位批次号(右对齐不足补充为0),8位数量(100000.0)(右对齐不足补充为0)
// 10位批次号(右对齐不足补充为0),8位数量(100000.0)(右对齐不足补充为0)
// this.getPlnr('006000000100100000000300000501001');
// this.getPlnr('006000000100100000000300000501001');
...
@@ -127,10 +127,8 @@ export default {
...
@@ -127,10 +127,8 @@ export default {
});
});
},
},
// 点击actionSheet回调
// 点击actionSheet回调
actionSheetCallback
(
index
)
{
actionSheetCallback
(
item
)
{
console
.
log
(
index
,
'index'
);
this
.
LGORT
=
item
?.
LGORT
||
""
;
this
.
LGOBE
=
this
.
depotLists
[
index
].
LGOBE
;
this
.
LGORT
=
this
.
depotLists
[
index
].
LGORT
;
},
},
deleGonds
(
idx
)
{
deleGonds
(
idx
)
{
this
.
goodsList
.
splice
(
idx
,
1
);
this
.
goodsList
.
splice
(
idx
,
1
);
...
...
pages/factoryTransfer/index.vue
0 → 100644
View file @
f0f9f313
<
template
>
<view>
<StickyNavBar>
<NavBar
title=
"工厂间调拨"
></NavBar>
<view
class=
"btn"
>
<uni-easyinput
prefixIcon=
"search"
:disabled=
"isDisabled"
v-model=
"wxparams"
:focus=
"isFocus"
placeholder=
"请扫描单号"
@
input=
"handleInputPlnr"
></uni-easyinput>
</view>
</StickyNavBar>
<view
class=
"cardBox"
>
<text
class=
"cardBoxTip"
>
步骤一 扫描单号
</text>
<u-image
class=
'cardBoxImg'
:src=
"bgSrc"
width=
"560rpx"
height=
"400rpx"
></u-image>
<view
class=
"cardBoxTip2"
>
摄像头对准
</view>
<view
class=
"cardBoxTip3"
>
生产发料单号二维码
</view>
<view
class=
"cardBoxTip2"
>
<text
class=
"tipLeft"
>
点击扫描或
</text>
<text
class=
"tipRight"
>
点选单号
</text>
</view>
</view>
<BottomBtn
:btnArr=
"btnArr"
@
getBtnHandle=
"getBtnHandle"
></BottomBtn>
</view>
</
template
>
<
script
>
import
StickyNavBar
from
'@/components/StickyNavBar/index.vue'
;
import
ContentLoadingMore
from
'@/components/ContentLoadingMore/index.vue'
;
import
BottomBtn
from
'@/components/BottomBtn/index.vue'
;
export
default
{
components
:
{
StickyNavBar
,
ContentLoadingMore
,
BottomBtn
},
data
()
{
return
{
bgSrc
:
require
(
'@/static/images/qrcode.png'
),
number
:
0
,
totalNum
:
0
,
show
:
true
,
nlpla
:
''
,
wxparams
:
''
,
btnArr
:
[
{
style
:
''
,
type
:
'primary'
,
text
:
'扫描单号'
,
way
:
'scanning'
},
{
style
:
''
,
type
:
'warning'
,
text
:
'查询单号'
,
way
:
'goClick'
}
],
goodsList
:
[],
isFocus
:
false
,
isDisabled
:
false
};
},
created
()
{
// this.getPlnr('SN202400172');
},
methods
:
{
getBtnHandle
(
row
)
{
this
[
row
.
way
]();
},
goClick
()
{
// uni.navigateTo({
// url: `/pages/productionIssuance/oddNumList`
// });
},
scanning
()
{
// uni.navigateTo({
// url: `/pages/productionIssuance/productionIssuanceList?order=${JSON.stringify(this.goodsList)}`
// });
},
handleInputPlnr
(
e
)
{
this
.
isFocus
=
false
;
e
&&
this
.
getPlnr
(
e
);
},
getPlnr
(
applyNo
)
{
this
.
totalNum
=
0
;
this
.
isDisabled
=
true
;
}
}
};
</
script
>
<
style
lang=
"scss"
scoped
>
page
{
background
:
#f8f8f8
;
}
.btn
{
padding
:
20rpx
;
background
:
#fff
;
.topSearch
{
margin-bottom
:
20rpx
;
}
}
.cardBox
{
min-height
:
calc
(
100vh
-
400rpx
);
padding
:
0rpx
20rpx
;
margin-top
:
20rpx
;
}
/
deep
/
.u-sticky
{
top
:
0
!
important
;
background
:
#fff
;
}
.cardBoxTip
{
color
:
#000
;
font-size
:
28rpx
;
}
.cardBoxTip2
{
color
:
#000
;
font-size
:
28rpx
;
text-align
:
center
;
}
.cardBoxTip3
{
color
:
#3f9dcc
;
font-size
:
28rpx
;
text-align
:
center
;
}
.tipRight
{
color
:
#ff9900
;
}
</
style
>
\ No newline at end of file
pages/index/index.vue
View file @
f0f9f313
...
@@ -120,6 +120,11 @@
...
@@ -120,6 +120,11 @@
text
:
'发货下架'
,
text
:
'发货下架'
,
url
:
'/pages/sendOutGoodsOff/index'
url
:
'/pages/sendOutGoodsOff/index'
},
},
{
src
:
require
(
'@/static/images/xsck.png'
),
text
:
'工厂间调拨'
,
url
:
'/pages/factoryTransfer/index'
},
]
]
}]
}]
};
};
...
...
pages/packing/packing.vue
View file @
f0f9f313
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
<relationships
v-show=
"current === 0"
:list=
"goodsList"
@
deleGonds=
"deleGonds"
/>
<relationships
v-show=
"current === 0"
:list=
"goodsList"
@
deleGonds=
"deleGonds"
/>
<metering
v-show=
"current === 1"
:form=
"form"
/>
<metering
v-show=
"current === 1"
:form=
"form"
/>
<unpacking
v-show=
"current === 2"
/>
<unpacking
v-show=
"current === 2"
/>
<BottomBtn
:btnArr=
"btnArr"
@
getBtnHandle=
"getBtnHandle"
v-if=
"current
=== 0
"
></BottomBtn>
<BottomBtn
:btnArr=
"btnArr"
@
getBtnHandle=
"getBtnHandle"
v-if=
"current
!== 2
"
></BottomBtn>
</view>
</view>
</
template
>
</
template
>
...
@@ -127,7 +127,7 @@
...
@@ -127,7 +127,7 @@
this
.
$u
.
toast
(
'暂无提交数据'
);
this
.
$u
.
toast
(
'暂无提交数据'
);
return
return
}
}
if
(
!
this
.
blNum
)
{
if
(
!
this
.
blNum
&&
this
.
form
.
ZZXFS
===
'BL+PL'
)
{
this
.
$u
.
toast
(
'请扫描箱码'
);
this
.
$u
.
toast
(
'请扫描箱码'
);
return
return
}
}
...
@@ -171,9 +171,7 @@
...
@@ -171,9 +171,7 @@
}
}
if
(
res
.
every
((
item
)
=>
item
.
TYPE
===
'S'
))
{
if
(
res
.
every
((
item
)
=>
item
.
TYPE
===
'S'
))
{
this
.
$u
.
toast
(
res
[
0
].
MESSAGE
);
this
.
$u
.
toast
(
res
[
0
].
MESSAGE
);
setTimeout
(()
=>
{
this
.
resetData
()
this
.
goBack
()
},
1000
)
}
}
const
foundObject
=
res
.
find
(
item
=>
item
.
TYPE
===
'E'
);
const
foundObject
=
res
.
find
(
item
=>
item
.
TYPE
===
'E'
);
if
(
foundObject
&&
foundObject
.
MESSAGE
)
{
if
(
foundObject
&&
foundObject
.
MESSAGE
)
{
...
@@ -181,6 +179,11 @@
...
@@ -181,6 +179,11 @@
}
}
});
});
},
},
// 重置数据
resetData
()
{
this
.
goodsList
=
[];
this
.
form
.
brgew
=
''
},
// 删除
// 删除
deleGonds
(
idx
)
{
deleGonds
(
idx
)
{
this
.
goodsList
.
splice
(
idx
,
1
);
this
.
goodsList
.
splice
(
idx
,
1
);
...
...
pages/sendOutGoodsOff/index.vue
View file @
f0f9f313
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
<StickyNavBar>
<StickyNavBar>
<NavBar
title=
"发货下架"
></NavBar>
<NavBar
title=
"发货下架"
></NavBar>
<view
class=
"btn"
>
<view
class=
"btn"
>
<uni-easyinput
class=
"boxSelect"
prefixIcon=
"search"
v-model=
"lgort"
placeholder=
"请扫描目标仓位"
></uni-easyinput>
<uni-easyinput
prefixIcon=
"search"
:disabled=
"isDisabled"
v-model=
"wxparams"
:focus=
"isFocus"
<uni-easyinput
prefixIcon=
"search"
:disabled=
"isDisabled"
v-model=
"wxparams"
:focus=
"isFocus"
placeholder=
"请扫描产品包装条码/外箱码"
@
input=
"handleInputPlnr"
></uni-easyinput>
placeholder=
"请扫描产品包装条码/外箱码"
@
input=
"handleInputPlnr"
></uni-easyinput>
</view>
</view>
...
@@ -28,7 +29,9 @@
...
@@ -28,7 +29,9 @@
<
script
>
<
script
>
import
BottomBtn
from
'@/components/BottomBtn/index.vue'
;
import
BottomBtn
from
'@/components/BottomBtn/index.vue'
;
import
StickyNavBar
from
'@/components/StickyNavBar/index.vue'
;
import
StickyNavBar
from
'@/components/StickyNavBar/index.vue'
;
import
{
parseTime
}
from
"@/utils/ruoyi"
;
import
{
parseTime
}
from
"@/utils/ruoyi"
;
export
default
{
export
default
{
components
:
{
components
:
{
...
@@ -38,6 +41,7 @@
...
@@ -38,6 +41,7 @@
data
()
{
data
()
{
return
{
return
{
wxparams
:
""
,
wxparams
:
""
,
lgort
:
''
,
isDisabled
:
false
,
isDisabled
:
false
,
isFocus
:
false
,
isFocus
:
false
,
goodsList
:
[],
goodsList
:
[],
...
@@ -58,31 +62,31 @@
...
@@ -58,31 +62,31 @@
},
},
methods
:
{
methods
:
{
handleInputPlnr
(
e
)
{
handleInputPlnr
(
e
)
{
if
(
this
.
goodsList
.
some
((
item
)
=>
item
.
ZCODE
===
e
||
item
.
PLNR
===
e
))
{
if
(
this
.
goodsList
.
some
((
item
)
=>
item
.
ZCODE
===
e
||
item
.
PLNR
===
e
))
{
this
.
$u
.
toast
(
'已经存在当前条码'
);
this
.
$u
.
toast
(
'已经存在当前条码'
);
this
.
reset
()
this
.
reset
()
return
return
}
}
// bl 长度 15 pl 长度 80
// bl 长度 15 pl 长度 80
const
bl
=
e
.
length
<=
15
&&
e
.
length
>=
13
;
const
bl
=
e
.
length
<=
15
&&
e
.
length
>=
13
;
const
pl
=
e
.
length
>
15
const
pl
=
e
.
length
>
15
if
(
bl
)
{
if
(
bl
)
{
this
.
isFocus
=
false
;
this
.
isFocus
=
false
;
this
.
isDisabled
=
true
;
this
.
isDisabled
=
true
;
this
.
goodsList
.
push
({
this
.
goodsList
.
push
({
ZCODE
:
e
,
ZCODE
:
e
,
PLNR
:
''
PLNR
:
''
})
})
this
.
reset
()
this
.
reset
()
}
else
if
(
pl
)
{
}
else
if
(
pl
)
{
this
.
isFocus
=
false
;
this
.
isFocus
=
false
;
this
.
isDisabled
=
true
;
this
.
isDisabled
=
true
;
this
.
goodsList
.
push
({
this
.
goodsList
.
push
({
PLNR
:
e
,
PLNR
:
e
,
ZCODE
:
''
ZCODE
:
''
})
})
this
.
reset
()
this
.
reset
()
}
}
},
},
deleGonds
(
index
)
{
deleGonds
(
index
)
{
this
.
goodsList
.
splice
(
index
,
1
)
this
.
goodsList
.
splice
(
index
,
1
)
...
@@ -94,19 +98,25 @@
...
@@ -94,19 +98,25 @@
this
.
wxparams
=
''
this
.
wxparams
=
''
},
1000
);
},
1000
);
},
},
goBack
()
{
uni
.
navigateBack
()
},
getBtnHandle
(
row
)
{
getBtnHandle
(
row
)
{
console
.
log
(
'getBtnHandle'
,
row
);
console
.
log
(
'getBtnHandle'
,
row
);
this
[
row
.
way
]();
this
[
row
.
way
]();
},
},
// 提交
// 提交
goSubmit
()
{
goSubmit
()
{
if
(
!
this
.
goodsList
.
length
)
{
if
(
!
this
.
goodsList
.
length
)
{
return
this
.
$u
.
toast
(
'请扫描需要下架的箱条码/外箱码'
)
return
this
.
$u
.
toast
(
'请扫描需要下架的箱条码/外箱码'
)
}
}
const
DATUM
=
parseTime
(
new
Date
(),
'{y}{m}{d}'
),
if
(
!
this
.
lgort
)
{
UNAME
=
this
.
vuex_user
.
nickName
,
return
this
.
$u
.
toast
(
'请选择目标仓位'
)
UZEIT
=
parseTime
(
new
Date
(),
'{h}{i}{s}'
);
}
const
arr
=
this
.
goodsList
const
arr
=
this
.
goodsList
.
map
((
item
)
=>
{
item
.
LGORT
=
this
.
lgort
return
item
})
this
.
$u
.
api
.
sapApi
this
.
$u
.
api
.
sapApi
.
sapCasePlnr2
(
arr
)
.
sapCasePlnr2
(
arr
)
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
...
@@ -132,11 +142,12 @@
...
@@ -132,11 +142,12 @@
flex
:
1
;
flex
:
1
;
flex-direction
:
column
;
flex-direction
:
column
;
}
}
page
{
page
{
background
:
#f8f8f8
;
background
:
#f8f8f8
;
}
}
/
deep
/
.u-sticky
{
/
deep
/
.u-sticky
{
top
:
0
!
important
;
top
:
0
!
important
;
background
:
#fff
;
background
:
#fff
;
}
}
...
@@ -144,11 +155,12 @@
...
@@ -144,11 +155,12 @@
.btn
{
.btn
{
padding
:
20rpx
;
padding
:
20rpx
;
background
:
#fff
;
background
:
#fff
;
.boxSelect
{
.boxSelect
{
margin-bottom
:
20rpx
;
margin-bottom
:
20rpx
;
}
}
}
}
.cardContent
{
.cardContent
{
border-radius
:
8px
;
border-radius
:
8px
;
background
:
#fff
;
background
:
#fff
;
...
@@ -177,5 +189,4 @@
...
@@ -177,5 +189,4 @@
font-weight
:
600
;
font-weight
:
600
;
}
}
}
}
</
style
>
</
style
>
uview-ui/libs/request/index.js
View file @
f0f9f313
import
deepMerge
from
"../function/deepMerge"
;
import
deepMerge
from
"../function/deepMerge"
;
import
validate
from
"../function/test"
;
import
validate
from
"../function/test"
;
class
Request
{
import
store
from
'@/store/index.js'
// 设置全局默认配置
class
Request
{
setConfig
(
customConfig
)
{
// 设置全局默认配置
// 深度合并对象,否则会造成对象深层属性丢失
setConfig
(
customConfig
)
{
this
.
config
=
deepMerge
(
this
.
config
,
customConfig
);
// 深度合并对象,否则会造成对象深层属性丢失
}
this
.
config
=
deepMerge
(
this
.
config
,
customConfig
);
}
// 主要请求部分
request
(
options
=
{})
{
// 主要请求部分
// 检查请求拦截
request
(
options
=
{})
{
if
(
this
.
interceptor
.
request
&&
typeof
this
.
interceptor
.
request
===
'function'
)
{
// 检查请求拦截
let
tmpConfig
=
{};
if
(
this
.
interceptor
.
request
&&
typeof
this
.
interceptor
.
request
===
'function'
)
{
let
interceptorRequest
=
this
.
interceptor
.
request
(
options
);
let
tmpConfig
=
{};
if
(
interceptorRequest
===
false
)
{
let
interceptorRequest
=
this
.
interceptor
.
request
(
options
);
// 返回一个处于pending状态中的Promise,来取消原promise,避免进入then()回调
if
(
interceptorRequest
===
false
)
{
return
new
Promise
(()
=>
{});
// 返回一个处于pending状态中的Promise,来取消原promise,避免进入then()回调
}
return
new
Promise
(()
=>
{});
this
.
options
=
interceptorRequest
;
}
}
this
.
options
=
interceptorRequest
;
options
.
dataType
=
options
.
dataType
||
this
.
config
.
dataType
;
}
options
.
responseType
=
options
.
responseType
||
this
.
config
.
responseType
;
options
.
dataType
=
options
.
dataType
||
this
.
config
.
dataType
;
options
.
url
=
options
.
url
||
''
;
options
.
responseType
=
options
.
responseType
||
this
.
config
.
responseType
;
options
.
params
=
options
.
params
||
{};
options
.
url
=
options
.
url
||
''
;
options
.
header
=
Object
.
assign
({},
this
.
config
.
header
,
options
.
header
);
options
.
params
=
options
.
params
||
{};
options
.
method
=
options
.
method
||
this
.
config
.
method
;
options
.
header
=
Object
.
assign
({},
this
.
config
.
header
,
options
.
header
);
options
.
method
=
options
.
method
||
this
.
config
.
method
;
return
new
Promise
((
resolve
,
reject
)
=>
{
options
.
complete
=
(
response
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
// 请求返回后,隐藏loading(如果请求返回快的话,可能会没有loading)
options
.
complete
=
(
response
)
=>
{
uni
.
hideLoading
();
// 请求返回后,隐藏loading(如果请求返回快的话,可能会没有loading)
// 清除定时器,如果请求回来了,就无需loading
uni
.
hideLoading
();
clearTimeout
(
this
.
config
.
timer
);
// 清除定时器,如果请求回来了,就无需loading
this
.
config
.
timer
=
null
;
clearTimeout
(
this
.
config
.
timer
);
// 判断用户对拦截返回数据的要求,如果originalData为true,返回所有的数据(response)到拦截器,否则只返回response.data
this
.
config
.
timer
=
null
;
if
(
this
.
config
.
originalData
)
{
// 判断用户对拦截返回数据的要求,如果originalData为true,返回所有的数据(response)到拦截器,否则只返回response.data
// 判断是否存在拦截器
if
(
this
.
config
.
originalData
)
{
if
(
this
.
interceptor
.
response
&&
typeof
this
.
interceptor
.
response
===
'function'
)
{
// 判断是否存在拦截器
let
resInterceptors
=
this
.
interceptor
.
response
(
response
);
if
(
this
.
interceptor
.
response
&&
typeof
this
.
interceptor
.
response
===
'function'
)
{
// 如果拦截器不返回false,就将拦截器返回的内容给this.$u.post的then回调
let
resInterceptors
=
this
.
interceptor
.
response
(
response
);
if
(
resInterceptors
!==
false
)
{
// 如果拦截器不返回false,就将拦截器返回的内容给this.$u.post的then回调
resolve
(
resInterceptors
);
if
(
resInterceptors
!==
false
)
{
}
else
{
resolve
(
resInterceptors
);
// 如果拦截器返回false,意味着拦截器定义者认为返回有问题,直接接入catch回调
}
else
{
reject
(
response
);
// 如果拦截器返回false,意味着拦截器定义者认为返回有问题,直接接入catch回调
}
reject
(
response
);
}
else
{
}
// 如果要求返回原始数据,就算没有拦截器,也返回最原始的数据
}
else
{
resolve
(
response
);
// 如果要求返回原始数据,就算没有拦截器,也返回最原始的数据
}
resolve
(
response
);
}
else
{
}
if
(
response
.
statusCode
==
200
)
{
}
else
{
if
(
this
.
interceptor
.
response
&&
typeof
this
.
interceptor
.
response
===
if
(
response
.
statusCode
==
200
)
{
'function'
)
{
if
(
this
.
interceptor
.
response
&&
typeof
this
.
interceptor
.
response
===
let
resInterceptors
=
this
.
interceptor
.
response
(
response
.
data
);
'function'
)
{
if
(
resInterceptors
!==
false
)
{
let
resInterceptors
=
this
.
interceptor
.
response
(
response
.
data
);
resolve
(
resInterceptors
);
if
(
resInterceptors
!==
false
)
{
}
else
{
resolve
(
resInterceptors
);
reject
(
response
.
data
);
}
else
{
}
reject
(
response
.
data
);
}
else
{
}
// 如果不是返回原始数据(originalData=false),且没有拦截器的情况下,返回纯数据给then回调
}
else
{
resolve
(
response
.
data
);
// 如果不是返回原始数据(originalData=false),且没有拦截器的情况下,返回纯数据给then回调
}
resolve
(
response
.
data
);
}
else
{
}
// 不返回原始数据的情况下,服务器状态码不为200,modal弹框提示
}
else
{
// if(response.errMsg) {
// 不返回原始数据的情况下,服务器状态码不为200,modal弹框提示
// uni.showModal({
// if(response.errMsg) {
// title: response.errMsg
// uni.showModal({
// });
// title: response.errMsg
// }
// });
reject
(
response
)
// }
}
reject
(
response
)
}
}
}
}
// 处理sap接口
}
let
url
=
this
.
config
.
baseUrl
// 处理sap接口
if
(
options
.
url
.
indexOf
(
'sap'
)
>
-
1
){
let
url
=
this
.
config
.
baseUrl
// console.log('sap')
if
(
options
.
url
.
indexOf
(
'sap'
)
>
-
1
)
{
// #ifdef APP-PLUS
url
=
'http://192.168.3.109:8000'
url
=
'http://192.168.3.109:8000'
options
.
header
=
{
// #endif
...
options
.
header
,
'content-type'
:
'application/json;charset=UTF-8'
,
options
.
header
=
{
'Authorization'
:
'Basic cmVzdF91c2VyOkJzbjEyMzQ1Ng=='
,
...
options
.
header
,
}
'content-type'
:
'application/json;charset=UTF-8'
,
}
else
if
(
options
.
url
.
indexOf
(
'apiPda'
)
>
-
1
){
'Authorization'
:
'Basic cmVzdF91c2VyOkJzbjEyMzQ1Ng=='
,
options
.
header
=
{
}
...
options
.
header
,
'content-type'
:
'application/json;charset=UTF-8'
,
// 设置公共参数
}
if
(
Object
.
prototype
.
toString
.
call
(
options
.
data
)
!=
'[object Array]'
)
{
url
=
'http://192.168.3.91:8100'
options
.
data
=
{
}
else
{
...
options
.
data
,
// console.log('mobile')
werks
:
store
.
state
.
vuex_user_factory
url
=
'http://192.168.3.91:8100'
}
}
}
// 判断用户传递的URL是否/开头,如果不是,加上/,这里使用了uView的test.js验证库的url()方法
options
.
url
=
validate
.
url
(
options
.
url
)
?
options
.
url
:
(
url
+
(
options
.
url
.
indexOf
(
'/'
)
==
0
?
}
else
if
(
options
.
url
.
indexOf
(
'apiPda'
)
>
-
1
)
{
options
.
url
:
'/'
+
options
.
url
));
options
.
header
=
{
...
options
.
header
,
// 是否显示loading
'content-type'
:
'application/json;charset=UTF-8'
,
// 加一个是否已有timer定时器的判断,否则有两个同时请求的时候,后者会清除前者的定时器id
}
// 而没有清除前者的定时器,导致前者超时,一直显示loading
url
=
'http://192.168.3.91:8100'
if
(
this
.
config
.
showLoading
&&
!
this
.
config
.
timer
)
{
}
else
{
this
.
config
.
timer
=
setTimeout
(()
=>
{
// console.log('mobile')
uni
.
showLoading
({
url
=
'http://192.168.3.91:8100'
title
:
this
.
config
.
loadingText
,
}
mask
:
this
.
config
.
loadingMask
// 判断用户传递的URL是否/开头,如果不是,加上/,这里使用了uView的test.js验证库的url()方法
})
options
.
url
=
validate
.
url
(
options
.
url
)
?
options
.
url
:
(
url
+
(
options
.
url
.
indexOf
(
'/'
)
==
0
?
this
.
config
.
timer
=
null
;
options
.
url
:
'/'
+
options
.
url
));
},
this
.
config
.
loadingTime
);
}
// 是否显示loading
console
.
log
(
'请求参数'
,
options
)
// 加一个是否已有timer定时器的判断,否则有两个同时请求的时候,后者会清除前者的定时器id
uni
.
request
(
options
);
// 而没有清除前者的定时器,导致前者超时,一直显示loading
})
if
(
this
.
config
.
showLoading
&&
!
this
.
config
.
timer
)
{
// .catch(res => {
this
.
config
.
timer
=
setTimeout
(()
=>
{
// // 如果返回reject(),不让其进入this.$u.post().then().catch()后面的catct()
uni
.
showLoading
({
// // 因为很多人都会忘了写后面的catch(),导致报错捕获不到catch
title
:
this
.
config
.
loadingText
,
// return new Promise(()=>{});
mask
:
this
.
config
.
loadingMask
// })
})
}
this
.
config
.
timer
=
null
;
},
this
.
config
.
loadingTime
);
constructor
()
{
}
this
.
config
=
{
console
.
log
(
'请求参数'
,
options
)
baseUrl
:
''
,
// 请求的根域名
uni
.
request
(
options
);
// 默认的请求头
})
header
:
{},
// .catch(res => {
method
:
'POST'
,
// // 如果返回reject(),不让其进入this.$u.post().then().catch()后面的catct()
// 设置为json,返回后uni.request会对数据进行一次JSON.parse
// // 因为很多人都会忘了写后面的catch(),导致报错捕获不到catch
dataType
:
'json'
,
// return new Promise(()=>{});
// 此参数无需处理,因为5+和支付宝小程序不支持,默认为text即可
// })
responseType
:
'text'
,
}
showLoading
:
true
,
// 是否显示请求中的loading
loadingText
:
'请求中...'
,
constructor
()
{
loadingTime
:
800
,
// 在此时间内,请求还没回来的话,就显示加载中动画,单位ms
this
.
config
=
{
timer
:
null
,
// 定时器
baseUrl
:
''
,
// 请求的根域名
originalData
:
false
,
// 是否在拦截器中返回服务端的原始数据,见文档说明
// 默认的请求头
loadingMask
:
true
,
// 展示loading的时候,是否给一个透明的蒙层,防止触摸穿透
header
:
{},
}
method
:
'POST'
,
// 设置为json,返回后uni.request会对数据进行一次JSON.parse
// 拦截器
dataType
:
'json'
,
this
.
interceptor
=
{
// 此参数无需处理,因为5+和支付宝小程序不支持,默认为text即可
// 请求前的拦截
responseType
:
'text'
,
request
:
null
,
showLoading
:
true
,
// 是否显示请求中的loading
// 请求后的拦截
loadingText
:
'请求中...'
,
response
:
null
loadingTime
:
800
,
// 在此时间内,请求还没回来的话,就显示加载中动画,单位ms
}
timer
:
null
,
// 定时器
originalData
:
false
,
// 是否在拦截器中返回服务端的原始数据,见文档说明
// get请求
loadingMask
:
true
,
// 展示loading的时候,是否给一个透明的蒙层,防止触摸穿透
this
.
get
=
(
url
,
data
=
{},
header
=
{})
=>
{
}
return
this
.
request
({
method
:
'GET'
,
// 拦截器
url
,
this
.
interceptor
=
{
header
,
// 请求前的拦截
data
request
:
null
,
})
// 请求后的拦截
}
response
:
null
}
// post请求
this
.
post
=
(
url
,
data
=
{},
header
=
{})
=>
{
// get请求
return
this
.
request
({
this
.
get
=
(
url
,
data
=
{},
header
=
{})
=>
{
url
,
return
this
.
request
({
method
:
'POST'
,
method
:
'GET'
,
header
,
url
,
data
header
,
})
data
}
})
}
// put请求,不支持支付宝小程序(HX2.6.15)
this
.
put
=
(
url
,
data
=
{},
header
=
{})
=>
{
// post请求
return
this
.
request
({
this
.
post
=
(
url
,
data
=
{},
header
=
{})
=>
{
url
,
return
this
.
request
({
method
:
'PUT'
,
url
,
header
,
method
:
'POST'
,
data
header
,
})
data
}
})
}
// delete请求,不支持支付宝和头条小程序(HX2.6.15)
this
.
delete
=
(
url
,
data
=
{},
header
=
{})
=>
{
// put请求,不支持支付宝小程序(HX2.6.15)
return
this
.
request
({
this
.
put
=
(
url
,
data
=
{},
header
=
{})
=>
{
url
,
return
this
.
request
({
method
:
'DELETE'
,
url
,
header
,
method
:
'PUT'
,
data
header
,
})
data
}
})
}
}
}
export
default
new
Request
// delete请求,不支持支付宝和头条小程序(HX2.6.15)
\ No newline at end of file
this
.
delete
=
(
url
,
data
=
{},
header
=
{})
=>
{
return
this
.
request
({
url
,
method
:
'DELETE'
,
header
,
data
})
}
}
}
export
default
new
Request
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