pictureCube.vue 7.2 KB

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