MomentsHeader.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <view class="top_container">
  3. <u-navbar
  4. title="工作圈"
  5. placeholder
  6. :class="{ transparent_wrap: needTransparent }"
  7. >
  8. <view v-if="!showBack" class="action_bar" slot="right">
  9. <image :src="commentIcon" @click="showNotificatons" />
  10. <u-badge v-show="unreadCount > 0" isDot></u-badge>
  11. <image class="more_icon" :src="moreIcon" @click="showMore" />
  12. </view>
  13. <view slot="left">
  14. <u-icon
  15. @click="goBack"
  16. name="arrow-left"
  17. :color="needTransparent ? '#fff' : '#333'"
  18. size="24"
  19. ></u-icon>
  20. <u-overlay
  21. :show="moreMenuVisible"
  22. @click="moreMenuVisible = false"
  23. opacity="0"
  24. >
  25. <view
  26. :style="{ top: popMenuPosition.top, right: popMenuPosition.right }"
  27. class="more_menu"
  28. >
  29. <view
  30. @click="clickMenu(item)"
  31. v-for="item in moreMenus"
  32. :key="item.idx"
  33. class="menu_item"
  34. >
  35. <image :src="item.icon" mode=""></image>
  36. <text>{{ item.title }}</text>
  37. </view>
  38. </view>
  39. </u-overlay>
  40. </view>
  41. </u-navbar>
  42. <view class="info_row">
  43. <my-avatar
  44. size="48"
  45. :src="
  46. showBack ? baseUserInfo.faceURL : $store.getters.storeSelfInfo.faceURL
  47. "
  48. :desc="
  49. showBack
  50. ? baseUserInfo.nickname
  51. : $store.getters.storeSelfInfo.nickname
  52. "
  53. @click="$emit('topbarClick')"
  54. />
  55. <view class="info_name" @click="$emit('topbarClick')">
  56. {{
  57. showBack
  58. ? baseUserInfo.nickname
  59. : $store.getters.storeSelfInfo.nickname
  60. }}
  61. </view>
  62. </view>
  63. <view
  64. v-show="unreadCount > 0 && !showBack"
  65. class="new_message_btn"
  66. @click="showNotificatons"
  67. >
  68. {{ `${unreadCount}条新消息` }}
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. import MyAvatar from "../../../../components/MyAvatar/index.vue";
  74. import { PageEvents } from "../../../../constant";
  75. import { getMomentUnreadCount, clearMomentUnreadCount } from "../../../../api/moments";
  76. const moments_top_more = "https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/moments_top_more.png";
  77. const moments_top_more_black = "https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/moments_top_more_black.png";
  78. const moments_top_coments = "https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/moments_top_coments.png";
  79. const moments_top_coments_black = "https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/moments_top_coments_black.png";
  80. export default {
  81. components: {
  82. MyAvatar,
  83. },
  84. props: {
  85. needTransparent: Boolean,
  86. showBack: Boolean,
  87. baseUserInfo: {
  88. type: Object,
  89. default: () => {},
  90. },
  91. },
  92. data() {
  93. return {
  94. moreMenuVisible: false,
  95. popMenuPosition: {
  96. top: 0,
  97. right: 0,
  98. },
  99. moreMenus: [
  100. {
  101. idx: 0,
  102. title: "发布图文",
  103. icon: "https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/moments_more_pic.png",
  104. },
  105. {
  106. idx: 1,
  107. title: "发布视频",
  108. icon: "https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/moments_more_video.png",
  109. },
  110. ],
  111. unreadCount: 0,
  112. };
  113. },
  114. computed: {
  115. moreIcon() {
  116. return this.needTransparent ? moments_top_more : moments_top_more_black;
  117. },
  118. commentIcon() {
  119. return this.needTransparent
  120. ? moments_top_coments
  121. : moments_top_coments_black;
  122. },
  123. },
  124. beforeMount() {
  125. this.getUnHandlerMessageCount();
  126. uni.$on(
  127. PageEvents.RefreshMomentsUnreadCount,
  128. this.getUnHandlerMessageCount,
  129. );
  130. },
  131. beforeDestroy() {
  132. uni.$off(
  133. PageEvents.RefreshMomentsUnreadCount,
  134. this.getUnHandlerMessageCount,
  135. );
  136. },
  137. methods: {
  138. clickMenu({ idx }) {
  139. uni.$u.route("/pages_im/pages/moments/momentsRelease/index", {
  140. momentsType: idx,
  141. });
  142. },
  143. goBack() {
  144. uni.navigateBack();
  145. },
  146. async showMore() {
  147. const { right, bottom } = await this.getEl(".more_icon");
  148. this.popMenuPosition.right = `${
  149. uni.getWindowInfo().windowWidth - right
  150. }px`;
  151. this.popMenuPosition.top = `${bottom + 12}px`;
  152. this.moreMenuVisible = true;
  153. },
  154. showNotificatons() {
  155. if (this.unreadCount > 0) {
  156. clearMomentUnreadCount(1);
  157. }
  158. uni.$u.route("/pages_im/pages/moments/interactiveMessage/index");
  159. },
  160. getEl(el) {
  161. return new Promise((resolve) => {
  162. const query = uni.createSelectorQuery().in(this);
  163. query
  164. .select(el)
  165. .boundingClientRect((data) => {
  166. resolve(data);
  167. })
  168. .exec();
  169. });
  170. },
  171. getUnHandlerMessageCount() {
  172. getMomentUnreadCount().then((data) => {
  173. console.log(data);
  174. this.unreadCount = data.total;
  175. });
  176. },
  177. },
  178. };
  179. </script>
  180. <style lang="scss" scoped>
  181. .top_container {
  182. display: flex;
  183. flex-direction: column;
  184. justify-content: space-between;
  185. padding-top: var(--status-bar-height);
  186. padding-bottom: 48rpx;
  187. height: 444rpx;
  188. background-image: url("https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/moments_bg.png");
  189. background-repeat: no-repeat;
  190. background-size: 100% 100%;
  191. margin-bottom: 24rpx;
  192. position: relative;
  193. .back_icon {
  194. margin-left: 12rpx;
  195. }
  196. /deep/.u-navbar__content {
  197. background-color: #f8f8f8 !important;
  198. .u-navbar__content__title {
  199. color: #000;
  200. }
  201. }
  202. /deep/.u-status-bar {
  203. background-color: #f8f8f8 !important;
  204. }
  205. .transparent_wrap {
  206. /deep/.u-status-bar {
  207. background-color: transparent !important;
  208. }
  209. /deep/.u-navbar__content {
  210. background-color: transparent !important;
  211. .u-navbar__content__title {
  212. color: #fff;
  213. }
  214. }
  215. }
  216. .action_bar {
  217. display: flex;
  218. position: absolute;
  219. right: 32rpx;
  220. image {
  221. width: 22px;
  222. height: 22px;
  223. &:last-child {
  224. margin-left: 32rpx;
  225. }
  226. }
  227. }
  228. .more_menu {
  229. position: absolute;
  230. z-index: 999;
  231. box-shadow: 0px 0px 6px 2px rgba(0, 0, 0, 0.16);
  232. width: max-content;
  233. border-radius: 12rpx;
  234. background-color: #fff;
  235. padding: 12rpx 0;
  236. .menu_item {
  237. display: flex;
  238. align-items: center;
  239. padding: 20rpx 48rpx;
  240. font-size: 28rpx;
  241. color: $uni-text-color;
  242. border-bottom: 1px solid #f0f0f0;
  243. image {
  244. width: 16px;
  245. height: 16px;
  246. margin-right: 24rpx;
  247. }
  248. &:last-child {
  249. border: none;
  250. }
  251. }
  252. }
  253. .info_row {
  254. display: flex;
  255. align-items: center;
  256. padding: 0 32rpx;
  257. .info_name {
  258. @include nomalEllipsis;
  259. margin-left: 24rpx;
  260. color: #fff;
  261. font-size: 36rpx;
  262. font-weight: 500;
  263. }
  264. }
  265. .new_message_btn {
  266. position: absolute;
  267. bottom: -32rpx;
  268. left: 50%;
  269. transform: translate(-50%, 100%);
  270. padding: 8rpx 28rpx;
  271. border-radius: 4px;
  272. background: rgba(22, 25, 28, 0.4);
  273. color: #fff;
  274. }
  275. }
  276. </style>