caimei-success.js 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /**
  2. *Created by ZHJY on 2020/7/14.
  3. */
  4. var payContainer = new Vue({
  5. el:"#payContainer",
  6. data: {
  7. type:'',
  8. pageType:'',//页面类型
  9. payAmount:0,//本次支付金额
  10. isRequest:false,
  11. isSuccess:true,
  12. paySuccessCounter:'',
  13. maxtime:10,
  14. linkText:'立即跳转',
  15. openLink:'/myaccount/orderlist--1-1.html',
  16. isSuccessText:''
  17. },
  18. filters: {
  19. NumFormat:function(value) {
  20. if(!value) return '0.00';
  21. var intPart = Number(value) - Number(value)%1; //获取整数部分(这里是windy93的方法)
  22. var intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,'); //将整数部分逢三一断
  23. var floatPart = ".00"; //预定义小数部分
  24. var value2Array = value.toString().split(".");
  25. if(value2Array.length == 2) { //=2表示数据有小数位
  26. floatPart = value2Array[1].toString(); //拿到小数部分
  27. if(floatPart.length == 1) { //补0,实际上用不着
  28. return intPartFormat + "." + floatPart + '0';
  29. } else {
  30. return intPartFormat + "." + floatPart;
  31. }
  32. } else {
  33. return intPartFormat + floatPart;
  34. }
  35. }
  36. },
  37. methods: {
  38. infoRequestBody:function(){//初始化支付状态信息
  39. var _self = this;
  40. if( _self.type == 'success'){
  41. _self.isSuccess = true;
  42. if(_self.pageType == 'second'){
  43. _self.isSuccessText ='支付成功,商品会在1-2个工作日内进行审核';
  44. }else{
  45. _self.isSuccessText ='支付成功';
  46. }
  47. }else{
  48. _self.isSuccessText ='支付失败';
  49. _self.isSuccess = false;
  50. }
  51. //处理根据类型做跳转
  52. switch (_self.pageType) {
  53. case 'www':
  54. _self.linkText = '订单列表';
  55. _self.openLink = '/user/order/list.html?state=0';
  56. break;
  57. case 'second':
  58. if(_self.isSuccess){
  59. _self.linkText = '二手商品页面';
  60. _self.openLink = '/flea-market/list.html';
  61. }else{
  62. _self.linkText = '发布二手商品页面';
  63. _self.openLink = '/flea-market/form.html';
  64. }
  65. break;
  66. default:
  67. _self.linkText = '回到首页';
  68. _self.openLink = '/index.html';
  69. }
  70. _self.isRequest = true;
  71. var timeClock = setInterval(function(){
  72. _self.maxtime--;
  73. if (_self.maxtime == 0) {
  74. window.location.href = _self.openLink;
  75. clearInterval(timeClock);
  76. _self.maxtime = 10;
  77. _self.isRefresh = true;
  78. }
  79. },1000);
  80. },
  81. toFixedFn:function(text){//处理小数点后两位数
  82. return Number(text).toFixed(2);
  83. }
  84. },
  85. mounted: function () {
  86. var _self = this;
  87. _self.pageType = CAIMEI.getUrlParam('pageType');
  88. _self.type = CAIMEI.getUrlParam('type');
  89. _self.payAmount = CAIMEI.getUrlParam('payAmount');
  90. _self.infoRequestBody();
  91. }
  92. });