classify.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <view class="content">
  3. <view class="box-1">
  4. <view class="box-left">
  5. 商品分类
  6. <text class="imp">*</text>
  7. </view>
  8. <view class="list-input" v-if="choose.length == 0" @click="open()">
  9. 请选择商品分类
  10. </view>
  11. <view class="list-input clamp" v-if="choose.length != 0" @click="open()">
  12. <text v-for="(item,index) in choose">{{item.label}}</text>
  13. </view>
  14. </view>
  15. <uni-popup ref="choose" type="bottom">
  16. <view class="choose-main">
  17. <view class="choose-top flex">
  18. <view class="choose-font" @click="close()">
  19. 取消
  20. </view>
  21. <view class="choose-qd" @click="qd()">
  22. 确定
  23. </view>
  24. </view>
  25. <scroll-view scroll-y="true" style="height: 600rpx;">
  26. <view class="choose-item flex" v-for="(item,index) in list" @click="xuanzhe(item)">
  27. <view class="choose-item-left" :class="{ current: item.disabled == 0 }">
  28. {{item.label}}
  29. </view>
  30. <view class="choose-item-right" v-if="item.disabled == 1">
  31. <image v-if="item.xuan == 1" src="../../../static/icon/dians.png" mode=""></image>
  32. <image v-if="item.xuan != 1" src="../../../static/icon/dian.png" mode=""></image>
  33. </view>
  34. </view>
  35. </scroll-view>
  36. </view>
  37. </uni-popup>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. name: 'classify',
  43. props: {
  44. //分类选项
  45. list: {
  46. type: Array,
  47. default: []
  48. },
  49. // 选择分类
  50. choose: {
  51. type: Array,
  52. default: []
  53. }
  54. },
  55. data() {
  56. return {};
  57. },
  58. created() {
  59. this.loadData()
  60. },
  61. onReachBottom() {},
  62. onReady() {},
  63. methods: {
  64. loadData() {
  65. this.list.forEach(e => {
  66. let j = 0
  67. for (var i = 0; i < this.choose.length; i++) {
  68. if (choose[i] == e.value) {
  69. j = 1
  70. }
  71. }
  72. e.xuan = j
  73. })
  74. },
  75. open() {
  76. this.$refs.choose.open()
  77. },
  78. close() {
  79. this.$refs.choose.close()
  80. },
  81. xuanzhe(opt) {
  82. const obj = this;
  83. console.log(opt, '123456');
  84. if (opt.xuan == 1) {
  85. opt.xuan = 0;
  86. let index = obj.choose.indexOf(opt);
  87. obj.choose.splice(index, 1);
  88. } else {
  89. opt.xuan = 1;
  90. obj.choose.push(opt);
  91. }
  92. },
  93. qd() {
  94. this.$refs.choose.close()
  95. this.$emit('chooseClasswc', this.choose);
  96. }
  97. }
  98. };
  99. </script>
  100. <style lang="scss">
  101. page,
  102. .content {
  103. min-height: 100%;
  104. height: auto;
  105. }
  106. .box-1 {
  107. background: #ffffff;
  108. display: flex;
  109. justify-content: space-between;
  110. align-items: center;
  111. width: 100%;
  112. padding-top: 20rpx;
  113. .box-left {
  114. padding-left: 2rpx;
  115. width: 50%;
  116. text-align: left;
  117. color: #000000;
  118. .imp {
  119. color: #e63931;
  120. }
  121. }
  122. .list-input {
  123. width: 50%;
  124. font-size: 28rpx;
  125. color: #959595;
  126. text-align: right;
  127. padding-right: 24rpx;
  128. }
  129. }
  130. .choose-main {
  131. background: #ffffff;
  132. }
  133. .choose-top {
  134. padding: 20rpx 40rpx 20rpx;
  135. font-size: 32rpx;
  136. .choose-font {
  137. color: #d4c7c2;
  138. }
  139. .choose-qd {
  140. color: #e63931;
  141. }
  142. }
  143. .choose-item {
  144. padding: 20rpx;
  145. .choose-item-left {
  146. font-size: 28rpx;
  147. }
  148. .current {
  149. color: #d4c7c2;
  150. }
  151. .choose-item-right {
  152. width: 40rpx;
  153. height: 40rpx;
  154. image {
  155. width: 100%;
  156. height: 100%;
  157. }
  158. }
  159. }
  160. </style>