personInfo.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. "use strict";
  2. var common_vendor = require("../common/vendor.js");
  3. var api_user = require("../api/user.js");
  4. require("../common/request.js");
  5. const _sfc_main = {
  6. data() {
  7. return {
  8. user: {
  9. avatar: null,
  10. phone: ""
  11. }
  12. };
  13. },
  14. onLoad() {
  15. this.getUserInfo();
  16. },
  17. methods: {
  18. bindblur(e) {
  19. this.user.nickName = e.detail.value;
  20. },
  21. bindinput(e) {
  22. this.user.nickName = e.detail.value;
  23. },
  24. onChooseAvatar(e) {
  25. let {
  26. avatarUrl
  27. } = e.detail;
  28. common_vendor.index.uploadFile({
  29. url: common_vendor.index.getStorageSync("requestPath") + "/app/common/uploadOSS",
  30. filePath: avatarUrl,
  31. name: "file",
  32. formData: {
  33. "user": "test"
  34. },
  35. success: (uploadFileRes) => {
  36. this.user.avatar = JSON.parse(uploadFileRes.data).url;
  37. }
  38. });
  39. },
  40. submit() {
  41. this.user.isWeixinAuth = 1;
  42. api_user.editUser(this.user).then((res) => {
  43. if (res.code == 200) {
  44. common_vendor.index.setStorageSync("avatar", this.avatar);
  45. common_vendor.index.setStorageSync("nickName", this.nickName);
  46. common_vendor.index.showToast({
  47. icon: "success",
  48. title: "\u4FEE\u6539\u6210\u529F"
  49. });
  50. this.getUserInfo();
  51. } else {
  52. common_vendor.index.showToast({
  53. icon: "none",
  54. title: "\u8BF7\u6C42\u5931\u8D25"
  55. });
  56. }
  57. }, (rej) => {
  58. });
  59. },
  60. getUserInfo() {
  61. api_user.getUserInfo().then((res) => {
  62. if (res.code == 200) {
  63. if (res.user != null) {
  64. this.user = res.user;
  65. } else {
  66. this.utils.loginOut();
  67. }
  68. } else {
  69. common_vendor.index.showToast({
  70. icon: "none",
  71. title: "\u8BF7\u6C42\u5931\u8D25"
  72. });
  73. }
  74. }, (rej) => {
  75. });
  76. }
  77. }
  78. };
  79. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  80. return common_vendor.e({
  81. a: $data.user.avatar == null ? "https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/22cb9518a55040dea74d8f730551a7a2.jpg" : $data.user.avatar,
  82. b: common_vendor.o((...args) => $options.onChooseAvatar && $options.onChooseAvatar(...args)),
  83. c: common_vendor.o((...args) => $options.bindblur && $options.bindblur(...args)),
  84. d: common_vendor.o([($event) => $data.user.nickName = $event.detail.value, (...args) => $options.bindinput && $options.bindinput(...args)]),
  85. e: $data.user.nickName,
  86. f: $data.user != null
  87. }, $data.user != null ? {
  88. g: common_vendor.t(_ctx.$parsePhone($data.user.phone))
  89. } : {}, {
  90. h: common_vendor.o(($event) => $options.submit())
  91. });
  92. }
  93. var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-2a25b94e"], ["__file", "E:/Project/2023/\u95EE\u8BCA\u5E73\u53F0/his_user_miniapp/pages_user/personInfo.vue"]]);
  94. wx.createPage(MiniProgramPage);