suspen_button.vue 6.5 KB

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