cart.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <view>
  3. <view class="goodsList animated fadeInDown">
  4. <view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
  5. <view class="title">{{ item.shopName }}</view>
  6. <view class="state" @click.stop="del(item)"><text class="icon del">&#xe852;</text></view>
  7. <image src="../../../../static/news.jpg" mode="aspectFill" class="pic"></image>
  8. <view class="con">
  9. <view class="productName omit">{{ item.goodsName }}</view>
  10. <view class="desc omit">
  11. <text>{{ item.netWeight }}吨</text>
  12. <text>{{ item.tradeAreaName }}</text>
  13. </view>
  14. <view class="price">¥ {{ item.totalPrice }}</view>
  15. </view>
  16. <view class="clear"></view>
  17. <view class="op">
  18. <view class="date">{{ item.createTime }}</view>
  19. <view class="an btn" @click.stop="buy(item)">立即购买</view>
  20. </view>
  21. </view>
  22. <u-empty v-if="list.length == 0"></u-empty>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. data() {
  29. return {
  30. list: []
  31. };
  32. },
  33. onLoad() {
  34. this.getData();
  35. },
  36. methods: {
  37. getData() {
  38. this.http.request({
  39. url: '/level-one-server/app/TbGoodsCart/getList',
  40. data: this.param,
  41. success: res => {
  42. this.list = res.data.data || [];
  43. }
  44. });
  45. },
  46. detail(item) {
  47. uni.navigateTo({ url: '/pages/market/one/detail?id=' + item.publishGoodsId });
  48. },
  49. // 立即购买
  50. buy(item) {
  51. this.http.request({
  52. url: '/level-one-server/app/TbGoodsTransit/purchaseLevelOntGoodsTransit',
  53. data: { goodsTransitId: item.publishGoodsId, goodsCartId: item.id },
  54. method: 'POST',
  55. contentType: 'application/json;charset=utf-8',
  56. success: res => {
  57. uni.redirectTo({ url: '/pages/market/one/leader/success' });
  58. }
  59. });
  60. },
  61. del(item) {
  62. let ids = item.id || this.list.map(i => i.id);
  63. uni.showModal({
  64. title: '提示',
  65. content: item.id ? '确定删除该购物车?' : '清空所有购物车',
  66. success: res => {
  67. if (res.confirm) {
  68. this.http.request({
  69. url: '/level-one-server/app/TbGoodsCart/cleanCart/' + ids,
  70. success: res => {
  71. uni.showToast({ title: '删除成功' });
  72. this.getData();
  73. }
  74. });
  75. }
  76. }
  77. });
  78. }
  79. },
  80. onNavigationBarButtonTap() {
  81. this.del({});
  82. }
  83. };
  84. </script>
  85. <style lang="scss">
  86. page {
  87. background-color: $pg;
  88. }
  89. .date {
  90. }
  91. .an {
  92. padding: 6px 15px;
  93. font-size: 14px;
  94. margin-top: 0px !important;
  95. font-weight: normal !important;
  96. }
  97. </style>