chooseGoods.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <view class="container">
  3. <view class="header flex flex-y-center">
  4. <view :class="['item','flex','flex-center',typeActive == 1 ? 'active' : '']" @click="onTypeChange(1)">
  5. <view class="title">全部商品</view>
  6. </view>
  7. <view :class="['item','flex','flex-center',typeActive == 2 ? 'active' : '']" @click="onTypeChange(2)">
  8. <view class="title">售卖中</view>
  9. </view>
  10. <view :class="['item','flex','flex-center',typeActive == 3 ? 'active' : '']" @click="onTypeChange(3)">
  11. <view class="title">已下架</view>
  12. </view>
  13. <view :class="['item','flex','flex-center',typeActive == 4 ? 'active' : '']" @click="onTypeChange(4)">
  14. <view class="title">已售罄</view>
  15. </view>
  16. </view>
  17. <view class="main-block flex box-pack-between">
  18. <scroll-view scroll-y class="left-bar">
  19. <view class="item" :class="[catIndex == -1?'active':'']" @click="onCatChange(-1)">全部(500)</view>
  20. <view class="item" :class="[catIndex == index?'active':'']" v-for="(item,index) in 20" :key="index" @click="onCatChange(index)">美味午餐</view>
  21. </scroll-view>
  22. <scroll-view scroll-y class="right-bar">
  23. <view class="cat-name">美味午餐</view>
  24. <view class="goods-list">
  25. <view class="item flex" v-for="(item,index) in 15" :key="index">
  26. <view class="goods-img-block">
  27. <image src="../static/images/icon_6.png" mode="aspectFill" class="goods-img"></image>
  28. </view>
  29. <view class="info-block">
  30. <view class="goods-name text-1 flex flex-y-center box-pack-between arr-r">香辣鸡翅套餐</view>
  31. <view class="flex flex-y-center box-pack-between" style="margin-top: 16rpx;">
  32. <view class="stock">库存:100</view>
  33. <view class="choose-btn">
  34. <image src="../static/images/icon_19.png" mode="aspectFit" class="icon-19"></image>
  35. </view>
  36. </view>
  37. <view class="goods-btm flex flex-y-center box-pack-between">
  38. <view class="price">¥14.70</view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </scroll-view>
  44. </view>
  45. <view class="footer-bar">
  46. <view class="content flex flex-center">
  47. <view class="btn">指定商品</view>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. typeActive: 1,
  57. catIndex:-1,//选中分类
  58. }
  59. },
  60. methods: {
  61. onTypeChange(index) {
  62. if (index != this.typeActive) {
  63. this.typeActive = index
  64. }
  65. },
  66. onCatChange(index){
  67. if(index != this.catIndex){
  68. this.catIndex = index
  69. }
  70. }
  71. }
  72. }
  73. </script>
  74. <style>
  75. @import url("../static/css/common.css");
  76. page {}
  77. .header {
  78. height: 96rpx;
  79. background-color: #fff;
  80. position: sticky;
  81. top: 0;
  82. z-index: 100;
  83. box-sizing: border-box;
  84. border-bottom: 8rpx solid #F4F5F7;
  85. }
  86. .header .item {
  87. width: 25vw;
  88. box-sizing: border-box;
  89. flex: none;
  90. height: 88rpx;
  91. position: relative;
  92. }
  93. .header .item.active .title{
  94. color: #247EFF;
  95. font-size: 32rpx;
  96. font-weight: 600;
  97. }
  98. .header .item.active::after {
  99. content: "";
  100. display: block;
  101. width: 40rpx;
  102. height: 4rpx;
  103. border-radius: 2rpx;
  104. background-color: #247EFF;
  105. position: absolute;
  106. bottom: 8rpx;
  107. left: 50%;
  108. transform: translateX(-50%);
  109. }
  110. .header .item .title {
  111. font-size: 28rpx;
  112. color: #666;
  113. }
  114. .main-block{
  115. width: 100%;
  116. height: calc(100vh - 96rpx - 160rpx);
  117. padding-bottom: constant(safe-area-inset-bottom);
  118. /*兼容 IOS>11.2*/
  119. padding-bottom: env(safe-area-inset-bottom);
  120. }
  121. .main-block .left-bar{
  122. width: 176rpx;
  123. flex:none;
  124. height: 100%;
  125. background-color: #F4F5F7;
  126. /*兼容 IOS<11.2*/
  127. }
  128. .main-block .item {
  129. padding:30rpx 15rpx;
  130. font-size: 28rpx;
  131. color: #666;
  132. font-weight: 500;
  133. line-height: 40rpx;
  134. }
  135. .main-block .item.active {
  136. color: #247EFF;
  137. font-weight: 600;
  138. background-color: #fff;
  139. }
  140. .main-block .right-bar{
  141. width: 574rpx;
  142. flex:none;
  143. height: 100%;
  144. background-color: #fff;
  145. box-sizing: border-box;
  146. padding:30rpx 0 0 25rpx ;
  147. position: relative;
  148. }
  149. .main-block .right-bar .cat-name{
  150. font-size: 30rpx;
  151. font-weight: 600;
  152. color: #333;
  153. line-height: 42rpx;
  154. background-color: #fff;
  155. }
  156. .main-block .right-bar .item{
  157. padding:40rpx 30rpx 40rpx 0;
  158. border-bottom: 1rpx solid #f5f5f5;
  159. }
  160. .main-block .right-bar .item .goods-img-block{
  161. flex:none;
  162. width: 120rpx;
  163. height: 120rpx;
  164. overflow: hidden;
  165. border-radius: 8rpx;
  166. position: relative;
  167. }
  168. .main-block .right-bar .item .goods-img-block .goods-img{
  169. display: block;
  170. width: 120rpx;
  171. height: 120rpx;
  172. }
  173. .main-block .right-bar .item .goods-img-block .goods-tips{
  174. background-color: rgba(0,0,0,0.5);
  175. width: 100%;
  176. height: 35rpx;
  177. position: absolute;
  178. left: 0;
  179. bottom: 0;
  180. color: #fff;
  181. line-height: 35rpx;
  182. text-align: center;
  183. font-size: 20rpx;
  184. }
  185. .main-block .right-bar .item .info-block{
  186. padding-left: 24rpx;
  187. width: 405rpx;
  188. box-sizing: border-box;
  189. }
  190. .main-block .right-bar .item .info-block .goods-name{
  191. padding-right: 15rpx;
  192. font-size: 30rpx;
  193. font-weight: 600;
  194. color: #333;
  195. line-height: 1;
  196. }
  197. .main-block .right-bar .item .arr-r::after{
  198. border-color: #333 #333 transparent transparent;
  199. }
  200. .main-block .right-bar .item .info-block .stock{
  201. font-size: 24rpx;
  202. color: #999;
  203. line-height: 1;
  204. }
  205. .main-block .right-bar .item .info-block .goods-btm{
  206. margin-top: 12rpx;
  207. }
  208. .main-block .right-bar .item .info-block .goods-btm .price{
  209. font-size: 30rpx;
  210. color: #FD3939;
  211. font-weight: 600;
  212. }
  213. .main-block .right-bar .item .info-block .choose-btn{
  214. width: 30rpx;
  215. height: 30rpx;
  216. border-radius: 50%;
  217. border:2rpx solid #CDCDCD;
  218. }
  219. .main-block .right-bar .item .info-block .choose-btn .icon-19{
  220. display: block;
  221. width: 100%;
  222. height: 100%;
  223. }
  224. </style>