pictureCube.vue 16 KB

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