purchaseGoods.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view>
  3. <view class="goods-ul">
  4. <block v-for="(item, index) in goods_list" :key="index">
  5. <view class="goods-li clearfix" @click="selGoods(item)">
  6. <view class="del-icon">
  7. <u-icon size="40" name="minus-circle-fill" :color="sel_goods_list.findIndex(goods => item.skuId === goods.skuId) > -1 ? '#fa3534' : '#999999'"></u-icon>
  8. </view>
  9. <view class="goods-name ellipsis">{{ item.goodsName }}</view>
  10. <view class="goods-code">{{ item.goodsCode }}</view>
  11. <view class="goods-num clearfix">
  12. <view class="float_left">{{ item.unitName }};{{ item.skuName }}</view>
  13. <text class="float_right">可退:{{ $utils.formatNub(item.returnOnNum) }}{{ item.unitName }}</text>
  14. </view>
  15. <view class="goods-num clearfix">
  16. <view class="float_left ">
  17. <text class="price">{{ $utils.formattedNumber(item.buyerUnitPrice) }}</text>
  18. </view>
  19. <view class="float_right">
  20. 小计:
  21. <text class="price">{{ $utils.formattedNumber(item.subtotalPrice) }}</text>
  22. </view>
  23. </view>
  24. </view>
  25. </block>
  26. </view>
  27. <view class="confirm-btn" @click="confirm">确定</view>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. data() {
  33. return {
  34. goods_list: [],
  35. sel_goods_skuid: [],
  36. sel_goods_list: []
  37. };
  38. },
  39. onLoad() {
  40. const obj = uni.getStorageSync('purchaseGoods');
  41. console.log(obj)
  42. this.goods_list = obj.goodsArrData;
  43. this.sel_goods_list = obj.goods_list;
  44. },
  45. methods: {
  46. confirm() {
  47. // 选择返回上一页
  48. this._prePage().purchaseGoodsData = this.sel_goods_list;
  49. uni.navigateBack();
  50. },
  51. selGoods(item) {
  52. if (this.sel_goods_list.length === 1) {
  53. this.$u.toast('至少保留一条数据');
  54. return;
  55. }
  56. const index = this.sel_goods_list.findIndex(godos => item.skuId === goods.skuId);
  57. if (index > -1) {
  58. this.sel_goods_list.splice(index, 1);
  59. } else {
  60. this.sel_goods_list.push({
  61. id: item.id,
  62. goodsId: item.basicGoodsId,
  63. goodsCode: item.goodsCode,
  64. goodsName: item.goodsName,
  65. unitName: item.unitName,
  66. skuName: item.skuName,
  67. skuId: item.skuId,
  68. purchaseNum: this.$utils.formatNub(item.buyerNum),
  69. buyerNum: this.$utils.formatNub(item.returnOnNum),
  70. inNum: item.inNum,
  71. inOfNum: item.inOfNum,
  72. returnOnNum: item.returnOnNum,
  73. returnNum: item.returnNum,
  74. inventoryNum: this.$utils.formatNub(item.num),
  75. buyerUnitPrice: this.$utils.formatNub(item.buyerUnitPrice),
  76. subtotalPrice: this.$utils.formatNub(item.subtotalPrice),
  77. couponAmount: this.$utils.formatNub(item.couponAmount),
  78. otherAmount: this.$utils.formatNub(item.otherAmount)
  79. });
  80. }
  81. }
  82. }
  83. };
  84. </script>
  85. <style lang="scss" scoped>
  86. .confirm-btn {
  87. color: #ffffff;
  88. background-color: $uni-color-primary;
  89. text-align: center;
  90. line-height: 90rpx;
  91. position: fixed;
  92. bottom: 0;
  93. left: 0;
  94. width: 100%;
  95. }
  96. .goods-ul {
  97. .goods-li {
  98. line-height: 32rpx;
  99. position: relative;
  100. background-color: #ffffff;
  101. width: 710rpx;
  102. margin: 20rpx auto;
  103. padding: 20rpx;
  104. border-radius: 10rpx;
  105. padding-left: 80rpx;
  106. position: relative;
  107. .del-icon {
  108. position: absolute;
  109. top: 50%;
  110. left: 20rpx;
  111. transform: translateY(-50%);
  112. }
  113. .goods-name {
  114. width: 640rpx;
  115. height: 34rpx;
  116. line-height: 34rpx;
  117. }
  118. .goods-code {
  119. font-size: 24rpx;
  120. padding-top: 10rpx;
  121. }
  122. .goods-num {
  123. padding-top: 10rpx;
  124. font-size: 24rpx;
  125. .float_left {
  126. input {
  127. display: inline-block;
  128. border: 1px solid #eeeeee;
  129. border-radius: 10rpx;
  130. padding: 0 10rpx;
  131. vertical-align: middle;
  132. text-align: center;
  133. }
  134. }
  135. .price {
  136. font-size: 28rpx;
  137. font-weight: bold;
  138. color: $uni-color-error;
  139. }
  140. }
  141. }
  142. }
  143. </style>