menuList.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. if(this.menuLists) {
  132. this.goods = this.menuLists[index].goods
  133. }
  134. this.title = this.menuLists[index].title
  135. this.$emit('listenMenu',data);
  136. },
  137. // 点击规格
  138. onClick(e) {
  139. this.$emit('listenEvent',e);
  140. },
  141. listenMenu(index) {
  142. this.$emit('listenMenu',index)
  143. },
  144. addCart(index) {
  145. this.$emit('addCart',index)
  146. }
  147. }
  148. }
  149. </script>
  150. <style lang="scss" scoped>
  151. .menuList{
  152. text-align: center;
  153. padding: 20rpx 10rpx;
  154. font-size: 30rpx;
  155. }
  156. .menuListSelect{
  157. text-align: center;
  158. background-color: #FFFFFF;
  159. padding: 30rpx 0rpx;
  160. font-size: 32rpx;
  161. font-weight: bold;
  162. }
  163. .goodsList{
  164. width: 100%;
  165. float: left;
  166. border-bottom: 1rpx solid #f3f4f6;
  167. box-sizing: border-box;
  168. padding: 10rpx 30rpx 10rpx 10rpx;
  169. text{
  170. font-weight: bold;
  171. font-size: 32rpx;
  172. }
  173. }
  174. .title{
  175. font-weight: bold;
  176. font-size: 32rpx;
  177. padding: 10rpx;
  178. }
  179. .hot{
  180. color: red;
  181. margin-top: 10rpx;
  182. font-size: 26rpx;
  183. }
  184. .price{
  185. margin-top: 10rpx;
  186. font-size: 28rpx;
  187. font-weight: bold;
  188. color: #FF2626;
  189. }
  190. .type{
  191. margin-left: 180rpx;
  192. width: 105rpx;
  193. display:inline-block;
  194. margin-bottom: 10rpx;
  195. background-color: #dd6161;
  196. padding: 5rpx 10rpx;
  197. border-radius: 10rpx;
  198. color: #FFFFFF;
  199. text-align: center;
  200. font-size: 26rpx;
  201. }
  202. .goodsDesc{
  203. width: calc(100% - 164rpx);
  204. margin-left: 25rpx;
  205. float: right;
  206. }
  207. .goods_text {
  208. font-size: 28rpx;
  209. font-weight: 500;
  210. color: #222222;
  211. line-height: 40rpx;
  212. text-overflow: ellipsis;
  213. overflow: hidden;
  214. display: -webkit-box;
  215. -webkit-box-orient: vertical;
  216. box-orient: vertical;
  217. line-clamp: 2;
  218. -webkit-line-clamp: 2;
  219. margin-bottom: 16rpx;
  220. }
  221. </style>