pay.js 2.4 KB

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