medicineVerticalItem.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <view class="item" @click="showProduct()">
  3. <view class="img-box">
  4. <image :src="item.image" mode="aspectFill"></image>
  5. <view class="otctxt" v-show="item.productType" :style="{background:_background(item.productType)}">{{$getDictLabelName("storeProductType",item.productType)}}</view>
  6. </view>
  7. <view class="info-box">
  8. <view class="title ellipsis2">{{item.productName}}</view>
  9. <view class="price-box x-bc">
  10. <view>
  11. <text class="price-box-unit">¥</text>
  12. <text class="price-box-integer">{{splitPrice(item.price || 0).intPart}}</text>
  13. <text class="price-box-decimal">.{{splitPrice(item.price || 0).decPart}}</text>
  14. <!-- <text class="price-box-text">/日</text> -->
  15. <!-- <text class="old" v-show="item.price!=item.otPrice&&item.otPrice!==null&&item.otPrice!==undefined">¥{{item.otPrice.toFixed(2)}}</text> -->
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. props: ['item','storeId'],
  24. data() {
  25. return {
  26. }
  27. },
  28. computed: {
  29. _background() {
  30. //productType: 1:OTC,2:Rx,3:非药品,4:器械
  31. return (productType)=> {
  32. switch (productType) {
  33. case 1: return '#37E2EA' // OTC
  34. case 2: return 'red' // Rx
  35. case 3: return '#2583EB' // 非药品
  36. case 4: return '#999' // 器械
  37. default: return '#ccc'
  38. }
  39. }
  40. }
  41. },
  42. methods: {
  43. splitPrice(num) {
  44. const [intPart = '0', decPart = '00'] = String(num||0).split('.');
  45. return { intPart, decPart: decPart.padEnd(2, '0').slice(0, 2) };
  46. },
  47. showProduct() {
  48. uni.navigateTo({
  49. url: '/pages_shopping/productDetails?productId=' + this.item.productId+'&storeId='+this.storeId || ''
  50. })
  51. },
  52. }
  53. }
  54. </script>
  55. <style scoped lang="scss">
  56. .otctxt {
  57. position: absolute;
  58. top: 0;
  59. left: 0;
  60. background-color: #37E2EA;
  61. font-family: PingFang SC, PingFang SC;
  62. font-weight: 500;
  63. font-size: 20rpx;
  64. color: #FFFFFF;
  65. padding: 4rpx 14rpx;
  66. border-radius: 16rpx 0 16rpx 0;
  67. }
  68. .price-box {
  69. font-family: Roboto, Roboto;
  70. font-weight: bold;
  71. font-size: 36rpx;
  72. color: #FF5C03;
  73. &-unit {
  74. font-weight: 600;
  75. font-size: 26rpx;
  76. }
  77. &-decimal {
  78. font-weight: 600;
  79. font-size: 26rpx;
  80. }
  81. &-text {
  82. font-family: PingFang SC, PingFang SC;
  83. font-weight: 500;
  84. font-size: 26rpx;
  85. }
  86. }
  87. .item{
  88. margin-right: 20rpx;
  89. margin-bottom: 20rpx;
  90. width: 235rpx;
  91. background: #FFFFFF;
  92. box-shadow: 0px 0px 10rpx 4rpx rgba(199, 199, 199, 0.22);
  93. border-radius: 20rpx;
  94. overflow: hidden;
  95. &:nth-child(2n) {
  96. margin-right: 0;
  97. }
  98. .img-box{
  99. width: 100%;
  100. height: 235rpx;
  101. position: relative;
  102. image{
  103. width: 100%;
  104. height: 100%;
  105. }
  106. }
  107. .info-box{
  108. box-sizing: border-box;
  109. // height: 182rpx;
  110. padding: 12rpx 20rpx;
  111. display: flex;
  112. flex-direction: column;
  113. justify-content: space-between;
  114. .title{
  115. font-size: 26rpx;
  116. font-family: PingFang SC;
  117. font-weight: 500;
  118. color: #111111;
  119. line-height: 40rpx;
  120. height: 80rpx;
  121. }
  122. .price-box{
  123. display: flex;
  124. align-items: flex-end;
  125. .now{
  126. display: flex;
  127. align-items: flex-end;
  128. margin-right: 20rpx;
  129. .unit{
  130. font-size: 24rpx;
  131. font-family: PingFang SC;
  132. font-weight: 500;
  133. color: #FF6633;
  134. line-height: 1.2;
  135. margin-right: 4rpx;
  136. }
  137. .num{
  138. font-size: 36rpx;
  139. font-family: PingFang SC;
  140. font-weight: bold;
  141. color: #FF6633;
  142. line-height: 1;
  143. }
  144. }
  145. .old{
  146. font-size: 26rpx;
  147. font-family: PingFang SC;
  148. font-weight: 500;
  149. text-decoration: line-through;
  150. color: #BBBBBB;
  151. line-height: 1.1;
  152. }
  153. }
  154. }
  155. }
  156. </style>