menuList.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <view class="content hflex jbetween">
  3. <scroll-view scroll-y="true" style="height: 1190rpx;">
  4. <view :style="[MobileLeft]">
  5. <view v-show="!isNav">
  6. <view v-for="(item,index) in menuLists" :class="menuIndex==index ? 'menuListSelect' : 'menuList' " @click="selectMenu(index,item)">
  7. {{item.title}}
  8. </view>
  9. </view>
  10. <view v-show="isNav">
  11. <slot name="nav"></slot>
  12. </view>
  13. <view :style="[foot]"></view>
  14. </view>
  15. </scroll-view>
  16. <scroll-view scroll-y="true" style="height: 1190rpx;">
  17. <view :style="[MobileRight]">
  18. <view v-show="!isSlot">
  19. <view class="goodsList hflex acenter jbetween" v-for="(it,index) in goods">
  20. <image :src="it.img" style="width: 144rpx;height: 144rpx;border-radius: 16rpx;" mode="aspectFill"></image>
  21. <view class="goodsDesc">
  22. <text class="goods_text">{{it.label}}</text>
  23. <!-- <view class="hot">月销量{{it.hot}}</view> -->
  24. <view class="hflex acenter jbetween">
  25. <view class="price">¥{{it.price}}元</view>
  26. <image src="/static/images/shop/add-cart.png" style="width: 44rpx;height: 44rpx;"></image>
  27. </view>
  28. <!-- <view class="type" @tap="onClick(it)">选规格</view> -->
  29. </view>
  30. </view>
  31. </view>
  32. <view v-show="isSlot">
  33. <slot name="list"></slot>
  34. </view>
  35. <!-- <view :style="[foot]"></view> -->
  36. </view>
  37. </scroll-view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. props:{
  43. menuLists:{
  44. type:[Array,Number,Object],
  45. default:[]
  46. },
  47. bottomSize:{
  48. type:String,
  49. default:'0rpx'
  50. },
  51. isSlot:{
  52. type:Boolean,
  53. default:false
  54. },
  55. isNav:{
  56. type:Boolean,
  57. default:false
  58. }
  59. },
  60. data() {
  61. return {
  62. menuIndex: 0,
  63. goods:[],
  64. height:'',
  65. title:''
  66. }
  67. },
  68. created() {
  69. //设置手机的高度
  70. var me = this
  71. uni.getSystemInfo({
  72. success: function (res) {
  73. me.height = res.windowHeight
  74. }
  75. });
  76. if(this.menuLists == []){
  77. }
  78. this.goods = this.menuLists[0].goods
  79. },
  80. mounted() {
  81. },
  82. computed:{
  83. // 右侧产品样式
  84. MobileRight(){
  85. let style = {}
  86. // style.position = 'fixed'
  87. // style.right = '0rpx'
  88. style.width = '520rpx'
  89. style.height = this.height +'px'
  90. style.right = "3rpx"
  91. style.backgroundColor = '#FFFFFF'
  92. style.overflow = 'auto'
  93. return style
  94. },
  95. //左侧菜单样式
  96. MobileLeft(){
  97. let style = {}
  98. // style.position = 'fixed'
  99. // style.left = '0rpx'
  100. style.width = '230rpx'
  101. style.height = this.height +'px'
  102. style.backgroundColor = '#f3f4f6'
  103. style.overflow = 'auto'
  104. return style
  105. },
  106. // 产品图片样式
  107. ImgStyle(){
  108. let style = {}
  109. style.width = this.imgSize
  110. style.height = this.imgSize
  111. style.marginTop = '10rpx'
  112. return style
  113. },
  114. //底部距离
  115. foot(){
  116. let style = {}
  117. style.width = '100%'
  118. style.float = 'left'
  119. style.height = this.bottomSize
  120. return style
  121. }
  122. },
  123. methods: {
  124. // 菜单选择
  125. selectMenu(index,data){
  126. this.menuIndex = index
  127. this.goods = this.menuLists[index].goods
  128. this.title = this.menuLists[index].title
  129. this.$emit('listenMenu',data);
  130. },
  131. // 点击规格
  132. onClick(e) {
  133. this.$emit('listenEvent',e);
  134. },
  135. }
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. .menuList{
  140. text-align: center;
  141. padding: 20rpx 10rpx;
  142. font-size: 30rpx;
  143. }
  144. .menuListSelect{
  145. text-align: center;
  146. background-color: #FFFFFF;
  147. padding: 30rpx 0rpx;
  148. font-size: 32rpx;
  149. font-weight: bold;
  150. }
  151. .goodsList{
  152. float: left;
  153. border-bottom: 1rpx solid #f3f4f6;
  154. padding: 10rpx;
  155. text{
  156. font-weight: bold;
  157. font-size: 32rpx;
  158. }
  159. }
  160. .title{
  161. font-weight: bold;
  162. font-size: 32rpx;
  163. padding: 10rpx;
  164. }
  165. .hot{
  166. color: red;
  167. margin-top: 10rpx;
  168. font-size: 26rpx;
  169. }
  170. .price{
  171. margin-top: 10rpx;
  172. font-size: 28rpx;
  173. font-weight: bold;
  174. color: #FF2626;
  175. }
  176. .type{
  177. margin-left: 180rpx;
  178. width: 105rpx;
  179. display:inline-block;
  180. margin-bottom: 10rpx;
  181. background-color: #dd6161;
  182. padding: 5rpx 10rpx;
  183. border-radius: 10rpx;
  184. color: #FFFFFF;
  185. text-align: center;
  186. font-size: 26rpx;
  187. }
  188. .goodsDesc{
  189. width: calc(100% - 164rpx);
  190. margin-left: 25rpx;
  191. float: right;
  192. }
  193. .goods_text {
  194. font-size: 28rpx;
  195. font-weight: 500;
  196. color: #222222;
  197. line-height: 40rpx;
  198. text-overflow: ellipsis;
  199. overflow: hidden;
  200. display: -webkit-box;
  201. -webkit-box-orient: vertical;
  202. box-orient: vertical;
  203. line-clamp: 2;
  204. -webkit-line-clamp: 2;
  205. margin-bottom: 16rpx;
  206. }
  207. </style>