uni-Popup.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <view class='uni-page'>
  3. <u-popup :show="modelshow" @close="close" :closeable="closeable" round="20rpx" :bgColor="bgColor" :mode="mode"
  4. :closeOnClickOverlay="closeOnClickOverlay" :customStyle="{ width: width }">
  5. <view class="">
  6. <view class="header header-padding dis a-c j-c" v-if="!headerSlot" :class="{ borderBottom: border }"
  7. :style="headerStyle">
  8. <text>{{ headerTitle }}</text>
  9. </view>
  10. <view v-else class="header-padding " :class="{ borderBottom: border }">
  11. <slot name="header"></slot>
  12. </view>
  13. <view class="content" :style="{ overflow: overflow, maxHeight: maxHeight }">
  14. <slot name="content" v-if="contentType != 'status'">
  15. </slot>
  16. <view class="quickOptions dis f-c" v-else>
  17. <view class=" dis a-c j-s f-wrap">
  18. <view class="tab dis a-c j-c " :class="{ tabactive: OptionsTabIndex == item.value }"
  19. v-for="(item, index) in statusList" :key="index" @click="OptionsTabSelect(item, index)">
  20. <text>{{ item.label }}</text>
  21. </view>
  22. </view>
  23. <view class="custom-footer dis j-s a-c ">
  24. <view class="dis a-c j-c" @tap="close">取消</view>
  25. <view class="dis a-c j-c" @tap="statusConfirm">确定</view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </u-popup>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. props: {
  36. // 状态数据
  37. statusList: {
  38. type: Array,
  39. default: () => []
  40. },
  41. // 当前激活标签
  42. show: {
  43. type: Boolean,
  44. default: false
  45. },
  46. //头部插槽
  47. headerSlot: {
  48. type: Boolean,
  49. default: false,
  50. },
  51. headerTitle: {
  52. //头部标题
  53. type: String,
  54. default: '请选择',
  55. },
  56. bgColor: {
  57. type: String,
  58. default: '#FFF'
  59. },
  60. overflow: {
  61. //是否局部滚动
  62. type: String,
  63. default: '',
  64. },
  65. //最大高度
  66. maxHeight: {
  67. type: String,
  68. default: ''
  69. },
  70. border: {
  71. //是否边框
  72. type: Boolean,
  73. default: true,
  74. },
  75. headerStyle: Object,
  76. closeable: {
  77. //是否显示右上角叉号
  78. type: Boolean,
  79. default: true,
  80. },
  81. //弹出方向
  82. mode: {
  83. type: String,
  84. default: 'bottom' //top / right / bottom / center
  85. },
  86. //弹窗宽度
  87. width: {
  88. type: String,
  89. default: '100%'
  90. },
  91. //插槽内容类型
  92. contentType: {
  93. type: String,
  94. default: 'list' //list :列表选择 / custom :自定义 / status :状态筛选 /
  95. },
  96. //点击遮罩是否关闭弹窗
  97. closeOnClickOverlay: {
  98. type: Boolean,
  99. default: true,
  100. }
  101. },
  102. data() {
  103. return {
  104. modelshow: this.show,
  105. OptionsTabIndex: null, //切换下标
  106. }
  107. },
  108. onShow() {
  109. },
  110. onLoad() {
  111. },
  112. watch: {
  113. show(newVal) {
  114. this.modelshow = newVal
  115. }
  116. },
  117. methods: {
  118. //状态切换回调
  119. statusConfirm() {
  120. this.$emit('statusConfirm', this.OptionsTabIndex)
  121. },
  122. //状态切换
  123. OptionsTabSelect(item, index) {
  124. this.OptionsTabIndex = item.value;
  125. },
  126. //关闭事件
  127. close() {
  128. this.$emit('close')
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang='scss' scoped>
  134. .header {
  135. color: #333;
  136. font-size: 32rpx;
  137. font-weight: bold;
  138. }
  139. .header-padding {
  140. padding: 27rpx 30rpx;
  141. }
  142. .borderBottom {
  143. border-bottom: 1px solid #EEEEEE;
  144. }
  145. .quickOptions {
  146. padding: 42rpx 42rpx 0;
  147. box-sizing: border-box;
  148. margin-bottom: 20rpx;
  149. .tab {
  150. width: 180rpx;
  151. padding: 9rpx 24rpx;
  152. box-sizing: border-box;
  153. font-size: 30rpx;
  154. color: #666;
  155. border-radius: 4rpx 4rpx 4rpx 4rpx;
  156. border: 1rpx solid #EEEEEE;
  157. margin-right: 30rpx;
  158. margin-bottom: 30rpx;
  159. }
  160. .tabactive {
  161. background: #FDE935;
  162. color: #333;
  163. border: 1rpx solid #FDE935;
  164. }
  165. }
  166. .custom-footer {
  167. padding: 40rpx 0 0;
  168. box-sizing: border-box;
  169. view {
  170. font-size: 30rpx;
  171. padding: 20rpx;
  172. flex: 1;
  173. }
  174. view:first-child {
  175. color: #333;
  176. background: transparent;
  177. border-radius: 50rpx;
  178. border: 1rpx solid #FDE935;
  179. margin-right: 28rpx;
  180. }
  181. view:last-child {
  182. background: #FDE935;
  183. border-radius: 50rpx;
  184. color: #1F1F1F;
  185. }
  186. }
  187. ::v-deep .u-transition.u-fade-enter-to,
  188. ::v-deep .u-transition.u-fade-enter-active,
  189. ::v-deep .u-transition.u-fade-leave-to,
  190. ::v-deep .u-transition.u-fade-leave-active {
  191. z-index: 99999 !important;
  192. }
  193. ::v-deep .u-transition {
  194. z-index: 99999 !important;
  195. }
  196. ::v-deep .u-popup {
  197. z-index: 100000 !important;
  198. }
  199. </style>