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

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