pay.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. var url = 'GetMiaoguoPayInfo3?EndDate=' + EndDate + '&PayType=' + PayType + '&UserID=' + app.globalData.userInfo.UserID;
  43. if (Price && DayNumber) {
  44. url += "&Price=" + Price + "&DayNumber=" + DayNumber;
  45. }
  46. main.getData(url, function (data) {
  47. if (data) {
  48. if (data.Text2.indexOf("\n")>0){
  49. data.Text2=data.Text2.split("\n");
  50. }
  51. that.setData({
  52. Info: data,
  53. PayType:PayType
  54. });
  55. }
  56. });
  57. },
  58. payMoney: function () {
  59. var that = this;
  60. var money = this.data.Info.PayMoney;
  61. var detail = {};
  62. detail.UserID = app.globalData.userInfo.UserID;
  63. detail.Introducer = app.globalData.userInfo.Introducer;
  64. for (var i = 0; i < that.data.Info.List1.length; i++) {
  65. if (that.data.Info.List1[i].Name == "有效期") {
  66. detail.EndTime = common.formatDateENG(that.data.Info.List1[i].Content, "/");
  67. }
  68. }
  69. if (that.data.PayType)
  70. detail.PayType=that.data.PayType;
  71. detail = JSON.stringify(detail);
  72. //console.log(detail);
  73. //console.log(money);
  74. var remark = null;
  75. if (that.data.Options && that.data.Options.Remark)
  76. remark = that.data.Options.Remark;
  77. main.payMoney(7, remark, money, detail, function () {
  78. that.setData({
  79. PayPanel: 1,
  80. });
  81. });
  82. },
  83. gotoIndex: function () {
  84. wx.reLaunch({
  85. url: '../index/index',
  86. })
  87. },
  88. onShareAppMessage: function () {
  89. return {
  90. title: app.globalData.ShareTitle,
  91. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  92. imageUrl: app.globalData.ShareImage,
  93. }
  94. },
  95. })