You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

297 lines
6.3 KiB

3 months ago
  1. <template>
  2. <view>
  3. <view class="cart_nav" :class="isBackgroundColor?'cart_nav_color':''" :style='"height:"+navH+"rpx;"'>
  4. <view class='navbarCon acea-row'>
  5. <!-- #ifdef MP -->
  6. <view class="select_nav flex justify-center align-center" id="home" :style="{ top: homeTop + 'rpx' }">
  7. <text class="iconfont icon-fanhui2 px-20" @tap="returns"></text>
  8. <text v-if="productType!=='video'" class="iconfont icon-gengduo5 px-20" @tap.stop="showNav"></text>
  9. <text v-if="productType!=='video'" class="nav_line"></text>
  10. </view>
  11. <!-- #endif -->
  12. <!-- #ifdef H5 -->
  13. <view id="home" class="home acea-row row-center-wrapper iconfont icon-shouye4 h5_back"
  14. :style="{ top: homeTop + 'rpx' }" @tap="goToHome">
  15. </view>
  16. <!-- #endif -->
  17. <!-- #ifndef APP-PLUS -->
  18. <view class="nav_title" :style="{ top: homeTop + 'rpx' }">{{navTitle}}</view>
  19. <!-- #endif -->
  20. <!-- #ifdef H5 -->
  21. <view class="right_select" :style="{ top: homeTop + 'rpx' }" @tap="showNav">
  22. <text class="iconfont icon-gengduo2"></text>
  23. </view>
  24. <!-- #endif -->
  25. </view>
  26. </view>
  27. <view class="dialog_nav" :style='"top:"+navH+"rpx;"' v-show="currentPage">
  28. <view class="dialog_nav_item" v-for="(item,index) in selectNavList" :key="index" @click="linkPage(item.url)">
  29. <text class="iconfont" :class="item.icon"></text>
  30. <text class="pl-20">{{item.name}}</text>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import animationType from '@/utils/animationType.js'
  37. import {
  38. mapGetters
  39. } from "vuex";
  40. let app = getApp();
  41. export default {
  42. data() {
  43. return {
  44. homeTop: 20,
  45. navH:"",
  46. currentPage:false,
  47. selectNavList:[
  48. {name:'首页',icon:'icon-shouye8',url:'/pages/index/index'},
  49. {name:'搜索',icon:'icon-sousuo6',url:'/pages/goods/goods_search/index'},
  50. {name:'我的收藏',icon:'icon-shoucang3',url:'/pages/users/user_goods_collection/index'},
  51. {name:'个人中心',icon:'icon-gerenzhongxin1',url:'/pages/user/index'},
  52. ]
  53. }
  54. },
  55. props:{
  56. navTitle:{
  57. type: String,
  58. default:''
  59. },
  60. isBackgroundColor: {
  61. type: Boolean,
  62. default: true
  63. },
  64. },
  65. computed: {
  66. ...mapGetters(['productType'])
  67. },
  68. created(){
  69. // #ifdef MP
  70. // 获取导航高度;
  71. uni.getSystemInfo({
  72. success: function(res) {
  73. app.globalData.navHeight = res.statusBarHeight * (750 / res.windowWidth) + 91;
  74. }
  75. });
  76. this.navH = app.globalData.navHeight;
  77. // #endif
  78. // #ifndef MP
  79. this.navH = 96;
  80. // #endif
  81. this.$emit('getNavH', this.navH)
  82. },
  83. onReady() {
  84. this.$nextTick(function() {
  85. // #ifdef MP
  86. const menuButton = uni.getMenuButtonBoundingClientRect();
  87. const query = uni.createSelectorQuery().in(this);
  88. query
  89. .select('#home')
  90. .boundingClientRect(data => {
  91. if(this.productType!=='video'){
  92. this.homeTop = menuButton.top * 2 + menuButton.height - data.height;
  93. }else{
  94. this.homeTop = 18;
  95. }
  96. })
  97. .exec();
  98. // #endif
  99. });
  100. },
  101. methods: {
  102. //返回首页
  103. goToHome(){
  104. uni.switchTab({
  105. url:'/pages/index/index'
  106. })
  107. },
  108. returns: function() {
  109. uni.navigateBack();
  110. },
  111. showNav(){
  112. this.currentPage = !this.currentPage;
  113. },
  114. //下拉导航页面跳转
  115. linkPage(url){
  116. if(url == '/pages/index/index' || url == '/pages/user/index'){
  117. uni.switchTab({
  118. url
  119. })
  120. }else{
  121. uni.navigateTo({
  122. animationType: animationType.type,
  123. animationDuration: animationType.duration,
  124. url
  125. })
  126. }
  127. this.currentPage = false
  128. },
  129. touchStart(){
  130. this.currentPage = false;
  131. }
  132. }
  133. }
  134. </script>
  135. <style scoped lang="scss">
  136. .pl-20{
  137. padding-left: 20rpx;
  138. }
  139. .cart_nav{
  140. position: fixed;
  141. top: 0;
  142. left: 0;
  143. z-index: 99;
  144. width: 100%;
  145. }
  146. .cart_nav_color{
  147. @include main_bg_color(theme);
  148. }
  149. .navbarCon {
  150. position: absolute;
  151. bottom: 0;
  152. height: 100rpx;
  153. width: 100%;
  154. }
  155. .h5_back {
  156. color: #fff;
  157. position: fixed;
  158. left:20rpx;
  159. font-size: 32rpx;
  160. text-align: center;
  161. line-height: 58rpx;
  162. }
  163. .select_nav{
  164. border: 1px solid rgba(0, 0, 0, 0.07);
  165. width: 170rpx !important;
  166. height: 60rpx !important;
  167. border-radius: 33rpx;
  168. background: rgba(255, 255, 255, 0.6);
  169. color: #000;
  170. position: fixed;
  171. font-size: 18px;
  172. line-height: 58rpx;
  173. z-index: 1000;
  174. left: 14rpx;
  175. }
  176. .px-20{
  177. padding: 0 20rpx 0;
  178. }
  179. .nav_line{
  180. content: '';
  181. display: inline-block;
  182. width: 1px;
  183. height: 34rpx;
  184. background: #ddd;
  185. position: absolute;
  186. left: 0;
  187. right: 0;
  188. margin: auto;
  189. }
  190. .container_detail{
  191. /* #ifdef MP */
  192. margin-top:32rpx;
  193. /* #endif */
  194. }
  195. .tab_nav{
  196. width: 100%;
  197. height: 48px;
  198. padding:0 30rpx 0;
  199. }
  200. .nav_title{
  201. width: 200rpx;
  202. height: 58rpx;
  203. line-height: 58rpx;
  204. color: #fff;
  205. font-size: 36rpx;
  206. position: fixed;
  207. text-align: center;
  208. left: 0;
  209. right: 0;
  210. margin: auto;
  211. }
  212. .right_select{
  213. position: fixed;
  214. right: 20rpx;
  215. color: #fff;
  216. text-align: center;
  217. line-height: 58rpx;
  218. }
  219. .select_nav{
  220. width: 170rpx !important;
  221. height: 60rpx !important;
  222. border-radius: 33rpx;
  223. background: rgba(255, 255, 255, 0.6);
  224. color: #000;
  225. position: fixed;
  226. font-size: 18px;
  227. line-height: 58rpx;
  228. z-index: 1000;
  229. left: 14rpx;
  230. }
  231. .px-20{
  232. padding: 0 20rpx 0;
  233. }
  234. .justify-center{
  235. justify-content: center;
  236. }
  237. .align-center {
  238. align-items: center;
  239. }
  240. .dialog_nav{
  241. position: fixed;
  242. /* #ifdef MP */
  243. left: 14rpx;
  244. /* #endif */
  245. /* #ifdef H5 || APP-PLUS*/
  246. right: 14rpx;
  247. /* #endif */
  248. width: 240rpx;
  249. background: #FFFFFF;
  250. box-shadow: 0px 0px 16rpx rgba(0, 0, 0, 0.08);
  251. z-index: 999;
  252. border-radius: 14rpx;
  253. &::before{
  254. content: '';
  255. width: 0;
  256. height: 0;
  257. position: absolute;
  258. /* #ifdef MP */
  259. left: 0;
  260. right: 0;
  261. margin:auto;
  262. /* #endif */
  263. /* #ifdef H5 || APP-PLUS */
  264. right: 8px;
  265. /* #endif */
  266. top:-9px;
  267. border-bottom: 10px solid #fff;
  268. border-left: 10px solid transparent; /*transparent 表示透明*/
  269. border-right: 10px solid transparent;
  270. }
  271. }
  272. .dialog_nav_item{
  273. width: 100%;
  274. height: 84rpx;
  275. line-height: 84rpx;
  276. padding: 0 20rpx 0;
  277. box-sizing: border-box;
  278. border-bottom: #eee;
  279. font-size: 28rpx;
  280. color: #333;
  281. position: relative;
  282. .iconfont{
  283. font-size: 32rpx;
  284. }
  285. &::after{
  286. content: '';
  287. position: absolute;
  288. width:86px;
  289. height: 1px;
  290. background-color: #EEEEEE;
  291. bottom: 0;
  292. right: 0;
  293. }
  294. }
  295. </style>