pictureCube.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <view class="pictureCube skeleton-rect" :class="{pageOn:bgStyle===1}"
  3. :style="{margin:'0 '+prConfig*2+'rpx',marginTop:slider*2+'rpx',background:bgColor}" v-if="picList.length"
  4. v-show="!isSortType">
  5. <view class="advertItem01" v-for="(item,index) in picList" :key="index" v-if="style==0" @click="goDetail(item)">
  6. <image :src="item.image" mode="widthFix"></image>
  7. </view>
  8. <view class="advertItem02 acea-row" v-if="style==1">
  9. <view class="item" v-for="(item,index) in picList" :key="index" @click="goDetail(item)">
  10. <image :src="item.image" mode="widthFix" :style="'height:'+ imageH +'rpx;'"></image>
  11. </view>
  12. </view>
  13. <view class="advertItem02 advertItem03 acea-row" v-if="style==2">
  14. <view class="item" v-for="(item,index) in picList" :key="index" @click="goDetail(item)">
  15. <image :src="item.image" mode="widthFix":style="'height:'+ imageH +'rpx;'"></image>
  16. </view>
  17. </view>
  18. <view class="advertItem04 acea-row" v-if="style==3">
  19. <view class="item" @click="goDetail(picList[0])">
  20. <image :src="picList[0].image"></image>
  21. </view>
  22. <view class="item">
  23. <view class="pic" @click="goDetail(picList[1])">
  24. <image :src="picList[1].image"></image>
  25. </view>
  26. <view class="pic" @click="goDetail(picList[2])">
  27. <image :src="picList[2].image"></image>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="advertItem02 advertItem05 acea-row" v-if="style==4">
  32. <view class="item" v-for="(item,index) in picList" :key="index" @click="goDetail(item)">
  33. <image :src="item.image" mode="aspectFill" :style="'height:'+ imageH +'rpx;'"></image>
  34. </view>
  35. </view>
  36. <view class="advertItem02 advertItem06 acea-row" v-if="style==5">
  37. <view class="item" v-for="(item,index) in picList" :key="index" @click="goDetail(item)">
  38. <image :src="item.image" mode="aspectFill"></image>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. name: 'pictureCube',
  46. props: {
  47. dataConfig: {
  48. type: Object,
  49. default: () => {}
  50. },
  51. isSortType: {
  52. type: String | Number,
  53. default: 0
  54. }
  55. },
  56. data() {
  57. return {
  58. picList: this.dataConfig.picStyle.picList,
  59. style: this.dataConfig.tabConfig.tabVal,
  60. bgStyle: this.dataConfig.bgStyle.type,
  61. prConfig: this.dataConfig.prConfig.val,
  62. slider: this.dataConfig.mbConfig.val,
  63. bgColor: this.dataConfig.bgColor.color[0].item,
  64. widthC: '',
  65. imageH: ''
  66. };
  67. },
  68. mounted() {
  69. if (this.picList.length) {
  70. let that = this;
  71. this.$nextTick((e) => {
  72. if (this.style == 1) {
  73. this.widthC = 375
  74. } else if (this.style == 2) {
  75. this.widthC = 250
  76. } else if (this.style == 4) {
  77. this.widthC = 188
  78. }
  79. uni.getImageInfo({
  80. src: that.setDomain(that.picList[0].image),
  81. success: (res) => {
  82. if (res && res.height > 0) {
  83. let height = res.height * ((that.widthC - that.prConfig * 2) / res
  84. .width)
  85. that.$set(that, 'imageH', height);
  86. } else {
  87. that.$set(that, 'imageH', (that.widthC - that.prConfig * 2) * 2);
  88. }
  89. },
  90. fail: function(error) {
  91. that.$set(that, 'imageH', (that.widthC - that.prConfig * 2) * 2);
  92. }
  93. })
  94. })
  95. }
  96. },
  97. created() {},
  98. methods: {
  99. //替换安全域名
  100. setDomain: function(url) {
  101. url = url ? url.toString() : '';
  102. //本地调试打开,生产请注销
  103. if (url.indexOf("https://") > -1) return url;
  104. else return url.replace('http://', 'https://');
  105. },
  106. goDetail(url) {
  107. let urls = url.link
  108. this.$util.JumpPath(urls);
  109. }
  110. }
  111. }
  112. </script>
  113. <style lang="scss">
  114. .pageOn {
  115. border-radius: 24rpx !important;
  116. .advertItem01 {
  117. image {
  118. border-radius: 20rpx;
  119. }
  120. }
  121. .advertItem02 {
  122. .item {
  123. &:nth-child(1) {
  124. image {
  125. border-radius: 20rpx 0 0 20rpx
  126. }
  127. }
  128. &:nth-child(2) {
  129. image {
  130. border-radius: 0 20rpx 20rpx 0
  131. }
  132. }
  133. }
  134. }
  135. .advertItem03 {
  136. .item {
  137. &:nth-child(1) {
  138. image {
  139. border-radius: 20rpx 0 0 20rpx
  140. }
  141. }
  142. &:nth-child(2) {
  143. image {
  144. border-radius: 0
  145. }
  146. }
  147. &:nth-child(3) {
  148. image {
  149. border-radius: 0 20rpx 20rpx 0
  150. }
  151. }
  152. }
  153. }
  154. .advertItem04 {
  155. .item {
  156. &:nth-child(1) {
  157. image {
  158. border-radius: 20rpx 0 0 20rpx
  159. }
  160. }
  161. &:nth-child(2) {
  162. .pic {
  163. &:nth-child(1) {
  164. image {
  165. border-radius: 0 20rpx 0 0
  166. }
  167. }
  168. &:nth-child(2) {
  169. image {
  170. border-radius: 0 0 20rpx 0
  171. }
  172. }
  173. }
  174. }
  175. }
  176. }
  177. .advertItem05 {
  178. .item {
  179. &:nth-child(1) {
  180. image {
  181. border-radius: 20rpx 0 0 20rpx
  182. }
  183. }
  184. &:nth-child(2) {
  185. image {
  186. border-radius: 0
  187. }
  188. }
  189. &:nth-child(4) {
  190. image {
  191. border-radius: 0 20rpx 20rpx 0
  192. }
  193. }
  194. }
  195. }
  196. .advertItem06 {
  197. .item {
  198. &:nth-child(1) {
  199. image {
  200. border-radius: 20rpx 0 0 0
  201. }
  202. }
  203. &:nth-child(2) {
  204. image {
  205. border-radius: 0 20rpx 0 0
  206. }
  207. }
  208. &:nth-child(3) {
  209. image {
  210. border-radius: 0 0 0 20rpx
  211. }
  212. }
  213. &:nth-child(4) {
  214. image {
  215. border-radius: 0 0 20rpx 0
  216. }
  217. }
  218. }
  219. }
  220. }
  221. .pictureCube {
  222. background-color: #fff;
  223. .advertItem01 {
  224. width: 100%;
  225. height: auto;
  226. image {
  227. width: 100%;
  228. height: 100%;
  229. display: block;
  230. }
  231. }
  232. .advertItem02 {
  233. // /deep/uni-image>img{
  234. // position: unset;
  235. // }
  236. width: 100%;
  237. .item {
  238. width: 50%;
  239. height: auto;
  240. image {
  241. width: 100%;
  242. height: 100%;
  243. display: block;
  244. }
  245. }
  246. }
  247. .advertItem03 {
  248. .item {
  249. width: 33.3333%;
  250. }
  251. }
  252. .advertItem04 {
  253. width: 100%;
  254. .item {
  255. width: 50%;
  256. height: 376rpx;
  257. .pic {
  258. width: 100%;
  259. height: 188rpx;
  260. }
  261. image {
  262. width: 100%;
  263. height: 100%;
  264. display: block;
  265. }
  266. }
  267. }
  268. .advertItem05 {
  269. .item {
  270. width: 25%;
  271. }
  272. }
  273. .advertItem06 {
  274. .item {
  275. width: 50%;
  276. height: 188rpx;
  277. }
  278. }
  279. }
  280. </style>