pay.js 2.6 KB

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