Commit 7ff270b0 authored by Nature's avatar Nature

Merge branch 'wechat'

parents a2c89978 66a6ae19
......@@ -34,14 +34,6 @@ export default {
if (vm.isLoading) {
Vue.$vux.loading.hide()
vm.isLoading = false
// 弹出操作失败
/* Vue.$vux.toast.show({
text: '操作失败',
type: 'warn',
time: vm.SHOW_TIMES,
isShowMask: vm.IS_SHOW_MASK,
position: 'middle',
}) */
}
}, 40000)
},
......@@ -60,7 +52,6 @@ export default {
showLongTop: function (content) {
let vm = this
let text = content || '操作失败'
if (!process.env.isMobilePlatform) {
Vue.$vux.toast.show({
text: text,
type: 'text',
......@@ -68,11 +59,6 @@ export default {
isShowMask: vm.IS_SHOW_MASK,
position: 'top',
})
} else {
window.plugins.toast.showLongTop(content, function (success) {
}, function (error) { // eslint-disable-line
})
}
},
/**
......@@ -82,7 +68,6 @@ export default {
showLongCenter: function (content) {
let vm = this
let text = content || '操作失败'
if (!process.env.isMobilePlatform) {
Vue.$vux.toast.show({
text: text,
type: 'text',
......@@ -90,11 +75,6 @@ export default {
isShowMask: vm.IS_SHOW_MASK,
position: 'middle',
})
} else {
window.plugins.toast.showLongCenter(content, function (success) {
}, function (error) { // eslint-disable-line
})
}
},
/**
* 长时间中部提示toast
......@@ -103,7 +83,7 @@ export default {
showLongBottom: function (content) {
let vm = this
let text = content || '操作失败'
if (!process.env.isMobilePlatform) {
Vue.$vux.toast.show({
text: text,
time: vm.SHOW_TIMES,
......@@ -111,11 +91,6 @@ export default {
isShowMask: vm.IS_SHOW_MASK,
position: 'bottom',
})
} else {
window.plugins.toast.showLongBottom(content, function (success) {
}, function (error) { // eslint-disable-line
})
}
},
/**
* 成功提示框
......@@ -152,7 +127,6 @@ export default {
* @param confirmObject.onConfirm 确定函数
*/
showConfirm: function (confirmObject) {
if (!process.env.isMobilePlatform) {
let def = {
title: confirmObject.title || '提示',
content: confirmObject.content || '',
......@@ -166,21 +140,6 @@ export default {
},
}
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 {
*
*/
showPopup: function (confirmObject) {
if (!process.env.isMobilePlatform) {
let def = {
title: confirmObject.title || '提示',
content: confirmObject.content || '',
......@@ -201,19 +159,6 @@ export default {
},
}
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 弹出框的标题可空
......@@ -298,6 +243,8 @@ export default {
ShowPicturePlugin.show({
imgUrl: imgObject.imgUrl,
width: imgObject.width,
imgList: imgObject.imgList,
startPosition: imgObject.startPosition,
})
}
},
......
......@@ -257,53 +257,32 @@ export default {
let pattern = /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/
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:高度}
* @param successFunction 成功回调函数
* @param errorFunction 失败函数
* 微信选择图片
* @returns {Promise<any>}
*/
takePicture: function (obj, successFunction, errorFunction) {
if (typeof successFunction === 'function' && typeof errorFunction === 'function') {
window.imagePicker.getPictures(
successFunction, errorFunction, {
maximumImagesCount: obj.maxCount || 10,
quality: obj.quality || 50,
width: obj.width || 1024,
height: obj.height || 768,
}
)
} else {
window.hlsPopup.showLongBottom('参数有误!')
}
takePicture: function () {
return new Promise(function (resolve, reject) {
wx.chooseImage({
count: 9, // 微信最多能选择9张图片
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success: function (data) {
let localIds = data.localIds // 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片
let pictureList = []
data.localIds.forEach((localId, index) => {
wx.getLocalImgData({
localId: localId, // 图片的localID
success: function (res) {
pictureList.push(res.localData)
},
})
})
resolve({localIds: localIds, pictureList: pictureList})
},
})
})
},
/**
......@@ -320,121 +299,23 @@ export default {
callEmail: function (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进行上传
* @param filePath
* @param success
* 上传图片到微信服务器返回 serverId
* @param localId
* @param isShowProgressTips
* @returns {Promise<any>}
*/
fileUploadSvc: function (file, success) {
let path = file.filePath
let name = path.substr(path.lastIndexOf('/') + 1)
let url = encodeURI(process.env.rootPath + '/app/fileUploadSvc?sysName=HLS_APP&apiName=attachment_upload')
let options = new FileUploadOptions() // eslint-disable-line
options.fileKey = 'file'
options.headers = {
'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)
wxFileUpload: function (localId, isShowProgressTips) {
return new Promise(function (resolve, reject) {
wx.uploadImage({
localId: localId, // 需要上传的图片的本地ID,由chooseImage接口获得
isShowProgressTips: isShowProgressTips, // 默认为1,显示进度提示
success: function (res) {
resolve(res.serverId)
},
/**
* 汉王识别
* @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 {
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} 平台
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment