virtualcardBehavior.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. let app = getApp();
  2. module.exports = Behavior({
  3. properties: {
  4. spuItem: {
  5. type: Object,
  6. value: {
  7. actId: "",
  8. skuId: "",
  9. spuImage: "",
  10. spuName: "",
  11. endTime: 0,
  12. beginTime: "",
  13. actPrice: ["", ""],
  14. marketPrice: ["", ""],
  15. spuCanBuyNum: "",
  16. soldNum: "",
  17. actId: "",
  18. limitMemberNum: "",
  19. limitOrderNum: "",
  20. serverTime: "",
  21. isLimit: false,
  22. skuList: [],
  23. spuDescribe: "",
  24. is_take_fullreduction: 0,
  25. bigImg: '',
  26. car_count: 0
  27. },
  28. observer: function (t) {
  29. let {presale_ding_time_start_int, presale_ding_time_end_int } = t;
  30. let nowtime = Date.parse(new Date())/1000;
  31. let saleStatus = 1; //客付定金 0未开始 2已结束
  32. let h = {};
  33. if(t.presale_type==0) {
  34. let { presale_ding_money, actPrice, presale_deduction_money } = t;
  35. let goodsPrice = (actPrice[0]+'.'+actPrice[1])*1;
  36. presale_deduction_money = presale_deduction_money>0?presale_deduction_money:presale_ding_money;
  37. let weikuan = goodsPrice - presale_deduction_money*1;
  38. presale_ding_money = presale_ding_money.toFixed(2);
  39. h.dingArr = (presale_ding_money+'').split('.');
  40. h.weikuan = weikuan.toFixed(2);
  41. }
  42. if(nowtime<presale_ding_time_start_int) {
  43. saleStatus = 0;
  44. } else if(nowtime>presale_ding_time_end_int) {
  45. saleStatus = 2;
  46. }
  47. this.setData({
  48. saleStatus,
  49. ...h
  50. })
  51. }
  52. },
  53. isPast: {
  54. type: Boolean,
  55. value: false
  56. },
  57. actEnd: {
  58. type: Boolean,
  59. value: false
  60. },
  61. reduction: {
  62. type: Object,
  63. value: {
  64. full_money: '',
  65. full_reducemoney: '',
  66. is_open_fullreduction: 0
  67. }
  68. },
  69. skin: Object,
  70. goods_sale_unit: String
  71. },
  72. attached() {
  73. this.setData({ placeholdeImg: app.globalData.placeholdeImg })
  74. },
  75. data: {
  76. disabled: false,
  77. placeholdeImg: '',
  78. weikuan: 0,
  79. dingArr: ['0', '00'],
  80. saleStatus: 1
  81. },
  82. methods: {
  83. goLink: function () {
  84. let id = this.data.spuItem.actId;
  85. id && wx.navigateTo({
  86. url: `/lionfish_comshop/pages/goods/goodsDetail?id=${id}&type=virtualcard`,
  87. })
  88. }
  89. }
  90. })