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

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