h-form-alert.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <view class="a_mask">
  3. <form class="a_box" @submit="formSubmit" @reset="formReset">
  4. <view class="a_head">
  5. {{title}}
  6. </view>
  7. <view class="a_input">
  8. <input :type="type" :value="value" :placeholder="placeholder" :name="name"/>
  9. </view>
  10. <view class="a_btn">
  11. <button form-type="reset" :style="{color:cancelColor}">{{cancelText}}</button>
  12. <button form-type="submit" :style="{color:confirmColor}">{{confirmText}}</button>
  13. </view>
  14. </form>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. props:{
  20. title:{
  21. type:String,
  22. default:'提示'
  23. },
  24. placeholder:{
  25. type:String,
  26. default:'请点击输入'
  27. },
  28. name:{
  29. type:String,
  30. default:'text'
  31. },
  32. type:{
  33. type:String,
  34. default:'text'
  35. },
  36. value:{
  37. type:String,
  38. default:''
  39. },
  40. cancelColor:{
  41. type:String,
  42. default:'#999999'
  43. },
  44. confirmColor:{
  45. type:String,
  46. default:'#333333'
  47. },
  48. cancelText:{
  49. type:String,
  50. default:'取消'
  51. },
  52. confirmText:{
  53. type:String,
  54. default:'确定'
  55. },
  56. },
  57. data() {
  58. return {
  59. };
  60. },
  61. methods: {
  62. formSubmit: function(e) {
  63. console.log(e)
  64. let _formdata = e.detail.value
  65. this.$emit('confirm',_formdata)
  66. },
  67. formReset: function(e) {
  68. this.$emit('cancel')
  69. }
  70. }
  71. }
  72. </script>
  73. <style lang="scss">
  74. .a_mask{
  75. position: fixed;
  76. z-index: 99999;
  77. background-color: rgba(0,0,0,0.5);
  78. top: 0;
  79. left: 0;
  80. bottom: 0;
  81. right: 0;
  82. .a_box{
  83. width: 500upx;
  84. overflow: hidden;
  85. background-color: #fff;
  86. border-radius: 10upx;
  87. position: absolute;
  88. top: 50%;
  89. left: 50%;
  90. transform: translate(-50%,-50%);
  91. .a_head{
  92. text-align: center;
  93. font-size: 30upx;
  94. line-height: 88upx;
  95. }
  96. .a_input{
  97. padding: 30upx 20upx;
  98. font-size: 28upx;
  99. input{
  100. text-align: center;
  101. }
  102. }
  103. .a_btn{
  104. text-align: center;
  105. font-size: 30upx;
  106. line-height: 88upx;
  107. display: flex;
  108. justify-content: space-between;
  109. border-top: 1upx solid #f5f5f5;
  110. button{
  111. width: 50%;
  112. background-color: #fff;
  113. font-size: 30upx;
  114. border-radius: 0upx;
  115. padding: 0;
  116. &::after{
  117. border:none
  118. }
  119. &:first-child{
  120. border-right: 1upx solid #f5f5f5;
  121. color: #999999;
  122. box-sizing: border-box;
  123. }
  124. &:last-child{
  125. color: #333;
  126. }
  127. }
  128. }
  129. }
  130. }
  131. </style>