首次完整推送,

V:1.20240808.006
This commit is contained in:
fm453
2024-08-13 18:32:37 +08:00
parent 15be3e9373
commit c62d15b288
939 changed files with 111777 additions and 0 deletions

View File

@ -0,0 +1,4 @@
## 1.0.12022-11-11
修改文档描述
## 1.0.02022-11-11
初次版本发布

View File

@ -0,0 +1,228 @@
<template>
<view class="start" v-if="show">
<view class="skip" :style="skipPositionStyle" @click="onSkip">跳过 {{time2}}</view>
<swiper class="swiper" :interval="interval" @change="onChangeSwiper">
<swiper-item v-for="(item, index) in list" :key="index">
<view class="swiper-item" :style="bgStyle">
<image class="image" :src="item" mode="widthFix"></image>
<view class="after" :style="afterStyle"></view>
</view>
</swiper-item>
<!-- autoplay -->
</swiper>
<view class="swiper-dot" v-if="list.length>1">
<view class="view" :style="index === current ? currentStyle : ''" :class="{'active': index === current}"
v-for="(item, index) in list" :key="index" />
</view>
</view>
</template>
<script>
export default {
props: {
list: {
type: Array,
default () {
return []
},
required: true
},
hasTabbar: {
type: Boolean,
default: false,
},
hasNavbar: {
type: Boolean,
default: false,
},
interval: {
type: Number,
default: 3000
},
time: {
type: Number,
default: 3
},
url: {
type: String,
default: ''
},
bgColor: {
type: String,
default: '#BB1219'
},
afterColor: {
type: String,
default: ''
},
currentColor: {
type: String,
default: '#BB1219'
}
},
data() {
return {
current: 0,
show: true,
timer: null,
time2: this.time
}
},
watch: {
time2(val) {
if (val <= 0) {
this.onSkip()
}
}
},
computed: {
bgStyle() {
return this.obj2strStyle({
'background-color': this.bgColor
})
},
afterStyle() {
return this.obj2strStyle({
'background-color': this.afterColor
})
},
currentStyle() {
return this.obj2strStyle({
'background-color': this.currentColor
})
},
skipPositionStyle() {
const {
statusBarHeight
} = uni.getSystemInfoSync()
if (!this.hasNavbar) {
return this.obj2strStyle({
'top': `${statusBarHeight*2 + 88 + 30}rpx`
})
}
return this.obj2strStyle({
'top': '30rpx'
})
}
},
mounted() {
if (this.hasTabbar) {
uni.hideTabBar()
}
this.timer = setInterval(() => {
this.time2--
}, 1000)
},
methods: {
obj2strStyle(obj) {
let style = ''
for (let key in obj) {
style += `${key}:${obj[key]};`
}
return style
},
onSkip() {
const {
url,
hasTabbar,
timer
} = this
clearTimeout(timer)
this.show = false
if (hasTabbar) {
uni.showTabBar()
}
if (url) {
uni.reLaunch({
url: url,
})
}
},
onChangeSwiper(e) {
this.current = e.detail.current
}
}
}
</script>
<style scoped>
/* $nav-height: 44px; */
.start {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 9999;
}
.skip {
position: absolute;
z-index: 2;
background-color: rgba(0, 0, 0, 0.1);
color: #fff;
right: 30rpx;
font-size: 28rpx;
width: 133rpx;
height: 60rpx;
border-radius: 44rpx;
display: flex;
align-items: center;
justify-content: center;
}
.swiper {
height: 100vh;
width: 100vw;
}
.swiper-item {
height: 100vh;
width: 100vw;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
background-color: transparent;
}
.swiper-item .after {
width: 100vw;
height: 500rpx;
position: absolute;
left: 0;
bottom: 0;
z-index: 1;
}
.swiper-item .image {
height: 100vh;
width: 100vw;
display: block;
position: relative;
z-index: 2;
}
.swiper-dot {
position: absolute;
width: 100vw;
left: 0;
bottom: 100rpx;
z-index: 3;
display: flex;
justify-content: center;
}
.swiper-dot .view {
width: 16rpx;
height: 16rpx;
border-radius: 100%;
background-color: rgba(0, 0, 0, 0.2);
margin: 0 12rpx;
}
.swiper-dot .view.active {
width: 30rpx;
border-radius: 24rpx;
}
</style>

View File

@ -0,0 +1,81 @@
{
"id": "m-start-ad",
"displayName": "start-ad开屏广告",
"version": "1.0.1",
"description": "自定义开屏广告",
"keywords": [
"start、开屏、开屏广告"
],
"repository": "",
"engines": {
"HBuilderX": "^3.2.12"
},
"dcloudext": {
"type": "component-vue",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"Vue": {
"vue2": "y",
"vue3": "y"
},
"App": {
"app-vue": "y",
"app-nvue": "y"
},
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "y",
"IE": "y",
"Edge": "y",
"Firefox": "y",
"Safari": "y"
},
"小程序": {
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "y",
"QQ": "y",
"钉钉": "y",
"快手": "y",
"飞书": "y",
"京东": "y"
},
"快应用": {
"华为": "y",
"联盟": "y"
}
}
}
}
}

View File

@ -0,0 +1,78 @@
# m-start-ad
快速制作一个自定义开屏广告,支持轮播
### 属性说明
| 属性名 | 类型 | 默认值 | 必填 | 说明 |
| ------- | ------- | ------- | ------- | ------- |
| list | Array | [] | true | 开屏图片列表 |
| hasTabbar | Boolean | false | false | 页面存在原生tabbar组件会自动判断隐藏tabbar |
| hasNavbar | Boolean | false | false | 页面是否包含navbar |
| interval | Number | 3000 | false | 轮播自动播放时间(多图时可用) |
| time | Number | 3 | false | 倒计时跳过 |
| url | String | '' | false | 时间倒计时结束后跳转地址,如果是tabbar页面可为空 |
| bgColor | String | '#BB1219' | false | 页面的背景颜色, 开屏图片为自动垂直居中,在大屏幕手机下,有些时候高度不够的情况下,会造成上下留白,使用此属性可以填充背景色 |
| afterColor | String | '' | false | 页面底部背景色填充有些时候设置会设计渐变色图片如果只使用bgcolor无法解决需求此时定义此属性可在最下面填充颜色以达到颜色过度效果 |
| currentColor | String | '#BB1219' | false | 定义dot当前状态颜色, list长度大于1可见 |
### 如何做自定义开屏界面
#### 方式一
1、新建一个新页面 pages/start
2、修改pages.js配置文件把start地址放在最前
```
{
"pages": [
{
"path" : "pages/start", //page第一页就是开屏第一个页面
"style" :
{
"navigationBarTitleText": "",
"navigationStyle": "custom" //取消默认导航做到满屏效果
}
}
]
}
```
3、页面引入组件传入list, url
### 使用方式
```
<template>
<m-start-ad :list="list" url="pages/index/index" />
</template>
```
#### 方式二
1、页面关闭原生导航
```
{
"pages": [
{
"path" : "pages/index/index",
"style" :
{
"navigationBarTitleText": "",
"navigationStyle": "custom" //取消默认导航做到满屏效果
}
}
]
}
```
1、页面直接使用
```
<m-start-ad :list="list" />
```
2、倒计时结束后自动隐藏组件无需操作
### 方式对比
|对比 | 优点 | 缺点 |
| ------- | ------- |------- |
| 方式一 | 所有页面都可以公用 | 如果内页需要tabbar,需要自定义 |
| 方式二 | 按需配置 | 无法控制navbar需要自定义 |