tuiProduct.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view>
  3. <view class="like-title">
  4. <image src="/static/images/tui.png" mode=""></image>
  5. <text class="text">精选药品</text>
  6. </view>
  7. <view class="like-list">
  8. <view class="item" v-for="(item,index) in list" :key="index" @click="showProduct(item)">
  9. <view class="img-box">
  10. <image :src="item.image" mode=""></image>
  11. </view>
  12. <view class="info-box">
  13. <view class="title ellipsis2">{{ item.productName }}</view>
  14. <view class="price-box">
  15. <view class="now">
  16. <text class="unit">¥</text>
  17. <text class="num">{{item.price.toFixed(2)}}</text>
  18. </view>
  19. <view class="old">¥{{item.otPrice.toFixed(2)}}</view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <Loading :loaded="loaded" :loading="loading"></Loading>
  25. </view>
  26. </template>
  27. <script>
  28. import {getTuiProducts} from '@/api/product'
  29. import Loading from "@/components/Loading";
  30. export default {
  31. components: {Loading },
  32. name: "likeProduct",
  33. data() {
  34. return {
  35. page:{
  36. page: 1,
  37. pageSize: 10
  38. },
  39. total:0,
  40. list:[],
  41. loaded: false,
  42. loading: false
  43. };
  44. },
  45. created() {
  46. },
  47. mounted() {
  48. this.getTuiProducts();
  49. },
  50. methods: {
  51. getTuiProducts(){
  52. console.log(1)
  53. var that=this;
  54. if (that.loaded == true || that.loading == true) return;
  55. that.loading = true;
  56. uni.showLoading({
  57. title:"加载中..."
  58. })
  59. getTuiProducts(that.page).then(
  60. res => {
  61. if(res.code==200){
  62. that.total=res.data.total;
  63. that.list.push.apply(that.list, res.data.list);
  64. that.loading = false;
  65. that.loaded = that.list.length<that.total?false:true;
  66. that.page.page = that.page.page + 1;
  67. uni.hideLoading()
  68. }
  69. },
  70. err => {
  71. uni.hideLoading()
  72. uni.showToast({
  73. title: err.msg ,
  74. icon: 'none',
  75. duration: 2000
  76. });
  77. }
  78. );
  79. },
  80. showProduct(item){
  81. uni.navigateTo({
  82. url: '/pages/shopping/productDetails?productId='+item.productId
  83. })
  84. },
  85. }
  86. };
  87. </script>
  88. <style lang="scss">
  89. .like-title{
  90. display: flex;
  91. align-items: center;
  92. justify-content: center;
  93. padding: 15upx 0rpx 30upx 0rpx;
  94. image{
  95. width: 37upx;
  96. height: 37upx;
  97. margin-right: 20upx;
  98. }
  99. .text{
  100. font-size: 36upx;
  101. font-family: PingFang SC;
  102. font-weight: bold;
  103. color: #111111;
  104. line-height: 1;
  105. }
  106. }
  107. .like-list{
  108. display: flex;
  109. flex-wrap: wrap;
  110. .item{
  111. margin-right: 20rpx;
  112. margin-bottom: 20rpx;
  113. width: 345rpx;
  114. background: #FFFFFF;
  115. box-shadow: 0px 0px 10rpx 4rpx rgba(199, 199, 199, 0.22);
  116. border-radius: 20rpx;
  117. overflow: hidden;
  118. &:nth-child(2n) {
  119. margin-right: 0;
  120. }
  121. .img-box{
  122. width: 100%;
  123. height: 334upx;
  124. image{
  125. width: 100%;
  126. height: 100%;
  127. }
  128. }
  129. .info-box{
  130. box-sizing: border-box;
  131. height: 182upx;
  132. padding: 20upx 20upx 30upx;
  133. display: flex;
  134. flex-direction: column;
  135. justify-content: space-between;
  136. .title{
  137. font-size: 26upx;
  138. font-family: PingFang SC;
  139. font-weight: 500;
  140. color: #111111;
  141. line-height: 40upx;
  142. }
  143. .price-box{
  144. display: flex;
  145. align-items: flex-end;
  146. .now{
  147. display: flex;
  148. align-items: flex-end;
  149. margin-right: 20upx;
  150. .unit{
  151. font-size: 24upx;
  152. font-family: PingFang SC;
  153. font-weight: 500;
  154. color: #FF6633;
  155. line-height: 1.2;
  156. margin-right: 4upx;
  157. }
  158. .num{
  159. font-size: 36upx;
  160. font-family: PingFang SC;
  161. font-weight: bold;
  162. color: #FF6633;
  163. line-height: 1;
  164. }
  165. }
  166. .old{
  167. font-size: 26upx;
  168. font-family: PingFang SC;
  169. font-weight: 500;
  170. text-decoration: line-through;
  171. color: #BBBBBB;
  172. line-height: 1.1;
  173. }
  174. }
  175. }
  176. }
  177. }
  178. </style>