Commit b122638b authored by leiqingsong's avatar leiqingsong

添加公共路径

parent db7069e2
//notation: js file can only use this kind of comments
//since comments will cause error when use in webview.loadurl,
//comments will be remove by java use regexp
(function() {
if (window.WebViewJavascriptBridge) {
return;
}
var receiveMessageQueue = [];
var messageHandlers = {};
var responseCallbacks = {};
var uniqueId = 1;
//set default messageHandler 初始化默认的消息线程
function init(messageHandler) {
if (WebViewJavascriptBridge._messageHandler) {
throw new Error('WebViewJavascriptBridge.init called twice');
}
WebViewJavascriptBridge._messageHandler = messageHandler;
var receivedMessages = receiveMessageQueue;
receiveMessageQueue = null;
for (var i = 0; i < receivedMessages.length; i++) {
_dispatchMessageFromNative(receivedMessages[i]);
}
}
// 发送
function send(data, responseCallback) {
_doSend('send', data, responseCallback);
}
// 注册线程 往数组里面添加值
function registerHandler(handlerName, handler) {
messageHandlers[handlerName] = handler;
}
// 调用线程
function callHandler(handlerName, data, responseCallback) {
_doSend(handlerName, data, responseCallback);
}
//sendMessage add message, 触发native处理 sendMessage
function _doSend(handlerName, message, responseCallback) {
var callbackId;
if(typeof responseCallback === 'string'){
callbackId = responseCallback;
} else if (responseCallback) {
callbackId = 'cb_' + (uniqueId++) + '_' + new Date().getTime();
responseCallbacks[callbackId] = responseCallback;
}else{
callbackId = '';
}
try {
var fn = eval('window.android.' + handlerName);
} catch(e) {
console.log(e);
}
if (typeof fn === 'function'){
var responseData = fn.call(this, JSON.stringify(message), callbackId);
if(responseData){
console.log('response message: '+ responseData);
responseCallback = responseCallbacks[callbackId];
if (!responseCallback) {
return;
}
responseCallback(responseData);
delete responseCallbacks[callbackId];
}
}
}
//提供给native使用,
function _dispatchMessageFromNative(messageJSON) {
setTimeout(function() {
var message = JSON.parse(messageJSON);
var responseCallback;
//java call finished, now need to call js callback function
if (message.responseId) {
responseCallback = responseCallbacks[message.responseId];
if (!responseCallback) {
return;
}
responseCallback(message.responseData);
delete responseCallbacks[message.responseId];
} else {
//直接发送
if (message.callbackId) {
var callbackResponseId = message.callbackId;
responseCallback = function(responseData) {
_doSend('response', responseData, callbackResponseId);
};
}
var handler = WebViewJavascriptBridge._messageHandler;
if (message.handlerName) {
handler = messageHandlers[message.handlerName];
}
//查找指定handler
try {
handler(message.data, responseCallback);
} catch (exception) {
if (typeof console != 'undefined') {
console.log("WebViewJavascriptBridge: WARNING: javascript handler threw.", message, exception);
}
}
}
});
}
//提供给native调用,receiveMessageQueue 在会在页面加载完后赋值为null,所以
function _handleMessageFromNative(messageJSON) {
console.log('handle message: '+ messageJSON);
if (receiveMessageQueue) {
receiveMessageQueue.push(messageJSON);
}
_dispatchMessageFromNative(messageJSON);
}
var WebViewJavascriptBridge = window.WebViewJavascriptBridge = {
init: init,
send: send,
registerHandler: registerHandler,
callHandler: callHandler,
_handleMessageFromNative: _handleMessageFromNative
};
var doc = document;
var readyEvent = doc.createEvent('Events');
readyEvent.initEvent('WebViewJavascriptBridgeReady');
readyEvent.bridge = WebViewJavascriptBridge;
doc.dispatchEvent(readyEvent);
})();
...@@ -2,14 +2,14 @@ import request from "@/utils/request"; ...@@ -2,14 +2,14 @@ import request from "@/utils/request";
/** /**
* 获取用户钱包 * 获取用户钱包
* @param {*} params userId * @param {*} params userId
*/ */
export function getMoneyPackage(params) { export function getMoneyPackage(params) {
return request({ return request({
url: "/wallet/getMoneyPackage", url: "/wallet/getMoneyPackage",
method: "get", method: "get",
params params
}) });
} }
/** /**
...@@ -17,11 +17,11 @@ export function getMoneyPackage(params) { ...@@ -17,11 +17,11 @@ export function getMoneyPackage(params) {
* @param {*} params userId * @param {*} params userId
*/ */
export function getWithdrawalAmount(params) { export function getWithdrawalAmount(params) {
return request({ return request({
url: "getWithdrawalAmount", url: "getWithdrawalAmount",
method: "get", method: "get",
params params
}) });
} }
/** /**
...@@ -30,11 +30,11 @@ export function getWithdrawalAmount(params) { ...@@ -30,11 +30,11 @@ export function getWithdrawalAmount(params) {
* @param {*}yearMonth yyyy-MM-dd * @param {*}yearMonth yyyy-MM-dd
*/ */
export function getWithdrawalRecord(params) { export function getWithdrawalRecord(params) {
return request({ return request({
url: "/wallet/getWithdrawalRecord", url: "/wallet/getWithdrawalRecord",
method: "get", method: "get",
params params
}) });
} }
/** /**
...@@ -42,11 +42,11 @@ export function getWithdrawalRecord(params) { ...@@ -42,11 +42,11 @@ export function getWithdrawalRecord(params) {
* @param {*} params userId * @param {*} params userId
*/ */
export function queryIncomeDetail(params) { export function queryIncomeDetail(params) {
return request({ return request({
url: "/wallet/queryIncomeDetail", url: "/wallet/queryIncomeDetail",
method: "get", method: "get",
params params
}) });
} }
/** /**
...@@ -55,9 +55,9 @@ export function queryIncomeDetail(params) { ...@@ -55,9 +55,9 @@ export function queryIncomeDetail(params) {
*/ */
export function showIncomeRecord(params) { export function showIncomeRecord(params) {
return request({ return request({
url: "/wallet/showIncomeRecord", url: "/wallet/showIncomeRecord",
method: "get", method: "get",
params params
}) });
} }
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终端
// 注册jsbridge // 注册jsbridge
function connectWebViewJavascriptBridge(callback) { function connectWebViewJavascriptBridge(callback) {
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);
} }
} }
// 调用注册方法 // 调用注册方法
connectWebViewJavascriptBridge(function (bridge) { connectWebViewJavascriptBridge(function(bridge) {
if (isAndroid) { if (isAndroid) {
bridge.init(function (message, responseCallback) { bridge.init(function(message, responseCallback) {
responseCallback(data); responseCallback(data);
}); });
} }
});
});
\ No newline at end of file
...@@ -4,14 +4,13 @@ import { Toast } from "vant"; ...@@ -4,14 +4,13 @@ import { Toast } from "vant";
let loading = null; let loading = null;
const service = axios.create({ const service = axios.create({
baseURL: "http://192.168.204.152:8997", baseURL: "http://8.131.244.76:8997",
timeout: 5000 timeout: 5000
}); });
service.interceptors.request.use( service.interceptors.request.use(
config => { config => {
config.headers["Authorization"] = config.headers["Authorization"] = "b6cd4e221fdc4e46a6825c236c912fa6";
"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ7XCJpZFwiOjEsXCJpbnZpdGVDb2RlXCI6XCIxXCIsXCJwYXNzd29yZFwiOlwiMTIzXCIsXCJ1c2VySWRcIjpcIjFcIixcInVzZXJMZXZlbFwiOjR9IiwiaWF0IjoxNjE0MzI3OTY0fQ.f9RPBOMo0BMMbWPnQIhvfLe535as60dk_SZoXMYOT3bHYjoYST-mivTcKC-u4grEpYZMax9RgyuHXCYydZPzQw";
if (!config.loading) { if (!config.loading) {
loading = Toast.loading({ loading = Toast.loading({
forbidClick: true, forbidClick: true,
......
...@@ -10,17 +10,16 @@ ...@@ -10,17 +10,16 @@
<span class="nav-title">专属客服</span> <span class="nav-title">专属客服</span>
</div> </div>
<div class="panel-box"> <div class="panel-box">
<div class="panel-content"> <div class="panel-content">
<div class="title">客服二维码</div> <div class="title">客服二维码</div>
<img src="@/assets/images/logo.png" class="qrCode" alt=""> <img src="@/assets/images/logo.png" class="qrCode" alt="" />
<div class="save-code"> <div class="save-code">
<p>保存二维码</p> <p>保存二维码</p>
<p>打开微信扫一扫添加客服</p> <p>打开微信扫一扫添加客服</p>
</div>
<van-button>保存</van-button>
</div> </div>
<van-button>保存</van-button>
</div>
</div> </div>
</div> </div>
</template> </template>
...@@ -28,9 +27,7 @@ ...@@ -28,9 +27,7 @@
export default { export default {
name: "customerService", name: "customerService",
data() { data() {
return { return {};
};
}, },
methods: { methods: {
handleUrl(urlName) { handleUrl(urlName) {
...@@ -70,55 +67,52 @@ $white: #ffffff; ...@@ -70,55 +67,52 @@ $white: #ffffff;
font-size: 16px; font-size: 16px;
} }
} }
.panel-box{ .panel-box {
height: calc(100vh - 86px); height: calc(100vh - 86px);
padding: 0 15px; padding: 0 15px;
margin-top: 15px; margin-top: 15px;
.panel-content{ .panel-content {
width: 100%; width: 100%;
height: 100%; height: 100%;
background-color: #ffffff; background-color: #ffffff;
box-shadow: 0px 2px 12px 0px box-shadow: 0px 2px 12px 0px rgba(6, 0, 1, 0.04);
rgba(6, 0, 1, 0.04); border-radius: 4px;
border-radius: 4px; padding-top: 45px;
padding-top: 45px; box-sizing: border-box;
box-sizing: border-box; .title {
.title{ font-size: 18px;
font-size: 18px; font-weight: normal;
font-weight: normal; font-stretch: normal;
font-stretch: normal; line-height: 26px;
line-height: 26px; letter-spacing: 0px;
letter-spacing: 0px; color: #333333;
color: #333333; text-align: center;
text-align: center; }
} .qrCode {
.qrCode{ width: 128px;
width: 128px; height: 130px;
height: 130px; margin: 80px auto 30px;
margin: 80px auto 30px; display: block;
display: block; }
} .save-code {
.save-code{ font-size: 14px;
font-size: 14px; font-weight: normal;
font-weight: normal; font-stretch: normal;
font-stretch: normal; line-height: 16px;
line-height: 16px; letter-spacing: 0px;
letter-spacing: 0px; color: #999999;
color: #999999; }
} .van-button {
.van-button{ width: 160px;
width: 160px; height: 36px;
height: 36px; background-color: #88c678;
background-color: #88c678; border-radius: 4px;
border-radius: 4px; font-size: 18px;
font-size: 18px; color: #ffffff;
color: #ffffff; margin: 85px auto 0;
margin: 85px auto 0 ; display: block;
display: block; }
}
} }
} }
} }
</style> </style>
This diff is collapsed.
const name = "西田森App"; const name = "西田森App";
module.exports = { module.exports = {
publicPath: "/font",
css: { css: {
loaderOptions: { loaderOptions: {
postcss: { postcss: {
......
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