From 6605d992fa0ff73183621bf59dd93738d4a1bc5b Mon Sep 17 00:00:00 2001 From: wkj <278599135@qq.com> Date: Mon, 24 Apr 2023 19:06:06 +0800 Subject: [PATCH] =?UTF-8?q?user/info=20mobile$user=E5=8F=96=E4=B8=8Buser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/user/info/index.js | 134 +++++++++++++++++++++++++---------- src/pages/user/info/index.ts | 5 ++ 2 files changed, 100 insertions(+), 39 deletions(-) diff --git a/lib/pages/user/info/index.js b/lib/pages/user/info/index.js index 79ea52685..6f3df9795 100644 --- a/lib/pages/user/info/index.js +++ b/lib/pages/user/info/index.js @@ -19,6 +19,11 @@ exports.default = OakComponent({ id: 1, mobile: 1, userId: 1, + user: { + id: 1, + userState: 1, + refId: 1, + }, }, }, extraFile$entity: { @@ -45,21 +50,50 @@ exports.default = OakComponent({ }, isList: false, formData: function (_a) { - var user = _a.data, features = _a.features; + var user = _a.data, + features = _a.features; var application = features.application.getApplication(); - var avatar = (user === null || user === void 0 ? void 0 : user.extraFile$entity) && (user === null || user === void 0 ? void 0 : user.extraFile$entity[0]); + var avatar = + (user === null || user === void 0 + ? void 0 + : user.extraFile$entity) && + (user === null || user === void 0 + ? void 0 + : user.extraFile$entity[0]); var avatarUrl = features.extraFile.getUrl(avatar); - var mobile = (((user === null || user === void 0 ? void 0 : user.mobile$user) && (user === null || user === void 0 ? void 0 : user.mobile$user[0])) || {}).mobile; - var genderOption = (user === null || user === void 0 ? void 0 : user.gender) && - this.state.genderOptions.find(function (ele) { return ele.value === (user === null || user === void 0 ? void 0 : user.gender); }); - var appType = application === null || application === void 0 ? void 0 : application.type; - var config = application === null || application === void 0 ? void 0 : application.config; + var mobile = ( + ((user === null || user === void 0 ? void 0 : user.mobile$user) && + (user === null || user === void 0 + ? void 0 + : user.mobile$user[0])) || + {} + ).mobile; + var genderOption = + (user === null || user === void 0 ? void 0 : user.gender) && + this.state.genderOptions.find(function (ele) { + return ( + ele.value === + (user === null || user === void 0 ? void 0 : user.gender) + ); + }); + var appType = + application === null || application === void 0 + ? void 0 + : application.type; + var config = + application === null || application === void 0 + ? void 0 + : application.config; var appId; var isSupportSyncWeChat = false; //是否支持微信公众号授权登录 if (appType === 'wechatPublic') { var config2 = config; - var isService = config2 === null || config2 === void 0 ? void 0 : config2.isService; //是否服务号 服务号才能授权登录 - appId = config2 === null || config2 === void 0 ? void 0 : config2.appId; + var isService = + config2 === null || config2 === void 0 + ? void 0 + : config2.isService; //是否服务号 服务号才能授权登录 + appId = + config2 === null || config2 === void 0 ? void 0 : config2.appId; isSupportSyncWeChat = !!(isService && appId); } return { @@ -67,14 +101,18 @@ exports.default = OakComponent({ name: user === null || user === void 0 ? void 0 : user.name, nickname: user === null || user === void 0 ? void 0 : user.nickname, gender: user === null || user === void 0 ? void 0 : user.gender, - genderStr: genderOption === null || genderOption === void 0 ? void 0 : genderOption.label, + genderStr: + genderOption === null || genderOption === void 0 + ? void 0 + : genderOption.label, birthText: (user === null || user === void 0 ? void 0 : user.birth) ? (0, dayjs_1.default)(user.birth).format('YYYY-MM-DD') : '', birth: user === null || user === void 0 ? void 0 : user.birth, avatarUrl: avatarUrl, mobile: mobile, - userState: user === null || user === void 0 ? void 0 : user.userState, + userState: + user === null || user === void 0 ? void 0 : user.userState, idState: user === null || user === void 0 ? void 0 : user.idState, isSupportSyncWeChat: isSupportSyncWeChat, }; @@ -120,7 +158,9 @@ exports.default = OakComponent({ if (userId !== oakId) { throw new types_1.OakUserUnpermittedException(); } - this.setState({ birthEnd: (0, dayjs_1.default)().format('YYYY-MM-DD') }); + this.setState({ + birthEnd: (0, dayjs_1.default)().format('YYYY-MM-DD'), + }); return [2 /*return*/]; }); }); @@ -139,7 +179,10 @@ exports.default = OakComponent({ _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - return [4 /*yield*/, this.features.token.refreshWechatPublicUserInfo()]; + return [ + 4 /*yield*/, + this.features.token.refreshWechatPublicUserInfo(), + ]; case 2: _a.sent(); this.setState({ @@ -152,17 +195,21 @@ exports.default = OakComponent({ refreshing: false, }); throw err_1; - case 4: return [2 /*return*/]; + case 4: + return [2 /*return*/]; } }); }); }, goAddMobile: function () { - this.navigateTo({ - url: '/mobile/me', - }, { - showBack: true, - }); + this.navigateTo( + { + url: '/mobile/me', + }, + { + showBack: true, + } + ); }, setVisibleMp: function (e) { var dataset = e.target.dataset; @@ -171,13 +218,16 @@ exports.default = OakComponent({ }, genderChangeMp: function (e) { var detail = e.detail; - var checked = detail.checked, currentKey = detail.currentKey; + var checked = detail.checked, + currentKey = detail.currentKey; var attr = this.state.attr; this.setCustomData(attr, currentKey); }, birthChangeMp: function (e) { var value = e.detail.value; - var birth = (0, dayjs_1.default)((0, dayjs_1.default)(value).format('YYYY-MM-DD')).valueOf(); + var birth = (0, dayjs_1.default)( + (0, dayjs_1.default)(value).format('YYYY-MM-DD') + ).valueOf(); var attr = this.state.attr; this.setState({ birthText2: (0, dayjs_1.default)(value).format('YYYY-MM-DD'), @@ -186,31 +236,32 @@ exports.default = OakComponent({ }, setVisible: function (visible, attr) { var _a; - this.setState((_a = { + this.setState( + ((_a = { visible: visible, - attr: visible ? attr : '' - }, - _a["new_".concat(attr)] = '', - _a.birthText2 = '', - _a)); + attr: visible ? attr : '', + }), + (_a['new_'.concat(attr)] = ''), + (_a.birthText2 = ''), + _a) + ); }, setCustomData: function (attr, value) { var _a; - this.setState((_a = {}, - _a["new_".concat(attr)] = value, - _a)); + this.setState(((_a = {}), (_a['new_'.concat(attr)] = value), _a)); }, setCustomDataMp: function (e) { - var detail = e.detail, dataset = e.target.dataset; + var detail = e.detail, + dataset = e.target.dataset; var value = detail.value; var attr = this.state.attr; this.setCustomData(attr, value); }, updateData: function (attr, value) { var _a; - this.update((_a = {}, - _a[attr] = this.state["new_".concat(attr)], - _a)); + this.update( + ((_a = {}), (_a[attr] = this.state['new_'.concat(attr)]), _a) + ); }, onConfirmMp: function () { return tslib_1.__awaiter(this, void 0, void 0, function () { @@ -235,16 +286,21 @@ exports.default = OakComponent({ switch (_b.label) { case 0: oakId = this.props.oakId; - if (!this.state["new_".concat(attr)]) { + if (!this.state['new_'.concat(attr)]) { this.setMessage({ type: 'warning', - content: "".concat(this.state.attrs[attr], "\u4E0D\u80FD\u4E3A\u7A7A"), + content: ''.concat( + this.state.attrs[attr], + '\u4E0D\u80FD\u4E3A\u7A7A' + ), }); return [2 /*return*/]; } - this.update((_a = {}, - _a[attr] = this.state["new_".concat(attr)], - _a)); + this.update( + ((_a = {}), + (_a[attr] = this.state['new_'.concat(attr)]), + _a) + ); return [4 /*yield*/, this.execute()]; case 1: _b.sent(); diff --git a/src/pages/user/info/index.ts b/src/pages/user/info/index.ts index 72e734d30..7b0c44fac 100644 --- a/src/pages/user/info/index.ts +++ b/src/pages/user/info/index.ts @@ -24,6 +24,11 @@ export default OakComponent({ id: 1, mobile: 1, userId: 1, + user: { + id: 1, + userState: 1, + refId: 1, + }, }, }, extraFile$entity: {