wangliang_wd

feat:修改bug

1 -import { StringUtils, UserDataLocal } from 'wdKit' 1 +import { SpConstants } from 'wdConstant/Index'
  2 +import { SPHelper, StringUtils, UserDataLocal } from 'wdKit'
2 import { WDRouterPage, WDRouterRule } from 'wdRouter' 3 import { WDRouterPage, WDRouterRule } from 'wdRouter'
3 import { TrackingButton, TrackConstants } from 'wdTracking/Index' 4 import { TrackingButton, TrackConstants } from 'wdTracking/Index'
4 import MinePageDatasModel from '../../model/MinePageDatasModel' 5 import MinePageDatasModel from '../../model/MinePageDatasModel'
@@ -8,7 +9,7 @@ const TAG = "MinePageUserSimpleInfoUI" @@ -8,7 +9,7 @@ const TAG = "MinePageUserSimpleInfoUI"
8 @Component 9 @Component
9 export default struct MinePageUserSimpleInfoUI { 10 export default struct MinePageUserSimpleInfoUI {
10 @Watch('loginStateChange') @Prop isLogin :boolean 11 @Watch('loginStateChange') @Prop isLogin :boolean
11 - @State userName:string = "登注册" 12 + @State userName:string = "登注册"
12 @State headPhotoUrl:string = "" 13 @State headPhotoUrl:string = ""
13 userType:string = "1" 14 userType:string = "1"
14 @State levelHead:string = "" 15 @State levelHead:string = ""
@@ -17,6 +18,10 @@ export default struct MinePageUserSimpleInfoUI { @@ -17,6 +18,10 @@ export default struct MinePageUserSimpleInfoUI {
17 18
18 loginStateChange(){ 19 loginStateChange(){
19 if(this.isLogin){ 20 if(this.isLogin){
  21 + ///已登录状态,先获取本地数据
  22 + this.userName = SPHelper.default.getSync(SpConstants.USER_NAME,"") as string
  23 + this.headPhotoUrl = SPHelper.default.getSync(SpConstants.USER_HEAD_PHOTO_URL,"") as string
  24 +
20 this.getUserInfo() 25 this.getUserInfo()
21 }else{ 26 }else{
22 this.headPhotoUrl = "" 27 this.headPhotoUrl = ""
@@ -57,7 +62,7 @@ export default struct MinePageUserSimpleInfoUI { @@ -57,7 +62,7 @@ export default struct MinePageUserSimpleInfoUI {
57 Text(this.userName) 62 Text(this.userName)
58 .fontColor($r('app.color.color_222222')) 63 .fontColor($r('app.color.color_222222'))
59 .maxLines(1) 64 .maxLines(1)
60 - .fontWeight(FontWeight.Bold) 65 + .fontWeight(FontWeight.Medium)
61 .textOverflow({ overflow: TextOverflow.Ellipsis }) 66 .textOverflow({ overflow: TextOverflow.Ellipsis })
62 .fontSize(`${this.calcHeight(33)}lpx`) 67 .fontSize(`${this.calcHeight(33)}lpx`)
63 .lineHeight(`${this.calcHeight(46)}lpx`) 68 .lineHeight(`${this.calcHeight(46)}lpx`)
@@ -74,18 +79,20 @@ export default struct MinePageUserSimpleInfoUI { @@ -74,18 +79,20 @@ export default struct MinePageUserSimpleInfoUI {
74 trackButtonClick("myPageUserName") 79 trackButtonClick("myPageUserName")
75 }) 80 })
76 81
77 - Stack(){  
78 - Image($r('app.media.mine_grade_bg'))  
79 - .width(`${this.calcHeight(84)}lpx`)  
80 - .height(`${this.calcHeight(29)}lpx`)  
81 - .objectFit(ImageFit.Auto)  
82 - Text(`等级${this.levelId}`)  
83 - .textAlign(TextAlign.Center)  
84 - .fontColor($r('app.color.white'))  
85 - .fontSize(`${this.calcHeight(19)}lpx`)  
86 - .width(this.levelId>9?`${this.calcHeight(69)}lpx`:`${this.calcHeight(50)}lpx`)  
87 - .height(`${this.calcHeight(29)}lpx`)  
88 - }.margin({top:'`${this.calcHeight(15)}lpx`'}) 82 + if (this.levelId !== 0){
  83 + Stack(){
  84 + Image($r('app.media.mine_grade_bg'))
  85 + .width(`${this.calcHeight(84)}lpx`)
  86 + .height(`${this.calcHeight(29)}lpx`)
  87 + .objectFit(ImageFit.Auto)
  88 + Text(`等级${this.levelId}`)
  89 + .textAlign(TextAlign.Center)
  90 + .fontColor($r('app.color.white'))
  91 + .fontSize(`${this.calcHeight(19)}lpx`)
  92 + .width(this.levelId>9?`${this.calcHeight(69)}lpx`:`${this.calcHeight(50)}lpx`)
  93 + .height(`${this.calcHeight(29)}lpx`)
  94 + }.margin({top:'`${this.calcHeight(15)}lpx`'})
  95 + }
89 }.alignItems(HorizontalAlign.Start) 96 }.alignItems(HorizontalAlign.Start)
90 .margin({top:`${this.calcHeight(12)}lpx`,left:`${this.calcHeight(23)}lpx`}) 97 .margin({top:`${this.calcHeight(12)}lpx`,left:`${this.calcHeight(23)}lpx`})
91 .width(`${this.calcHeight(352)}lpx`) 98 .width(`${this.calcHeight(352)}lpx`)
@@ -6,7 +6,7 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter'; @@ -6,7 +6,7 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter';
6 import {AreaPickerDialog} from '../view/areaPickerDialog/AreaPickerDialog' 6 import {AreaPickerDialog} from '../view/areaPickerDialog/AreaPickerDialog'
7 import {EditUserInfoCustomDialog} from '../view/areaPickerDialog/EditUserInfoCustomDialog' 7 import {EditUserInfoCustomDialog} from '../view/areaPickerDialog/EditUserInfoCustomDialog'
8 import {EditUserSexCustomDialog} from '../view/areaPickerDialog/EditUserSexCustomDialog' 8 import {EditUserSexCustomDialog} from '../view/areaPickerDialog/EditUserSexCustomDialog'
9 -import { AreaListModel } from '../../model/AreaListModel'; 9 +import { AreaListManageModel, AreaListModel } from '../../model/AreaListModel';
10 import router from '@ohos.router'; 10 import router from '@ohos.router';
11 import TrackingPageBrowseUtils from '../../utils/TrackingPageBrowseUtils' 11 import TrackingPageBrowseUtils from '../../utils/TrackingPageBrowseUtils'
12 import { TrackConstants } from 'wdTracking/Index'; 12 import { TrackConstants } from 'wdTracking/Index';
@@ -22,8 +22,12 @@ struct EditUserInfoPage { @@ -22,8 +22,12 @@ struct EditUserInfoPage {
22 @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 22 @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
23 @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 23 @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
24 24
  25 + @State firstSelect:number = 0
  26 + @State secondSelect:number = 0
  27 + @State thirdSelect:number = 0
  28 +
25 dialogController: CustomDialogController = new CustomDialogController({ 29 dialogController: CustomDialogController = new CustomDialogController({
26 - builder: AreaPickerDialog({dataSource:this.dataSource, 30 + builder: AreaPickerDialog({dataSource:this.dataSource,firstSelect:this.firstSelect,secondSelect:this.secondSelect,thirdSelect:this.thirdSelect,
27 confirmCallback:(province:string,city:string,county:string,address:string)=>{ 31 confirmCallback:(province:string,city:string,county:string,address:string)=>{
28 this.currentUserInfo.userExtend.province = province; 32 this.currentUserInfo.userExtend.province = province;
29 this.currentUserInfo.userExtend.city = city; 33 this.currentUserInfo.userExtend.city = city;
@@ -31,6 +35,7 @@ struct EditUserInfoPage { @@ -31,6 +35,7 @@ struct EditUserInfoPage {
31 this.currentUserInfo.userExtend.address = address; 35 this.currentUserInfo.userExtend.address = address;
32 this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_region 36 this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_region
33 this.updateEditModel() 37 this.updateEditModel()
  38 + this.getAreaIndex()
34 } 39 }
35 }), 40 }),
36 alignment: DialogAlignment.Bottom, 41 alignment: DialogAlignment.Bottom,
@@ -232,6 +237,30 @@ struct EditUserInfoPage { @@ -232,6 +237,30 @@ struct EditUserInfoPage {
232 getAreaList(){ 237 getAreaList(){
233 EditInfoViewModel.getAreaList(getContext(this)).then((value) =>{ 238 EditInfoViewModel.getAreaList(getContext(this)).then((value) =>{
234 this.dataSource.push(...value) 239 this.dataSource.push(...value)
  240 + this.getAreaIndex()
235 }) 241 })
236 } 242 }
  243 +
  244 + getAreaIndex(){
  245 + ///地区选择器当前位置
  246 + if (this.currentUserInfo.userExtend.province.length > 0) {
  247 + this.dataSource.forEach((element,index) => {
  248 + if (element.label === this.currentUserInfo.userExtend.province) {
  249 + this.firstSelect = index
  250 + let currentFirst = EditInfoViewModel.getAreaListManageModel(element)
  251 + currentFirst.children.forEach((element,index) => {
  252 + if (element.label === this.currentUserInfo.userExtend.city) {
  253 + this.secondSelect = index
  254 + let currentSecondBean = EditInfoViewModel.getAreaListManageModel(element)
  255 + currentSecondBean.children.forEach((element,index) => {
  256 + if (element.label === this.currentUserInfo.userExtend.county) {
  257 + this.thirdSelect = index
  258 + }
  259 + });
  260 + }
  261 + });
  262 + }
  263 + });
  264 + }
  265 + }
237 } 266 }
@@ -202,10 +202,6 @@ export struct TopNavigationComponentNew { @@ -202,10 +202,6 @@ export struct TopNavigationComponentNew {
202 //防止多次点击 202 //防止多次点击
203 if (!this.isClickMorningEveningPaper) { 203 if (!this.isClickMorningEveningPaper) {
204 this.isClickMorningEveningPaper = true; 204 this.isClickMorningEveningPaper = true;
205 - let c = setInterval(() => {  
206 - this.isClickMorningEveningPaper = false  
207 - }, 1000);  
208 -  
209 this.clickMorningEveningPaper() 205 this.clickMorningEveningPaper()
210 } 206 }
211 }) 207 })
@@ -705,11 +701,15 @@ export struct TopNavigationComponentNew { @@ -705,11 +701,15 @@ export struct TopNavigationComponentNew {
705 } else { 701 } else {
706 ToastUtils.showToast('暂无早晚报信息', 1000) 702 ToastUtils.showToast('暂无早晚报信息', 1000)
707 } 703 }
  704 +
  705 + this.isClickMorningEveningPaper = false
708 }).catch((err: string) => { 706 }).catch((err: string) => {
709 ToastUtils.showToast('暂无早晚报信息', 1000) 707 ToastUtils.showToast('暂无早晚报信息', 1000)
  708 + this.isClickMorningEveningPaper = false
710 }) 709 })
711 } else { 710 } else {
712 ToastUtils.showToast('网络出小差了,请检查网络后重试', 1000) 711 ToastUtils.showToast('网络出小差了,请检查网络后重试', 1000)
  712 + this.isClickMorningEveningPaper = false
713 } 713 }
714 } 714 }
715 715
@@ -12,6 +12,11 @@ export struct AreaPickerDialog { @@ -12,6 +12,11 @@ export struct AreaPickerDialog {
12 title: string = '修改地区' 12 title: string = '修改地区'
13 @Provide dataSource: AreaListModel[] = [] 13 @Provide dataSource: AreaListModel[] = []
14 result: JSON[] = []; 14 result: JSON[] = [];
  15 +
  16 + firstSelect:number = 0
  17 + secondSelect:number = 0
  18 + thirdSelect:number = 0
  19 +
15 confirmCallback: (province:string,city:string,county:string,address:string) => void = () => { 20 confirmCallback: (province:string,city:string,county:string,address:string) => void = () => {
16 21
17 } 22 }
@@ -52,9 +57,9 @@ export struct AreaPickerDialog { @@ -52,9 +57,9 @@ export struct AreaPickerDialog {
52 .strokeWidth(1) 57 .strokeWidth(1)
53 58
54 Row(){ 59 Row(){
55 - FirstLevelComponent().width('33%')  
56 - SecondLevelComponent().width('33%')  
57 - ThirdLevelComponent().width('33%') 60 + FirstLevelComponent({select:this.firstSelect}).width('33%')
  61 + SecondLevelComponent({currentSelect:this.secondSelect}).width('33%')
  62 + ThirdLevelComponent({currentSelect:this.thirdSelect}).width('33%')
58 } 63 }
59 } 64 }
60 .backgroundColor(0xffffff) 65 .backgroundColor(0xffffff)
@@ -7,7 +7,7 @@ export struct SecondLevelComponent { @@ -7,7 +7,7 @@ export struct SecondLevelComponent {
7 @State select: number = 0; 7 @State select: number = 0;
8 @Consume @Watch('onFirstChange') currentFirst: AreaListManageModel; 8 @Consume @Watch('onFirstChange') currentFirst: AreaListManageModel;
9 @Consume currentSecondBean: AreaListManageModel 9 @Consume currentSecondBean: AreaListManageModel
10 - 10 + currentSelect:number = 0
11 build() { 11 build() {
12 Column(){ 12 Column(){
13 Column(){ 13 Column(){
@@ -35,7 +35,13 @@ export struct SecondLevelComponent { @@ -35,7 +35,13 @@ export struct SecondLevelComponent {
35 } 35 }
36 36
37 onFirstChange(){ 37 onFirstChange(){
38 - this.select = 0 38 + if (this.currentSelect > 0){
  39 + this.select = this.currentSelect
  40 + this.currentSelect = 0
  41 + }else {
  42 + this.select = 0
  43 + }
  44 +
39 if (!this.currentFirst) { 45 if (!this.currentFirst) {
40 this.mTip = '暂无数据'; 46 this.mTip = '暂无数据';
41 } else { 47 } else {
@@ -8,7 +8,7 @@ export struct ThirdLevelComponent { @@ -8,7 +8,7 @@ export struct ThirdLevelComponent {
8 @Consume @Watch('onFirstChange') currentFirst: AreaListManageModel; 8 @Consume @Watch('onFirstChange') currentFirst: AreaListManageModel;
9 @Consume @Watch('onSecondChange') currentSecondBean: AreaListManageModel; 9 @Consume @Watch('onSecondChange') currentSecondBean: AreaListManageModel;
10 @Consume currentThirdBean: AreaListManageModel 10 @Consume currentThirdBean: AreaListManageModel
11 - 11 + currentSelect:number = 0
12 build() { 12 build() {
13 Column(){ 13 Column(){
14 Column(){ 14 Column(){
@@ -36,11 +36,21 @@ export struct ThirdLevelComponent { @@ -36,11 +36,21 @@ export struct ThirdLevelComponent {
36 } 36 }
37 37
38 onFirstChange(){ 38 onFirstChange(){
39 - this.select = 0 39 + // if (this.currentSelect > 0){
  40 + // this.select = this.currentSelect
  41 + // this.currentSelect = 0
  42 + // }else {
  43 + // this.select = 0
  44 + // }
40 } 45 }
41 46
42 onSecondChange(){ 47 onSecondChange(){
43 - this.select = 0 48 + if (this.currentSelect > 0){
  49 + this.select = this.currentSelect
  50 + this.currentSelect = 0
  51 + }else {
  52 + this.select = 0
  53 + }
44 if (!this.currentSecondBean) { 54 if (!this.currentSecondBean) {
45 this.mTip = '暂无数据'; 55 this.mTip = '暂无数据';
46 } else { 56 } else {
1 1
  2 +export interface AreaListData{
  3 + success: boolean;
  4 + code: number;
  5 + message: string;
  6 + data: AreaListModel[];
  7 + timestamp?: number;
  8 +}
2 9
3 10
4 export interface AreaListModel{ 11 export interface AreaListModel{
@@ -4,7 +4,7 @@ import { @@ -4,7 +4,7 @@ import {
4 EditListInfo, editModel, editModelParams, WDEditDataModelType } from '../model/EditInfoModel'; 4 EditListInfo, editModel, editModelParams, WDEditDataModelType } from '../model/EditInfoModel';
5 import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork'; 5 import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
6 import { Logger, ResourcesUtils } from 'wdKit'; 6 import { Logger, ResourcesUtils } from 'wdKit';
7 -import { AreaListManageModel, AreaListModel } from '../model/AreaListModel'; 7 +import { AreaListManageModel, AreaListModel,AreaListData } from '../model/AreaListModel';
8 import promptAction from '@ohos.promptAction'; 8 import promptAction from '@ohos.promptAction';
9 9
10 const TAG = "EditInfoViewModel" 10 const TAG = "EditInfoViewModel"
@@ -74,17 +74,16 @@ class EditInfoViewModel { @@ -74,17 +74,16 @@ class EditInfoViewModel {
74 74
75 getAreaList(context: Context):PromiseLike<AreaListModel[]>{ 75 getAreaList(context: Context):PromiseLike<AreaListModel[]>{
76 return new Promise((success, error) => { 76 return new Promise((success, error) => {
77 - success(this.getAreaListLocal(context))  
78 - // HttpRequest.post(HttpUrlUtils.APPOINTMENT_AccountOwner_PATH).then((navResDTO:ResponseDTO) =>{  
79 - // if (navResDTO.code == 200) {  
80 - // // let editM = navResDTO.data as EditInfoModel  
81 - // // success(JSON.parse(navResDTO.data)  
82 - // }  
83 - // }).catch((error: Error) => {  
84 - // Logger.info(TAG,'getAreaList','EditInfoViewModel')  
85 - // success(this.getAreaListLocal(context))  
86 - //  
87 - // }) 77 + WDHttp.get<AreaListData>(HttpUrlUtils.getHost() + HttpUrlUtils.APPOINTMENT_userArea_PATH).then((navResDTO: AreaListData) => {
  78 + if (navResDTO.code == 0) {
  79 + success(navResDTO.data)
  80 + }else {
  81 + success(this.getAreaListLocal(context))
  82 + }
  83 + }).catch((error: Error) => {
  84 + Logger.info(TAG,'executeCollcet','ResponseDTO')
  85 + success(this.getAreaListLocal(context))
  86 + })
88 }) 87 })
89 } 88 }
90 89
@@ -246,6 +246,8 @@ export class LoginViewModel { @@ -246,6 +246,8 @@ export class LoginViewModel {
246 } 246 }
247 if(data.userExtend.headPhotoUrl!=undefined){ 247 if(data.userExtend.headPhotoUrl!=undefined){
248 SPHelper.default.saveSync(SpConstants.USER_HEAD_PHOTO_URL, data.userExtend.headPhotoUrl) 248 SPHelper.default.saveSync(SpConstants.USER_HEAD_PHOTO_URL, data.userExtend.headPhotoUrl)
  249 + }else {
  250 + SPHelper.default.deleteSync(SpConstants.USER_HEAD_PHOTO_URL)
249 } 251 }
250 if(data.userExtend.birthday!=undefined){ 252 if(data.userExtend.birthday!=undefined){
251 SPHelper.default.saveSync(SpConstants.USER_BIRTHDAY, data.userExtend.birthday) 253 SPHelper.default.saveSync(SpConstants.USER_BIRTHDAY, data.userExtend.birthday)