diff --git a/es/components/changePassword/index.js b/es/components/changePassword/index.js index 761825727..7bf11aefe 100644 --- a/es/components/changePassword/index.js +++ b/es/components/changePassword/index.js @@ -2,39 +2,56 @@ const SEND_KEY = 'captcha:sendAt'; const SEND_CAPTCHA_LATENCY = process.env.NODE_ENV === 'development' ? 10 : 60; export default OakComponent({ isList: false, - entity: 'user', - projection: { - id: 1, - name: 1, - nickname: 1, - mobile$user: { - $entity: 'mobile', - data: { - id: 1, - mobile: 1, - }, - filter: { - ableState: 'enabled' - } - } - }, - formData: function ({ data: user, features, props }) { - return { - user, - }; - }, + // entity: 'user', + // projection: { + // id: 1, + // name: 1, + // nickname: 1, + // mobile$user: { + // $entity: 'mobile', + // data: { + // id: 1, + // mobile: 1, + // }, + // filter: { + // ableState: 'enabled' + // } + // } + // }, + // formData: function ({ data: user, features, props }) { + // return { + // user, + // }; + // }, data: { channels: [], }, + properties: { + oakId: '', + }, lifetimes: { async attached() { const userId = this.props.oakId; - const { result } = await this.features.cache.exec('getChangePasswordChannels', { - userId, - }); this.setState({ - channels: result + loading: true, }); + try { + const { result } = await this.features.cache.exec( + 'getChangePasswordChannels', + { + userId: userId, + } + ); + this.setState({ + channels: result, + loading: false, + }); + } catch { + this.setState({ + loading: false, + channels: [], + }); + } }, }, methods: { diff --git a/es/components/changePassword/web.d.ts b/es/components/changePassword/web.d.ts index c17eb3860..1a9cd689b 100644 --- a/es/components/changePassword/web.d.ts +++ b/es/components/changePassword/web.d.ts @@ -1,10 +1,18 @@ import React from 'react'; import { WebComponentProps } from 'oak-frontend-base'; import { EntityDict } from '../../oak-app-domain'; -export default function Render(props: WebComponentProps void; -}>): React.JSX.Element; +export default function Render( + props: WebComponentProps< + EntityDict, + 'user', + false, + { + loading: boolean; + channels: string[]; + oakId: string; + }, + { + goToMobile: () => void; + } + > +): React.JSX.Element; diff --git a/es/components/changePassword/web.js b/es/components/changePassword/web.js index 64e4313ab..97dca056b 100644 --- a/es/components/changePassword/web.js +++ b/es/components/changePassword/web.js @@ -4,8 +4,13 @@ import ByMobile from './byMobile'; import ByPassword from './byPassword'; export default function Render(props) { const { data, methods } = props; - const { channels, user, oakFullpath, oakId } = data; + const { channels, oakFullpath, oakId, loading } = data; const { goToMobile } = methods; + + if (loading) { + return null; + } + const items = [ { key: 'password', diff --git a/es/features/weiXinJsSdk.web.d.ts b/es/features/weiXinJsSdk.web.d.ts index 837cc13a1..e2165d3ea 100644 --- a/es/features/weiXinJsSdk.web.d.ts +++ b/es/features/weiXinJsSdk.web.d.ts @@ -17,7 +17,7 @@ type ConfigOptions = { jsApiList?: wx.jsApiList; openTagList?: wx.openTagList; }; -type ParamOptions = wx.IcheckJsApi | wx.IaddCard | wx.IchooseCard | wx.IonMenuShareTimeline | wx.IonMenuShareAppMessage | wx.IonMenuShareQQ | wx.IonMenuShareWeibo | wx.IonMenuShareQZone | wx.IchooseImage | wx.IpreviewImage | wx.IuploadImage | wx.IdownloadImage | wx.IgetLocalImgData | wx.IplaypausestopVoice | wx.IupdownloadVoice | wx.IopenLocation | wx.IgetLocation | wx.IscanQRCode | wx.IopenProductSpecificView | wx.IchooseCard | wx.IopenCard | wx.IchooseWXPay; +type ParamOptions = wx.IcheckJsApi | wx.IaddCard | wx.IchooseCard | wx.IonMenuShareTimeline | wx.IonMenuShareAppMessage | wx.IonMenuShareQQ | wx.IonMenuShareWeibo | wx.IonMenuShareQZone | wx.IchooseImage | wx.IpreviewImage | wx.IgetLocalImgData | wx.IplaypausestopVoice | wx.IopenLocation | wx.IgetLocation | wx.IscanQRCode | wx.IopenProductSpecificView | wx.IchooseCard | wx.IopenCard | wx.IchooseWXPay; export declare class WeiXinJsSdk, FrontCxt extends FrontendRuntimeContext, AD extends AspectDict & CommonAspectDict> extends Feature { private cache; private storage; diff --git a/lib/features/weiXinJsSdk.web.d.ts b/lib/features/weiXinJsSdk.web.d.ts index 837cc13a1..e2165d3ea 100644 --- a/lib/features/weiXinJsSdk.web.d.ts +++ b/lib/features/weiXinJsSdk.web.d.ts @@ -17,7 +17,7 @@ type ConfigOptions = { jsApiList?: wx.jsApiList; openTagList?: wx.openTagList; }; -type ParamOptions = wx.IcheckJsApi | wx.IaddCard | wx.IchooseCard | wx.IonMenuShareTimeline | wx.IonMenuShareAppMessage | wx.IonMenuShareQQ | wx.IonMenuShareWeibo | wx.IonMenuShareQZone | wx.IchooseImage | wx.IpreviewImage | wx.IuploadImage | wx.IdownloadImage | wx.IgetLocalImgData | wx.IplaypausestopVoice | wx.IupdownloadVoice | wx.IopenLocation | wx.IgetLocation | wx.IscanQRCode | wx.IopenProductSpecificView | wx.IchooseCard | wx.IopenCard | wx.IchooseWXPay; +type ParamOptions = wx.IcheckJsApi | wx.IaddCard | wx.IchooseCard | wx.IonMenuShareTimeline | wx.IonMenuShareAppMessage | wx.IonMenuShareQQ | wx.IonMenuShareWeibo | wx.IonMenuShareQZone | wx.IchooseImage | wx.IpreviewImage | wx.IgetLocalImgData | wx.IplaypausestopVoice | wx.IopenLocation | wx.IgetLocation | wx.IscanQRCode | wx.IopenProductSpecificView | wx.IchooseCard | wx.IopenCard | wx.IchooseWXPay; export declare class WeiXinJsSdk, FrontCxt extends FrontendRuntimeContext, AD extends AspectDict & CommonAspectDict> extends Feature { private cache; private storage; diff --git a/src/components/changePassword/index.ts b/src/components/changePassword/index.ts index a82262274..a57050b16 100644 --- a/src/components/changePassword/index.ts +++ b/src/components/changePassword/index.ts @@ -5,48 +5,64 @@ const SEND_CAPTCHA_LATENCY = process.env.NODE_ENV === 'development' ? 10 : 60; export default OakComponent({ isList: false, - entity: 'user', - projection: { - id: 1, - name: 1, - nickname: 1, - mobile$user: { - $entity: 'mobile', - data: { - id: 1, - mobile: 1, - }, - filter: { - ableState: 'enabled' - } - } - }, - formData: function ({ data: user, features, props }) { - return { - user, - }; - }, + // entity: 'user', + // projection: { + // id: 1, + // name: 1, + // nickname: 1, + // mobile$user: { + // $entity: 'mobile', + // data: { + // id: 1, + // mobile: 1, + // }, + // filter: { + // ableState: 'enabled' + // } + // } + // }, + // formData: function ({ data: user, features, props }) { + // return { + // user, + // }; + // }, data: { channels: [] as string[], + loading: false, + }, + properties: { + oakId: '', }, lifetimes: { async attached() { - const userId = this.props.oakId as string; - const { result } = await this.features.cache.exec('getChangePasswordChannels', { - userId, - }); + const userId = this.props.oakId; this.setState({ - channels: result + loading: true, }); + try { + const { result } = await this.features.cache.exec( + 'getChangePasswordChannels', + { + userId: userId!, + } + ); + this.setState({ + channels: result, + loading: false, + }); + } catch { + this.setState({ + loading: false, + channels: [], + }); + } }, }, methods: { goToMobile() { - this.navigateTo( - { - url: '/mobile/me', - } - ) + this.navigateTo({ + url: '/mobile/me', + }); }, }, }); diff --git a/src/components/changePassword/web.tsx b/src/components/changePassword/web.tsx index a75ed642a..f81a5ec62 100644 --- a/src/components/changePassword/web.tsx +++ b/src/components/changePassword/web.tsx @@ -9,12 +9,12 @@ import ByPassword from './byPassword'; export default function Render( props: WebComponentProps< EntityDict, - 'message', + 'user', false, { - user: EntityDict['user']['Schema']; channels: string[]; oakId: string; + loading: boolean; }, { goToMobile: () => void; @@ -22,18 +22,36 @@ export default function Render( > ) { const { data, methods } = props; - const { channels, user, oakFullpath, oakId } = data; + const { channels, oakFullpath, oakId, loading } = data; const { goToMobile } = methods; + + + if (loading) { + return null + } + const items = [ { key: 'password', label: '原密码验证', - children: , + children: ( + + ), }, { key: 'mobile', label: '手机号验证', - children: , + children: ( + + ), }, ]; if (channels.length === 0) { diff --git a/src/features/weiXinJsSdk.web.ts b/src/features/weiXinJsSdk.web.ts index 6562a8635..0c0c0da2c 100644 --- a/src/features/weiXinJsSdk.web.ts +++ b/src/features/weiXinJsSdk.web.ts @@ -40,11 +40,8 @@ type ParamOptions = | wx.IonMenuShareQZone | wx.IchooseImage | wx.IpreviewImage - | wx.IuploadImage - | wx.IdownloadImage | wx.IgetLocalImgData | wx.IplaypausestopVoice - | wx.IupdownloadVoice | wx.IopenLocation | wx.IgetLocation | wx.IscanQRCode @@ -112,12 +109,17 @@ export class WeiXinJsSdk< async init(options?: { jsApiList?: wx.jsApiList; openTagList?: wx.openTagList; + debug?: boolean; }) { if (!isWeiXin) { console.warn('只能在微信客户端初始化JSSDK'); return; } - const { jsApiList, openTagList } = options || {}; + const { + jsApiList, + openTagList, + debug = process.env.NODE_ENV === 'development', + } = options || {}; let url = window.location.href; //在ios上 实际真正有效的的签名URL是【第一次进入应用时的URL】 @@ -153,7 +155,7 @@ export class WeiXinJsSdk< } return this.getConfig({ - debug: process.env.NODE_ENV === 'development', + debug: debug, appId: result.appId, timestamp: result.timestamp, nonceStr: result.noncestr,