header.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <!-- 导航条 -->
  3. <view class="position-top-center" :style="{ height: height + 'px',width: width + 'px', }">
  4. <view class="
  5. header-bar
  6. padding-lr-bj
  7. justify-between
  8. " :style="{
  9. height: height + 'px',
  10. width: width + 'px',
  11. paddingTop: top + 'px',
  12. backgroundColor:'transparent',
  13. }">
  14. <view class="flex flex-row align-center">
  15. <view>
  16. <view class="text-xxxl padding-left padding-right">
  17. <uni-icons type="videocam" size="30" color="#fff" @tap="handleRelease"></uni-icons>
  18. </view>
  19. </view>
  20. <view v-for="(item, index) in currentList" :key="index"
  21. class="header-tag position-relative align-center justify-center" @tap="onChange(item.type)">
  22. <text class="text-34 text-white-7"
  23. :class="{ active: currentItemId === item.type }">{{ item.name }}</text>
  24. <view v-if="currentItemId === item.type" class="header-tag-active"></view>
  25. </view>
  26. <view class="flex-user">
  27. <view class="text-xxxl margin-right-sm">
  28. <uni-icons type="person" size="30" color="#fff" @tap="toUser"></uni-icons>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import uniIcons from "@/components/uni-icons/uni-icons.vue";
  37. import _data from '@/common/_data.js'
  38. import _get from '@/common/_get';
  39. export default {
  40. props: {
  41. navColor: {
  42. type: String,
  43. default: "#fd4705",
  44. },
  45. currentItemId: {
  46. type: String,
  47. default: "",
  48. },
  49. currentList: {
  50. type: Array,
  51. default () {
  52. return [];
  53. },
  54. },
  55. height: {
  56. type: Number,
  57. default: 0,
  58. },
  59. top: {
  60. type: Number,
  61. default: 0,
  62. },
  63. width: {
  64. type: Number,
  65. default: 0,
  66. }
  67. },
  68. components: {
  69. uniIcons,
  70. },
  71. data() {
  72. return {
  73. my_data: {}
  74. }
  75. },
  76. mounted() {
  77. let _this = this;
  78. _get.getUserInfo({});
  79. uni.$on('data_user_info', function(data) {
  80. data.photo = data.photo + '?_=' + +Math.random()
  81. data.photo = data.photo.replace(/(\?_=)[\d\.]+$/, '$1' + Math.random());
  82. _this.my_data = data;
  83. _data.data('user_info', data)
  84. });
  85. },
  86. methods: {
  87. onChange(e) {
  88. this.$emit("onChange", e);
  89. },
  90. // 点击发布
  91. handleRelease() {
  92. console.log("发布")
  93. let itemList = ["发布短视频"];
  94. let url = ["./add?type=video"];
  95. uni.showActionSheet({
  96. itemList: itemList,
  97. success: (res) => {
  98. uni.navigateTo({
  99. url: url[res.tapIndex],
  100. });
  101. },
  102. });
  103. },
  104. toUser() {
  105. uni.navigateTo({
  106. url: "./user?id=" + this.my_data.id
  107. })
  108. },
  109. },
  110. };
  111. </script>
  112. <style scoped>
  113. @import "@/static/css/common.css";
  114. .flex-user {
  115. flex: 1;
  116. display: flex;
  117. flex-direction: row;
  118. justify-content: flex-end;
  119. }
  120. .header-icon-tag {
  121. position: absolute;
  122. right: -8rpx;
  123. top: -4rpx;
  124. width: 16rpx;
  125. height: 16rpx;
  126. border-radius: 2000%;
  127. background-color: red;
  128. }
  129. .flex-row {
  130. flex-direction: row;
  131. }
  132. .header-bar {
  133. display: flex;
  134. flex-direction: row;
  135. }
  136. .header-tag {
  137. height: 71rpx;
  138. width: 110rpx;
  139. }
  140. .header-tag-active {
  141. position: absolute;
  142. bottom: 0;
  143. background-color: #fff;
  144. width: 22rpx;
  145. height: 4rpx;
  146. border-radius: 200rpx;
  147. }
  148. .active {
  149. font-weight: bold;
  150. color: #fff;
  151. }
  152. </style>