uni-popup.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <view class='uni-page'>
  3. <u-popup v-model="modelshow" @close="close" :closeable="closeable" border-radius="20" :mode="mode"
  4. :closeOnClickOverlay="closeOnClickOverlay" :customStyle="{width:width}">
  5. <view class="dis f-c ">
  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==index}"
  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. OptionsTabInfo: {},
  107. }
  108. },
  109. onShow() {
  110. },
  111. onLoad() {
  112. },
  113. watch: {
  114. show(newVal) {
  115. this.modelshow = newVal
  116. }
  117. },
  118. methods: {
  119. //状态切换回调
  120. statusConfirm() {
  121. this.$emit('statusConfirm', this.OptionsTabInfo)
  122. },
  123. //状态切换
  124. OptionsTabSelect(item, index) {
  125. this.OptionsTabInfo = item;
  126. this.OptionsTabIndex = index;
  127. },
  128. //关闭事件
  129. close() {
  130. this.$emit('close')
  131. }
  132. }
  133. }
  134. </script>
  135. <style lang='scss' scoped>
  136. .header {
  137. color: #333;
  138. font-size: 32rpx;
  139. font-weight: bold;
  140. }
  141. .header-padding {
  142. padding: 27rpx 30rpx;
  143. }
  144. .borderBottom {
  145. border-bottom: 1px solid #EEEEEE;
  146. }
  147. .quickOptions {
  148. padding: 42rpx 42rpx 0;
  149. box-sizing: border-box;
  150. margin-bottom: 20rpx;
  151. .tab {
  152. width: 180rpx;
  153. padding: 9rpx 24rpx;
  154. box-sizing: border-box;
  155. font-size: 30rpx;
  156. color: #666;
  157. border-radius: 4rpx 4rpx 4rpx 4rpx;
  158. border: 1rpx solid #EEEEEE;
  159. margin-right: 30rpx;
  160. margin-bottom: 30rpx;
  161. }
  162. .tabactive {
  163. background: #EAF0FF;
  164. color: #2D6DFF;
  165. border: 1rpx solid #EAF0FF;
  166. }
  167. }
  168. .custom-footer {
  169. padding: 40rpx 0 0;
  170. box-sizing: border-box;
  171. view {
  172. font-size: 30rpx;
  173. padding: 18rpx;
  174. box-sizing: border-box;
  175. flex: 1;
  176. }
  177. view:first-child {
  178. background: rgba(45, 109, 255, 0.1);
  179. border-radius: 4rpx 4rpx 4rpx 4rpx;
  180. font-size: 32rpx;
  181. color: #2D6DFF;
  182. margin-right: 36rpx;
  183. }
  184. view:last-child {
  185. background: linear-gradient(132deg, #2DD9FF 0%, #2D6DFF 100%);
  186. border-radius: 4rpx 4rpx 4rpx 4rpx;
  187. font-size: 32rpx;
  188. color: #fff;
  189. }
  190. }
  191. </style>