index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view class="flex-col" :style="{height: winHeight + 'px'}">
  3. <!-- #ifdef MP -->
  4. <view class="cart_nav">
  5. <nav-bar iconColor='#fff' ref="navBarRef" navTitle="游戏搭子" backgroundColor="#FF6702" :isBackgroundColor="false">
  6. </nav-bar>
  7. </view>
  8. <!-- #endif -->
  9. <view class='newsList tui-skeleton flex-col' style="background-color: #fff;flex: 1;">
  10. <view class='nav'>
  11. <scroll-view class="scroll-view_x" scroll-x scroll-with-animation :scroll-left="scrollLeft" style="width:auto;overflow:hidden;">
  12. <block v-for="(item,index) in navList" :key="index">
  13. <view class='item borRadius14 tui-skeleton-rect' :class='active==item.id?"on":""' @click='tabSelect(item.id, index)'>
  14. <view class="line1">{{item.name}}</view>
  15. <view class='line bg_color' v-if="active==item.id"></view>
  16. </view>
  17. </block>
  18. </scroll-view>
  19. </view>
  20. <view class='list' style="flex: 1;">
  21. <template v-if="active == 1">
  22. </template>
  23. <template v-if="active == 2">
  24. </template>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. // +----------------------------------------------------------------------
  31. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  32. // +----------------------------------------------------------------------
  33. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  34. // +----------------------------------------------------------------------
  35. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  36. // +----------------------------------------------------------------------
  37. // | Author: CRMEB Team <admin@crmeb.com>
  38. // +----------------------------------------------------------------------
  39. import navBar from '@/components/navBar';
  40. import animationType from '@/utils/animationType.js'
  41. import tuiSkeleton from '@/components/base/tui-skeleton.vue';
  42. import {
  43. getAddressList
  44. } from '@/api/user.js';
  45. let app = getApp();
  46. export default {
  47. components: {
  48. tuiSkeleton,
  49. navBar
  50. },
  51. data() {
  52. return {
  53. winHeight: 0,
  54. isNodes: 0, //控制什么时候开始抓取元素节点,只要数值改变就重新抓取
  55. autoplay: true,
  56. navList: [{
  57. id: 1,
  58. name: '本校'
  59. }, {
  60. id: 2,
  61. name: '同城'
  62. }],
  63. active: 1,
  64. scrollLeft: 0,
  65. addressItem: {}
  66. };
  67. },
  68. onLoad() {
  69. let that = this;
  70. uni.getSystemInfo({
  71. success: function(res) {
  72. that.winHeight = res.windowHeight
  73. },
  74. });
  75. this.getaddressInfo()
  76. },
  77. /**
  78. * 生命周期函数--监听页面显示
  79. */
  80. onShow: function() {
  81. let that = this;
  82. uni.$on('addressItem', function(res) {
  83. that.$set(that, 'addressItem', res);
  84. })
  85. },
  86. methods: {
  87. tabSelect(active, e) {
  88. this.active = active;
  89. this.scrollLeft = e * 60;
  90. },
  91. /*
  92. * 获取默认收货地址或者获取某条地址信息
  93. */
  94. getaddressInfo: function() {
  95. getAddressList().then(res => {
  96. console.log('地址', res)
  97. if (res.code = 200) {
  98. if (res.data.length !== 0) {
  99. this.addressItem = res.data.find(item => item.isDefault === true) || {} // this.addressItem = res.data[0];
  100. } else {
  101. this.addressItem = {}
  102. }
  103. console.log('默认地址', this.addressItem)
  104. }
  105. })
  106. }
  107. }
  108. }
  109. </script>
  110. <style lang="scss">
  111. .courie {
  112. padding: 14rpx 24rpx 0 24rpx;
  113. font-weight: 500;
  114. font-size: 23rpx;
  115. color: $bg-color-primary;
  116. background-color: #fff;
  117. image {
  118. width: 46rpx;
  119. height: 46rpx;
  120. margin-right: 15rpx;
  121. }
  122. }
  123. .newsList .swiper {
  124. width: 100%;
  125. position: relative;
  126. box-sizing: border-box;
  127. padding: 0 30rpx;
  128. }
  129. .newsList .swiper swiper {
  130. width: 100%;
  131. height: 365rpx;
  132. position: relative;
  133. }
  134. .newsList .swiper .slide-image {
  135. width: 100%;
  136. height: 335rpx;
  137. border-radius: 14rpx;
  138. }
  139. // #ifdef MP-WEIXIN
  140. .newsList .swiper .wx-swiper-dot {
  141. width: 12rpx !important;
  142. height: 12rpx !important;
  143. border-radius: 0;
  144. transform: rotate(-45deg);
  145. transform-origin: 0 100%;
  146. }
  147. .newsList .swiper .wx-swiper-dot~.wx-swiper-dot {
  148. margin-left: 5rpx;
  149. }
  150. .newsList .swiper .wx-swiper-dots.wx-swiper-dots-horizontal {
  151. margin-bottom: -15rpx;
  152. }
  153. // #endif
  154. // #ifdef APP-PLUS || H5
  155. .newsList .swiper .uni-swiper-dot {
  156. width: 12rpx !important;
  157. height: 12rpx !important;
  158. border-radius: 0;
  159. transform: rotate(-45deg);
  160. transform-origin: 0 100%;
  161. }
  162. .newsList .swiper .uni-swiper-dot~.uni-swiper-dot {
  163. margin-left: 5rpx;
  164. }
  165. .newsList .swiper .uni-swiper-dots.uni-swiper-dots-horizontal {
  166. margin-bottom: -15rpx;
  167. }
  168. // #endif
  169. .newsList .nav {
  170. padding: 0 24rpx;
  171. width: 100%;
  172. white-space: nowrap;
  173. box-sizing: border-box;
  174. padding-top: 43rpx;
  175. border-top-right-radius: 23rpx;
  176. }
  177. .newsList .nav .item {
  178. // max-width: 156rpx;
  179. display: inline-block;
  180. font-size: 32rpx;
  181. color: #999;
  182. }
  183. .newsList .nav .item.on {
  184. color: #282828;
  185. }
  186. .newsList .nav .item~.item {
  187. margin-left: 46rpx;
  188. }
  189. .newsList .nav .item .line {
  190. // width: 24rpx;
  191. height: 10rpx;
  192. border-radius: 6rpx;
  193. margin: 10rpx auto 0 auto;
  194. background-color: $bg-color-primary;
  195. }
  196. .newsList .nav .item .line1 {
  197. color: $bg-color-primary;
  198. }
  199. </style>