help.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <div >
  3. <div class="help" v-drag="isMove">
  4. <div @click="feedback">
  5. <span>
  6. <i class="iconfont icon-yijianfankui"></i>
  7. </span>
  8. <span>意见反馈</span>
  9. </div>
  10. <div @click="guide" class="help-guid">
  11. <span>
  12. <i class="iconfont icon-xinshouzhiyin"></i>
  13. </span>
  14. <span>新手指引</span>
  15. </div>
  16. </div>
  17. <feedback ref="feedback"></feedback>
  18. </div>
  19. </template>
  20. <script>
  21. import feedback from './dialog/feedback.vue';
  22. import { guide } from "./guide";
  23. export default {
  24. mixins:[guide],
  25. components: {
  26. feedback
  27. },
  28. props: {},
  29. data() {
  30. return {
  31. move:false,
  32. };
  33. },
  34. //注册局部组件指令
  35. directives: {
  36. drag: function (el,data,vnode) {
  37. let dragBox = el; //获取当前元素
  38. let clientHeight = document.documentElement.clientHeight
  39. dragBox.onmousedown = e => {
  40. //算出鼠标相对元素的位置
  41. var start = dragBox.offsetTop
  42. var height = dragBox.offsetHeight
  43. var startY = e.clientY
  44. document.onmousemove = e => {
  45. if ( e.stopPropagation ) {
  46. e.stopPropagation()
  47. }
  48. if ( e.preventDefault ) {
  49. e.preventDefault()
  50. }
  51. var moveY = e.clientY - startY
  52. var bottom = 50
  53. if(moveY < 0){
  54. bottom = clientHeight - start - height + Math.abs(moveY)
  55. if(bottom - height > clientHeight - 200){
  56. bottom = clientHeight - 100
  57. }
  58. }else{
  59. bottom = clientHeight - start - height - Math.abs(moveY)
  60. if(bottom < 50){
  61. bottom = 50
  62. }
  63. }
  64. dragBox.style.bottom = bottom + 'px'
  65. };
  66. document.onmouseup = e2 => {
  67. //鼠标弹起来的时候不再移动
  68. document.onmousemove = null;
  69. //预防鼠标弹起来后还会循环(即预防鼠标放上去的时候还会移动)
  70. document.onmouseup = null;
  71. if ( startY == e2.clientY ) {
  72. data.value(true)
  73. }else{
  74. data.value(false)
  75. }
  76. };
  77. };
  78. }
  79. },
  80. watch: {},
  81. computed: {},
  82. created() {},
  83. mounted() {},
  84. methods: {
  85. //是否移动
  86. isMove(val){
  87. this.move = val
  88. },
  89. //意见反馈
  90. feedback(){
  91. if(this.move){
  92. this.$refs.feedback.open()
  93. }
  94. },
  95. //新手指引
  96. guide(){
  97. if(this.move){
  98. //开始新手指引(title:当前路由标识,arr:需要展示的指引步骤,userinfo:用户信息)
  99. this.startGuide(this.$route.meta.sign)
  100. }
  101. },
  102. },
  103. };
  104. </script>
  105. <style lang="scss">
  106. @keyframes moveX {
  107. to{
  108. transform: translateX(var(--x));
  109. }
  110. }
  111. @keyframes moveY {
  112. to{
  113. transform: translateY(var(--y));
  114. }
  115. }
  116. .plus{
  117. position:fixed;
  118. top:var(--top);
  119. left: var(--left);
  120. width: 30px;
  121. height: 30px;
  122. border-radius: 50%;
  123. cursor: pointer;
  124. z-index: 99999999;
  125. animation: moveY .8s cubic-bezier(0.5,-0.5,1,1);
  126. }
  127. .plus-icon{
  128. height: 100%;
  129. width: 100%;
  130. background-color: #5151e7;
  131. border-radius: 50%;
  132. z-index: 99999999;
  133. animation: moveX .8s linear;
  134. }
  135. // .plus-icon::before{
  136. // content: '';
  137. // position: absolute;
  138. // left: 50%;
  139. // top: 3;
  140. // width: 4px;
  141. // height: 24px;
  142. // margin-left: -2px;
  143. // background-color: #fff;
  144. // border-radius: 8px;
  145. // }
  146. // .plus-icon::after{
  147. // content: '';
  148. // position: absolute;
  149. // left: 3px;
  150. // top: 50%;
  151. // width: 24px;
  152. // height: 4px;
  153. // margin-top: -2px;
  154. // background-color: #fff;
  155. // border-radius: 8px;
  156. // }
  157. </style>
  158. <style lang="scss" scoped>
  159. .help{
  160. background: white;
  161. z-index: 999;
  162. border:3px solid var(--color1);
  163. border-right: none;
  164. width: 35px;
  165. height: auto;
  166. white-space: nowrap;
  167. border-radius: 5px 0 0 10px;
  168. position: fixed;
  169. right: 0;
  170. bottom:50px;
  171. div{
  172. border-bottom: 1px solid var(--color1);
  173. padding: 5px 0;
  174. }
  175. div:last-child{
  176. border-bottom: none;
  177. }
  178. span{
  179. color: var(--color1);
  180. font-family: var(--fm);
  181. font-size: 14px;
  182. font-weight: bold;
  183. margin-left:10px;
  184. cursor: pointer;
  185. }
  186. i{
  187. font-size: 20px;
  188. }
  189. }
  190. .help:hover{
  191. width: 100px;
  192. i{
  193. font-size: 14px;
  194. }
  195. }
  196. </style>