yangchenggong1_wd

desc:搜索跳转 和 登录注销处理

@@ -101,4 +101,9 @@ export class SPHelper { @@ -101,4 +101,9 @@ export class SPHelper {
101 // preferences.clearSync() 101 // preferences.clearSync()
102 // preferences.flush() 102 // preferences.flush()
103 // } 103 // }
  104 +
  105 + public getPreferences(){
  106 + let preferences = data_preferences.getPreferences(SPHelper.context, SPHelper.spFilename);
  107 + return preferences;
  108 + }
104 } 109 }
@@ -97,4 +97,6 @@ export class WDRouterPage { @@ -97,4 +97,6 @@ export class WDRouterPage {
97 static broadcastPage = new WDRouterPage("phone", "ets/pages/broadcast/BroadcastPage"); 97 static broadcastPage = new WDRouterPage("phone", "ets/pages/broadcast/BroadcastPage");
98 //搜索主页 98 //搜索主页
99 static searchPage = new WDRouterPage("wdComponent", "ets/pages/SearchPage"); 99 static searchPage = new WDRouterPage("wdComponent", "ets/pages/SearchPage");
  100 + //搜索人民号主页
  101 + static searchCreatorPage = new WDRouterPage("wdComponent", "ets/pages/SearchCreatorPage");
100 } 102 }
1 import { WDRouterRule, WDRouterPage } from 'wdRouter' 1 import { WDRouterRule, WDRouterPage } from 'wdRouter'
2 import MinePagePersonalFunctionsItem from '../../viewmodel/MinePagePersonalFunctionsItem' 2 import MinePagePersonalFunctionsItem from '../../viewmodel/MinePagePersonalFunctionsItem'
3 -import router from '@ohos.router'  
4 3
5 @Component 4 @Component
6 export default struct MinePagePersonFunctionUI { 5 export default struct MinePagePersonFunctionUI {
7 @Link personalData:MinePagePersonalFunctionsItem[] 6 @Link personalData:MinePagePersonalFunctionsItem[]
8 @Prop isLogin:boolean 7 @Prop isLogin:boolean
9 - @Consume('isLogin')@Watch('loginChange') loginState:Record<string,string>  
10 - loginChange(){  
11 - if(this.loginState){  
12 - this.isLogin=true  
13 - }else{  
14 - this.isLogin=false  
15 - }  
16 - }  
17 8
18 build() { 9 build() {
19 Grid(){ 10 Grid(){
1 -import { Logger, UserDataLocal } from 'wdKit' 1 +import { Logger, StringUtils, UserDataLocal } from 'wdKit'
2 import { WDRouterPage, WDRouterRule } from 'wdRouter' 2 import { WDRouterPage, WDRouterRule } from 'wdRouter'
3 import MinePageDatasModel from '../../model/MinePageDatasModel' 3 import MinePageDatasModel from '../../model/MinePageDatasModel'
4 const TAG = "MinePageUserSimpleInfoUI" 4 const TAG = "MinePageUserSimpleInfoUI"
@@ -12,20 +12,13 @@ export default struct MinePageUserSimpleInfoUI { @@ -12,20 +12,13 @@ export default struct MinePageUserSimpleInfoUI {
12 @State levelHead:string = "" 12 @State levelHead:string = ""
13 @State levelId:number = 0 13 @State levelId:number = 0
14 14
15 -  
16 - @Consume('isLogin') @Watch('loginChange') loginState:Record<string,string>  
17 - loginChange(){  
18 - Logger.debug("isLogin",'MinePageUserSimpleInfoUI')  
19 - if(this.loginState){  
20 - this.isLogin=true  
21 - }else {  
22 - this.isLogin=false  
23 - }  
24 - }  
25 loginStateChange(){ 15 loginStateChange(){
26 if(this.isLogin){ 16 if(this.isLogin){
27 this.getUserInfo() 17 this.getUserInfo()
28 this.getUserLevel() 18 this.getUserLevel()
  19 + }else{
  20 + this.headPhotoUrl = ""
  21 + this.levelHead = ""
29 } 22 }
30 } 23 }
31 24
@@ -33,17 +26,20 @@ export default struct MinePageUserSimpleInfoUI { @@ -33,17 +26,20 @@ export default struct MinePageUserSimpleInfoUI {
33 Row(){ 26 Row(){
34 //头像 27 //头像
35 Stack(){ 28 Stack(){
36 - Image(this.headPhotoUrl) 29 + Image(this.headPhotoUrl==""?$r('app.media.default_head'):this.headPhotoUrl)
37 .alt($r('app.media.default_head')) 30 .alt($r('app.media.default_head'))
38 .width('100lpx') 31 .width('100lpx')
39 .height('100lpx') 32 .height('100lpx')
40 .objectFit(ImageFit.Cover) 33 .objectFit(ImageFit.Cover)
41 .borderRadius(50) 34 .borderRadius(50)
  35 +
  36 + if(StringUtils.isNotEmpty(this.levelHead)){
42 Image(this.levelHead) 37 Image(this.levelHead)
43 .width('130lpx') 38 .width('130lpx')
44 .height('130lpx') 39 .height('130lpx')
45 .objectFit(ImageFit.Cover) 40 .objectFit(ImageFit.Cover)
46 .borderRadius(50) 41 .borderRadius(50)
  42 + }
47 }.width('130lpx') 43 }.width('130lpx')
48 .height('130lpx') 44 .height('130lpx')
49 .alignContent(Alignment.Center) 45 .alignContent(Alignment.Center)
@@ -4,11 +4,10 @@ import MinePageMoreFunctionModel from '../../viewmodel/MinePageMoreFunctionModel @@ -4,11 +4,10 @@ import MinePageMoreFunctionModel from '../../viewmodel/MinePageMoreFunctionModel
4 import MinePageDatasModel from '../../model/MinePageDatasModel' 4 import MinePageDatasModel from '../../model/MinePageDatasModel'
5 import MinePageUserSimpleInfoUI from '../mine/MinePageUserSimpleInfoUI' 5 import MinePageUserSimpleInfoUI from '../mine/MinePageUserSimpleInfoUI'
6 import MinePagePersonFunctionUI from '../mine/MinePagePersonFunctionUI' 6 import MinePagePersonFunctionUI from '../mine/MinePagePersonFunctionUI'
7 -import MinePageCardUI from '../mine/MinePageCardUI'  
8 -import MinePageCreatorFunctionUI from '../mine/MinePageCreatorFunctionUI'  
9 import MinePageMoreFunctionUI from '../mine/MinePageMoreFunctionUI' 7 import MinePageMoreFunctionUI from '../mine/MinePageMoreFunctionUI'
10 import { SPHelper, StringUtils } from 'wdKit' 8 import { SPHelper, StringUtils } from 'wdKit'
11 import { SpConstants } from 'wdConstant' 9 import { SpConstants } from 'wdConstant'
  10 +import dataPreferences from '@ohos.data.preferences';
12 11
13 const TAG = 'MinePageComponent'; 12 const TAG = 'MinePageComponent';
14 13
@@ -24,12 +23,29 @@ export struct MinePageComponent { @@ -24,12 +23,29 @@ export struct MinePageComponent {
24 @State creatorData:MinePageCreatorFunctionsItem[] = [] 23 @State creatorData:MinePageCreatorFunctionsItem[] = []
25 @State moreData:MinePageMoreFunctionModel[] = [] 24 @State moreData:MinePageMoreFunctionModel[] = []
26 scroller: Scroller = new Scroller() 25 scroller: Scroller = new Scroller()
  26 + preferences: dataPreferences.Preferences | null = null;
27 27
28 aboutToAppear(){ 28 aboutToAppear(){
29 this.getUserLogin() 29 this.getUserLogin()
30 this.getFunctionData() 30 this.getFunctionData()
  31 + this.addLoginStatusObserver()
31 } 32 }
32 33
  34 + async addLoginStatusObserver(){
  35 + this.preferences = await SPHelper.default.getPreferences();
  36 + let observer = (key: string) => {
  37 + if(key == SpConstants.USER_ID){
  38 + if(StringUtils.isEmpty(SPHelper.default.getSync(SpConstants.USER_ID,""))){
  39 + this.isLogin = false
  40 + }else {
  41 + this.isLogin = true
  42 + }
  43 + }
  44 + }
  45 + this.preferences.on('change', observer);
  46 + }
  47 +
  48 +
33 getFunctionData(){ 49 getFunctionData(){
34 //个人功能数据 50 //个人功能数据
35 this.personalData = MinePageDatasModel.getPersonalFunctionsData() 51 this.personalData = MinePageDatasModel.getPersonalFunctionsData()
@@ -4,6 +4,7 @@ import { ContentDTO, @@ -4,6 +4,7 @@ import { ContentDTO,
4 import { LiveInfoDTO } from 'wdBean/src/main/ets/bean/detail/LiveInfoDTO' 4 import { LiveInfoDTO } from 'wdBean/src/main/ets/bean/detail/LiveInfoDTO'
5 import { VoiceInfoDTO } from 'wdBean/src/main/ets/bean/detail/VoiceInfoDTO' 5 import { VoiceInfoDTO } from 'wdBean/src/main/ets/bean/detail/VoiceInfoDTO'
6 import { LazyDataSource, StringUtils, ToastUtils } from 'wdKit/Index' 6 import { LazyDataSource, StringUtils, ToastUtils } from 'wdKit/Index'
  7 +import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
7 import SearcherAboutDataModel from '../../model/SearcherAboutDataModel' 8 import SearcherAboutDataModel from '../../model/SearcherAboutDataModel'
8 import { CreatorDetailRequestItem } from '../../viewmodel/CreatorDetailRequestItem' 9 import { CreatorDetailRequestItem } from '../../viewmodel/CreatorDetailRequestItem'
9 import { SearchResultContentData } from '../../viewmodel/SearchResultContentData' 10 import { SearchResultContentData } from '../../viewmodel/SearchResultContentData'
@@ -20,9 +21,8 @@ export struct SearchResultContentComponent{ @@ -20,9 +21,8 @@ export struct SearchResultContentComponent{
20 @State searchType:string = "" 21 @State searchType:string = ""
21 @State data: LazyDataSource<ContentDTO> = new LazyDataSource(); 22 @State data: LazyDataSource<ContentDTO> = new LazyDataSource();
22 @State data_rmh: SearchRmhDescription[] = [] 23 @State data_rmh: SearchRmhDescription[] = []
23 - @State count:number = 0; 24 + @State count:number = -1;
24 @State isLoading:boolean = false 25 @State isLoading:boolean = false
25 - @State isLoading2:boolean = false  
26 @State hasMore:boolean = true 26 @State hasMore:boolean = true
27 curPageNum:number = 1; 27 curPageNum:number = 1;
28 28
@@ -80,6 +80,7 @@ export struct SearchResultContentComponent{ @@ -80,6 +80,7 @@ export struct SearchResultContentComponent{
80 }).catch((err:Error)=>{ 80 }).catch((err:Error)=>{
81 console.log(TAG,JSON.stringify(err)) 81 console.log(TAG,JSON.stringify(err))
82 this.isLoading = false 82 this.isLoading = false
  83 + this.count = this.count===-1?0:this.count
83 }) 84 })
84 } 85 }
85 } 86 }
@@ -155,7 +156,7 @@ export struct SearchResultContentComponent{ @@ -155,7 +156,7 @@ export struct SearchResultContentComponent{
155 vImageUrl: "", 156 vImageUrl: "",
156 screenType: "", 157 screenType: "",
157 source: StringUtils.isEmpty(value.data.creatorName) ? value.data.sourceName : value.data.creatorName, 158 source: StringUtils.isEmpty(value.data.creatorName) ? value.data.sourceName : value.data.creatorName,
158 - objectId: "", 159 + objectId: value.data.id,
159 objectType: value.data.type, 160 objectType: value.data.type,
160 channelId: value.data.channelId, 161 channelId: value.data.channelId,
161 relId: value.data.relId, 162 relId: value.data.relId,
@@ -196,6 +197,7 @@ export struct SearchResultContentComponent{ @@ -196,6 +197,7 @@ export struct SearchResultContentComponent{
196 }).catch((err:Error)=>{ 197 }).catch((err:Error)=>{
197 console.log(TAG,"请求失败") 198 console.log(TAG,"请求失败")
198 this.isLoading = false 199 this.isLoading = false
  200 + this.count = this.count===-1?0:this.count
199 }) 201 })
200 } 202 }
201 203
@@ -235,16 +237,24 @@ export struct SearchResultContentComponent{ @@ -235,16 +237,24 @@ export struct SearchResultContentComponent{
235 }) 237 })
236 238
237 ListItem(){ 239 ListItem(){
  240 + Column(){
238 Text("查看更多") 241 Text("查看更多")
  242 + .width('19lpx')
  243 + .fontSize('19lpx')
  244 + .fontWeight('400lpx')
  245 + .lineHeight('27lpx')
  246 + .fontColor($r('app.color.color_9E9E9E'))
  247 + }.borderRadius({topLeft:'4lpx',bottomLeft:'4lpx'})
239 .height('180lpx') 248 .height('180lpx')
240 - .textAlign(TextAlign.Center)  
241 .width('77lpx') 249 .width('77lpx')
242 .backgroundColor($r('app.color.color_EDEDED')) 250 .backgroundColor($r('app.color.color_EDEDED'))
243 - .fontColor($r('app.color.color_9E9E9E'))  
244 - .borderRadius({topLeft:'4lpx',bottomLeft:'4lpx'}) 251 + .justifyContent(FlexAlign.Center)
  252 +
245 }.height('100%') 253 }.height('100%')
246 .margin({left:'23lpx'}) 254 .margin({left:'23lpx'})
247 - 255 + .onClick(()=>{
  256 + WDRouterRule.jumpWithPage(WDRouterPage.searchCreatorPage)
  257 + })
248 } 258 }
249 .cachedCount(6) 259 .cachedCount(6)
250 .edgeEffect(EdgeEffect.Spring) 260 .edgeEffect(EdgeEffect.Spring)
@@ -252,14 +262,6 @@ export struct SearchResultContentComponent{ @@ -252,14 +262,6 @@ export struct SearchResultContentComponent{
252 .listDirection(Axis.Horizontal) 262 .listDirection(Axis.Horizontal)
253 .width('100%') 263 .width('100%')
254 .height('219lpx') 264 .height('219lpx')
255 - .onReachEnd(()=>{  
256 - if(!this.isLoading2){  
257 - this.isLoading2 = true  
258 - //进入更多关注页  
259 - ToastUtils.shortToast("进入更多关注页")  
260 -  
261 - }  
262 - })  
263 265
264 Divider() 266 Divider()
265 .width('100%') 267 .width('100%')
@@ -2,7 +2,6 @@ import router from '@ohos.router' @@ -2,7 +2,6 @@ import router from '@ohos.router'
2 import { Params } from 'wdBean'; 2 import { Params } from 'wdBean';
3 import { StringUtils } from 'wdKit'; 3 import { StringUtils } from 'wdKit';
4 import { WDRouterPage, WDRouterRule } from 'wdRouter'; 4 import { WDRouterPage, WDRouterRule } from 'wdRouter';
5 -import { CardParser } from '../components/CardParser';  
6 import { HomePageBottomComponent } from '../components/mine/home/HomePageBottomComponent'; 5 import { HomePageBottomComponent } from '../components/mine/home/HomePageBottomComponent';
7 import MinePageDatasModel from '../model/MinePageDatasModel'; 6 import MinePageDatasModel from '../model/MinePageDatasModel';
8 7
@@ -183,37 +182,14 @@ struct MineHomePage { @@ -183,37 +182,14 @@ struct MineHomePage {
183 182
184 Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx') 183 Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx')
185 184
186 - Column(){  
187 - Column() {  
188 - // 页签  
189 - Row({ space: 7 }) {  
190 - Scroll() {  
191 - Row() {  
192 - this.TabBuilder(0,"评论")  
193 - this.TabBuilder(1,"关注")  
194 - }  
195 - .justifyContent(FlexAlign.Start)  
196 - }  
197 - .align(Alignment.Start)  
198 - .scrollable(ScrollDirection.Horizontal)  
199 - .scrollBar(BarState.Off)  
200 - .width('90%')  
201 - .padding({left:'31lpx'})  
202 - }  
203 - .alignItems(VerticalAlign.Bottom)  
204 - .width('100%')  
205 - }  
206 - .alignItems(HorizontalAlign.Start)  
207 - .width('100%')  
208 -  
209 //tab 页面 185 //tab 页面
210 Tabs({controller: this.controller}) { 186 Tabs({controller: this.controller}) {
211 TabContent() { 187 TabContent() {
212 HomePageBottomComponent({style:0}) 188 HomePageBottomComponent({style:0})
213 - } 189 + }.tabBar(this.TabBuilder(0,"评论"))
214 TabContent() { 190 TabContent() {
215 HomePageBottomComponent({style:1}) 191 HomePageBottomComponent({style:1})
216 - } 192 + }.tabBar(this.TabBuilder(1,"关注"))
217 } 193 }
218 .backgroundColor($r('app.color.white')) 194 .backgroundColor($r('app.color.white'))
219 .animationDuration(0) 195 .animationDuration(0)
@@ -221,8 +197,6 @@ struct MineHomePage { @@ -221,8 +197,6 @@ struct MineHomePage {
221 this.currentIndex = index 197 this.currentIndex = index
222 }) 198 })
223 .vertical(false) 199 .vertical(false)
224 - .barHeight(0)  
225 - }  
226 }.width("100%") 200 }.width("100%")
227 } 201 }
228 .edgeEffect(EdgeEffect.None) 202 .edgeEffect(EdgeEffect.None)
@@ -232,8 +206,8 @@ struct MineHomePage { @@ -232,8 +206,8 @@ struct MineHomePage {
232 } 206 }
233 }.width('100%') 207 }.width('100%')
234 .layoutWeight(1) 208 .layoutWeight(1)
235 - }  
236 209
  210 + }
237 @Builder MineHomeTitleTransparent() { 211 @Builder MineHomeTitleTransparent() {
238 RelativeContainer() { 212 RelativeContainer() {
239 //标题栏目 213 //标题栏目
@@ -368,9 +342,9 @@ struct MineHomePage { @@ -368,9 +342,9 @@ struct MineHomePage {
368 this.currentIndex = index 342 this.currentIndex = index
369 this.controller.changeIndex(this.currentIndex) 343 this.controller.changeIndex(this.currentIndex)
370 }) 344 })
371 - .height('77lpx')  
372 - .width('70lpx')  
373 - .margin({right:'29lpx'}) 345 + .height('100%')
  346 + .width('100%')
  347 + .margin({right:'9lpx'})
374 } 348 }
375 349
376 /** 350 /**
@@ -172,42 +172,17 @@ struct OtherNormalUserHomePage { @@ -172,42 +172,17 @@ struct OtherNormalUserHomePage {
172 .width('100%') 172 .width('100%')
173 .backgroundColor($r('app.color.white')) 173 .backgroundColor($r('app.color.white'))
174 } 174 }
175 -  
176 //间隔符 175 //间隔符
177 Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx') 176 Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx')
178 177
179 - Column(){  
180 - Column() {  
181 - // 页签  
182 - Row({ space: 7 }) {  
183 - Scroll() {  
184 - Row() {  
185 - this.TabBuilder(0,"评论")  
186 - this.TabBuilder(1,"关注")  
187 - }  
188 - .justifyContent(FlexAlign.Start)  
189 - }  
190 - .align(Alignment.Start)  
191 - .scrollable(ScrollDirection.Horizontal)  
192 - .scrollBar(BarState.Off)  
193 - .width('90%')  
194 - .padding({left:'31lpx'})  
195 - }  
196 - .alignItems(VerticalAlign.Bottom)  
197 - .width('100%')  
198 - }  
199 - .backgroundColor($r('app.color.white'))  
200 - .alignItems(HorizontalAlign.Start)  
201 - .width('100%')  
202 -  
203 //tab 页面 178 //tab 页面
204 Tabs({controller: this.controller}) { 179 Tabs({controller: this.controller}) {
205 TabContent() { 180 TabContent() {
206 OtherHomePageBottomCommentComponent({curUserId:this.curUserId,levelHead:this.levelHead,commentNum:$commentNum}) 181 OtherHomePageBottomCommentComponent({curUserId:this.curUserId,levelHead:this.levelHead,commentNum:$commentNum})
207 - } 182 + }.tabBar(this.TabBuilder(0,"评论"))
208 TabContent() { 183 TabContent() {
209 OtherHomePageBottomFollowComponent({curUserId:this.curUserId}) 184 OtherHomePageBottomFollowComponent({curUserId:this.curUserId})
210 - } 185 + }.tabBar(this.TabBuilder(1,"关注"))
211 } 186 }
212 .backgroundColor($r('app.color.white')) 187 .backgroundColor($r('app.color.white'))
213 .animationDuration(0) 188 .animationDuration(0)
@@ -215,8 +190,6 @@ struct OtherNormalUserHomePage { @@ -215,8 +190,6 @@ struct OtherNormalUserHomePage {
215 this.currentIndex = index 190 this.currentIndex = index
216 }) 191 })
217 .vertical(false) 192 .vertical(false)
218 - .barHeight(0)  
219 - }  
220 }.width("100%") 193 }.width("100%")
221 } 194 }
222 .edgeEffect(EdgeEffect.None) 195 .edgeEffect(EdgeEffect.None)
@@ -327,9 +300,9 @@ struct OtherNormalUserHomePage { @@ -327,9 +300,9 @@ struct OtherNormalUserHomePage {
327 this.currentIndex = index 300 this.currentIndex = index
328 this.controller.changeIndex(this.currentIndex) 301 this.controller.changeIndex(this.currentIndex)
329 }) 302 })
330 - .height('77lpx')  
331 - .width('70lpx')  
332 - .margin({right:'29lpx'}) 303 + .height('100%')
  304 + .width('100%')
  305 + .margin({right:'9lpx'})
333 } 306 }
334 307
335 308
  1 +import { CustomTitleUI } from '../components/reusable/CustomTitleUI';
  2 +
  3 +@Entry
  4 +@Component
  5 +struct SearchCreatorPage {
  6 +
  7 + build() {
  8 + Row() {
  9 + Column() {
  10 + CustomTitleUI({titleName:"全部结果"})
  11 +
  12 + }
  13 + .width('100%')
  14 + }
  15 + .height('100%')
  16 + }
  17 +}
@@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
13 "components/page/BrowsingHistoryPage", 13 "components/page/BrowsingHistoryPage",
14 "components/page/MyCollectionListPage", 14 "components/page/MyCollectionListPage",
15 "pages/OtherNormalUserHomePage", 15 "pages/OtherNormalUserHomePage",
16 - "pages/SearchPage" 16 + "pages/SearchPage",
  17 + "pages/SearchCreatorPage"
17 ] 18 ]
18 } 19 }