tuiProduct.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <view class="medicine-box box">
  3. <view class="title-box">
  4. <view class="title">推荐药品</view>
  5. <view class="more" @click="navTo('/pages_shopping/home/productList')">
  6. <view class="text">更多药品</view>
  7. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/arrow_gray.png"></image>
  8. </view>
  9. </view>
  10. <view class="medicine-item x-f" v-for="(item, index) in list" :key="index" @click="showProduct(item)">
  11. <view class="medicine">
  12. <image :src="item.image" mode="aspectFill"></image>
  13. <!-- {{utils.getDictLabelName("storeProductType",product.productType)}} -->
  14. <!-- <image class="otc" src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/index/blue_lable_otc.svg" mode="aspectFill"></image> -->
  15. </view>
  16. <view class="medicine-r">
  17. <view class="ellipsis" style="white-space: normal;">{{ item.productName || '' }}</view>
  18. <view class="desc">包装规格:{{ item.unitName || '--' }}</view>
  19. <view class="desc">共有 <text style="color: #2583EB;margin: 0 10rpx;">12</text> 个商家销售 </view>
  20. <view class="price-box">
  21. <text class="price-box-unit">¥</text>
  22. <text class="price-box-integer">{{splitPrice(item.price || 0).intPart}}</text>
  23. <text class="price-box-decimal">.{{splitPrice(item.price || 0).decPart}}</text>
  24. <!-- <text class="price-box-text">/日</text> -->
  25. <text class="old" v-show="item.price!=item.otPrice&&item.otPrice!==null&&item.otPrice!==undefined">¥{{item.otPrice.toFixed(2)}}</text>
  26. </view>
  27. </view>
  28. </view>
  29. <Loading :loaded="loaded" :loading="loading"></Loading>
  30. </view>
  31. </template>
  32. <script>
  33. import {getTuiProducts} from '@/api/index.js'
  34. import Loading from "@/components/Loading";
  35. export default {
  36. components: {
  37. Loading
  38. },
  39. name: "likeProduct",
  40. data() {
  41. return {
  42. page: {
  43. page: 1,
  44. pageSize: 10
  45. },
  46. total: 0,
  47. list: [],
  48. loaded: false,
  49. loading: false
  50. };
  51. },
  52. created() {},
  53. mounted() {
  54. this.getTuiProducts();
  55. },
  56. methods: {
  57. splitPrice(num) {
  58. const [intPart = '0', decPart = '00'] = String(num||0).split('.');
  59. return { intPart, decPart: decPart.padEnd(2, '0').slice(0, 2) };
  60. },
  61. getTuiProducts() {
  62. var that = this;
  63. if (that.loaded == true || that.loading == true) return;
  64. that.loading = true;
  65. uni.showLoading({
  66. title: "加载中..."
  67. })
  68. getTuiProducts(that.page).then(
  69. res => {
  70. if (res.code == 200) {
  71. that.total = res.data.total;
  72. that.list.push.apply(that.list, res.data.list);
  73. that.loading = false;
  74. that.loaded = that.list.length < that.total ? false : true;
  75. that.page.page = that.page.page + 1;
  76. uni.hideLoading()
  77. }
  78. },
  79. err => {
  80. uni.hideLoading()
  81. uni.showToast({
  82. title: err.msg,
  83. icon: 'none',
  84. duration: 2000
  85. });
  86. }
  87. );
  88. },
  89. showProduct(item) {
  90. uni.navigateTo({
  91. url: '/pages_shopping/productDetails?productId=' + item.productId
  92. })
  93. },
  94. navTo(url){
  95. uni.navigateTo({
  96. url: url
  97. })
  98. },
  99. }
  100. };
  101. </script>
  102. <style lang="scss" scoped>
  103. .old{
  104. margin-left: 14rpx;
  105. font-size: 26upx;
  106. font-family: PingFang SC;
  107. font-weight: 500;
  108. text-decoration: line-through;
  109. color: #BBBBBB;
  110. line-height: 1.1;
  111. }
  112. .box {
  113. background: #FFFFFF;
  114. border-radius: 16rpx 16rpx 16rpx 16rpx;
  115. margin: 24rpx;
  116. box-sizing: border-box;
  117. .title-box {
  118. display: flex;
  119. flex-direction: row;
  120. align-items: center;
  121. justify-content: space-between;
  122. padding: 28rpx 0;
  123. box-sizing: border-box;
  124. .title {
  125. font-size: 32upx;
  126. font-family: PingFang SC;
  127. font-weight: bold;
  128. color: #111111;
  129. }
  130. .more {
  131. display: flex;
  132. align-items: center;
  133. justify-content: flex-end;
  134. .text {
  135. font-size: 24rpx;
  136. font-family: PingFang SC;
  137. color: #9B9B9B;
  138. }
  139. image {
  140. margin-left: 10rpx;
  141. width: 15rpx;
  142. height: 20rpx;
  143. }
  144. }
  145. }
  146. .price-box {
  147. font-family: Roboto, Roboto;
  148. font-weight: bold;
  149. font-size: 36rpx;
  150. color: #FF5C03;
  151. margin-top: 22rpx;
  152. &-unit {
  153. font-weight: 600;
  154. font-size: 26rpx;
  155. }
  156. &-decimal {
  157. font-weight: 600;
  158. font-size: 26rpx;
  159. }
  160. &-text {
  161. font-family: PingFang SC, PingFang SC;
  162. font-weight: 500;
  163. font-size: 26rpx;
  164. }
  165. }
  166. }
  167. .medicine-box {
  168. padding: 0 24rpx 32rpx 24rpx;
  169. .medicine {
  170. width: 200rpx;
  171. height: 200rpx;
  172. flex-shrink: 0;
  173. border-radius: 16rpx 16rpx 16rpx 16rpx;
  174. overflow: hidden;
  175. position: relative;
  176. margin-right: 24rpx;
  177. .otc {
  178. position: absolute;
  179. top: 0;
  180. left: 0;
  181. width: 96rpx;
  182. height: 40rpx;
  183. border-radius: 0;
  184. }
  185. image {
  186. width: 100%;
  187. height: 100%;
  188. border-radius: 16rpx 16rpx 16rpx 16rpx;
  189. }
  190. &-r {
  191. font-family: PingFang SC, PingFang SC;
  192. font-weight: 500;
  193. font-size: 32rpx;
  194. color: #191A1B;
  195. flex: 1;
  196. overflow: hidden;
  197. }
  198. &-item {
  199. align-items: flex-start !important;
  200. margin-bottom: 40rpx;
  201. &:last-child {
  202. margin-bottom: 0;
  203. }
  204. }
  205. }
  206. .desc {
  207. margin-top: 12rpx;
  208. font-family: PingFang SC, PingFang SC;
  209. font-weight: 400;
  210. font-size: 24rpx;
  211. color: #939599;
  212. }
  213. }
  214. </style>