王士厅
Showing 21 changed files with 850 additions and 81 deletions
... ... @@ -6,7 +6,7 @@ export const enum CompStyle {
Carousel_Layout_01 = 'Zh_Carousel_Layout-01', // 通用轮播卡:视频、直播、活动、专题、榜单、外链
Carousel_Layout_02 = 'Carousel_Layout-02', // 直播轮播卡:直播
Single_Row_01 = 'Zh_Single_Row-01', // 三格方形小卡(排名):专题、活动
Zh_Single_Row_01 = 'Zh_Single_Row-01', // 横划卡
Zh_Single_Row_01 = 'Zh_Single_Row-01', // 横划卡 imageScale-封面图比例 1-4:3, 2-16:9, 3-3:2
Single_Row_02 = 'Zh_Single_Row-02', // 通用横划卡:视频、直播、专题
Single_Row_03 = 'Single_Row-03', // 直播横划卡:直播
Single_Row_04 = 'Single_Row-04', // 三格方形小卡:专题、活动
... ... @@ -26,5 +26,8 @@ export const enum CompStyle {
Single_ImageCard_03 = '13',//单图卡:3行标题
Single_ImageCard_01 = '6',//单图卡,竖图
ZhGrid_Layout_03 = 'Zh_Grid_Layout-03', //金刚位卡
Album_Card_01 = '17' //图卡集
Album_Card_01 = '17', //图卡集
Zh_Single_Row_04 = 'Zh_Single_Row-04', // 地方精选卡
CompStyle_09 = 9, // 时间链卡
CompStyle_10 = 10, // 大专题卡
}
... ...
... ... @@ -309,8 +309,19 @@ export class HttpUrlUtils {
return url;
}
static getVerifyCodeByTokenUrl() {
let url = HttpUrlUtils.hostUrl + "/api/rmrb-user-center/auth/zh/c/sendVerifyCodeByToken";
return url;
}
static getForgetPasswordUrl() {
let url = HttpUrlUtils.hostUrl + "/api/rmrb-user-center/auth/zh/c/forgotPassword";
let url = HttpUrlUtils.hostUrl + "/api/rmrb-user-center/user/zh/c/forgotPassword";
return url;
}
static getResetPassworddUrl() {
let url = HttpUrlUtils.hostUrl + "/api/rmrb-user-center/user/zh/c/resetPassword";
return url;
}
... ... @@ -334,6 +345,11 @@ export class HttpUrlUtils {
return url;
}
static getCheckVerifyByTokenCodeUrl() {
let url = HttpUrlUtils.hostUrl + "/api/rmrb-user-center/auth/zh/c/checkVerifyCodeByToken";
return url;
}
static getAppointmentListDataUrl() {
let url = HttpUrlUtils.HOST_SIT + HttpUrlUtils.APPOINTMENT_LIST_DATA_PATH
return url
... ...
import { LazyDataSource, StringUtils } from 'wdKit';
import { CommentListItem } from '../../../viewmodel/CommentListItem';
import { OtherUserCommentListRequestItem } from '../../../viewmodel/OtherUserCommentListRequestItem';
import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI';
const TAG = "HomePageBottomComponent"
@Component
export struct OtherHomePageBottomCommentComponent{
@Prop curUserId: string
@State data_comment: LazyDataSource<CommentListItem> = new LazyDataSource();
@State isLoading:boolean = false
@State hasMore:boolean = true
curPageNum:number = 1;
@State count:number = 0;
aboutToAppear(){
this.getNewPageData()
}
build(){
Column(){
Divider().width('100%')
.height('2lpx')
.strokeWidth('1lpx')
.backgroundColor($r('app.color.color_EDEDED'))
if(this.count === 0){
ListHasNoMoreDataUI({style:2})
.height('100%')
}else{
List({ space: 3 }) {
LazyForEach(this.data_comment, (item: CommentListItem, index: number = 0) => {
ListItem() {
ChildCommentComponent({data: item})
}
.onClick(() => {
})
}, (item: CommentListItem, index: number) => index.toString())
//没有更多数据 显示提示
if(!this.hasMore){
ListItem(){
ListHasNoMoreDataUI()
}
}
}.cachedCount(15)
.layoutWeight(1)
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None)
// .nestedScroll({
// scrollForward: NestedScrollMode.PARENT_FIRST,
// scrollBackward: NestedScrollMode.SELF_FIRST
// })
.onReachEnd(()=>{
console.log(TAG,"触底了");
if(!this.isLoading){
this.isLoading = true
//加载分页数据
this.getNewPageData()
}
})
}
}
.width('100%')
}
@Styles
listStyle() {
.backgroundColor(Color.White)
.height(72)
.width("100%")
.borderRadius(12)
}
getNewPageData(){
this.isLoading = true
if(this.hasMore){
let object = new OtherUserCommentListRequestItem("",20,this.curPageNum,"","1",this.curUserId)
// MinePageDatasModel.getMineCommentListData(object,getContext(this)).then((value)=>{
// if (!this.data_comment || value.list.length == 0){
// this.hasMore = false
// }else{
// value.list.forEach((value)=>{
// this.data_comment.push(new CommentListItem(value.fromUserHeader,value.fromUserName,value.targetTitle,value.createTime,value.commentContent))
// })
// this.data_comment.notifyDataReload()
// this.count = this.data_comment.totalCount()
// if (this.data_comment.totalCount() < value.totalCount) {
// this.curPageNum++
// }else {
// this.hasMore = false
// }
// }
// this.isLoading = false
// }).catch((err:Error)=>{
// console.log(TAG,"请求失败")
// this.isLoading = false
// })
}
}
}
@Component
struct ChildCommentComponent {
@ObjectLink data: CommentListItem
build() {
Column(){
Row() {
Image(StringUtils.isEmpty(this.data.fromUserHeader)?$r('app.media.default_head'):this.data.fromUserHeader)
.objectFit(ImageFit.Auto)
.width('69lpx')
.height('69lpx')
.margin({right:'15lpx'})
Column(){
Text(this.data.fromUserName)
.fontSize('25lpx')
.lineHeight('35lpx')
.fontWeight('600lpx')
.fontColor($r('app.color.color_222222'))
.margin({bottom:'6lpx'})
.maxLines(1)
Text(`${this.data.createTime}`)
.fontColor($r('app.color.color_B0B0B0'))
.fontSize('23lpx')
.lineHeight('31lpx')
.fontWeight('400lpx')
.maxLines(1)
}.layoutWeight(1)
.alignItems(HorizontalAlign.Start)
}
.margin({bottom:'10lpx'})
.width('100%')
.height('108lpx')
.padding({left:'31lpx',right:'31lpx'})
Row(){
Text(this.data.commentContent)
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontWeight('400lpx')
.fontSize('31lpx')
.lineHeight('46lpx')
.fontColor($r('app.color.color_222222'))
.margin({bottom:'10lpx'})
}.padding({left:'31lpx',right:'31lpx'})
.width('100%')
Row(){
Text(this.data.targetTitle)
.fontWeight('400lpx')
.fontColor($r('app.color.color_222222'))
.lineHeight('38lpx')
.fontSize('27lpx')
.textAlign(TextAlign.Center)
.margin({right:'4lpx'})
.maxLines(3)
.width('616lpx')
Image($r('app.media.arrow_icon_right'))
.objectFit(ImageFit.Auto)
.width('27lpx')
.height('27lpx')
}
.padding({top:'17lpx',bottom:'17lpx',left:'23lpx',right:'23lpx'})
.width('662lpx')
.backgroundColor($r('app.color.color_F5F5F5'))
.margin({top:'19lpx',bottom:'31lpx'})
Divider().width('100%')
.height('12lpx')
.strokeWidth('12lpx')
.backgroundColor($r('app.color.color_F5F5F5'))
}
.justifyContent(FlexAlign.Center)
}
}
\ No newline at end of file
... ...
import { Params } from 'wdBean';
import { LazyDataSource, StringUtils } from 'wdKit';
import { WDRouterRule, WDRouterPage } from 'wdRouter';
import MinePageDatasModel from '../../../model/MinePageDatasModel';
import { FollowListDetailItem } from '../../../viewmodel/FollowListDetailItem';
import { FollowListDetailRequestItem } from '../../../viewmodel/FollowListDetailRequestItem';
import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI';
const TAG = "HomePageBottomComponent"
@Component
export struct OtherHomePageBottomFollowComponent{
@State data_follow: LazyDataSource<FollowListDetailItem> = new LazyDataSource();
@State isLoading:boolean = false
@State hasMore:boolean = true
curPageNum:number = 1;
@State count:number = 0;
aboutToAppear(){
this.getNewPageData()
}
build(){
Column(){
Divider().width('100%')
.height('2lpx')
.strokeWidth('1lpx')
.backgroundColor($r('app.color.color_EDEDED'))
if(this.count === 0){
ListHasNoMoreDataUI({style:2})
.height('100%')
}else{
List({ space: 3 }) {
ListItem() {
Row(){
Text("关注更多人民号")
.fontWeight('400lpx')
.fontColor($r('app.color.color_222222'))
.lineHeight('38lpx')
.fontSize('27lpx')
.textAlign(TextAlign.Center)
.margin({right:'4lpx'})
Image($r('app.media.arrow_icon_right'))
.objectFit(ImageFit.Auto)
.width('27lpx')
.height('27lpx')
}.height('69lpx')
.width('659lpx')
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.Center)
.backgroundColor($r('app.color.color_F5F5F5'))
.margin({top:'31lpx',bottom:'4lpx'})
}.onClick(()=>{
let params: Params = {
pageID: "1"
}
WDRouterRule.jumpWithPage(WDRouterPage.followListPage,params)
})
LazyForEach(this.data_follow, (item: FollowListDetailItem, index: number = 0) => {
ListItem() {
ChildFollowComponent({data: item})
}
.onClick(() => {
})
}, (item: FollowListDetailItem, index: number) => index.toString())
//没有更多数据 显示提示
if(!this.hasMore){
ListItem(){
ListHasNoMoreDataUI()
}
}
}.cachedCount(15)
.padding({left:'31lpx',right:'31lpx'})
.layoutWeight(1)
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None)
// .nestedScroll({
// scrollForward: NestedScrollMode.PARENT_FIRST,
// scrollBackward: NestedScrollMode.SELF_FIRST
// })
.onReachEnd(()=>{
console.log(TAG,"触底了");
if(!this.isLoading){
this.isLoading = true
//加载分页数据
this.getNewPageData()
}
})
}
}
.width('100%')
}
@Styles
listStyle() {
.backgroundColor(Color.White)
.height(72)
.width("100%")
.borderRadius(12)
}
getNewPageData(){
this.isLoading = true
//我的关注列表
if(this.hasMore){
let object = new FollowListDetailRequestItem(20,this.curPageNum)
MinePageDatasModel.getMineFollowListData(object,getContext(this)).then((value)=>{
if (!this.data_follow || value.list.length == 0){
this.hasMore = false
}else{
value.list.forEach((value)=>{
this.data_follow.push(new FollowListDetailItem(value.attentionHeadPhotoUrl,value.attentionUserName,value.fansNum,value.introduction,value.attentionCreatorId,"1"))
})
this.data_follow.notifyDataReload()
this.count = this.data_follow.totalCount()
if (this.data_follow.totalCount() < value.totalCount) {
this.curPageNum++
}else {
this.hasMore = false
}
}
this.isLoading = false
}).catch((err:Error)=>{
console.log(TAG,"请求失败")
this.isLoading = false
})
}
}
}
@Component
struct ChildFollowComponent {
@ObjectLink data: FollowListDetailItem
build() {
Column(){
Blank().height('27lpx')
Row() {
Image(StringUtils.isEmpty(this.data.headPhotoUrl)?$r('app.media.default_head'):this.data.headPhotoUrl)
.objectFit(ImageFit.Auto)
.width('92lpx')
.height('92lpx')
.margin({right:'15lpx'})
Column(){
Text(this.data.cnUserName)
.fontWeight('400lpx')
.fontSize('31lpx')
.lineHeight('38lpx')
.fontColor($r('app.color.color_222222'))
Text(`粉丝${this.data.cnFansNum}`)
.fontColor($r('app.color.color_B0B0B0'))
.fontSize('23lpx')
.maxLines(1)
Text(`${this.data.introduction}`)
.fontColor($r('app.color.color_B0B0B0'))
.fontSize('23lpx')
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}.layoutWeight(1)
.alignItems(HorizontalAlign.Start)
if(this.data.status == "1"){
Row(){
Text(`已关注`)
.fontColor($r('app.color.color_CCCCCC'))
.fontSize('23lpx')
.fontWeight('500lpx')
.lineHeight('35lpx')
}.backgroundColor($r('app.color.color_F5F5F5'))
.borderRadius('6lpx')
.borderColor($r('app.color.color_F5F5F5'))
.borderWidth('2lpx')
.justifyContent(FlexAlign.Center)
.width('100lpx')
.height('46lpx')
.margin({left:'4lpx',top:'23lpx'})
.onClick(()=>{
this.data.status = "0"
})
}else{
Row(){
Image($r('app.media.follow_icon'))
.margin({right:'4lpx'})
.width('23lpx')
.height('23lpx')
Text(`关注`)
.fontColor($r('app.color.color_ED2800'))
.fontSize('23lpx')
.fontWeight('500lpx')
.lineHeight('35lpx')
}.borderColor($r('app.color.color_1AED2800'))
.borderRadius('6lpx')
.borderWidth('2lpx')
.justifyContent(FlexAlign.Center)
.width('100lpx')
.height('46lpx')
.margin({left:'4lpx',top:'23lpx'})
.onClick(()=>{
this.data.status = "1"
})
}
}.alignItems(VerticalAlign.Top)
.width('100%')
.layoutWeight(1)
Divider().width('100%')
.height('2lpx')
.strokeWidth('1lpx')
.backgroundColor($r('app.color.color_EDEDED'))
}.height('146lpx')
.justifyContent(FlexAlign.Center)
}
}
\ No newline at end of file
... ...
... ... @@ -9,10 +9,10 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter';
@Component
struct EditUserInfoPage {
private listData: EditListInfo[] = []
editM: editModel = new editModel
// editM: editModel
aboutToAppear() {
this.listData = EditInfoViewModel.getEditListInfo(this.editM)
// this.listData = EditInfoViewModel.getEditListInfo(this.editM)
this.getAccountOwnerInfo()
}
... ... @@ -20,7 +20,7 @@ struct EditUserInfoPage {
Row() {
Column() {
CustomTitleUI({titleName:'资料编辑'})
Image(this.editM.userExtend.headPhotoUrl?this.editM.userExtend.headPhotoUrl:'')
Image('')
.backgroundColor(Color.Gray)
.width(100)
.height(100)
... ... @@ -111,7 +111,7 @@ struct EditUserInfoPage {
getAccountOwnerInfo(){
EditInfoViewModel.queryAccountOwnerInfo(1,getContext(this)).then((result) => {
this.editM = result
// this.editM = result
});
}
... ...
... ... @@ -63,7 +63,7 @@ export struct AboutPageUI {
Blank()
Image($r('app.media.app_icon'))
Image($r('app.media.about_us_code'))
.width('192lpx')
.height('192lpx')
... ...
... ... @@ -59,13 +59,12 @@ export struct AccountAndSecurityLayout {
.onClick(() => {
console.log(index + "")
if (index == 0){
let pageType = {'pageType': 2} as Record<string, number>;
WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType)
}else if (index == 1) {
let params: SettingPasswordParams = {
pageID:'1',
}
WDRouterRule.jumpWithPage(WDRouterPage.settingPasswordPage, params)
let pageType = {'pageType': 1} as Record<string, number>;
WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType)
}
})
... ... @@ -83,7 +82,7 @@ export struct AccountAndSecurityLayout {
}.height("100%")
Column() {
Button('退出登录',{ stateEffect: true }).width('90%').height('80lpx').backgroundColor('#da3e22').fontColor('#fff').margin('20lpx').onClick(()=>{
Button('退出登录',{ stateEffect: true ,type: ButtonType.Normal}).width('90%').height('80lpx').backgroundColor('#da3e22').fontColor('#fff').margin('20lpx').borderRadius('8lpx').onClick(()=>{
AlertDialog.show({
title: '🥟id : ' + "button",
message: '标题:' + '退出登录',
... ...
import { CompDTO } from 'wdBean';
import { CommonConstants } from 'wdConstant';
import { CompUtils } from '../../utils/CompUtils';
@Component
export struct HeadPictureCardComponent {
... ... @@ -16,7 +15,6 @@ export struct HeadPictureCardComponent {
Row()
.width(CommonConstants.FULL_WIDTH)
.height(59)
.backgroundColor(Color.Red)
.linearGradient({
colors: [
['rgba(0, 0, 0, 0.0)', 0.0], ['rgba(0, 0, 0, 0.3)', 1.0]
... ...
import { CompDTO, ContentDTO } from 'wdBean';
import { CommonConstants } from 'wdConstant';
import { DateTimeUtils } from 'wdKit';
import { ProcessUtils } from '../../utils/ProcessUtils';
/**
* 本地精选卡
* ZhSingleRow04
*/
@Component
export struct ZhSingleRow04 {
@State compDTO: CompDTO = {} as CompDTO
aboutToAppear() {}
build() {
Column(){
//顶部
Row(){
Row() {
Image($r("app.media.local_selection"))
.width(24)
.height(24)
.margin({ right: 4 })
Text(this.compDTO.objectTitle)
.fontSize($r("app.float.font_size_17"))
.fontColor($r("app.color.color_222222"))
.fontWeight(600)
}
Row() {
Text("更多")
.fontSize($r("app.float.font_size_14"))
.fontColor($r("app.color.color_999999"))
.margin({ right: 1 })
Image($r("app.media.more"))
.width(14)
.height(14)
}
}
.justifyContent(FlexAlign.SpaceBetween)
.margin({ top: 8, bottom: 8 })
.width('100%')
// 列表内容
List({ space: 12 }) {
ForEach(this.compDTO.operDataList, (item: ContentDTO) => {
ListItem() {
Row(){
if(item.coverUrl) {
Image(item.coverUrl)
.width(84)
.height(56)
.borderRadius(3)
.objectFit(ImageFit.Cover)
.padding({right: 6})
}
Column(){
Text(item.newsTitle)
.fontSize($r("app.float.font_size_16"))
.fontColor($r("app.color.color_212228"))
.fontWeight(400)
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。
.margin({ top: 8 })
Row(){
Text(item.source)
.fontSize($r('app.float.font_size_12'))
.fontColor($r('app.color.color_B0B0B0'))
Image($r("app.media.point"))
.width(16)
.height(16)
Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.compDTO.operDataList[0].publishTime)))
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
}
.width('100%')
}
.width(200)
}
// .margin({right: 18})
.onClick(() =>{
ProcessUtils.processPage(item)
})
}
})
}
.listDirection(Axis.Horizontal)
.width('100%')
}
.width(CommonConstants.FULL_WIDTH)
.padding({
top: 14,
left: 16,
right: 16,
bottom: 14
})
.backgroundColor($r("app.color.white"))
.margin({ bottom: 8 })
}
}
\ No newline at end of file
... ...
... ... @@ -11,29 +11,29 @@ export class EditListInfo{
}
}
export class EditInfoModel{
export interface EditInfoModel{
//头像
headPhotoUrl:string = ''
headPhotoUrl:string
//简介
introduction:string = ''
introduction:string
//城市
city:string = ''
city:string
//地区
county:string = ''
county:string
//生日
birthday:string = ''
birthday:string
//性别
sex:string = ''
sex:string
}
export class editModel{
userName:string = ''
export interface editModel{
userName:string
userNameStatus:string = ''
userNameStatus:string
phone:string = ''
phone:string
headPhotoStatus:string = ''
headPhotoStatus:string
userExtend:EditInfoModel
}
\ No newline at end of file
... ...
import router from '@ohos.router'
import { Params } from 'wdBean';
import { StringUtils } from 'wdKit';
import { HomePageBottomComponent } from '../components/mine/home/HomePageBottomComponent';
import { OtherHomePageBottomCommentComponent } from '../components/mine/home/OtherHomePageBottomCommentComponent';
import { OtherHomePageBottomFollowComponent } from '../components/mine/home/OtherHomePageBottomFollowComponent';
import MinePageDatasModel from '../model/MinePageDatasModel';
import { OtherUserDetailRequestItem } from '../viewmodel/OtherUserDetailRequestItem';
... ... @@ -152,10 +153,10 @@ struct OtherNormalUserHomePage {
//tab 页面
Tabs({controller: this.controller}) {
TabContent() {
HomePageBottomComponent({style:0})
OtherHomePageBottomCommentComponent({curUserId:this.curUserId})
}.tabBar(this.TabBuilder(0,"评论"))
TabContent() {
HomePageBottomComponent({style:1})
OtherHomePageBottomFollowComponent()
}.tabBar(this.TabBuilder(1,"关注"))
}
.backgroundColor($r('app.color.white'))
... ...
... ... @@ -29,11 +29,12 @@ class EditInfoViewModel {
getEditListInfo(item:editModel):EditListInfo[]{
this.editListData = [
new EditListInfo('昵称',item&&item.userName?item.userName:'待完善'),
new EditListInfo('简介',item&&item.userExtend.introduction?item.userExtend.introduction:'待完善'),
new EditListInfo('地区',item&&item.userExtend.city?item.userExtend.city:'待完善'),
new EditListInfo('生日',item&&item.userExtend.birthday?item.userExtend.birthday:'待完善'),
new EditListInfo('性别',item&&item.userExtend.sex?item.userExtend.sex:'待完善'),]
// new EditListInfo('昵称',item&&item.userName?item.userName:'待完善'),
// new EditListInfo('简介',item&&item.userExtend.introduction?item.userExtend.introduction:'待完善'),
// new EditListInfo('地区',item&&item.userExtend.city?item.userExtend.city:'待完善'),
// new EditListInfo('生日',item&&item.userExtend.birthday?item.userExtend.birthday:'待完善'),
// new EditListInfo('性别',item&&item.userExtend.sex?item.userExtend.sex:'待完善'),
]
return this.editListData
}
... ... @@ -45,6 +46,7 @@ class EditInfoViewModel {
// let editM = navResDTO.data as EditInfoModel
// success(JSON.parse(navResDTO.data)
}
return this.GetqueryAccountOwnerLocal(context)
}).catch((error: Error) => {
Logger.info('EditInfoViewModel','EditInfoViewModel','EditInfoViewModel')
return this.GetqueryAccountOwnerLocal(context)
... ...
export class OtherUserCommentListRequestItem {
creatorId: string = ""
pageSize: number = 20
pageNum: number = 1
time: string = ""
userType: string = "1"
userId: string = ""
constructor(creatorId: string, pageSize: number,
pageNum: number,
time: string,
userType: string,
userId: string) {
this.creatorId = creatorId
this.pageSize = pageSize
this.pageNum = pageNum
this.time = time
this.userType = userType
this.userId = userId
}
}
\ No newline at end of file
... ...
... ... @@ -6,6 +6,7 @@ import promptAction from '@ohos.promptAction'
import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/Index'
import { WDRouterRule, WDRouterPage } from 'wdRouter';
import { SettingPasswordParams } from './SettingPasswordLayout'
import { Router } from '@ohos.arkui.UIContext'
const TAG = 'ForgetPasswordPage'
... ... @@ -20,23 +21,30 @@ struct ForgetPasswordPage {
@State isSubmit: boolean = false //是否可以提交 默认不可以
loginViewModel: LoginViewModel = new LoginViewModel()
@State @Watch('onCodeSend') isCodeSend: boolean = false //验证码点击发送事件
pageType:number = (router.getParams() as Record<string, number>)['pageType']; //0、登录->忘记密码 1、设置->重置密码 2、设置->更换手机号页面1 3、设置->更换手机号页面2
pageTitle = '找回密码';
onCodeSend() {
if (this.isCodeSend) {
this.sendVerifyCode()
}
}
build() {
Column() {
Image($r('app.media.login_back_icon')).width(24).height(24).margin({ left: 15, top: 10 }).onClick(() => {
router.back()
})
Text('找回密码').fontSize(22).fontColor('#333333').fontWeight(FontWeight.Bold).margin({ left: 25, top: 112 })
Text(this.pageTitle).fontSize(22).fontColor('#333333').fontWeight(FontWeight.Bold).margin({ left: 25, top: 112 })
LoginInputComponent({
phoneContent: $phoneContent,
codeContent: $codeContent,
isSubmit: $isSubmit,
isCodeSend: $isCodeSend
isCodeSend: $isCodeSend,
pageType:this.pageType
})
Row() {
Text("确认")
... ... @@ -60,6 +68,15 @@ struct ForgetPasswordPage {
}
aboutToAppear() {
if (this.pageType == 0){
this.pageTitle = '找回密码'
}else if (this.pageType == 1){
this.pageTitle = '验证当前手机号'
}else if (this.pageType == 2){
this.pageTitle = '验证当前手机号'
}else if (this.pageType == 2){
this.pageTitle = '更换手机号'
}
if (this.isCodeSend) {
this.sendVerifyCode()
}
... ... @@ -95,6 +112,7 @@ struct ForgetPasswordPage {
pageID:'1',
phoneContent:this.phoneContent,
codeContent:this.codeContent,
pageType:this.pageType
}
WDRouterRule.jumpWithPage(WDRouterPage.settingPasswordPage, params)
... ...
... ... @@ -9,32 +9,59 @@ export struct LoginInputComponent {
@Link isCodeSend: boolean //验证码控件是否点击 默认没有 发送接口
@Link isSubmit: boolean //是否可以提交
isFirst:boolean=true//是否第一次获取验证码
pageType?:number; //0、登录->忘记密码 1、设置->重置密码 2、设置->更换手机号页面1 3、设置->更换手机号页面2
build() {
Column() {
this.addCodeLayout()
}.width('100%').padding({ left: 25, right: 25 })
}
aboutToAppear(){
if (this.pageType == 1) {
this.phoneContent = '18655957611';
}
}
@Builder
addCodeLayout() {
TextInput({ placeholder: "请输入手机号" })
.fontSize(16)
.height(48)
.maxLength(11)
.margin({ top: 36 })
.backgroundColor("#F5F5F5")
.borderRadius(4)
.type(InputType.PhoneNumber)
.onChange((content) => {
this.phoneContent = content
this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 6)
if (content.length >= 11) {
this.codeBtnState = true
} else {
this.codeBtnState = false
}
})
if (this.pageType == 1){
TextInput({ placeholder: this.securityPhone('18655957611') })
.fontSize(16)
.height(48)
.maxLength(11)
.margin({ top: 36 })
.backgroundColor("#F5F5F5")
.borderRadius(4)
.enabled(false)
.type(InputType.PhoneNumber)
.onChange((content) => {
this.phoneContent = content
this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 6)
if (content.length >= 11) {
this.codeBtnState = true
} else {
this.codeBtnState = false
}
})
}else{
TextInput({ placeholder: "请输入手机号" })
.fontSize(16)
.height(48)
.maxLength(11)
.margin({ top: 36 })
.backgroundColor("#F5F5F5")
.borderRadius(4)
.type(InputType.PhoneNumber)
.onChange((content) => {
this.phoneContent = content
this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 6)
if (content.length >= 11) {
this.codeBtnState = true
} else {
this.codeBtnState = false
}
})
}
Row() {
TextInput({ placeholder: "验证码" })
... ... @@ -86,4 +113,11 @@ export struct LoginInputComponent {
.backgroundImageSize({width:'100%',height:48})
}
securityPhone(phoneNum:string):string{
let securityNum:string;
let needSecurityString = phoneNum.substring(3, phoneNum.length - 4);
securityNum = phoneNum.replace(needSecurityString,'****')
return securityNum;
}
}
\ No newline at end of file
... ...
import HashMap from '@ohos.util.HashMap';
import { HttpUrlUtils, ResponseDTO } from 'wdNetwork';
import { Logger } from 'wdKit';
import { Logger, SPHelper } from 'wdKit';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
import { LoginBean } from './LoginBean';
import { CheckVerifyBean } from './CheckVerifyBean';
import {
SpConstants
} from '../../../../../../../commons/wdNetwork/oh_modules/wdConstant/src/main/ets/constants/SpConstants'
const TAG = 'LoginModel'
... ... @@ -32,6 +36,29 @@ export class LoginModel {
}
sendVerifyCodeByToken() {
let bean: Record<string, string> = {};
// bean['phoneNum'] = number
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return new Promise<string>((success, fail) => {
HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.getVerifyCodeByTokenUrl(), bean, headers).then((data: ResponseDTO<string>) => {
if (!data || !data.data) {
fail("数据为空")
return
}
if (data.code != 0) {
fail(data.message)
return
}
success(data.data)
}, (error: Error) => {
fail(error.message)
Logger.debug("LoginViewModel:error ", error.toString())
})
})
}
//{"phone":"13625644528","loginType":2,"deviceId":"60da5af6-9c59-3566-8622-8c6c00710994","verificationCode":"644528"}
appLogin(phone: string, loginType: number, verificationCode: string) {
... ... @@ -113,13 +140,68 @@ export class LoginModel {
})
}
//忘记密码 设置新密码
checkVerifyCodeByToken(verifyCode: string) {
let bean: Record<string, Object> = {};
bean['verifyCode'] = verifyCode
// bean['phone'] = phone
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return new Promise<CheckVerifyBean>((success, fail) => {
HttpRequest.post<ResponseDTO<CheckVerifyBean>>(HttpUrlUtils.getCheckVerifyByTokenCodeUrl(), bean, headers).then((data: ResponseDTO<CheckVerifyBean>) => {
Logger.debug("LoginViewModel:success2 ", data.message)
if (!data || !data.data) {
fail("数据为空")
return
}
if (data.code != 0) {
fail(data.message)
return
}
success(data.data)
}, (error: Error) => {
Logger.debug("LoginViewModel:error2 ", error.toString())
fail(error.message)
})
})
}
//修改密码 //需要老密码
resetPassword(password: string, tempToken: string) {
let bean: Record<string, string> = {};
// bean['password'] = password;
// bean['tempToken'] = tempToken;
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return new Promise<string>((success, fail) => {
HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.getForgetPasswordUrl(), bean, headers).then((data: ResponseDTO<string>) => {
if (!data || !data.data) {
fail("数据为空")
return
}
if (data.code != 0) {
fail(data.message)
return
}
success(data.data)
}, (error: Error) => {
fail(error.message)
Logger.debug("LoginViewModel:error ", error.toString())
})
})
}
//忘记密码 //不需要老密码
forgotPassword(password: string, tempToken: string) {
let bean: Record<string, string> = {};
bean['password'] = password;
bean['tempToken'] = tempToken;
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
let JwtToken = SPHelper.default.getSync(SpConstants.USER_JWT_TOKEN, '') as string;
headers.set('JwtToken',(JwtToken));
return new Promise<string>((success, fail) => {
HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.getForgetPasswordUrl(), bean, headers).then((data: ResponseDTO<string>) => {
if (!data || !data.data) {
... ... @@ -137,5 +219,6 @@ export class LoginModel {
})
})
}
}
... ...
... ... @@ -141,7 +141,8 @@ struct LoginPage {
Text('忘记密码').fontColor('#666666').fontSize(14).margin({ top: 16 })
.onClick(() => {
// router.pushUrl({ url: 'pages/login/ForgetPasswordPage' })
WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage)
let pageType = {'pageType': 0} as Record<string, number>;
WDRouterRule.jumpWithPage(WDRouterPage.forgetPasswordPage, pageType)
})
}
... ...
... ... @@ -31,6 +31,17 @@ export class LoginViewModel {
}
sendVerifyCodeByToken() {
return new Promise<string>((success, fail) => {
this.loginModel.sendVerifyCodeByToken().then((data) => {
success(data)
}).catch((message: string) => {
fail(message)
})
})
}
appLogin(phone: string, loginType: number, verificationCode: string) {
return new Promise<LoginBean>((success, fail) => {
... ... @@ -91,8 +102,21 @@ export class LoginViewModel {
})
})
}
checkVerifyCodeByToken(verifyCode: string) {
return new Promise<CheckVerifyBean>((success, reject) => {
this.loginModel.checkVerifyCodeByToken(verifyCode).then((data: CheckVerifyBean) => {
//todo 保存数据
SPHelper.default.save(SpConstants.USER_TEMP_TOKEN, data.temToken)
SPHelper.default.save(SpConstants.USER_JWT_TOKEN, data.jwtToken)
success(data)
//重置密码
}, (value: string) => {
reject(value)
})
})
}
//重置密码 需要老密码
resetPassword(password: string, tempToken: string) {
return new Promise<string>(async (success, fail) => {
let passwordNew = await this.doMd(password)
... ... @@ -105,6 +129,18 @@ export class LoginViewModel {
}
//忘记密码
forgotPassword(password: string, tempToken: string) {
return new Promise<string>(async (success, fail) => {
let passwordNew = await this.doMd(password)
this.loginModel.forgotPassword(passwordNew, tempToken).then((data) => {
success(data)
}).catch((message: string) => {
fail(message)
})
})
}
async doMd(content: string): Promise<string> {
... ...
... ... @@ -8,6 +8,8 @@ import {
SpConstants
} from '../../../../../../../commons/wdNetwork/oh_modules/wdConstant/src/main/ets/constants/SpConstants'
import data_preferences from '@ohos.data.preferences';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
const TAG = "SettingPasswordLayout"
export interface SettingPasswordParams {
... ... @@ -15,6 +17,7 @@ export interface SettingPasswordParams {
phoneContent?: string;
codeContent?: string;
tempToken?:string;
pageType?:number; //0、登录->忘记密码 1、设置->重置密码 2、设置->更换手机号页面1 3、设置->更换手机号页面2
}
export default class AccoutPageDataModel {
... ... @@ -53,6 +56,7 @@ export struct SettingPasswordLayout {
password02: string = '';
passwordOri: string = '';
loginViewModel = new LoginViewModel()
pageType?:number; //0、登录->忘记密码 1、设置->重置密码 2、设置->更换手机
aboutToAppear() {
let params:SettingPasswordParams = router.getParams() as SettingPasswordParams;
... ... @@ -61,6 +65,7 @@ export struct SettingPasswordLayout {
this.phoneContent = params.phoneContent!;
this.codeContent = params.codeContent!;
this.pageType = params.pageType;
}
getPageListData(pageId:number) {
... ... @@ -304,22 +309,30 @@ export struct SettingPasswordLayout {
promptAction.showToast({ message: '密码不符合密码规范' })
return
}
promptAction.showToast({ message: '请求接口' })
}
if(this.pageId == 1){ //设置密码
if (this.password01.length < 6 || this.password01.length > 20) {
promptAction.showToast({ message: '密码不符合密码规范' })
return
}
if (this.password01 != this.password02) {
promptAction.showToast({ message: '密码不一致' })
return
}
if(this.pageId == 1){ //设置密码
SPHelper.default.get(SpConstants.USER_JWT_TOKEN, '').then((str) => {
this.loginViewModel.forgotPassword(this.password01, str.toString()).then((data =>{
if (this.pageType == 0) {//登录页
WDRouterRule.jumpWithPage(WDRouterPage.loginPage);
}else if(this.pageType == 1){//设置
let params: Params = {
pageID: 'AccountAndSecurityLayout'
}
WDRouterRule.jumpWithPage(WDRouterPage.settingPage, params)
}
}))
}).catch((err: Error) => {
Logger.error(TAG, 'catch err:' + JSON.stringify(err));
});
}
// promptAction.showToast({ message: '请求接口' })
}
}
// 输入框数据变动:输入数据处理
... ... @@ -338,15 +351,6 @@ export struct SettingPasswordLayout {
} else {
this.btnStatus = false;
}
SPHelper.default.get(SpConstants.USER_JWT_TOKEN, '').then((str) => {
this.loginViewModel.resetPassword(this.password01, str.toString()).then((data =>{
}))
}).catch((err: Error) => {
Logger.error(TAG, 'catch err:' + JSON.stringify(err));
});
}
}
}
... ...
... ... @@ -36,8 +36,58 @@
],
"requestPermissions": [
{
"name": "ohos.permission.CAMERA",
"reason": "$string:EntryAbility_desc",
"usedScene": {
"abilities": [
"FormAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.READ_MEDIA",
"reason": "$string:EntryAbility_desc",
"usedScene": {
"abilities": [
"FormAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.WRITE_MEDIA",
"reason": "$string:EntryAbility_desc",
"usedScene": {
"abilities": [
"FormAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.LOCATION",
"reason": "$string:EntryAbility_desc",
"usedScene": {
"abilities": [
"FormAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.MICROPHONE",
"reason": "$string:EntryAbility_desc",
"usedScene": {
"abilities": [
"FormAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.INTERNET"
}
]
],
}
}
\ No newline at end of file
... ...