Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
hrs_app_h5
/
bill
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ef648a3e
authored
May 14, 2020
by
赵艳波
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
tj
parent
933970d7
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
151 additions
and
97 deletions
src/api/http.js
src/assets/js/JsBridge.js
src/assets/js/bridge/birdge.js
src/main.js
src/views/Bill/index.vue
src/api/http.js
View file @
ef648a3e
...
@@ -54,17 +54,18 @@ http.interceptors.response.use(
...
@@ -54,17 +54,18 @@ http.interceptors.response.use(
overlay
:
true
,
overlay
:
true
,
onClose
:
()
=>
{
onClose
:
()
=>
{
console
.
log
(
'WebViewJavascriptBridge'
);
console
.
log
(
'WebViewJavascriptBridge'
);
try
{
this
.
$bridge
.
closeWebView
();
window
.
WebViewJavascriptBridge
.
callHandler
(
// try {
"closeWebView"
,
// window.WebViewJavascriptBridge.callHandler(
null
,
// "closeWebView",
function
(
response
)
{
// null,
console
.
log
(
"closeWebView 来自 ios/android的回传数据:"
,
response
);
// function (response) {
}
// console.log("closeWebView 来自 ios/android的回传数据:", response);
);
// }
}
catch
(
err
)
{
// );
console
.
log
(
"closeWebView is error"
);
// } catch (err) {
}
// console.log("closeWebView is error");
// }
}
}
})
})
//return info;
//return info;
...
...
src/assets/js/JsBridge.js
View file @
ef648a3e
function
initJsBridge
(
readyCallback
)
{
//
function initJsBridge(readyCallback) {
var
u
=
navigator
.
userAgent
;
//
var u = navigator.userAgent;
var
isAndroid
=
u
.
indexOf
(
'Android'
)
>
-
1
||
u
.
indexOf
(
'Adr'
)
>
-
1
;
//android终端
//
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
var
isiOS
=
!!
u
.
match
(
/
\(
i
[^
;
]
+;
(
U;
)?
CPU.+Mac OS X/
);
//ios终端
//
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
// console.log('initJsBridge');
//
// console.log('initJsBridge');
// 注册jsbridge
//
// 注册jsbridge
function
connectWebViewJavascriptBridge
(
callback
)
{
//
function connectWebViewJavascriptBridge(callback) {
// console.log('connectWebViewJavascriptBridge');
//
// console.log('connectWebViewJavascriptBridge');
if
(
isAndroid
)
{
//
if (isAndroid) {
if
(
window
.
WebViewJavascriptBridge
)
{
//
if (window.WebViewJavascriptBridge) {
callback
(
WebViewJavascriptBridge
)
//
callback(WebViewJavascriptBridge)
}
else
{
//
} else {
document
.
addEventListener
(
//
document.addEventListener(
'WebViewJavascriptBridgeReady'
//
'WebViewJavascriptBridgeReady'
,
function
()
{
//
, function () {
callback
(
WebViewJavascriptBridge
)
//
callback(WebViewJavascriptBridge)
},
//
},
false
//
false
);
//
);
}
//
}
return
;
//
return;
}
//
}
if
(
isiOS
)
{
//
if (isiOS) {
if
(
window
.
WebViewJavascriptBridge
)
{
//
if (window.WebViewJavascriptBridge) {
return
callback
(
WebViewJavascriptBridge
);
//
return callback(WebViewJavascriptBridge);
}
//
}
if
(
window
.
WVJBCallbacks
)
{
//
if (window.WVJBCallbacks) {
return
window
.
WVJBCallbacks
.
push
(
callback
);
//
return window.WVJBCallbacks.push(callback);
}
//
}
window
.
WVJBCallbacks
=
[
callback
];
//
window.WVJBCallbacks = [callback];
var
WVJBIframe
=
document
.
createElement
(
'iframe'
);
//
var WVJBIframe = document.createElement('iframe');
WVJBIframe
.
style
.
display
=
'none'
;
//
WVJBIframe.style.display = 'none';
WVJBIframe
.
src
=
'https://__bridge_loaded__'
;
//
WVJBIframe.src = 'https://__bridge_loaded__';
document
.
documentElement
.
appendChild
(
WVJBIframe
);
//
document.documentElement.appendChild(WVJBIframe);
setTimeout
(
function
()
{
//
setTimeout(function () {
document
.
documentElement
.
removeChild
(
WVJBIframe
)
//
document.documentElement.removeChild(WVJBIframe)
},
0
)
//
}, 0)
}
//
}
}
//
}
// 调用注册方法 原生调用JS
//
// 调用注册方法 原生调用JS
connectWebViewJavascriptBridge
(
function
(
bridge
)
{
//
connectWebViewJavascriptBridge(function (bridge) {
if
(
isAndroid
)
{
//
if (isAndroid) {
bridge
.
init
(
'getbarheight'
,
function
(
data
,
responseCallback
)
{
//
bridge.init('getbarheight', function (data, responseCallback) {
responseCallback
(
'received from native data:'
,
data
);
//
responseCallback('received from native data:', data);
});
//
});
}
//
}
readyCallback
();
//
readyCallback();
});
//
});
}
//
}
export
default
initJsBridge
;
// export default initJsBridge;
\ No newline at end of file
\ No newline at end of file
src/assets/js/bridge/birdge.js
View file @
ef648a3e
...
@@ -8,16 +8,15 @@ class Bridge {
...
@@ -8,16 +8,15 @@ class Bridge {
/**
/**
* 设置齐刘海头部颜色
* 设置齐刘海头部颜色
*
*
* @param {"barColor": "#0978e7"} data 请求数据
* @param {Object=} args 请求数据
* @param {String} args.barColor 栏颜色 #0978e7
*/
*/
setBarColor
(
data
=
{})
{
setBarColor
(
args
=
{})
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
try
{
try
{
jsBridge
.
callHandler
(
'setBarColor'
,
data
,
function
(
response
)
{
jsBridge
.
callHandler
(
'setBarColor'
,
args
,
function
(
response
)
{
console
.
log
(
'44444=>'
,
response
);
resolve
(
response
)
resolve
(
response
)
});
});
resolve
(
null
);
}
catch
(
err
)
{
}
catch
(
err
)
{
reject
(
err
)
reject
(
err
)
}
}
...
@@ -27,14 +26,53 @@ class Bridge {
...
@@ -27,14 +26,53 @@ class Bridge {
/**
/**
* 获取头部栏高度
* 获取头部栏高度
*
*
* @param {Object
} data
* @param {Object
=} args 请求参数
*/
*/
getBarHeight
(
data
=
{})
{
getBarHeight
(
args
=
{})
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
try
{
try
{
jsBridge
.
callHandler
(
"getBarHeight"
,
data
,
function
(
response
)
{
jsBridge
.
callHandler
(
"getBarHeight"
,
args
,
function
(
response
)
{
console
.
log
(
"高度=>"
,
response
);
resolve
(
response
);
});
}
catch
(
err
)
{
reject
(
err
);
}
})
}
/**
* 设置页面导肮栏状态
*
* @param {Object} args 请求参数
* @param {Boolean} args.isShowClose 是否显示关闭
* @param {Boolean} args.isShowBack 是否显示返回
* @param {Boolean} args.isCloseLeft 是否关闭左侧
* @param {Boolean} args.isShowTitle 是否显示标题
* @param {Boolean} args.isShowNav 是否显示导航栏
* @param {Boolean} args.isCloseWebView 是否关闭WebView
*/
setPageNavState
(
args
=
{})
{
return
new
Promise
((
resolve
,
reject
)
=>
{
try
{
jsBridge
.
callHandler
(
"setPageNavState"
,
args
,
function
(
response
)
{
resolve
(
response
);
});
}
catch
(
err
)
{
reject
(
err
);
}
})
}
/**
* 关闭WebView
*
* @param {Object=} args 请求对象
*/
closeWebView
(
args
=
{})
{
return
new
Promise
((
resolve
,
reject
)
=>
{
try
{
jsBridge
.
callHandler
(
"closeWebView"
,
args
,
function
(
response
)
{
resolve
(
response
);
resolve
(
response
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
...
src/main.js
View file @
ef648a3e
...
@@ -6,7 +6,7 @@ import 'lib-flexible/flexible'
...
@@ -6,7 +6,7 @@ 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
FastClick
from
'fastclick'
import
initJsBridge
from
"./assets/js/JsBridge"
;
//
import initJsBridge from "./assets/js/JsBridge";
import
bridge
from
"./assets/js/bridge/birdge"
;
import
bridge
from
"./assets/js/bridge/birdge"
;
Vue
.
config
.
productionTip
=
false
Vue
.
config
.
productionTip
=
false
...
@@ -30,7 +30,15 @@ FastClick.prototype.focus = function (targetElement) {
...
@@ -30,7 +30,15 @@ FastClick.prototype.focus = function (targetElement) {
}
}
};
};
Vue
.
prototype
.
setPageNavState
=
function
(
params
=
{
headerColor
:
false
,
isShowClose
:
false
,
isShowBack
:
false
,
isCloseLeft
:
false
,
isShowTitle
:
false
,
isShowNav
:
false
,
isCloseWebView
:
false
})
{
Vue
.
prototype
.
setPageNavState
=
function
()
{
bridge
.
setPageNavState
({
isShowClose
:
false
,
isShowBack
:
false
,
isCloseLeft
:
false
,
isShowTitle
:
false
,
isShowNav
:
false
,
isCloseWebView
:
false
})
// try {
// try {
// initJsBridge((params) => {
// initJsBridge((params) => {
// window.WebViewJavascriptBridge.callHandler(
// window.WebViewJavascriptBridge.callHandler(
...
...
src/views/Bill/index.vue
View file @
ef648a3e
...
@@ -159,7 +159,7 @@ import { Icon, Loading } from "vant";
...
@@ -159,7 +159,7 @@ import { Icon, Loading } from "vant";
import
{
TabHeader
}
from
"@/components"
;
import
{
TabHeader
}
from
"@/components"
;
import
*
as
utils
from
"../../utils/common"
;
import
*
as
utils
from
"../../utils/common"
;
import
{
mapGetters
,
mapActions
}
from
"vuex"
;
import
{
mapGetters
,
mapActions
}
from
"vuex"
;
import
initJsBridge
from
"../../assets/js/JsBridge"
;
//
import initJsBridge from "../../assets/js/JsBridge";
import
dayjs
from
"dayjs"
;
import
dayjs
from
"dayjs"
;
export
default
{
export
default
{
...
@@ -468,33 +468,44 @@ export default {
...
@@ -468,33 +468,44 @@ export default {
}
}
},
},
closeWebView
()
{
closeWebView
()
{
try
{
this
.
$bridge
.
closeWebView
();
window
.
WebViewJavascriptBridge
.
callHandler
(
// try {
"closeWebView"
,
// window.WebViewJavascriptBridge.callHandler(
null
,
// "closeWebView",
function
(
response
)
{
// null,
console
.
log
(
"closeWebView 来自 ios/android的回传数据:"
,
response
);
// function(response) {
}
// console.log("closeWebView 来自 ios/android的回传数据:", response);
);
// }
}
catch
(
err
)
{
// );
console
.
log
(
"closeWebView is error"
);
// } catch (err) {
}
// console.log("closeWebView is error");
// }
},
},
setPageNavStateShow
()
{
setPageNavStateShow
()
{
window
.
WebViewJavascriptBridge
.
callHandler
(
this
.
$bridge
"setPageNavState"
,
.
setPageNavStateShow
({
{
isShowClose
:
true
,
isShowClose
:
true
,
isShowBack
:
true
,
isShowBack
:
true
,
isCloseLeft
:
true
,
isCloseLeft
:
true
,
isShowTitle
:
true
,
isShowTitle
:
true
,
isShowNav
:
true
,
isShowNav
:
true
,
isCloseWebView
:
true
isCloseWebView
:
true
},
})
function
(
response
)
{
.
then
(
res
=>
{});
console
.
log
(
"setPageNavState来自 ios/android的回传数据: "
,
response
);
// window.WebViewJavascriptBridge.callHandler(
}
// "setPageNavState",
);
// {
// isShowClose: true,
// isShowBack: true,
// isCloseLeft: true,
// isShowTitle: true,
// isShowNav: true,
// isCloseWebView: true
// },
// function(response) {
// console.log("setPageNavState来自 ios/android的回传数据: ", response);
// }
// );
},
},
navLeftArrowClick
()
{
navLeftArrowClick
()
{
this
.
closeWebView
();
this
.
closeWebView
();
...
@@ -513,10 +524,6 @@ export default {
...
@@ -513,10 +524,6 @@ export default {
this
.
setBarHeightLowBee
();
this
.
setBarHeightLowBee
();
this
.
globalNavLeftArrowClick
(
this
.
navLeftArrowClick
);
this
.
globalNavLeftArrowClick
(
this
.
navLeftArrowClick
);
await
this
.
loadPeriodData
();
await
this
.
loadPeriodData
();
this
.
$bridge
.
getBarHeight
().
then
(
res
=>
{
console
.
log
(
"结果=>"
,
res
);
});
},
},
async
created
()
{
async
created
()
{
this
.
payUrl
=
await
this
.
loadPayUrl
();
this
.
payUrl
=
await
this
.
loadPayUrl
();
...
...
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