setPassword.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const _sfc_main = {
  4. data() {
  5. return {
  6. password: "",
  7. confirmPassword: ""
  8. };
  9. },
  10. methods: {
  11. submit() {
  12. if (!this.password || this.password.length < 6) {
  13. common_vendor.index.showToast({ title: "密码至少6位", icon: "none" });
  14. return;
  15. }
  16. if (this.password !== this.confirmPassword) {
  17. common_vendor.index.showToast({ title: "两次密码不一致", icon: "none" });
  18. return;
  19. }
  20. common_vendor.index.request({
  21. url: "http://localhost:9527/api/setPassword",
  22. method: "POST",
  23. data: {
  24. uid: common_vendor.index.getStorageSync("uid"),
  25. password: this.password
  26. },
  27. success: (res) => {
  28. if (res.statusCode === 200 && res.data.code === 200) {
  29. common_vendor.index.showToast({ title: "设置成功", icon: "success" });
  30. setTimeout(() => common_vendor.index.navigateBack(), 1e3);
  31. } else {
  32. common_vendor.index.showToast({ title: res.data.message || "设置失败", icon: "none" });
  33. }
  34. }
  35. });
  36. }
  37. }
  38. };
  39. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  40. return {
  41. a: $data.password,
  42. b: common_vendor.o(($event) => $data.password = $event.detail.value),
  43. c: $data.confirmPassword,
  44. d: common_vendor.o(($event) => $data.confirmPassword = $event.detail.value),
  45. e: common_vendor.o((...args) => $options.submit && $options.submit(...args))
  46. };
  47. }
  48. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-cf17a44e"]]);
  49. wx.createPage(MiniProgramPage);
  50. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/mine/setPassword.js.map