shopSelect.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <view class="select-bg_bx">
  3. <view v-if="isShowTit" @click="switchCut" :class="['select-title',dropdownShow?'select_corlor':'']">
  4. <text>{{showShopName!=''?showShopName:getMyShopInfo.shopName}}</text>
  5. <text v-if="placeholder" style="color: #ccc;">{{placeholder}}</text>
  6. <i v-if="isShowMore" class="iconfont iconsanjiao_xia"></i>
  7. </view>
  8. <view v-else @click="switchCut" :class="['select-title',dropdownShow?'select_corlor':'']">
  9. <text v-if="placeholder" style="color: #ccc;">{{placeholder}}</text>
  10. </view>
  11. <view class="select-mark-view" v-show="dropdownShow" @click="switchCut"></view>
  12. <view v-if="dropdownShow" :style="{top}" class="select-fixed_bx">
  13. <slot>
  14. <view class="select-item-box">
  15. <view class="title">门店</view>
  16. <view class="item-child_box">
  17. <button v-for="(item,index) in shopList" :key="index" @click="changeItem(item)"
  18. :class="['admin-button-com','mini-btn','default']"> {{item.name}} </button>
  19. </view>
  20. </view>
  21. </slot>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import DropdownList from "@/components/plugin/dropdown-list";
  27. import {mapGetters,mapState} from "vuex";
  28. export default {
  29. name:'DorpdownSelect',
  30. components:{
  31. DropdownList
  32. },
  33. props:{
  34. top:{
  35. type: String,
  36. default: 'auto'
  37. },
  38. isShowTit:{
  39. type: Boolean,
  40. default: true
  41. },
  42. typeTime:{
  43. type: Boolean,
  44. default: false
  45. },
  46. isShowMore:{
  47. type: Boolean,
  48. default: true
  49. },
  50. placeholder: {
  51. type: String,
  52. default: ''
  53. }
  54. },
  55. data(){
  56. return {
  57. dropdownShow: false,
  58. selectItem:'',
  59. showShopName:'',
  60. shopList:[]
  61. }
  62. },
  63. computed:{
  64. ...mapGetters(["getMyShopInfo"]),
  65. ...mapState({
  66. userShopAll:state=>state.user.userShopAll
  67. }),
  68. },
  69. mounted(){
  70. this.shopList = this.userShopAll.map(i=>({...i,name:i.shopName}))
  71. },
  72. watch:{
  73. userShopAll (val) {
  74. if(!this.$util.isEmpty(val)) {
  75. this.shopList = val.map(i=>({
  76. ...i,
  77. name:i.shopName
  78. }));
  79. }
  80. }
  81. },
  82. methods:{
  83. switchCut(){
  84. this.dropdownShow = !this.dropdownShow
  85. },
  86. changeItem(val){
  87. this.dropdownShow = false;
  88. this.showShopName = val.name;
  89. this.$emit('selectShopFn',val)
  90. }
  91. }
  92. }
  93. </script>
  94. <style lang="scss" scoped>
  95. .select-bg_bx {
  96. .select-title {
  97. color: #666666;
  98. font-size: 26upx;
  99. & .iconsanjiao_xia {
  100. margin-left: 10upx;
  101. }
  102. &.select_corlor {
  103. color: #3385FF;
  104. & .iconsanjiao_xia {
  105. transform: rotate(180deg);
  106. }
  107. }
  108. }
  109. .select-mark-view {
  110. height: 100vh;
  111. height: 100%;
  112. position: fixed;
  113. width: 100%;
  114. background-color: rgba(0, 0, 0, 0.5);
  115. left: 0;
  116. top: 0upx;
  117. z-index: 20;
  118. }
  119. & .select-fixed_bx {
  120. position: fixed;
  121. width: 100%;
  122. background-color: #FFFFFF;
  123. left: 0upx;
  124. top:0upx;
  125. z-index: 29;
  126. padding:120upx 30upx 40upx;
  127. border-radius: 0upx 0upx 20upx 20upx;
  128. transition: all 0.5s ease-in-out;
  129. & .select-item-box {
  130. & .title {
  131. font-size: 24upx;
  132. color: #333333;
  133. font-weight: 600;
  134. text-align: left;
  135. }
  136. & .item-child_box {
  137. padding: 20upx 0 0;
  138. align-items: center;
  139. & .admin-button-com {
  140. margin-bottom: 20upx;
  141. padding: 18upx 50upx;
  142. margin-right: 20upx;
  143. &.custom {
  144. width: 100%;
  145. }
  146. }
  147. }
  148. }
  149. }
  150. }
  151. </style>