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
8f8312e1
Commit
8f8312e1
authored
Mar 16, 2024
by
xiangzj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sap接口服务调整
parent
2a22a070
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
95 additions
and
230 deletions
+95
-230
config.js
common/config.js
+1
-0
http.api.js
common/http.api.js
+0
-178
http.interceptor.js
common/http.interceptor.js
+1
-0
confirComplete.vue
pages/confirComplete/confirComplete.vue
+4
-4
inventoryForm.vue
pages/inventoryCounting/inventoryForm.vue
+4
-4
inventoryList.vue
pages/inventoryCounting/inventoryList.vue
+39
-6
purchaseStorage.vue
pages/purchaseStorage/purchaseStorage.vue
+12
-12
login.vue
pages/sys/login/login.vue
+15
-15
index.js
uview-ui/libs/request/index.js
+19
-11
No files found.
common/config.js
View file @
8f8312e1
...
...
@@ -22,6 +22,7 @@ const config = {
// 设置后台接口服务的基础地址
config
.
baseUrl
=
'http://192.168.3.91:8080'
;
config
.
baseSapUrl
=
'http://192.168.3.109:8080'
;
//sap接口服务
//config.baseUrl = "http://101.43.244.58:8080/";
//config.baseUrl = "/api";
//config.baseUrl = "http://101.200.162.168:8080";
...
...
common/http.api.js
View file @
8f8312e1
...
...
@@ -18,143 +18,6 @@ const install = (Vue, vm) => {
sendCode
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/mobile/login/sendCode'
,
params
),
registerUser
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/mobile/user/registerUser'
,
params
),
/**
* 系统设置API
*/
//获取工序清单
getProcessList
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mobile/pro/process/getProcessList'
,
params
),
getWorkstationList
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mobile/md/workstation/getWorkstationList'
,
params
),
getWorkUnitList
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/md/workunit/getListByUser'
,
params
),
/**
* 生产管理相关API
**/
//获取当前工作站的生产任务
getTaskList
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mobile/pro/protask/getTaskList'
,
params
),
//根据任务ID获取任务详情
getTaskInfo
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mobile/pro/protask/'
+
params
.
taskId
),
//修改任务状态
changeStatus
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/mobile/pro/protask/change'
,
params
),
//生产报工
feedback
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/mobile/pro/protask/feedback'
,
params
),
//增加检验
getTaskInfoByTaskCode
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mobile/pro/protask/getProTaskByTaskCode'
,
params
),
//
getIpqcCode
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/system/autocode/get/IPQC_CODE'
,
params
),
//增加缺陷记录
addDefectrecord
:
(
params
=
{})
=>
vm
.
$u
.
putJson
(
config
.
adminPath
+
'/mes/qc/defectrecord'
,
params
),
//查询缺陷列表
getDefectrecordList
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mes/qc/defectrecord/list'
,
params
),
//查询检测项
getIpqcLineList
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mes/qc/ipqcline/list'
,
params
),
//生产日志
productionLogList
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mobile/pro/productionlog/list'
,
params
),
//增加生产日志
addProductionlog
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/mobile/pro/productionlog/add'
,
params
),
//增加生产物料扣减
addMaterialusagerecord
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/mobile/pro/materialusagerecord'
,
params
),
//生产物料扣减列表
materialusagerecordList
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mobile/pro/materialusagerecord/list'
,
params
),
//查询检验列表
ipqcList
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mes/qc/ipqc/list'
,
params
),
//增加检验
addIpqc
:
(
params
=
{})
=>
vm
.
$u
.
postJson
(
config
.
adminPath
+
'/mes/qc/ipqc'
,
params
),
//根据字典类型查询字典数据信息
getDicts
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/system/dict/data/type/'
+
params
),
//根据字典类型查询字典数据信息
getIssusLinebyWorkorderCodes
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/mobile/wm/issueline/listByWorkorderCodes'
,
params
),
/**
* 工艺工序相关API
*/
getProcessInfo
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mobile/pro/process/'
+
params
.
processId
),
//获取当前产品的SOP
getSopList
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mobile/pro/taskissue/getSopList'
,
params
),
//生产投料
addIssue
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/mobile/pro/taskissue/add'
,
params
),
//整个领料单投料
addholeIssue
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/mobile/pro/taskissue/addIssue'
,
params
),
//删除投料信息
removeTaskIssue
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/mobile/pro/taskissue/'
+
params
.
recordId
),
//获取当前工作站、当前生产任务对应的投料清单
getTaskIssueList
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mobile/pro/taskissue/getlist'
,
params
),
//查询可用的领料单
getReserveIssue
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mobile/pro/taskissue/getReserveIssueList'
,
params
),
//打印流转单
//投料验证
listFeedingInspection
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/mobile/pro/proMaterial/listIssueLine'
,
params
),
validateFeedingInspection
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/mobile/pro/proMaterial/validateFeedingInspection'
,
params
),
validateFeedingInspectionById
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/mobile/pro/proMaterial/validateFeedingInspectionById'
,
params
),
//查询反冲料列表
recoilMaterialList
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/mobile/pro/proMaterial/getRecoilMaterial'
,
params
),
//增加反冲料
addRecoilMaterial
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/mobile/pro/proMaterial/addRecoilMaterial'
,
params
),
//删除反冲料
deleteRecoilMaterial
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/mobile/pro/proMaterial/deleteRecoilMaterial'
,
params
),
//领料申请
listMaterialRequest
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/mobile/pro/proMaterial/listMaterialRequest'
,
params
),
addMaterialRequest
:
(
params
=
{})
=>
vm
.
$u
.
postJson
(
config
.
adminPath
+
'/mobile/pro/proMaterial/addMaterialRequest'
,
params
),
getWproworkOrderProcessItem
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/pro/materialRequest/selectworkorder/'
+
params
.
workorderId
),
//退料申请
listMaterialReturn
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/mobile/pro/proMaterial/listIssueLine'
,
params
),
addMaterialReturn
:
(
params
=
{})
=>
vm
.
$u
.
postJson
(
config
.
adminPath
+
'/mobile/pro/proMaterial/addMaterialReturn'
,
params
),
//质量相关api
//获取当前产品、当前质检类型的质检模板行信息
getQcTemplateLine
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mobile/qc/templateindex/getLines'
,
params
),
//首页相关api
getIndexCardInfo
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mobile/index/getIndexCardInfo'
,
params
),
getM2mOrderFlowList
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mobile/index/getM2mOrderFlowList'
,
params
),
//获取卡可购买套餐包
getM2mOrderPackageList
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mobile/index/getM2mOrderPackageList'
,
params
),
//查看生产工单
getWorkorder
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mes/pro/workorder/list'
,
params
),
logout
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mobile/login/logout'
,
params
),
authInfo
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/authInfo'
,
params
),
menuTree
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/menuTree'
,
params
),
switchSys
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/switch/'
+
params
.
sysCode
),
dictData
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/system/dict/data/type/'
+
params
.
dictType
),
// 账号服务:验证码接口、忘记密码接口、注册账号接口等
validCode
:
(
params
=
{})
=>
vm
.
$u
.
getText
(
'/validCode'
,
params
),
getFpValidCode
:
(
params
=
{})
=>
vm
.
$u
.
post
(
'/account/getFpValidCode'
,
params
),
savePwdByValidCode
:
(
params
=
{})
=>
vm
.
$u
.
post
(
'/account/savePwdByValidCode'
,
params
),
getRegValidCode
:
(
params
=
{})
=>
vm
.
$u
.
post
(
'/account/getRegValidCode'
,
params
),
saveRegByValidCode
:
(
params
=
{})
=>
vm
.
$u
.
post
(
'/account/saveRegByValidCode'
,
params
),
// APP公共服务
upgradeCheck
:
()
=>
vm
.
$u
.
post
(
'/app/upgrade/check'
,
{
appCode
:
config
.
appCode
,
appVersion
:
config
.
appVersion
}),
commentSave
:
(
params
=
{})
=>
vm
.
$u
.
post
(
'/app/comment/save'
,
params
),
// 个人信息修改
user
:
{
saveUserInfo
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/mobile/user/saveUserInfo'
,
params
),
...
...
@@ -167,47 +30,6 @@ const install = (Vue, vm) => {
empUser
:
{
listData
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/sys/empUser/listData'
,
params
),
},
// 组织机构查询
office
:
{
treeData
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/sys/office/treeData'
,
params
),
},
//查看异常模块信息
abnormal
:
{
detail
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/qc/information/list'
,
params
),
newlyAdd
:
(
params
=
{})
=>
vm
.
$u
.
postJson
(
config
.
adminPath
+
'/qc/report'
,
params
),
},
//查看图片
viewpicture
:
{
//查看工单
viewWorkorder
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mobile/pro/protask/getProWorkder'
,
params
),
//查看图片
viewSop
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mes/md/sop/getProWorkder/'
+
params
.
workorderId
),
},
// 增删改查例子
testData
:
{
form
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/test/testData/form'
,
params
),
list
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/test/testData/listData'
,
params
),
save
:
(
params
=
{})
=>
vm
.
$u
.
postJson
(
config
.
adminPath
+
'/test/testData/save'
,
params
),
disable
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/test/testData/disable'
,
params
),
enable
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/test/testData/enable'
,
params
),
delete
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/test/testData/delete'
,
params
),
},
// 刀模版相关
dModel
:
{
// 获取领用单
getToolsByProcessIdAndArrangeCode
:
(
params
=
{})
=>
vm
.
$u
.
putJson
(
config
.
adminPath
+
'/tm/tmToolRequestUse/getToolsByProcessIdAndArrangeCode'
,
params
),
// 获取上下机记录
getRecordsByProcessIdAndArrangeCode
:
(
params
=
{})
=>
vm
.
$u
.
putJson
(
config
.
adminPath
+
'/tm/tmToolMachinesRecord/getRecordsByProcessIdAndArrangeCode'
,
params
),
// 新增
tmToolMachines
:
(
params
=
{})
=>
vm
.
$u
.
postJson
(
config
.
adminPath
+
'/tm/tmToolMachines'
,
params
),
tmToolMachinesRecord
:
(
params
=
{})
=>
vm
.
$u
.
putJson
(
config
.
adminPath
+
'/tm/tmToolMachinesRecord'
,
params
)
}
};
}
...
...
common/http.interceptor.js
View file @
8f8312e1
...
...
@@ -11,6 +11,7 @@ const install = (Vue, vm) => {
// 请求参数默认配置
Vue
.
prototype
.
$u
.
http
.
setConfig
({
baseUrl
:
vm
.
vuex_config
.
baseUrl
,
baseSapUrl
:
vm
.
vuex_config
.
baseSapUrl
,
originalData
:
true
,
// 默认头部,http2约定header名称统一小写 aidex
header
:
{
...
...
pages/confirComplete/confirComplete.vue
View file @
8f8312e1
...
...
@@ -38,14 +38,14 @@
<view
class=
"bottomTitle"
@
tap=
"show = !show"
>
<view
class=
"desc"
>
卷条码明细
</view>
<view
class=
"topIcons"
>
<
text
v-if=
"show"
>
<
view
v-if=
"show"
>
<u-icon
name=
"arrow-down"
color=
"#aaa"
size=
"32"
></u-icon>
展开
</
text
>
<
text
v-else
>
</
view
>
<
view
v-else
>
<u-icon
name=
"arrow-up"
color=
"#aaa"
size=
"32"
></u-icon>
收起
</
text
>
</
view
>
</view>
</view>
<view
v-if=
"!show"
class=
"bottomBox"
>
...
...
pages/inventoryCounting/inventoryForm.vue
View file @
8f8312e1
...
...
@@ -14,14 +14,14 @@
<view
class=
"bottomTitle"
@
tap=
"show = !show"
>
<view
class=
"desc"
>
展开调整明细
</view>
<view
class=
"topIcons"
>
<
text
v-if=
"show"
>
<
view
v-if=
"show"
>
<u-icon
name=
"arrow-down"
color=
"#aaa"
size=
"32"
></u-icon>
展开
</
text
>
<
text
v-else
>
</
view
>
<
view
v-else
>
<u-icon
name=
"arrow-up"
color=
"#aaa"
size=
"32"
></u-icon>
收起
</
text
>
</
view
>
</view>
</view>
<view
v-if=
"!show"
class=
"bottomBox"
>
...
...
pages/inventoryCounting/inventoryList.vue
View file @
8f8312e1
...
...
@@ -15,7 +15,7 @@
<view
class=
"inventoryDetail"
>
<view
class=
"detailTitle"
>
盘点明细
</view>
<view
class=
""
>
<u-button
size=
"mini"
class=
""
type=
"success"
@
click=
"
handleClickWork()
"
>
<u-button
size=
"mini"
class=
""
type=
"success"
@
click=
"
addShowModel = true
"
>
<u-icon
name=
"plus"
></u-icon>
新增
</u-button>
...
...
@@ -52,7 +52,7 @@
<view
class=
"boxRight"
>
<view
class=
"items"
>
891/1000pcs
</view>
<view
class=
"itemsBtn"
>
<u-button
size=
"mini"
class=
""
type=
"primary"
@
click=
"
handleClickWork()
"
>
盘点
</u-button>
<u-button
size=
"mini"
class=
""
type=
"primary"
@
click=
"
checkShowModel=true
"
>
盘点
</u-button>
</view>
</view>
</view>
...
...
@@ -60,6 +60,23 @@
</view>
</view>
<BottomBtn
:btnArr=
"btnArr"
@
getBtnHandle=
"getBtnHandle"
></BottomBtn>
<u-modal
v-model=
"addShowModel"
@
confirm=
"addConfirm"
ref=
"addShowModel"
:show-title=
"false"
:show-cancel-button=
"true"
>
<view
class=
"slot-content"
>
<u-form
:model=
"addForm"
ref=
"addForm"
>
<u-form-item
label=
"批号"
><u-input
v-model=
"addForm.name"
/></u-form-item>
<u-form-item
label=
"批次"
><u-input
v-model=
"addForm.name"
/></u-form-item>
<u-form-item
label=
"数量"
><u-input
v-model=
"addForm.name"
/></u-form-item>
</u-form>
</view>
</u-modal>
<u-modal
v-model=
"checkShowModel"
@
confirm=
"addConfirm"
ref=
"checkShowModel"
:show-title=
"false"
:show-cancel-button=
"true"
>
<view
class=
"slot-content"
>
<u-form
:model=
"checkForm"
ref=
"checkForm"
>
<uni-easyinput
prefixIcon=
"search"
class=
"topSearch"
v-model=
"checkForm.name"
focus
placeholder=
"请扫描盘点库位条码"
@
input=
"handleInput"
></uni-easyinput>
<u-form-item
label=
"数量"
><u-input
v-model=
"checkForm.name"
/></u-form-item>
</u-form>
</view>
</u-modal>
</view>
</
template
>
...
...
@@ -76,7 +93,7 @@ export default {
data
()
{
return
{
value
:
''
,
show
:
fals
e
,
show
:
tru
e
,
btnArr
:
[
{
style
:
''
,
...
...
@@ -84,12 +101,19 @@ export default {
text
:
'盘点确认'
,
way
:
'goBack'
}
]
],
addShowModel
:
false
,
checkShowModel
:
false
,
addForm
:
{
name
:
''
},
checkForm
:
{
name
:
''
},
};
},
computed
:
{},
methods
:
{
handleClickWork
()
{},
handleInput
(
e
)
{
console
.
log
(
e
,
'eee'
);
},
...
...
@@ -102,7 +126,10 @@ export default {
},
ontabtap
(
e
,
type
)
{
console
.
log
(
'切换tab'
,
e
,
type
);
}
},
addConfirm
(){
this
.
addShowModel
=
false
},
}
};
</
script
>
...
...
@@ -205,4 +232,10 @@ export default {
justify-content
:
space-between
;
border-bottom
:
1px
solid
#333
;
}
.slot-content
{
padding
:
20rpx
;
.u-form-item
{
padding
:
0
;
}
}
</
style
>
pages/purchaseStorage/purchaseStorage.vue
View file @
8f8312e1
...
...
@@ -38,14 +38,14 @@
<view
class=
"bottomTitle"
@
tap=
"show = !show"
>
<view
class=
"desc"
>
卷条码明细
</view>
<view
class=
"topIcons"
>
<
text
v-if=
"show"
>
<
view
v-if=
"show"
>
<u-icon
name=
"arrow-down"
color=
"#aaa"
size=
"32"
></u-icon>
展开
</
text
>
<
text
v-else
>
</
view
>
<
view
v-else
>
<u-icon
name=
"arrow-up"
color=
"#aaa"
size=
"32"
></u-icon>
收起
</
text
>
</
view
>
</view>
</view>
<view
v-if=
"!show"
class=
"bottomBox"
>
...
...
@@ -122,28 +122,28 @@ export default {
style
:
''
,
type
:
'warning'
,
text
:
'返回'
,
way
:
'goBack'
,
way
:
'goBack'
},
{
style
:
''
,
type
:
'primary'
,
text
:
'提交'
,
way
:
'goSubmit'
,
way
:
'goSubmit'
}
]
,
]
};
},
methods
:
{
getBtnHandle
(
row
){
this
[
row
.
way
]()
getBtnHandle
(
row
)
{
this
[
row
.
way
]()
;
},
goBack
(){
goBack
()
{
uni
.
navigateBack
();
},
goSubmit
(){},
goSubmit
()
{},
handleInput
(
e
)
{
console
.
log
(
e
,
'eee'
);
}
,
}
}
};
</
script
>
...
...
pages/sys/login/login.vue
View file @
8f8312e1
...
...
@@ -45,24 +45,24 @@
return
{
loading
:
false
,
loginForm
:
{
username
:
"admin"
,
password
:
"000000"
,
rememberMe
:
false
,
validCode
:
''
,
uuid
:
""
username
:
"admin"
,
password
:
"000000"
,
rememberMe
:
false
,
validCode
:
''
,
uuid
:
""
},
loginRules
:
{
username
:
{
rules
:
[
{
required
:
true
,
trigger
:
"blur"
,
errorMessage
:
"请输入您的账号"
}
],
},
username
:
{
rules
:
[
{
required
:
true
,
trigger
:
"blur"
,
errorMessage
:
"请输入您的账号"
}
],
},
password
:
{
rules
:
[
{
required
:
true
,
trigger
:
"blur"
,
errorMessage
:
"请输入您的密码"
}
]
}
password
:
{
rules
:
[
{
required
:
true
,
trigger
:
"blur"
,
errorMessage
:
"请输入您的密码"
}
]
}
},
}
},
...
...
uview-ui/libs/request/index.js
View file @
8f8312e1
...
...
@@ -15,7 +15,7 @@ class Request {
let
interceptorRequest
=
this
.
interceptor
.
request
(
options
);
if
(
interceptorRequest
===
false
)
{
// 返回一个处于pending状态中的Promise,来取消原promise,避免进入then()回调
return
new
Promise
(()
=>
{});
return
new
Promise
(()
=>
{});
}
this
.
options
=
interceptorRequest
;
}
...
...
@@ -34,7 +34,7 @@ class Request {
clearTimeout
(
this
.
config
.
timer
);
this
.
config
.
timer
=
null
;
// 判断用户对拦截返回数据的要求,如果originalData为true,返回所有的数据(response)到拦截器,否则只返回response.data
if
(
this
.
config
.
originalData
)
{
if
(
this
.
config
.
originalData
)
{
// 判断是否存在拦截器
if
(
this
.
interceptor
.
response
&&
typeof
this
.
interceptor
.
response
===
'function'
)
{
let
resInterceptors
=
this
.
interceptor
.
response
(
response
);
...
...
@@ -51,7 +51,8 @@ class Request {
}
}
else
{
if
(
response
.
statusCode
==
200
)
{
if
(
this
.
interceptor
.
response
&&
typeof
this
.
interceptor
.
response
===
'function'
)
{
if
(
this
.
interceptor
.
response
&&
typeof
this
.
interceptor
.
response
===
'function'
)
{
let
resInterceptors
=
this
.
interceptor
.
response
(
response
.
data
);
if
(
resInterceptors
!==
false
)
{
resolve
(
resInterceptors
);
...
...
@@ -73,15 +74,21 @@ class Request {
}
}
}
// 处理sap接口
let
url
=
this
.
config
.
baseUrl
if
(
options
.
url
.
indexOf
(
'sap'
)
>
-
1
){
url
=
this
.
config
.
baseSapUrl
// options.url = options.url.replace('/sap','')
options
.
header
=
{...
options
.
header
,
'Authorization'
:
'Basic cmVzdF91c2VyOkJzbjEyMzQ1Ng=='
}
}
// 判断用户传递的URL是否/开头,如果不是,加上/,这里使用了uView的test.js验证库的url()方法
options
.
url
=
validate
.
url
(
options
.
url
)
?
options
.
url
:
(
this
.
config
.
baseU
rl
+
(
options
.
url
.
indexOf
(
'/'
)
==
0
?
options
.
url
=
validate
.
url
(
options
.
url
)
?
options
.
url
:
(
u
rl
+
(
options
.
url
.
indexOf
(
'/'
)
==
0
?
options
.
url
:
'/'
+
options
.
url
));
// 是否显示loading
// 加一个是否已有timer定时器的判断,否则有两个同时请求的时候,后者会清除前者的定时器id
// 而没有清除前者的定时器,导致前者超时,一直显示loading
if
(
this
.
config
.
showLoading
&&
!
this
.
config
.
timer
)
{
if
(
this
.
config
.
showLoading
&&
!
this
.
config
.
timer
)
{
this
.
config
.
timer
=
setTimeout
(()
=>
{
uni
.
showLoading
({
title
:
this
.
config
.
loadingText
,
...
...
@@ -102,6 +109,7 @@ class Request {
constructor
()
{
this
.
config
=
{
baseUrl
:
''
,
// 请求的根域名
baseSapUrl
:
''
,
// SAP请求的根域名
// 默认的请求头
header
:
{},
method
:
'POST'
,
...
...
@@ -116,7 +124,7 @@ class Request {
originalData
:
false
,
// 是否在拦截器中返回服务端的原始数据,见文档说明
loadingMask
:
true
,
// 展示loading的时候,是否给一个透明的蒙层,防止触摸穿透
}
// 拦截器
this
.
interceptor
=
{
// 请求前的拦截
...
...
@@ -144,7 +152,7 @@ class Request {
data
})
}
// put请求,不支持支付宝小程序(HX2.6.15)
this
.
put
=
(
url
,
data
=
{},
header
=
{})
=>
{
return
this
.
request
({
...
...
@@ -154,7 +162,7 @@ class Request {
data
})
}
// delete请求,不支持支付宝和头条小程序(HX2.6.15)
this
.
delete
=
(
url
,
data
=
{},
header
=
{})
=>
{
return
this
.
request
({
...
...
@@ -166,4 +174,4 @@ class Request {
}
}
}
export
default
new
Request
export
default
new
Request
\ No newline at end of file
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