register.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const api_login = require("../../api/login.js");
  4. const common_assets = require("../../common/assets.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: "请输入帐号",
  37. icon: "none"
  38. });
  39. return;
  40. }
  41. if (this.$isEmpty(this.password)) {
  42. common_vendor.index.showToast({
  43. title: "请输入密码",
  44. icon: "none"
  45. });
  46. return;
  47. }
  48. if (this.password != this.password1) {
  49. common_vendor.index.showToast({
  50. title: "两次密码输入不一致",
  51. icon: "none"
  52. });
  53. }
  54. if (!this.agree) {
  55. common_vendor.index.showToast({
  56. title: "请同意相关协议",
  57. icon: "none"
  58. });
  59. return;
  60. }
  61. var data = {
  62. phone: this.userName,
  63. password: this.password
  64. // jpushId: this.registrationID || uni.getStorageSync("registrationID"),
  65. // loginType: 1
  66. };
  67. common_vendor.index.showLoading({
  68. title: "注册中..."
  69. });
  70. api_login.register(data).then(
  71. (res) => {
  72. if (res.code == 200) {
  73. console.log("注册好了");
  74. this.doLogin();
  75. } else {
  76. common_vendor.index.hideLoading();
  77. common_vendor.index.showToast({
  78. title: res.msg,
  79. icon: "none"
  80. });
  81. }
  82. },
  83. (rej) => {
  84. }
  85. );
  86. },
  87. doLogin() {
  88. var data = {
  89. phone: this.userName,
  90. password: this.password,
  91. // jpushId: this.registrationID || uni.getStorageSync("registrationID"),
  92. loginType: 1
  93. };
  94. api_login.loginByApp(data).then(
  95. (res) => {
  96. common_vendor.index.hideLoading();
  97. if (res.code == 200) {
  98. common_vendor.index.setStorageSync("AppToken", res.token);
  99. common_vendor.index.setStorageSync("userInfo", JSON.stringify(res.user));
  100. common_vendor.index.$emit("refreshIM");
  101. common_vendor.index.$emit("showHealthButler");
  102. common_vendor.index.reLaunch({
  103. url: "/pages/list/index",
  104. animationType: "pop-in",
  105. animationDuration: 100
  106. });
  107. } else {
  108. common_vendor.index.showToast({
  109. title: res.msg,
  110. icon: "none"
  111. });
  112. }
  113. },
  114. (rej) => {
  115. }
  116. );
  117. },
  118. getRegistrationID() {
  119. },
  120. handleAgree() {
  121. this.agree = !this.agree;
  122. },
  123. goToWeb(index) {
  124. common_vendor.index.setStorageSync("url", index == 0 ? "https://userapp.his.cdwjyyh.com/web/userAgreement" : "https://userapp.his.cdwjyyh.com/web/privacyPolicy");
  125. common_vendor.index.navigateTo({
  126. url: "/pages/index/h5"
  127. });
  128. }
  129. }
  130. };
  131. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  132. return {
  133. a: $data.userName,
  134. b: common_vendor.o(($event) => $data.userName = $event.detail.value),
  135. c: $data.password,
  136. d: common_vendor.o(($event) => $data.password = $event.detail.value),
  137. e: $data.password1,
  138. f: common_vendor.o(($event) => $data.password1 = $event.detail.value),
  139. g: common_vendor.o((...args) => $options.doRegister && $options.doRegister(...args)),
  140. h: common_assets._imports_0$4,
  141. i: !$data.agree,
  142. j: common_assets._imports_1$2,
  143. k: $data.agree,
  144. l: common_vendor.o((...args) => $options.handleAgree && $options.handleAgree(...args)),
  145. m: common_vendor.o(($event) => $options.goToWeb(0)),
  146. n: common_vendor.o(($event) => $options.goToWeb(1))
  147. };
  148. }
  149. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
  150. wx.createPage(MiniProgramPage);