Navbar.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <view class="">
  3. <uni-nav-bar v-if="navType === 'custom'" :status-bar="true" :shadow="false" :border="false" :fixed="true"
  4. :color="color" :background-color="backgroundColor" :leftWidth="leftWidth" :rightWidth="rightWidth">
  5. <view class="" style="width: 100%">
  6. <slot></slot>
  7. </view>
  8. </uni-nav-bar>
  9. <uni-nav-bar v-else-if="navType === 'search'" :title="title" :status-bar="true" :shadow="false" :border="false"
  10. :fixed="true" :color="color" :background-color="backgroundColor" :leftWidth="leftWidth"
  11. :rightWidth="rightWidth">
  12. <view slot="left">
  13. <IconText v-if="showBack" style="padding: 8px;" @click.native="handle_click_search" :color="color"
  14. :code="`\ue8be`" size="16" />
  15. </view>
  16. </uni-nav-bar>
  17. <uni-nav-bar v-else-if="navType === 'front'" :title="title" :status-bar="true" :shadow="false" :border="false"
  18. :fixed="true" :color="color" :background-color="backgroundColor" :leftWidth="leftWidth"
  19. :rightWidth="rightWidth" class="front-seatch-box">
  20. <view slot="left" class="front-seatch-left">
  21. <view class="front-seatch-title">
  22. <!-- <IconText class="icon" size="18" color="#009360" :code="`\ue883`"></IconText> -->
  23. <image :src="staticUrl ? staticUrl + 'front-title.png' : ''" class="pic" mode="heightFix">
  24. </view>
  25. <view class="front-search-box" @click="handle_click_search">
  26. <IconText class="icon" size="16" color="#B3B3B3" :code="`\ue887`"></IconText>
  27. 搜索
  28. </view>
  29. </view>
  30. <view class="bg"></view>
  31. </uni-nav-bar>
  32. <uni-nav-bar v-else-if="navType === 'user'" :title="title" :status-bar="true" :shadow="false" :border="false"
  33. :fixed="true" :color="color" :background-color="backgroundColor" :leftWidth="leftWidth"
  34. :rightWidth="rightWidth">
  35. <view class="user-navbar-box">
  36. <view class="user-navbar-bg"></view>
  37. {{title}}
  38. </view>
  39. <view slot="left">
  40. <view class="user-left">
  41. <IconText style="padding: 8px;" @click.native="toMessage" :color="color" :code="`\ue899`"
  42. size="20" />
  43. <view class="num">{{_yesNum}}</view>
  44. </view>
  45. </view>
  46. </uni-nav-bar>
  47. <uni-nav-bar v-else :title="title" :status-bar="true" :shadow="false" :border="false" :fixed="true"
  48. :color="color" :background-color="backgroundColor" :leftWidth="leftWidth" :rightWidth="rightWidth">
  49. <view slot="left">
  50. <IconText v-if="showBack" style="padding: 8px;" @click.native="handle_click_back" :color="color"
  51. :code="`\ue8be`" size="16" />
  52. <IconText v-if="showHome" style="padding: 8px;" @click.native="handle_click_home" :color="color"
  53. :code="`\ue75f`" size="16" />
  54. </view>
  55. </uni-nav-bar>
  56. </view>
  57. </template>
  58. <script lang="ts">
  59. import {
  60. Component,
  61. Prop,
  62. Vue
  63. } from 'vue-property-decorator';
  64. import {
  65. namespace
  66. } from 'vuex-class';
  67. const baseModule = namespace('base');
  68. @Component({})
  69. export default class Navbar extends Vue {
  70. @baseModule.Getter('_yesNum') _yesNum : any;
  71. @Prop({
  72. default: ''
  73. })
  74. private title ?: string; // 标题
  75. @Prop({
  76. default: true
  77. })
  78. private showBack ?: boolean; // 是否展示返回按钮
  79. @Prop({
  80. default: false
  81. })
  82. private showHome ?: boolean; // 是否展示返回按钮
  83. @Prop({
  84. default: true
  85. })
  86. private statusBar ?: boolean; //
  87. @Prop({
  88. default: false
  89. })
  90. private shadow ?: boolean; //
  91. @Prop({
  92. default: false
  93. })
  94. private border ?: boolean; //
  95. @Prop({
  96. default: true
  97. })
  98. private fixed ?: boolean; //
  99. @Prop({
  100. default: '#ffffff'
  101. })
  102. private backgroundColor ?: string; //
  103. @Prop({
  104. default: '#000000'
  105. })
  106. private color ?: string; //
  107. @Prop({
  108. default: ''
  109. })
  110. private navType ?: string; //navbar类型
  111. @Prop({
  112. default: ''
  113. })
  114. private leftWidth ?: string;
  115. @Prop({
  116. default: ''
  117. })
  118. private rightWidth ?: string;
  119. staticUrl : string = this.$oss_url; //oss地址
  120. handle_click_back() : void {
  121. console.log(this.$Router)
  122. this.$Router.back(1);
  123. }
  124. handle_click_search() {
  125. this.$Router.push({
  126. path: '/packages/goods/search'
  127. })
  128. }
  129. handle_click_home() {
  130. this.$Router.pushTab({
  131. path: '/pages/front/front'
  132. })
  133. }
  134. toMessage() {
  135. this.$Router.push({
  136. path: '/packages/user/user/message'
  137. })
  138. }
  139. }
  140. </script>
  141. <style lang="scss">
  142. // .front-seatch-box{
  143. // background: linear-gradient(270deg, #EBF2F0 -6%, #F3F4F4 110%);
  144. // }
  145. .front-search-box {
  146. height: vw(32);
  147. // width: vw(124);
  148. box-sizing: border-box;
  149. // border: vw(1) solid rgba(255, 255, 255, 0.3);
  150. border-radius: vw(16);
  151. @include flex-x(flex-start);
  152. background: #fff;
  153. position: relative;
  154. z-index: 10;
  155. padding-left: vw(10);
  156. box-sizing: border-box;
  157. flex: 1;
  158. box-sizing: border-box;
  159. margin-left: vw(12);
  160. @include word-vw(14, #333);
  161. .icon {
  162. margin-right: vw(8);
  163. }
  164. }
  165. .front-seatch-left {
  166. width: 100%;
  167. @include flex-x();
  168. }
  169. .front-seatch-title {
  170. // position: absolute;
  171. // width: calc(100vw - 20px);
  172. height: 44px;
  173. line-height: 44px;
  174. position: relative;
  175. z-index: 10;
  176. // bottom: 0;
  177. // z-index: 9;
  178. // text-align: center;
  179. font-size: vw(16);
  180. @include flex-x(center);
  181. .pic{
  182. height: 36px;
  183. }
  184. }
  185. .user-left {
  186. @include flex-x();
  187. position: relative;
  188. height: vw(24);
  189. .num{
  190. position: absolute;
  191. top: 0;
  192. right: vw(2);
  193. min-width: vw(12);
  194. height: vw(12);
  195. background: #CF174E;
  196. @include flex-x(center);
  197. border-radius: vw(6);
  198. @include word-vw(10, #fff);
  199. padding: 0 vw(3);
  200. }
  201. }
  202. .bg {
  203. position: absolute;
  204. width: 100%;
  205. height: 100%;
  206. background: linear-gradient(270deg, #EBF2F0 -6%, #F3F4F4 110%);
  207. top: 0;
  208. left: 0;
  209. }
  210. .user-navbar-box {
  211. width: 100%;
  212. @include flex-x(center);
  213. .user-navbar-bg {
  214. position: absolute;
  215. width: 100%;
  216. height: 100%;
  217. top: 0;
  218. left: 0;
  219. background: linear-gradient(90deg, #FEF4F6 0%, #F2FBFB 100%);
  220. z-index: -1;
  221. }
  222. }
  223. </style>