choose-Cade.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <view class="boxa">
  3. <view class="top_kbox">
  4. <block v-for="(item,i) in newlist" :key="i">
  5. <view class="ibox" @tap="alertnum(i)" :class="[i== i1?'actives':'']">
  6. <text class="uni_14">{{item}}</text>
  7. <image v-if="i != i1" class="ii" src="/static/choose-Cade/choose-Cadex.png" mode=""></image>
  8. <image v-else class="ii" src="/static/choose-Cade/choose-Cades.png" mode=""></image>
  9. </view>
  10. </block>
  11. </view>
  12. <view :class="[show?'list_boxs2':'list_boxs']">
  13. <view class="lione">
  14. <block v-for="(item,i) in listchild" :key="i">
  15. <view class="mli" @tap="chooseOne(i)">
  16. <text :class="[i== i2?'actives':'']" class="uni_14">{{item}}</text>
  17. <image v-if="i == i2" class="ii" src="/static/choose-Cade/choose-Cadecc.png" mode=""></image>
  18. </view>
  19. </block>
  20. </view>
  21. <view class="hideA" @tap="hide">
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. props: ['list', 'arr'], //数组 arr
  29. data() {
  30. return {
  31. i1: null,
  32. i2: null,
  33. show: false,
  34. listchild: [],
  35. newlist: this.list,
  36. origin:this.list,
  37. }
  38. },
  39. watch: {
  40. list(val) { //message即为父组件的值,val参数为值
  41. console.log(this.list);
  42. this.list = val //将父组件的值赋给childrenMessage 子组件的值
  43. this.newlist = this.list;
  44. }
  45. },
  46. methods: {
  47. alertnum(i) {
  48. console.log(i, this.newlist,this.i1);
  49. if (this.i1 != i) {
  50. this.listchild = [];
  51. this.i1 = i;
  52. this.listchild = this.arr[i];
  53. this.i2 = null;
  54. this.show = true;
  55. let ins = this.listchild.indexOf(this.newlist[i]);
  56. if (ins > -1) {
  57. this.i2 = ins
  58. }
  59. }
  60. },
  61. chooseOne(i) {
  62. this.i2 = i;
  63. this.newlist[this.i1] = this.listchild[i];
  64. console.log(this.i2, this.newlist);
  65. this.$emit('chooseLike', [this.i1, this.i2])
  66. },
  67. hide() {
  68. this.show = false;
  69. this.i1 = null;
  70. this.i2 = null;
  71. }
  72. }
  73. }
  74. </script>
  75. <style>
  76. .hideA {
  77. height: calc(100% - 310upx);
  78. }
  79. .mli {
  80. /* border: 1upx solid red; */
  81. display: flex;
  82. justify-content: space-between;
  83. align-items: center;
  84. padding: 22upx 0;
  85. }
  86. .lione {
  87. background-color: #fff;
  88. /* height: 262upx; */
  89. padding: 10upx 40upx;
  90. }
  91. .list_boxs {
  92. background-color: rgba(84, 80, 80, 0.48);
  93. position: fixed;
  94. height: calc(100%);
  95. width: 100%;
  96. z-index: 88;
  97. transition: all .5s;
  98. transform: translateY(-120%);
  99. }
  100. .list_boxs2 {
  101. background-color: rgba(84, 80, 80, 0.48);
  102. position: fixed;
  103. height: calc(100%);
  104. width: 100%;
  105. z-index: 88;
  106. transform: translateY(0);
  107. transition: all .5s;
  108. }
  109. .ii {
  110. width: 30upx;
  111. height: 30upx;
  112. display: block;
  113. margin-left: 12upx;
  114. }
  115. .actives {
  116. color: #F0AD4E;
  117. }
  118. .ibox {
  119. display: flex;
  120. align-items: center;
  121. }
  122. .top_kbox {
  123. display: flex;
  124. justify-content: space-between;
  125. align-items: center;
  126. background-color: #FFFFFF;
  127. padding: 28upx 5%;
  128. position: fixed;
  129. top: 0upx;
  130. width: 90%;
  131. z-index: 99;
  132. /* #ifdef APP-PLUS */
  133. top: 0;
  134. /* #endif */
  135. }
  136. .boxa {
  137. padding-top: 84upx;
  138. position: relative;
  139. }
  140. </style>