topWarn.vue 4.3 KB

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