Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hls-webapp-cli
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
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
heasy
hls-webapp-cli
Commits
66a6ae19
Commit
66a6ae19
authored
Jul 12, 2019
by
Nature
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微信弹框和文件选择
parent
e2cc21cb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
380 deletions
+81
-380
hlsPopup.js
template/src/scripts/hlsPopup.js
+44
-97
hlsUtil.js
template/src/scripts/hlsUtil.js
+37
-283
No files found.
template/src/scripts/hlsPopup.js
View file @
66a6ae19
...
@@ -34,14 +34,6 @@ export default {
...
@@ -34,14 +34,6 @@ export default {
if
(
vm
.
isLoading
)
{
if
(
vm
.
isLoading
)
{
Vue
.
$vux
.
loading
.
hide
()
Vue
.
$vux
.
loading
.
hide
()
vm
.
isLoading
=
false
vm
.
isLoading
=
false
// 弹出操作失败
/* Vue.$vux.toast.show({
text: '操作失败',
type: 'warn',
time: vm.SHOW_TIMES,
isShowMask: vm.IS_SHOW_MASK,
position: 'middle',
}) */
}
}
},
40000
)
},
40000
)
},
},
...
@@ -60,7 +52,6 @@ export default {
...
@@ -60,7 +52,6 @@ export default {
showLongTop
:
function
(
content
)
{
showLongTop
:
function
(
content
)
{
let
vm
=
this
let
vm
=
this
let
text
=
content
||
'操作失败'
let
text
=
content
||
'操作失败'
if
(
!
process
.
env
.
isMobilePlatform
)
{
Vue
.
$vux
.
toast
.
show
({
Vue
.
$vux
.
toast
.
show
({
text
:
text
,
text
:
text
,
type
:
'text'
,
type
:
'text'
,
...
@@ -68,11 +59,6 @@ export default {
...
@@ -68,11 +59,6 @@ export default {
isShowMask
:
vm
.
IS_SHOW_MASK
,
isShowMask
:
vm
.
IS_SHOW_MASK
,
position
:
'top'
,
position
:
'top'
,
})
})
}
else
{
window
.
plugins
.
toast
.
showLongTop
(
content
,
function
(
success
)
{
},
function
(
error
)
{
// eslint-disable-line
})
}
},
},
/**
/**
...
@@ -82,7 +68,6 @@ export default {
...
@@ -82,7 +68,6 @@ export default {
showLongCenter
:
function
(
content
)
{
showLongCenter
:
function
(
content
)
{
let
vm
=
this
let
vm
=
this
let
text
=
content
||
'操作失败'
let
text
=
content
||
'操作失败'
if
(
!
process
.
env
.
isMobilePlatform
)
{
Vue
.
$vux
.
toast
.
show
({
Vue
.
$vux
.
toast
.
show
({
text
:
text
,
text
:
text
,
type
:
'text'
,
type
:
'text'
,
...
@@ -90,11 +75,6 @@ export default {
...
@@ -90,11 +75,6 @@ export default {
isShowMask
:
vm
.
IS_SHOW_MASK
,
isShowMask
:
vm
.
IS_SHOW_MASK
,
position
:
'middle'
,
position
:
'middle'
,
})
})
}
else
{
window
.
plugins
.
toast
.
showLongCenter
(
content
,
function
(
success
)
{
},
function
(
error
)
{
// eslint-disable-line
})
}
},
},
/**
/**
* 长时间中部提示toast
* 长时间中部提示toast
...
@@ -103,7 +83,7 @@ export default {
...
@@ -103,7 +83,7 @@ export default {
showLongBottom
:
function
(
content
)
{
showLongBottom
:
function
(
content
)
{
let
vm
=
this
let
vm
=
this
let
text
=
content
||
'操作失败'
let
text
=
content
||
'操作失败'
if
(
!
process
.
env
.
isMobilePlatform
)
{
Vue
.
$vux
.
toast
.
show
({
Vue
.
$vux
.
toast
.
show
({
text
:
text
,
text
:
text
,
time
:
vm
.
SHOW_TIMES
,
time
:
vm
.
SHOW_TIMES
,
...
@@ -111,11 +91,6 @@ export default {
...
@@ -111,11 +91,6 @@ export default {
isShowMask
:
vm
.
IS_SHOW_MASK
,
isShowMask
:
vm
.
IS_SHOW_MASK
,
position
:
'bottom'
,
position
:
'bottom'
,
})
})
}
else
{
window
.
plugins
.
toast
.
showLongBottom
(
content
,
function
(
success
)
{
},
function
(
error
)
{
// eslint-disable-line
})
}
},
},
/**
/**
* 成功提示框
* 成功提示框
...
@@ -152,7 +127,6 @@ export default {
...
@@ -152,7 +127,6 @@ export default {
* @param confirmObject.onConfirm 确定函数
* @param confirmObject.onConfirm 确定函数
*/
*/
showConfirm
:
function
(
confirmObject
)
{
showConfirm
:
function
(
confirmObject
)
{
if
(
!
process
.
env
.
isMobilePlatform
)
{
let
def
=
{
let
def
=
{
title
:
confirmObject
.
title
||
'提示'
,
title
:
confirmObject
.
title
||
'提示'
,
content
:
confirmObject
.
content
||
''
,
content
:
confirmObject
.
content
||
''
,
...
@@ -166,21 +140,6 @@ export default {
...
@@ -166,21 +140,6 @@ export default {
},
},
}
}
Vue
.
$vux
.
confirm
.
show
(
def
)
Vue
.
$vux
.
confirm
.
show
(
def
)
}
else
{
let
message
=
confirmObject
.
content
||
''
let
onConfirm
=
function
(
index
)
{
confirmObject
.
onConfirm
(
index
)
}
let
title
=
confirmObject
.
title
navigator
.
notification
.
confirm
(
message
,
// message
function
(
index
)
{
onConfirm
(
index
-
1
)
},
title
,
// title
[
'取消'
,
'确定'
]
// buttonLabels
)
}
},
},
/*
/*
* 弹出确认的窗口
* 弹出确认的窗口
...
@@ -190,7 +149,6 @@ export default {
...
@@ -190,7 +149,6 @@ export default {
*
*
*/
*/
showPopup
:
function
(
confirmObject
)
{
showPopup
:
function
(
confirmObject
)
{
if
(
!
process
.
env
.
isMobilePlatform
)
{
let
def
=
{
let
def
=
{
title
:
confirmObject
.
title
||
'提示'
,
title
:
confirmObject
.
title
||
'提示'
,
content
:
confirmObject
.
content
||
''
,
content
:
confirmObject
.
content
||
''
,
...
@@ -201,19 +159,6 @@ export default {
...
@@ -201,19 +159,6 @@ export default {
},
},
}
}
Vue
.
$vux
.
confirm
.
show
(
def
)
Vue
.
$vux
.
confirm
.
show
(
def
)
}
else
{
var
alertDismissed
=
function
(
index
)
{
confirmObject
.
onConfirm
()
}
let
title
=
confirmObject
.
title
||
'提示'
var
message
=
confirmObject
.
content
||
''
navigator
.
notification
.
alert
(
message
,
// message
alertDismissed
,
// callback
title
||
'提示'
,
// title
'确定'
// buttonName
)
}
},
},
/**
/**
* @param actionObject.titleText 弹出框的标题可空
* @param actionObject.titleText 弹出框的标题可空
...
@@ -298,6 +243,8 @@ export default {
...
@@ -298,6 +243,8 @@ export default {
ShowPicturePlugin
.
show
({
ShowPicturePlugin
.
show
({
imgUrl
:
imgObject
.
imgUrl
,
imgUrl
:
imgObject
.
imgUrl
,
width
:
imgObject
.
width
,
width
:
imgObject
.
width
,
imgList
:
imgObject
.
imgList
,
startPosition
:
imgObject
.
startPosition
,
})
})
}
}
},
},
...
...
template/src/scripts/hlsUtil.js
View file @
66a6ae19
...
@@ -257,53 +257,32 @@ export default {
...
@@ -257,53 +257,32 @@ export default {
let
pattern
=
/^
([
a-zA-Z0-9_.-
])
+@
([
a-zA-Z0-9_-
])
+
(
.
[
a-zA-Z0-9_-
])
+/
let
pattern
=
/^
([
a-zA-Z0-9_.-
])
+@
([
a-zA-Z0-9_-
])
+
(
.
[
a-zA-Z0-9_-
])
+/
return
pattern
.
test
(
str
)
return
pattern
.
test
(
str
)
},
},
/**
*
* @param cameraoption 对象{quality:质量默认50,allowEdit:true||false,width:宽度,height:高度}
* @param onSuccess 成功回调函数
* @param onFail 失败回调函数
*/
/* eslint-disable */
openCamera
:
function
(
cameraoption
,
onSuccess
,
onFail
)
{
if
(
typeof
onSuccess
===
'function'
&&
typeof
onFail
===
'function'
)
{
let
options
=
{
quality
:
cameraoption
.
quality
||
50
,
destinationType
:
Camera
.
DestinationType
.
FILE_URI
,
sourceType
:
Camera
.
PictureSourceType
.
CAMERA
,
allowEdit
:
cameraoption
.
allowEdit
||
false
,
targetWidth
:
cameraoption
.
width
||
1024
,
targetHeight
:
cameraoption
.
height
||
768
,
encodingType
:
Camera
.
EncodingType
.
JPEG
,
popoverOptions
:
CameraPopoverOptions
,
saveToPhotoAlbum
:
window
.
localStorage
.
savePhoto
||
false
,
correctOrientation
:
true
,
}
navigator
.
camera
.
getPicture
(
onSuccess
,
onFail
,
options
)
}
else
{
window
.
hlsPopup
.
showLongCenter
(
'参数有误!'
)
}
},
/**
/**
* 最多选取10张,返回图片的存储地址数组形式
* 微信选择图片
* @param obj {quality:质量默认50,width:宽度,height:高度}
* @returns {Promise<any>}
* @param successFunction 成功回调函数
* @param errorFunction 失败函数
*/
*/
takePicture
:
function
(
obj
,
successFunction
,
errorFunction
)
{
takePicture
:
function
()
{
if
(
typeof
successFunction
===
'function'
&&
typeof
errorFunction
===
'function'
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
window
.
imagePicker
.
getPictures
(
wx
.
chooseImage
({
successFunction
,
errorFunction
,
{
count
:
9
,
// 微信最多能选择9张图片
maximumImagesCount
:
obj
.
maxCount
||
10
,
sizeType
:
[
'original'
,
'compressed'
],
// 可以指定是原图还是压缩图,默认二者都有
quality
:
obj
.
quality
||
50
,
sourceType
:
[
'album'
,
'camera'
],
// 可以指定来源是相册还是相机,默认二者都有
width
:
obj
.
width
||
1024
,
success
:
function
(
data
)
{
height
:
obj
.
height
||
768
,
let
localIds
=
data
.
localIds
// 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片
}
let
pictureList
=
[]
)
data
.
localIds
.
forEach
((
localId
,
index
)
=>
{
}
else
{
wx
.
getLocalImgData
({
window
.
hlsPopup
.
showLongBottom
(
'参数有误!'
)
localId
:
localId
,
// 图片的localID
}
success
:
function
(
res
)
{
pictureList
.
push
(
res
.
localData
)
},
})
})
resolve
({
localIds
:
localIds
,
pictureList
:
pictureList
})
},
})
})
},
},
/**
/**
...
@@ -320,121 +299,23 @@ export default {
...
@@ -320,121 +299,23 @@ export default {
callEmail
:
function
(
email
)
{
callEmail
:
function
(
email
)
{
window
.
open
(
'mailto:'
+
email
)
window
.
open
(
'mailto:'
+
email
)
},
},
/**
* 非ftp的上传方式
* @param filePath
* @param success
*/
fileUploadHls
:
function
(
file
,
success
)
{
let
path
=
file
.
filePath
let
name
=
path
.
substr
(
path
.
lastIndexOf
(
'/'
)
+
1
)
let
url
=
encodeURI
(
process
.
env
.
rootPath
+
'/app/fileUploadHls?sysName=HLS_APP&apiName=attment_file_upload'
)
let
options
=
new
FileUploadOptions
()
// eslint-disable-line
options
.
fileKey
=
'file'
options
.
headers
=
{
'Authorization'
:
'Bearer '
+
window
.
localStorage
.
access_token
,
}
options
.
params
=
{
'table_name'
:
file
.
table_name
,
'table_pk_value'
:
file
.
table_pk_value
,
'user_id'
:
window
.
localStorage
.
user_id
,
'access_token'
:
window
.
localStorage
.
access_token
,
'filePath'
:
path
,
}
options
.
fileName
=
name
options
.
mimeType
=
'multipart/form-date'
let
ft
=
new
FileTransfer
()
// eslint-disable-line
ft
.
onprogress
=
function
(
progressEvent
)
{
if
(
progressEvent
.
lengthComputable
)
{
loadingStatus
.
setPercentage
(
progressEvent
.
loaded
/
progressEvent
.
total
)
// eslint-disable-line
}
else
{
loadingStatus
.
increment
()
// eslint-disable-line
}
}
function
uploadSuccess
(
result
)
{
success
(
JSON
.
parse
(
result
.
response
))
}
function
fileError
()
{
window
.
hlsPopup
.
hideLoading
()
console
.
log
(
'upload error source '
+
error
.
source
)
console
.
log
(
'upload error target '
+
error
.
target
)
}
ft
.
upload
(
path
,
url
,
uploadSuccess
,
fileError
,
options
)
},
/**
/**
* 调用系统svc进行上传
* 上传图片到微信服务器返回 serverId
* @param filePath
* @param localId
* @param success
* @param isShowProgressTips
* @returns {Promise<any>}
*/
*/
fileUploadSvc
:
function
(
file
,
success
)
{
wxFileUpload
:
function
(
localId
,
isShowProgressTips
)
{
let
path
=
file
.
filePath
return
new
Promise
(
function
(
resolve
,
reject
)
{
let
name
=
path
.
substr
(
path
.
lastIndexOf
(
'/'
)
+
1
)
wx
.
uploadImage
({
let
url
=
encodeURI
(
process
.
env
.
rootPath
+
'/app/fileUploadSvc?sysName=HLS_APP&apiName=attachment_upload'
)
localId
:
localId
,
// 需要上传的图片的本地ID,由chooseImage接口获得
let
options
=
new
FileUploadOptions
()
// eslint-disable-line
isShowProgressTips
:
isShowProgressTips
,
// 默认为1,显示进度提示
options
.
fileKey
=
'file'
success
:
function
(
res
)
{
options
.
headers
=
{
resolve
(
res
.
serverId
)
'Authorization'
:
'Bearer '
+
window
.
localStorage
.
access_token
,
}
options
.
params
=
{
'source_type'
:
file
.
table_name
,
'pkvalue'
:
file
.
table_pk_value
,
'user_id'
:
window
.
localStorage
.
user_id
,
'access_token'
:
window
.
localStorage
.
access_token
,
'filePath'
:
path
,
'timestamp'
:
file
.
timestamp
,
'sequence'
:
file
.
sequence
,
}
options
.
fileName
=
name
options
.
mimeType
=
'multipart/form-date'
let
ft
=
new
FileTransfer
()
// eslint-disable-line
function
uploadSuccess
(
result
)
{
success
(
JSON
.
parse
(
result
.
response
))
}
function
fileError
()
{
window
.
hlsPopup
.
hideLoading
()
console
.
log
(
'upload error source '
+
error
.
source
)
console
.
log
(
'upload error target '
+
error
.
target
)
}
ft
.
upload
(
path
,
url
,
uploadSuccess
,
fileError
,
options
)
},
},
/**
})
* 汉王识别
})
* @param file
* @param url
* @param success
*/
hangwan
:
function
(
fileUrl
,
postUrl
,
success
)
{
if
(
!
fileUrl
)
{
return
}
let
path
=
fileUrl
let
name
=
fileUrl
.
substr
(
fileUrl
.
lastIndexOf
(
'/'
)
+
1
)
let
url
=
encodeURI
(
postUrl
)
let
options
=
new
FileUploadOptions
()
// eslint-disable-line
options
.
headers
=
{
'Authorization'
:
'Bearer '
+
window
.
localStorage
.
access_token
,
}
options
.
fileKey
=
'file'
options
.
fileName
=
name
options
.
mimeType
=
'multipart/form-date'
let
ft
=
new
FileTransfer
()
// eslint-disable-line
function
uploadSuccess
(
message
)
{
let
res
=
JSON
.
parse
(
message
.
response
)
success
(
res
)
}
function
error
(
e
)
{
this
.
hlsPopup
.
showLongCenter
(
'汉王识别失败'
)
}
ft
.
upload
(
path
,
url
,
uploadSuccess
,
error
,
options
)
},
},
/**
/**
*
*
...
@@ -729,133 +610,6 @@ export default {
...
@@ -729,133 +610,6 @@ export default {
return
Math
.
round
(
xirr
*
100
)
/
100
return
Math
.
round
(
xirr
*
100
)
/
100
},
},
// 指纹
fingerLogin
:
function
()
{
if
(
vum
.
Platform
.
isIOS
())
{
return
this
.
fingerLoginIos
()
}
else
{
return
this
.
fingerLoginAndroid
()
}
},
// android
fingerLoginAndroid
:
function
()
{
let
isSupportFinger
=
'true'
return
new
Promise
(
function
(
resolve
,
reject
)
{
Fingerprint
.
isAvailable
(
function
(
res
)
{
// eslint-disable-line
if
(
window
.
localStorage
.
isSupportFinger
)
{
window
.
localStorage
.
removeItem
(
'isSupportFinger'
)
}
window
.
localStorage
.
setItem
(
'isSupportFinger'
,
isSupportFinger
)
if
(
window
.
localStorage
.
isOpenFingerLogin
&&
window
.
localStorage
.
username
&&
window
.
localStorage
.
password
)
{
var
successCallback
=
function
(
msg
)
{
resolve
(
msg
)
}
var
errorCallback
=
function
(
err
)
{
reject
(
err
)
}
Fingerprint
.
show
({
// eslint-disable-line
clientId
:
'com.car.rental.easy'
,
clientSecret
:
'a_very_secret_encryption_key'
,
// Only necessary for Android
},
successCallback
,
errorCallback
)
}
else
{
reject
()
// eslint-disable-line
}
},
function
(
error
)
{
isSupportFinger
=
false
window
.
localStorage
.
isSupportFinger
=
isSupportFinger
reject
(
error
)
})
})
},
// ios
fingerLoginIos
:
function
()
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
let
isSupportFinger
=
true
window
.
plugins
.
touchid
.
isAvailable
(
// 支持指纹
function
()
{
isSupportFinger
=
true
if
(
window
.
localStorage
.
isSupportFinger
)
{
window
.
localStorage
.
removeItem
(
'isSupportFinger'
)
}
window
.
localStorage
.
setItem
(
'isSupportFinger'
,
isSupportFinger
)
// window.localStorage.isSupportFinger = true;
// 判断是否开启了指纹登录
if
(
window
.
localStorage
.
isOpenFingerLogin
&&
window
.
localStorage
.
username
&&
window
.
localStorage
.
password
)
{
window
.
plugins
.
touchid
.
verifyFingerprint
(
'通过Home键验证已有的手机指纹!'
,
// this will be shown in the native scanner popup
function
(
msg
)
{
resolve
(
msg
)
},
function
(
msg
)
{
reject
(
msg
)
})
}
else
{
reject
()
// eslint-disable-line
}
}
// 不支持指纹
,
function
(
msg
)
{
isSupportFinger
=
false
window
.
localStorage
.
isSupportFinger
=
isSupportFinger
reject
(
msg
)
}
)
})
},
// 判断是否为首次登录
isFirstTimeLogin
:
function
(
name
)
{
if
(
window
.
localStorage
.
username
)
{
if
(
window
.
localStorage
.
username
!==
name
)
{
return
true
}
else
{
return
false
}
}
else
{
return
true
}
},
// 打开指纹登陆
openFingerLogin
:
function
()
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
if
(
vum
.
Platform
.
isIOS
())
{
window
.
plugins
.
touchid
.
isAvailable
(
function
()
{
window
.
plugins
.
touchid
.
verifyFingerprint
(
'通过Home键验证已有的手机指纹!'
,
function
()
{
resolve
()
},
function
()
{
reject
()
// eslint-disable-line
}
)
},
function
()
{
this
.
hlsPopup
.
showLongCenter
(
'您的设配暂不支持指纹'
)
reject
()
// eslint-disable-line
})
}
else
{
Fingerprint
.
isAvailable
(
function
(
res
)
{
// eslint-disable-line
Fingerprint
.
show
({
// eslint-disable-line
clientId
:
'com.car.rental.easy'
,
clientSecret
:
'a_very_secret_encryption_key'
,
// Only necessary for Android
},
successCallback
,
errorCallback
)
function
successCallback
(
msg
)
{
resolve
(
msg
)
}
function
errorCallback
(
err
)
{
reject
(
err
)
}
},
function
(
error
)
{
this
.
hlsPopup
.
showLongCenter
(
'您的设配暂不支持指纹'
)
reject
(
error
)
})
}
})
},
/**
/**
* 判断平台
* 判断平台
* @return {String} 平台
* @return {String} 平台
...
...
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