Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yanshouyi-Minipro
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
xinzhedeai
yanshouyi-Minipro
Commits
a344f63f
Commit
a344f63f
authored
Dec 16, 2024
by
xinzhedeai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
数据列表对接 login使用公共方法
parent
8c72da9d
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
1190 additions
and
242 deletions
+1190
-242
blueToothMeasure.js
api/blueToothMeasure.js
+35
-0
login.js
api/login.js
+9
-0
request.js
common/request.js
+61
-0
pages.json
pages.json
+8
-0
home.vue
pages/home/home.vue
+11
-138
importFileDataPreview.vue
pages/home/importFileDataPreview.vue
+118
-82
paokongceliang.vue
pages/home/paokongceliang.vue
+689
-0
tableData.js
pages/home/tableData.js
+194
-0
login.vue
pages/user/login.vue
+65
-22
No files found.
api/blueToothMeasure.js
0 → 100644
View file @
a344f63f
import
request
from
'
@/common/request.js
'
export
function
getSelectList
(
data
)
{
// 获取下拉列表数据
return
request
({
url
:
'
/product/getList
'
,
method
:
'
get
'
,
data
})
}
export
function
getDetailInfo
(
data
)
{
// 获取下拉列表数据
return
request
({
url
:
'
/product/getList
'
,
method
:
'
get
'
,
data
})
}
export
function
saveData
(
data
)
{
// 获取下拉列表数据
return
request
({
url
:
'
/product/getList
'
,
method
:
'
post
'
,
data
})
}
export
function
getDict
(
data
)
{
// 获取下拉列表数据
return
request
({
url
:
'
/system/dict/data/type/
'
+
data
.
type
,
method
:
'
get
'
,
})
}
api/login.js
0 → 100644
View file @
a344f63f
import
request
from
'
@/common/request.js
'
export
function
login
(
params
)
{
// 登录获取token
return
request
({
url
:
'
/weixin/wxLogin
'
,
method
:
'
post
'
,
data
:
params
.
data
})
}
\ No newline at end of file
common/request.js
0 → 100644
View file @
a344f63f
import
{
showCustomModal
}
from
"
./util
"
;
const
BASE_URL
=
'
http://192.168.2.14:8080
'
;
const
REQUEST_TIMEOUT
=
30000
;
export
default
function
request
(
options
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
uni
.
request
({
url
:
options
.
url
,
method
:
options
.
method
||
'
GET
'
,
data
:
options
.
data
||
{},
header
:
options
.
header
||
{
'
Content-Type
'
:
'
application/json
'
,
},
success
:
(
res
)
=>
{
console
.
log
(
res
,
'
request
'
)
if
(
res
.
code
===
200
)
{
resolve
(
res
.
data
);
}
else
{
reject
(
res
);
}
},
fail
:
(
err
)
=>
{
reject
(
err
);
}
});
});
}
uni
.
addInterceptor
(
"
request
"
,
{
invoke
(
args
)
{
// request 触发前拼接 url
args
.
url
=
BASE_URL
+
args
.
url
},
success
(
res
)
{
const
{
code
,
msg
}
=
res
.
data
;
console
.
log
(
'
addInterceptor
'
,
code
,
msg
)
if
(
code
!==
200
)
{
showCustomModal
({
content
:
msg
,
});
// uni.navigateTo({
// url: "/pages/login/login"
// });
return
;
}
return
Promise
.
resolve
(
res
.
data
);
},
fail
(
err
)
{
uni
.
showToast
({
title
:
"
网络异常
"
,
icon
:
"
error
"
,
duration
:
2000
});
return
Promise
.
reject
(
err
);
}
});
\ No newline at end of file
pages.json
View file @
a344f63f
...
...
@@ -84,8 +84,16 @@
{
"navigationBarTitleText"
:
""
}
},
{
"path"
:
"pages/home/paokongceliang"
,
"style"
:
{
"navigationBarTitleText"
:
""
}
}
],
"globalStyle"
:
{
"pageOrientation"
:
"portrait"
,
...
...
pages/home/home.vue
View file @
a344f63f
...
...
@@ -15,7 +15,7 @@
</p>
<p
class=
"list-item"
>
<image
src=
"/static/image/home/icon1.png"
alt=
""
/>
<span>
登录
</span>
<span>
入出date
</span>
<button
size=
"mini"
class=
"funcBtn"
type=
"primary"
@
click=
"navTo('import')"
>
导入导出
</button>
</p>
<p
class=
"list-item"
>
...
...
@@ -38,11 +38,16 @@
<span>
钻孔测量数据列表
</span>
<button
size=
"mini"
class=
"funcBtn"
type=
"primary"
@
click=
"navTo('export')"
>
导出
</button>
</p>
<
!--
<
p
class=
"list-item"
>
<p
class=
"list-item"
>
<image
src=
"/static/image/home/5.png"
alt=
""
/>
<span>
导入数据预览
</span>
<button
size=
"mini"
class=
"funcBtn"
type=
"primary"
@
click=
"navTo('importFileDataPreview')"
>
进入
</button>
</p>
-->
</p>
<p
class=
"list-item"
>
<image
src=
"/static/image/home/5.png"
alt=
""
/>
<span>
炮孔测量
</span>
<button
size=
"mini"
class=
"funcBtn"
type=
"primary"
@
click=
"navTo('paokongceliang')"
>
进入
</button>
</p>
<view
class=
"footer"
>
<span>
威海晶合数字矿山技术有限公司
...
...
@@ -79,64 +84,6 @@
uni
.
hideTabBar
()
},
methods
:
{
exportData2Excel
()
{
//要导出的json数据
// const jsonData = [{
// name: '测试数据',
// phone: '123456',
// email: '123@456.com'
// }
// ]
const
jsonData
=
uni
.
getStorageSync
(
'
importDataList
'
)
||
[]
if
(
!
jsonData
.
length
){
showCustomModal
({
content
:
'
本地暂无可导出数据,请确认
'
})
return
}
//列标题
let
worksheet
=
"
sheet1
"
;
let
str
=
`<tr>
<td>工程名称</td>
<td>中段名称</td>
<td>分段名称</td>
<td>排位线名称</td>
<td>炮孔编号</td>
<td>透孔</td>
<td>设计孔深</td>
<td>设计倾角</td>
<td>实测孔深</td>
<td>实测倾角</td>
<td>实测时间</td>
</tr>`
;
//循环遍历,每行加入tr标签,每个单元格加td标签
for
(
let
i
=
0
;
i
<
jsonData
.
length
;
i
++
)
{
str
+=
`<tr>
<td>
${
jsonData
[
i
][
'
engineeringName
'
]}
</td>
<td>
${
jsonData
[
i
][
'
middleSectionName
'
]}
</td>
<td>
${
jsonData
[
i
][
'
segmentName
'
]}
</td>
<td>
${
jsonData
[
i
][
'
alignmentLineName
'
]}
</td>
<td>
${
jsonData
[
i
][
'
boreholeNumber
'
]}
</td>
<td>
${
jsonData
[
i
][
'
throughHole
'
]}
</td>
<td>
${
jsonData
[
i
][
'
designHoleDepth
'
]}
</td>
<td>
${
jsonData
[
i
][
'
designInclination
'
]}
</td>
<td>
${
jsonData
[
i
][
'
realTestHoleDepth
'
]
||
''
}
</td>
<td>
${
jsonData
[
i
][
'
realTestInclination
'
]
||
''
}
</td>
<td>
${
jsonData
[
i
][
'
realTestTime
'
]
||
''
}
</td>
</tr>`
;
}
//下载的表格模板数据
let
template
=
`<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<head><!--[if gte mso 9]><xml encoding="UTF-8"><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>
<x:Name>
${
worksheet
}
</x:Name>
<x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet>
</x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]-->
</head><body><table>
${
str
}
</table></body></html>`
;
//下载模板
exportFile
(
template
);
},
navTo
(
flag
){
if
(
flag
===
'
export
'
){
this
.
exportData2Excel
()
...
...
@@ -156,90 +103,16 @@
url
=
'
/pages/home/blueSearch
'
}
else
if
(
flag
===
'
importFileDataPreview
'
){
url
=
'
/pages/home/importFileDataPreview
'
}
else
if
(
flag
===
'
paokongceliang
'
){
url
=
'
/pages/home/paokongceliang
'
}
uni
.
navigateTo
({
url
})
}
}
}
// 导出文件到手机 fileData:要写入到文件的数据,返回参数为文档路径
function
exportFile
(
fileData
,
documentName
=
"
项目Excel文件
"
)
{
/*
PRIVATE_DOC: 应用私有文档目录常量
PUBLIC_DOCUMENTS: 程序公用文档目录常量
*/
plus
.
io
.
requestFileSystem
(
plus
.
io
.
PUBLIC_DOCUMENTS
,
function
(
fs
)
{
let
rootObj
=
fs
.
root
;
let
fullPath
=
rootObj
.
fullPath
;
// let reader = rootObj.createReader();
// console.log(reader);
// reader.readEntries((res)=>{
// console.log(res); //这里拿到了该目录下所有直接文件和目录
// },(err)=>{console.log(err);})
console
.
log
(
"
开始导出数据********
"
);
// 创建文件夹
rootObj
.
getDirectory
(
documentName
,
{
create
:
true
},
function
(
dirEntry
)
{
//获取当前的年月继续创建文件夹
let
date
=
new
Date
();
let
year
=
date
.
getFullYear
();
let
month
=
date
.
getMonth
()
+
1
;
dirEntry
.
getDirectory
(
`
${
year
}
年
${
month
}
月`
,{
create
:
true
},
function
(
dirEntry2
){
// 创建文件,防止重名
let
fileName
=
"
excel
"
+
getUnixTime
(
formatDateThis
(
new
Date
()));
console
.
log
(
fileName
);
dirEntry2
.
getFile
(
`
${
fileName
}
.xlsx`
,
{
create
:
true
},
function
(
fileEntry
)
{
fileEntry
.
createWriter
(
function
(
writer
)
{
writer
.
onwritestart
=
(
e
)
=>
{
uni
.
showLoading
({
title
:
"
正在导出
"
,
mask
:
true
})
}
// /storage/emulated/0指的就是系统路径
let
pathStr
=
fullPath
.
replace
(
"
/storage/emulated/0
"
,
""
);
writer
.
onwrite
=
(
e
)
=>
{
// 成功导出数据;
uni
.
hideLoading
();
setTimeout
(()
=>
{
showCustomModal
({
content
:
`导出成功=>文件位置:
${
pathStr
}
/
${
documentName
}
/
${
year
}
年
${
month
}
月`
})
// uni.showToast({
// title:"成功导出",
// icon:"success"
// })
// that.successTip = `文件位置:${pathStr}/${documentName}/${year}年${month}月`;
},
500
)
};
// 写入内容;
writer
.
write
(
fileData
);
},
function
(
e
)
{
console
.
log
(
e
.
message
);
});
});
})
});
});
}
</
script
>
<
style
lang=
"scss"
>
.wrapper
{
...
...
pages/home/importFileDataPreview.vue
View file @
a344f63f
<
template
>
<view
class=
"pageWrapper"
>
<table>
<caption>
导入数据预览
</caption>
<tr>
<th>
工程名称
</th>
<th>
中段名称
</th>
<th>
分段名称
</th>
<th>
排位线名称
</th>
<th>
炮孔编号
</th>
<th>
透孔
</th>
<th>
设计孔深
</th>
<th>
设计倾角
</th>
<th>
实测孔深
</th>
<th>
实测倾角
</th>
<th>
实测时间
</th>
</tr>
<tr
v-for=
"item in dataList"
>
<td>
{{
item
[
'
engineeringName
'
]
}}
</td>
<td>
{{
item
[
'
middleSectionName
'
]
}}
</td>
<td>
{{
item
[
'
segmentName
'
]
}}
</td>
<td>
{{
item
[
'
alignmentLineName
'
]
}}
</td>
<td>
{{
item
[
'
boreholeNumber
'
]
}}
</td>
<td>
{{
item
[
'
throughHole
'
]
}}
</td>
<td>
{{
item
[
'
designHoleDepth
'
]
}}
</td>
<td>
{{
item
[
'
designInclination
'
]
}}
</td>
<td>
{{
item
[
'
realTestHoleDepth
'
]
}}
</td>
<td>
{{
item
[
'
realTestInclination
'
]
}}
</td>
<td>
{{
item
[
'
realTestTime
'
]
}}
</td>
</tr>
</table>
<view>
<view
class=
"uni-container"
>
<uni-table
ref=
"table"
:loading=
"loading"
border
stripe
type=
"selection"
emptyText=
"暂无更多数据"
@
selection-change=
"selectionChange"
>
<uni-tr>
<uni-th
width=
"150"
align=
"center"
>
日期
</uni-th>
<uni-th
width=
"150"
align=
"center"
>
姓名
</uni-th>
<uni-th
align=
"center"
>
地址
</uni-th>
<uni-th
width=
"204"
align=
"center"
>
设置
</uni-th>
</uni-tr>
<uni-tr
v-for=
"(item, index) in tableData"
:key=
"index"
>
<uni-td>
{{
item
.
date
}}
</uni-td>
<uni-td>
<view
class=
"name"
>
{{
item
.
name
}}
</view>
</uni-td>
<uni-td
align=
"center"
>
{{
item
.
address
}}
</uni-td>
<uni-td>
<view
class=
"uni-group"
>
<button
class=
"uni-button"
size=
"mini"
type=
"primary"
>
修改
</button>
<button
class=
"uni-button"
size=
"mini"
type=
"warn"
>
删除
</button>
</view>
</uni-td>
</uni-tr>
</uni-table>
<view
class=
"uni-pagination-box"
><uni-pagination
show-icon
:page-size=
"pageSize"
:current=
"pageCurrent"
:total=
"total"
@
change=
"change"
/></view>
</view>
</view>
</
template
>
<
script
>
export
default
{
import
tableData
from
'
./tableData.js
'
export
default
{
data
()
{
return
{
dataList
:
[]
searchVal
:
''
,
tableData
:
[],
// 每页数据量
pageSize
:
10
,
// 当前页
pageCurrent
:
1
,
// 数据总量
total
:
0
,
loading
:
false
}
},
onLoad
()
{
this
.
selectedIndexs
=
[]
this
.
getData
(
1
)
},
methods
:
{
// 多选处理
selectedItems
()
{
return
this
.
selectedIndexs
.
map
(
i
=>
this
.
tableData
[
i
])
},
onLoad
()
{
this
.
dataList
=
uni
.
getStorageSync
(
'
importDataList
'
)
}
}
</
script
>
<
style
>
.pageWrapper
{
overflow-x
:
auto
;
font-family
:
Arial
,
sans-serif
;
background-color
:
#f4f4f4
;
/* margin: 0; */
/* padding: 20rpx; */
}
h1
{
text-align
:
center
;
color
:
#333
;
}
table
{
width
:
100vw
;
border-collapse
:
collapse
;
/* margin: 20px 0; */
box-shadow
:
0
2px
10px
rgba
(
0
,
0
,
0
,
0.1
);
background-color
:
#fff
;
// 多选
selectionChange
(
e
)
{
console
.
log
(
e
.
detail
.
index
)
this
.
selectedIndexs
=
e
.
detail
.
index
},
//批量删除
delTable
()
{
console
.
log
(
this
.
selectedItems
())
},
// 分页触发
change
(
e
)
{
this
.
$refs
.
table
.
clearSelection
()
this
.
selectedIndexs
.
length
=
0
this
.
getData
(
e
.
current
)
},
// 搜索
search
()
{
this
.
getData
(
1
,
this
.
searchVal
)
},
// 获取数据
getData
(
pageCurrent
,
value
=
''
)
{
this
.
loading
=
true
this
.
pageCurrent
=
pageCurrent
this
.
request
({
pageSize
:
this
.
pageSize
,
pageCurrent
:
pageCurrent
,
value
:
value
,
success
:
res
=>
{
// console.log('data', res);
this
.
tableData
=
res
.
data
this
.
total
=
res
.
total
this
.
loading
=
false
}
th
,
td
{
padding
:
12
rpx
;
text-align
:
left
;
border-bottom
:
1px
solid
#ddd
;
})
},
// 伪request请求
request
(
options
)
{
const
{
pageSize
,
pageCurrent
,
success
,
value
}
=
options
let
total
=
tableData
.
length
let
data
=
tableData
.
filter
((
item
,
index
)
=>
{
const
idx
=
index
-
(
pageCurrent
-
1
)
*
pageSize
return
idx
<
pageSize
&&
idx
>=
0
})
if
(
value
)
{
data
=
[]
tableData
.
forEach
(
item
=>
{
if
(
item
.
name
.
indexOf
(
value
)
!==
-
1
)
{
data
.
push
(
item
)
}
th
{
background-color
:
#1499ff
;
color
:
white
;
})
total
=
data
.
length
}
tr
:nth-child
(
even
)
{
background-color
:
#f2f2f2
;
setTimeout
(()
=>
{
typeof
success
===
'
function
'
&&
success
({
data
:
data
,
total
:
total
})
},
500
)
}
tr
:hover
{
background-color
:
#e0e0e0
;
}
}
</
script
>
<
style
>
/* #ifndef H5 */
/* page {
padding-top: 85px;
} */
/* #endif */
.uni-group
{
display
:
flex
;
align-items
:
center
;
}
</
style
>
pages/home/paokongceliang.vue
0 → 100644
View file @
a344f63f
<
template
>
<view
class=
"pageWrapper"
>
<CustomNavbar
:title=
"navBarTitle"
goBackUrl=
"/pages/home/home"
@
gobackDeal=
"gobackDeal"
>
</CustomNavbar>
<view
class=
"body-wrapper"
>
<view
class=
"sumary-title"
>
手动填写数据
</view>
<uni-row
class=
"demo-uni-row mb-10"
>
<uni-col
:span=
"6"
class=
"_title"
>
<view>
工程名称
</view>
</uni-col>
<uni-col
:span=
"16"
>
<uni-data-select
v-model=
"form.productName"
:localdata=
"selectListLv1"
:clear=
"false"
@
change=
"changeLv1"
></uni-data-select>
</uni-col>
</uni-row>
<uni-row
class=
"demo-uni-row mb-10"
>
<uni-col
:span=
"6"
class=
"_title"
>
<view>
爆区名称
</view>
</uni-col>
<uni-col
:span=
"16"
>
<uni-data-select
v-model=
"form.artilleryAreaName"
:localdata=
"selectListLv2"
:clear=
"false"
@
change=
"changeLv2"
></uni-data-select>
</uni-col>
</uni-row>
<uni-row
class=
"demo-uni-row mb-10"
>
<uni-col
:span=
"6"
class=
"_title"
>
<view>
炮孔排号
</view>
</uni-col>
<uni-col
:span=
"16"
>
<uni-data-select
v-model=
"form['cannonHoleArrayNum']"
:localdata=
"selectListLv3"
:clear=
"false"
@
change=
"changeLv3"
></uni-data-select>
</uni-col>
</uni-row>
<uni-row
class=
"demo-uni-row mb-10"
>
<uni-col
:span=
"6"
class=
"_title"
>
<view>
炮孔编号
</view>
</uni-col>
<uni-col
:span=
"16"
>
<uni-data-select
v-model=
"form['cannonHoleNum']"
:localdata=
"selectListLv4"
:clear=
"false"
@
change=
"changeLv4"
></uni-data-select>
</uni-col>
</uni-row>
<uni-row
class=
"demo-uni-row mb-10"
>
<uni-col
:span=
"6"
class=
"_title"
>
<view>
设计孔深
</view>
</uni-col>
<uni-col
:span=
"16"
>
<view
class=
"_content"
>
{{
form
[
'
expectedDepth
'
]
||
'
-
'
}}
</view>
</uni-col>
</uni-row>
<uni-row
class=
"demo-uni-row mb-10"
>
<uni-col
:span=
"6"
class=
"_title"
>
<view>
装药选择
</view>
</uni-col>
<uni-col
:span=
"16"
>
<uni-data-select
v-model=
"form['status']"
:localdata=
"zhuangyaoDict"
:clear=
"false"
></uni-data-select>
</uni-col>
</uni-row>
</view>
<view
class=
"body-wrapper auto"
>
<view
class=
"sumary-title"
>
自动更新数据
</view>
<uni-row
class=
"demo-uni-row mb-10"
>
<uni-col
:span=
"6"
class=
"_title"
>
<view>
测量孔深度
</view>
</uni-col>
<uni-col
:span=
"16"
>
<view
class=
"_content"
>
{{
form
[
'
actualDepth
'
]
||
'
-
'
}}
</view>
</uni-col>
</uni-row>
<uni-row
class=
"demo-uni-row mb-10 demo-uni-row-unborder"
>
<uni-col
:span=
"6"
class=
"_title"
>
<view>
测量孔水位
</view>
</uni-col>
<uni-col
:span=
"16"
>
<view
class=
"_content angle"
>
<view>
{{
form
[
'
actualWaterLevel
'
]
||
'
-
'
}}
</view>
</view>
</uni-col>
</uni-row>
<uni-row
class=
"demo-uni-row mb-10 demo-uni-row-unborder"
>
<uni-col
:span=
"6"
class=
"_title"
>
<view>
备注
</view>
</uni-col>
<uni-col
:span=
"16"
>
<view
class=
"_content unaffix"
>
<view>
{{
form
[
'
remark
'
]
||
'
-
'
}}
</view>
</view>
</uni-col>
</uni-row>
</view>
<!--
<view
style=
"display: flex; justify-content: flex-end; align-items: center; margin-right: 20rpx;padding-top: 10rpx;"
>
<switch
checked
style=
"transform:scale(0.7)"
@
change=
"showResultChange"
/>
不显示实测结果直接保存
</view>
-->
<view
class=
"footer-wrapper"
v-show=
"connected"
>
<view
class=
"funcBtn end"
@
tap=
"resetForm"
>
取消
</view>
<view
class=
"funcBtn end"
@
tap=
"saveData"
>
保存
</view>
</view>
<view
class=
""
v-show=
"!connected"
style=
"text-align: center; color: darkgray; margin-top:20rpx;"
>
{{
pageLoadText
}}
</view>
<!--
<button
@
click=
"showResultModal"
>
点击模态框显示
</button>
-->
<!--
<uni-popup
ref=
"popup"
background-color=
"#fff"
@
change=
"change"
>
<view
class=
"popup-content"
>
<view
class=
"_header"
>
孔实测结果
</view>
<view
class=
"_body"
>
<p>
实测孔深:
<span>
{{
form
[
'
actualDepth
'
]
||
'
-
'
}}
m
</span></p>
<p>
实测倾角:
<span>
{{
form
[
'
actualWaterLevel
'
]
||
'
-
'
}}
°
</span></p>
</view>
<view
class=
"funcBtn _btn"
@
click=
"saveTestResult"
>
保存测量结果
</view>
</view>
</uni-popup>
-->
</view>
</
template
>
<
script
>
import
CustomNavbar
from
'
@/pages/component/CustomNavbar.vue
'
;
import
{
blueToothMixin
}
from
'
../../common/mixin.js
'
import
{
getCurrentTime
,
showCustomToast
,
showCustomModal
}
from
'
../../common/util.js
'
import
{
getSelectList
,
getDetailInfo
,
saveData
,
getDict
}
from
'
../../api/blueToothMeasure.js
'
export
default
{
mixins
:
[
blueToothMixin
],
components
:
{
CustomNavbar
,
},
data
()
{
return
{
navBarTitle
:
'
炮孔测量
'
,
redirectUrl
:
'
/pages/home/blueSearch?refer=blueMeasure
'
,
// 表单数据相关
zhuangyaoDict
:
[
/* {
text: '未填装',
value: '未填装'
}, {
text: '已填装',
value: '已填装'
} */
],
form
:
{
'
productName
'
:
''
,
'
artilleryAreaName
'
:
''
,
'
cannonHoleArrayNum
'
:
''
,
'
cannonHoleNum
'
:
''
,
'
status
'
:
''
,
'
expectedDepth
'
:
''
,
'
actualDepth
'
:
''
,
'
actualWaterLevel
'
:
''
},
dataList
:
[],
selectListLv1
:
[],
selectListLv2
:
[],
selectListLv3
:
[],
selectListLv4
:
[],
selectListLv5
:
[],
};
},
/**
* 生命周期函数--监听页面加载
*/
onLoad
:
function
(
options
)
{
uni
.
hideLoading
()
// this.dataList = uni.getStorageSync('importDataList') || []
// console.log('this.dataList',JSON.stringify(this.dataList));
this
.
getDictInfo
()
this
.
getSelectListLv1
()
// this.initLink()
},
methods
:
{
async
getDictInfo
()
{
let
res
=
await
getDict
({
type
:
'
zhuangyao_type
'
})
if
(
res
){
this
.
zhuangyaoDict
=
res
.
map
((
item
)
=>
{
return
{
text
:
item
.
dictLabel
,
value
:
item
.
dictValue
}
})
}
},
changeLvCommonReset
(
lvNum
)
{
// 下拉列表值改变,清空级联数据公共方法
let
newFildArr
=
[]
let
newDataListSelectArr
=
[]
let
formFieldArr
=
[
'
productName
'
,
'
artilleryAreaName
'
,
'
cannonHoleArrayNum
'
,
'
cannonHoleNum
'
,
'
status
'
,
'
expectedDepth
'
,
'
actualDepth
'
,
'
actualWaterLevel
'
]
let
dataListSelectArr
=
[
'
selectListLv1
'
,
'
selectListLv2
'
,
'
selectListLv3
'
,
'
selectListLv4
'
,
'
selectListLv5
'
]
// [1, 2, 3, 4, 5]; lvNum:2 => [3, 4, 5]
newFildArr
=
formFieldArr
.
slice
(
lvNum
);
newFildArr
.
forEach
((
key
)
=>
{
this
[
'
form
'
][
key
]
=
''
});
newDataListSelectArr
=
dataListSelectArr
.
slice
(
lvNum
);
newDataListSelectArr
.
forEach
((
key
)
=>
{
this
[
key
]
=
[]
});
},
async
getSelectListLv1
()
{
// const dataArr = JSON.parse(JSON.stringify(this.dataList))
// // 获取第一个数据列表
// this.selectListLv1 = getCascadeList(dataArr, {
// productName: null
// }).map((item) => {
// return {
// text: item.productName,
// value: item.productName
// }
// })
const
res
=
await
getSelectList
({
productName
:
''
,
artilleryAreaName
:
''
,
cannonHoleArrayNum
:
''
,
cannonHoleNum
:
''
})
console
.
log
(
'
响应res
'
,
res
)
this
.
selectListLv1
=
res
.
map
((
item
)
=>
{
return
{
text
:
item
,
value
:
item
}
})
},
changeLv1
(
e
)
{
// console.log("e:", e);
this
.
changeLvCommonReset
(
1
)
this
.
getSelectListLv2
(
e
)
},
async
getSelectListLv2
(
prevLvVal
)
{
// const dataArr = JSON.parse(JSON.stringify(this.dataList))
// this.selectListLv2 = getCascadeList(dataArr, {
// productName: prevLvVal,
// }).map((item) => {
// return {
// text: item.artilleryAreaName,
// value: item.artilleryAreaName
// }
// })
// //console.log('this.selectListLv2', this.selectListLv2)
const
res
=
await
getSelectList
({
productName
:
prevLvVal
,
artilleryAreaName
:
''
,
cannonHoleArrayNum
:
''
,
cannonHoleNum
:
''
})
console
.
log
(
'
响应res
'
,
res
)
this
.
selectListLv2
=
res
.
map
((
item
)
=>
{
return
{
text
:
item
,
value
:
item
}
})
},
changeLv2
(
e
)
{
//console.log("e:", e);
this
.
changeLvCommonReset
(
2
)
this
.
getSelectListLv3
(
e
)
},
async
getSelectListLv3
(
prevLvVal
)
{
// const dataArr = JSON.parse(JSON.stringify(this.dataList))
// this.selectListLv3 = getCascadeList(dataArr, {
// productName: this.form.productName,
// artilleryAreaName: prevLvVal
// }).map((item) => {
// return {
// text: item.cannonHoleArrayNum,
// value: item.cannonHoleArrayNum
// }
// })
const
res
=
await
getSelectList
({
productName
:
this
.
form
.
productName
,
artilleryAreaName
:
prevLvVal
,
cannonHoleArrayNum
:
''
,
cannonHoleNum
:
''
})
console
.
log
(
'
响应res
'
,
res
)
this
.
selectListLv3
=
res
.
map
((
item
)
=>
{
return
{
text
:
item
,
value
:
item
}
})
},
changeLv3
(
e
)
{
//console.log("e:", e);
this
.
changeLvCommonReset
(
3
)
this
.
getSelectListLv4
(
e
)
},
async
getSelectListLv4
(
prevLvVal
)
{
// const dataArr = JSON.parse(JSON.stringify(this.dataList))
// this.selectListLv4 = getCascadeList(dataArr, {
// productName: this.form.productName,
// artilleryAreaName: this.form.artilleryAreaName,
// cannonHoleArrayNum: prevLvVal
// }).map((item) => {
// return {
// text: item.cannonHoleNum,
// value: item.cannonHoleNum
// }
// })
const
res
=
await
getSelectList
({
productName
:
this
.
form
.
productName
,
artilleryAreaName
:
this
.
form
.
artilleryAreaName
,
cannonHoleArrayNum
:
prevLvVal
,
cannonHoleNum
:
''
})
console
.
log
(
'
响应res
'
,
res
)
this
.
selectListLv4
=
res
.
map
((
item
)
=>
{
return
{
text
:
item
,
value
:
item
}
})
},
changeLv4
(
e
)
{
// this.changeLvCommonReset(4)
// //console.log("e:", e);
// this.getSelectListLv5(e)
this
.
getDetailInfo
(
e
)
},
// getSelectListLv5(prevLvVal) {
// const dataArr = JSON.parse(JSON.stringify(this.dataList))
// this.selectListLv5 = getCascadeList(dataArr, {
// productName: this.form.productName,
// artilleryAreaName: this.form.artilleryAreaName,
// cannonHoleArrayNum: this.form.cannonHoleArrayNum,
// cannonHoleNum: prevLvVal,
// }).map((item) => {
// return {
// text: item.boreholeNumber,
// value: item.boreholeNumber
// }
// })
// },
// changeLv5(e) {
// //console.log("e:", e);
// this.getDetailInfo(e)
// },
async
getDetailInfo
()
{
let
res
=
await
getDetailInfo
()
if
(
res
)
{
this
.
form
[
'
status
'
]
=
res
[
'
status
'
]
this
.
form
[
'
expectedDepth
'
]
=
res
[
'
expectedDepth
'
]
this
.
form
[
'
designInclination
'
]
=
res
[
'
designInclination
'
]
return
}
showCustomToast
({
title
:
'
暂无详情信息
'
})
},
async
saveData
()
{
// 保存当前表单数据到本地
let
formFieldArr
=
[
'
productName
'
,
'
artilleryAreaName
'
,
'
cannonHoleArrayNum
'
,
'
cannonHoleNum
'
,
'
boreholeNumber
'
]
var
validFlag
=
true
for
(
var
i
=
0
;
i
<
formFieldArr
.
length
;
i
++
)
{
console
.
log
(
'
this.form[formFieldArr[i]]
'
,
i
,
this
.
form
[
formFieldArr
[
i
]])
if
(
!
this
.
form
[
formFieldArr
[
i
]])
{
validFlag
=
false
break
;
}
}
if
(
!
validFlag
)
{
showCustomModal
({
content
:
`手动填写数据不可为空`
})
return
}
// const index = this.dataList.findIndex((item) => {
// return item.productName === this.form.productName &&
// item.artilleryAreaName === this.form.artilleryAreaName &&
// item.cannonHoleArrayNum === this.form.cannonHoleArrayNum &&
// item.cannonHoleNum === this.form.cannonHoleNum &&
// item.boreholeNumber === this.form.boreholeNumber
// })
if
(
this
.
form
.
measureDepth
&&
this
.
form
.
shuiwei
)
{
let
res
=
await
saveData
({
...
this
.
form
})
// this.$set(this.dataList[index], 'actualWaterLevel', this.form.actualWaterLevel);
// this.$set(this.dataList[index], 'actualDepth', this.form.actualDepth);
// this.$set(this.dataList[index], 'remark', getCurrentTime());
// uni.setStorageSync('importDataList', JSON.parse(JSON.stringify(this.dataList)))
if
(
res
)
{
uni
.
showToast
({
title
:
'
保存成功
'
,
icon
:
false
})
this
.
resetForm
()
}
return
}
showCustomModal
({
content
:
'
孔深水位不能为空
'
,
})
},
}
};
/**
* 处理级联数据方法
*/
function
getCascadeList
(
originArr
=
[],
paramObj
)
{
let
sonArr
=
new
Array
()
// let sonArr = new Set()
if
(
paramObj
.
artilleryAreaName
&&
paramObj
.
productName
&&
paramObj
.
cannonHoleArrayNum
&&
paramObj
.
cannonHoleNum
)
{
// 返回第5级
const
tempArr
=
originArr
.
filter
((
item
)
=>
{
return
item
.
productName
===
paramObj
.
productName
&&
item
.
artilleryAreaName
===
paramObj
.
artilleryAreaName
&&
item
.
cannonHoleArrayNum
===
paramObj
.
cannonHoleArrayNum
&&
item
.
cannonHoleNum
===
paramObj
.
cannonHoleNum
})
const
uniqueArray
=
Array
.
from
(
new
Map
(
tempArr
.
map
(
item
=>
[
item
.
boreholeNumber
,
item
])).
values
());
return
uniqueArray
}
if
(
paramObj
.
artilleryAreaName
&&
paramObj
.
productName
&&
paramObj
.
cannonHoleArrayNum
)
{
// 返回第4级
const
tempArr
=
originArr
.
filter
((
item
)
=>
{
return
item
.
productName
===
paramObj
.
productName
&&
item
.
artilleryAreaName
===
paramObj
.
artilleryAreaName
&&
item
.
cannonHoleArrayNum
===
paramObj
.
cannonHoleArrayNum
})
const
uniqueArray
=
Array
.
from
(
new
Map
(
tempArr
.
map
(
item
=>
[
item
.
cannonHoleNum
,
item
])).
values
());
return
uniqueArray
}
if
(
paramObj
.
artilleryAreaName
&&
paramObj
.
productName
)
{
// 返回第三级
const
tempArr
=
originArr
.
filter
((
item
)
=>
{
return
item
.
productName
===
paramObj
.
productName
&&
item
.
artilleryAreaName
===
paramObj
.
artilleryAreaName
})
const
uniqueArray
=
Array
.
from
(
new
Map
(
tempArr
.
map
(
item
=>
[
item
.
cannonHoleArrayNum
,
item
])).
values
());
return
uniqueArray
}
if
(
paramObj
.
productName
)
{
// 返回2级列表
const
tempArr
=
originArr
.
filter
((
item
)
=>
{
// 二级列表基于1级选择后的值进行过滤
return
item
.
productName
===
paramObj
.
productName
})
const
uniqueArray
=
Array
.
from
(
new
Map
(
tempArr
.
map
(
item
=>
[
item
.
artilleryAreaName
,
item
])).
values
());
return
uniqueArray
}
if
(
!
paramObj
.
productName
)
{
// 返回1级列表
const
uniqueArray
=
Array
.
from
(
new
Map
(
originArr
.
map
(
item
=>
[
item
.
productName
,
item
])).
values
());
return
uniqueArray
}
}
</
script
>
<
style
lang=
"scss"
>
::v-deep
.uni-row
::after
{
clear
:
both
;
width
:
608rpx
;
border-bottom
:
1rpx
solid
#E3E6EC
;
transform
:
translateX
(
28rpx
);
}
.pageWrapper
{
width
:
100vw
;
height
:
calc
(
100vh-44rpx
);
padding-top
:
44rpx
;
background
:
linear-gradient
(
180deg
,
#007AFF
0%
,
#419AFF
16%
,
#EFF1F4
43%
);
}
.body-wrapper
{
margin
:
0
auto
;
width
:
690rpx
;
padding-top
:
20rpx
;
padding-left
:
15rpx
;
padding-right
:
15rpx
;
background
:
#FFFFFF
;
border-radius
:
10rpx
;
&
.auto
{
margin-top
:
30rpx
;
background-color
:
#D1E5FB
;
.demo-uni-row
{
padding-top
:
10rpx
;
padding-bottom
:
10rpx
;
// border-bottom: 1px solid #F1F8FF;
}
::v-deep
.uni-row
::after
{
border-bottom-color
:
#FFFFFF
;
}
.
demo-uni-row-unborder
:
:
after
{
// 特殊没有底部边线 处理
border-bottom-color
:
transparent
;
}
}
.sumary-title
{
position
:
relative
;
padding-left
:
50rpx
;
font-size
:
32rpx
;
color
:
#007AFF
;
margin-top
:
20rpx
;
margin-bottom
:
20rpx
;
&
:before
{
content
:
''
;
width
:
16rpx
;
height
:
16rpx
;
background
:
#007AFF
;
border-radius
:
50%
;
position
:
absolute
;
left
:
20rpx
;
top
:
50%
;
transform
:
translateY
(
-50%
);
}
}
}
.logo-wrapper
{
display
:
flex
;
justify-content
:
center
;
image
{
width
:
366rpx
;
height
:
432rpx
;
margin
:
0
auto
;
}
}
.mb-10
{
margin-bottom
:
10rpx
;
}
._title
{
// border: 1px solid lightgray;
height
:
70rpx
;
text-align
:
center
;
line-height
:
70rpx
;
margin-right
:
10rpx
;
font-size
:
29rpx
;
font-weight
:
bold
;
color
:
#000000
;
}
._content
{
// border: 1px solid lightgray;
height
:
70rpx
;
line-height
:
70rpx
;
padding-left
:
20rpx
;
position
:
relative
;
&
:after
{
content
:
'm'
;
width
:
70rpx
;
height
:
70rpx
;
// border-left: 1px solid lightgray;
position
:
absolute
;
right
:
-12rpx
;
top
:
0
;
text-align
:
center
;
line-height
:
70rpx
;
font-size
:
29rpx
;
color
:
#000000
;
}
}
.funcBtn
{
width
:
280rpx
;
height
:
70rpx
;
line-height
:
70rpx
;
background
:
#007AFF
;
border-radius
:
35rpx
;
text-align
:
center
;
font-size
:
29rpx
;
color
:
#FFFFFF
;
border
:
2px
solid
#007AFF
;
&
.end
{
background
:
#FFFFFF
;
;
color
:
#007AFF
;
}
&
.loading
{
opacity
:
0
.5
;
}
}
.footer-wrapper
{
display
:
flex
;
justify-content
:
space-around
;
margin-top
:
50rpx
;
}
.angle
{
&
:after
{
content
:
'°'
;
}
}
.unaffix
{
&
:after
{
display
:
none
;
}
}
/**
* 蓝牙连接互动相关
*/
page
{
color
:
#333
;
}
/*划线 */
.line
{
background-color
:
blue
;
height
:
5px
;
width
:
100%
;
}
.div
{
background-color
:
white
;
height
:
10px
;
width
:
10px
;
}
.blank
{
height
:
150rpx
;
}
</
style
>
\ No newline at end of file
pages/home/tableData.js
0 → 100644
View file @
a344f63f
export
default
[{
"
date
"
:
"
2020-09-01
"
,
"
name
"
:
"
Dcloud1
"
,
"
address
"
:
"
上海市普陀区金沙江路 1518 弄
"
},
{
"
date
"
:
"
2020-09-02
"
,
"
name
"
:
"
Dcloud2
"
,
"
address
"
:
"
上海市普陀区金沙江路 1517 弄
"
},
{
"
date
"
:
"
2020-09-03
"
,
"
name
"
:
"
Dcloud3
"
,
"
address
"
:
"
上海市普陀区金沙江路 1519 弄
"
},
{
"
date
"
:
"
2020-09-04
"
,
"
name
"
:
"
Dcloud4
"
,
"
address
"
:
"
上海市普陀区金沙江路 1516 弄
"
},
{
"
date
"
:
"
2020-09-05
"
,
"
name
"
:
"
Dcloud5
"
,
"
address
"
:
"
上海市普陀区金沙江路 1518 弄
"
},
{
"
date
"
:
"
2020-09-06
"
,
"
name
"
:
"
Dcloud6
"
,
"
address
"
:
"
上海市普陀区金沙江路 1517 弄
"
},
{
"
date
"
:
"
2020-09-07
"
,
"
name
"
:
"
Dcloud7
"
,
"
address
"
:
"
上海市普陀区金沙江路 1519 弄
"
},
{
"
date
"
:
"
2020-09-08
"
,
"
name
"
:
"
Dcloud8
"
,
"
address
"
:
"
上海市普陀区金沙江路 1516 弄
"
},
{
"
date
"
:
"
2020-09-09
"
,
"
name
"
:
"
Dcloud9
"
,
"
address
"
:
"
上海市普陀区金沙江路 1518 弄
"
},
{
"
date
"
:
"
2020-09-10
"
,
"
name
"
:
"
Dcloud10
"
,
"
address
"
:
"
上海市普陀区金沙江路 1517 弄
"
},
{
"
date
"
:
"
2020-09-11
"
,
"
name
"
:
"
Dcloud11
"
,
"
address
"
:
"
上海市普陀区金沙江路 1519 弄
"
},
{
"
date
"
:
"
2020-09-12
"
,
"
name
"
:
"
Dcloud12
"
,
"
address
"
:
"
上海市普陀区金沙江路 1516 弄
"
},
{
"
date
"
:
"
2020-09-13
"
,
"
name
"
:
"
Dcloud13
"
,
"
address
"
:
"
上海市普陀区金沙江路 1518 弄
"
},
{
"
date
"
:
"
2020-09-14
"
,
"
name
"
:
"
Dcloud14
"
,
"
address
"
:
"
上海市普陀区金沙江路 1517 弄
"
},
{
"
date
"
:
"
2020-09-15
"
,
"
name
"
:
"
Dcloud15
"
,
"
address
"
:
"
上海市普陀区金沙江路 1519 弄
"
},
{
"
date
"
:
"
2020-09-16
"
,
"
name
"
:
"
Dcloud16
"
,
"
address
"
:
"
上海市普陀区金沙江路 1516 弄
"
},
{
"
date
"
:
"
2020-09-01
"
,
"
name
"
:
"
Dcloud17
"
,
"
address
"
:
"
上海市普陀区金沙江路 1518 弄
"
},
{
"
date
"
:
"
2020-09-02
"
,
"
name
"
:
"
Dcloud18
"
,
"
address
"
:
"
上海市普陀区金沙江路 1517 弄
"
},
{
"
date
"
:
"
2020-09-03
"
,
"
name
"
:
"
Dcloud19
"
,
"
address
"
:
"
上海市普陀区金沙江路 1519 弄
"
},
{
"
date
"
:
"
2020-09-04
"
,
"
name
"
:
"
Dcloud20
"
,
"
address
"
:
"
上海市普陀区金沙江路 1516 弄
"
},
{
"
date
"
:
"
2020-09-05
"
,
"
name
"
:
"
Dcloud21
"
,
"
address
"
:
"
上海市普陀区金沙江路 1518 弄
"
},
{
"
date
"
:
"
2020-09-06
"
,
"
name
"
:
"
Dcloud22
"
,
"
address
"
:
"
上海市普陀区金沙江路 1517 弄
"
},
{
"
date
"
:
"
2020-09-07
"
,
"
name
"
:
"
Dcloud23
"
,
"
address
"
:
"
上海市普陀区金沙江路 1519 弄
"
},
{
"
date
"
:
"
2020-09-08
"
,
"
name
"
:
"
Dcloud24
"
,
"
address
"
:
"
上海市普陀区金沙江路 1516 弄
"
},
{
"
date
"
:
"
2020-09-09
"
,
"
name
"
:
"
Dcloud25
"
,
"
address
"
:
"
上海市普陀区金沙江路 1518 弄
"
},
{
"
date
"
:
"
2020-09-10
"
,
"
name
"
:
"
Dcloud26
"
,
"
address
"
:
"
上海市普陀区金沙江路 1517 弄
"
},
{
"
date
"
:
"
2020-09-11
"
,
"
name
"
:
"
Dcloud27
"
,
"
address
"
:
"
上海市普陀区金沙江路 1519 弄
"
},
{
"
date
"
:
"
2020-09-12
"
,
"
name
"
:
"
Dcloud28
"
,
"
address
"
:
"
上海市普陀区金沙江路 1516 弄
"
},
{
"
date
"
:
"
2020-09-13
"
,
"
name
"
:
"
Dcloud29
"
,
"
address
"
:
"
上海市普陀区金沙江路 1518 弄
"
},
{
"
date
"
:
"
2020-09-14
"
,
"
name
"
:
"
Dcloud30
"
,
"
address
"
:
"
上海市普陀区金沙江路 1517 弄
"
},
{
"
date
"
:
"
2020-09-15
"
,
"
name
"
:
"
Dcloud31
"
,
"
address
"
:
"
上海市普陀区金沙江路 1519 弄
"
},
{
"
date
"
:
"
2020-09-16
"
,
"
name
"
:
"
Dcloud32
"
,
"
address
"
:
"
上海市普陀区金沙江路 1516 弄
"
},
{
"
date
"
:
"
2020-09-01
"
,
"
name
"
:
"
Dcloud33
"
,
"
address
"
:
"
上海市普陀区金沙江路 1518 弄
"
},
{
"
date
"
:
"
2020-09-02
"
,
"
name
"
:
"
Dcloud34
"
,
"
address
"
:
"
上海市普陀区金沙江路 1517 弄
"
},
{
"
date
"
:
"
2020-09-03
"
,
"
name
"
:
"
Dcloud35
"
,
"
address
"
:
"
上海市普陀区金沙江路 1519 弄
"
},
{
"
date
"
:
"
2020-09-04
"
,
"
name
"
:
"
Dcloud36
"
,
"
address
"
:
"
上海市普陀区金沙江路 1516 弄
"
},
{
"
date
"
:
"
2020-09-05
"
,
"
name
"
:
"
Dcloud37
"
,
"
address
"
:
"
上海市普陀区金沙江路 1518 弄
"
},
{
"
date
"
:
"
2020-09-06
"
,
"
name
"
:
"
Dcloud38
"
,
"
address
"
:
"
上海市普陀区金沙江路 1517 弄
"
},
{
"
date
"
:
"
2020-09-07
"
,
"
name
"
:
"
Dcloud39
"
,
"
address
"
:
"
上海市普陀区金沙江路 1519 弄
"
},
{
"
date
"
:
"
2020-09-08
"
,
"
name
"
:
"
Dcloud40
"
,
"
address
"
:
"
上海市普陀区金沙江路 1516 弄
"
},
{
"
date
"
:
"
2020-09-09
"
,
"
name
"
:
"
Dcloud41
"
,
"
address
"
:
"
上海市普陀区金沙江路 1518 弄
"
},
{
"
date
"
:
"
2020-09-10
"
,
"
name
"
:
"
Dcloud42
"
,
"
address
"
:
"
上海市普陀区金沙江路 1517 弄
"
},
{
"
date
"
:
"
2020-09-11
"
,
"
name
"
:
"
Dcloud43
"
,
"
address
"
:
"
上海市普陀区金沙江路 1519 弄
"
},
{
"
date
"
:
"
2020-09-12
"
,
"
name
"
:
"
Dcloud44
"
,
"
address
"
:
"
上海市普陀区金沙江路 1516 弄
"
},
{
"
date
"
:
"
2020-09-13
"
,
"
name
"
:
"
Dcloud45
"
,
"
address
"
:
"
上海市普陀区金沙江路 1518 弄
"
},
{
"
date
"
:
"
2020-09-14
"
,
"
name
"
:
"
Dcloud46
"
,
"
address
"
:
"
上海市普陀区金沙江路 1517 弄
"
},
{
"
date
"
:
"
2020-09-15
"
,
"
name
"
:
"
Dcloud47
"
,
"
address
"
:
"
上海市普陀区金沙江路 1519 弄
"
},
{
"
date
"
:
"
2020-09-16
"
,
"
name
"
:
"
Dcloud48
"
,
"
address
"
:
"
上海市普陀区金沙江路 1516 弄
"
}]
pages/user/login.vue
View file @
a344f63f
...
...
@@ -19,9 +19,12 @@
<
script
>
import
{
showCustomToast
}
from
'
../../common/util.js
'
import
{
login
}
from
'
../../api/login.js
'
export
default
{
onLoad
()
{
/**
*
* {"errMsg":"login:ok","code":"0f1q6Tll2gxgEe4Apiml2fxzdl4q6Tlh"}
* {
"encryptedData": "z47dFJgWWcFlRiN38qzwykrxraYUj/caxt8nNJb/YonFtuGtMHCirL5G/GKWs/T7UDfmREUgyJ3z9nBiuCDE9XIbDslKTO3hpdM0Lw98gVZKOMtSjbmtAYTLbkUdDn4J6RdPYLIdCF8pUaqSZxkD+41tXW1JXKYrEuLWAZ5fmxn4rV0vCsnS+ciRdUWToq8s/KkMNHb0/1nlIyho5dz5GO1ac+BNvfk0YPrgkQdvMSCzB5NAQxUfFQERyErMW9dfQeQLXpelu0F00q778V1xAgmFWFh9IFIwVUyzSsCsMQHZpDPZT8nM3l/kNPRpK50L2msSxJ9H7lp2M8oUcQDPRttPakj1TyYb3iGDs6dx4lMBA38qbw5IYvWmrXw+A7avz/o+0u0RRrUR99u+ert6V1cg8ubDbMJGDqzAPlsTt6OdzIsGNZfddVZ/HR/9vJQc5OCgnMFRVDU9S+OTZbFLHQ==",
"iv": "kdDnOvCrhjUS5J1vA5fK9A==",
...
...
@@ -39,38 +42,79 @@
"errMsg": "getUserInfo:ok"
}
*/
const
token
=
uni
.
getStorageSync
(
'
accessToken
'
)
if
(
!
token
){
this
.
wxLogin
()
}
},
data
()
{
return
{
}
},
methods
:
{
async
wxLogin
(){
const
loginRes
=
await
this
.
getWxCode
()
if
(
!
loginRes
.
code
){
return
}
const
userInfo
=
await
this
.
getUserInfo
()
if
(
!
userInfo
.
iv
){
return
}
await
this
.
getToken
(
loginRes
.
code
,
userInfo
)
},
getWxCode
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
uni
.
login
({
provider
:
'
weixin
'
,
success
:
(
loginRes
)
=>
{
console
.
log
(
'
loginRes:
'
+
JSON
.
stringify
(
loginRes
));
// 获取用户信息
success
:
(
loginRes
)
=>
{
console
.
log
(
'
loginRes:
'
+
JSON
.
stringify
(
loginRes
));
resolve
(
loginRes
);
},
fail
:
(
err
)
=>
reject
(
err
)
// 添加失败处理
});
});
},
getUserInfo
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
uni
.
getUserInfo
({
provider
:
'
weixin
'
,
success
:
(
infoRes
)
=>
{
this
.
getToken
()
console
.
log
(
'
infoRes:
'
+
JSON
.
stringify
(
infoRes
));
}
resolve
(
infoRes
);
},
fail
:
(
err
)
=>
reject
(
err
)
// 添加失败处理
});
}
});
},
data
()
{
return
{
}
async
getToken
(
code
,
userInfo
){
let
res
=
await
login
({
data
:
{
"
code
"
:
code
,
"
encryptedIv
"
:
userInfo
.
iv
,
"
encryptedData
"
:
userInfo
.
encryptedData
},
methods
:
{
async
getToken
(
reqObj
){
})
console
.
log
(
'
res
'
,
res
)
if
(
res
){
uni
.
setStorageSync
(
'
accessToken
'
,
res
.
token
)
console
.
log
(
'
获取token
'
,
res
.
token
)
}
// let [error, res] = await uni.request({
// url: `
${BASE_URI}/api/login/weChat
Login`,
// url: `
http://192.168.2.14:8080/weixin/wx
Login`,
// data: {
// ...reqObj
// "code": code,
// "encryptedIv": userInfo.iv,
// "encryptedData": userInfo.encryptedData
// },
// method,
// method
: 'POST'
,
// header: {
// 'accessToken': uni.getStorageSync('accessToken'),
//
//
'accessToken': uni.getStorageSync('accessToken'),
// }
// });
...
...
@@ -80,10 +124,9 @@
// })
// return
// }
// if(res){
// uni.setStorageSync('accessToken', res.
accessT
oken)
// if(res
.data.code === 200
){
// uni.setStorageSync('accessToken', res.
data.t
oken)
// }
}
}
...
...
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