uni-Popup.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. console.log(item);
  125. this.OptionsTabIndex = item.value;
  126. },
  127. //关闭事件
  128. close() {
  129. this.$emit('close')
  130. }
  131. }
  132. }
  133. </script>
  134. <style lang='scss' scoped>
  135. .header {
  136. color: #333;
  137. font-size: 32rpx;
  138. font-weight: bold;
  139. }
  140. .header-padding {
  141. padding: 27rpx 30rpx;
  142. }
  143. .borderBottom {
  144. border-bottom: 1px solid #EEEEEE;
  145. }
  146. .quickOptions {
  147. padding: 42rpx 42rpx 0;
  148. box-sizing: border-box;
  149. margin-bottom: 20rpx;
  150. .tab {
  151. width: 180rpx;
  152. padding: 9rpx 24rpx;
  153. box-sizing: border-box;
  154. font-size: 30rpx;
  155. color: #666;
  156. border-radius: 4rpx 4rpx 4rpx 4rpx;
  157. border: 1rpx solid #EEEEEE;
  158. margin-right: 30rpx;
  159. margin-bottom: 30rpx;
  160. }
  161. .tabactive {
  162. background: #FDE935;
  163. color: #333;
  164. border: 1rpx solid #FDE935;
  165. }
  166. }
  167. .custom-footer {
  168. padding: 40rpx 0 0;
  169. box-sizing: border-box;
  170. view {
  171. font-size: 30rpx;
  172. padding: 20rpx;
  173. flex: 1;
  174. }
  175. view:first-child {
  176. color: #333;
  177. background: transparent;
  178. border-radius: 50rpx;
  179. border: 1rpx solid #FDE935;
  180. margin-right: 28rpx;
  181. }
  182. view:last-child {
  183. background: #FDE935;
  184. border-radius: 50rpx;
  185. color: #1F1F1F;
  186. }
  187. }
  188. </style>