guide.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <view v-show="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>
  50. export default {
  51. name: "guide",
  52. props: {
  53. show: {
  54. type: Boolean,
  55. default: false
  56. },
  57. left: {
  58. type: [Number, String],
  59. default: ''
  60. },
  61. right: {
  62. type: [Number, String],
  63. default: ''
  64. },
  65. top: {
  66. type: [Number, String],
  67. default: ''
  68. },
  69. width: {
  70. type: [Number, String],
  71. default: ''
  72. },
  73. height: {
  74. type: [Number, String],
  75. default: ''
  76. },
  77. showMessage: {
  78. type: String,
  79. default: ''
  80. },
  81. currentIndex: {
  82. type: Number,
  83. default: 0
  84. },
  85. noticeArray: {
  86. type: Array,
  87. default: []
  88. }
  89. },
  90. data() {
  91. return {
  92. topMsgHeight: 0,
  93. winWidth: 0,
  94. nextText: '下一步' // 知道了,关闭说明
  95. }
  96. },
  97. watch: {
  98. show(n) {},
  99. currentIndex(value) {
  100. console.log('currentIndex', value)
  101. if (value != this.noticeArray.length && this.noticeArray[value].type == 'top') {
  102. const className = this.left < (this.winWidth / 2) ? '.show-message_top_left' :
  103. '.show-message_top_right'
  104. const query = uni.createSelectorQuery().in(this);
  105. query.select(className).boundingClientRect(data => {
  106. // 29px 为一行语句的高度
  107. this.topMsgHeight = data.height - 29
  108. }).exec();
  109. }
  110. }
  111. },
  112. methods: {
  113. click() {
  114. this.$emit('click');
  115. },
  116. // 清除页面所有定时器
  117. clearTimeAll() {
  118. clearTimeout(this.stt01);
  119. }
  120. },
  121. created() {
  122. this.stt01 = setTimeout(() => {
  123. uni.getSystemInfo({
  124. success: (res) => {
  125. this.winWidth = res.windowWidth;
  126. }
  127. });
  128. }, 60)
  129. }
  130. }
  131. </script>
  132. <style lang="scss">
  133. .main {
  134. position: fixed;
  135. top: 0;
  136. left: 0;
  137. right: 0;
  138. bottom: 0;
  139. z-index: 99999;
  140. }
  141. .rect-shadow {
  142. position: absolute;
  143. border-radius: 12px;
  144. box-shadow: 0 0 0 3000px rgba(0, 0, 0, 0.5);
  145. pointer-events: none;
  146. }
  147. .arrow {
  148. position: absolute;
  149. }
  150. .show-message_left,
  151. .show-message_top_left,
  152. .show-message_top_right,
  153. .show-message_right,
  154. .show-message_bottom_left,
  155. .show-message_bottom_right {
  156. position: absolute;
  157. border-radius: 12rpx;
  158. background-color: rgba(0, 0, 0, .5);
  159. text-align: center;
  160. pointer-events: none;
  161. color: #fff;
  162. font-size: 24rpx;
  163. max-width: 30%;
  164. text-align: left;
  165. }
  166. .show-message_left::after {
  167. content: '';
  168. border-left: 12rpx solid rgba(0, 0, 0, .5);
  169. border-top: 12rpx solid transparent;
  170. border-right: 12rpx solid transparent;
  171. border-bottom: 12rpx solid transparent;
  172. width: 0;
  173. height: 0;
  174. position: absolute;
  175. top: 25%;
  176. right: -22rpx;
  177. }
  178. // .show-message_top_left::after,
  179. // .show-message_top_right::after {
  180. // content: '';
  181. // border-left: 12rpx solid transparent;
  182. // border-top: 12rpx solid rgba(0, 0, 0, .5);
  183. // border-right: 12rpx solid transparent;
  184. // border-bottom: 12rpx solid transparent;
  185. // width: 0;
  186. // height: 0;
  187. // position: absolute;
  188. // top: 100%;
  189. // }
  190. .show-message_top_left::after {
  191. left: 20%;
  192. }
  193. .show-message_top_right::after {
  194. right: 20%;
  195. }
  196. .show-message_right::after {
  197. content: '';
  198. border-left: 12rpx solid transparent;
  199. border-top: 12rpx solid transparent;
  200. border-right: 12rpx solid rgba(0, 0, 0, .5);
  201. border-bottom: 12rpx solid transparent;
  202. width: 0;
  203. height: 0;
  204. position: absolute;
  205. top: 25%;
  206. left: -24rpx;
  207. }
  208. // .show-message_bottom_left::after,
  209. // .show-message_bottom_right::after {
  210. // content: '';
  211. // border-left: 12rpx solid transparent;
  212. // border-top: 12rpx solid transparent;
  213. // border-right: 12rpx solid transparent;
  214. // border-bottom: 12rpx solid rgba(0, 0, 0, .5);
  215. // width: 0;
  216. // height: 0;
  217. // position: absolute;
  218. // top: -22rpx;
  219. // }
  220. .show-message_bottom_left::after {
  221. left: 20%;
  222. }
  223. .show-message_bottom_right::after {
  224. right: 20%;
  225. }
  226. .guide-next {
  227. position: absolute;
  228. }
  229. // .cover-wrap {
  230. // width: 100vw;
  231. // height: 100vh;
  232. // top: 0;
  233. // left: 0;
  234. // position: absolute;
  235. // .guide-next {
  236. // position: absolute;
  237. // padding: 0 40rpx;
  238. // padding: 16rpx 32rpx;
  239. // height: 40rpx;
  240. // background-color: #FFFFFF;
  241. // text-align: center;
  242. // font-size: 28rpx;
  243. // border-radius: 38rpx;
  244. // position: absolute;
  245. // bottom: 60rpx;
  246. // left: 50%;
  247. // transform: translate(-50%, 0);
  248. // }
  249. // }
  250. </style>