member.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import '../css/bootstrap.less';
  2. import 'bootstrap/dist/js/bootstrap.js';
  3. import '../css/public.css';
  4. import '../css/member.css';
  5. import './public.js';
  6. import {
  7. message
  8. } from './tools.js';
  9. function loadBenefit(callback) {
  10. $.ajax({
  11. method: "get",
  12. dataType: "json",
  13. url: globalConfig.context + "/open/html/json/member_benefit",
  14. success: function (data) {
  15. callback(data)
  16. },
  17. });
  18. }
  19. function loadData(pageNo) {
  20. var rank, money, mouth, gradeName;
  21. $.ajax({
  22. method: "get",
  23. dataType: "json",
  24. url: globalConfig.context + "/api/portal/member/selectMemberGradeFr",
  25. success: function (data) {
  26. var theArr = [];
  27. if (data.data && data.data.length) {
  28. //黄金会员
  29. let thisdata1 = data.data[0],
  30. thisdata2 = data.data[1];
  31. let theBusiness1 = [],
  32. theBusiness2 = [];
  33. let theCost1 = [],
  34. theCost2 = [];
  35. loadBenefit((x) => {
  36. let BenefitObj = x;
  37. for (let item in thisdata1.business) {
  38. if (thisdata1.business[item] == "1") {
  39. theBusiness1.push('<p>' + BenefitObj[item] + '</p>')
  40. }
  41. };
  42. for (let item in thisdata2.business) {
  43. if (thisdata2.business[item] == "1") {
  44. theBusiness2.push('<p>' + BenefitObj[item] + '</p>')
  45. }
  46. };
  47. $('#member1business').append(theBusiness1.join(''));
  48. $('#member2business').append(theBusiness2.join(''));
  49. });
  50. for (let item in thisdata1.cost) {
  51. theCost1.push('<li data-mouth="' + item + '" data-money="' + thisdata1.cost[item] + '" data-rank="' + thisdata1.memberRank + '" data-gradename="' + thisdata1.gradeName + '">' + thisdata1.cost[item] + '/' + item + '个月</li>')
  52. };
  53. for (let item in thisdata2.cost) {
  54. theCost2.push('<li data-mouth="' + item + '" data-money="' + thisdata2.cost[item] + '" data-rank="' + thisdata2.memberRank + '" data-gradename="' + thisdata2.gradeName + '">' + thisdata2.cost[item] + '/' + item + '个月</li>')
  55. };
  56. $('#member1cost').append(theCost1.join(''));
  57. $('#member2cost').append(theCost2.join(''));
  58. } else {
  59. message(data.error[0].message);
  60. };
  61. $('.member_on ul').on('click', 'li', function (e) {
  62. e.preventDefault();
  63. if (userData && userData.mobile) {
  64. if (userData.lvl > 0) {
  65. mouth = this.dataset.mouth;
  66. money = this.dataset.money;
  67. rank = this.dataset.rank;
  68. gradeName = this.dataset.gradename;
  69. $('#modal-content').append("确认提交 " + money + " 元/ " + mouth + " 月的 " + gradeName + " 订单吗?");
  70. $('#myModal').modal('show');
  71. } else {
  72. message('请先进行实名认证,通过以后才能申请高级会员!');
  73. setTimeout("window.location.href = globalConfig.context + '/user/account/index.html#normal'", 3000);
  74. return;
  75. }
  76. } else {
  77. $('.login').fadeIn(800)
  78. }
  79. });
  80. $('#submitOrder').on('click', function (e) {
  81. $('#submitOrder').attr("disabled", true);
  82. $.ajax({
  83. method: "post",
  84. dataType: "json",
  85. url: globalConfig.context + "/api/user/member/addBasicsMemberOrder",
  86. data: {
  87. menberType: rank,
  88. price: money,
  89. validMonth: mouth
  90. },
  91. success: function (data) {
  92. if (data.error && data.error.length) {
  93. message(data.error[0].message);
  94. } else {
  95. message('提交会员服务订单成功!');
  96. setTimeout("window.location.href = globalConfig.context + '/user/account/index.html#serviceList'", 3000);
  97. }
  98. },
  99. });
  100. })
  101. },
  102. });
  103. }
  104. $(function () {
  105. loadData();
  106. })