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

289 lines
5.3 KiB

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