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

306 lines
5.8 KiB

1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
11 months ago
11 months ago
1 year ago
11 months ago
11 months ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
7 months ago
7 months ago
1 year ago
1 year ago
1 year ago
11 months ago
11 months ago
1 year ago
1 year ago
11 months ago
11 months ago
1 year ago
11 months ago
11 months ago
11 months ago
1 year ago
1 year 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. onLoad() {
  98. if(this.category[this.currentChildren]){
  99. this.queryParams.categoryId = this.category[this.currentChildren].id
  100. }else{
  101. this.$store.commit('getCategoryList', data => {
  102. this.queryParams.categoryId = data[this.currentChildren].id
  103. this.mixinsListApi = 'queryGoodsList'
  104. this.getData()
  105. })
  106. }
  107. },
  108. methods: {
  109. change(e) {
  110. this.currentChildren = e
  111. // 重新加载数据
  112. this.queryParams.categoryId = this.category[e].id
  113. this.getData()
  114. },
  115. search() {
  116. // for (let i = 0; i < 10; i++) {
  117. // delete this.queryParams[i]
  118. // }
  119. // this.queryParams.pageSize = 10
  120. this.getData()
  121. },
  122. navigateToDetail(id, open) {
  123. this.$utils.navigateTo(`/pages_order/product/productDetail?id=${id}&open=${open}`);
  124. }
  125. },
  126. }
  127. </script>
  128. <style scoped lang="scss">
  129. .page {
  130. // background-color: #f5f5ff;
  131. /deep/ .uv-vtabs {
  132. height: calc(100vh - 470rpx) !important;
  133. }
  134. /deep/ .uv-vtabs__bar {
  135. height: calc(100vh - 470rpx) !important;
  136. }
  137. /deep/ .uv-vtabs__content {
  138. height: calc(100vh - 470rpx) !important;
  139. }
  140. .search {
  141. background: $uni-color;
  142. height: 280rpx;
  143. padding-left: 20rpx;
  144. .search-img {
  145. width: 120rpx;
  146. height: 120rpx;
  147. margin: 40rpx 0 10rpx 10rpx;
  148. border-radius: 50%;
  149. }
  150. .search-text {
  151. position: absolute;
  152. right: 80rpx;
  153. top: 50%;
  154. transform: translateY(-50%);
  155. color: $uni-color;
  156. }
  157. /deep/ .uv-search__action {
  158. background-color: $uni-color;
  159. color: #FFFFFF;
  160. padding: 10rpx 20rpx;
  161. border-radius: 30rpx;
  162. }
  163. }
  164. /deep/ .uv-vtabs__content {
  165. background: transparent !important;
  166. overflow: hidden;
  167. }
  168. }
  169. .header {
  170. padding: 30rpx;
  171. font-size: 30rpx;
  172. color: #333;
  173. }
  174. .item {
  175. padding: 10rpx 20rpx;
  176. &-title {
  177. .text {
  178. font-weight: 700;
  179. font-size: 32rpx;
  180. color: #111;
  181. }
  182. }
  183. &-content {
  184. padding: 20rpx 0;
  185. .text {
  186. line-height: 48rpx;
  187. font-size: 30rpx;
  188. color: #111;
  189. /* #ifndef APP-NVUE */
  190. word-break: break-all;
  191. /* #endif */
  192. }
  193. }
  194. }
  195. .gap {
  196. padding: 0 30rpx;
  197. }
  198. .category {
  199. /* background-color: green; */
  200. font-size: 30rpx;
  201. color: #333;
  202. .category-title {
  203. position: relative;
  204. display: flex;
  205. justify-content: center;
  206. align-items: center;
  207. height: 120rpx;
  208. &::before,
  209. &::after {
  210. position: absolute;
  211. top: 50%;
  212. content: '';
  213. width: 10%;
  214. border-top: 2rpx solid black;
  215. }
  216. &::before {
  217. left: 25%;
  218. }
  219. &::after {
  220. right: 25%;
  221. }
  222. }
  223. /deep/ .uv-vtabs {
  224. width: 750rpx;
  225. overflow: hidden;
  226. }
  227. .list {
  228. width: 100%;
  229. padding: 0rpx 20rpx;
  230. box-sizing: border-box;
  231. }
  232. }
  233. .header {
  234. padding: 30rpx;
  235. font-size: 30rpx;
  236. color: #333;
  237. }
  238. .item {
  239. padding: 10rpx 20rpx;
  240. &-title {
  241. .text {
  242. font-weight: 700;
  243. font-size: 32rpx;
  244. color: #111;
  245. }
  246. }
  247. &-content {
  248. padding: 20rpx 0;
  249. .text {
  250. line-height: 48rpx;
  251. font-size: 30rpx;
  252. color: #111;
  253. /* #ifndef APP-NVUE */
  254. word-break: break-all;
  255. /* #endif */
  256. }
  257. }
  258. }
  259. .gap {
  260. padding: 0 30rpx;
  261. }
  262. </style>