一、效果图展示
二、界面讲解
以上是基于ArkTS的鸿蒙应用网吧会员软件的引导页,使用滑动组件滑动页面,至最后一页时,点击立即体验,进入登录页面。
三、代码演示
import promptAction from '@ohos.promptAction';
import router from '@ohos.router';
import MemberInfo from '../entity/MemberInfo';
import MemberInfoTable from '../entity/MemberInfoTable';
import NetBarInfo from '../entity/NetBarInfo';
import NetBarInfoTable from '../entity/NetBarInfoTable';
import WbHyInfoTable from '../entity/WbHyInfoTable';
@Entry
@Component
struct Index {
//创建网吧信息表对象
private NBIT: NetBarInfoTable = new NetBarInfoTable();
//创建会员信息表对象
private mi:MemberInfoTable=new MemberInfoTable();
private wh:WbHyInfoTable=new WbHyInfoTable();
//轮播图片资源
private imgs: Resource[] = [$r("app.media.load_1"),
$r("app.media.load_2"), $r("app.media.load_3")]
//轮播控制器
private sc: SwiperController = new SwiperController();
//在该界面显示之前执行
aboutToAppear() {
//初始化数据库
this.NBIT.getRdbStore(() => {
this.NBIT.query(0, (result) => {
if (String(JSON.stringify(result)) == "[]") {
//添加初始化数据
this.NBIT.initData(()=>{
// promptAction.showToast({message:"数据加载成功"})
})
}
})
this.mi.query(0,(result)=>{
if (String(JSON.stringify(result)) == "[]") {
//添加用户信息
this.mi.initData(()=>{
// promptAction.showToast({message:"会员信息初始化成功"})
})
}
})
this.wh.query(0,0,(result)=>{
if (String(JSON.stringify(result))=="[]") {
this.wh.initData(()=>{
promptAction.showToast({message:"会员记录信息初始化成功"})
})
}
})
})
}
build() {
Row() {
Column() {
Swiper(this.sc) {
ForEach(this.imgs, (img, index) => {
Image(img).width("100%").height("100%")
.onClick(() => {
if (index == this.imgs.length - 1) {
//判断是否已经滑动到最后一页,并触发点击事件,则跳转进入主页
router.replaceUrl({ url: "pages/login" })
}
})
})
}.loop(false) //不允许循环滑动
.autoPlay(true) //允许自动轮播
.interval(2000) //设置延迟滑动时间,单位毫秒
.indicator(false) //设置不显示导航点
}
.width('100%')
}
.height('100%')
}
}