conMixins.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import Vue from 'vue'
  2. const conMixins = {
  3. data() {
  4. return {
  5. handleComType:0,//跳转类型
  6. cartParam: {
  7. // 购物车立即结算确认订单参数
  8. townId:null, //地址ID
  9. skuIds: 0, // 商品Id(逗号隔开)
  10. source: 2, // 来源:1WWW 2小程序
  11. userId: 0 // 用户Id
  12. },
  13. productParam: {
  14. // 商品立即购买确认订单参数
  15. townId:null, //地址ID
  16. productCount: 0, // 商品数量
  17. productId: 0, // 商品Id
  18. source: 2, // 来源:1WWW 2小程序
  19. userId: 0 // 用户Id
  20. },
  21. supportParm: {
  22. // 组合商品立即购买确认订单参数
  23. townId:null, //地址ID
  24. productInfo: '',
  25. source: 2, // 来源:1WWW 2小程序
  26. userId: 0 // 用户Id
  27. },
  28. totalCount: 1, // 订单提交总数量
  29. reducedPrice: 0, // 满减金额
  30. couponAmount: 0, // 优惠券金额
  31. allPrice: 0.0, // 订单总金额
  32. userMoney: 0.0, // 显示可使用余额
  33. deductMoney: 0.0, // 显示已使用的余额
  34. orderShouldPayFee:0 //显示最终订单金额
  35. }
  36. },
  37. computed: {
  38. // 计算订单最终支付金额 = 供应商下的合计金额之和
  39. orderTotalPrice(){
  40. let totalPrice = 0
  41. this.goodsData.forEach(el =>{
  42. totalPrice += el.totalPrice
  43. })
  44. console.log('订单最终金额',totalPrice)
  45. return totalPrice - this.couponAmount
  46. },
  47. // 显示勾选后的剩余抵扣 = 用户总余额-当前使用金额
  48. surplusMoney(){
  49. console.log('剩余抵扣', (this.userMoney - this.deductMoney))
  50. return this.userMoney - this.deductMoney
  51. },
  52. // 共减 = 减金额 + 优惠券金额
  53. totalDiscountAmount(){
  54. console.log('共减金额', (this.reducedPrice + this.couponAmount))
  55. return this.reducedPrice + this.couponAmount
  56. }
  57. },
  58. methods: {
  59. //勾选使用余额
  60. checkedBalabce() {
  61. if (this.userMoney > 0) {
  62. this.ischecked = !this.ischecked
  63. if (this.ischecked) {
  64. this.confirmParam.payInfo.balancePayFlag = 1
  65. this.attributePallPrice()
  66. } else {
  67. this.confirmParam.payInfo.balancePayFlag = 0
  68. this.attributePallPrice()
  69. }
  70. console.log('勾选使用余额最终订单支付金额', this.orderShouldPayFee)
  71. }
  72. },
  73. // 是否勾选冷链费计算
  74. handleChangeChina(supplier){
  75. this.attributePallPrice()
  76. },
  77. // 修改供应商运费类型
  78. handleChangePostage(supplier){
  79. this.attributePallPrice()
  80. },
  81. // 计算最终订单支付金额
  82. attributePallPrice() {
  83. if (this.ischecked) {// 是否勾选余额抵扣
  84. if (this.userMoney >= this.orderTotalPrice) {
  85. this.orderShouldPayFee =0.0
  86. this.deductMoney = this.orderTotalPrice// 当前使用金额等于订单金额
  87. console.log('最终订单支付金额00001', this.orderShouldPayFee)
  88. } else {
  89. this.orderShouldPayFee = this.orderTotalPrice - this.userMoney // 订单最终支付金额等于订单金额-账户余额
  90. this.deductMoney = this.userMoney // 当前使用金额等于总余额
  91. console.log('最终订单支付金额00002', this.orderShouldPayFee)
  92. }
  93. console.log('余额抵扣最终订单支付金额', this.orderShouldPayFee)
  94. } else {
  95. this.orderShouldPayFee = this.orderTotalPrice
  96. this.deductMoney = 0 // 当前使用
  97. console.log('未余额抵扣最终订单支付金额', this.orderShouldPayFee)
  98. }
  99. }
  100. }
  101. }
  102. export default conMixins