pay.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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(new Date());
  28. this.init(PayType, EndDate, options.Price, options.DayNumber);
  29. that.setData({
  30. Options: options,
  31. });
  32. }
  33. }
  34. else {
  35. var EndDate = options.EndDate;
  36. this.init(PayType, EndDate);
  37. }
  38. },
  39. init: function (PayType, EndDate, Price, DayNumber) {
  40. var that = this;
  41. var url = 'GetMiaoguoPayInfo3?EndDate=' + EndDate + '&PayType=' + PayType + '&UserID=' + app.globalData.userInfo.UserID;
  42. if (Price && DayNumber) {
  43. url += "&Price=" + Price + "&DayNumber=" + DayNumber;
  44. }
  45. main.getData(url, function (data) {
  46. if (data) {
  47. that.setData({
  48. Info: data,
  49. });
  50. }
  51. });
  52. },
  53. payMoney: function () {
  54. var that = this;
  55. var money = this.data.Info.PayMoney;
  56. var detail = {};
  57. detail.UserID = app.globalData.userInfo.UserID;
  58. detail.Introducer = app.globalData.userInfo.Introducer;
  59. for (var i = 0; i < that.data.Info.List1.length; i++) {
  60. if (that.data.Info.List1[i].Name == "有效期") {
  61. detail.EndTime = common.formatDateENG(that.data.Info.List1[i].Content, "/");
  62. }
  63. }
  64. detail = JSON.stringify(detail);
  65. //console.log(detail);
  66. //console.log(money);
  67. var remark = null;
  68. if (that.data.Options && that.data.Options.Remark)
  69. remark = that.data.Options.Remark;
  70. main.payMoney(7, remark, money, detail, function () {
  71. that.setData({
  72. PayPanel: 1,
  73. });
  74. });
  75. },
  76. gotoIndex: function () {
  77. wx.reLaunch({
  78. url: '../index/index',
  79. })
  80. },
  81. onShareAppMessage: function () {
  82. return {
  83. title: app.globalData.ShareTitle,
  84. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  85. imageUrl: app.globalData.ShareImage,
  86. }
  87. },
  88. })