shishuangxi

绑定手机号

@@ -13,6 +13,11 @@ export class SpConstants{ @@ -13,6 +13,11 @@ export class SpConstants{
13 //协议相关 13 //协议相关
14 static USER_PROTOCOL = "user_protocol" //用户协议 14 static USER_PROTOCOL = "user_protocol" //用户协议
15 static PRIVATE_PROTOCOL = "private_protocol" //隐私协议 15 static PRIVATE_PROTOCOL = "private_protocol" //隐私协议
  16 + static LOGOUT_PROTOCOL = "logout_protocol" //人民日报客户端app注销协议
  17 + static MESSAGE_BOARD_USER_PROTOCOL = "message_board_user_protocol" //"留言板-用户协议"
  18 + static MESSAGE_BOARD_NOTICE_PROTOCOL = "message_board_notice_protocol" //留言板-留言须知
  19 + static MESSAGE_BOARD_QUESTION_PROTOCOL = "message_board_question_protocol" //"留言板-发布提问规定""
  20 + static MESSAGE_BOARD_PRIVATE_PROTOCOL = "message_board_private_protocol" //"留言板-隐私政策"
16 //设置页面 21 //设置页面
17 static SETTING_WIFI_IMAGE_SWITCH = "setting_wifi_switch" //wifi 图片开关 22 static SETTING_WIFI_IMAGE_SWITCH = "setting_wifi_switch" //wifi 图片开关
18 static SETTING_WIFI_VIDEO_SWITCH = "setting_wifi_switch" //wifi 视频开关 23 static SETTING_WIFI_VIDEO_SWITCH = "setting_wifi_switch" //wifi 视频开关
@@ -525,6 +525,12 @@ export class HttpUrlUtils { @@ -525,6 +525,12 @@ export class HttpUrlUtils {
525 return url; 525 return url;
526 } 526 }
527 527
  528 + //获取用户安全页信息
  529 + static querySecurity() {
  530 + let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/security/query";
  531 + return url;
  532 + }
  533 +
528 static getAppointmentListDataUrl() { 534 static getAppointmentListDataUrl() {
529 let url = HttpUrlUtils._hostUrl + HttpUrlUtils.APPOINTMENT_LIST_DATA_PATH 535 let url = HttpUrlUtils._hostUrl + HttpUrlUtils.APPOINTMENT_LIST_DATA_PATH
530 return url 536 return url
@@ -17,6 +17,7 @@ import { Router } from '@ohos.arkui.UIContext'; @@ -17,6 +17,7 @@ import { Router } from '@ohos.arkui.UIContext';
17 import promptAction from '@ohos.promptAction'; 17 import promptAction from '@ohos.promptAction';
18 import { LogoutViewModel } from '../../viewmodel/LogoutViewModel'; 18 import { LogoutViewModel } from '../../viewmodel/LogoutViewModel';
19 import { CustomLogoutDialog } from './CustomLogoutDialog'; 19 import { CustomLogoutDialog } from './CustomLogoutDialog';
  20 +import { emitter } from '@kit.BasicServicesKit';
20 21
21 export { SettingPasswordParams } from "wdLogin" 22 export { SettingPasswordParams } from "wdLogin"
22 23
@@ -41,9 +42,11 @@ export struct AccountAndSecurityLayout { @@ -41,9 +42,11 @@ export struct AccountAndSecurityLayout {
41 alignment: DialogAlignment.Center 42 alignment: DialogAlignment.Center
42 }) 43 })
43 44
  45 +
44 aboutToAppear() { 46 aboutToAppear() {
45 // 获取设置页面数据 47 // 获取设置页面数据
46 this.getAccountAndSecurityData() 48 this.getAccountAndSecurityData()
  49 + this.addEmitEvent()
47 } 50 }
48 51
49 async getAccountAndSecurityData() { 52 async getAccountAndSecurityData() {
@@ -56,6 +59,28 @@ export struct AccountAndSecurityLayout { @@ -56,6 +59,28 @@ export struct AccountAndSecurityLayout {
56 59
57 } 60 }
58 61
  62 + addEmitEvent(){
  63 + // 定义一个eventId为1的事件
  64 + let event: emitter.InnerEvent = {
  65 + eventId: 10010
  66 + };
  67 +
  68 + // 收到eventId为1的事件后执行该回调
  69 + let callback = (eventData: emitter.EventData): void => {
  70 + promptAction.showToast({
  71 + message: JSON.stringify(eventData)
  72 + });
  73 + if(eventData&&eventData.data){
  74 + this.listData[0].subTitle = eventData.data['content']
  75 + }
  76 + Logger.debug( 'event callback:' + JSON.stringify(eventData));
  77 + };
  78 +
  79 + // 订阅eventId为1的事件
  80 + emitter.on(event, callback);
  81 +
  82 + }
  83 +
59 build() { 84 build() {
60 Column(){ 85 Column(){
61 if(this.isAccountPage){ 86 if(this.isAccountPage){
@@ -106,7 +131,8 @@ export struct AccountAndSecurityLayout { @@ -106,7 +131,8 @@ export struct AccountAndSecurityLayout {
106 ListItem() { 131 ListItem() {
107 if (item.type == 0) { 132 if (item.type == 0) {
108 Column() { 133 Column() {
109 - this.getArrowCell(item) 134 + // this.getArrowCell(item)
  135 + AccountArrowCell({ item:item})
110 }.padding({ left: '27lpx' }).height('117lpx').justifyContent(FlexAlign.Center) 136 }.padding({ left: '27lpx' }).height('117lpx').justifyContent(FlexAlign.Center)
111 } else if (item.type == 1) { 137 } else if (item.type == 1) {
112 Column() { 138 Column() {
@@ -285,7 +311,7 @@ export struct AccountAndSecurityLayout { @@ -285,7 +311,7 @@ export struct AccountAndSecurityLayout {
285 }.alignItems(VerticalAlign.Center) 311 }.alignItems(VerticalAlign.Center)
286 312
287 Row() { 313 Row() {
288 - Text("登录") 314 + Text("注销账户")
289 .borderRadius(4) 315 .borderRadius(4)
290 .fontColor(this.protocolState ? "#FFFFFFFF" : "#66FFFFFF") 316 .fontColor(this.protocolState ? "#FFFFFFFF" : "#66FFFFFF")
291 .fontSize(18) 317 .fontSize(18)
@@ -404,4 +430,47 @@ export struct AccountAndSecurityLayout { @@ -404,4 +430,47 @@ export struct AccountAndSecurityLayout {
404 securityNum = phoneNum.replace(needSecurityString,'****') 430 securityNum = phoneNum.replace(needSecurityString,'****')
405 return securityNum; 431 return securityNum;
406 } 432 }
  433 +}
  434 +
  435 +@Component
  436 +export struct AccountArrowCell{
  437 + @ObjectLink item: MineMainSettingFunctionItem
  438 + build() {
  439 + Column() {
  440 + Row() {
  441 + // 左侧logo和标题
  442 + Row() {
  443 + // 判断有没有图片
  444 + if (this.item.imgSrc) {
  445 + Image(this.item.imgSrc)
  446 + .height('38lpx')
  447 + .margin({ right: '5lpx' })
  448 + }
  449 + Text(`${this.item.title}`)
  450 + .margin({ top: '8lpx' })
  451 + .height('38lpx')
  452 + .fontColor('#333333')
  453 + .fontSize('29lpx')
  454 + }.width('60%')
  455 +
  456 + // 右侧文案和右箭头
  457 + Row() {
  458 + Text(this.item.subTitle ? this.item.subTitle : '')
  459 + .fontColor('#999999')
  460 + .maxLines(1)
  461 + Image($r('app.media.mine_user_arrow'))
  462 + .width('27lpx')
  463 + .height('27lpx')
  464 + .objectFit(ImageFit.Auto)
  465 + Column().width('29lpx')
  466 + }.width('40%')
  467 + .margin({ right: '29lpx' })
  468 + .justifyContent(FlexAlign.End)
  469 +
  470 + }
  471 + .alignItems(VerticalAlign.Center)
  472 + .justifyContent(FlexAlign.SpaceBetween)
  473 + }
  474 + .height('54lpx')
  475 + }
407 } 476 }
@@ -7,7 +7,9 @@ import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/ @@ -7,7 +7,9 @@ import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/
7 import { WDRouterRule, WDRouterPage } from 'wdRouter'; 7 import { WDRouterRule, WDRouterPage } from 'wdRouter';
8 import { SettingPasswordParams } from './SettingPasswordLayout' 8 import { SettingPasswordParams } from './SettingPasswordLayout'
9 import { Router } from '@ohos.arkui.UIContext' 9 import { Router } from '@ohos.arkui.UIContext'
10 -import { ToastUtils } from 'wdKit/Index' 10 +import { SPHelper, ToastUtils } from 'wdKit/Index'
  11 +import { SpConstants } from 'wdConstant/Index'
  12 +import { emitter } from '@kit.BasicServicesKit'
11 13
12 14
13 const TAG = 'ForgetPasswordPage' 15 const TAG = 'ForgetPasswordPage'
@@ -147,7 +149,34 @@ struct ForgetPasswordPage { @@ -147,7 +149,34 @@ struct ForgetPasswordPage {
147 } 149 }
148 this.loginViewModel.changeBindPhone(this.phoneContent,this.codeContent).then(()=>{ 150 this.loginViewModel.changeBindPhone(this.phoneContent,this.codeContent).then(()=>{
149 ToastUtils.shortToast('绑定成功') 151 ToastUtils.shortToast('绑定成功')
  152 + this.querySecurity()
  153 + })
  154 + }
  155 +
  156 + querySecurity(){
  157 + this.loginViewModel.querySecurity().then(()=>{
  158 + SPHelper.default.save(SpConstants.USER_PHONE,this.phoneContent)
  159 + this.sendEmitEvent()
150 router.back() 160 router.back()
  161 + }).catch(()=>{
  162 +
151 }) 163 })
152 } 164 }
  165 +
  166 + sendEmitEvent(){
  167 + // 定义一个eventId为1的事件,事件优先级为Low
  168 + let event: emitter.InnerEvent = {
  169 + eventId: 10010,
  170 + priority: emitter.EventPriority.LOW
  171 + };
  172 +
  173 + let eventData: emitter.EventData = {
  174 + data: {
  175 + content: this.phoneContent,
  176 + }
  177 + };
  178 +
  179 + // 发送eventId为1的事件,事件内容为eventData
  180 + emitter.emit(event, eventData);
  181 + }
153 } 182 }
@@ -71,11 +71,11 @@ export class LoginModel { @@ -71,11 +71,11 @@ export class LoginModel {
71 return new Promise<LoginBean>((success, fail) => { 71 return new Promise<LoginBean>((success, fail) => {
72 HttpRequest.post<ResponseDTO<LoginBean>>(HttpUrlUtils.getAppLoginUrl(), bean, headers).then((data: ResponseDTO<LoginBean>) => { 72 HttpRequest.post<ResponseDTO<LoginBean>>(HttpUrlUtils.getAppLoginUrl(), bean, headers).then((data: ResponseDTO<LoginBean>) => {
73 Logger.debug("LoginViewModel:success2 ", data.message) 73 Logger.debug("LoginViewModel:success2 ", data.message)
74 - if (!data || !data.data) { 74 + if (!data) {
75 fail("数据为空") 75 fail("数据为空")
76 return 76 return
77 } 77 }
78 - if (data.code != 0) { 78 + if (!data.data||data.code != 0) {
79 fail(data.message) 79 fail(data.message)
80 return 80 return
81 } 81 }
@@ -99,11 +99,11 @@ export class LoginModel { @@ -99,11 +99,11 @@ export class LoginModel {
99 return new Promise<LoginBean>((success, fail) => { 99 return new Promise<LoginBean>((success, fail) => {
100 HttpRequest.post<ResponseDTO<LoginBean>>(HttpUrlUtils.getAppLoginUrl(), bean, headers).then((data: ResponseDTO<LoginBean>) => { 100 HttpRequest.post<ResponseDTO<LoginBean>>(HttpUrlUtils.getAppLoginUrl(), bean, headers).then((data: ResponseDTO<LoginBean>) => {
101 Logger.debug("LoginViewModel:success2 ", data.message) 101 Logger.debug("LoginViewModel:success2 ", data.message)
102 - if (!data || !data.data) { 102 + if (!data) {
103 fail("数据为空") 103 fail("数据为空")
104 return 104 return
105 } 105 }
106 - if (data.code != 0) { 106 + if (!data.data||data.code != 0) {
107 fail(data.message) 107 fail(data.message)
108 return 108 return
109 } 109 }
@@ -268,10 +268,10 @@ export class LoginModel { @@ -268,10 +268,10 @@ export class LoginModel {
268 let bean: Record<string, Object> = {}; 268 let bean: Record<string, Object> = {};
269 bean['phone'] = phone 269 bean['phone'] = phone
270 bean['verifyCode'] = verificationCode 270 bean['verifyCode'] = verificationCode
271 - return new Promise<LoginBean>((success, fail) => {  
272 - HttpRequest.post<ResponseDTO<LoginBean>>(HttpUrlUtils.changeBindPhone(), bean, headers).then((data: ResponseDTO<LoginBean>) => { 271 + return new Promise<object>((success, fail) => {
  272 + HttpRequest.post<ResponseDTO<object>>(HttpUrlUtils.changeBindPhone(), bean, headers).then((data: ResponseDTO<object>) => {
273 Logger.debug("LoginViewModel:success2 ", data.message) 273 Logger.debug("LoginViewModel:success2 ", data.message)
274 - if (!data || !data.data) { 274 + if (!data) {
275 fail("数据为空") 275 fail("数据为空")
276 return 276 return
277 } 277 }
@@ -279,7 +279,29 @@ export class LoginModel { @@ -279,7 +279,29 @@ export class LoginModel {
279 fail(data.message) 279 fail(data.message)
280 return 280 return
281 } 281 }
282 - success(data.data) 282 + success(data)
  283 + }, (error: Error) => {
  284 + fail(error.message)
  285 + Logger.debug("LoginViewModel:error2 ", error.toString())
  286 + })
  287 + })
  288 + }
  289 +
  290 + /**获取用户安全页信息*/
  291 + querySecurity(){
  292 + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
  293 + return new Promise<object>((success, fail) => {
  294 + HttpRequest.get<ResponseDTO<object>>(HttpUrlUtils.querySecurity(), headers).then((data: ResponseDTO<object>) => {
  295 + Logger.debug("LoginViewModel:success2 ", data.message)
  296 + if (!data) {
  297 + fail("数据为空")
  298 + return
  299 + }
  300 + if (data.code != 0) {
  301 + fail(data.message)
  302 + return
  303 + }
  304 + success(data)
283 }, (error: Error) => { 305 }, (error: Error) => {
284 fail(error.message) 306 fail(error.message)
285 Logger.debug("LoginViewModel:error2 ", error.toString()) 307 Logger.debug("LoginViewModel:error2 ", error.toString())
@@ -312,6 +312,8 @@ struct LoginPage { @@ -312,6 +312,8 @@ struct LoginPage {
312 url: `${WDRouterPage.getBundleInfo()}` 312 url: `${WDRouterPage.getBundleInfo()}`
313 } 313 }
314 ) 314 )
  315 + }).catch((error:string)=>{
  316 + promptAction.showToast({ message: error })
315 }) 317 })
316 } else { 318 } else {
317 this.loginViewModel.appLoginByPassword(this.accountContent, 0, this.passwordContent, "").then((data) => { 319 this.loginViewModel.appLoginByPassword(this.accountContent, 0, this.passwordContent, "").then((data) => {
@@ -14,18 +14,22 @@ struct LoginProtocolWebview { @@ -14,18 +14,22 @@ struct LoginProtocolWebview {
14 webviewController: webview.WebviewController = new webview.WebviewController() 14 webviewController: webview.WebviewController = new webview.WebviewController()
15 userProtocol = "https://cdnpeoplefrontuat.aikan.pdnews.cn/rmrb/rmrb-protocol-zh-web/0.0.1/app/protocol-1005.html" 15 userProtocol = "https://cdnpeoplefrontuat.aikan.pdnews.cn/rmrb/rmrb-protocol-zh-web/0.0.1/app/protocol-1005.html"
16 privateProtocol = 'https://cdnpeoplefrontuat.aikan.pdnews.cn/rmrb/rmrb-protocol-zh-web/0.0.1/app/protocol-1001.html' 16 privateProtocol = 'https://cdnpeoplefrontuat.aikan.pdnews.cn/rmrb/rmrb-protocol-zh-web/0.0.1/app/protocol-1001.html'
  17 + logoutProtocol = 'https://cdnpeoplefrontuat.aikan.pdnews.cn/rmrb/rmrb-protocol-zh-web/0.0.1/app/protocol-1003.html'
17 18
18 async aboutToAppear() { 19 async aboutToAppear() {
19 if (router.getParams()) { 20 if (router.getParams()) {
20 let params = router.getParams() as Params 21 let params = router.getParams() as Params
21 Logger.info(TAG, 'params.contentID:' + params.contentID); 22 Logger.info(TAG, 'params.contentID:' + params.contentID);
22 - if (params.contentID == "1") { 23 + if (params.contentID == "1") { //用户协议
23 this.webUrl = await SPHelper.default.get(SpConstants.USER_PROTOCOL, this.userProtocol) as string 24 this.webUrl = await SPHelper.default.get(SpConstants.USER_PROTOCOL, this.userProtocol) as string
24 this.webviewController.loadUrl(this.webUrl) 25 this.webviewController.loadUrl(this.webUrl)
25 26
26 - } else { 27 + } else if(params.contentID == "2"){ //隐私协议
27 this.webUrl = await SPHelper.default.get(SpConstants.PRIVATE_PROTOCOL, this.privateProtocol) as string 28 this.webUrl = await SPHelper.default.get(SpConstants.PRIVATE_PROTOCOL, this.privateProtocol) as string
28 this.webviewController.loadUrl(this.webUrl) 29 this.webviewController.loadUrl(this.webUrl)
  30 + }else if(params.contentID == "3"){ //注销协议
  31 + this.webUrl = await SPHelper.default.get(SpConstants.LOGOUT_PROTOCOL, this.logoutProtocol) as string
  32 + this.webviewController.loadUrl(this.webUrl)
29 } 33 }
30 } 34 }
31 35
@@ -59,8 +59,8 @@ export class LoginViewModel { @@ -59,8 +59,8 @@ export class LoginViewModel {
59 HttpUrlUtils.setUserType(data.userType+"") 59 HttpUrlUtils.setUserType(data.userType+"")
60 HttpUrlUtils.setUserToken(data.jwtToken) 60 HttpUrlUtils.setUserToken(data.jwtToken)
61 success(data) 61 success(data)
62 - }).catch(() => {  
63 - fail() 62 + }).catch((error:string) => {
  63 + fail(error)
64 }) 64 })
65 }) 65 })
66 } 66 }
@@ -169,8 +169,8 @@ export class LoginViewModel { @@ -169,8 +169,8 @@ export class LoginViewModel {
169 } 169 }
170 170
171 changeBindPhone(phone: string, verificationCode: string) { 171 changeBindPhone(phone: string, verificationCode: string) {
172 - return new Promise<LoginBean>((success, fail) => {  
173 - this.loginModel.changeBindPhone(phone, verificationCode).then((data: LoginBean) => { 172 + return new Promise<object>((success, fail) => {
  173 + this.loginModel.changeBindPhone(phone, verificationCode).then((data: object) => {
174 success(data) 174 success(data)
175 }).catch(() => { 175 }).catch(() => {
176 fail() 176 fail()
@@ -178,7 +178,15 @@ export class LoginViewModel { @@ -178,7 +178,15 @@ export class LoginViewModel {
178 }) 178 })
179 } 179 }
180 180
181 - 181 + querySecurity(){
  182 + return new Promise<object>((success, fail) => {
  183 + this.loginModel.querySecurity().then((data: object) => {
  184 + success(data)
  185 + }).catch(() => {
  186 + fail()
  187 + })
  188 + })
  189 + }
182 190
183 async doMd(content: string): Promise<string> { 191 async doMd(content: string): Promise<string> {
184 let mdAlgName = 'SHA256'; // 摘要算法名 192 let mdAlgName = 'SHA256'; // 摘要算法名
@@ -26,6 +26,16 @@ export class LaunchModel { @@ -26,6 +26,16 @@ export class LaunchModel {
26 SPHelper.default.save(SpConstants.USER_PROTOCOL, data.data[i].linkUrl) 26 SPHelper.default.save(SpConstants.USER_PROTOCOL, data.data[i].linkUrl)
27 } else if (data.data[i].type == 2) { 27 } else if (data.data[i].type == 2) {
28 SPHelper.default.save(SpConstants.PRIVATE_PROTOCOL, data.data[i].linkUrl) 28 SPHelper.default.save(SpConstants.PRIVATE_PROTOCOL, data.data[i].linkUrl)
  29 + }else if (data.data[i].type == 4) {
  30 + SPHelper.default.save(SpConstants.LOGOUT_PROTOCOL, data.data[i].linkUrl)
  31 + }else if (data.data[i].type == 5) {
  32 + SPHelper.default.save(SpConstants.MESSAGE_BOARD_USER_PROTOCOL, data.data[i].linkUrl)
  33 + }else if (data.data[i].type == 6) {
  34 + SPHelper.default.save(SpConstants.MESSAGE_BOARD_NOTICE_PROTOCOL, data.data[i].linkUrl)
  35 + }else if (data.data[i].type == 7) {
  36 + SPHelper.default.save(SpConstants.MESSAGE_BOARD_QUESTION_PROTOCOL, data.data[i].linkUrl)
  37 + }else if (data.data[i].type == 8) {
  38 + SPHelper.default.save(SpConstants.MESSAGE_BOARD_PRIVATE_PROTOCOL, data.data[i].linkUrl)
29 } 39 }
30 } 40 }
31 41