search.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <input type="text" v-model="searchInfo.name" @input="toInput" placeholder="搜索商品">
  6. </view>
  7. <view class="two">
  8. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
  9. <view class="list-scroll-view">
  10. <view class="two_1">
  11. <view :class="['list',condActive==index?'activeList':'']" v-for="(item,index) in condList" :key="index" @tap="toCond(index,item)">
  12. <view class="name">
  13. {{item.name}}
  14. </view>
  15. <view class="icon">
  16. <view class="icon_1">
  17. <text :class="['iconfont',item.shangActive]" v-if="condActive==index&&shang==true"></text>
  18. <text :class="['iconfont',item.shang]" v-else></text>
  19. </view>
  20. <view class="icon_1">
  21. <text :class="['iconfont', item.xiaActive]" v-if="condActive==index&&xia==true"></text>
  22. <text :class="['iconfont', item.xia]" v-else></text>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="two_2">
  28. <view class="list" v-for="(item,index) in list" :key="index">
  29. <image class="image" :src="item.url" mode=""></image>
  30. <view class="sale" v-if="item.is_sale==true">
  31. <text>已售尽</text>
  32. </view>
  33. <view class="name">
  34. {{item.name}}
  35. </view>
  36. <view class="other">
  37. <view class="money">
  38. <text>¥</text>
  39. <text>{{item.money}}</text>
  40. </view>
  41. <view class="btn" v-if="item.is_sale==false">
  42. <text class="iconfont icon-gouwuche"></text>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </scroll-view>
  49. </view>
  50. </view>
  51. </mobile-frame>
  52. </template>
  53. <script>
  54. export default {
  55. data() {
  56. return {
  57. searchInfo: {},
  58. list: [ //商品列表
  59. {
  60. url: require('@/static/test.png'),
  61. name: '商品名称',
  62. money: '10.00',
  63. is_sale: false
  64. },
  65. {
  66. url: require('@/static/test.png'),
  67. name: '商品名称',
  68. money: '10.00',
  69. is_sale: false
  70. },
  71. {
  72. url: require('@/static/test.png'),
  73. name: '商品名称',
  74. money: '10.00',
  75. is_sale: true
  76. },
  77. ],
  78. condActive: 0,
  79. shang: false,
  80. xia: false,
  81. condList: [ // 筛选
  82. {
  83. name: '默认',
  84. },
  85. {
  86. name: '销量',
  87. shang: 'icon-shangjiantou',
  88. shangActive: 'icon-shangjiantou-copy',
  89. xia: 'icon-xiajiantou',
  90. xiaActive: 'icon-xiajiantou-copy'
  91. },
  92. {
  93. name: '价格',
  94. shang: 'icon-shangjiantou',
  95. shangActive: 'icon-shangjiantou-copy',
  96. xia: 'icon-xiajiantou',
  97. xiaActive: 'icon-xiajiantou-copy'
  98. },
  99. {
  100. name: '浏览量',
  101. shang: 'icon-shangjiantou',
  102. shangActive: 'icon-shangjiantou-copy',
  103. xia: 'icon-xiajiantou',
  104. xiaActive: 'icon-xiajiantou-copy'
  105. }
  106. ]
  107. };
  108. },
  109. onShow: function() {},
  110. methods: {
  111. // 分页
  112. toPage(e) {
  113. },
  114. // 输入框
  115. toInput(e) {
  116. const that = this;
  117. that.$set(that.searchInfo, `name`, e.detail.value)
  118. },
  119. // 筛选
  120. toCond(index, e) {
  121. const that = this;
  122. that.$set(that, `condActive`, index);
  123. if (that.xia == false) {
  124. that.$set(that, `shang`, false);
  125. that.$set(that, `xia`, true);
  126. } else if (that.xia == true) {
  127. that.$set(that, `shang`, true);
  128. that.$set(that, `xia`, false);
  129. }
  130. }
  131. }
  132. }
  133. </script>
  134. <style lang="scss">
  135. .main {
  136. display: flex;
  137. flex-direction: column;
  138. width: 100vw;
  139. height: 100vh;
  140. .one {
  141. border-bottom: 1px solid var(--f85Color);
  142. padding: 2vw;
  143. input {
  144. padding: 2vw;
  145. background-color: var(--f1Color);
  146. font-size: var(--font14Size);
  147. border-radius: 5px;
  148. }
  149. }
  150. .two {
  151. position: relative;
  152. flex-grow: 1;
  153. .two_1 {
  154. background-color: var(--fffColor);
  155. padding: 2vw;
  156. display: flex;
  157. flex-direction: row;
  158. justify-content: space-around;
  159. .list {
  160. display: flex;
  161. flex-direction: row;
  162. .icon {
  163. position: relative;
  164. top: -5px;
  165. left: 2px;
  166. .icon_1 {
  167. height: 10px;
  168. .iconfont {
  169. font-size: 12px;
  170. }
  171. }
  172. }
  173. }
  174. .activeList {
  175. .name {
  176. color: #ff0000;
  177. }
  178. }
  179. }
  180. .two_2 {
  181. display: flex;
  182. flex-direction: row;
  183. flex-wrap: wrap;
  184. padding: 2vw 2vw 0 2vw;
  185. background-color: var(--f1Color);
  186. .list {
  187. position: relative;
  188. width: 43vw;
  189. margin: 0 2vw 2vw 0;
  190. padding: 2vw;
  191. border-radius: 9px;
  192. background-color: var(--fffColor);
  193. .image {
  194. width: 100%;
  195. height: 40vw;
  196. }
  197. .sale {
  198. position: absolute;
  199. top: 18vw;
  200. text-align: center;
  201. width: 43vw;
  202. text {
  203. background-color: #0000005f;
  204. border-radius: 90px;
  205. display: inline-block;
  206. width: 15vw;
  207. height: 15vw;
  208. color: var(--fffColor);
  209. text-align: center;
  210. line-height: 15vw;
  211. }
  212. }
  213. .name {
  214. font-size: var(--font16Size);
  215. margin: 0 0 1vw 0;
  216. }
  217. .other {
  218. display: flex;
  219. flex-direction: row;
  220. justify-content: space-between;
  221. .money {
  222. font-size: var(--font14Size);
  223. text:nth-child(1) {
  224. font-size: var(--font12Size);
  225. }
  226. }
  227. .btn {
  228. button {
  229. font-size: var(--font20Size);
  230. }
  231. }
  232. }
  233. }
  234. .list:nth-child(2n) {
  235. margin: 0 0 2vw 0;
  236. }
  237. }
  238. }
  239. }
  240. .scroll-view {
  241. position: absolute;
  242. top: 0;
  243. left: 0;
  244. right: 0;
  245. bottom: 0;
  246. .list-scroll-view {
  247. display: flex;
  248. flex-direction: column;
  249. }
  250. }
  251. </style>