topWarn.vue 4.1 KB

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