CashOutBillItem.ts 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import SetGray from "../../component/SetGray";
  2. const { ccclass, property } = cc._decorator;
  3. @ccclass
  4. export default class CashOutBillItem extends cc.Component {
  5. @property({ displayName: "金额", type: cc.Label })
  6. lab_value: cc.Label = null;
  7. @property({ displayName: "状态", type: cc.Label })
  8. lab_status: cc.Label = null;
  9. @property({ displayName: "操作描述", type: cc.Label })
  10. lab_operate: cc.Label = null;
  11. @property({ displayName: "操作按钮", type: SetGray })
  12. node_setGray: SetGray = null;
  13. private mData_ = null;
  14. private mIsGray_;
  15. setItemData(data) {
  16. this.mData_ = data;
  17. let index= this.node["index"];
  18. console.log("----");
  19. //this.initUI();
  20. }
  21. initUI() {
  22. this.lab_value.string = this.mData_.amount / 100 + '';
  23. if (this.mData_.amount == this.mData_.payAmount) {
  24. this.lab_status.string = "提现到账";
  25. this.lab_operate.string = "已到账";
  26. this.node_setGray.setGray(true);
  27. this.mIsGray_ = true;
  28. }else{
  29. let currentDay = new Date();
  30. let currentTimestamp = mk.time.dateToTimestamp(currentDay);
  31. let unlockDay= new Date(this.mData_.unlockDate);
  32. if(currentTimestamp >= this.mData_.unlockDate){
  33. this.lab_operate.string = "提现";
  34. this.node_setGray.setGray(false);
  35. this.mIsGray_ = false;
  36. this.lab_status.string = "已提现" + this.mData_.payAmount / 100 + "元";
  37. }else{
  38. let dayOffset = unlockDay.getDate() - currentDay.getDate();
  39. if(dayOffset == 1){
  40. this.lab_operate.string = "次日提现";
  41. }else{
  42. this.lab_operate.string = "待提现";
  43. }
  44. if(this.mData_.payAmount > 0){
  45. this.lab_status.string = "已提现" + this.mData_.payAmount / 100 + "元";
  46. }else{
  47. this.lab_status.string = dayOffset + "天内到账";
  48. }
  49. this.node_setGray.setGray(true);
  50. this.mIsGray_ = true;
  51. }
  52. }
  53. }
  54. clickBtn() {
  55. if(!this.mIsGray_){
  56. this.billCashOut();
  57. }
  58. }
  59. async billCashOut() {
  60. let data: any = {};
  61. data.partnerTradeNo = this.mData_.partnerTradeNo;
  62. let response = await mk.http.sendData('bill/billCash', data);
  63. if (response.errcode != 0) {
  64. return null;
  65. }
  66. let index= this.node["index"];
  67. let billData = response.data.billOrderInfoView;
  68. if(billData && billData.billDetailInfoList.length > index){
  69. let updateData = billData.billDetailInfoList[index];
  70. this.mData_.unlockDate = updateData.unlockDate;
  71. this.mData_.payAmount = updateData.payAmount;
  72. this.initUI();
  73. console.log(`billCashOut===${updateData.unlockDate}==${updateData.amount}==${updateData.payAmount}`);
  74. }
  75. }
  76. // update (dt) {}
  77. }