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

347 lines
8.5 KiB

  1. <template>
  2. <view class="page">
  3. <!-- 导航栏 -->
  4. <!-- <navbar bgColor="#019245" color="#fff" /> -->
  5. <!-- 搜索栏 -->
  6. <view class="search">
  7. <image src="/static/image/中森明菜.webp" mode="aspectFill" class="search-img"></image>
  8. <view style="position: relative;">
  9. <uv-search placeholder="陕西苹果" bgColor="#fff" @search="search" @change="search" @custom="search"
  10. v-model="queryParams.title" height="70rpx" :showAction="false" actionText=" "></uv-search>
  11. <text class="search-text" @click="search">搜索</text>
  12. </view>
  13. </view>
  14. <!-- 商品列表 -->
  15. <view style="position: 20rpx;" v-if="queryParams.title">
  16. <productList :list="list" />
  17. </view>
  18. <!-- 分类商品列表 -->
  19. <view class="category" v-else>
  20. <view class="tabs">
  21. <uv-tabs :list="category" :activeStyle="{ color: '#f00', fontWeight: 600 }" lineColor="#f00"
  22. :inactiveStyle="{ color: 'rgba(0,0,0,.8)' }" lineHeight="8rpx" lineWidth="50rpx" :current="current"
  23. @click="clickTabs"></uv-tabs>
  24. </view>
  25. <!-- 原来的选择框 -->
  26. <uv-vtabs :list="category[current].children" :current="currentChildren" keyName="name" :chain="false"
  27. @change="change">
  28. <!-- 可有可无 -->
  29. <!-- <view class="list">
  30. <template v-for="(item, index) in category[current].children">
  31. <uv-vtabs-item :index="index" :key="index">
  32. <view class="category-item">
  33. <view class="category-title">
  34. {{ item.name }}
  35. </view>
  36. <productItem :item="pro"
  37. v-for="(pro, i) in item.shopList" :key="i"
  38. @click="$utils.navigateTo(`/pages_order/product/productDetail?id=${pro.id}`)" />
  39. </view>
  40. </uv-vtabs-item>
  41. </template>
  42. </view> -->
  43. <uv-vtabs-item>
  44. <view class="category-item">
  45. <productItem :item="pro" v-for="(pro, i) in categoryList.shopList" :key="i"
  46. @click="$utils.navigateTo(`/pages_order/product/productDetail?id=${pro.id}`)" />
  47. <uv-empty v-if="categoryList.shopList.length == 0" text="还没有呢" />
  48. </view>
  49. </uv-vtabs-item>
  50. </uv-vtabs>
  51. <!-- <view class="content">
  52. <uv-vtabs :chain="chain" :list="list"
  53. :barItemBadgeStyle="{
  54. right: '20rpx',
  55. top: '12rpx'
  56. }"
  57. :barStyle="{
  58. boxShadow: '0 0 18rpx 0rpx rgba(0, 0, 0, 0.1)',
  59. fontWeight: '600',
  60. textAlign: 'center',
  61. backgroundColor: '#F5F5F5',
  62. }"
  63. :barItemStyle="{
  64. color: 'black'
  65. }"
  66. :barItemActiveLineStyle="{
  67. height: '35%',
  68. top: '32.5%',
  69. bottom: 'auto',
  70. left: '2%',
  71. borderRadius: '4rpx',
  72. width: '8rpx'
  73. }"
  74. @change="tabChange" height="1100rpx">
  75. <uv-vtabs-item>
  76. <view class="item" v-for="(item2, index2) in list2" :key="index2">
  77. <view class="item-title">
  78. <text class="text">{{ item2.name }}</text>
  79. </view>
  80. <view class="item-content">
  81. <text class="text">{{ item2.desc }}</text>
  82. </view>
  83. </view> -->
  84. <view class="category-item">
  85. <productItem :item="item2" v-for="(item2, i) in list2" :key="i"
  86. @click="$utils.navigateTo(`/pages_order/product/productDetail?id=${item2.id}`)" />
  87. <uv-empty v-if="list2.length == 0" text="还没有呢" />
  88. </view>
  89. </uv-vtabs-item>
  90. </uv-vtabs>
  91. </view>
  92. </view>
  93. <!-- tabbar -->
  94. <tabber select="category" />
  95. </view>
  96. </template>
  97. <script>
  98. import productItem from '@/components/product/productItem.vue';
  99. import mixinsList from '@/mixins/list.js'
  100. import {
  101. mapState
  102. } from 'vuex'
  103. import tabber from '@/components/base/tabbar.vue'
  104. import productList from '@/components/user/productList.vue'
  105. export default {
  106. mixins: [mixinsList],
  107. components: {
  108. productItem,
  109. tabber,
  110. productList,
  111. },
  112. data() {
  113. return {
  114. mixinsListApi: 'getClassShopPageList',
  115. current: 0,
  116. currentChildren: 0,
  117. }
  118. },
  119. computed: {
  120. ...mapState(['category']),
  121. categoryList() {
  122. return this.category[this.current]?.children?.[this.currentChildren] || {};
  123. },
  124. },
  125. onLoad({
  126. search,
  127. cid
  128. }) {
  129. console.log('我是cid', cid);
  130. console.log('我是category', this.category);
  131. if (search) {
  132. this.queryParams.title = search
  133. }
  134. if (this.category.length > 0 && cid) {
  135. this.category.forEach((n, i) => {
  136. if (n.id == cid) {
  137. this.current = i
  138. }
  139. })
  140. // this.queryParams.classId = cid
  141. } else if (this.category.length > 0) {
  142. // this.queryParams.classId = this.category[0].id
  143. }
  144. },
  145. methods: {
  146. change(e) {
  147. // this.queryParams.classId = this.category[e].id
  148. this.currentChildren = e
  149. },
  150. tabChange(index) {
  151. console.log('选项改变:', index);
  152. this.value = index
  153. },
  154. clickTabs({ index }) {
  155. this.current = index
  156. this.currentChildren = 0
  157. console.log(this.category, this.category[index].children);
  158. },
  159. search() {
  160. for (let i = 0; i < 10; i++) {
  161. delete this.queryParams[i]
  162. }
  163. this.queryParams.pageSize = 10
  164. this.getData()
  165. },
  166. }
  167. }
  168. </script>
  169. <style scoped lang="scss">
  170. .page {
  171. // background-color: #f5f5ff;
  172. /deep/ .uv-vtabs {
  173. height: calc(100vh - 470rpx) !important;
  174. }
  175. // /deep/ .uv-vtabs__bar {
  176. // height: calc(100vh - 600rpx) !important;
  177. // }
  178. /deep/ .uv-vtabs__content {
  179. height: calc(100vh - 500rpx) !important;
  180. }
  181. .search {
  182. background: $uni-color;
  183. height: 280rpx;
  184. padding-left: 20rpx;
  185. .search-img {
  186. width: 120rpx;
  187. height: 120rpx;
  188. margin: 40rpx 0 0 10rpx;
  189. border-radius: 50%;
  190. }
  191. .search-text {
  192. position: absolute;
  193. right: 80rpx;
  194. top: 50%;
  195. transform: translateY(-50%);
  196. color: $uni-color;
  197. }
  198. /deep/ .uv-search__action {
  199. background-color: $uni-color;
  200. color: #FFFFFF;
  201. padding: 10rpx 20rpx;
  202. border-radius: 30rpx;
  203. }
  204. }
  205. /deep/ .uv-vtabs__content {
  206. background: transparent !important;
  207. overflow: hidden;
  208. }
  209. }
  210. .header {
  211. padding: 30rpx;
  212. font-size: 30rpx;
  213. color: #333;
  214. }
  215. .item {
  216. padding: 10rpx 20rpx;
  217. &-title {
  218. .text {
  219. font-weight: 700;
  220. font-size: 32rpx;
  221. color: #111;
  222. }
  223. }
  224. &-content {
  225. padding: 20rpx 0;
  226. .text {
  227. line-height: 48rpx;
  228. font-size: 30rpx;
  229. color: #111;
  230. /* #ifndef APP-NVUE */
  231. word-break: break-all;
  232. /* #endif */
  233. }
  234. }
  235. }
  236. .gap {
  237. padding: 0 30rpx;
  238. }
  239. .category {
  240. /* background-color: green; */
  241. font-size: 30rpx;
  242. color: #333;
  243. .category-title {
  244. position: relative;
  245. display: flex;
  246. justify-content: center;
  247. align-items: center;
  248. height: 120rpx;
  249. &::before,
  250. &::after {
  251. position: absolute;
  252. top: 50%;
  253. content: '';
  254. width: 10%;
  255. border-top: 2rpx solid black;
  256. }
  257. &::before {
  258. left: 25%;
  259. }
  260. &::after {
  261. right: 25%;
  262. }
  263. }
  264. /deep/ .uv-vtabs {
  265. width: 750rpx;
  266. overflow: hidden;
  267. }
  268. .list {
  269. width: 100%;
  270. padding: 0rpx 20rpx;
  271. box-sizing: border-box;
  272. }
  273. }
  274. .header {
  275. padding: 30rpx;
  276. font-size: 30rpx;
  277. color: #333;
  278. }
  279. .item {
  280. padding: 10rpx 20rpx;
  281. &-title {
  282. .text {
  283. font-weight: 700;
  284. font-size: 32rpx;
  285. color: #111;
  286. }
  287. }
  288. &-content {
  289. padding: 20rpx 0;
  290. .text {
  291. line-height: 48rpx;
  292. font-size: 30rpx;
  293. color: #111;
  294. /* #ifndef APP-NVUE */
  295. word-break: break-all;
  296. /* #endif */
  297. }
  298. }
  299. }
  300. .gap {
  301. padding: 0 30rpx;
  302. }
  303. </style>