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

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