uni-popup-qiang.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <view class="uni-popup-dialog">
  3. <view class="uni-dialog-title">
  4. <text class="uni-dialog-title-text" :class="['uni-popup__'+dialogType]">{{title}}</text>
  5. </view>
  6. <view class="uni-dialog-content">
  7. <view class="uni-dialog-content-title">频率:</view>
  8. <lxc-count
  9. @handleCount="handleCountClick"
  10. :index="item.index"
  11. :value="item.num"
  12. :delayed="100"
  13. >
  14. </lxc-count>
  15. </view>
  16. <view class="uni-dialog-button-group">
  17. <view class="uni-dialog-button" @click="close">
  18. <text class="uni-dialog-button-text">取消</text>
  19. </view>
  20. <view class="uni-dialog-button uni-border-left" @click="onOk(status == 0 ? 1 : 0)">
  21. <text class="uni-dialog-button-text uni-button-color">{{status == 0 ? '开启' : '关闭'}}</text>
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. /**
  28. * PopUp 弹出层-对话框样式
  29. * @description 弹出层-对话框样式
  30. * @tutorial https://ext.dcloud.net.cn/plugin?id=329
  31. * @property {String} value input 模式下的默认值
  32. * @property {String} placeholder input 模式下输入提示
  33. * @property {String} type = [success|warning|info|error] 主题样式
  34. * @value success 成功
  35. * @value warning 提示
  36. * @value info 消息
  37. * @value error 错误
  38. * @property {String} mode = [base|input] 模式、
  39. * @value base 基础对话框
  40. * @value input 可输入对话框
  41. * @property {String} content 对话框内容
  42. * @property {Boolean} beforeClose 是否拦截取消事件
  43. * @event {Function} confirm 点击确认按钮触发
  44. * @event {Function} close 点击取消按钮触发
  45. */
  46. export default {
  47. name: "uniPopupQiang",
  48. props: {
  49. item:{
  50. type:Object,
  51. default:()=>{
  52. return {
  53. index:0,
  54. num:2,
  55. }
  56. }
  57. },
  58. value: {
  59. type: [String, Number],
  60. default: ''
  61. },
  62. maxlength:{
  63. type: Number,
  64. default: 10
  65. },
  66. status:{
  67. type:String,
  68. default:'0'
  69. },
  70. placeholder: {
  71. type: [String, Number],
  72. default: '请输入内容'
  73. },
  74. /**
  75. * 对话框主题 success/warning/info/error 默认 success
  76. */
  77. type: {
  78. type: String,
  79. default: 'error'
  80. },
  81. /**
  82. * 对话框模式 base/input
  83. */
  84. mode: {
  85. type: String,
  86. default: 'base'
  87. },
  88. /**
  89. * 对话框标题
  90. */
  91. title: {
  92. type: String,
  93. default: '提示'
  94. },
  95. /**
  96. * 对话框内容
  97. */
  98. content: {
  99. type: String,
  100. default: ''
  101. },
  102. /**
  103. * 拦截取消事件 ,如果拦截取消事件,必须监听close事件,执行 done()
  104. */
  105. beforeClose: {
  106. type: Boolean,
  107. default: false
  108. }
  109. },
  110. data() {
  111. return {
  112. dialogType: 'error',
  113. focus: false,
  114. val: "",
  115. num:2
  116. }
  117. },
  118. inject: ['popup'],
  119. watch: {
  120. type(val) {
  121. this.dialogType = val
  122. },
  123. mode(val) {
  124. if (val === 'input') {
  125. this.dialogType = 'info'
  126. }
  127. },
  128. value(val) {
  129. this.val = val
  130. }
  131. },
  132. created() {
  133. // 对话框遮罩不可点击
  134. this.popup.mkclick = false
  135. if (this.mode === 'input') {
  136. this.dialogType = 'info'
  137. this.val = this.value
  138. } else {
  139. this.dialogType = this.type
  140. }
  141. },
  142. mounted() {
  143. this.focus = true
  144. },
  145. methods: {
  146. handleCountClick(num){
  147. this.num = num;
  148. },
  149. /**
  150. * 点击确认按钮
  151. */
  152. onOk(status) {
  153. this.$emit('confirm',{num:this.num,status:status})
  154. },
  155. /**
  156. * 点击取消按钮
  157. */
  158. close() {
  159. if (this.beforeClose) {
  160. this.$emit('close', () => {
  161. this.popup.close()
  162. })
  163. return
  164. }
  165. this.popup.close()
  166. }
  167. }
  168. }
  169. </script>
  170. <style lang="scss" scoped>
  171. .uni-popup-dialog {
  172. width: 300px;
  173. border-radius: 5px;
  174. background-color: #fff;
  175. }
  176. .uni-dialog-title {
  177. /* #ifndef APP-NVUE */
  178. display: flex;
  179. /* #endif */
  180. flex-direction: row;
  181. justify-content: flex-start;
  182. padding: 20px 0 10px 15px;
  183. }
  184. .uni-dialog-title-text {
  185. font-size: 16px;
  186. font-weight: 500;
  187. }
  188. .uni-dialog-button-group {
  189. /* #ifndef APP-NVUE */
  190. display: flex;
  191. /* #endif */
  192. flex-direction: row;
  193. border-top-color: #bdbdbd;
  194. border-top-style: solid;
  195. border-top-width: 1px;
  196. margin-top:5px;
  197. }
  198. .uni-dialog-button {
  199. /* #ifndef APP-NVUE */
  200. display: flex;
  201. /* #endif */
  202. flex: 1;
  203. flex-direction: row;
  204. justify-content: center;
  205. align-items: center;
  206. height: 55px;
  207. }
  208. .uni-border-left {
  209. border-left-color: #bdbdbd;
  210. border-left-style: solid;
  211. border-left-width: 1px;
  212. }
  213. .uni-dialog-button-text {
  214. font-size: 14px;
  215. }
  216. .uni-button-color {
  217. }
  218. .uni-dialog-input {
  219. flex: 1;
  220. font-size: 14px;
  221. overflow: visible !important;
  222. line-height :1.9rem !important;
  223. height:1.9rem !important;
  224. border-radius: 10px;
  225. padding-left:2px;
  226. background-color: #eeeeee;
  227. }
  228. .uni-popup__success {
  229. color: $uni-color-success;
  230. }
  231. .uni-popup__warn {
  232. color: $uni-color-warning;
  233. }
  234. .uni-popup__error {
  235. color: $uni-color-error;
  236. }
  237. .uni-popup__info {
  238. color: #909399;
  239. }
  240. .uni-dialog-content{
  241. display: flex;
  242. padding: 40rpx;
  243. }
  244. </style>