pictureCube.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <view :style="{background:bgColor,paddingTop:slider*2+'rpx'}" v-if="picList.length" v-show="!isSortType">
  3. <view class="pictureCube skeleton-rect" :class="{pageOn:bgStyle===1}" :style="{margin:'0 '+prConfig*2+'rpx',background:bgColor}">
  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" :style="'height:'+ imageH +'rpx;'" mode="widthFix"></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" :style="'height:'+ imageH +'rpx;'" mode="widthFix"></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"></image>
  20. </view>
  21. <view class="item">
  22. <view class="pic" @click="goDetail(picList[1])">
  23. <image :src="picList[1].image"></image>
  24. </view>
  25. <view class="pic" @click="goDetail(picList[2])">
  26. <image :src="picList[2].image"></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="aspectFill" :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"></image>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. // +----------------------------------------------------------------------
  45. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  46. // +----------------------------------------------------------------------
  47. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  48. // +----------------------------------------------------------------------
  49. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  50. // +----------------------------------------------------------------------
  51. // | Author: CRMEB Team <admin@crmeb.com>
  52. // +----------------------------------------------------------------------
  53. import {merPath} from "@/utils/index"
  54. export default {
  55. name: 'pictureCube',
  56. props: {
  57. dataConfig: {
  58. type: Object,
  59. default: () => {}
  60. },
  61. isSortType: {
  62. type: String | Number,
  63. default: 0
  64. },
  65. merId: {
  66. type: String || Number,
  67. default: ''
  68. }
  69. },
  70. data() {
  71. return {
  72. picList: this.dataConfig.picStyle.picList,
  73. style: this.dataConfig.tabConfig.tabVal,
  74. bgStyle: this.dataConfig.bgStyle.type,
  75. prConfig: this.dataConfig.prConfig.val,
  76. slider: this.dataConfig.mbConfig.val,
  77. bgColor: this.dataConfig.bgColor.color[0].item,
  78. widthC: '',
  79. imageH: ''
  80. };
  81. },
  82. mounted() {
  83. if(this.picList.length){
  84. let that = this;
  85. this.$nextTick((e) => {
  86. if(this.style==1){
  87. this.widthC = 375
  88. }else if(this.style==2){
  89. this.widthC = 250
  90. }else if(this.style==4){
  91. this.widthC = 188
  92. }
  93. uni.getImageInfo({
  94. src: that.setDomain(that.picList[0].image),
  95. success: (res) => {
  96. if (res && res.height > 0) {
  97. let height = res.height * ((that.widthC-that.prConfig*2) / res.width)
  98. that.$set(that, 'imageH', height);
  99. } else {
  100. that.$set(that, 'imageH', (that.widthC-that.prConfig*2)*2);
  101. }
  102. },
  103. fail: function(error) {
  104. that.$set(that, 'imageH', (that.widthC-that.prConfig*2)*2);
  105. }
  106. })
  107. })
  108. }
  109. },
  110. created() {},
  111. methods: {
  112. //替换安全域名
  113. setDomain: function(url) {
  114. url = url ? url.toString() : '';
  115. //本地调试打开,生产请注销
  116. if (url.indexOf("https://") > -1) return url;
  117. else return url.replace('http://', 'https://');
  118. },
  119. goDetail(url) {
  120. let urls = url.link
  121. urls = merPath(urls, this.merId)
  122. this.$util.JumpPath(urls);
  123. }
  124. }
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. .pageOn{
  129. border-radius:24rpx!important;
  130. .advertItem01{
  131. image{
  132. border-radius:20rpx;
  133. }
  134. }
  135. .advertItem02{
  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 20rpx 20rpx 0
  145. }
  146. }
  147. }
  148. }
  149. .advertItem03{
  150. .item{
  151. &:nth-child(1){
  152. image{
  153. border-radius:20rpx 0 0 20rpx
  154. }
  155. }
  156. &:nth-child(2){
  157. image{
  158. border-radius:0
  159. }
  160. }
  161. &:nth-child(3){
  162. image{
  163. border-radius:0 20rpx 20rpx 0
  164. }
  165. }
  166. }
  167. }
  168. .advertItem04{
  169. .item{
  170. &:nth-child(1){
  171. image{
  172. border-radius:20rpx 0 0 20rpx
  173. }
  174. }
  175. &:nth-child(2){
  176. .pic{
  177. &:nth-child(1){
  178. image{
  179. border-radius:0 20rpx 0 0
  180. }
  181. }
  182. &:nth-child(2){
  183. image{
  184. border-radius:0 0 20rpx 0
  185. }
  186. }
  187. }
  188. }
  189. }
  190. }
  191. .advertItem05{
  192. .item{
  193. &:nth-child(1){
  194. image{
  195. border-radius:20rpx 0 0 20rpx
  196. }
  197. }
  198. &:nth-child(2){
  199. image{
  200. border-radius:0
  201. }
  202. }
  203. &:nth-child(4){
  204. image{
  205. border-radius:0 20rpx 20rpx 0
  206. }
  207. }
  208. }
  209. }
  210. .advertItem06{
  211. .item{
  212. &:nth-child(1){
  213. image{
  214. border-radius:20rpx 0 0 0
  215. }
  216. }
  217. &:nth-child(2){
  218. image{
  219. border-radius:0 20rpx 0 0
  220. }
  221. }
  222. &:nth-child(3){
  223. image{
  224. border-radius:0 0 0 20rpx
  225. }
  226. }
  227. &:nth-child(4){
  228. image{
  229. border-radius:0 0 20rpx 0
  230. }
  231. }
  232. }
  233. }
  234. }
  235. .pictureCube {
  236. background-color: #fff;
  237. .advertItem01 {
  238. width: 100%;
  239. height: auto;
  240. image {
  241. width: 100%;
  242. height: 100%;
  243. display: block;
  244. }
  245. }
  246. .advertItem02{
  247. width: 100%;
  248. .item{
  249. width: 50%;
  250. height: auto;
  251. image{
  252. width: 100%;
  253. height: 100%;
  254. display: block;
  255. }
  256. }
  257. }
  258. .advertItem03{
  259. .item{
  260. width: 33.3333%;
  261. }
  262. }
  263. .advertItem04{
  264. width: 100%;
  265. .item{
  266. width: 50%;
  267. height: 376rpx;
  268. .pic{
  269. width: 100%;
  270. height: 188rpx;
  271. }
  272. image{
  273. width: 100%;
  274. height: 100%;
  275. display: block;
  276. }
  277. }
  278. }
  279. .advertItem05{
  280. .item{
  281. width: 25%;
  282. }
  283. }
  284. .advertItem06{
  285. .item{
  286. width: 50%;
  287. height: 188rpx;
  288. }
  289. }
  290. }
  291. </style>