pictureCube.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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="aspectFit" ></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. console.log(url.link);
  108. let urls = url.link
  109. this.$util.JumpPath(urls);
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss">
  115. .pageOn {
  116. border-radius: 24rpx !important;
  117. .advertItem01 {
  118. image {
  119. border-radius: 20rpx;
  120. }
  121. }
  122. .advertItem02 {
  123. .item {
  124. &:nth-child(1) {
  125. image {
  126. border-radius: 20rpx 0 0 20rpx
  127. }
  128. }
  129. &:nth-child(2) {
  130. image {
  131. border-radius: 0 20rpx 20rpx 0
  132. }
  133. }
  134. }
  135. }
  136. .advertItem03 {
  137. .item {
  138. &:nth-child(1) {
  139. image {
  140. border-radius: 20rpx 0 0 20rpx
  141. }
  142. }
  143. &:nth-child(2) {
  144. image {
  145. border-radius: 0
  146. }
  147. }
  148. &:nth-child(3) {
  149. image {
  150. border-radius: 0 20rpx 20rpx 0
  151. }
  152. }
  153. }
  154. }
  155. .advertItem04 {
  156. .item {
  157. &:nth-child(1) {
  158. image {
  159. border-radius: 20rpx 0 0 20rpx
  160. }
  161. }
  162. &:nth-child(2) {
  163. .pic {
  164. &:nth-child(1) {
  165. image {
  166. border-radius: 0 20rpx 0 0
  167. }
  168. }
  169. &:nth-child(2) {
  170. image {
  171. border-radius: 0 0 20rpx 0
  172. }
  173. }
  174. }
  175. }
  176. }
  177. }
  178. .advertItem05 {
  179. .item {
  180. &:nth-child(1) {
  181. image {
  182. border-radius: 20rpx 0 0 20rpx
  183. }
  184. }
  185. &:nth-child(2) {
  186. image {
  187. border-radius: 0
  188. }
  189. }
  190. &:nth-child(4) {
  191. image {
  192. border-radius: 0 20rpx 20rpx 0
  193. }
  194. }
  195. }
  196. }
  197. .advertItem06 {
  198. .item {
  199. &:nth-child(1) {
  200. image {
  201. border-radius: 20rpx 0 0 0
  202. }
  203. }
  204. &:nth-child(2) {
  205. image {
  206. border-radius: 0 20rpx 0 0
  207. }
  208. }
  209. &:nth-child(3) {
  210. image {
  211. border-radius: 0 0 0 20rpx
  212. }
  213. }
  214. &:nth-child(4) {
  215. image {
  216. border-radius: 0 0 20rpx 0
  217. }
  218. }
  219. }
  220. }
  221. }
  222. .pictureCube {
  223. background-color: #fff;
  224. .advertItem01 {
  225. width: 100%;
  226. height: auto;
  227. image {
  228. width: 100%;
  229. height: 100%;
  230. display: block;
  231. }
  232. }
  233. .advertItem02 {
  234. // /deep/uni-image>img{
  235. // position: unset;
  236. // }
  237. width: 100%;
  238. .item {
  239. width: 50%;
  240. height: auto;
  241. image {
  242. width: 100%;
  243. height: 100%;
  244. display: block;
  245. }
  246. }
  247. }
  248. .advertItem03 {
  249. .item {
  250. width: 33.3333%;
  251. }
  252. }
  253. .advertItem04 {
  254. width: 100%;
  255. .item {
  256. width: 50%;
  257. height: 376rpx;
  258. .pic {
  259. width: 100%;
  260. height: 188rpx;
  261. }
  262. image {
  263. width: 100%;
  264. height: 100%;
  265. display: block;
  266. }
  267. }
  268. }
  269. .advertItem05 {
  270. .item {
  271. width: 25%;
  272. }
  273. }
  274. .advertItem06 {
  275. .item {
  276. width: 50%;
  277. height: 188rpx;
  278. }
  279. }
  280. }
  281. </style>