tuiProduct.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. <medicineItem v-for="(item, index) in list" :key="index" :item="item"></medicineItem>
  11. <Loading :loaded="loaded" :loading="loading"></Loading>
  12. </view>
  13. </template>
  14. <script>
  15. import medicineItem from "@/components/medicineItem";
  16. import {getTuiProducts} from '@/api/index.js'
  17. import Loading from "@/components/Loading";
  18. export default {
  19. components: {
  20. Loading,
  21. medicineItem
  22. },
  23. name: "likeProduct",
  24. data() {
  25. return {
  26. page: {
  27. page: 1,
  28. pageSize: 4
  29. },
  30. total: 0,
  31. list: [],
  32. loaded: false,
  33. loading: false
  34. };
  35. },
  36. created() {},
  37. mounted() {
  38. this.getTuiProducts();
  39. },
  40. methods: {
  41. getTuiProducts() {
  42. var that = this;
  43. if (that.loaded == true || that.loading == true) return;
  44. that.loading = true;
  45. getTuiProducts(that.page).then(
  46. res => {
  47. if (res.code == 200) {
  48. that.total = res.data.total;
  49. that.list.push.apply(that.list, res.data.list);
  50. that.loading = false;
  51. that.loaded = that.list.length < that.total ? false : true;
  52. that.page.page = that.page.page + 1;
  53. uni.hideLoading()
  54. }
  55. },
  56. err => {
  57. uni.hideLoading()
  58. uni.showToast({
  59. title: err.msg,
  60. icon: 'none',
  61. duration: 2000
  62. });
  63. }
  64. )
  65. },
  66. navTo(url){
  67. uni.navigateTo({
  68. url: url
  69. })
  70. },
  71. }
  72. };
  73. </script>
  74. <style lang="scss" scoped>
  75. .box {
  76. background: #FFFFFF;
  77. border-radius: 16rpx 16rpx 16rpx 16rpx;
  78. margin: 24rpx;
  79. box-sizing: border-box;
  80. .title-box {
  81. display: flex;
  82. flex-direction: row;
  83. align-items: center;
  84. justify-content: space-between;
  85. padding: 28rpx 0 8rpx 0;
  86. box-sizing: border-box;
  87. .title {
  88. font-size: 32upx;
  89. font-family: PingFang SC;
  90. font-weight: bold;
  91. color: #111111;
  92. }
  93. .more {
  94. display: flex;
  95. align-items: center;
  96. justify-content: flex-end;
  97. .text {
  98. font-size: 24rpx;
  99. font-family: PingFang SC;
  100. color: #9B9B9B;
  101. }
  102. image {
  103. margin-left: 10rpx;
  104. width: 15rpx;
  105. height: 20rpx;
  106. }
  107. }
  108. }
  109. }
  110. .medicine-box {
  111. padding: 0 24rpx 10rpx 24rpx;
  112. }
  113. </style>