topWarn.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <!-- 顶部警告 -->
  2. <template>
  3. <view class="top-warn" v-if="pageType">
  4. <view>{{text}}</view>
  5. <view @click="buttonClick" v-if="whetherRoute">操作</view>
  6. </view>
  7. </template>
  8. <script>
  9. import { getListStatusTwo,evacuate,closeRiskPlan } from '@/api/index.js'
  10. export default {
  11. data() {
  12. return {
  13. pageType:false,
  14. text:"",
  15. subjectId:"",
  16. buildingId:"",
  17. floorId:"",
  18. subjectName:"",
  19. closePlan:false,
  20. closeId:"",
  21. whetherRoute:true,// true 有疏散路线,false 没有疏散路线
  22. }
  23. },
  24. created() {
  25. },
  26. mounted(){
  27. this.getWarn();
  28. getApp().watch(this.getWarn,'warnData');
  29. getApp().watch(this.lineDataFunction,'lineData');
  30. this.timeFuncontion();
  31. },
  32. methods: {
  33. //应急变更
  34. lineDataFunction(val){
  35. console.log("val",val);
  36. },
  37. buttonClick(){
  38. let self = this;
  39. let list = [];
  40. if(self.closePlan){
  41. list = ['执行疏散', '结束预案'];
  42. }else{
  43. list = ['执行疏散'];
  44. }
  45. uni.showActionSheet({
  46. itemList: list,
  47. success: function (res) {
  48. if(res.tapIndex == 0){
  49. self.evacuationClick();
  50. }else if(res.tapIndex == 1){
  51. self.offEvacuationClick();
  52. }
  53. console.log('res.tapIndex',res.tapIndex);
  54. console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
  55. },
  56. fail: function (res) {
  57. console.log(res.errMsg);
  58. }
  59. });
  60. },
  61. //执行疏散
  62. evacuationClick(){
  63. let self = this;
  64. uni.showModal({
  65. content: '确认执行疏散?',
  66. cancelColor:"#999",
  67. confirmColor:"#0183FA",
  68. success: function (res) {
  69. if (res.confirm) {
  70. self.goPage();
  71. console.log('用户点击确定');
  72. } else if (res.cancel) {
  73. console.log('用户点击取消');
  74. }
  75. }
  76. });
  77. },
  78. offEvacuationClick(){
  79. let self = this;
  80. uni.showModal({
  81. content: '确认结束预案?',
  82. cancelColor:"#999",
  83. confirmColor:"#0183FA",
  84. success: function (res) {
  85. if (res.confirm) {
  86. self.closeRiskPlan();
  87. console.log('用户点击确定');
  88. } else if (res.cancel) {
  89. console.log('用户点击取消');
  90. }
  91. }
  92. });
  93. },
  94. async closeRiskPlan(){
  95. const {data} = await closeRiskPlan({id:this.closeId});
  96. if(data.code == 200){
  97. uni.showToast({
  98. title: '操作成功',
  99. icon:"none",
  100. mask:true,
  101. duration: 2000
  102. });
  103. this.pageType = false;
  104. }
  105. },
  106. //页面跳转
  107. goPage(){
  108. let obj = {
  109. buildingId:this.buildingId,
  110. subId:this.subjectId,
  111. floorId:this.floorId,
  112. subjectName:this.subjectName,
  113. address:this.text,
  114. type:"1",
  115. }
  116. uni.navigateTo({
  117. url:'/pages/emergencyEvacuationBig?item='+encodeURIComponent(JSON.stringify(obj))
  118. });
  119. },
  120. //获取报警信息
  121. async getWarn(){
  122. let self = this;
  123. const {data} = await getListStatusTwo();
  124. console.log("baojing",data)
  125. if(data.code == 200){
  126. let num = 0;
  127. for(let i=0;i<data.data.length;i++){
  128. if(data.data[i].floorId != 7 && data.data[i].whetherRoute){
  129. num++;
  130. self.text = data.data[i].buildName + data.data[i].floorName + data.data[i].roomName + data.data[i].subjectName + '发生应急预案.';
  131. self.subjectId = data.data[i].subjectId;
  132. self.buildingId = data.data[i].buildId;
  133. self.floorId = data.data[i].floorId;
  134. self.whetherRoute = data.data[i].whetherRoute;
  135. self.subjectName = data.data[i].subjectName;
  136. self.pageType = true;
  137. self.closePlan =data.data[i].closePlan;
  138. self.closeId = data.data[i].id;
  139. }
  140. }
  141. if(num == 0){
  142. self.pageType = false;
  143. }
  144. }
  145. },
  146. timeFuncontion(){
  147. let self = this;
  148. var t1 = setInterval(refreshCount, 300);
  149. function refreshCount() {
  150. let txt = self.text
  151. let start = txt.substring(0, 1);//取该字符串的第一个字符
  152. let end = txt.substring(1);//取该字符串的从1之后的所有字符
  153. let newText = end + start;//拼接新的字符串
  154. self.$set(self,'text',newText)
  155. }
  156. }
  157. }
  158. }
  159. </script>
  160. <style lang="stylus" scoped>
  161. .top-warn{
  162. height:80rpx;
  163. line-height:80rpx;
  164. background rgba(2550,0,0,0.2)
  165. margin:20rpx 0;
  166. display flex;
  167. overflow hidden
  168. view:nth-child(1){
  169. padding-left:20rpx;
  170. color:#FF0000;
  171. flex:1;
  172. view{
  173. padding-left:20rpx;
  174. white-space:nowrap;
  175. }
  176. }
  177. view:nth-child(2){
  178. width:140rpx;
  179. color:#0183FA;
  180. text-align center;
  181. }
  182. }
  183. </style>