Commit 4ba9f97d by wjd

Merge branch 'jianxiang' into 'debug'

app更新方法更改

See merge request iot-project-js/doorlock!36
parents 94f6b325 9b947d6b
class Barcode{
constructor() {
}
startQr(id,keyArrays,success,error){
console.log("开始扫描....");
this.scan = iot.navigator.barcode(id);
console.log(this.scan);
this.scan.start();
this.scan.onmarked = (type, result)=>{
if(result) {
let typeJson = this.formatUrlToJson(result);
let type = typeJson["type"];
let bool = this.isInArray(keyArrays,type);
if (bool) {
success(type);
}else{
error("当前扫描的二维码不和规范");
}
}
};
}
isInArray(arr,value){
for(var i = 0; i < arr.length; i++){
if(value === arr[i]){
return true;
}
}
return false;
}
formatUrlToJson(str){
console.log("测试字符串截取功能");
let index = str.indexOf("?");
let subStr = str.substr(index+1,str.length);
let subIndex = subStr.indexOf("=");
let keyStr = subStr.substr(0,subIndex);
console.log(keyStr);
let value = subStr.substr(subIndex+1,subStr.length);
let json = {};
json[keyStr] = value;
// alert(JSON.stringify(json));
return json;
}
}
export default new Barcode();
\ No newline at end of file
import {iot, uPublic, uComponents} from './public.js';
class Request{
constructor(json) {//当前版本号、最新版本号以及获取最新安装包地址
}
versionRequest(url,need,notneed){
this.getDownloadUrl(url,need,notneed);
}
getDownloadUrl(url,need,notneed){
let type = null;
if (iot.navigator.osName() == "iOS") {
type = "ios";
}else{
type = "android";
}
iot.business.api.send(url,
{
data: {
type:type
},
success: (response) => {
console.log(response);
if (response.code == 0) {
this.dealWithVersion(response,need,notneed);
}
},
error: (error) => {
console.log(error);
notneed(error);
},
complete: () => {}
},false);
}
dealWithVersion(response,need,notneed){
let type = null;
if (iot.navigator.osName() == "iOS") {
type = "ios";
}else{
type = "android";
}
let info = null;
if (type == "ios") {
info = response.data["ios"];
}else{
info = response.data["android"];
}
console.log(info);
let newVersion = info.version;// 新版本 无论是安卓还是iOS都用此变量存储
let downloadUrl = info.url;
let backinfo = {
url:downloadUrl,
version:newVersion
};
need(backinfo);
}
}
export default new Request();
\ No newline at end of file
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
*/ */
import CryptoJS from "crypto-js"; import CryptoJS from "crypto-js";
import Request from "../../public/request.js";
import moment from 'moment'; import moment from 'moment';
import crypto from '../../public/crypto.js'; import crypto from '../../public/crypto.js';
import config from '../../public/config.js'; import config from '../../public/config.js';
...@@ -22,7 +23,21 @@ function init() { ...@@ -22,7 +23,21 @@ function init() {
uPublic.closeSlideBack(); uPublic.closeSlideBack();
//通用 图片轮播、跑马灯、开关、按钮、dialog、loading组件 //通用 图片轮播、跑马灯、开关、按钮、dialog、loading组件
uPublic.componentsInit(['u-carousel','u-marquee','u-switch','u-button','u-dialog','u-loading','u-text','u-comm-loading']); uPublic.componentsInit(['u-carousel','u-marquee','u-switch','u-button','u-dialog','u-loading','u-text','u-comm-loading']);
uPublic.componentsExtend(['update-app']); // uPublic.componentsExtend(['update-app']);
Request.versionRequest('device/getVersion',(info)=>{
let json = {
downloadUrl : info.url,
version: info.version,
title :Vue.t('newFeature.tip'),
content :Vue.t('newFeature.newVersion'),
ok :Vue.t('newFeature.update'),
cancel :Vue.t('newFeature.miss')
};
iot.native.checkUpdate(json);
},(err)=>{
console(err);
});
if(iot.navigator.getExtras().needClose){ if(iot.navigator.getExtras().needClose){
iot.navigator.closeAllBesidesItself(); iot.navigator.closeAllBesidesItself();
} }
...@@ -575,9 +590,7 @@ function getTreenRecord(self, record){ ...@@ -575,9 +590,7 @@ function getTreenRecord(self, record){
self.newMsg = []; self.newMsg = [];
for(let i = record.length - 1; i >= 0; i--){ for(let i = record.length - 1; i >= 0; i--){
let msg = ''; let msg = '';
if(record[i].nickname == null){ if((record[i].mode != 30) && (record[i].mode != 5)){
msg = ' ID:' + record[i].openId;
}else{
msg = record[i].nickname; msg = record[i].nickname;
} }
self.newMsg.push(moment(record[i].time).format("YY.MM.DD HH:mm")+ ' ' + msg + Vue.t('device.use') + Vue.t('opendoorRecord.'+config.openDoorMode[record[i].mode]+'')); self.newMsg.push(moment(record[i].time).format("YY.MM.DD HH:mm")+ ' ' + msg + Vue.t('device.use') + Vue.t('opendoorRecord.'+config.openDoorMode[record[i].mode]+''));
...@@ -659,9 +672,7 @@ async function updateHistoryMap(self, historyRecord){ ...@@ -659,9 +672,7 @@ async function updateHistoryMap(self, historyRecord){
if(record && record.length){ if(record && record.length){
for(let i=0; i< record.length; i++){ for(let i=0; i< record.length; i++){
let msg = ''; let msg = '';
if(record[i].nickname == null){ if((record[i].mode != 30) && (record[i].mode != 5)){
msg = ' ID:' + record[i].openId;
}else{
msg = record[i].nickname; msg = record[i].nickname;
} }
self.newMsg.shift(); self.newMsg.shift();
......
...@@ -18,7 +18,7 @@ function init() { ...@@ -18,7 +18,7 @@ function init() {
const app = new Vue({ const app = new Vue({
data:{ data:{
textName: iot.navigator.getExtras().nickname, textName: iot.navigator.getExtras().nickname,
textErrorTip: null, textErrorTip: '',
//配置组件 //配置组件
componentsConfig: initComponentsConfig(), componentsConfig: initComponentsConfig(),
extras: {} extras: {}
......
...@@ -18,7 +18,7 @@ function init() { ...@@ -18,7 +18,7 @@ function init() {
const app = new Vue({ const app = new Vue({
data:{ data:{
textName: null, textName: null,
textErrorTip: null, textErrorTip: '',
//配置组件 //配置组件
componentsConfig: initComponentsConfig(), componentsConfig: initComponentsConfig(),
extras: {} extras: {}
......
...@@ -17,7 +17,7 @@ function init() { ...@@ -17,7 +17,7 @@ function init() {
const app = new Vue({ const app = new Vue({
data:{ data:{
textName: iot.navigator.getExtras().nickname, textName: iot.navigator.getExtras().nickname,
textErrorTip: null, textErrorTip: '',
//配置组件 //配置组件
componentsConfig: initComponentsConfig(), componentsConfig: initComponentsConfig(),
extras: {}, extras: {},
......
...@@ -19,7 +19,7 @@ function init() { ...@@ -19,7 +19,7 @@ function init() {
data:{ data:{
//配置组件 //配置组件
textNickName: iot.navigator.getExtras().nickname, textNickName: iot.navigator.getExtras().nickname,
textErrorTip: null, textErrorTip: '',
componentsConfig: initComponentsConfig() componentsConfig: initComponentsConfig()
}, },
mounted(){ mounted(){
......
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
</u-comm-loading> </u-comm-loading>
</div> </div>
</transition> </transition>
<update-app :show-flag="true"></update-app> <!--<update-app :show-flag="true"></update-app>-->
<u-dialog ref="udialog" :init-param="componentsConfig.dialog.initParam"></u-dialog> <u-dialog ref="udialog" :init-param="componentsConfig.dialog.initParam"></u-dialog>
<u-loading ref="uloading" :init-param="componentsConfig.loading.initParam"></u-loading> <u-loading ref="uloading" :init-param="componentsConfig.loading.initParam"></u-loading>
</div> </div>
......
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