H5CallApp

<template>
	<view class="container">
		<button @click="btnClick" type="primary">点击button>

	view>
template>

<script>
	export default {
		methods: {
			configWifi() {
				var params = {
					type: "2",
					command: "wifi",
					idflag: "oneKeySetWifi",
					data: {
						url: '',
						param: {},
						method: ''
					}
				}

				if (window.androidJSBridge) {
					window.androidJSBridge.H5CallApp(JSON.stringify(params))
				} else if (window.webkit) {
					window.webkit.messageHandlers.H5CallApp.postMessage(params)
				}
			},

			addDeviceByQRCode() {
				var params = {
					type: "2",
					command: "qrcode",
					idflag: "byQrcodeAddDevice",
					data: {

					}
				}

				if (window.androidJSBridge) {
					window.androidJSBridge.H5CallApp(JSON.stringify(params))
				} else if (window.webkit) {
					window.webkit.messageHandlers.H5CallApp.postMessage(params)
				}
			},

			macAddress() {
				var params = {
					type: "0",
					command: "macAddress",
					idflag: "getMac",
					data: {}
				}

				if (window.androidJSBridge) {
					window.androidJSBridge.H5CallApp(JSON.stringify(params))
				} else if (window.webkit) {
					window.webkit.messageHandlers.H5CallApp.postMessage(params)
				}
			},

			mqtt() {
				var params = {
					type: "4",
					command: "mqttInfo2App",
					idflag: "",
					data: {
						deviceDetail: "deviceDetail"
					}
				}



				if (window.androidJSBridge) {
					window.androidJSBridge.H5CallApp(JSON.stringify(params))
				} else if (window.webkit) {
					window.webkit.messageHandlers.H5CallApp.postMessage(params)
				}
			},


			btnClick() {
				console.log("======");
				this.mqtt();


			}

		},
		onLoad() {

			window.appCallH5 = function(e) {
				var t = JSON.parse(e);
				alert(JSON.stringify(t));

			}
		}
	}
script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
style>

你可能感兴趣的:(Vue)