hotSpot.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <!-- 热区+图片魔方 -->
  3. <view class="mobile-page" v-if="dataConfig" :style="[boxStyle]">
  4. <view class="advert">
  5. <!-- 单图/热区布局 -->
  6. <template v-if="style === 0">
  7. <view class="advertItem01 acea-row hotspot" v-for="(item, index) in picList" :key="index">
  8. <image :src="item.image" mode="widthFix" v-if="item.image" :style="[contentStyle]"
  9. @click="dataConfig.checkoutConfig.hotspot.length?'':goDetail(item)"></image>
  10. <view v-for="(item, index) in dataConfig.checkoutConfig.hotspot" :key="index" :style="{
  11. top: `${Number(spotIndex*item.starY)}rpx`,
  12. left: `${Number(spotIndex*item.starX)}rpx`,
  13. width: `${Number(spotIndex*item.areaWidth)}rpx`,
  14. height: `${Number(spotIndex*item.areaHeight)}rpx`,
  15. }" class="area" @click="goDetail(item)"></view>
  16. </view>
  17. </template>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. // +----------------------------------------------------------------------
  23. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  24. // +----------------------------------------------------------------------
  25. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  26. // +----------------------------------------------------------------------
  27. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  28. // +----------------------------------------------------------------------
  29. // | Author: CRMEB Team <admin@crmeb.com>
  30. // +----------------------------------------------------------------------
  31. export default {
  32. name: 'hotSpot',
  33. props: {
  34. dataConfig: {
  35. type: Object,
  36. default: () => {}
  37. },
  38. },
  39. data() {
  40. return {
  41. picList: this.dataConfig.picStyle.picList,
  42. style: this.dataConfig.tabConfig.tabVal,
  43. prConfig: this.dataConfig.lrConfig.val,
  44. igConfig: this.dataConfig.igConfig.val
  45. };
  46. },
  47. computed: {
  48. //最外层盒子的样式
  49. boxStyle() {
  50. return {
  51. borderRadius: this.dataConfig.bgStyle.val * 2 + 'rpx',
  52. backgroundImage: `linear-gradient(${this.dataConfig.bgColor.color[0].item}, ${this.dataConfig.bgColor.color[1].item})`,
  53. margin: this.dataConfig.mbConfig.val * 2 + 'rpx' + ' ' + this.dataConfig.lrConfig.val * 2 + 'rpx' +
  54. ' ' + 0,
  55. padding: this.dataConfig.upConfig.val * 2 + 'rpx' + ' ' + '0' + ' ' + this.dataConfig.downConfig.val *
  56. 2 + 'rpx'
  57. }
  58. },
  59. contentStyle(){
  60. return{
  61. borderRadius: this.dataConfig.contentStyle.val * 2 + 'rpx',
  62. }
  63. },
  64. //伸缩系数
  65. spotIndex(){
  66. return (750-4*this.dataConfig.lrConfig.val)/456
  67. },
  68. // 两张图片 图片间距样式
  69. twoImgStyle() {
  70. return {
  71. width: (750 - 2 * this.igConfig - 4 * this.prConfig) / 2 + 'rpx',
  72. height: (750 - 2 * this.igConfig - 4 * this.prConfig) / 2 + 'rpx',
  73. }
  74. },
  75. // 第一种 三张图片间距样式
  76. thrOneImgStyle() {
  77. return {
  78. width: (750 - 4 * this.igConfig - 4 * this.prConfig) / 3 + 'rpx',
  79. height: (750 - 4 * this.igConfig - 4 * this.prConfig) / 3 + 'rpx',
  80. }
  81. },
  82. // 第一种四张图片布局
  83. forOneImgStyle() {
  84. return {
  85. width: (750 - 6 * this.igConfig - 4 * this.prConfig) / 4 + 'rpx',
  86. }
  87. },
  88. // 第二种四张图片布局
  89. forTwoImgStyle() {
  90. return {
  91. width: (750 - 2 * this.igConfig - 4 * this.prConfig) / 2 + 'rpx',
  92. height: (750 - 2 * this.igConfig - 4 * this.prConfig) / 2 + 'rpx',
  93. }
  94. },
  95. imgBoxStyle() {
  96. return {
  97. display: this.igConfig ? 'flex' : '',
  98. 'justify-content': this.igConfig ? 'space-between' : ''
  99. }
  100. }
  101. },
  102. methods: {
  103. //替换安全域名
  104. setDomain: function(url) {
  105. url = url ? url.toString() : '';
  106. //本地调试打开,生产请注销
  107. if (url.indexOf("https://") > -1) return url;
  108. else return url.replace('http://', 'https://');
  109. },
  110. goDetail(item) {
  111. this.$util.navigateTo(item.link);
  112. }
  113. }
  114. }
  115. </script>
  116. <style lang="scss" scoped>
  117. .mobile-page {
  118. .advert {
  119. .advertItem01 {
  120. width: 100%;
  121. height: 100%;
  122. .empty-box {
  123. width: 100%;
  124. height: auto;
  125. }
  126. image {
  127. width: 100%;
  128. height: 100%;
  129. }
  130. }
  131. .advertItem02 {
  132. width: 100%;
  133. .item {
  134. width: 50%;
  135. height: auto;
  136. image {
  137. width: 100%;
  138. height: 100%;
  139. }
  140. .empty-box {
  141. width: 100%;
  142. height: auto;
  143. }
  144. }
  145. }
  146. .advertItem03 {
  147. .item {
  148. width: 33.3333%;
  149. height: auto;
  150. .empty-box {
  151. width: 100%;
  152. height: auto;
  153. }
  154. }
  155. }
  156. .advertItem04 {
  157. .item {
  158. width: 50%;
  159. height: auto;
  160. .empty-box {
  161. width: 100%;
  162. height: 100%;
  163. }
  164. image {
  165. width: 100%;
  166. height: 100%;
  167. }
  168. .pic {
  169. width: 100%;
  170. height: auto;
  171. }
  172. }
  173. }
  174. .advertItem05 {
  175. .item {
  176. width: 25%;
  177. .empty-box {
  178. width: 100%;
  179. height: auto;
  180. }
  181. }
  182. }
  183. .advertItem06 {
  184. .item {
  185. width: 50%;
  186. image {
  187. width: 100%;
  188. height: 100%;
  189. }
  190. .empty-box {
  191. width: 100%;
  192. height: 100%;
  193. }
  194. }
  195. }
  196. }
  197. }
  198. .hotspot {
  199. position: relative;
  200. .area {
  201. position: absolute;
  202. }
  203. }
  204. </style>