cart.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <view>
  3. <navigation-bar title="购物车" background-color="#0081ff" front-color="#ffffff" :left-button="null" />
  4. <!-- <u-tabs lineWidth="50" :list="list" itemStyle="height:90rpx;width: 100rpx;" :is-scroll="false"
  5. :current="current" @change="change"></u-tabs> -->
  6. <u-list style="margin-top: 10rpx;padding: 15rpx;" @scrolltolower="scrolltolower">
  7. <u-list-item v-for="(item, index) in cartList" :key="index">
  8. <view class="item-box">
  9. <view class="goods-item">
  10. <view class="good-row">
  11. <view>
  12. <u--image radius="10" :showLoading="true" :src="item.goodsImg" width="250rpx"
  13. height="210rpx"></u--image>
  14. </view>
  15. <view class="des">
  16. <view style="font-size: 34rpx; height: 100rpx; display: flex;">
  17. <view style="width: 300rpx;">
  18. {{item.goodsName}}
  19. </view>
  20. <view class="status" @click="cleanCart(item.id)">
  21. <uni-icons type="trash" color="grey" size="30"></uni-icons>
  22. </view>
  23. </view>
  24. <!-- <view style="font-size: 34rpx;">[老板力荐]鲜活小龙虾(帮剪头去虾线)约250g/份</view> -->
  25. <view class="subtit">
  26. <view class="price">¥{{item.totalPrice}}</view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="goods-item">
  32. <view class="footer-item">
  33. <view style="margin: 15rpx 0rpx;"><button size="mini"
  34. :plain="true">立即购买</button></view>
  35. </view>
  36. </view>
  37. </view>
  38. </u-list-item>
  39. </u-list>
  40. </view>
  41. </template>
  42. <script>
  43. export default {
  44. data() {
  45. return {
  46. cartList: [],
  47. }
  48. },
  49. onLoad() {
  50. this.getCartList()
  51. },
  52. methods: {
  53. getCartList() {
  54. this.http.request({
  55. url: '/level-one-server/TbGoodsCart/getList',
  56. success: res => {
  57. this.cartList = res.data.data;
  58. }
  59. });
  60. },
  61. scrolltolower() {
  62. this.getCartList()
  63. },
  64. //
  65. cleanCart(id) {
  66. this.http.request({
  67. url: '/level-one-server/app/TbGoodsCart/cleanCart',
  68. data: {id: 1460500735619366940},
  69. contentType: 'application/json; charset=utf-8',
  70. method: 'POST',
  71. success: res => {
  72. setTimeout(function() {
  73. uni.showToast({
  74. title: res.data.msg
  75. });
  76. }, 1000)
  77. }
  78. });
  79. console.log( id + "类型"+ typeof id)
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss">
  85. .goods-item {
  86. margin-bottom: 15rpx;
  87. }
  88. .good-row {
  89. display: flex;
  90. align-items: center;
  91. }
  92. .shop {
  93. display: flex;
  94. align-items: center;
  95. width: 480rpx;
  96. }
  97. .shop-icon {
  98. width: 60rpx;
  99. height: 60rpx;
  100. border-radius: 30rpx;
  101. background-color: #eaf1fe;
  102. display: flex;
  103. align-items: center;
  104. justify-content: center;
  105. }
  106. .status {
  107. width: 100rpx;
  108. display: flex;
  109. align-items: center;
  110. // justify-content: flex-end;
  111. }
  112. .des {
  113. margin-left: 20rpx;
  114. position: relative;
  115. top: 1rpx;
  116. height: 200rpx;
  117. }
  118. .subtit {
  119. font-size: 28rpx;
  120. color: #9C9C9C;
  121. margin: 20rpx 10rpx;
  122. }
  123. .footer-item {
  124. display: flex;
  125. justify-content: flex-end;
  126. margin-top: -15rpx;
  127. margin-bottom: 5rpx;
  128. }
  129. .price {
  130. font-size: 30rpx;
  131. }
  132. .item-box {
  133. height: 280rpx;
  134. width: 85%;
  135. padding: 30rpx;
  136. border: 1rpx #888 solid;
  137. margin: 10rpx 15rpx;
  138. border-radius: 10rpx;
  139. }
  140. </style>