paySuccess.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const _sfc_main = {
  4. data() {
  5. return {
  6. phone: "",
  7. code: "",
  8. //时间标志
  9. time: null,
  10. //倒计时数字
  11. timeCount: 60,
  12. //显示倒计时还是发送验证码
  13. sendCodeFlag: "发送验证码",
  14. userId: "",
  15. resultId: ""
  16. };
  17. },
  18. onLoad(options) {
  19. if (options.userId && options.resultId) {
  20. this.userId = options.userId;
  21. this.resultId = options.resultId;
  22. }
  23. },
  24. onUnload() {
  25. clearInterval(this.time);
  26. this.phone = "";
  27. this.code = "";
  28. this.timeCount = 60;
  29. this.sendCodeFlag = "发送验证码";
  30. },
  31. methods: {
  32. //对手机号进行校验
  33. checkPhone() {
  34. var phoneReg = /^[1][3,4,5,7,8][0-9]{9}$/;
  35. if (phoneReg.test(this.phone)) {
  36. return true;
  37. } else {
  38. common_vendor.index.showToast({
  39. title: "请输入正确手机号",
  40. icon: "error"
  41. });
  42. return false;
  43. }
  44. },
  45. sendCode() {
  46. if (!this.checkPhone()) {
  47. return;
  48. }
  49. if (this.sendCodeFlag == "重新发送" || this.sendCodeFlag == "发送验证码") {
  50. this.timeCount = 60;
  51. clearInterval(this.time);
  52. this.sendCodeFlag = this.timeCount + "s";
  53. this.time = setInterval(() => {
  54. this.timeCount -= 1;
  55. this.sendCodeFlag = this.timeCount + "s";
  56. if (this.timeCount == 0) {
  57. clearInterval(this.time);
  58. this.sendCodeFlag = "重新发送";
  59. }
  60. }, 1e3);
  61. this.$request.get({
  62. url: "user/authCode",
  63. loadingTip: "加载中...",
  64. data: {
  65. phone: this.phone
  66. }
  67. }).then((res) => {
  68. common_vendor.index.showToast({
  69. title: "验证码已发送",
  70. icon: "success"
  71. });
  72. });
  73. }
  74. },
  75. // 绑定手机号并查看报告
  76. saveAndView() {
  77. if (this.checkPhone() && this.code != "") {
  78. this.$request.get({
  79. url: "user/updateMobile",
  80. loadingTip: "加载中...",
  81. data: {
  82. id: this.userId,
  83. mobile: this.phone,
  84. authCode: this.code
  85. }
  86. }).then((res) => {
  87. if (res.code == 200) {
  88. common_vendor.index.showToast({
  89. icon: "success",
  90. title: "保存成功"
  91. });
  92. common_vendor.index.navigateTo({
  93. url: `/newScale/EQtest/testResult?resultId=${this.resultId}&messageShare=1`
  94. });
  95. } else {
  96. common_vendor.index.showToast({
  97. icon: "none",
  98. title: res.msg
  99. });
  100. }
  101. });
  102. }
  103. }
  104. }
  105. };
  106. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  107. return {
  108. a: common_vendor.o(($event) => $options.checkPhone()),
  109. b: $data.phone,
  110. c: common_vendor.o(($event) => $data.phone = $event.detail.value),
  111. d: $data.code,
  112. e: common_vendor.o(($event) => $data.code = $event.detail.value),
  113. f: common_vendor.t($data.sendCodeFlag),
  114. g: common_vendor.o(($event) => $options.sendCode()),
  115. h: common_vendor.o((...args) => $options.saveAndView && $options.saveAndView(...args))
  116. };
  117. }
  118. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-02edb9a7"], ["__file", "E:/psy_web_share/newScale/EQtest/paySuccess.vue"]]);
  119. tt.createPage(MiniProgramPage);