index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <view class="body">
  3. <view class="search">
  4. <p>
  5. <image style="width: 5vw; height: 5vw; margin-top: 1vw; " src="../../static/search.png"></image>
  6. </p>
  7. <p style="margin-left: 2vw;"> <input style="font-size: 0.75rem; width: 60vw; height: 10vw;" type="text"
  8. v-model="productName" name="" id="" placeholder="搜索你想要的商品" @blur="search"> </p>
  9. </view>
  10. <!-- 滑动搜索 -->
  11. <view class="slideSearch">
  12. <p :class="index==int? 'xuanzhong' : 'noxuanzhong'" @click="selectInfo(item,int)" v-for="(item,int) in typeProduct" :key="int" >{{item.name}}</p>
  13. <!-- <p :class="index==1? 'xuanzhong' : 'noxuanzhong'" @click="selectInfo(1)">车载用品</p>
  14. <p :class="index==2? 'xuanzhong' : 'noxuanzhong'" @click="selectInfo(2)">美容清洗</p>
  15. <p :class="index==3? 'xuanzhong' : 'noxuanzhong'" @click="selectInfo(3)">运动户外</p>
  16. <p :class="index==4? 'xuanzhong' : 'noxuanzhong'" @click="selectInfo(4)">智能家电</p>
  17. <p :class="index==5? 'xuanzhong' : 'noxuanzhong'" @click="selectInfo(5)">科技数码</p>
  18. <p :class="index==6? 'xuanzhong' : 'noxuanzhong'" @click="selectInfo(6)">箱包服饰</p> -->
  19. </view>
  20. <!-- 搜索 -->
  21. <!-- <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="refresherTriggered"
  22. @refresherrefresh="refresherrefresh" @scrolltolower="scrolltolowerEvent(event)"
  23. lower-threshold="100">
  24. </scroll-view> -->
  25. <view class="content">
  26. <view class="model" v-for="(item,index) in productList " :key="index" @click="ShopDetial(item.id)">
  27. <p> <image style="width: 45vw; height: 45vw;" :src="item.cover_url.url"></image> </p>
  28. <p style="font-size: 1rem; font-weight: 550;">{{item.name}}</p>
  29. <p style="font-size: 0.75rem; margin-top: 2vw;"> <span style="font-size: 1rem; color: red;">¥{{item.price_f}}起</span> <!-- <span style="color: grey; text-decoration: line-through;">¥85</span> --> </p>
  30. <!-- <p style="font-size: 0.65rem; margin-top: 1vw; margin-bottom: 2vw;">恒信豆最高可抵实付全额 <span style="color: red; margin-left: 1vw; ">5%</span> </p> -->
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. data() {
  38. return {
  39. index: 0,
  40. productList:[],
  41. productName:'',
  42. index:'',
  43. typeProduct:[],
  44. typeId:''
  45. }
  46. },
  47. onLoad() {
  48. },
  49. onTabItemTap(e){
  50. this.ProductList(this.productName,this.typeId)
  51. this.ProductType()
  52. },
  53. methods: {
  54. search(){
  55. this.ProductList(this.productName,this.typeId)
  56. },
  57. // 商品类别
  58. ProductType(){
  59. this.$api.getProductType(res=>{
  60. if(res.code==0){
  61. this.typeProduct=res.data
  62. }
  63. })
  64. },
  65. selectInfo(item,index) {
  66. this.index = index
  67. this.ProductList(this.productName,item.id)
  68. },
  69. ShopDetial(id){
  70. uni.navigateTo({
  71. url:'/pages/shopStore/detial?id='+id
  72. })
  73. },
  74. // 商品列表
  75. ProductList(name,id){
  76. this.$api.getProductList(name,id,res=>{
  77. if(res.code==0){
  78. this.productList=res.data
  79. }
  80. })
  81. }
  82. }
  83. }
  84. </script>
  85. <style lang="scss" scoped>
  86. .body {
  87. width: 100vw;
  88. height: 100vh;
  89. background-color: white;
  90. overflow: hidden;
  91. .search {
  92. box-sizing: border-box;
  93. padding: 0 4vw;
  94. width: 90vw;
  95. margin-left: 5vw;
  96. height: 12vw;
  97. border-radius: 7vw;
  98. background-color: #f8f8f8;
  99. display: flex;
  100. margin-top: 1vw;
  101. align-items: center;
  102. }
  103. .slideSearch {
  104. max-width: 100vw;
  105. height: 13vw;
  106. margin-top: 2vw;
  107. display: flex;
  108. white-space: nowrap;
  109. /*不允许折行*/
  110. overflow-x: auto;
  111. /*启动横向滚动条*/
  112. align-items: center;
  113. }
  114. .content{
  115. width: 100vw;
  116. height: 83vh;
  117. display: flex;
  118. flex-wrap: wrap; // 强制换行
  119. padding:0 2vw;
  120. box-sizing: border-box;
  121. overflow-y: auto;
  122. .model{
  123. width: 48vw;
  124. // height: 65vw;
  125. display: flex;
  126. flex-direction: column;
  127. // justify-content: center;
  128. background-color: white;
  129. box-sizing: border-box;
  130. padding: 0 2vw;
  131. margin-top: 2vw;
  132. }
  133. }
  134. .noxuanzhong {
  135. width: 20vw;
  136. height: 7vw;
  137. box-sizing: border-box;
  138. padding-left: 2vw;
  139. padding-right: 2vw;
  140. font-size: 0.8rem;
  141. line-height: 7vw;
  142. text-align: center;
  143. }
  144. .xuanzhong {
  145. width: 20vw;
  146. height: 7vw;
  147. box-sizing: border-box;
  148. padding-left: 2vw;
  149. padding-right: 2vw;
  150. font-size: 0.8rem;
  151. color: red;
  152. border-radius: 20px;
  153. border: 1px solid red;
  154. line-height: 7vw;
  155. text-align: center;
  156. margin-right: 4vw;
  157. }
  158. }
  159. </style>