guide.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <view v-if="show" class="main" @touchmove.stop>
  3. <view class="rect-shadow"
  4. :style="{'width':width+'px','height':height+'px','left':left+'px',top:top+'px','border-radius': noticeArray[currentIndex].radius?noticeArray[currentIndex].radius+'rpx':'' }">
  5. </view>
  6. <template v-if="noticeArray[currentIndex].type == 'left' ">
  7. <view class="show-message_left" :style="{'top': top +'px', 'right': winWidth-right+width+20+'px' }">
  8. <view style="padding: 12rpx 18rpx;">{{showMessage}}</view>
  9. </view>
  10. </template>
  11. <template v-if="noticeArray[currentIndex].type == 'top' ">
  12. <view class="arrow"
  13. :style="{'height':'96rpx','width':'96rpx','top': (top-height-topMsgHeight+50) +'px', 'left': left<(winWidth/2)?left+'px':'' , 'right': left>(winWidth/2)?(winWidth-right) +'px':'' }">
  14. <image mode="aspectFill" src="../../static/arrow-down.png" style="width: 96rpx;height: 96rpx;"></image>
  15. </view>
  16. <view :class="left<(winWidth/2)?'show-message_top_left':'show-message_top_right'"
  17. :style="{'top': (top-height-topMsgHeight-10) +'px', 'left': left<(winWidth/2)?left+'px':'' , 'right': left>(winWidth/2)?(winWidth-right)+'px':'' }">
  18. <view style="padding: 12rpx 18rpx;">{{showMessage}}</view>
  19. </view>
  20. <view @click="click" class="guide-next"
  21. :style="{'top': (top-height-topMsgHeight+170) +'px', 'left': left<(winWidth/2)?left+'px':'' , 'right': left>(winWidth/2)?(winWidth-right) +'px':'' }">
  22. <image mode="aspectFit" src="../../static/i_know.png" style="width: 200rpx; height: 100rpx;"></image>
  23. </view>
  24. </template>
  25. <template v-if="noticeArray[currentIndex].type == 'right' ">
  26. <view class="show-message_right" :style="{'top': top +'px', 'left': (left+width+20) +'px' }">
  27. <view style="padding: 12rpx 18rpx;">{{showMessage}}</view>
  28. </view>
  29. </template>
  30. <template v-if="noticeArray[currentIndex].type == 'bottom' ">
  31. <view class="arrow"
  32. :style="{'height':'96rpx','width':'96rpx','top': (top+height) +'px', 'left': left<(winWidth/2)?left+'px':'' , 'right': left>(winWidth/2)?(winWidth-right) +'px':'' }">
  33. <image mode="aspectFill" src="../../static/arrow-top.png" style="width: 96rpx;height: 96rpx;"></image>
  34. </view>
  35. <view :class="left<(winWidth/2)?'show-message_bottom_left':'show-message_bottom_right'"
  36. :style="{'top': (top+height+50) +'px', 'left': left<(winWidth/2)?left+'px':'' , 'right': left>(winWidth/2)?(winWidth-right) +'px':'' }">
  37. <view style="padding: 12rpx 18rpx;">{{showMessage}}</view>
  38. </view>
  39. <view @click="click" class="guide-next"
  40. :style="{'top': (top+height+110) +'px', 'left': left<(winWidth/2)?left+'px':'' , 'right': left>(winWidth/2)?(winWidth-right) +'px':'' }">
  41. <image mode="aspectFit" src="../../static/i_know.png" style="width: 200rpx; height: 100rpx;"></image>
  42. </view>
  43. </template>
  44. <!-- <view class="cover-wrap">
  45. <view class="guide-next" @tap="click" :style="{color: '#000000'}">{{nextText}}</view>
  46. </view> -->
  47. </view>
  48. </template>
  49. <script setup>
  50. import {
  51. watch,
  52. defineEmits,
  53. onBeforeMount,
  54. ref,
  55. getCurrentInstance,
  56. computed
  57. } from 'vue'
  58. const props = defineProps({
  59. show: {
  60. type: Boolean,
  61. default: false
  62. },
  63. left: {
  64. type: [Number, String],
  65. default: ''
  66. },
  67. right: {
  68. type: [Number, String],
  69. default: ''
  70. },
  71. top: {
  72. type: [Number, String],
  73. default: ''
  74. },
  75. width: {
  76. type: [Number, String],
  77. default: ''
  78. },
  79. height: {
  80. type: [Number, String],
  81. default: ''
  82. },
  83. showMessage: {
  84. type: String,
  85. default: ''
  86. },
  87. currentIndex: {
  88. type: Number,
  89. default: 0
  90. },
  91. noticeArray: {
  92. type: Array,
  93. default: []
  94. }
  95. })
  96. let topMsgHeight = ref(0)
  97. let winWidth = ref(0)
  98. let nextText = '下一步'
  99. // const instance = getCurrentInstance()
  100. // watch(() => props.currentIndex, (oldValue, newValue) => {
  101. // console.log('currentIndex', newValue)
  102. // console.log(props)
  103. // if (newValue <= props.noticeArray.length) {
  104. // if (newValue != props.noticeArray.length && props.noticeArray[newValue].type == 'top') {
  105. // const className = props.left < (winWidth.value / 2) ? '.show-message_top_left' :
  106. // '.show-message_top_right'
  107. // const query = uni.createSelectorQuery().in(instance);
  108. // query.select(className).boundingClientRect(data => {
  109. // // 29px 为一行语句的高度
  110. // topMsgHeight.value = data.height - 29
  111. // }).exec();
  112. // }
  113. // }
  114. // })
  115. const emit = defineEmits(['click'])
  116. function click() {
  117. emit('click')
  118. }
  119. onBeforeMount(() => {
  120. winWidth.value = uni.getWindowInfo().windowWidth
  121. })
  122. </script>
  123. <style lang="scss">
  124. .main {
  125. position: fixed;
  126. top: 0;
  127. left: 0;
  128. right: 0;
  129. bottom: 0;
  130. z-index: 99999;
  131. }
  132. .rect-shadow {
  133. position: absolute;
  134. border-radius: 12px;
  135. box-shadow: 0 0 0 3000px rgba(0, 0, 0, 0.5);
  136. pointer-events: none;
  137. }
  138. .arrow {
  139. position: absolute;
  140. }
  141. .show-message_left,
  142. .show-message_top_left,
  143. .show-message_top_right,
  144. .show-message_right,
  145. .show-message_bottom_left,
  146. .show-message_bottom_right {
  147. position: absolute;
  148. border-radius: 12rpx;
  149. background-color: rgba(0, 0, 0, .5);
  150. text-align: center;
  151. pointer-events: none;
  152. color: #fff;
  153. font-size: 24rpx;
  154. max-width: 30%;
  155. text-align: left;
  156. }
  157. .show-message_left::after {
  158. content: '';
  159. border-left: 12rpx solid rgba(0, 0, 0, .5);
  160. border-top: 12rpx solid transparent;
  161. border-right: 12rpx solid transparent;
  162. border-bottom: 12rpx solid transparent;
  163. width: 0;
  164. height: 0;
  165. position: absolute;
  166. top: 25%;
  167. right: -22rpx;
  168. }
  169. // .show-message_top_left::after,
  170. // .show-message_top_right::after {
  171. // content: '';
  172. // border-left: 12rpx solid transparent;
  173. // border-top: 12rpx solid rgba(0, 0, 0, .5);
  174. // border-right: 12rpx solid transparent;
  175. // border-bottom: 12rpx solid transparent;
  176. // width: 0;
  177. // height: 0;
  178. // position: absolute;
  179. // top: 100%;
  180. // }
  181. .show-message_top_left::after {
  182. left: 20%;
  183. }
  184. .show-message_top_right::after {
  185. right: 20%;
  186. }
  187. .show-message_right::after {
  188. content: '';
  189. border-left: 12rpx solid transparent;
  190. border-top: 12rpx solid transparent;
  191. border-right: 12rpx solid rgba(0, 0, 0, .5);
  192. border-bottom: 12rpx solid transparent;
  193. width: 0;
  194. height: 0;
  195. position: absolute;
  196. top: 25%;
  197. left: -24rpx;
  198. }
  199. // .show-message_bottom_left::after,
  200. // .show-message_bottom_right::after {
  201. // content: '';
  202. // border-left: 12rpx solid transparent;
  203. // border-top: 12rpx solid transparent;
  204. // border-right: 12rpx solid transparent;
  205. // border-bottom: 12rpx solid rgba(0, 0, 0, .5);
  206. // width: 0;
  207. // height: 0;
  208. // position: absolute;
  209. // top: -22rpx;
  210. // }
  211. .show-message_bottom_left::after {
  212. left: 20%;
  213. }
  214. .show-message_bottom_right::after {
  215. right: 20%;
  216. }
  217. .guide-next {
  218. position: absolute;
  219. }
  220. // .cover-wrap {
  221. // width: 100vw;
  222. // height: 100vh;
  223. // top: 0;
  224. // left: 0;
  225. // position: absolute;
  226. // .guide-next {
  227. // position: absolute;
  228. // padding: 0 40rpx;
  229. // padding: 16rpx 32rpx;
  230. // height: 40rpx;
  231. // background-color: #FFFFFF;
  232. // text-align: center;
  233. // font-size: 28rpx;
  234. // border-radius: 38rpx;
  235. // position: absolute;
  236. // bottom: 60rpx;
  237. // left: 50%;
  238. // transform: translate(-50%, 0);
  239. // }
  240. // }
  241. </style>