MinePagePersonFunctionUI.ets 2.63 KB
import { WDRouterRule, WDRouterPage } from 'wdRouter'
import MinePagePersonalFunctionsItem from '../../viewmodel/MinePagePersonalFunctionsItem'

@Component
export default struct MinePagePersonFunctionUI {
  @Link personalData:MinePagePersonalFunctionsItem[]
  @Prop isLogin:boolean

  build() {
    Grid(){
      ForEach(this.personalData,(item:MinePagePersonalFunctionsItem,index:number)=>{
        GridItem(){
          Row(){
            Column(){
              Image(item.imgSrc)
                .width('46lpx')
                .height('46lpx')
                .objectFit(ImageFit.Auto)
                .interpolation(ImageInterpolation.High)
              Text(`${item.msg}`)
                .margin({top:'8lpx'})
                .width('50lpx')
                .height('23lpx')
                .fontColor($r('app.color.color_222222'))
                .fontSize('23lpx')
            }
            .alignItems(HorizontalAlign.Center)
            .width('100%')
            Blank()
              .layoutWeight(1)
            if(index % 4 < 3 && index != this.personalData.length-1){
              Text().backgroundColor($r('app.color.color_222222'))
                .opacity(0.1)
                .width('2lpx')
                .height('29lpx')
            }
          }
        }.onClick(()=>{
          console.log(index+"")
          switch (item.msg){
            case "预约":{
              if(!this.isLogin){
                WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
                return
              }
              WDRouterRule.jumpWithPage(WDRouterPage.appointmentListPage)
              break;
            }
            case "关注":{
              if(!this.isLogin){
                WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
                return
              }
              WDRouterRule.jumpWithPage(WDRouterPage.followListPage)
              break;
            }
            case "收藏":{
              if(!this.isLogin){
                WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
                return
              }
              WDRouterRule.jumpWithPage(WDRouterPage.myCollectionListPagePage)
              break;
            }
            case "历史":{
              if(!this.isLogin){
                WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
                return
              }
              WDRouterRule.jumpWithPage(WDRouterPage.browsingHistoryPage)
              break;
            }
          }
        }).width('169lpx')
        .height('117lpx')
      })
    }
    .rowsTemplate('1fr 1fr')
    .columnsTemplate('1fr 1fr 1fr 1fr')
    .height('234lpx')
    .margin({top:'31lpx',left:'23lpx',right:'23lpx' })
  }
}