popAlert.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <view class="root" catchtouchmove='return' v-if="bShow">
  3. <!-- 背景黑幕 -->
  4. <view class="blackBg" @click="close()"></view>
  5. <!-- 背景 -->
  6. <view class="formBg">
  7. <!-- 标题 -->
  8. <view class="titleBg">
  9. <view class="title">{{title}}</view>
  10. </view>
  11. <!-- 内容 -->
  12. <view class="middle">{{content}}</view>
  13. <!-- 按钮区 -->
  14. <view class="btnArea">
  15. <button type="default" size="mini" class="confirm" @click="confirm()">确定</button>
  16. <button type="default" size="mini" class="cancel" @click="cancel()">取消</button>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. data() {
  24. return {
  25. bShow:false,
  26. title:'标题',
  27. // content:'内容',
  28. callback:null
  29. }
  30. },
  31. methods: {
  32. isShow(bShow){
  33. this.bShow = bShow;
  34. },
  35. setTitle(title){
  36. this.title = title;
  37. },
  38. setContent(content,callback){
  39. this.content = content;
  40. this.callback = callback;
  41. },
  42. close(){
  43. // this.bShow = !this.bShow;
  44. },
  45. confirm(){
  46. this.bShow = !this.bShow;
  47. this.callback();
  48. },
  49. cancel(){
  50. this.bShow = !this.bShow;
  51. }
  52. },
  53. }
  54. </script>
  55. <style lang="scss">
  56. .root{
  57. width: 100%;
  58. height: 100%;
  59. position: absolute;
  60. top:0;
  61. left:0;
  62. z-index: 1;
  63. display: flex;
  64. justify-content: center;
  65. align-items: center;
  66. }
  67. .blackBg{
  68. width: 100%;
  69. height: 100%;
  70. opacity: 0.5;
  71. background-color: #000000;
  72. }
  73. .formBg{
  74. position: absolute;
  75. width: 20%;
  76. background-color: #ffffff;
  77. display: flex;
  78. justify-content: space-between;
  79. align-items: center;
  80. flex-direction: column;
  81. }
  82. .titleBg{
  83. width: 100%;
  84. background-color: #ff0000;
  85. display: flex;
  86. justify-content: center;
  87. align-items: center;
  88. }
  89. .title{
  90. color: #ffffff;
  91. font-size: 30rpx;
  92. margin: 5%;
  93. // border:1px solid #000000;
  94. }
  95. .middle{
  96. width: 100%;
  97. // height: 100%;
  98. display: flex;
  99. justify-content: center;
  100. align-items: center;
  101. font-weight: 400 !important;
  102. margin: 5%;
  103. // border:1px solid #000000;
  104. }
  105. .btnArea{
  106. width: 100%;
  107. // height: 10%;
  108. // border:1px solid #000000;
  109. display: flex;
  110. justify-content: space-around;
  111. align-items: center;
  112. flex-direction: row;
  113. margin-bottom: 5%;
  114. }
  115. .confirm{
  116. background: rgb(234, 37, 44);
  117. color: rgb(255, 255, 255);
  118. }
  119. .cancel{
  120. background: rgb(234, 37, 44);
  121. color: rgb(255, 255, 255);
  122. }
  123. </style>