cart.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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="confirm(item.id, 1, '确认接单?')">立即够买</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. del(item) {
  50. let ids = item.id || this.list.map(i => i.id);
  51. uni.showModal({
  52. title: '提示',
  53. content: item.id ? '确定删除该购物车?' : '清空所有购物车',
  54. success: res => {
  55. if (res.confirm) {
  56. this.http.request({
  57. url: '/level-one-server/app/TbGoodsCart/cleanCart/' + ids,
  58. success: res => {
  59. uni.showToast({ title: '删除成功' });
  60. this.getData();
  61. }
  62. });
  63. }
  64. }
  65. });
  66. }
  67. },
  68. onNavigationBarButtonTap() {
  69. this.del({});
  70. }
  71. };
  72. </script>
  73. <style lang="scss">
  74. page {
  75. background-color: $pg;
  76. }
  77. .date {
  78. }
  79. .an {
  80. padding: 6px 15px;
  81. font-size: 14px;
  82. margin-top: 0px !important;
  83. font-weight: normal !important;
  84. }
  85. </style>