Browse Source

调接口

9-plugin-notice
aBin 4 years ago
parent
commit
de58a201ce
  1. 22
      index.html

22
index.html

@ -22,7 +22,7 @@
<!-- 日常任务面板-->
<div class="content p-3 h-46 bg-white rounded-lg">
<div class="h-auto mb-2 bg-gray-100">
<view data-pid="1402180561518333952" data-uid="1298194698783170560" data-rid="xxx" data-tid="xxx" data-did="xxx">
<view data-pid="1420652719055839232" data-uid="1298194698783170560" data-rid="xxx" data-tid="xxx" data-did="xxx">
<!--绿道一键通知-->
<div data-root="p1419895620596146176">
<!-- main -->
@ -42,6 +42,8 @@
dom: '',
name: 'pluginNotice',
timer: null,
content: '',
init() {
this.dom = document.querySelector("div[data-root=p1419895620596146176]");
var domBox = this.dom.parentNode;
@ -64,10 +66,11 @@
const { success, code, data, msg } = res;
if (success && code === 200) {
that.token = data.token;
that.getFirstAidRecord()
that.timer = setInterval(function (){
//查询当前项目的最新消息
that.getFirstAidRecord()
},3000)
},5000)
} else {
alert(msg || '获取失败')
}
@ -84,8 +87,9 @@
param: {projectId: that.projectId}
});
fetch('http://www.tall.wiki/gateway/qcp/v3.0/patient/queryNewMessage', {
fetch('https://www.tall.wiki/gateway/qcp/v3.0/project/queryNewMessage', {
method: 'POST',
mode: 'cors',
body: params,
headers: new Headers({
'Authorization': 'Bearer ' + that.token ,'Content-Type': 'application/json;charset=utf-8'
@ -94,22 +98,22 @@
return response.json();
}).catch(function(error){
console.error('Error:', error)
// TODO: 测试数据
that.setDate('请<span style="color: #f00">张小小</span><span style="color: #f00">3号窗口</span>交费')
clearInterval(that.timer)
// TODO
}).then(function(res){
const { success, code, data, msg } = res;
if (success && code === 200) {
that.setDate(data.content)
if(data.content !== this.content){
that.setDate(data.content)
}
} else {
alert(msg || '查询失败')
console.log('msg: ', msg);
}
})
},
// 界面渲染
setDate(res) {
this.content = res
var textLeft = 0
var oTxt = this.dom.querySelector('.txt'); //获取标签
var offsetWidth = oTxt.offsetWidth
@ -124,7 +128,7 @@
if(-textLeft >= offsetWidth){
textLeft = offsetWidth
}
},300)
},500)
}
}
p1419895620596146176.init()

Loading…
Cancel
Save