更新记录

3.2(2024-04-24)

组件优化

3.1(2024-01-07)

组件优化

3.0.2(2023-07-29)

组件优化

查看更多

平台兼容性

Vue2 Vue3
App 快应用 微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序
HBuilderX 3.8.0 app-vue app-nvue
钉钉小程序 快手小程序 飞书小程序 京东小程序
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari

cc-beautyPoster

我的技术微信公众号

查看更多前端组件和框架信息,请关注我的技术微信公众号【前端组件开发】

图片

使用方法


<!-- posterData: 海报数据 -->
<cc-beautyPoster :posterData="posterData"></cc-beautyPoster>

<!-- 海报数据字段 注意小程序下网络图片地址需要是服务器设置的白名单地址 本地图片无限制! -->
posterData: {
            // 用户姓名
            name: '小明',
            // 用户头像
            logo: '/static/images/headIcon.jpg',
            // 商品名称
            title: '精美时尚苹果手机一部',
            // 商品价格
            money: '5200.90',
            // 商品图片(小程序需要换成自己服务器白名单设置的地址)
            img: '/static/images/goods.jpg',
            // 商品链接
            url: 'https://www.apple.com.cn/iphone/'

    },          

HTML代码实现部分

<template>
    <view class="content">

        <button style="margin-top: 38px;" @click="openPoster">生成商品海报</button>

        <!-- 海报弹框 -->
        <uni-popup ref="popup" type="center">
            <view class="center_poter" style="margin: 0 auto;" v-if="shows">
                <!-- #ifndef MP -->
                <image class="close_btn" src="/static/images/goods/close.png" @click="hidePoster">
                </image>
                <!-- #endif -->
                <!-- #ifdef MP -->
                <cover-image class="close_btn" src="/static/images/goods/close.png" @click="hidePoster">
                </cover-image>
                <!-- #endif -->

                <!-- posterData: 海报数据 -->
                <cc-beautyPoster :posterData="posterData"></cc-beautyPoster>
            </view>
        </uni-popup>

    </view>

</template>

<script>
    import uniPopup from '@/components/uni-popup/uni-popup.vue'

    export default {
        components: {
            uniPopup
        },
        data() {
            return {
                shows: false,
                posterData: {
                    // 用户姓名
                    name: '小明',
                    // 用户头像
                    logo: '/static/images/headIcon.jpg',
                    // 商品名称
                    title: '精美时尚苹果手机一部',
                    // 商品价格
                    money: '5200.90',
                    // 商品图片(小程序需要换成自己服务器白名单设置的地址)
                    img: '/static/images/goods.jpg',
                    // 商品链接
                    url: 'https://www.apple.com.cn/iphone/'

                },

            }
        },

        methods: {
            //生成海报
            openPoster() {
                this.shows = false
                uni.showLoading({
                    title: '海报绘制中..'
                })
                this.$refs.popup.open()
                setTimeout(() => {
                    uni.hideLoading()
                    this.shows = true
                }, 400)
            },

            //关闭海报
            hidePoster() {
                this.$refs.popup.close()
            },

        }
    }
</script>

<style lang="scss" scoped>
    .content {
        display: flex;
        flex-direction: column;

    }

    .center_poter {
        position: relative;
        z-index: 999;

        .close_btn {
            width: 40upx;
            height: 40upx;
            background-color: rgba($color: #000000, $alpha: .3);
            position: absolute;
            top: 5upx;
            right: 5upx;
            z-index: 500;
            padding: 5upx;
            border-radius: 6upx;
            z-index: 999;
            text-align: center;
        }
    }
</style>

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问