pictureCube.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. <template>
  2. <!-- 图片魔方 -->
  3. <view class="pictureCube" :style="{
  4. padding: `0 ${dataConfig.prConfig.val*2}rpx`,
  5. marginTop: `${dataConfig.mbConfig.val*2}rpx`,
  6. background: dataConfig.bottomBgColor.color[0].item
  7. }" v-if="picList.length">
  8. <view class="advert1" v-if="style==0">
  9. <view class="item" v-for="(item,index) in picList" :key="index" :style="[imgGap]" @click="goDetail(item)">
  10. <easy-loadimage mode="widthFix" width="100%" :height="imageH + 'px'" :image-src="item.image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  11. </view>
  12. </view>
  13. <view class="advert2" v-else-if="style==1">
  14. <view class="item" v-for="(item,index) in picList" :key="index" :style="[imgGap]" @click="goDetail(item)">
  15. <easy-loadimage mode="aspectFill" width="100%" :height="imageH + 'rpx'" :image-src="item.image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  16. </view>
  17. </view>
  18. <view class="advert3" v-else-if="style==2">
  19. <view class="item" v-for="(item,index) in picList" :key="index" :style="[imgGap]" @click="goDetail(item)">
  20. <easy-loadimage mode="aspectFill" width="100%" :height="imageH + 'rpx'" :image-src="item.image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  21. </view>
  22. </view>
  23. <view class="advert4" :style="[autoHeight]" v-else-if="style==3">
  24. <view class="item">
  25. <view class="pic" :style="[imgGap]" @click="goDetail(picList[0])">
  26. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="picList[0].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  27. </view>
  28. <view class="pic" :style="[imgGap]" @click="goDetail(picList[1])">
  29. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="picList[1].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  30. </view>
  31. </view>
  32. <view class="item" :style="[imgGap]" @click="goDetail(picList[2])">
  33. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="picList[2].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  34. </view>
  35. </view>
  36. <view class="advert5" :style="[autoHeight]" v-else-if="style==4">
  37. <view class="item" :style="[imgGap]" @click="goDetail(picList[0])">
  38. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="picList[0].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  39. </view>
  40. <view class="item">
  41. <view class="pic" :style="[imgGap]" @click="goDetail(picList[1])">
  42. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="picList[1].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  43. </view>
  44. <view class="pic" :style="[imgGap]" @click="goDetail(picList[2])">
  45. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="picList[2].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="advert6" :style="[autoHeight]" v-else-if="style==5">
  50. <view class="item" :style="[imgGap]" @click="goDetail(picList[0])">
  51. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="picList[0].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  52. </view>
  53. <view class="item">
  54. <view class="pic" :style="[imgGap]" @click="goDetail(picList[1])">
  55. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="picList[1].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  56. </view>
  57. <view class="pic" :style="[imgGap]" @click="goDetail(picList[2])">
  58. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="picList[2].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="advert7" :style="[autoHeight]" v-else-if="style==6">
  63. <view class="item">
  64. <view class="pic" :style="[imgGap]" @click="goDetail(picList[0])">
  65. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="picList[0].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  66. </view>
  67. <view class="pic" :style="[imgGap]" @click="goDetail(picList[1])">
  68. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="picList[1].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  69. </view>
  70. </view>
  71. <view class="item" :style="[imgGap]" @click="goDetail(picList[2])">
  72. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="picList[2].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  73. </view>
  74. </view>
  75. <view class="advert8" :style="[autoHeight]" v-else-if="style==7">
  76. <view class="item" :style="[imgGap]" v-for="(item,index) in picList" @click="goDetail(item)">
  77. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="item.image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  78. </view>
  79. </view>
  80. <view class="advert9" :style="[autoHeight]" v-else-if="style==8">
  81. <view class="item">
  82. <view class="pic" :style="[imgGap]" @click="goDetail(picList[0])">
  83. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="picList[0].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  84. </view>
  85. <view class="pic" :style="[imgGap]" @click="goDetail(picList[1])">
  86. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="picList[1].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  87. </view>
  88. </view>
  89. <view class="item">
  90. <view class="pic" :style="[imgGap]" @click="goDetail(picList[2])">
  91. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="picList[2].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  92. </view>
  93. <view class="pic" :style="[imgGap]" @click="goDetail(picList[3])">
  94. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="picList[3].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  95. </view>
  96. <view class="pic" :style="[imgGap]" @click="goDetail(picList[4])">
  97. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="picList[4].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  98. </view>
  99. </view>
  100. </view>
  101. <view class="advert10" :style="[autoHeight]" v-else-if="style==9">
  102. <view class="item" :style="[imgGap]" @click="goDetail(picList[0])">
  103. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="picList[0].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  104. </view>
  105. <view class="item">
  106. <view class="pic-wrap">
  107. <view class="pic" :style="[imgGap]" @click="goDetail(picList[1])">
  108. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="picList[1].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  109. </view>
  110. </view>
  111. <view class="pic-wrap">
  112. <view class="pic" :style="[imgGap]" @click="goDetail(picList[2])">
  113. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="picList[2].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  114. </view>
  115. <view class="pic" :style="[imgGap]" @click="goDetail(picList[3])">
  116. <easy-loadimage mode="aspectFill" width="100%" height="100%" :image-src="picList[3].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  117. </view>
  118. </view>
  119. </view>
  120. </view>
  121. <view class="advert11" v-else-if="style==10">
  122. <view class="pic" :style="[imgGap]" @click="goDetail(picList[0])">
  123. <easy-loadimage mode="aspectFill" width="100%" :height="imageH + 'px'" :image-src="picList[0].image" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  124. </view>
  125. </view>
  126. <view class="advert12" :style="[autoHeight]" v-else-if="style==11">
  127. <template v-if="dataConfig.picStyle.docPicList.length">
  128. <view v-for="(item,index) in dataConfig.picStyle.docPicList" :key="index" :style="{
  129. top: `${item.doc.startY*2}rpx`,
  130. left: `${item.doc.startX*2}rpx`,
  131. width: `${item.doc.w*2}rpx`,
  132. height: `${item.doc.h*2}rpx`,
  133. borderWidth: `${dataConfig.imgConfig.val*2}rpx`,
  134. }" class="item" @click="goDetail(item)">
  135. <easy-loadimage mode="aspectFill" width="100%" height="100%" :imageSrc="item.img" class="image" :borderRadius="imgBorderRadius"></easy-loadimage>
  136. </view>
  137. </template>
  138. </view>
  139. </view>
  140. </template>
  141. <script>
  142. export default {
  143. name: 'pictureCube',
  144. props: {
  145. dataConfig: {
  146. type: Object,
  147. default: () => {}
  148. },
  149. },
  150. data() {
  151. return {
  152. picList: this.dataConfig.picStyle.picList,
  153. style: this.dataConfig.styleConfig.tabVal,
  154. imageH: 0,
  155. };
  156. },
  157. computed: {
  158. filletImg() {
  159. let borderRadius = `${this.dataConfig.filletImg.val * 2}rpx`;
  160. if (this.dataConfig.filletImg.type) {
  161. borderRadius =
  162. `${this.dataConfig.filletImg.valList[0].val * 2}rpx ${this.dataConfig.filletImg.valList[1].val * 2}rpx ${this.dataConfig.filletImg.valList[2].val * 2}rpx ${this.dataConfig.filletImg.valList[3].val * 2}rpx`;
  163. }
  164. return {
  165. 'border-radius': borderRadius,
  166. }
  167. },
  168. imgGap() {
  169. return {
  170. borderWidth: `${this.dataConfig.imgConfig.val*2}rpx`,
  171. }
  172. },
  173. imgBorderRadius() {
  174. let borderRadius = `${this.dataConfig.filletImg.val * 2}rpx`;
  175. if (this.dataConfig.filletImg.type) {
  176. borderRadius =
  177. `${this.dataConfig.filletImg.valList[0].val * 2}rpx ${this.dataConfig.filletImg.valList[1].val * 2}rpx ${this.dataConfig.filletImg.valList[2].val * 2}rpx ${this.dataConfig.filletImg.valList[3].val * 2}rpx`;
  178. }
  179. return borderRadius
  180. },
  181. autoHeight(){
  182. let windowWidth = uni.getSystemInfoSync().windowWidth;
  183. return {
  184. height: windowWidth + 'px'
  185. }
  186. },
  187. },
  188. mounted() {
  189. this.computedHeight();
  190. },
  191. methods: {
  192. //替换安全域名
  193. setDomain: function(url) {
  194. url = url ? url.toString() : '';
  195. //本地调试打开,生产请注销
  196. if (url.indexOf("https://") > -1) return url;
  197. else return url.replace('http://', 'https://');
  198. },
  199. goDetail(url) {
  200. let urls = url.link;
  201. uni.navigateTo({
  202. url: urls
  203. })
  204. // this.$util.JumpPath(urls);
  205. },
  206. computedHeight(){
  207. if(this.picList.length){
  208. let that = this;
  209. let windowWidth = uni.getSystemInfoSync().windowWidth;
  210. this.$nextTick((e)=>{
  211. if (this.style == 0){
  212. this.imageH = windowWidth / 2;
  213. }else if([1,2].includes(this.style)){
  214. uni.getImageInfo({
  215. src: that.setDomain(that.picList[0].image),
  216. success: (res) => {
  217. if (res && res.height > 0) {
  218. let height = res.height * ((this.style == 1 ? 375 : 250 - that.dataConfig.prConfig.val * 2) / res.width)
  219. that.$set(that, 'imageH', height);
  220. } else {
  221. that.$set(that, 'imageH', (this.style == 1 ? 375 : 250 - that.dataConfig.prConfig.val * 2)*2);
  222. }
  223. },
  224. fail: function(error) {
  225. that.$set(that, 'imageH', (this.style == 1 ? 375 : 250 - that.dataConfig.prConfig.val*2)*2);
  226. }
  227. })
  228. }else if(this.style == 10){
  229. uni.getImageInfo({
  230. src: that.setDomain(that.picList[0].image),
  231. success: (image) => {
  232. this.imageH = image.height * windowWidth / image.width;
  233. }
  234. })
  235. }
  236. })
  237. }
  238. }
  239. }
  240. }
  241. </script>
  242. <style lang="scss">
  243. .pageOn {
  244. border-radius: 24rpx !important;
  245. .advertItem01 {
  246. image {
  247. border-radius: 20rpx;
  248. }
  249. }
  250. .advertItem02 {
  251. .item {
  252. &:nth-child(1) {
  253. image {
  254. border-radius: 20rpx 0 0 20rpx
  255. }
  256. }
  257. &:nth-child(2) {
  258. image {
  259. border-radius: 0 20rpx 20rpx 0
  260. }
  261. }
  262. }
  263. }
  264. .advertItem03 {
  265. .item {
  266. &:nth-child(1) {
  267. image {
  268. border-radius: 20rpx 0 0 20rpx
  269. }
  270. }
  271. &:nth-child(2) {
  272. image {
  273. border-radius: 0
  274. }
  275. }
  276. &:nth-child(3) {
  277. image {
  278. border-radius: 0 20rpx 20rpx 0
  279. }
  280. }
  281. }
  282. }
  283. .advertItem04 {
  284. .item {
  285. &:nth-child(1) {
  286. image {
  287. border-radius: 20rpx 0 0 20rpx
  288. }
  289. }
  290. &:nth-child(2) {
  291. .pic {
  292. &:nth-child(1) {
  293. image {
  294. border-radius: 0 20rpx 0 0
  295. }
  296. }
  297. &:nth-child(2) {
  298. image {
  299. border-radius: 0 0 20rpx 0
  300. }
  301. }
  302. }
  303. }
  304. }
  305. }
  306. .advertItem05 {
  307. .item {
  308. &:nth-child(1) {
  309. image {
  310. border-radius: 20rpx 0 0 20rpx
  311. }
  312. }
  313. &:nth-child(2) {
  314. image {
  315. border-radius: 0
  316. }
  317. }
  318. &:nth-child(4) {
  319. image {
  320. border-radius: 0 20rpx 20rpx 0
  321. }
  322. }
  323. }
  324. }
  325. .advertItem06 {
  326. .item {
  327. &:nth-child(1) {
  328. image {
  329. border-radius: 20rpx 0 0 0
  330. }
  331. }
  332. &:nth-child(2) {
  333. image {
  334. border-radius: 0 20rpx 0 0
  335. }
  336. }
  337. &:nth-child(3) {
  338. image {
  339. border-radius: 0 0 0 20rpx
  340. }
  341. }
  342. &:nth-child(4) {
  343. image {
  344. border-radius: 0 0 20rpx 0
  345. }
  346. }
  347. }
  348. }
  349. }
  350. .pictureCube {
  351. display: flex;
  352. background-color: #fff;
  353. .item {
  354. border-width: 0;
  355. border-style: solid;
  356. border-color: transparent;
  357. }
  358. .pic {
  359. border-width: 0;
  360. border-style: solid;
  361. border-color: transparent;
  362. }
  363. .advert1 {
  364. flex: 1;
  365. display: flex;
  366. flex-direction: column;
  367. .item {
  368. flex: 1;
  369. min-height: 0;
  370. border-style: solid;
  371. }
  372. .image {
  373. display: block;
  374. width: 100%;
  375. height: 100%;
  376. }
  377. }
  378. .advert2 {
  379. flex: 1;
  380. display: flex;
  381. .item {
  382. flex: 1;
  383. min-width: 0;
  384. }
  385. .image {
  386. display: block;
  387. width: 100%;
  388. height: 100%;
  389. }
  390. }
  391. .advert3 {
  392. flex: 1;
  393. display: flex;
  394. .item {
  395. flex: 1;
  396. min-width: 0;
  397. }
  398. .image {
  399. display: block;
  400. width: 100%;
  401. height: 100%;
  402. }
  403. }
  404. .advert4 {
  405. flex: 1;
  406. display: flex;
  407. flex-direction: column;
  408. .item {
  409. flex: 1;
  410. min-height: 0;
  411. &:nth-child(1) {
  412. display: flex;
  413. .pic {
  414. flex: 1;
  415. min-width: 0;
  416. }
  417. }
  418. }
  419. .image {
  420. display: block;
  421. width: 100%;
  422. height: 100%;
  423. }
  424. }
  425. .advert5 {
  426. flex: 1;
  427. display: flex;
  428. flex-direction: column;
  429. .item {
  430. flex: 1;
  431. min-height: 0;
  432. &:nth-child(2) {
  433. display: flex;
  434. .pic {
  435. flex: 1;
  436. }
  437. }
  438. }
  439. .image {
  440. display: block;
  441. width: 100%;
  442. height: 100%;
  443. }
  444. }
  445. .advert6 {
  446. flex: 1;
  447. display: flex;
  448. .item {
  449. flex: 1;
  450. min-width: 0;
  451. &:nth-child(2) {
  452. display: flex;
  453. flex-direction: column;
  454. .pic {
  455. flex: 1;
  456. min-height: 0;
  457. }
  458. }
  459. }
  460. .image {
  461. display: block;
  462. width: 100%;
  463. height: 100%;
  464. }
  465. }
  466. .advert7 {
  467. flex: 1;
  468. display: flex;
  469. .item {
  470. flex: 1;
  471. min-width: 0;
  472. &:nth-child(1) {
  473. display: flex;
  474. flex-direction: column;
  475. .pic {
  476. flex: 1;
  477. min-height: 0;
  478. }
  479. }
  480. }
  481. .image {
  482. display: block;
  483. width: 100%;
  484. height: 100%;
  485. }
  486. }
  487. .advert8 {
  488. flex: 1;
  489. display: flex;
  490. flex-wrap: wrap;
  491. .item {
  492. flex: 0 0 50%;
  493. min-width: 0;
  494. }
  495. .image {
  496. display: block;
  497. width: 100%;
  498. height: 100%;
  499. }
  500. }
  501. .advert9 {
  502. flex: 1;
  503. display: flex;
  504. flex-direction: column;
  505. .item {
  506. flex: 1;
  507. min-height: 0;
  508. display: flex;
  509. }
  510. .pic {
  511. flex: 1;
  512. min-width: 0;
  513. }
  514. .image {
  515. display: block;
  516. width: 100%;
  517. height: 100%;
  518. }
  519. }
  520. .advert10 {
  521. flex: 1;
  522. display: flex;
  523. .item {
  524. flex: 1;
  525. min-width: 0;
  526. &:nth-child(2) {
  527. display: flex;
  528. flex-direction: column;
  529. }
  530. }
  531. .pic-wrap {
  532. flex: 1;
  533. min-height: 0;
  534. display: flex;
  535. .pic {
  536. flex: 1;
  537. min-width: 0;
  538. }
  539. }
  540. .image {
  541. display: block;
  542. width: 100%;
  543. height: 100%;
  544. }
  545. }
  546. .advert11 {
  547. flex: 1;
  548. .pic {
  549. width: 100%;
  550. height: 100%;
  551. }
  552. .image {
  553. display: block;
  554. width: 100%;
  555. height: 100%;
  556. }
  557. }
  558. .advert12 {
  559. flex: 1;
  560. position: relative;
  561. .item {
  562. position: absolute;
  563. border-style: solid;
  564. border-color: transparent;
  565. }
  566. .image {
  567. display: block;
  568. width: 100%;
  569. height: 100%;
  570. }
  571. }
  572. .advertItem02 {
  573. // /deep/uni-image>img{
  574. // position: unset;
  575. // }
  576. width: 100%;
  577. .item {
  578. width: 50%;
  579. height: auto;
  580. image {
  581. width: 100%;
  582. height: 100%;
  583. display: block;
  584. }
  585. }
  586. }
  587. .advertItem03 {
  588. .item {
  589. width: 33.3333%;
  590. }
  591. }
  592. .advertItem04 {
  593. width: 100%;
  594. .item {
  595. width: 50%;
  596. height: 200px;
  597. .pic {
  598. width: 100%;
  599. height: 100px;
  600. }
  601. image {
  602. width: 100%;
  603. height: 100%;
  604. display: block;
  605. }
  606. }
  607. }
  608. .advertItem05 {
  609. .item {
  610. width: 25%;
  611. }
  612. }
  613. .advertItem06 {
  614. .item {
  615. width: 50%;
  616. height: 100px;
  617. }
  618. }
  619. }
  620. </style>