register.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. "use strict";
  2. var common_vendor = require("../../common/vendor.js");
  3. var api_login = require("../../api/login.js");
  4. require("../../common/request.js");
  5. const _sfc_main = {
  6. components: {},
  7. data() {
  8. return {
  9. userName: "",
  10. password: "",
  11. password1: "",
  12. registrationID: "",
  13. yzcode: "",
  14. aback: true,
  15. agree: false
  16. };
  17. },
  18. onLoad(option) {
  19. let that = this;
  20. common_vendor.index.$on("getRegistrationID", function(data) {
  21. that.registrationID = data;
  22. });
  23. },
  24. onShow() {
  25. this.$getRegistrationID();
  26. },
  27. onUnload() {
  28. common_vendor.index.$off("getRegistrationID");
  29. },
  30. mounted() {
  31. },
  32. methods: {
  33. doRegister() {
  34. if (this.$isEmpty(this.userName)) {
  35. common_vendor.index.showToast({
  36. title: "\u8BF7\u8F93\u5165\u5E10\u53F7",
  37. icon: "none"
  38. });
  39. return;
  40. }
  41. if (this.$isEmpty(this.password)) {
  42. common_vendor.index.showToast({
  43. title: "\u8BF7\u8F93\u5165\u5BC6\u7801",
  44. icon: "none"
  45. });
  46. return;
  47. }
  48. if (this.password != this.password1) {
  49. common_vendor.index.showToast({
  50. title: "\u4E24\u6B21\u5BC6\u7801\u8F93\u5165\u4E0D\u4E00\u81F4",
  51. icon: "none"
  52. });
  53. }
  54. if (!this.agree) {
  55. common_vendor.index.showToast({
  56. title: "\u8BF7\u540C\u610F\u76F8\u5173\u534F\u8BAE",
  57. icon: "none"
  58. });
  59. return;
  60. }
  61. var data = {
  62. phone: this.userName,
  63. password: this.password
  64. };
  65. common_vendor.index.showLoading({
  66. title: "\u6CE8\u518C\u4E2D..."
  67. });
  68. api_login.register(data).then((res) => {
  69. if (res.code == 200) {
  70. console.log("\u6CE8\u518C\u597D\u4E86");
  71. this.doLogin();
  72. } else {
  73. common_vendor.index.hideLoading();
  74. common_vendor.index.showToast({
  75. title: res.msg,
  76. icon: "none"
  77. });
  78. }
  79. }, (rej) => {
  80. });
  81. },
  82. doLogin() {
  83. var data = {
  84. phone: this.userName,
  85. password: this.password,
  86. loginType: 1
  87. };
  88. api_login.loginByApp(data).then((res) => {
  89. common_vendor.index.hideLoading();
  90. if (res.code == 200) {
  91. common_vendor.index.setStorageSync("AppToken", res.token);
  92. common_vendor.index.setStorageSync("userInfo", JSON.stringify(res.user));
  93. common_vendor.index.$emit("refreshIM");
  94. common_vendor.index.$emit("showHealthButler");
  95. common_vendor.index.reLaunch({
  96. url: "/pages/list/index",
  97. animationType: "pop-in",
  98. animationDuration: 100
  99. });
  100. } else {
  101. common_vendor.index.showToast({
  102. title: res.msg,
  103. icon: "none"
  104. });
  105. }
  106. }, (rej) => {
  107. });
  108. },
  109. getRegistrationID() {
  110. },
  111. handleAgree() {
  112. this.agree = !this.agree;
  113. },
  114. goToWeb(index) {
  115. common_vendor.index.setStorageSync("url", index == 0 ? "https://userapp.his.cdwjyyh.com/web/userAgreement" : "https://userapp.his.cdwjyyh.com/web/privacyPolicy");
  116. common_vendor.index.navigateTo({
  117. url: "/pages/index/h5"
  118. });
  119. }
  120. }
  121. };
  122. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  123. return {
  124. a: $data.userName,
  125. b: common_vendor.o(($event) => $data.userName = $event.detail.value),
  126. c: $data.password,
  127. d: common_vendor.o(($event) => $data.password = $event.detail.value),
  128. e: $data.password1,
  129. f: common_vendor.o(($event) => $data.password1 = $event.detail.value),
  130. g: common_vendor.o((...args) => $options.doRegister && $options.doRegister(...args)),
  131. h: !$data.agree,
  132. i: $data.agree,
  133. j: common_vendor.o((...args) => $options.handleAgree && $options.handleAgree(...args)),
  134. k: common_vendor.o(($event) => $options.goToWeb(0)),
  135. l: common_vendor.o(($event) => $options.goToWeb(1))
  136. };
  137. }
  138. var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "C:/Users/Administrator/Desktop/\u9879\u76EE/\u76F4\u64AD/liveH5-v3/pages/auth/register.vue"]]);
  139. wx.createPage(MiniProgramPage);