多租户商城-商户小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

235 lines
5.9 KiB

2 years ago
  1. <template>
  2. <div class="mainContent">
  3. <div class="canvasContent" ref="canvasContent" :style="{ width: `${canvasWidth}rpx`, height: `${canvasHeight}rpx` }"
  4. v-if="interactionDiagramDetailData.interactionDiagramImage">
  5. <img class="img-bg" ref="canvasBgContent" :src="interactionDiagramDetailData.interactionDiagramImage" />
  6. <div class="drap-container-item" v-for="(point, index) in pointList" :key="index"
  7. :style="{ top: `${canvasHeight * point.pointY}rpx`, left: `${canvasWidth * point.pointX}rpx` }"
  8. @click="handleClick(point, index)">
  9. <div :class="showPoint == point ? 'point_source_active' : 'point_source'" />
  10. <div class="product-detail" @click="toProductDetail" v-if="showPoint == point && (point.product && point.product.productName)">
  11. <div class="product-name">{{ (point.product && point.product.productName) ? point.product.productName : '' }}</div>
  12. <div class="product-price">{{ (point.product && point.product.price) ? point.product.price : '' }}</div>
  13. </div>
  14. </div>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. export default {
  20. data () {
  21. return {
  22. interactionDiagramDetailData:{},
  23. showPoint: {},
  24. pointList: [],
  25. canvasWidth: 0,
  26. canvasHeight: 0
  27. }
  28. },
  29. methods: {
  30. toProductDetail () {
  31. this.$emit('clickProductDetail', {
  32. productId: this.productData.productId
  33. })
  34. },
  35. // 点击元素获取组件配置
  36. handleClick(row, index) {
  37. console.log("handleClick");
  38. if(this.showPoint == row){
  39. this.showPoint = null
  40. }else{
  41. this.showPoint = row
  42. }
  43. },
  44. setParams (data, pointList) {
  45. this.interactionDiagramDetailData = data
  46. this.pointList = pointList
  47. const position = {
  48. height: 750,
  49. width: 750
  50. }
  51. // 图片的原始宽度
  52. var naturalWidth = this.interactionDiagramDetailData.imageWidth;
  53. var naturalHeight = this.interactionDiagramDetailData.imageHeight;
  54. //计算图片显示宽高
  55. var showWidth = position.width;
  56. var showHeight = naturalHeight * showWidth / naturalWidth;
  57. this.canvasWidth = showWidth;
  58. this.canvasHeight = showHeight;
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="scss" scoped>
  64. .point_source_active{
  65. align-items: center;
  66. background: hsla(0,0%,47%,.5);
  67. border: 3rpx solid transparent;
  68. border-radius: 50%;
  69. display: flex;
  70. height: 48rpx;
  71. justify-content: center;
  72. opacity: 1;
  73. padding: 0;
  74. transition: border-color .25s ease-in-out,opacity .25s ease-in-out,visibility .25s ease-in-out;
  75. width: 48rpx;
  76. &:after {
  77. background: #fff;
  78. border-radius: 50%;
  79. box-shadow: 0 1rpx 4rpx #0000008c;
  80. content: "";
  81. display: block;
  82. height: 18rpx;
  83. position: relative;
  84. transition: transform .25s ease-in-out;
  85. width: 18rpx;
  86. transform: scale(.667);
  87. }
  88. }
  89. .point_source {
  90. align-items: center;
  91. background: hsla(0,0%,47%,.5);
  92. border: 3rpx solid transparent;
  93. border-radius: 50%;
  94. display: flex;
  95. height: 48rpx;
  96. justify-content: center;
  97. opacity: 1;
  98. padding: 0;
  99. transition: border-color .25s ease-in-out,opacity .25s ease-in-out,visibility .25s ease-in-out;
  100. width: 48rpx;
  101. &:after {
  102. background: #fff;
  103. border-radius: 50%;
  104. box-shadow: 0 1px 4px #0000008c;
  105. content: "";
  106. display: block;
  107. height: 18rpx;
  108. position: relative;
  109. transition: transform .25s ease-in-out;
  110. width: 18rpx;
  111. }
  112. }
  113. .mainContent {
  114. margin: 0 auto;
  115. width: 750rpx;
  116. height: auto;
  117. display: flex;
  118. flex-direction: column;
  119. flex-wrap: nowrap;
  120. align-content: flex-start;
  121. justify-content: flex-start;
  122. align-items: flex-start;
  123. .canvasContent {
  124. width: 100%;
  125. height: 100%;
  126. position: relative;
  127. .img-bg {
  128. width: 100%;
  129. height: 100%;
  130. object-fit: contain;
  131. }
  132. .drap-container-item {
  133. -webkit-user-select: none;
  134. -moz-user-select: none;
  135. -o-user-select: none;
  136. user-select: none;
  137. position: absolute;
  138. user-select: none;
  139. cursor: pointer;
  140. border: 1px solid transparent;
  141. .drap-item-img {
  142. width: 40rpx;
  143. height: 40rpx;
  144. object-fit: contain;
  145. }
  146. .drap-item-name {
  147. text-align: center;
  148. }
  149. .product-detail-top{
  150. position: relative;
  151. top: -100rpx;
  152. }
  153. .product-detail-bottom{
  154. }
  155. .product-detail-left{
  156. position: relative;
  157. left: -100rpx;
  158. }
  159. .product-detail-right{
  160. }
  161. .product-detail-centerv{
  162. margin-top: -25%;
  163. margin-bottom: 25%;
  164. }
  165. .product-detail-centerh{
  166. margin-left: -25%;
  167. margin-right: 25%;
  168. }
  169. .product-detail{
  170. display: flex;
  171. flex-direction: column;
  172. flex-wrap: nowrap;
  173. align-content: flex-start;
  174. justify-content: center;
  175. align-items: flex-start;
  176. background: white;
  177. padding-left: 10rpx;
  178. padding-right: 10rpx;
  179. padding-top: 8rpx;
  180. padding-bottom: 8rpx;
  181. border-radius: 4rpx;
  182. margin-left: -25%;
  183. margin-right: 25%;
  184. .product-name{
  185. width: 100%;
  186. height: auto;
  187. font-size: 16rpx;
  188. font-family: Source Han Sans CN;
  189. font-weight: bold;
  190. color: #252744;
  191. display: block;
  192. overflow: hidden;
  193. text-overflow: ellipsis;
  194. white-space: nowrap;
  195. line-height: 20px;
  196. text-align: left;
  197. }
  198. .product-price{
  199. width: auto;
  200. height: 20rpx;
  201. line-height: 20rpx;
  202. font-size: 14rpx;
  203. font-family: Source Han Sans CN;
  204. font-weight: bold;
  205. color: #252744;
  206. }
  207. }
  208. }
  209. .drap-container-item-active {
  210. border: 1rpx solid skyblue;
  211. }
  212. }
  213. }
  214. </style>