menuList.vue 4.8 KB

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