|
@@ -1,17 +1,5 @@
|
|
|
-let carmera = uni.requireNativePlugin('uniplugin_camerascan')
|
|
|
+let carmera = uni.requireNativePlugin('ziteng-maskcamera')
|
|
|
let cameraModule = uni.requireNativePlugin("SMUniPlugin-CameraModule")
|
|
|
-
|
|
|
-export function objToUrl(obj) {
|
|
|
- let uri = '';
|
|
|
- let keys = Object.keys(obj);
|
|
|
- keys.forEach(item => {
|
|
|
- uri += '&' + item + '=' + obj[item];
|
|
|
- });
|
|
|
-
|
|
|
- uri = uri.substr(1);
|
|
|
-
|
|
|
- return uri;
|
|
|
-}
|
|
|
// 节流函数
|
|
|
export function throttle(fn, gaptime) {
|
|
|
if (gaptime == null || gaptime == undefined) {
|
|
@@ -58,21 +46,25 @@ export const imgToBase64 = function (path,callback){
|
|
|
export const openCamera = function (type,callback){
|
|
|
let carNumberOptions = {
|
|
|
widthRatio: 0.8,
|
|
|
- heightRatio: 0.3,
|
|
|
+ heightRatio: 0.2,
|
|
|
showText: '请将车牌号码对准框中'
|
|
|
}
|
|
|
let carVinNumberOptions = {
|
|
|
- widthRatio: 1,
|
|
|
- heightRatio: 0.15,
|
|
|
+ widthRatio: 0.9,
|
|
|
+ heightRatio: 0.1,
|
|
|
showText: '请将车辆VIN码对准框中'
|
|
|
}
|
|
|
let option = (type == 'searchCar' || type == 'carNumber') ? carNumberOptions : carVinNumberOptions
|
|
|
// 竖屏 false,横屏 true
|
|
|
- let isLandscape = (type == 'searchCar' || type == 'carNumber') ? false : true
|
|
|
+ let isLandscape = false
|
|
|
//安卓摄像头
|
|
|
if(uni.getSystemInfoSync().platform === 'android'){
|
|
|
+ option.isLandscape = isLandscape
|
|
|
carmera.show(option,function(result){
|
|
|
- callback(result)
|
|
|
+ console.log(result)
|
|
|
+ if(result.msg != 'backCancel'){
|
|
|
+ callback(result.data)
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
// ios 摄像头
|
|
@@ -88,7 +80,7 @@ export const openCamera = function (type,callback){
|
|
|
y = (screenHeight - h)/2
|
|
|
}else{
|
|
|
// 竖屏
|
|
|
- w = screenWidth*option.widthRatio*0.9
|
|
|
+ w = screenWidth*option.widthRatio
|
|
|
h = screenHeight*option.heightRatio
|
|
|
x = (screenWidth - w)/2
|
|
|
y = (screenHeight - h)/2 - 50
|
|
@@ -101,7 +93,7 @@ export const openCamera = function (type,callback){
|
|
|
'isLandscape': isLandscape
|
|
|
},
|
|
|
(result) => {
|
|
|
- callback({path:'file://'+result})
|
|
|
+ callback('file://'+result)
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -234,13 +226,16 @@ export const setStorageForAppVersion = function(currTimeStamp){
|
|
|
* @param {Object} server_version 服务器最新 应用版本号
|
|
|
* @param {Object} curr_version 当前应用版本号
|
|
|
* isQzgx 是否强制更新
|
|
|
- * market 打开应用市场
|
|
|
+ * callback 登录
|
|
|
*/
|
|
|
-export const checkVersionToLoadUpdate = function(newVersion,type,market){
|
|
|
- console.log(newVersion)
|
|
|
- const curVer = getApp().globalData.version
|
|
|
- const server_version = newVersion.version
|
|
|
- const curr_version = curVer.versionCode
|
|
|
+export const checkVersionToLoadUpdate = function(newVersion,type,callback){
|
|
|
+ if(newVersion.version == '2001'||newVersion.version == '2002'){
|
|
|
+ newVersion.version = 201
|
|
|
+ }
|
|
|
+ const curVer = getApp().globalData.version // 当前版本信息
|
|
|
+ console.log(newVersion,curVer,callback)
|
|
|
+ const curr_version = curVer.version.replace(/\./g,'')
|
|
|
+ const server_version = newVersion.version // 最新版本信息
|
|
|
const isQzgx = newVersion.forceUpgrade != 1
|
|
|
let isWifi = plus.networkinfo.getCurrentType()!=3 ? '有新的版本发布,检测到您目前非Wifi连接,' : '有新的版本发布,'
|
|
|
let msg = isWifi + (!isQzgx ? '请立即更新?' : '是否立即更新版本?')
|
|
@@ -274,57 +269,35 @@ export const checkVersionToLoadUpdate = function(newVersion,type,market){
|
|
|
// 打开ios 应用市场
|
|
|
let openIosAppSotre = function(downloadUrl){
|
|
|
//在App Store Connect中的App Store下的app信息,可找到appleId
|
|
|
- // let appleId= 111111111
|
|
|
plus.runtime.launchApplication({
|
|
|
- // action: `itms-apps://itunes.apple.com/cn/app/id${appleId}?mt=8`
|
|
|
action: downloadUrl
|
|
|
}, function(e) {
|
|
|
console.log('Open system default browser failed: ' + e.message);
|
|
|
})
|
|
|
}
|
|
|
- // 打开应用市场
|
|
|
- // const marketOpen = function(){
|
|
|
- // market.open({
|
|
|
- // ios:'',
|
|
|
- // android:'com.zyucgj.car'
|
|
|
- // });
|
|
|
- // }
|
|
|
+ console.log(server_version,curr_version)
|
|
|
if(Number(server_version) > Number(curr_version)){
|
|
|
- // #ifndef APP-PLUS
|
|
|
- uni.showModal({
|
|
|
- title: msg,
|
|
|
- content: '更新内容:'+newVersion.upgradeContent,
|
|
|
- showCancel: isQzgx,
|
|
|
- confirmText:'立即更新',
|
|
|
- cancelText:'稍后进行',
|
|
|
- success: function (res) {
|
|
|
- if (res.confirm) {
|
|
|
- if(curVer.platform == 'android'){
|
|
|
- //设置 最新版本apk的下载链接
|
|
|
- downloadApp(newVersion.attachment);
|
|
|
- }else{
|
|
|
- openIosAppSotre(newVersion.downloadUrl)
|
|
|
- }
|
|
|
- // marketOpen()
|
|
|
- } else if (res.cancel) {
|
|
|
- console.log('稍后更新');
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- // #endif
|
|
|
- // #ifdef APP-PLUS
|
|
|
- plus.nativeUI.confirm('更新内容:'+newVersion.upgradeContent, function(e){
|
|
|
- if(e.index == 0){ // 确认
|
|
|
+ uni.showModal({
|
|
|
+ title: msg,
|
|
|
+ content: '更新内容:'+newVersion.upgradeContent,
|
|
|
+ showCancel: isQzgx,
|
|
|
+ confirmText:'立即更新',
|
|
|
+ cancelText:'稍后进行',
|
|
|
+ success: function (res) {
|
|
|
+ if (res.confirm) {
|
|
|
if(curVer.platform == 'android'){
|
|
|
- //设置最新版本apk的下载链接
|
|
|
+ //设置 最新版本apk的下载链接
|
|
|
downloadApp(newVersion.attachment);
|
|
|
}else{
|
|
|
openIosAppSotre(newVersion.downloadUrl)
|
|
|
}
|
|
|
- // marketOpen()
|
|
|
+ } else if (res.cancel) {
|
|
|
+ console.log('稍后更新');
|
|
|
+ callback()
|
|
|
}
|
|
|
- },{"title":msg,"buttons": !isQzgx ? ["立即更新"] : ["立即更新","稍后进行"]})
|
|
|
- // #endif
|
|
|
+ }
|
|
|
+ });
|
|
|
+ uni.hideLoading();
|
|
|
}else{
|
|
|
if(type){
|
|
|
uni.showToast({
|
|
@@ -332,6 +305,8 @@ export const checkVersionToLoadUpdate = function(newVersion,type,market){
|
|
|
title: '已是最新版本',
|
|
|
duration: 1500
|
|
|
});
|
|
|
+ }else{
|
|
|
+ callback()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -376,9 +351,30 @@ export const numberToFixed = function (val, num, max) {
|
|
|
else if (num == 5)_value = _value.replace(/^(\-)*(\d+)\.(\d\d\d\d\d).*$/, '$1$2.$3')
|
|
|
else if (num == 0)_value = _value.indexOf('.') >= 0 ? _value.split('.')[0] : _value
|
|
|
else _value = _value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3')
|
|
|
- return _value > maxNums ? maxNums : _value
|
|
|
+ // console.log(_value,maxNums,Number(_value)>Number(maxNums),'_value')
|
|
|
+ return Number(_value)>Number(maxNums) ? maxNums : _value
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+// 保存图片到阿里云
|
|
|
+export const saveImgToAliOss = function(src,callback){
|
|
|
+ console.log(src,getApp().globalData.baseUrl,'getApp().globalData.baseUrl')
|
|
|
+ const authorization = getApp().globalData.token
|
|
|
+ uni.uploadFile({
|
|
|
+ url: getApp().globalData.baseUrl + 'upload/', //自行修改各自的对应的接口
|
|
|
+ filePath: src,
|
|
|
+ name: 'file',
|
|
|
+ header: {'X-AUTH-TOKEN':authorization},
|
|
|
+ success: (uploadFileRes) => {
|
|
|
+ if (uploadFileRes) {
|
|
|
+ let res = JSON.parse(uploadFileRes.data);
|
|
|
+ callback(res)
|
|
|
+ }
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: uploadFileRes ? '保存图片成功' : '保存图片失败'
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail:(error) => {
|
|
|
+ console.log(error)
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|