round-menu.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <template>
  2. <view>
  3. <view class="round-mask" v-if="isShow" @click="_onClick"></view>
  4. <view class="uni-menu--rightBottom uni-round-menu ">
  5. <view style="position: absolute;left: 6px;top: 6px; width: 200px;height: 200px; ">
  6. <view :class="{'uni-menu-bg--active':isShow}" class="uni-menu-white-bg"></view>
  7. <view :class="{'uni-menu-bg--active':isShow}" class="uni-menu-blue-bg"></view>
  8. <view :class="{'uni-menu--close':!isShow}" class="uni-menu-content">
  9. <view v-for="(item, index) in content" :key="index" class="surround-box">
  10. <view class="circle-line"></view>
  11. <view class="circle" :style="{'--rotate':item.rotate}" @click="_onItemClick(index, item)">
  12. <view class="chircle-item">
  13. <image style="width: 20px;height: 20px;" :src="item.iconPath"></image>
  14. <view style="font-size: 11px; line-height: 15px; ">{{item.text}}</view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. <view style="position: absolute;left: 6px;top: 6px;width: 100px;height: 100px;">
  21. <view :class="{'uni-click-white-bg':!isShow}"></view>
  22. <view class="uni-click-grey-bg" :class="{'uni-click-bg-menu':!isShow}"></view>
  23. <view v-if="isShow" class="uni-click__circle " @click="_onClick">
  24. <view class="click-circle-v"></view>
  25. <view class="click-circle-h"></view>
  26. </view>
  27. <view v-else class="uni-click__image" @click="_onClick">
  28. <image style="width: 30px;height: 30px;" src="/static/round-menu/menu.png"></image>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. props: {
  37. middleIcon: {
  38. type: String,
  39. default: ''
  40. },
  41. // content: {
  42. // type: Array,
  43. // default () {
  44. // return []
  45. // }
  46. // },
  47. },
  48. data() {
  49. return {
  50. isShow: false,
  51. // 按钮
  52. content: [
  53. {
  54. iconPath: '/static/round-menu/home.png',
  55. text: '首页',
  56. rotate: "155deg",
  57. type:'persnal'
  58. },{
  59. iconPath: '/static/round-menu/video.png',
  60. text: '娱乐',
  61. rotate: "115deg",
  62. type:'game'
  63. }
  64. ]
  65. }
  66. },
  67. methods: {
  68. _onClick() {
  69. // console.log("_onClick");
  70. this.isShow = !this.isShow
  71. },
  72. open() {
  73. this.isShow = true
  74. },
  75. close() {
  76. this.isShow = false
  77. },
  78. /**
  79. * 按钮点击事件
  80. */
  81. _onItemClick(index, item) {
  82. // console.log(index, item);
  83. this.close();
  84. this.$emit('trigger', {
  85. index,
  86. item
  87. })
  88. }
  89. }
  90. }
  91. </script>
  92. <style>
  93. * {
  94. margin: 0;
  95. padding: 0;
  96. box-sizing: border-box;
  97. }
  98. .round-mask{
  99. position: fixed;
  100. background-color: rgba(0,0,0,0.3);
  101. left: 0;
  102. top: 0;
  103. bottom: 0;
  104. right: 0;
  105. width: 100%;
  106. height: 100%;
  107. z-index: 999;
  108. /* pointer-events: none; */
  109. }
  110. .uni-round-menu {
  111. position: fixed;
  112. /* #ifndef APP-NVUE */
  113. display: flex;
  114. /* #endif */
  115. justify-content: center;
  116. align-items: center;
  117. z-index: 1000;
  118. width: 106px;
  119. height: 106px;
  120. /* background-color: #3c3e49; */
  121. pointer-events: none;
  122. overflow: hidden;
  123. }
  124. .uni-menu--rightBottom {
  125. right: 0;
  126. bottom: 0;
  127. }
  128. .uni-menu--leftTop {
  129. left: 100px;
  130. top: 200px;
  131. }
  132. .uni-menu-blue-bg {
  133. position: absolute;
  134. right: 0;
  135. bottom: 0;
  136. width: 200px;
  137. height: 200px;
  138. background: #ffffff;
  139. box-sizing: border-box;
  140. border: 50px solid #33bdfb;
  141. border-radius: 50%;
  142. opacity: 0;
  143. transition: opacity 0.2s;
  144. }
  145. .uni-menu-white-bg {
  146. position: absolute;
  147. right: -4px;
  148. bottom:-4px;
  149. width: 208px;
  150. height: 208px;
  151. background: #ffffff;
  152. box-sizing: border-box;
  153. border: 50px solid #ffffff;
  154. border-radius: 50%;
  155. /* border-color: #ffc107;
  156. border-bottom: 60px solid transparent;
  157. border-left: 60px solid #99edd1;
  158. border-top: 60px solid transparent;
  159. border-right: 60px solid transparent;
  160. border-radius: 100% 0 0 0; */
  161. opacity: 0;
  162. transition: opacity 0.2s;
  163. box-shadow:0px 0px 5px #888888;
  164. }
  165. .uni-menu-bg--active {
  166. opacity: 1;
  167. }
  168. .uni-menu-content {
  169. position: absolute;
  170. z-index: 20;
  171. width: 200px;
  172. height: 200px;
  173. display: flex;
  174. transform: rotate(0);
  175. transition: transform 0.2s;
  176. }
  177. .uni-menu--close {
  178. transform: rotate(100deg);
  179. }
  180. .uni-click-white-bg {
  181. position: absolute;
  182. right: 0;
  183. bottom: 0;
  184. width: 50px;
  185. height: 50px;
  186. border-radius: 100% 0 0 0;
  187. border: 2px solid rgba(255,255,255,0.5);
  188. box-shadow:0px 0px 5px #888888;
  189. }
  190. .uni-click-grey-bg {
  191. position: absolute;
  192. right: 0;
  193. bottom: 0;
  194. z-index: 11;
  195. width: 48px;
  196. height: 48px;
  197. border-radius: 100% 0 0 0;
  198. background-color: rgba(0, 0, 0, 0.3);
  199. transition: background-color 0.2s;
  200. }
  201. .uni-click-bg-menu {
  202. background-color: rgba(117, 117, 249, 255);
  203. }
  204. .uni-click__circle {
  205. /* #ifndef APP-NVUE */
  206. display: flex;
  207. /* #endif */
  208. justify-content: center;
  209. align-items: center;
  210. position: absolute;
  211. right: 0;
  212. bottom: 0;
  213. width: 55px;
  214. height: 55px;
  215. z-index: 30;
  216. transform: rotate(135deg) scale(0.5) translateY(-20px);
  217. pointer-events: all;
  218. }
  219. .uni-click__image {
  220. /* #ifndef APP-NVUE */
  221. display: flex;
  222. /* #endif */
  223. justify-content: center;
  224. align-items: center;
  225. position: absolute;
  226. right: -8px;
  227. bottom: -2px;
  228. width: 55px;
  229. height: 55px;
  230. z-index: 29;
  231. transform: scale(0.5) translateY(10px);
  232. pointer-events: all;
  233. }
  234. .click-circle-v {
  235. position: absolute;
  236. width: 3px;
  237. height: 31px;
  238. left: 26px;
  239. top: 12px;
  240. background-color: white;
  241. }
  242. .click-circle-h {
  243. position: absolute;
  244. width: 31px;
  245. height: 3px;
  246. left: 12px;
  247. top: 26px;
  248. background-color: white;
  249. }
  250. .uni-fab__item--active {
  251. opacity: 1;
  252. }
  253. .uni-content__item {
  254. /* #ifndef APP-NVUE */
  255. display: flex;
  256. /* #endif */
  257. flex-direction: column;
  258. justify-content: center;
  259. align-items: center;
  260. width: 55px;
  261. height: 55px;
  262. opacity: 1;
  263. /* transition: opacity 0.2s; */
  264. }
  265. .content-child {
  266. position: absolute;
  267. top: 0;
  268. left: 0;
  269. width: 40px;
  270. height: 40px;
  271. line-height: 40px;
  272. border-radius: 50%;
  273. text-align: center;
  274. color: #fff;
  275. /* border: 1rpx solid #000000; */
  276. background-color: red;
  277. transform: rotateZ(var(--rotate)) translateY(80px);
  278. }
  279. .surround-box {
  280. position: absolute;
  281. top: 50%;
  282. left: 50%;
  283. width: 20px;
  284. height: 20px;
  285. margin-left: -10px;
  286. margin-top: -10px;
  287. border-radius: 50%;
  288. z-index: 50;
  289. /* background-color: #000; */
  290. }
  291. .circle {
  292. /* 这里一定要绝对定位,这样位置才能铺开来 */
  293. position: absolute;
  294. top: -10px;
  295. left: -10px;
  296. width: 40px;
  297. height: 40px;
  298. line-height: 40px;
  299. border-radius: 50%;
  300. text-align: center;
  301. z-index: 50;
  302. color: #fff;
  303. transform: rotateZ(var(--rotate)) translateY(80px);
  304. pointer-events: all;
  305. }
  306. .circle-line {
  307. position: absolute;
  308. top: -15px;
  309. left: 10px;
  310. width: 1px;
  311. height: 50px;
  312. text-align: center;
  313. background-image: linear-gradient(to top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.1));
  314. color: #fff;
  315. transform: rotateZ(135deg) translateY(80px);
  316. }
  317. .chircle-item {
  318. transform: rotate(180deg);
  319. display: flex;
  320. justify-content: center;
  321. flex-direction: column;
  322. align-items: center;
  323. }
  324. </style>