info.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const sheep_index = require("../../sheep/index.js");
  4. const sheep_hooks_useModal = require("../../sheep/hooks/useModal.js");
  5. const sheep_api_infra_file = require("../../sheep/api/infra/file.js");
  6. const sheep_api_member_user = require("../../sheep/api/member/user.js");
  7. require("../../sheep/url/index.js");
  8. require("../../sheep/store/index.js");
  9. require("../../sheep/store/app.js");
  10. require("../../sheep/api/promotion/diy.js");
  11. require("../../sheep/request/index.js");
  12. require("../../sheep/config/index.js");
  13. require("../../sheep/platform/index.js");
  14. require("../../sheep/platform/provider/wechat/index.js");
  15. require("../../sheep/platform/provider/wechat/miniProgram.js");
  16. require("../../sheep/api/member/auth.js");
  17. require("../../sheep/api/member/social.js");
  18. require("../../sheep/platform/provider/apple/index.js");
  19. require("../../sheep/platform/share.js");
  20. require("../../sheep/router/index.js");
  21. require("../../sheep/helper/throttle.js");
  22. require("../../sheep/platform/pay.js");
  23. require("../../sheep/helper/index.js");
  24. require("../../sheep/helper/test.js");
  25. require("../../sheep/helper/digit.js");
  26. require("../../sheep/api/pay/order.js");
  27. require("../../sheep/store/user.js");
  28. require("../../sheep/store/cart.js");
  29. require("../../sheep/api/trade/cart.js");
  30. require("../../sheep/api/pay/wallet.js");
  31. require("../../sheep/api/trade/order.js");
  32. require("../../sheep/api/promotion/coupon.js");
  33. require("../../sheep/store/sys.js");
  34. require("../../sheep/store/modal.js");
  35. require("../../sheep/config/zIndex.js");
  36. require("../../sheep/api/member/signin.js");
  37. if (!Array) {
  38. const _easycom_su_image2 = common_vendor.resolveComponent("su-image");
  39. const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
  40. const _easycom_uni_forms_item2 = common_vendor.resolveComponent("uni-forms-item");
  41. const _easycom_su_radio2 = common_vendor.resolveComponent("su-radio");
  42. const _easycom_uni_forms2 = common_vendor.resolveComponent("uni-forms");
  43. const _easycom_su_fixed2 = common_vendor.resolveComponent("su-fixed");
  44. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  45. (_easycom_su_image2 + _easycom_uni_easyinput2 + _easycom_uni_forms_item2 + _easycom_su_radio2 + _easycom_uni_forms2 + _easycom_su_fixed2 + _easycom_s_layout2)();
  46. }
  47. const _easycom_su_image = () => "../../sheep/ui/su-image/su-image.js";
  48. const _easycom_uni_easyinput = () => "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
  49. const _easycom_uni_forms_item = () => "../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.js";
  50. const _easycom_su_radio = () => "../../sheep/ui/su-radio/su-radio.js";
  51. const _easycom_uni_forms = () => "../../uni_modules/uni-forms/components/uni-forms/uni-forms.js";
  52. const _easycom_su_fixed = () => "../../sheep/ui/su-fixed/su-fixed.js";
  53. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  54. if (!Math) {
  55. (_easycom_su_image + _easycom_uni_easyinput + _easycom_uni_forms_item + _easycom_su_radio + _easycom_uni_forms + _easycom_su_fixed + _easycom_s_layout)();
  56. }
  57. const _sfc_main = {
  58. __name: "info",
  59. setup(__props) {
  60. const state = common_vendor.reactive({
  61. model: {},
  62. // 个人信息
  63. rules: {},
  64. thirdInfo: {}
  65. // 社交用户的信息
  66. });
  67. const sexRadioMap = [
  68. {
  69. name: "男",
  70. value: "1"
  71. },
  72. {
  73. name: "女",
  74. value: "2"
  75. }
  76. ];
  77. const userInfo = common_vendor.computed(() => sheep_index.sheep.$store("user").userInfo);
  78. function onChangeGender(e) {
  79. state.model.sex = e.detail.value;
  80. }
  81. const onChangeMobile = () => {
  82. sheep_hooks_useModal.showAuthModal("changeMobile");
  83. };
  84. function onChooseAvatar(e) {
  85. const tempUrl = e.detail.avatarUrl || "";
  86. uploadAvatar(tempUrl);
  87. }
  88. async function uploadAvatar(tempUrl) {
  89. if (!tempUrl) {
  90. return;
  91. }
  92. let { data } = await sheep_api_infra_file.FileApi.uploadFile(tempUrl);
  93. state.model.avatar = data;
  94. }
  95. function onSetPassword() {
  96. sheep_hooks_useModal.showAuthModal("changePassword");
  97. }
  98. async function bindThirdOauth() {
  99. await sheep_index.sheep.$platform.useProvider("wechat").bind();
  100. }
  101. function unBindThirdOauth() {
  102. common_vendor.index.showModal({
  103. title: "解绑提醒",
  104. content: "解绑后您将无法通过微信登录此账号",
  105. cancelText: "再想想",
  106. confirmText: "确定",
  107. success: async function(res) {
  108. if (!res.confirm) {
  109. return;
  110. }
  111. const result = await sheep_index.sheep.$platform.useProvider("wechat").unbind(state.thirdInfo.openid);
  112. if (result) {
  113. await getUserInfo();
  114. }
  115. }
  116. });
  117. }
  118. async function onSubmit() {
  119. const { code } = await sheep_api_member_user.UserApi.updateUser({
  120. avatar: state.model.avatar,
  121. nickname: state.model.nickname,
  122. sex: state.model.sex
  123. });
  124. if (code === 0) {
  125. await getUserInfo();
  126. }
  127. }
  128. const getUserInfo = async () => {
  129. const userInfo2 = await sheep_index.sheep.$store("user").getInfo();
  130. state.model = common_vendor.lodashExports.clone(userInfo2);
  131. if (sheep_index.sheep.$platform.name !== "H5") {
  132. let result = await sheep_index.sheep.$platform.useProvider("wechat").getInfo();
  133. state.thirdInfo = result || {};
  134. }
  135. };
  136. common_vendor.onLoad(async (options) => {
  137. getUserInfo();
  138. setTimeout(getUserInfo, 2e3);
  139. });
  140. return (_ctx, _cache) => {
  141. var _a, _b, _c, _d, _e;
  142. return common_vendor.e({
  143. a: common_vendor.p({
  144. isPreview: true,
  145. current: 0,
  146. src: (_a = state.model) == null ? void 0 : _a.avatar,
  147. height: 160,
  148. width: 160,
  149. radius: 80,
  150. mode: "scaleToFill"
  151. }),
  152. b: common_vendor.o(onChooseAvatar),
  153. c: common_vendor.o(($event) => state.model.nickname = $event),
  154. d: common_vendor.p({
  155. type: "nickname",
  156. placeholder: "设置昵称",
  157. inputBorder: false,
  158. placeholderStyle: _ctx.placeholderStyle,
  159. modelValue: state.model.nickname
  160. }),
  161. e: common_vendor.p({
  162. name: "nickname",
  163. label: "昵称"
  164. }),
  165. f: common_vendor.f(sexRadioMap, (item, k0, i0) => {
  166. var _a2;
  167. return {
  168. a: item.value,
  169. b: parseInt(item.value) === ((_a2 = state.model) == null ? void 0 : _a2.sex),
  170. c: common_vendor.t(item.name),
  171. d: item.value
  172. };
  173. }),
  174. g: common_vendor.o(onChangeGender),
  175. h: common_vendor.p({
  176. name: "sex",
  177. label: "性别"
  178. }),
  179. i: (_b = userInfo.value.verification) == null ? void 0 : _b.mobile
  180. }, ((_c = userInfo.value.verification) == null ? void 0 : _c.mobile) ? {
  181. j: common_vendor.p({
  182. modelValue: true
  183. })
  184. } : {}, {
  185. k: common_vendor.o(($event) => userInfo.value.mobile = $event),
  186. l: common_vendor.p({
  187. placeholder: "请绑定手机号",
  188. inputBorder: false,
  189. disabled: true,
  190. styles: {
  191. disableColor: "#fff"
  192. },
  193. placeholderStyle: _ctx.placeholderStyle,
  194. clearable: false,
  195. modelValue: userInfo.value.mobile
  196. }),
  197. m: common_vendor.o(onChangeMobile),
  198. n: common_vendor.p({
  199. name: "mobile",
  200. label: "手机号"
  201. }),
  202. o: (_d = userInfo.value.verification) == null ? void 0 : _d.password
  203. }, ((_e = userInfo.value.verification) == null ? void 0 : _e.password) ? {
  204. p: common_vendor.p({
  205. modelValue: true
  206. })
  207. } : {}, {
  208. q: common_vendor.o(($event) => userInfo.value.password = $event),
  209. r: common_vendor.p({
  210. placeholder: "点击修改登录密码",
  211. inputBorder: false,
  212. styles: {
  213. disableColor: "#fff"
  214. },
  215. disabled: true,
  216. placeholderStyle: "color:#BBBBBB;font-size:28rpx;line-height:normal",
  217. clearable: false,
  218. modelValue: userInfo.value.password
  219. }),
  220. s: common_vendor.o(onSetPassword),
  221. t: common_vendor.p({
  222. name: "password",
  223. label: "登录密码"
  224. }),
  225. v: common_vendor.p({
  226. model: state.model,
  227. rules: state.rules,
  228. labelPosition: "left",
  229. border: true
  230. }),
  231. w: common_vendor.unref(sheep_index.sheep).$platform.name !== "H5"
  232. }, common_vendor.unref(sheep_index.sheep).$platform.name !== "H5" ? common_vendor.e({
  233. x: "WechatOfficialAccount" === common_vendor.unref(sheep_index.sheep).$platform.name
  234. }, "WechatOfficialAccount" === common_vendor.unref(sheep_index.sheep).$platform.name ? {
  235. y: common_vendor.unref(sheep_index.sheep).$url.static("/static/images/WechatOfficialAccount.png")
  236. } : {}, {
  237. z: "WechatMiniProgram" === common_vendor.unref(sheep_index.sheep).$platform.name
  238. }, "WechatMiniProgram" === common_vendor.unref(sheep_index.sheep).$platform.name ? {
  239. A: common_vendor.unref(sheep_index.sheep).$url.static("/static/images/WechatMiniProgram.png")
  240. } : {}, {
  241. B: "App" === common_vendor.unref(sheep_index.sheep).$platform.name
  242. }, "App" === common_vendor.unref(sheep_index.sheep).$platform.name ? {
  243. C: common_vendor.unref(sheep_index.sheep).$url.static("/static/images/wechat.png")
  244. } : {}, {
  245. D: state.thirdInfo
  246. }, state.thirdInfo ? {
  247. E: common_vendor.unref(sheep_index.sheep).$url.cdn(state.thirdInfo.avatar),
  248. F: common_vendor.t(state.thirdInfo.nickname)
  249. } : {}, {
  250. G: state.thirdInfo.openid
  251. }, state.thirdInfo.openid ? {
  252. H: common_vendor.o(unBindThirdOauth)
  253. } : {
  254. I: common_vendor.o(bindThirdOauth)
  255. }) : {}, {
  256. J: common_vendor.o(onSubmit),
  257. K: common_vendor.p({
  258. bottom: true,
  259. placeholder: true,
  260. bg: "none"
  261. }),
  262. L: common_vendor.p({
  263. title: "用户信息"
  264. })
  265. });
  266. };
  267. }
  268. };
  269. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-aab93774"], ["__file", "D:/zx/mall-front-app/pages/user/info.vue"]]);
  270. wx.createPage(MiniProgramPage);