Commit 7f868323 by 展昭

jsBridge+fastclick

parent 6509a6be
...@@ -4767,6 +4767,11 @@ ...@@ -4767,6 +4767,11 @@
"integrity": "sha1-h0v2nG9ATCtdmcSBNBOZ/VWJJjM=", "integrity": "sha1-h0v2nG9ATCtdmcSBNBOZ/VWJJjM=",
"dev": true "dev": true
}, },
"fastclick": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/fastclick/-/fastclick-1.0.6.tgz",
"integrity": "sha1-FhYlsnsaWAZAWTa9qaLBkm0Gvmo="
},
"faye-websocket": { "faye-websocket": {
"version": "0.10.0", "version": "0.10.0",
"resolved": "https://registry.npm.taobao.org/faye-websocket/download/faye-websocket-0.10.0.tgz", "resolved": "https://registry.npm.taobao.org/faye-websocket/download/faye-websocket-0.10.0.tgz",
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"core-js": "^3.6.4", "core-js": "^3.6.4",
"dayjs": "^1.8.24", "dayjs": "^1.8.24",
"fastclick": "^1.0.6",
"lib-flexible": "^0.3.2", "lib-flexible": "^0.3.2",
"mescroll.js": "^1.4.2", "mescroll.js": "^1.4.2",
"moment": "^2.24.0", "moment": "^2.24.0",
......
function initJsBridge(readyCallback) {
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
// 注册jsbridge
function connectWebViewJavascriptBridge(callback) {
if (isAndroid) {
if (window.WebViewJavascriptBridge) {
callback(WebViewJavascriptBridge)
} else {
document.addEventListener(
'WebViewJavascriptBridgeReady'
, function () {
callback(WebViewJavascriptBridge)
},
false
);
}
return;
}
if (isiOS) {
if (window.WebViewJavascriptBridge) {
return callback(WebViewJavascriptBridge);
}
if (window.WVJBCallbacks) {
return window.WVJBCallbacks.push(callback);
}
window.WVJBCallbacks = [callback];
var WVJBIframe = document.createElement('iframe');
WVJBIframe.style.display = 'none';
WVJBIframe.src = 'https://__bridge_loaded__';
document.documentElement.appendChild(WVJBIframe);
setTimeout(function () {
document.documentElement.removeChild(WVJBIframe)
}, 0)
}
}
// 调用注册方法
connectWebViewJavascriptBridge(function (bridge) {
if (isAndroid) {
bridge.init('reloadTXLContact', function (data, responseCallback) {
//store.dispatch('changeTxlMember', data);
// data=JSON.parse(data);
// const date=Date.now();
// router.replace({ name: "addmembermanual", query: { name: data.name, linkway: data.linkway,date } });
responseCallback('received from native data:', data);
});
}
bridge.registerHandler('reloadTXLContact', function (data, responseCallback) {
//store.dispatch('changeTxlMember', data);
// data=JSON.parse(data);
// const date=Date.now();
// router.replace({ name: "addmembermanual", query: { name: data.name, linkway: data.linkway,date } });
responseCallback('received from native data:' + data);
});
readyCallback();
});
}
export default initJsBridge;
\ No newline at end of file
...@@ -5,6 +5,8 @@ import store from './store' ...@@ -5,6 +5,8 @@ import store from './store'
import 'lib-flexible/flexible' import 'lib-flexible/flexible'
import './assets/css/index.css' import './assets/css/index.css'
import './utils/filter' import './utils/filter'
import FastClick from 'fastclick'
import initJsBridge from "./assets/js/JsBridge";
Vue.config.productionTip = false Vue.config.productionTip = false
...@@ -14,6 +16,45 @@ Vue.prototype.globalNavLeftArrowClick = function (callback) { ...@@ -14,6 +16,45 @@ Vue.prototype.globalNavLeftArrowClick = function (callback) {
}; };
}; };
FastClick.attach(document.body);
FastClick.prototype.focus = function (targetElement) {
let length;
if (targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month') {
length = targetElement.value.length;
targetElement.focus();
targetElement.setSelectionRange(length, length);
} else {
targetElement.focus();
}
};
Vue.prototype.setPageNavState = function () {
try {
initJsBridge(() => {
window.WebViewJavascriptBridge.callHandler("ready", null, function (
response
) {
window.WebViewJavascriptBridge.callHandler(
"setPageNavState",
{
isShowClose: false,
isShowBack: false,
isCloseLeft: false,
isShowTitle: false,
isShowNav: false,
isCloseWebView: false
},
function (response) {
console.log("来自 ios/android的回传数据: ", response);
}
);
});
});
} catch (err) {
console.log("setPageNavState is error");
}
};
new Vue({ new Vue({
store, store,
......
...@@ -86,6 +86,7 @@ export default { ...@@ -86,6 +86,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.setPageNavState();
this.globalNavLeftArrowClick(this.navLeftArrowClick); this.globalNavLeftArrowClick(this.navLeftArrowClick);
this.getData(); this.getData();
} }
......
...@@ -398,14 +398,31 @@ export default { ...@@ -398,14 +398,31 @@ export default {
this.currentPerName = element.name; this.currentPerName = element.name;
this.savePerBeginDate(element.beginDate); this.savePerBeginDate(element.beginDate);
break; break;
}else{ } else {
this.currentPerId = this.period[localPerIndex].id; this.currentPerId = this.period[localPerIndex].id;
} }
} }
} }
},
closeWebView() {
try {
window.WebViewJavascriptBridge.callHandler(
"closeWebView",
null,
function(response) {
console.log("closeWebView 来自 ios/android的回传数据:", response);
}
);
} catch (err) {
console.log("closeWebView is error");
}
},
navLeftArrowClick() {
this.closeWebView();
} }
}, },
async mounted() { async mounted() {
this.globalNavLeftArrowClick(this.navLeftArrowClick);
await this.loadPeriodData(); await this.loadPeriodData();
} }
}; };
......
...@@ -97,6 +97,7 @@ export default { ...@@ -97,6 +97,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.setPageNavState();
this.globalNavLeftArrowClick(this.navLeftArrowClick); this.globalNavLeftArrowClick(this.navLeftArrowClick);
this.accountId = this.$route.query.accountId; this.accountId = this.$route.query.accountId;
this.title = dayjs(this.getBeginDate).format("M") + "月" + "资金记录"; this.title = dayjs(this.getBeginDate).format("M") + "月" + "资金记录";
......
...@@ -113,6 +113,7 @@ export default { ...@@ -113,6 +113,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.setPageNavState();
this.globalNavLeftArrowClick(this.navLeftArrowClick); this.globalNavLeftArrowClick(this.navLeftArrowClick);
this.type = this.$route.query.type; this.type = this.$route.query.type;
this.currentPerId = this.$route.query.currentPerId; this.currentPerId = this.$route.query.currentPerId;
......
...@@ -83,6 +83,7 @@ export default { ...@@ -83,6 +83,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.setPageNavState();
this.globalNavLeftArrowClick(this.navLeftArrowClick); this.globalNavLeftArrowClick(this.navLeftArrowClick);
this.getData(); this.getData();
} }
......
...@@ -215,6 +215,7 @@ export default { ...@@ -215,6 +215,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.setPageNavState();
this.globalNavLeftArrowClick(this.navLeftArrowClick); this.globalNavLeftArrowClick(this.navLeftArrowClick);
this.getData(); this.getData();
} }
......
...@@ -41,6 +41,7 @@ export default { ...@@ -41,6 +41,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.setPageNavState();
this.globalNavLeftArrowClick(this.navLeftArrowClick); this.globalNavLeftArrowClick(this.navLeftArrowClick);
const index = parseInt(this.$route.query.index); const index = parseInt(this.$route.query.index);
const name = this.$route.query.name; const name = this.$route.query.name;
......
...@@ -103,6 +103,7 @@ export default { ...@@ -103,6 +103,7 @@ export default {
} }
}, },
async mounted() { async mounted() {
this.setPageNavState();
this.globalNavLeftArrowClick(this.navLeftArrowClick); this.globalNavLeftArrowClick(this.navLeftArrowClick);
await this.getData(); await this.getData();
} }
......
...@@ -53,6 +53,7 @@ export default { ...@@ -53,6 +53,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.setPageNavState();
this.globalNavLeftArrowClick(this.navLeftArrowClick); this.globalNavLeftArrowClick(this.navLeftArrowClick);
} }
}; };
......
...@@ -54,6 +54,7 @@ export default { ...@@ -54,6 +54,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.setPageNavState();
this.globalNavLeftArrowClick(this.navLeftArrowClick); this.globalNavLeftArrowClick(this.navLeftArrowClick);
this.getData(); this.getData();
} }
......
...@@ -107,6 +107,7 @@ export default { ...@@ -107,6 +107,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.setPageNavState();
this.globalNavLeftArrowClick(this.navLeftArrowClick); this.globalNavLeftArrowClick(this.navLeftArrowClick);
this.getData(); this.getData();
} }
......
...@@ -98,6 +98,7 @@ export default { ...@@ -98,6 +98,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.setPageNavState();
this.globalNavLeftArrowClick(this.navLeftArrowClick); this.globalNavLeftArrowClick(this.navLeftArrowClick);
this.getData(); this.getData();
} }
......
...@@ -74,6 +74,7 @@ export default { ...@@ -74,6 +74,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.setPageNavState();
this.globalNavLeftArrowClick(this.navLeftArrowClick); this.globalNavLeftArrowClick(this.navLeftArrowClick);
} }
}; };
......
...@@ -42,6 +42,7 @@ export default { ...@@ -42,6 +42,7 @@ export default {
// this.oidcCheckAccess(this.$route).then(hasAccess => { // this.oidcCheckAccess(this.$route).then(hasAccess => {
// console.log("hasAccess=", hasAccess); // console.log("hasAccess=", hasAccess);
// }); // });
this.setPageNavState();
}, },
methods: { methods: {
...mapActions([ ...mapActions([
......
const path = require("path"); const path = require("path");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
// gzip --start // gzip --start
const CompressionWebpackPlugin = require("compression-webpack-plugin") const CompressionWebpackPlugin = require("compression-webpack-plugin")
const productionGzipExtensions = ["js", "css"]; // 需要gzip压缩的文件后缀 const productionGzipExtensions = ["js", "css"]; // 需要gzip压缩的文件后缀
module.exports = { module.exports = {
title:'业务账单', title: '业务账单',
// 部署应用时的基本 URL // 部署应用时的基本 URL
// baseUrl: process.env.NODE_ENV === "production" ? "192.168.60.110:8080" : "192.168.60.110:8080", // baseUrl: process.env.NODE_ENV === "production" ? "192.168.60.110:8080" : "192.168.60.110:8080",
publicPath: process.env.VUE_APP_PUBLIC_DIR, publicPath: process.env.VUE_APP_PUBLIC_DIR,
...@@ -119,8 +118,8 @@ module.exports = { ...@@ -119,8 +118,8 @@ module.exports = {
"vue$": 'vue/dist/vue.common.js' "vue$": 'vue/dist/vue.common.js'
}, },
modules: [ modules: [
path.resolve(__dirname,'node_modules'), path.resolve(__dirname, 'node_modules'),
path.resolve(__dirname,'src/utils') path.resolve(__dirname, 'src/utils')
] ]
} }
}); });
......
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 sign in to comment