pay.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. var app = getApp();
  4. var userid = 0;
  5. Page({
  6. data: {
  7. PayPanel:0,
  8. },
  9. onPullDownRefresh: function () {
  10. this.gotoIndex();
  11. wx.stopPullDownRefresh();
  12. },
  13. onLoad: function (options) {
  14. var that = this;
  15. that.setData({
  16. Containnerheight: main.getWindowHeight(),
  17. });
  18. userid = options.UserID;
  19. var PayType = options.PayType;
  20. if (PayType == "6") {//自定义开具
  21. if (options.PayUserID != app.globalData.userInfo.UserID) {
  22. that.setData({
  23. PayPanel: 2,
  24. });
  25. }
  26. else {
  27. var EndDate = common.formatTime(common.addDate("y",1,new Date()));
  28. if (options.DayNumber)
  29. EndDate = common.formatTime(new Date());
  30. if (options.EndDate)
  31. EndDate=options.EndDate;
  32. this.init(PayType, EndDate, options.Price, options.DayNumber);
  33. }
  34. }
  35. else {
  36. var EndDate = options.EndDate;
  37. this.init(PayType, EndDate);
  38. }
  39. },
  40. init: function (PayType, EndDate, Price, DayNumber) {
  41. var that = this;
  42. if (EndDate)
  43. EndDate=common.formatTime(EndDate,"-");
  44. var url = 'GetMiaoguoPayInfo3?EndDate=' + EndDate + '&PayType=' + PayType + '&UserID=' + app.globalData.userInfo.UserID;
  45. if (Price && DayNumber) {
  46. url += "&Price=" + Price + "&DayNumber=" + DayNumber;
  47. }
  48. main.getData(url, function (data) {
  49. if (data) {
  50. if (data.Text2.indexOf("\n")>0){
  51. data.Text2=data.Text2.split("\n");
  52. }
  53. that.setData({
  54. Info: data,
  55. PayType:PayType
  56. });
  57. }
  58. });
  59. },
  60. payMoney: function () {
  61. var that = this;
  62. var money = this.data.Info.PayMoney;
  63. var detail = {};
  64. detail.UserID = app.globalData.userInfo.UserID;
  65. detail.Introducer = app.globalData.userInfo.Introducer;
  66. for (var i = 0; i < that.data.Info.List1.length; i++) {
  67. if (that.data.Info.List1[i].Name == "有效期") {
  68. detail.EndTime = common.formatDateENG(that.data.Info.List1[i].Content, "/");
  69. }
  70. }
  71. if (that.data.PayType)
  72. detail.PayType=that.data.PayType;
  73. detail = JSON.stringify(detail);
  74. //console.log(detail);
  75. //console.log(money);
  76. var remark = null;
  77. if (that.data.Options && that.data.Options.Remark)
  78. remark = that.data.Options.Remark;
  79. main.payMoney(7, remark, money, detail, function () {
  80. that.setData({
  81. PayPanel: 1,
  82. });
  83. });
  84. },
  85. gotoIndex: function () {
  86. wx.reLaunch({
  87. url: '../index/index',
  88. })
  89. },
  90. onShareAppMessage: function () {
  91. return {
  92. title: app.globalData.ShareTitle,
  93. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  94. imageUrl: app.globalData.ShareImage,
  95. }
  96. },
  97. })