敢为人鲜小程序前端代码仓库
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.

301 lines
5.7 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
4 months ago
4 months ago
5 months ago
5 months ago
4 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
  1. <template>
  2. <view class="page">
  3. <!-- 导航栏 -->
  4. <!-- <navbar bgColor="#019245" color="#fff" /> -->
  5. <!-- 搜索栏 -->
  6. <view class="search">
  7. <image src="/static/image/logo.png" mode="aspectFill" class="search-img"></image>
  8. <view style="position: relative;">
  9. <uv-search placeholder="陕西苹果" bgColor="#fff" @search="search" @change="search" @custom="search"
  10. :searchIconSize="40" v-model="queryParams.title" height="75rpx" :showAction="false"
  11. actionText=" "></uv-search>
  12. <text class="search-text" @click="search">搜索</text>
  13. </view>
  14. </view>
  15. <!-- 商品列表 -->
  16. <view style="position: 20rpx;" v-if="queryParams.title">
  17. <productList :list="list" />
  18. </view>
  19. <!-- 分类商品列表 -->
  20. <view class="category" v-else>
  21. <!-- 这是顶部的内容 -->
  22. <!-- <view class="tabs">
  23. <uv-tabs :list="category" :activeStyle="{ color: '#f00', fontWeight: 600 }" lineColor="#f00"
  24. :inactiveStyle="{ color: 'rgba(0,0,0,.8)' }" lineHeight="8rpx" lineWidth="50rpx" :current="current"
  25. @click="clickTabs"></uv-tabs>
  26. </view> -->
  27. <uv-vtabs :list="category[2].children" :barStyle="{
  28. boxShadow: '0 0 18rpx 0rpx rgba(0, 0, 0, 0.1)',
  29. fontWeight: '600',
  30. textAlign: 'center',
  31. backgroundColor: '#F5F5F5',
  32. }" :barItemStyle="{
  33. color: 'black'
  34. }" :barItemActiveLineStyle="{
  35. height: '35%',
  36. top: '32.5%',
  37. bottom: 'auto',
  38. left: '2%',
  39. borderRadius: '4rpx',
  40. width: '8rpx'
  41. }" :current="currentChildren" keyName="name" :chain="false" @change="change">
  42. <uv-vtabs-item>
  43. <view class="category-item">
  44. <productItem :item="pro" v-for="(pro, i) in categoryList.shopList" :key="i"
  45. @click="navigateToDetail(pro.id)" />
  46. <uv-empty v-if="categoryList.shopList.length == 0" text="还没有呢" />
  47. </view>
  48. </uv-vtabs-item>
  49. </uv-vtabs>
  50. </view>
  51. <!-- tabbar -->
  52. <tabber select="category" />
  53. </view>
  54. </template>
  55. <script>
  56. import productItem from '@/components/product/productItem.vue';
  57. import mixinsList from '@/mixins/list.js'
  58. import {
  59. mapState
  60. } from 'vuex'
  61. import tabber from '@/components/base/tabbar.vue'
  62. import productList from '@/components/user/productList.vue'
  63. export default {
  64. mixins: [mixinsList],
  65. components: {
  66. productItem,
  67. tabber,
  68. productList,
  69. },
  70. data() {
  71. return {
  72. mixinsListApi: 'getClassShopPageList',
  73. current: 0,
  74. currentChildren: 0,
  75. }
  76. },
  77. computed: {
  78. ...mapState(['category']),
  79. categoryList() {
  80. // return this.category[this.current].children[this.currentChildren]
  81. return this.category[2].children[this.currentChildren]
  82. },
  83. },
  84. onLoad({
  85. search,
  86. cid
  87. }) {
  88. if (search) {
  89. this.queryParams.title = search
  90. }
  91. // this.$store.commit('getCategoryList')
  92. if (this.category.length > 0 && cid) {
  93. this.category.forEach((n, i) => {
  94. if (n.id == cid) {
  95. this.current = i
  96. }
  97. })
  98. // this.queryParams.classId = cid
  99. } else if (this.category.length > 0) {
  100. // this.queryParams.classId = this.category[0].id
  101. }
  102. },
  103. methods: {
  104. change(e) {
  105. // this.queryParams.classId = this.category[e].id
  106. this.currentChildren = e
  107. },
  108. clickTabs({ index }) {
  109. this.current = index
  110. this.currentChildren = 0
  111. },
  112. search() {
  113. for (let i = 0; i < 10; i++) {
  114. delete this.queryParams[i]
  115. }
  116. this.queryParams.pageSize = 10
  117. this.getData()
  118. },
  119. navigateToDetail(id) {
  120. console.log('跳转到商品详情页:', id);
  121. // uni.navigateTo({
  122. // url: `/pages_order/product/productDetail?id=${id}`
  123. // })
  124. this.$utils.navigateTo(`/pages_order/product/productDetail?id=${id}`);
  125. }
  126. }
  127. }
  128. </script>
  129. <style scoped lang="scss">
  130. .page {
  131. // background-color: #f5f5ff;
  132. /deep/ .uv-vtabs {
  133. height: calc(100vh - 470rpx) !important;
  134. }
  135. /deep/ .uv-vtabs__bar {
  136. height: calc(100vh - 470rpx) !important;
  137. }
  138. /deep/ .uv-vtabs__content {
  139. height: calc(100vh - 470rpx) !important;
  140. }
  141. .search {
  142. background: $uni-color;
  143. height: 280rpx;
  144. padding-left: 20rpx;
  145. .search-img {
  146. width: 120rpx;
  147. height: 120rpx;
  148. margin: 40rpx 0 10rpx 10rpx;
  149. border-radius: 50%;
  150. }
  151. .search-text {
  152. position: absolute;
  153. right: 80rpx;
  154. top: 50%;
  155. transform: translateY(-50%);
  156. color: $uni-color;
  157. }
  158. /deep/ .uv-search__action {
  159. background-color: $uni-color;
  160. color: #FFFFFF;
  161. padding: 10rpx 20rpx;
  162. border-radius: 30rpx;
  163. }
  164. }
  165. /deep/ .uv-vtabs__content {
  166. background: transparent !important;
  167. overflow: hidden;
  168. }
  169. }
  170. .header {
  171. padding: 30rpx;
  172. font-size: 30rpx;
  173. color: #333;
  174. }
  175. .item {
  176. padding: 10rpx 20rpx;
  177. &-title {
  178. .text {
  179. font-weight: 700;
  180. font-size: 32rpx;
  181. color: #111;
  182. }
  183. }
  184. &-content {
  185. padding: 20rpx 0;
  186. .text {
  187. line-height: 48rpx;
  188. font-size: 30rpx;
  189. color: #111;
  190. /* #ifndef APP-NVUE */
  191. word-break: break-all;
  192. /* #endif */
  193. }
  194. }
  195. }
  196. .gap {
  197. padding: 0 30rpx;
  198. }
  199. .category {
  200. /* background-color: green; */
  201. font-size: 30rpx;
  202. color: #333;
  203. .category-title {
  204. position: relative;
  205. display: flex;
  206. justify-content: center;
  207. align-items: center;
  208. height: 120rpx;
  209. &::before,
  210. &::after {
  211. position: absolute;
  212. top: 50%;
  213. content: '';
  214. width: 10%;
  215. border-top: 2rpx solid black;
  216. }
  217. &::before {
  218. left: 25%;
  219. }
  220. &::after {
  221. right: 25%;
  222. }
  223. }
  224. /deep/ .uv-vtabs {
  225. width: 750rpx;
  226. overflow: hidden;
  227. }
  228. .list {
  229. width: 100%;
  230. padding: 0rpx 20rpx;
  231. box-sizing: border-box;
  232. }
  233. }
  234. .header {
  235. padding: 30rpx;
  236. font-size: 30rpx;
  237. color: #333;
  238. }
  239. .item {
  240. padding: 10rpx 20rpx;
  241. &-title {
  242. .text {
  243. font-weight: 700;
  244. font-size: 32rpx;
  245. color: #111;
  246. }
  247. }
  248. &-content {
  249. padding: 20rpx 0;
  250. .text {
  251. line-height: 48rpx;
  252. font-size: 30rpx;
  253. color: #111;
  254. /* #ifndef APP-NVUE */
  255. word-break: break-all;
  256. /* #endif */
  257. }
  258. }
  259. }
  260. .gap {
  261. padding: 0 30rpx;
  262. }
  263. </style>