zhaojs
2023-06-12 c28b3b105e5294165ff6b278723df5e0889cb36f
no message
已添加5个文件
已修改6个文件
514 ■■■■■ 文件已修改
uniapp/App.vue 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
uniapp/components/indexPage.vue 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
uniapp/manifest.json 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
uniapp/pages.json 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
uniapp/pages/active/vipsearch.vue 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
uniapp/pages/index/launchPage.vue 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
uniapp/uni_modules/m-start-ad/changelog.md 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
uniapp/uni_modules/m-start-ad/components/m-start-ad/m-start-ad.vue 232 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
uniapp/uni_modules/m-start-ad/package.json 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
uniapp/uni_modules/m-start-ad/readme.md 78 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
uniapp/utils/utils.js 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
uniapp/App.vue
@@ -139,6 +139,7 @@
            ifwt: 0,
            hasinit:false,
            hasbcinit:false,
            isLaunch:false
            
        },
        onShow: function() {
@@ -158,6 +159,7 @@
                        }
                        if(!that.globalData.hasbcinit)
                        {
                            console.log("初始化百川插件")
                            that.bcInit();
                        }
                        /* let appInfo = utils.getCacheSync('appInfo')
@@ -200,13 +202,20 @@
                        }
                    });
                }
                else{
                    that.globalData.hasbcinit=true;
                }
            },
            getAppInfo: function() {
                var that = this;
                that.globalData.hasinit=true;
                this.$u.api.comminInt({}).then(e => {
                    console.log(e)
                    if (e.code != 0) return that.$alert(e.msg)
                    that.globalData.hasinit=true;
                    if (e.code != 0)
                    {
                        that.globalData.hasinit=false;
                        return that.$alert(e.msg)
                    }
                    that.globalData.appinfo = e.data.basic
                    utils.setCache('appInfo', e.data.basic)
                    utils.setCache('baseUrl', this.$u.http.config.baseUrl)
@@ -237,7 +246,7 @@
                        }
                    }
                    // #endif
                }).catch(function(err) {})
                }).catch(function(err) {that.globalData.hasinit=false;})
                
            },
            
uniapp/components/indexPage.vue
@@ -629,8 +629,12 @@
                    console.log(e)
                    if (e.code == 1) return that.$alert(e.msg);
                    var res = e.data.info;
                    this.topBannerList = res.topBannerList;
                    this.headerColor = this.topBannerList[0].colour;
                    if(res.topBannerList&&res.topBannerList.length>0)
                    {
                        this.topBannerList = res.topBannerList;
                        this.headerColor = this.topBannerList[0].colour;
                    }
                    this.singleLineList = res.singleLineList;
                    this.doubleLineList = res.doubleLineList;
                    this.bottomBannerList = res.bottomBannerList;
uniapp/manifest.json
@@ -12,8 +12,8 @@
        "nvueCompiler" : "uni-app",
        "compilerVersion" : 3,
        "splashscreen" : {
            "alwaysShowBeforeRender" : true,
            "waiting" : true,
            "alwaysShowBeforeRender" : false,
            "waiting" : false,
            "autoclose" : true,
            "delay" : 0
        },
@@ -126,7 +126,7 @@
                }
            },
            "splashscreen" : {
                "androidStyle" : "default",
                "androidStyle" : "common",
                "android" : {
                    "hdpi" : "E:/OPProject/发版用_勿删/开屏/开屏小.png",
                    "xhdpi" : "E:/OPProject/图片/开屏/开屏中.png",
uniapp/pages.json
@@ -4,6 +4,9 @@
        "^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
    },
    "pages": [
        {
            "path": "pages/index/launchPage"
        },
        //首页
        {
            "path": "pages/index/index",
uniapp/pages/active/vipsearch.vue
@@ -132,8 +132,16 @@
                    pageSize: 10,
                    page: this.pageCurrent,
                }).then(e => {
                    console.log(e);
                    if(e.code != 0)return that.$alert(e.msg)
                    var res = e.data;
                    if(res.list==null)
                    {
                        that.pageCurrent++
                        that.canloadmore = false
                        that.loadstatus = 'nomarl'
                        return;
                    }
                    if (res.list < 10) {
                        that.pageCurrent++
                        that.canloadmore = false
uniapp/pages/index/launchPage.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,77 @@
<template>
    <view v-if="list&&list.length>0">
         <m-start-ad :list="list" v-on:pgoUrl="goUrl" :time="time" url="/pages/index/index" />
    </view>
</template>
<script>
 import utils from "../../utils/utils.js"
    export default {
        data() {
            return {
                list:[],
                time:5
            };
        },
        onShow: function () {
            var first = getApp().globalData.isLaunch;
            if(first){
                uni.reLaunch({
                    url: "/pages/index/index"
                });
            } else {
                getApp().globalData.isLaunch=true;
                var that = this;
                this.$u.api.getBanner({
                    type: '1,15'
                }).then(e => {
                    console.log(e)
                    if (e.code == 1)
                    {//返回失败,直接跳首页
                        this.t_index();
                        return;
                    }
                    var res = e.data.info;
                    if(res.launchpic&&res.launchpic.length>0)
                    {
                        that.list=res.launchpic;
                    }
                    else{
                        console.log("跳转")
                        this.t_index();
                    }
                }).catch(function(err) {
                    console.log(err);
                    this.t_index();
                })
                }
        },
        methods: {
            goUrl(info) {
                if (info.url_type == 1&&info.parameter_json.url=="/pages/index/index")
                {
                    uni.reLaunch({
                        url: './index'
                    })
                }
                else{
                    utils.goUrl(info, this)
                }
            },
            t_index()
            {
                uni.reLaunch({
                    url: "/pages/index/index"
                });
                /* setTimeout(()=>{
                }, 500); */
            }
        }
    }
</script>
uniapp/uni_modules/m-start-ad/changelog.md
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,4 @@
## 1.0.1(2022-11-11)
修改文档描述
## 1.0.0(2022-11-11)
初次版本发布
uniapp/uni_modules/m-start-ad/components/m-start-ad/m-start-ad.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,232 @@
<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="'background:'+ item.colour +';'" @click="goUrl(item)">
                    <image class="image" :src="item.image" 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
            },
            goUrl(item)
            {
                this.$emit("pgoUrl",item);
            },
            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>
uniapp/uni_modules/m-start-ad/package.json
¶Ô±ÈÐÂÎļþ
@@ -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"
        }
      }
    }
  }
}
uniapp/uni_modules/m-start-ad/readme.md
¶Ô±ÈÐÂÎļþ
@@ -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,需要自定义   |
uniapp/utils/utils.js
@@ -56,7 +56,9 @@
                url: '/pages/webView/webView?url=' + info.parameter_json.url
            })
        } else if (info.url_type == 1) {
            console.log("进来了1·11111111111")
            let url = info.parameter_json.url == undefined ? '' : info.parameter_json.url;
            console.log(url)
            if(url == '') return false;
            uni.navigateTo({
                url: url