list.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <view class="content">
  3. <view class="varHeight"></view>
  4. <block :key="ind" v-for="(lss, ind) in list">
  5. <view class="goodsList-item flex" v-if="lss.show" @click="navProduct(lss)">
  6. <image :src="lss.logo" lazy-load mode="scaleToFill"></image>
  7. <view class="goodsList-content">
  8. <view class="title clamp">
  9. <text>{{ lss.title }}</text>
  10. </view>
  11. <view class="slider flex">
  12. <view class="sales-nub">简介:{{ lss.info }}</view>
  13. </view>
  14. <view class="goods-money flex">
  15. <view class="money-box">
  16. <view class="otMoney-box">
  17. <text class="otMoney">{{ lss.address }}</text>
  18. </view>
  19. </view>
  20. <view class="cart seckill-action">进入店铺</view>
  21. </view>
  22. </view>
  23. </view>
  24. </block>
  25. </view>
  26. </template>
  27. <script>
  28. import { getShoping } from '@/api/shoping.js';
  29. export default {
  30. data() {
  31. return {
  32. // 当前选中的滑块
  33. list: [],
  34. keyword: '' //查询中的内容
  35. };
  36. },
  37. watch: {
  38. keyword(newValue, oldValue) {
  39. this.keyword = newValue;
  40. console.log(newValue);
  41. this.search();
  42. }
  43. },
  44. onLoad() {
  45. this.getShoping();
  46. },
  47. // #ifndef MP
  48. // 点击键盘搜索事件
  49. onNavigationBarSearchInputConfirmed(e) {
  50. this.search();
  51. },
  52. // 搜索栏内容变化事件
  53. onNavigationBarSearchInputChanged(e) {
  54. this.keyword = e.text;
  55. },
  56. // #endif
  57. methods: {
  58. // 查询店铺信息
  59. search(title) {
  60. let obj = this;
  61. obj.list.forEach(e => {
  62. if (e.title.indexOf(obj.keyword) >= 0) {
  63. e.show = true;
  64. } else {
  65. e.show = false;
  66. }
  67. });
  68. },
  69. // 跳转店铺页面
  70. navProduct(item) {
  71. uni.navigateTo({
  72. url: './index?merid=' + item.id
  73. });
  74. },
  75. //获取商店信息
  76. getShoping() {
  77. let obj = this;
  78. getShoping({
  79. mer_id: 0
  80. })
  81. .then(function({ data }) {
  82. obj.list = data.map(e => {
  83. e.show = true;
  84. return e;
  85. });
  86. })
  87. .catch(e => {
  88. console.log(e);
  89. });
  90. }
  91. }
  92. };
  93. </script>
  94. <style lang="scss">
  95. page,
  96. .content {
  97. height: 100%;
  98. }
  99. .varHeight {
  100. height: var(--status-bar-height);
  101. }
  102. $slider-color: #fe9398; //滑块左侧颜色
  103. .goodsList-item {
  104. background-color: #ffffff;
  105. padding: 30rpx;
  106. border-bottom: 1px solid $border-color-light;
  107. image {
  108. flex-shrink: 0;
  109. border-radius: $border-radius-sm;
  110. height: 180rpx;
  111. width: 180rpx;
  112. }
  113. .slider {
  114. margin-top: 15rpx;
  115. justify-content: flex-start;
  116. .slider-box {
  117. width: 196rpx;
  118. border-radius: 99px;
  119. border: 1px solid $slider-color;
  120. height: 16rpx;
  121. .slider-action {
  122. background-color: $slider-color;
  123. height: 100%;
  124. }
  125. }
  126. .sales-nub {
  127. color: $font-color-light;
  128. font-size: 24rpx;
  129. height: 2.5em;
  130. overflow: hidden;
  131. }
  132. }
  133. .goodsList-content {
  134. margin-left: 20rpx;
  135. flex-grow: 1;
  136. height: 180rpx;
  137. position: relative;
  138. .title {
  139. font-size: $font-base;
  140. color: $font-color-dark;
  141. font-weight: 500;
  142. width: 0;
  143. min-width: 100%;
  144. }
  145. .goods-money {
  146. position: absolute;
  147. left: 0;
  148. bottom: 0;
  149. width: 100%;
  150. .money-box {
  151. .money {
  152. font-size: $font-lg + 10rpx;
  153. color: $color-red;
  154. font-weight: bold;
  155. }
  156. .otMoney-box {
  157. font-size: $font-sm;
  158. .otMoney {
  159. color: $font-color-light;
  160. padding-right: 20rpx;
  161. }
  162. .sales {
  163. color: $font-color-light;
  164. }
  165. }
  166. }
  167. .cart {
  168. font-size: $font-base - 2rpx;
  169. border-radius: 99px;
  170. padding: 10rpx 20rpx;
  171. line-height: 1;
  172. color: #ffffff;
  173. background-color: $color-gray;
  174. &.seckill-action {
  175. border: 1px solid $color-red;
  176. background-color: $color-red;
  177. }
  178. }
  179. }
  180. }
  181. }
  182. </style>