info.js 11 KB

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