Blame view
src/pages/detailsChoiceArgs/compoents/MyCollapse.vue
5.88 KB
ab4209caf update |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
<template> <!-- 折叠框 --> <view class="myCollapse"> <view class="head"> <view>{{title}}</view> <view v-if="title==='折射率'" class="headMid">注:折射率越高,镜片越薄,看着更美观。</view> <view class="headRighted" v-if="this.isOpen" @click="myCollapseChange(isOpen)"></view> <view class="headRight" v-else @click="myCollapseChange(isOpen)" ></view> </view> <view class="body"> <block v-if="this.isOpen"> <view style="background-color: #FFFFFF;" class="funBox"> <template v-if="title==='镜片种类'"> <view class="noRange"> <block v-for="(item,index) in funList" :key="item.key"> <view class="boxChoiced" v-if="item.isChioce" @click="choice(item.key-1,item.isChioce)">{{item.name}}</view> <view class="boxChoice" v-else @click="choice(item.key-1,item.isChioce)">{{item.name}}</view> </block> </view> <view class="noRange"> <block v-for="(item,index) in funList2" :key="item.key"> <view class="boxChoiced-C" :style="colorList[index]" v-if="item.isChioce" @click="choice2(index,item.key-1,item.isChioce)"></view> <view class="boxChoice-C" :style="colorList[index]" v-else @click="choice2(index,item.key-1,item.isChioce)"></view> </block> </view> </template> <template v-else> <view class="range" v-for="(item,index) in funList" :key="item.key">{{item.range}}</view> <view class="noRange"> <block v-for="(item,index) in funList" :key="item.key"> <view class="boxChoiced" v-if="item.isChioce" @click="choice(item.key-1,item.isChioce)">{{item.name}}</view> <view class="boxChoice" v-else @click="choice(item.key-1,item.isChioce)">{{item.name}}</view> </block> </view> <!-- 手动换行 --> <view class="range" v-for="(item) in funList2" :key="item.key">{{item.range}}</view> <view class="noRange" style="max-width: 624rpx"> <block v-for="(item,index) in funList2" :key="item.key"> <view class="boxChoiced" v-if="item.isChioce" @click="choice2(index,item.key-1,item.isChioce)">{{item.name}}</view> <view class="boxChoice" v-else @click="choice2(index,item.key-1,item.isChioce)">{{item.name}}</view> </block> </view> </template> </view> </block> <block v-else> *<text v-for="(item,index) in funContent" :key="index">{{item}}</text> </block> </view> </view> </template> <script> export default { props:{ isOpenProps:{ // 是否展开,默认 true type: Boolean, default: true }, funList:{ type: Array, default: [] }, funList2:{ type:Array, } , funContent: { type: Array, default: [] }, title:{ type: String, default: '' } }, data() { return { isOpen:this.isOpenProps, // 颜色数组要与传入的值手动相同 colorList:[ "background-image: linear-gradient(180deg, #ECEAEA 1%, #f2f2f2 100%);", "background-image: linear-gradient(180deg, #ECEAEA 1%, #8D8C8C 100%);", "background-image: linear-gradient(180deg, #AEA8A8 1%, #624B3F 100%);", "background-image: linear-gradient(180deg, #AEA096 1%, #5E3521 100%);", "background-image: linear-gradient(180deg, #6F6864 1%, #352B26 100%);" ] }; }, methods:{ myCollapseChange(isopen){ this.isOpen = !isopen }, choice(index,isChoice){ this.funList[index].isChioce = !isChoice if(!isChoice){ this.funContent[index] = this.funList[index].name } else{ this.funContent[index] = '' } }, choice2(index,conIndex,isChoice){ this.funList2[index].isChioce = !isChoice if(!isChoice){ this.funContent[conIndex] = this.funList2[index].name } else{ this.funContent[conIndex] = '' } } } } </script> <style lang="scss"> .myCollapse{ width: 100%; padding-bottom: 28rpx; margin-top: 7px; border-bottom: 1px solid #E9E9E9; .head{ display: flex; justify-content: space-between; height: 24px; // font-family: PingFangSC-Medium; font-size: 16px; color: #333333; letter-spacing: -0.3px; text-align: justify; line-height: 24px; margin-bottom: 18rpx; .headRighted{ width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 4px solid #CFCFCF; transform: scaleY(-1); margin-top: 10px; } .headMid{ // font-family: PingFangSC-Regular; font-size: 10px; color: #999999; letter-spacing: -0.19px; margin-left: -120rpx; } .headRight{ width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 4px solid #CFCFCF; margin-top: 10px; } } .body{ // font-family: PingFangSC-Regular; font-size: 12px; color: #666666; letter-spacing: 0; display: flex; flex-wrap: wrap; text{ padding-left: 4px; } } } .funBox { // display: flex; width: 100%; // flex-wrap: wrap; // max-width: 624rpx; .range{ // font-family: PingFangSC-Regular; font-size: 10px; color: #999999; letter-spacing: -0.19px; margin-bottom: 5px; } .noRange{ display: flex; flex-wrap: wrap; // max-width: 624rpx; // margin-bottom: 28rpx; .boxChoiced,.boxChoice{ height: 60rpx; border-radius: 4rpx; // font-family: PingFangSC-Regular; font-size: 12px; letter-spacing: 0; line-height: 60rpx; box-sizing: border-box; padding: 0 20rpx; margin-right: 20rpx; margin-bottom: 13rpx; } .boxChoiced{ background: rgba(255,107,74,0.15); color: #FF6B4A; } .boxChoice{ background: #F2F2F2; color: #666666; } .boxChoiced-C,.boxChoice-C{ width: 64rpx; height: 64rpx; border-radius: 32rpx; margin-right: 8px; } .boxChoiced-C{ opacity: 0.7; border: 1px solid #FF6B4A; } .boxChoice-C{ opacity: 0.7; border: 1px solid #FFFFFF; } } } </style> |