main-action-menu.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <view @touchmove.stop.prevent="moveHandle('touchmove')" @click="moveHandle('click')" v-if="isActive">
  3. <view class="main-action-menu" :animation="animationData" :style="{ top: height + 'px' }">
  4. <view class="main-action-menu-top-arrow"></view>
  5. <view class="menu-list">
  6. <view class="menu-item" @click="go2CreateGroup">
  7. <view class="menu-item-icon">
  8. <view class="wxfont message2"></view>
  9. </view>
  10. <view class="text">发起群聊</view>
  11. </view>
  12. <view class="menu-item" @click="go2SearchFriend">
  13. <view class="menu-item-icon">
  14. <view class="wxfont add2"></view>
  15. </view>
  16. <view class="text">添加朋友</view>
  17. </view>
  18. <view class="menu-item" @click="go2ScanQrCode">
  19. <view class="menu-item-icon">
  20. <view class="wxfont qr_code"></view>
  21. </view>
  22. <view class="text">扫一扫</view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="main-action-menu-background-model"></view>
  27. </view>
  28. </template>
  29. <script>
  30. import Config from "../../config";
  31. import store from "../../store";
  32. export default {
  33. data() {
  34. return {
  35. height: 0,//距离顶部高度oo
  36. isActive: false,
  37. animationData: {}
  38. };
  39. },
  40. props: {
  41. list: {
  42. type: Array,
  43. default() {
  44. return [{}];
  45. }
  46. }
  47. },
  48. onShow() {
  49. },
  50. mounted() {
  51. this.getstatusBarHeight();
  52. let animation = uni.createAnimation({
  53. duration: 300,
  54. timingFunction: 'linear'
  55. });
  56. this.animation = animation;
  57. },
  58. methods: {
  59. go2CreateGroup() {
  60. let sharedContactState = store.state.contact;
  61. let users = sharedContactState.favContactList.concat(sharedContactState.friendList);
  62. users = users.filter(u => {
  63. return u.uid !== Config.FILE_HELPER_ID
  64. });
  65. this.$pickUser({
  66. users: users,
  67. successCB: users => {
  68. // TODO 创建群聊会比较慢,可以在这儿加一个 loading 页面
  69. store.createConversation(users, (conversation) => {
  70. // 不加延时的话,不能正常切换页面,会报莫名其妙的错误
  71. setTimeout(() => {
  72. this.$go2ConversationPage();
  73. }, 50)
  74. }, err => {
  75. })
  76. }
  77. });
  78. },
  79. go2SearchFriend() {
  80. uni.navigateTo({
  81. url: '/pages/contact/SearchUserPage',
  82. fail: err => {
  83. }
  84. })
  85. },
  86. go2ScanQrCode() {
  87. uni.scanCode({
  88. success: function (res) {
  89. console.log('条码类型:' + res.scanType);
  90. console.log('条码内容:' + res.result);
  91. if (res.result){
  92. // TODO
  93. // wildfirechat://pcsession/xxxx
  94. uni.showToast({
  95. title: '扫码成功: ' + res.result,
  96. icon: 'none',
  97. });
  98. }
  99. }
  100. });
  101. },
  102. showAnimation() {
  103. this.animation.opacity(1).step();
  104. this.animationData = this.animation.export();
  105. },
  106. hideAnimation() {
  107. this.animation.opacity(0).step();
  108. this.animationData = this.animation.export();
  109. },
  110. moveHandle(e) {
  111. this.hide()
  112. },
  113. show() {
  114. this.isActive = true
  115. setTimeout(() => {
  116. this.showAnimation()
  117. }, 30)
  118. },
  119. hide() {
  120. this.isActive = false
  121. this.hideAnimation()
  122. },
  123. getstatusBarHeight() {
  124. let SystemInfo = uni.getSystemInfoSync();
  125. // #ifdef H5
  126. this.height = SystemInfo.safeArea.top + SystemInfo.windowTop;
  127. // #endif
  128. }
  129. }
  130. };
  131. </script>
  132. <style scoped>
  133. .main-action-menu {
  134. width: 300rpx;
  135. position: fixed;
  136. z-index: 9999;
  137. top: -10px;
  138. right: 16rpx;
  139. display: flex;
  140. flex-direction: row;
  141. flex-wrap: wrap;
  142. opacity: 0;
  143. }
  144. .main-action-menu-background-model {
  145. background-color: rgba(0, 0, 0, 0);
  146. position: fixed;
  147. top: 0;
  148. bottom: 0;
  149. right: 0;
  150. left: 0;
  151. z-index: 9998;
  152. }
  153. .main-action-menu-top-arrow {
  154. width: 0px;
  155. height: 0px;
  156. border: 10px solid transparent;
  157. border-bottom-color: #4C4C4C;
  158. margin-left: auto;
  159. margin-right: 20rpx;
  160. }
  161. .menu-list {
  162. width: 100%;
  163. background-color: #4C4C4C;
  164. border-radius: 10rpx;
  165. }
  166. .menu-item {
  167. display: flex;
  168. flex-direction: row;
  169. align-items: center;
  170. padding: 0rpx 36rpx;
  171. padding-right: 0;
  172. }
  173. .menu-item-icon {
  174. width: 38rpx;
  175. height: 38rpx;
  176. margin-right: 28rpx;
  177. color: #fff;
  178. }
  179. .menu-item-icon .wxfont {
  180. font-size: 40rpx;
  181. }
  182. .menu-item .text {
  183. color: #fff;
  184. font-size: 32rpx;
  185. border-bottom: 1px #535353 solid;
  186. padding: 30rpx 0rpx;
  187. flex: 1;
  188. }
  189. .menu-item:nth-last-child(1) .text {
  190. border: none;
  191. }
  192. </style>