pictureCube.vue 7.9 KB

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