cart.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <view>
  3. <view class="goodsList animated fadeInDown">
  4. <view class="item" v-for="(item, index) in list" :key="index">
  5. <view class="title" @click.stop="selected(item)">
  6. <text class="icon" v-if="item.check" style="color: #4581fb">&#xe631;</text>
  7. <text class="icon" v-else>&#xe60c;</text>
  8. <text>{{ item.createName }}</text>
  9. </view>
  10. <view class="state" @click.stop="del(item)"><text class="icon del">&#xe852;</text></view>
  11. <image src="../../../../../static/news.jpg" mode="aspectFill" class="pic"></image>
  12. <view class="con">
  13. <view class="productName omit">{{ item.goodsName }}</view>
  14. <view class="desc omit">
  15. <text>{{ item.tradeAreaName }}</text>
  16. </view>
  17. <view class="price">¥ {{ item.resalePrice }}</view>
  18. </view>
  19. <view class="clear"></view>
  20. <view class="op">
  21. <view class="date">{{ item.createTime }}</view>
  22. <view class="an btn" @click.stop="buy(item)">立即购买</view>
  23. </view>
  24. </view>
  25. <u-empty v-if="list.length == 0"></u-empty>
  26. </view>
  27. <view class="mfooter" v-if="selects.length > 0">
  28. <view class="flex">
  29. <view class="f">
  30. <button class="btn" @click="buy({})">立即购买({{ selects.length }})</button>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. data() {
  39. return {
  40. list: [],
  41. selects: []
  42. };
  43. },
  44. onLoad() {
  45. this.getData();
  46. },
  47. methods: {
  48. getData() {
  49. this.http.request({
  50. url: '/level-two-server/app/TbOrdersCart/getList',
  51. data: this.param,
  52. success: res => {
  53. this.list = res.data.data || [];
  54. }
  55. });
  56. },
  57. selected(item) {
  58. item.check = !item.check;
  59. this.$forceUpdate();
  60. this.selects = this.list.filter(item => item.check);
  61. },
  62. // 立即购买
  63. buy(item) {
  64. if (item.orderId) {
  65. uni.navigateTo({
  66. url: '/pages/market/two/purchaser/buy/buy?orderId=' + item.orderId
  67. });
  68. } else {
  69. uni.navigateTo({
  70. url: '/pages/market/two/purchaser/buy/buy?orderId=' + this.selects.map(item => item.orderId)
  71. });
  72. }
  73. },
  74. del(item) {
  75. let ids = item.id || this.list.map(i => i.id);
  76. uni.showModal({
  77. title: '提示',
  78. content: item.id ? '确定删除该购物车?' : '清空所有购物车',
  79. success: res => {
  80. if (res.confirm) {
  81. this.http.request({
  82. url: '/level-two-server/app/TbOrdersCart/deleteByIds/' + ids,
  83. success: res => {
  84. uni.showToast({ title: '删除成功' });
  85. this.getData();
  86. }
  87. });
  88. }
  89. }
  90. });
  91. }
  92. },
  93. onNavigationBarButtonTap() {
  94. this.del({});
  95. }
  96. };
  97. </script>
  98. <style lang="scss">
  99. page {
  100. background-color: $pg;
  101. }
  102. .title {
  103. .icon {
  104. color: $font-c;
  105. padding-right: 5px;
  106. }
  107. }
  108. .an {
  109. padding: 6px 15px;
  110. font-size: 14px;
  111. margin-top: 0px !important;
  112. font-weight: normal !important;
  113. }
  114. .mfooter {
  115. background-color: #ffffff00;
  116. border: 0px;
  117. }
  118. </style>