suspen_button.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <view class="suspen-button">
  3. <view class="px-suspen-button" :style="{ top: mobileTop, left: mobileLeft }" @touchmove.stop.prevent="onTouchMove" @touchend.stop.prevent="ontouchend">
  4. <view :class="['center-button', 'px-button', { active: open }]" @click.stop="onOpen">
  5. <image v-if="!$slots.center" mode="widthFix" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/most_confidential.png"> </image>
  6. </view>
  7. <view :class="['top-button', 'px-button', 'ot-button', { 'active-top': open, 'hidden-top': !first && !open }]" @click.stop="goSecretDetail(1)">
  8. <image v-if="!$slots.top" mode="widthFix" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/company_icon.png"> </image>
  9. </view>
  10. <!-- <view :class="['left-button', 'px-button', 'ot-button', { 'active-left': open, 'hidden-left': !first && !open }]" @click.stop="goSecretDetail(2)">
  11. <image v-if="!$slots.bottom" mode="widthFix" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/this_week.png"> </image>
  12. </view> -->
  13. <view :class="['bottom-button', 'px-button', 'ot-button', { 'active-bottom': open, 'hidden-bottom': !first && !open }]" @click.stop="goSecretDetail(3)">
  14. <image v-if="!$slots.left" mode="widthFix" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/week_summary.png"> </image>
  15. </view>
  16. <view class="px-suspen-close" @click="closeButtonHandler">
  17. <image class="px-suspen-close-img" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/close-icon.png"></image>
  18. </view>
  19. </view>
  20. <view :class="[open ? 'mask-show' : '']" @click.stop="onOpen"> </view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. props: {
  26. show: {},
  27. },
  28. data() {
  29. return {
  30. first: true, //样式的一个切换
  31. open: false,
  32. mobileTop: "",
  33. mobileLeft: "",
  34. windowHeight: "",
  35. windowWidth: "",
  36. isLeft: "",
  37. };
  38. },
  39. mounted() {
  40. uni.getSystemInfo({
  41. success: (res) => {
  42. let width = res.windowWidth;
  43. let rate = 750.0 / width;
  44. this.windowHeight = res.windowHeight;
  45. this.windowWidth = width;
  46. },
  47. });
  48. },
  49. methods: {
  50. onOpen() {
  51. this.open = !this.open;
  52. this.first = false;
  53. },
  54. onTouchMove(e) {
  55. let x = e.touches[0].clientX;
  56. let y = e.touches[0].clientY;
  57. if (x < 0) {
  58. x = 0;
  59. } else if (x > this.windowWidth - this.size / this.rate) {
  60. x = this.windowWidth - this.size / this.rate;
  61. }
  62. this.isLeft = x;
  63. this.mobileLeft = x + "px";
  64. this.mobileTop = y + "px";
  65. },
  66. ontouchend() {
  67. if (!this.isLeft) return;
  68. this.mobileLeft = this.windowWidth - 85 + "px";
  69. this.isLeft = "";
  70. },
  71. /* 绝密标签点击后的跳转 */
  72. goSecretDetail(type) {
  73. if (type == 1) {
  74. uni.navigateTo({
  75. url: "/reportPages/keyCompany/keyCompany",
  76. });
  77. } else {
  78. uni.navigateTo({
  79. url: "/reportPages/secretDetails/secretDetails",
  80. });
  81. }
  82. this.onOpen();
  83. },
  84. // 点击了取消的按钮
  85. closeButtonHandler() {
  86. this.$emit("update:show", false);
  87. },
  88. },
  89. };
  90. </script>
  91. <style lang="scss" scoped>
  92. .suspen-button {
  93. width: 100%;
  94. height: 100%;
  95. }
  96. .mask-show {
  97. position: fixed;
  98. top: 0;
  99. left: 0;
  100. right: 0;
  101. bottom: 0;
  102. transition: transform 0.3s;
  103. background-color: rgba(0, 0, 0, 0.6);
  104. z-index: 90;
  105. transition: all 0.3s ease-in-out 0s;
  106. transform: scale(1, 1);
  107. }
  108. .px-suspen-button {
  109. position: fixed;
  110. z-index: 99;
  111. bottom: 320rpx;
  112. right: 180rpx;
  113. }
  114. .px-suspen-close {
  115. position: absolute;
  116. display: flex;
  117. align-items: center;
  118. justify-content: center;
  119. width: 50rpx;
  120. height: 60rpx;
  121. z-index: 99;
  122. top: -38rpx;
  123. left: 108rpx;
  124. .px-suspen-close-img {
  125. width: 35rpx;
  126. height: 35rpx;
  127. }
  128. }
  129. .px-button {
  130. position: absolute;
  131. border-radius: 50%;
  132. top: 0rpx;
  133. left: 0rpx;
  134. height: 120rpx;
  135. width: 120rpx;
  136. display: flex;
  137. flex-direction: column;
  138. justify-content: center;
  139. align-items: center;
  140. z-index: 999;
  141. overflow: hidden;
  142. image {
  143. width: 100%;
  144. height: 100%;
  145. }
  146. &.center-button {
  147. z-index: 1000;
  148. }
  149. &.ot-button {
  150. display: none;
  151. opacity: 0;
  152. &.active-top {
  153. animation: 0.5s ease top forwards;
  154. display: flex;
  155. }
  156. &.hidden-top {
  157. animation: 0.5s ease hidetop forwards;
  158. display: flex;
  159. }
  160. &.active-left {
  161. animation: 0.5s ease left forwards;
  162. display: flex;
  163. }
  164. &.hidden-left {
  165. animation: 0.5s ease hideleft forwards;
  166. display: flex;
  167. }
  168. &.active-bottom {
  169. animation: 0.5s ease bottom forwards;
  170. display: flex;
  171. }
  172. &.hidden-bottom {
  173. animation: 0.5s ease hidebottom forwards;
  174. display: flex;
  175. }
  176. }
  177. }
  178. @keyframes center {
  179. //中间的按钮
  180. 0% {
  181. }
  182. 100% {
  183. transform: rotate(315deg);
  184. opacity: 1;
  185. }
  186. }
  187. @keyframes bottom {
  188. //底部的按钮
  189. 0% {
  190. opacity: 0;
  191. }
  192. 100% {
  193. top: 80rpx;
  194. left: -126rpx;
  195. transform: rotate(360deg);
  196. opacity: 1;
  197. }
  198. }
  199. @keyframes left {
  200. 0% {
  201. opacity: 0;
  202. }
  203. 100% {
  204. top: 0rpx;
  205. left: -180rpx;
  206. transform: rotate(360deg);
  207. opacity: 1;
  208. }
  209. }
  210. @keyframes top {
  211. //头部的按钮
  212. 0% {
  213. opacity: 0;
  214. }
  215. 100% {
  216. top: -90rpx;
  217. left: -126rpx;
  218. transform: rotate(360deg);
  219. opacity: 1;
  220. }
  221. }
  222. @keyframes hideleft {
  223. 0% {
  224. top: 0rpx;
  225. left: -180rpx;
  226. opacity: 1;
  227. }
  228. 100% {
  229. top: 0rpx;
  230. left: 0rpx;
  231. transform: rotate(360deg);
  232. opacity: 0;
  233. }
  234. }
  235. @keyframes hidebottom {
  236. 0% {
  237. top: 100rpx;
  238. left: -120rpx;
  239. opacity: 1;
  240. }
  241. 100% {
  242. top: 0rpx;
  243. left: 0rpx;
  244. transform: rotate(360deg);
  245. opacity: 0;
  246. }
  247. }
  248. @keyframes hidetop {
  249. 0% {
  250. top: -100rpx;
  251. left: -120rpx;
  252. opacity: 1;
  253. }
  254. 100% {
  255. top: 0rpx;
  256. left: 0rpx;
  257. transform: rotate(360deg);
  258. opacity: 0;
  259. }
  260. }
  261. </style>