conMixins.js 3.7 KB

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