shopPage.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view class="store-page">
  3. <view class="status_bar">
  4. <!-- 这里是状态栏 -->
  5. </view>
  6. <view class="header">
  7. <div class="search">
  8. <u-icon @click="back" style="margin:0 10rpx 0;" name="arrow-left" size="40" color="#fff"></u-icon>
  9. <u-search :show-action="false" border-color="#fff" bg-color="#fff" v-model="keyword" @search="search" placeholder="请输入搜索" />
  10. <u-icon @click="shareChange()" style="margin:0 10rpx 0;" name="share-fill" size="40" color="#fff"></u-icon>
  11. </div>
  12. <view class="tab-header">
  13. <text :class="{ cur: tabIndex == 0 }" @click="checkNavigation(0)">首页</text>
  14. <text :class="{ cur: tabIndex == 1 }" @click="checkNavigation(1)">商品</text>
  15. </view>
  16. </view>
  17. <swiper :current="tabIndex" class="swiper-box" @change="tabChange">
  18. <swiper-item class="swiper-item" v-for="(item, index) in indexCats" :key="index">
  19. <scroll-view class="scroll-v" scroll-anchoring enableBackToTop="true" scroll-y @refresherrefresh="refresh()" @scroll="pageScroll">
  20. <storePageMain :load="load" :storeId="storeId" v-if="index == 0"></storePageMain>
  21. <storePageGoods :load="load" :categoryId="item" :storeId="storeId" v-if="index == 1"></storePageGoods>
  22. </scroll-view>
  23. </swiper-item>
  24. </swiper>
  25. <!-- 分享 -->
  26. <shares type="shops" :link="'/pages/product/shopPage?id='+ this.storeId" v-if="shareFlage" @close="shareFlage = false" />
  27. </view>
  28. </template>
  29. <script>
  30. import shares from "@/components/m-share/index"; //分享
  31. import storePageMain from "./shopPageMain.vue";
  32. import storePageGoods from "./shopPageGoods.vue";
  33. export default {
  34. components: {
  35. shares,
  36. storePageMain,
  37. storePageGoods,
  38. },
  39. data() {
  40. return {
  41. shareFlage: false, //分享share
  42. tabIndex: 0, //默认为第一个tab
  43. keyword: "", //搜索关键字
  44. load: false,
  45. storeId: undefined, //店铺id
  46. indexCats: [0, 1], //默认为2个tab
  47. loadIndex: 1, //加载的距离
  48. };
  49. },
  50. /**
  51. * 加载
  52. */
  53. async onLoad(options) {
  54. this.storeId = options.id;
  55. },
  56. mounted() {},
  57. methods: {
  58. // 点击分享
  59. async shareChange() {
  60. this.shareFlage = true;
  61. },
  62. /**
  63. * 搜索
  64. */
  65. search() {
  66. uni.navigateTo({
  67. url: `/pages/navigation/search/searchPage?storeId=${this.storeId}&keyword=${this.keyword}`,
  68. });
  69. },
  70. /**
  71. * 下滑加载
  72. */
  73. pageScroll(e) {
  74. if (e.detail.scrollTop > 300 * this.loadIndex) {
  75. this.loadIndex++;
  76. this.load = this.loadIndex;
  77. }
  78. },
  79. /**
  80. * 返回
  81. */
  82. back() {
  83. if (getCurrentPages().length == 1) {
  84. uni.switchTab({
  85. url: "/pages/tabbar/home/index",
  86. });
  87. } else {
  88. uni.navigateBack();
  89. }
  90. },
  91. /**
  92. * 点击导航栏
  93. */
  94. checkNavigation(index) {
  95. this.tabIndex = index;
  96. },
  97. /**
  98. * 滑动回调
  99. */
  100. tabChange(e) {
  101. this.tabIndex = e.detail.current;
  102. this.checkNavigation(this.tabIndex);
  103. },
  104. },
  105. };
  106. </script>
  107. <style>
  108. page {
  109. height: 100%;
  110. }
  111. </style>
  112. <style lang="scss" scoped>
  113. // #ifdef MP-WEIXIN
  114. @import "./mp-shopPage.scss";
  115. // #endif
  116. input[type="search"] {
  117. -webkit-appearance: none;
  118. // 也可以去除加上border: 0;之类的 根据设计图来
  119. }
  120. input::-webkit-search-cancel-button {
  121. display: none;
  122. }
  123. // 关闭的按钮
  124. .storeScrollBox {
  125. overflow-y: auto;
  126. }
  127. .store-page {
  128. height: 100%;
  129. // background: #fff;
  130. overflow: auto;
  131. .tab-header {
  132. height: 80rpx;
  133. display: flex;
  134. justify-content: space-between;
  135. align-items: center;
  136. font-size: 28rpx;
  137. z-index: 9999;
  138. text {
  139. width: 50%;
  140. text-align: center;
  141. position: relative;
  142. color: #fff;
  143. &.cur {
  144. font-size: 30rpx;
  145. font-weight: bold;
  146. color: #fff;
  147. &::after {
  148. content: "";
  149. position: absolute;
  150. width: 30rpx;
  151. border: 1px solid #fff;
  152. bottom: -6rpx;
  153. left: 50%;
  154. margin-left: -15rpx;
  155. }
  156. }
  157. }
  158. }
  159. .header-line {
  160. height: 1px;
  161. background: #f2f2f2;
  162. position: fixed;
  163. top: 170rpx;
  164. left: 0;
  165. right: 0;
  166. z-index: 999;
  167. }
  168. }
  169. .swiper-box {
  170. width: 750rpx;
  171. height: calc(
  172. 100% - var(--status-bar-height) - var(--window-top) - var(--window-bottom) -
  173. (160rpx) - 16rpx - 28rpx
  174. );
  175. // #ifdef H5
  176. height: calc(
  177. 100% - var(--status-bar-height) - var(--window-top) - var(--window-bottom) -
  178. (160rpx)
  179. );
  180. // #endif
  181. }
  182. .swiper-item {
  183. height: 100%;
  184. }
  185. .scroll-v {
  186. width: 750rpx;
  187. height: 100%;
  188. overflow-y: auto;
  189. }
  190. .status_bar {
  191. height: calc(var(--status-bar-height) + 160rpx);
  192. width: 100%;
  193. background-image: linear-gradient(
  194. 25deg,
  195. $main-color,
  196. $light-color,
  197. $aider-light-color
  198. );
  199. }
  200. .header {
  201. width: 100%;
  202. position: fixed;
  203. top: var(--status-bar-height);
  204. padding: 16rpx 0 0;
  205. font-size: 30rpx;
  206. z-index: 9999;
  207. > .search {
  208. width: 100%;
  209. display: flex;
  210. align-items: center;
  211. .back {
  212. width: 90rpx;
  213. height: 90rpx;
  214. }
  215. .input-wrap {
  216. background: $light-color;
  217. width: 600rpx;
  218. height: 58rpx;
  219. padding: 10rpx 30rpx 10rpx 30rpx;
  220. box-sizing: border-box;
  221. background-color: #fff;
  222. border-radius: 50rpx;
  223. position: relative;
  224. border: 1px solid $light-color;
  225. input {
  226. font-size: 26rpx;
  227. }
  228. }
  229. }
  230. }
  231. </style>