Blame view
src/pages/detailsChoiceArgs/compoents/MyCollapse.vue
6.55 KB
ab4209caf update |
1 2 3 4 5 6 |
<template> <!-- 折叠框 --> <view class="myCollapse"> <view class="head"> <view>{{title}}</view> <view v-if="title==='折射率'" class="headMid">注:折射率越高,镜片越薄,看着更美观。</view> |
eab89b254 updates |
7 |
<view class="headRighted" v-if="isOpen" @click="myCollapseChange(isOpen)"></view> |
ab4209caf update |
8 9 10 |
<view class="headRight" v-else @click="myCollapseChange(isOpen)" ></view> </view> <view class="body"> |
eab89b254 updates |
11 12 13 |
<block v-if="isOpen"> |
ab4209caf update |
14 |
<view style="background-color: #FFFFFF;" class="funBox"> |
eab89b254 updates |
15 |
<block v-if="title==='镜片种类'"> |
ab4209caf update |
16 |
<view class="noRange"> |
eab89b254 updates |
17 18 19 |
<block v-for="(item) in funList" :key="item.key"> <view v-bind:class="item.isChioce?'boxChoiced':'boxChoice'" @click="choice(item.key-1,item.isChioce)">{{item.name}}</view> |
ab4209caf update |
20 21 22 23 |
</block> </view> <view class="noRange"> <block v-for="(item,index) in funList2" :key="item.key"> |
eab89b254 updates |
24 |
<view v-bind:class="item.isChioce?'boxChoiced-C':'boxChoice-C'" |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
25 |
:style="colorList[index]" @click="choice2(index,item.isChioce)"></view> |
ab4209caf update |
26 27 |
</block> </view> |
eab89b254 updates |
28 29 30 |
</block> <block v-else> <view class="range" v-for="(item) in funList" :key="item.key">{{item.range}}</view> |
ab4209caf update |
31 |
<view class="noRange"> |
eab89b254 updates |
32 33 34 |
<block v-for="(item) in funList" :key="item.key"> <view v-bind:class="item.isChioce?'boxChoiced':'boxChoice'" @click="choice(item.key-1,item.isChioce)">{{item.name}}</view> |
ab4209caf update |
35 36 |
</block> </view> |
eab89b254 updates |
37 |
|
ab4209caf update |
38 39 40 |
<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"> |
eab89b254 updates |
41 |
<view v-bind:class="item.isChioce?'boxChoiced':'boxChoice'" |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
42 |
@click="choice2(index,item.isChioce)">{{item.name}}</view> |
ab4209caf update |
43 44 |
</block> </view> |
eab89b254 updates |
45 |
</block> |
ab4209caf update |
46 47 |
</view> </block> |
eab89b254 updates |
48 |
|
ab4209caf update |
49 |
<block v-else> |
eab89b254 updates |
50 51 52 |
*<block v-for="(item,index) in funContent" :key="index"> <text v-if="item!==null">{{item}}</text> </block> |
ab4209caf update |
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
</block> </view> </view> </template> <script> export default { props:{ isOpenProps:{ // 是否展开,默认 true type: Boolean, default: true }, |
eab89b254 updates |
67 68 69 70 |
funListProp:{ "name":String, "isChioce": Number, "key":Number |
ab4209caf update |
71 |
}, |
eab89b254 updates |
72 |
funList2Prop:{ |
ab4209caf update |
73 |
type:Array, |
ab4209caf update |
74 75 |
} , |
eab89b254 updates |
76 77 |
funContentProp: { type: Array |
ab4209caf update |
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
}, 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%);" |
eab89b254 updates |
94 95 96 97 |
], funList: this.funListProp, funList2: this.funList2Prop, funContent: this.funContentProp |
ab4209caf update |
98 99 |
}; }, |
eab89b254 updates |
100 |
|
ab4209caf update |
101 102 103 104 105 |
methods:{ myCollapseChange(isopen){ this.isOpen = !isopen }, choice(index,isChoice){ |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
106 107 108 109 110 111 112 113 |
if(this.funList[index].type==="fun"){ this.funList[index].isChioce = !isChoice if(!isChoice){ this.funContent[index] = this.funList[index].name } else{ this.funContent[index] = '' } |
ab4209caf update |
114 |
} |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
else if(this.funList[index].type==="kind"){ for(let i=0;i<this.funList.length;i++){ this.funList[i].isChioce = false } this.funList[index].isChioce = !isChoice this.funContent[0]=this.funList[index].name }else { for(let i=0;i<this.funList.length;i++){ this.funList[i].isChioce = false } for(let i=0;i<this.funList2.length;i++){ this.funList2[i].isChioce = false } this.funList[index].isChioce = !isChoice this.funContent[0]=this.funList[index].name |
ab4209caf update |
130 131 |
} }, |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
132 133 134 135 136 137 138 |
choice2(index,isChoice){ if(this.funList2[index].type==="kind"){ for(let i=0;i<this.funList2.length;i++){ this.funList2[i].isChioce = false } this.funList2[index].isChioce = !isChoice this.funContent[1] = this.funList2[index].name |
ab4209caf update |
139 140 |
} else{ |
7d2bdf29e 修改镜片选购逻辑 添加购物车和用户... |
141 142 143 144 145 146 147 148 |
for(let i=0;i<this.funList.length;i++){ this.funList[i].isChioce = false } for(let i=0;i<this.funList2.length;i++){ this.funList2[i].isChioce = false } this.funList2[index].isChioce = !isChoice this.funContent[0]=this.funList2[index].name |
ab4209caf update |
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 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
} } } } </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> |