You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 lines
3.3 KiB

  1. <template>
  2. <view class="selectEssentialOil">
  3. <van-popup v-model:show="showBottom" round position="bottom" @close="close" :style="{ height: '75%' }">
  4. <view class="box">
  5. <view class="title">
  6. {{ title || '选择精油' }}
  7. </view>
  8. <view class="technician-list">
  9. <van-list v-model:loading="loading" :finished="finished" @load="onLoad">
  10. <view class="EssentialOil-list">
  11. <view @click="select(item)" v-for="item in essentialOilList" :key="item.key" class="EssentialOil-item">
  12. <view class="img-box">
  13. <image :src="item.path" mode="aspectFill"></image>
  14. </view>
  15. <view class="name-price">
  16. <view class="name">{{ item.name }}</view>
  17. <view class="price">{{ item.price }}</view>
  18. </view>
  19. </view>
  20. </view>
  21. </van-list>
  22. </view>
  23. </view>
  24. </van-popup>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. data() {
  30. return {
  31. showBottom : false,
  32. essentialOilList : [
  33. { id : 1 , path : '/static/test/精油.png' , name : '精油1' , price : 600 },
  34. { id : 2 , path : '/static/test/精油1.png' , name : '精油2' , price : 660 },
  35. { id : 3 , path : '/static/test/精油2.png' , name : '精油3' , price : 888 },
  36. { id : 4 , path : '/static/test/精油3.png' , name : '精油4' , price : 999 },
  37. ],
  38. loading : false,
  39. finished : true
  40. }
  41. },
  42. props : ['show', 'title'],
  43. created(){
  44. this.getEssentialOil()
  45. },
  46. methods: {
  47. //获取精油列表
  48. getEssentialOil(){
  49. this.loading = false;
  50. this.finished = true;
  51. console.log('获取精油列表');
  52. },
  53. //用户选择了精油
  54. select(e){
  55. this.$emit('select', e)
  56. },
  57. //关闭弹窗
  58. close(){
  59. this.$emit('close')
  60. },
  61. //滑动到屏幕底部触发(分页)
  62. onLoad(){
  63. // this.queryParams.pageSize += 10
  64. // this.getEssentialOil()
  65. }
  66. },
  67. watch: {
  68. show: {
  69. handler (newValue, oldValue) {
  70. this.showBottom = newValue
  71. this.getEssentialOil()
  72. },
  73. immediate: true
  74. }
  75. }
  76. }
  77. </script>
  78. <style lang="scss" scoped>
  79. .selectEssentialOil {
  80. .box {
  81. width: 100%;
  82. height: 100%;
  83. background: #F1B8BD;
  84. box-sizing: border-box;
  85. padding: 40rpx;
  86. .title {
  87. font-size: 32rpx;
  88. text-align: center;
  89. color: #fff;
  90. margin-bottom: 40rpx;
  91. }
  92. .technician-list {
  93. overflow: auto;
  94. width: 100%;
  95. height: calc(100% - 45rpx);
  96. }
  97. .EssentialOil-list{
  98. display: flex;
  99. flex-wrap: wrap;
  100. .EssentialOil-item{
  101. width: calc(50% - 15rpx);
  102. background: #fff;
  103. padding: 20rpx;
  104. margin-right: 15rpx;
  105. flex-shrink: 0;
  106. margin-bottom: 20rpx;
  107. border-radius: 10rpx;
  108. box-sizing: border-box;
  109. .img-box{
  110. display: flex;
  111. align-items: center;
  112. justify-content: center;
  113. width: 100%;
  114. aspect-ratio: 1 / 1; /* 设置宽高比为1:1 */
  115. image{
  116. width: 100%;
  117. height: 100%;
  118. }
  119. }
  120. .name-price{
  121. .name{
  122. font-size: 30rpx;
  123. white-space: nowrap;
  124. overflow: hidden;
  125. text-overflow: ellipsis;
  126. color: #666;
  127. margin: 20rpx;
  128. }
  129. .price{
  130. color: red;
  131. }
  132. }
  133. &:nth-child(2n){
  134. margin-right: 0rpx;
  135. }
  136. }
  137. }
  138. }
  139. }
  140. </style>