From cf979bd3e7feffa86558a9085c4d317158cc6bf1 Mon Sep 17 00:00:00 2001 From: aBin Date: Tue, 27 Jul 2021 16:41:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A8=E6=8E=A7=E5=9B=BE=E7=89=87=E6=8F=92?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 69 ++++-------------------------------------------------- 1 file changed, 4 insertions(+), 65 deletions(-) diff --git a/index.html b/index.html index bd4ce31..1f16713 100644 --- a/index.html +++ b/index.html @@ -48,9 +48,8 @@
-
- - +
+
@@ -61,68 +60,8 @@ alert(this.name) } } - /* - 1.进页面首先查询绑定状态 - 2.根据返回的数据,判断显示哪个btn - */ - ;(async function() { - var dom = document.querySelector("div[data-root=p101]"); - var domBox = dom.parentNode; - var domChild = document.querySelectorAll('div[data-root=p101]>button'); - const uid = domBox.getAttribute('data-uid'); - const pid = domBox.getAttribute('data-pid'); - const token = await getToken(uid); - const carInfo = await getBindCar(pid,token); - if(carInfo && carInfo.length) { - domChild[0].innerHTML = `平车${carNumber}` - domChild[0].style.display = 'block' - } else { - domChild[1].style.display = 'block' - } - })(); - /* - 根据uid获取token接口 - */ - async function getToken(uid) { - var token = '' - await fetch(`https://www.tall.wiki/gateway/tall/v1.0/users/userId?userId=${uid}`) - .then(function(response) { - return response.json(); - }) - .then(function(myJson) { - token = myJson.data.token - }); - return token - } - /* - 查询绑定好的平车 - 1. 有则显示 平车+编号 按钮 - 2. 无泽显示 绑定平车 按钮 - */ - async function getBindCar(projectId,token) { - const params = { param: { projectId } } - const response = await fetch('https://www.tall.wiki/gateway/wisdomcar/car/queryBindingCar', { - method: 'POST', - headers: { - 'Content-Type': 'application/json;charset=utf-8', - 'Authorization': 'Bearer ' + token, - }, - body: JSON.stringify(params) - }); - const json = await response.json(); - return json.data; - } - /* - 1. p101插件的所有事件及属性 - */ - const p101 = { - bindOne(that) { - console.log(that.parentNode.parentNode) - console.log('data-pid',that.parentNode.parentNode.getAttribute('data-pid')) - }, - bindTwo(that) { - console.log(that.parentNode.parentNode) - console.log('data-uid',that.parentNode.parentNode.getAttribute('data-uid')) + const p102 = { + jumpDetails() { location.href = 'https://www.baidu.com' } };