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

315 lines
5.9 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.webp" mode="aspectFill" class="search-img" @tap="testUtiles" />
  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=" " />
  12. <text class="search-text" @tap="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. @tap="clickTabs"></uv-tabs>
  26. </view> -->
  27. <uv-vtabs :list="category" :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. <!-- 这里加载更多数据需要你使用scroll-view 因为你的列表在uv-vtabs里面 -->
  45. <scroll-view
  46. scroll-y="true"
  47. @scrolltolower="loadMoreData"
  48. style="height: calc(100vh - 470rpx);">
  49. <productItem :item="pro" v-for="(pro, i) in list" :key="i"
  50. @tap="navigateToDetail(pro.id)" />
  51. </scroll-view>
  52. <uv-empty v-if="list.length == 0" text="还没有呢" />
  53. </view>
  54. </uv-vtabs-item>
  55. </uv-vtabs>
  56. </view>
  57. <!-- tabbar -->
  58. <tabber select="category" />
  59. </view>
  60. </template>
  61. <script>
  62. import productItem from '@/components/product/productItem.vue';
  63. // list再这里定义了
  64. import mixinsList from '@/mixins/list.js'
  65. import {
  66. mapState
  67. } from 'vuex'
  68. import tabber from '@/components/base/tabbar.vue'
  69. import productList from '@/components/user/productList.vue'
  70. export default {
  71. mixins: [mixinsList],
  72. components: {
  73. productItem,
  74. tabber,
  75. productList,
  76. },
  77. data() {
  78. return {
  79. // 这这里定义查询的接口名称,就可以实现加载列表、加载跟多、下拉刷新
  80. mixinsListApi: 'queryGoodsList',
  81. current: 0,
  82. currentChildren: 0,
  83. }
  84. },
  85. computed: {
  86. ...mapState(['category']),
  87. },
  88. onLoad({
  89. search,
  90. cid
  91. }) {
  92. // 再这里加默认参数 实例:
  93. // this.queryParams.test = 11111
  94. },
  95. methods: {
  96. change(e) {
  97. // this.queryParams.classId = this.category[e].id
  98. this.currentChildren = e
  99. console.log(this.currentChildren);
  100. console.log(this.category[e].id);
  101. // 重新加载数据
  102. this.getData({ categoryId: this.category[e].id })
  103. },
  104. clickTabs({ index }) {
  105. this.current = index
  106. this.currentChildren = 0
  107. // 重新加载数据
  108. this.getData()
  109. },
  110. search() {
  111. for (let i = 0; i < 10; i++) {
  112. delete this.queryParams[i]
  113. }
  114. this.queryParams.pageSize = 10
  115. this.getData()
  116. },
  117. navigateToDetail(id) {
  118. console.log('跳转到商品详情页:', id);
  119. // uni.navigateTo({
  120. // url: `/pages_order/product/productDetail?id=${id}`
  121. // })
  122. this.$utils.navigateTo(`/pages_order/product/productDetail?id=${id}`);
  123. },
  124. testUtiles() {
  125. try{
  126. this.$authorize('scope.userLocation')
  127. }catch(error){
  128. console.log(error);
  129. }
  130. }
  131. }
  132. }
  133. </script>
  134. <style scoped lang="scss">
  135. .page {
  136. // background-color: #f5f5ff;
  137. /deep/ .uv-vtabs {
  138. height: calc(100vh - 470rpx) !important;
  139. }
  140. /deep/ .uv-vtabs__bar {
  141. height: calc(100vh - 470rpx) !important;
  142. }
  143. /deep/ .uv-vtabs__content {
  144. height: calc(100vh - 470rpx) !important;
  145. }
  146. .search {
  147. background: $uni-color;
  148. height: 280rpx;
  149. padding-left: 20rpx;
  150. .search-img {
  151. width: 120rpx;
  152. height: 120rpx;
  153. margin: 40rpx 0 10rpx 10rpx;
  154. border-radius: 50%;
  155. }
  156. .search-text {
  157. position: absolute;
  158. right: 80rpx;
  159. top: 50%;
  160. transform: translateY(-50%);
  161. color: $uni-color;
  162. }
  163. /deep/ .uv-search__action {
  164. background-color: $uni-color;
  165. color: #FFFFFF;
  166. padding: 10rpx 20rpx;
  167. border-radius: 30rpx;
  168. }
  169. }
  170. /deep/ .uv-vtabs__content {
  171. background: transparent !important;
  172. overflow: hidden;
  173. }
  174. }
  175. .header {
  176. padding: 30rpx;
  177. font-size: 30rpx;
  178. color: #333;
  179. }
  180. .item {
  181. padding: 10rpx 20rpx;
  182. &-title {
  183. .text {
  184. font-weight: 700;
  185. font-size: 32rpx;
  186. color: #111;
  187. }
  188. }
  189. &-content {
  190. padding: 20rpx 0;
  191. .text {
  192. line-height: 48rpx;
  193. font-size: 30rpx;
  194. color: #111;
  195. /* #ifndef APP-NVUE */
  196. word-break: break-all;
  197. /* #endif */
  198. }
  199. }
  200. }
  201. .gap {
  202. padding: 0 30rpx;
  203. }
  204. .category {
  205. /* background-color: green; */
  206. font-size: 30rpx;
  207. color: #333;
  208. .category-title {
  209. position: relative;
  210. display: flex;
  211. justify-content: center;
  212. align-items: center;
  213. height: 120rpx;
  214. &::before,
  215. &::after {
  216. position: absolute;
  217. top: 50%;
  218. content: '';
  219. width: 10%;
  220. border-top: 2rpx solid black;
  221. }
  222. &::before {
  223. left: 25%;
  224. }
  225. &::after {
  226. right: 25%;
  227. }
  228. }
  229. /deep/ .uv-vtabs {
  230. width: 750rpx;
  231. overflow: hidden;
  232. }
  233. .list {
  234. width: 100%;
  235. padding: 0rpx 20rpx;
  236. box-sizing: border-box;
  237. }
  238. }
  239. .header {
  240. padding: 30rpx;
  241. font-size: 30rpx;
  242. color: #333;
  243. }
  244. .item {
  245. padding: 10rpx 20rpx;
  246. &-title {
  247. .text {
  248. font-weight: 700;
  249. font-size: 32rpx;
  250. color: #111;
  251. }
  252. }
  253. &-content {
  254. padding: 20rpx 0;
  255. .text {
  256. line-height: 48rpx;
  257. font-size: 30rpx;
  258. color: #111;
  259. /* #ifndef APP-NVUE */
  260. word-break: break-all;
  261. /* #endif */
  262. }
  263. }
  264. }
  265. .gap {
  266. padding: 0 30rpx;
  267. }
  268. </style>