# 小程序公共组件文档 **注意:调用任何组件需要在外部套一个标签,避免意料之外的样式产生。** ## app-radio - 代码 ````html ```` - 属性 - v-model: 开启关闭数据(boolean) ````html ```` - theme: 主题色(字符串,变量)--- 变量需在props中定义 ````html ```` - type: 类型(String)圆形---round, 默认情况方形 ````html ```` ## app-input - 代码 ````html ```` - 属性 - type: 键盘类型(String) ````html 文本输入键盘 数字输入键盘 身份证输入键盘 带小数点的数字键盘 输入框 ```` - disabled :禁用(Boolean) ````html ```` - password: 密码(Boolean) ````html ```` - placeholder: 占位符(String) ````html ```` - autoHeight: 自动高度(Boolean) type = 'textarea' ````html ```` - showConfirmBar: 显示完成按钮(Boolean) type = 'textarea' ````html ```` - placeholderStyle: 占位符文字样式(String) 指定 placeholder 的样式,目前仅支持color,font-size和font-weight type = 'textarea' ````html ```` ## app-form-id - 代码 ```html 按钮 ```` - 属性 - disabled: 禁止点击(boolean) ```html 按钮 按钮 ``` - type: 按钮类型,(字符串)分为三种: 重要-important,一般-general,普通-(不传参) ```html 按钮 ``` - round:圆角按钮,50rpx(boolean)(统一) ```html 按钮 ``` - theme: 主题色,(字符串,变量)--- 变量需在props中定义 ```html 按钮 ``` - height:高度,(字符串)--- 单位为rpx,不需要传 ```html 按钮 ``` - fontSize: 字体大小,不传,默认为32rpx(字符串)--- 单位为rpx,不需要传 ```html 按钮 ``` - width: 宽度,不传默认为100%,(字符串)--- 单位为rpx.不需要传 ```html 按钮 ``` - color:文字颜色(字符串) ```html 按钮 ``` - size: 规定的三种按钮高度,(字符串)分为三种:大---large(100),小---small(60),中---medium(80) ```html 按钮 ``` - background: 背景颜色,不用主题色的情况下使用 ```html 按钮 按钮 ``` ## app-form-id app-button - 两者结合使用 ````html 按钮 ```` ## app-jump-button - 代码 ````html ```` - 属性 - arrangement: 插槽内部排列方式(字符串) column --- 竖排居中对齐,row --- 横排居中对齐 ````html ```` - backgroundColor: 背景颜色 ````html ```` - item: 对象 ``` { open_type: "contact", //(redirect, contact, navigate, tel, web, app...) url: "pages/index/index", //(跳转路径, 可有可无, 与link_url二选一) link_url: "pages/index/index"//(跳转路径, 可有可无, 与link_url二选一) } //redirect: 重定向, //contact: 客服消息回调, //navigate: 跳转, //tel: 电话, //web: 网页, //app: 跳转其他小程序 ``` ## app-report-error - 代码 ```javascript // 服务端报错弹框, 在全局app-layout中使用 //开启: this.$store.dispatch('gConfig/reportAndErrorB', true); //关闭: this.$store.dispatch('gConfig/reportAndErrorB', false); //传递报错信息 //开启: this.$store.dispatch('gConfig/reportAndErrorObj', { boolean: true, content: '网络开了会儿小差, 请刷新重试下哦~'}); //关闭: this.$store.dispatch('gConfig/reportAndErrorObj', { boolean: false, content: '网络开了会儿小差, 请刷新重试下哦~'}); ``` ## app-tab-bar - 代码 ```javascript // 底部导航,放在全局app-layout 中, 再次展现页面时,判断当前页面是否有tabbar // 在每一个可能存在tabbar的页面中 写上 import { mapGetters } from "vuex"; export default { computed: { ...mapGetters('mallConfig',{ tabBarNavs: 'getNavBar', }) }, onShow() { this.$store.dispatch('gConfig/setTabBarBoolean', this.tabBarNavs.navs); } } ``` ## app-loading - 代码 ```html ``` - 属性 - type: loading 类型(字符串) 全局---global,小框--- toast ```html ``` - text: 显示文字 (字符串) ```html ``` - backgroundImage: 背景图片(字符串) ````html ```` ## app-text 主题文字 - 代码 ````html ```` - 属性 - theme: 主题色(字符串,变量)--- 变量需在props中定义 ````html ```` - fontSize: 文字大小 ````html ```` - color: 文字颜色 ````html ```` ## app-map 注:字节跳动小程序不支持 - 代码 ````html ```` ````javascript export default { data() { return { data: { backgroundColor: '#ffffff', backgroundPicUrl: 'http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg', height: 400, latitude: '30.747440', location: '30.747440,120.784830', longitude: '120.784830', marginTop: 20, marginTopColor: "#ffffff", paddingX: 40, paddingY: 40, } } } } ```` ## app-copyright - 代码 ````html ```` ````javascript export default { data() { return { data: { backgroundColor: 'red', link: { data: {}, openType: '', url: '', }, picUrl: 'http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg', text: '凡云科技', } } } } ```` ## app-video - 代码 ````html ```` ````javascript export default { data() { return { scrollTop: 0 } }, onPageScroll: function(e) { this.$nextTick().then(() => { this.scrollTop = e.scrollTop; }); }, } ```` ## app-search-for - 代码 ````html ```` ````javascript export default { data() { return { data: { background: `#968B8B`, color: '#DECACA', placeholder: '搜索', radius: 10, textColor: '#E8E3E3', textPosition: `left`, } } } } ```` ## app-quick-navigation - 代码 ````html ```` ````javascript export default { data() { return { data: { closedPicUrl: 'http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg', customerService: { opened: true, picUrl: 'http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg', }, home: { opened: true, picUrl: 'http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg', }, mApp: { appId: '', opened: false, page: '', picUrl: '', }, mapNav: { address: '南湖', latitude: '30.762457', location: '', longitude: '120.763779', opened: true, picUrl: 'http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg' }, navStyle: 1, navSwitch: 1, openedPicUrl: 'http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg', tel: { number: '1885813481', opened: true, picUrl: 'http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg', }, useMallConfig: false, web: { opened: true, picUrl: 'http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg', url: 'www.baidu.com', }, } } } } ```` ## app-navigation-icon - 代码 ```html ``` ````javascript export default { data() { return { data: { background: "#C42929", color: "#1358EE", columns: 3, navs: [ { icon: "http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg", icon_url: "http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg", link_url: "/pages/index/index", name: "导航13", openType: "navigate", open_type: "navigate", url: "/pages/index/index", }, ], rows: 4, scroll: true, } } } } ```` ## app-announcement - 代码 ````html ```` ````javascript export default { data() { return { data: { background: '#f67f79', btnColor: '#ff4544', btnHeight: 80, btnRadius: 40, btnText: '我知道了', btnTextColor: '#ffffff', btnWidth: 500, content: 'sdfsdfsdfwerr2323232323232323232323232323232323232323232323232323232323232323232323', headerUrl: 'https://www.bangdian.net/plugins/diy/assets/images/icon-notice-title.png', icon: 'http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg', name: '公告', textColor: "#ffffff", } } } } ```` ## app-special-topic-normal - 代码 ````html ```` ````javascript export default { data() { return { data: { cat_show: false, count: 2, icon: "https://www.bangdian.net/web/statics/img/app/topic/icon-topic-r.png", list: [], logo_1: "https://www.bangdian.net/web/statics/img/app/topic/icon-topic-1.png", logo_2: "https://www.bangdian.net/web/statics/img/app/topic/icon-topic-2.png", style: "normal", topic_list: [ { cover_pic: 'http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg', id: 14, layout: 0, read_count: '0人浏览', title: '专题一专题一专题一专题一专题一专题一专题一专题一专题一专题一专题一专题一专题一专题一专题一专题一专题一专题一专题一专题一专题一专题一专题一专题一专题一', } ], } } } } ```` ## app-special-topic-list - 代码 ````html ```` ````javascript export default { data() { return { cat_show: { type: Boolean, default: function() { return false; } }, list: { type: Array, default: function() { return [ { cat_id: '18', cat_name: '123', children: [ ], custom: false, name: '附页', number: 30, }, { cat_id: '18', cat_name: '123', children: [ { cover_pic: 'http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg', id: 14, layout: 0, read_count: '0人浏览', title: '专题一', } ], custom: false, name: '首页', number: 30, } ]; } }, topic_list: { type: Array, default: function() { return [ { cover_pic:'http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg', id: 15, layout:1, read_count: '0人浏览', title: '专题二专题二专题二专题二专题二专题二专题二专题二专题二专题二专题二专题二专题二专题二专题二专题二专题二专题二专题二专题二专题二专题二专题二专题二专题二', } ] } } } } } ```` ## app-tab-nav - 代码 ````html ```` - 属性 - setHeight: 组件高度,不传,默认为90rpx(字符串)--- 单位为rpx,不需要传 - fontSize: 字体大小,不传,默认为28rpx(字符串)--- 单位为rpx,不需要传 - tabList: 数组,需要显示的tab栏,需name和id字段 - activeItem: 当前激活的tab的id - theme: 主题色 - tabStatus: 字体大小,不传,默认为32rpx(字符串)--- 单位为rpx,不需要传 - click: 点击事件,事件名称可自定义 ````javascript export default { data() { return { tabList: [ {id:1, name: '商品'}, {id:2, name: '专题'} ], activeTab: 1, } }, methods: { tabStatus(e) { console.log(e) }, } } ```` ## app-reservation - 代码 ````html ```` ````javascript export default { props: { buttonColor: { type: String, default: function() { return "blue"; } }, buyBtnStyle: { type: Number, default: function() { return 4; } }, buyBtnText: { type: String, default: function() { return "预约"; } }, customizeGoodsTag: { type: Boolean, default: function() { return false; } }, fill: { type: Number, default: function() { return 0; } }, goodsCoverProportion: { type: String, default: function() { return "3-2"; } }, goodsStyle: { type: Number, default: function() { return 3; } }, goodsTagPicUrl: { type: String, default: function() { return "https://shop.9026.com/plugins/diy/assets/images/goods-tag-xp.png"; } }, list: { type: Array, default: function() { return [ { cover_pic: "http://matianxia.oss-cn-qingdao.aliyuncs.com/uploads/20190426/ba493adde2ed99593821c1b5816e6775.png?x-oss-process=style/q90", id: 13, name: "TESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTEST1", page_url: "/plugins/book/goods/goods?goods_id=13", price: "0.00", price_content: "¥0.00", }, { cover_pic: "http://matianxia.oss-cn-qingdao.aliyuncs.com/uploads/20190428/3609e08f1dfa8c9c8449808b93331a36.png?x-oss-process=style/q90", id: 47, name: "预约商品【免费】预约商品【免费】预约商品【免费】预约商品【免费】预约商品【免费】预约商品【免费】预约商品【免费】预约商品【免费】预约商品【免费】预约商品【免费】预约商品【免费】预约商品【免费】预约商品【免费】预约商品【免费】预约商品【免费】预约商品【免费】预约商品【免费】预约商品【免费】", page_url: "/plugins/book/goods/goods?goods_id=47", price: "10.00", price_content: "¥10.00", }, ]; } }, listStyle: { type: Number, default: function() { return 1; } }, showBuyBtn: { type: Boolean, default: function() { return true; } }, showGoodsName: { type: Boolean, default: function() { return false; } }, showGoodsTag: { type: Boolean, default: function() { return false; } }, scrollTop: { type: Number, default: function() { return 0; } }, value: { type: Boolean, default: function() { return true; } } } } ```` ## app-model - 代码 ````html ```` ````javascript export default { data() { return { input: false, } }, methods: { openHidden() { this.input = !this.input; } } } ```` ## app-image-ad - 代码 ````html ```` ``````javascript export default { props: { h: { type: Number, default: function() { return 1; } }, height: { default: function() { return 750; } }, hotspot: { type: Array, default: function() { return []; } }, list: { type: Array, default: function() { return [ ]; } }, space: { type: Number, default: function() { return 0; } }, style: { type: Number, default: function() { return 1; } }, w: { type: Number, default: function() { return 25; } } }, } `````` ## app-diy-form 自定义表单 - 代码 ```vue ``` - 属性 - title: String,表单标题 - list: Object,传入的表单数据,实例值: ``` [ { key: 'text', // 类型(text,textarea,date,time,radio,checkbox,img_upload) name: '姓名', // 名称 default: null, // 默认值 }, { key: 'radio', name: '性别', default: null, list: [ {label: '男', value: false}, {label: '女', value: true}, {label: '隐私', value: false} ], }, { key: 'checkbox', name: '其他', default: null, list: [ {label: '不要辣', value: false}, {label: '不加葱', value: true}, {label: '多加盐', value: true} ], }, { key: 'img_upload', name: '头像', default: null, }, ... ] ``` - sign: Any,自定义传入参数,@input|@validate时将返回 - 事件 - @input: 表单值有更新时触发,返回值: - data: 表单内容,示例: ``` [ { key: 'text', // 类型(text,textarea,date,time,radio,checkbox,img_upload) name: '姓名', // 名称 default: null, // 默认值 value: '张三', // 表单值 }, { key: 'radio', name: '性别', default: null, list: [ {label: '男', value: false}, {label: '女', value: true}, {label: '隐私', value: false} ], value: '女', }, { key: 'checkbox', name: '其他', default: null, list: [ {label: '不要辣', value: false}, {label: '不加葱', value: true}, {label: '多加盐', value: true} ], value: ['不加葱', '多加盐'], }, { key: 'img_upload', name: '头像', default: null, value: 'http://xxx.xxx/abc.jpg', }, ... ] ``` - sign: 自定义传入的值 - @validate: 表单验证返回结果,返回值 - result: 验证结果,示例: ``` { hasError: false, // 表单填写内容是否有错误 errors: [ { index: 0, // 第几个表单 msg: '"姓名不能为空"', // 错误信息 }, ] } ``` - sign: 自定义传入的值