diff --git a/dist/btn/index.wxml b/dist/btn/index.wxml index 0a1703cc..13d69d79 100644 --- a/dist/btn/index.wxml +++ b/dist/btn/index.wxml @@ -18,6 +18,7 @@ bindgetuserinfo="bindgetuserinfo" bindgetphonenumber="bindgetphonenumber" binderror="binderror" + bindopensetting="bindopensetting" > diff --git a/dist/btn/native-button-behaviors.js b/dist/btn/native-button-behaviors.js index ebecb56c..3bd240d8 100644 --- a/dist/btn/native-button-behaviors.js +++ b/dist/btn/native-button-behaviors.js @@ -56,11 +56,18 @@ module.exports = Behavior({ this.triggerEvent('getphonenumber', detail); }, - binderror: function binderror() { + bindopensetting: function bindopensetting() { var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, _ref4$detail = _ref4.detail, detail = _ref4$detail === undefined ? {} : _ref4$detail; + this.triggerEvent('opensetting', detail); + }, + binderror: function binderror() { + var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + _ref5$detail = _ref5.detail, + detail = _ref5$detail === undefined ? {} : _ref5$detail; + this.triggerEvent('error', detail); } } diff --git a/dist/cell-group/index.js b/dist/cell-group/index.js index 3514148e..d16bdaad 100644 --- a/dist/cell-group/index.js +++ b/dist/cell-group/index.js @@ -6,6 +6,12 @@ var CELL_PATH = '../cell/index'; var FIELD_PATH = '../field/index'; Component({ + properties: { + titleWidth: { + type: Number, + value: null + } + }, relations: (_relations = {}, _relations[CELL_PATH] = { type: 'child', linked: function linked() { @@ -46,10 +52,14 @@ Component({ var elementUpdateTimeout = setTimeout(function () { _this.setData({ elementUpdateTimeout: 0 }); var elements = _this.getRelationNodes(childPath); + var titleWidth = _this.properties.titleWidth; + + if (elements.length > 0) { var lastIndex = elements.length - 1; elements.forEach(function (cell, index) { + titleWidth && cell.setTitleWidth(titleWidth); cell.updateIsLastElement(index === lastIndex); }); } diff --git a/dist/cell/index.js b/dist/cell/index.js index dab3047f..13ebdf5e 100644 --- a/dist/cell/index.js +++ b/dist/cell/index.js @@ -5,7 +5,7 @@ var warn = function warn(msg, getValue) { }; Component({ - externalClasses: ['cell-class'], + externalClasses: ['cell-class', 'title-class'], options: { multipleSlots: true }, @@ -44,10 +44,12 @@ Component({ url: { type: String, value: '' - } + }, + noBorder: Boolean }, data: { - isLastCell: true + isLastCell: true, + titleWidth: 'auto' }, methods: { footerTap: function footerTap() { @@ -73,6 +75,14 @@ Component({ // 用于被 cell-group 更新,标志是否是最后一个 cell updateIsLastElement: function updateIsLastElement(isLastCell) { this.setData({ isLastCell: isLastCell }); + }, + + + // 设置统一的title区域宽度 + setTitleWidth: function setTitleWidth(titleWidth) { + this.setData({ + titleWidth: titleWidth + 'px' + }); } } }); diff --git a/dist/cell/index.wxml b/dist/cell/index.wxml index dc94e6a6..dd7bc431 100644 --- a/dist/cell/index.wxml +++ b/dist/cell/index.wxml @@ -1,15 +1,18 @@ - + {{ title }} {{ label }} + + + diff --git a/dist/cell/index.wxss b/dist/cell/index.wxss index f3a0dd67..a072fbfa 100644 --- a/dist/cell/index.wxss +++ b/dist/cell/index.wxss @@ -1 +1 @@ -.zan-cell{position:relative;padding:12px 15px;display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;line-height:1.4;background-color:#fff;font-size:14px}.zan-cell::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;-webkit-transform:scale(.5);transform:scale(.5);-webkit-transform-origin:0 0;transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e5e5e5;border-bottom-width:1px;left:15px;right:0}.zan-cell .zan-cell__icon{margin-right:5px}.zan-cell .zan-cell__icon:empty{display:none}.zan-cell__bd{-webkit-box-flex:1;flex:1}.zan-cell__text{line-height:24px;font-size:14px}.zan-cell__desc{line-height:1.2;font-size:12px;color:#666}.zan-cell__ft{position:relative;text-align:right;color:#666}.zan-cell__no-pading{padding:0}.zan-cell__no-pading .zan-cell__bd_padding{padding:12px 0 12px 15px}.zan-cell__no-pading .zan-cell__bd_padding .zan-form__input{height:26px}.zan-cell__no-pading .zan-cell__ft_padding{padding:12px 15px 12px 0}.zan-cell.last-cell::after{display:none}.zan-cell--access .zan-cell__ft{padding-right:13px}.zan-cell--access .zan-cell__ft::after{position:absolute;top:50%;right:2px;content:" ";display:inline-block;height:6px;width:6px;border-width:2px 2px 0 0;border-color:#c8c8c8;border-style:solid;-webkit-transform:translateY(-50%) matrix(.71,.71,-.71,.71,0,0);transform:translateY(-50%) matrix(.71,.71,-.71,.71,0,0)}.zan-cell--switch{padding-top:6px;padding-bottom:6px} \ No newline at end of file +.zan-cell{position:relative;padding:12px 15px;display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;line-height:1.4;background-color:#fff;font-size:14px}.zan-cell::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;-webkit-transform:scale(.5);transform:scale(.5);-webkit-transform-origin:0 0;transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e5e5e5;border-bottom-width:1px;left:15px;right:0}.zan-cell__icon{margin-right:5px}.zan-cell__icon:empty{display:none}.zan-cell__title{min-width:65px;padding-right:10px}.zan-cell__title:empty{display:none}.zan-cell__bd{-webkit-box-flex:1;flex:1}.zan-cell__text{line-height:24px;font-size:14px}.zan-cell__desc{line-height:1.2;font-size:12px;color:#666}.zan-cell__ft{position:relative;text-align:right;color:#666}.zan-cell__no-pading{padding:0}.zan-cell__no-pading .zan-cell__bd_padding{padding:12px 0 12px 15px}.zan-cell__no-pading .zan-cell__bd_padding .zan-form__input{height:26px}.zan-cell__no-pading .zan-cell__ft_padding{padding:12px 15px 12px 0}.zan-cell.last-cell::after,.zan-cell.no-border::after{display:none}.zan-cell--access .zan-cell__ft{padding-right:13px}.zan-cell--access .zan-cell__ft::after{position:absolute;top:50%;right:2px;content:" ";display:inline-block;height:6px;width:6px;border-width:2px 2px 0 0;border-color:#c8c8c8;border-style:solid;-webkit-transform:translateY(-50%) matrix(.71,.71,-.71,.71,0,0);transform:translateY(-50%) matrix(.71,.71,-.71,.71,0,0)}.zan-cell--switch{padding-top:6px;padding-bottom:6px} \ No newline at end of file diff --git a/dist/checkbox/index.wxml b/dist/checkbox/index.wxml index 874c18a6..bba78662 100644 --- a/dist/checkbox/index.wxml +++ b/dist/checkbox/index.wxml @@ -1,25 +1,13 @@ - - -function getColor(color) { - color = color || '#ff4444' - return color; -} - -module.exports = { - getColor: getColor -}; - diff --git a/dist/dialog/data.js b/dist/dialog/data.js index d1fe5342..597b192e 100644 --- a/dist/dialog/data.js +++ b/dist/dialog/data.js @@ -20,5 +20,7 @@ module.exports = { // 取消按钮文案 cancelButtonText: '取消', // 取消按钮颜色 - cancelButtonColor: '#333' + cancelButtonColor: '#333', + // 点击按钮自动关闭 dialog + autoClose: true }; \ No newline at end of file diff --git a/dist/dialog/dialog.js b/dist/dialog/dialog.js index e0ea26c5..a305fa1b 100644 --- a/dist/dialog/dialog.js +++ b/dist/dialog/dialog.js @@ -2,21 +2,37 @@ var defaultData = require('./data'); -// options 使用参数 -// pageCtx 页面 page 上下文 -function Dialog(options, pageCtx) { - var parsedOptions = Object.assign({ - // 自定义 btn 列表 - // { type: 按钮类型,回调时以此作为区分依据,text: 按钮文案, color: 按钮文字颜色 } - buttons: [] - }, defaultData, options); +function getDialogCtx(_ref) { + var selector = _ref.selector, + pageCtx = _ref.pageCtx; var ctx = pageCtx; if (!ctx) { var pages = getCurrentPages(); ctx = pages[pages.length - 1]; } - var dialogCtx = ctx.selectComponent(parsedOptions.selector); + return ctx.selectComponent(selector); +} + +function getParsedOptions() { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + return Object.assign({ + // 自定义 btn 列表 + // { type: 按钮类型,回调时以此作为区分依据,text: 按钮文案, color: 按钮文字颜色 } + buttons: [] + }, defaultData, options); +} + +// options 使用参数 +// pageCtx 页面 page 上下文 +function Dialog(options, pageCtx) { + var parsedOptions = getParsedOptions(options); + + var dialogCtx = getDialogCtx({ + selector: parsedOptions.selector, + pageCtx: pageCtx + }); if (!dialogCtx) { console.error('无法找到对应的dialog组件,请于页面中注册并在 wxml 中声明 dialog 自定义组件'); @@ -60,9 +76,29 @@ function Dialog(options, pageCtx) { showCustomBtns: showCustomBtns, key: '' + new Date().getTime(), show: true, - promiseFunc: { resolve: resolve, reject: reject } + promiseFunc: { resolve: resolve, reject: reject }, + openTypePromiseFunc: null })); }); } +Dialog.close = function (options, pageCtx) { + var parsedOptions = getParsedOptions(options); + + var dialogCtx = getDialogCtx({ + selector: parsedOptions.selector, + pageCtx: pageCtx + }); + + if (!dialogCtx) { + return; + } + + dialogCtx.setData({ + show: false, + promiseFunc: null, + openTypePromiseFunc: null + }); +}; + module.exports = Dialog; \ No newline at end of file diff --git a/dist/dialog/index.js b/dist/dialog/index.js index b4d79852..5514c0e1 100644 --- a/dist/dialog/index.js +++ b/dist/dialog/index.js @@ -1,6 +1,7 @@ 'use strict'; var _f = function _f() {}; +var needResponseOpenTypes = ['getUserInfo', 'getPhoneNumber', 'openSetting']; Component({ properties: {}, @@ -9,7 +10,7 @@ Component({ // 标题 title: '', // 自定义 btn 列表 - // { type: 按钮类型,回调时以此作为区分依据,text: 按钮文案, color: 按钮文字颜色 } + // { type: 按钮类型,回调时以此作为区分依据,text: 按钮文案, color: 按钮文字颜色, openType: 微信开放能力 } buttons: [], // 内容 message: ' ', @@ -30,13 +31,17 @@ Component({ // 取消按钮颜色 cancelButtonColor: '#333', key: '', + autoClose: true, show: false, showCustomBtns: false, - promiseFunc: {} + promiseFunc: {}, + openTypePromiseFunc: {} }, methods: { handleButtonClick: function handleButtonClick(e) { + var _this = this; + var _e$currentTarget = e.currentTarget, currentTarget = _e$currentTarget === undefined ? {} : _e$currentTarget; var _currentTarget$datase = currentTarget.dataset, @@ -53,15 +58,22 @@ Component({ // 重置展示 - this.setData({ - show: false - }); + if (this.data.autoClose) { + this.setData({ show: false }); + } // 自定义按钮,全部 resolve 形式返回,根据 type 区分点击按钮 if (this.data.showCustomBtns) { - resolve({ - type: dataset.type - }); + var isNeedOpenDataButton = needResponseOpenTypes.indexOf(dataset.openType) > -1; + var resolveData = { type: dataset.type }; + // 如果需要 openData,就额外返回一个 promise,用于后续 open 数据返回 + if (isNeedOpenDataButton) { + resolveData.openDataPromise = new Promise(function (resolve, reject) { + _this.setData({ openTypePromiseFunc: { resolve: resolve, reject: reject } }); + }); + resolveData.hasOpenDataPromise = true; + } + resolve(resolveData); return; } @@ -75,6 +87,47 @@ Component({ type: 'cancel' }); } + + this.setData({ promiseFunc: {} }); + }, + + + // 以下为处理微信按钮开放能力的逻辑 + handleUserInfoResponse: function handleUserInfoResponse(_ref2) { + var detail = _ref2.detail; + + this.__handleOpenDataResponse({ + type: detail.errMsg === 'getUserInfo:ok' ? 'resolve' : 'reject', + data: detail + }); + }, + handlePhoneResponse: function handlePhoneResponse(_ref3) { + var detail = _ref3.detail; + + this.__handleOpenDataResponse({ + type: detail.errMsg === 'getPhoneNumber:ok' ? 'resolve' : 'reject', + data: detail + }); + }, + handleOpenSettingResponse: function handleOpenSettingResponse(_ref4) { + var detail = _ref4.detail; + + this.__handleOpenDataResponse({ + type: detail.errMsg === 'openSetting:ok' ? 'resolve' : 'reject', + data: detail + }); + }, + __handleOpenDataResponse: function __handleOpenDataResponse(_ref5) { + var _ref5$type = _ref5.type, + type = _ref5$type === undefined ? 'resolve' : _ref5$type, + _ref5$data = _ref5.data, + data = _ref5$data === undefined ? {} : _ref5$data; + + var promiseFuncs = this.data.openTypePromiseFunc || {}; + var responseFunc = promiseFuncs[type] || _f; + + responseFunc(data); + this.setData({ openTypePromiseFunc: null }); } } }); \ No newline at end of file diff --git a/dist/dialog/index.wxml b/dist/dialog/index.wxml index 8eba385b..5af903db 100644 --- a/dist/dialog/index.wxml +++ b/dist/dialog/index.wxml @@ -23,8 +23,12 @@ class="zan-dialog__button" custom-class="{{ index === 0 ? 'zan-dialog__button-inside--first' : 'zan-dialog__button-inside' }}" data-type="{{ item.type }}" + data-open-type="{{ item.openType }}" open-type="{{ item.openType }}" bind:btnclick="handleButtonClick" + bind:getuserinfo="handleUserInfoResponse" + bind:getphonenumber="handlePhoneResponse" + bind:opensetting="handleOpenSettingResponse" > - - - - - - - + + + + 加载中... - - - - {{ nodata_str || '暂无数据' }} - + + + {{ text }} + + - - - - - 加载中... - - - - + \ No newline at end of file diff --git a/dist/loadmore/index.wxss b/dist/loadmore/index.wxss index 1a7d7f9d..43027485 100644 --- a/dist/loadmore/index.wxss +++ b/dist/loadmore/index.wxss @@ -1 +1 @@ -.zan-loadmore{position:relative;width:65%;margin:21px auto;line-height:20px;font-size:14px;text-align:center;vertical-align:middle}.zan-loading{width:20px;height:20px;display:inline-block;vertical-align:middle;-webkit-animation:weuiLoading 1s steps(12,end) infinite;animation:weuiLoading 1s steps(12,end) infinite;background:transparent url(data:image/svg+xml;base64,PHN2ZyBjbGFzcz0iciIgd2lkdGg9JzEyMHB4JyBoZWlnaHQ9JzEyMHB4JyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj4KICAgIDxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiBmaWxsPSJub25lIiBjbGFzcz0iYmsiPjwvcmVjdD4KICAgIDxyZWN0IHg9JzQ2LjUnIHk9JzQwJyB3aWR0aD0nNycgaGVpZ2h0PScyMCcgcng9JzUnIHJ5PSc1JyBmaWxsPScjRTlFOUU5JwogICAgICAgICAgdHJhbnNmb3JtPSdyb3RhdGUoMCA1MCA1MCkgdHJhbnNsYXRlKDAgLTMwKSc+CiAgICA8L3JlY3Q+CiAgICA8cmVjdCB4PSc0Ni41JyB5PSc0MCcgd2lkdGg9JzcnIGhlaWdodD0nMjAnIHJ4PSc1JyByeT0nNScgZmlsbD0nIzk4OTY5NycKICAgICAgICAgIHRyYW5zZm9ybT0ncm90YXRlKDMwIDUwIDUwKSB0cmFuc2xhdGUoMCAtMzApJz4KICAgICAgICAgICAgICAgICByZXBlYXRDb3VudD0naW5kZWZpbml0ZScvPgogICAgPC9yZW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ZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNDMkMwQzEnCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgyMTAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNDQkNCQ0InCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgyNDAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNEMkQyRDInCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgyNzAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNEQURBREEnCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgzMDAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNFMkUyRTInCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgzMzAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0Pgo8L3N2Zz4=) no-repeat;background-size:100%}.zan-loadmore .zan-loading{margin-right:4px}.zan-loadmore__tips{display:inline-block;vertical-align:middle;height:20px;line-height:20px}.zan-loadmore--nodata,.zan-loadmore--nomore{color:#999}.zan-loadmore--nodata::after,.zan-loadmore--nomore::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;-webkit-transform:scale(.5);transform:scale(.5);-webkit-transform-origin:0 0;transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e5e5e5;border-top-width:1px}.zan-loadmore--nodata{margin-top:120px}.zan-loadmore--nodata .zan-loadmore__tips{position:relative;top:-11px;background:#f9f9f9;padding:0 6px;z-index:1}.zan-loadmore--nomore .zan-loadmore__tips{position:relative;top:-11px;background:#f9f9f9;padding:0 6px;z-index:1}.zan-loadmore__dot{position:absolute;left:50%;top:10px;margin-left:-2px;margin-top:-2px;content:" ";width:4px;height:4px;border-radius:50%;background-color:#e5e5e5;display:inline-block;vertical-align:middle} \ No newline at end of file +.zan-loadmore{display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;-webkit-box-pack:center;justify-content:center;min-height:24px;line-height:24px;font-size:12px}.zan-loadmore__line{-webkit-box-flex:1;flex:1;height:1px;position:relative}.zan-loadmore__line::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;-webkit-transform:scale(.5);transform:scale(.5);-webkit-transform-origin:0 0;transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e5e5e5;border-bottom-width:1px}.zan-loadmore__dot,.zan-loadmore__text{margin:0 5px}.zan-loadmore__dot{content:"";width:4px;height:4px;border-radius:50%;background-color:#e5e5e5;display:inline-block;vertical-align:middle}.zan-loading{width:20px;height:20px;display:inline-block;vertical-align:middle;-webkit-animation:weuiLoading 1s steps(12,end) infinite;animation:weuiLoading 1s steps(12,end) infinite;background:transparent url(data:image/svg+xml;base64,PHN2ZyBjbGFzcz0iciIgd2lkdGg9JzEyMHB4JyBoZWlnaHQ9JzEyMHB4JyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj4KICAgIDxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIi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yBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNEQURBREEnCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgzMDAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNFMkUyRTInCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgzMzAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0Pgo8L3N2Zz4=) no-repeat;background-size:100%}.zan-loadmore__tips{display:inline-block;vertical-align:middle;height:24px;line-height:24px} \ No newline at end of file diff --git a/dist/radio/index.js b/dist/radio/index.js new file mode 100644 index 00000000..c6934df7 --- /dev/null +++ b/dist/radio/index.js @@ -0,0 +1,33 @@ +'use strict'; + +Component({ + behaviors: ['wx://form-field'], + + externalClasses: ['radio-class', 'radio-color'], + + properties: { + items: Array, + type: String + }, + + methods: { + radioChange: function radioChange(e) { + this.selectItem(e.detail.value); + this.triggerEvent('change', e); + }, + selectItem: function selectItem(value) { + var items = this.data.items; + + + items.forEach(function (item) { + if (item.name === value) { + item.checked = true; + } else { + item.checked = false; + } + }); + + this.setData({ items: items }); + } + } +}); \ No newline at end of file diff --git a/dist/radio/index.json b/dist/radio/index.json new file mode 100644 index 00000000..fc0d0bf9 --- /dev/null +++ b/dist/radio/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "zan-icon": "../icon/index" + } +} diff --git a/dist/radio/index.wxml b/dist/radio/index.wxml new file mode 100644 index 00000000..10dbffe5 --- /dev/null +++ b/dist/radio/index.wxml @@ -0,0 +1,28 @@ + + + diff --git a/dist/radio/index.wxss b/dist/radio/index.wxss new file mode 100644 index 00000000..3e9f2722 --- /dev/null +++ b/dist/radio/index.wxss @@ -0,0 +1 @@ +.zan-radio{display:block;padding:0 10px;font-size:14px}.zan-radio__item{display:block;margin-top:10px;height:20px}.zan-radio__item:last-child{margin-bottom:10px}.zan-radio__list-item{display:block;padding:10px 10px 10px 0;border-bottom:1px solid #e5e5e5}.zan-radio__list-item .zan-radio__icon-wrap{float:right;margin-top:3px}.zan-radio__icon-wrap{position:relative;width:14px;height:15px;display:-webkit-inline-box;display:inline-flex;-webkit-box-align:center;align-items:center;color:#aaa}.zan-radio__icon-wrap .zan-radio__origin{opacity:0;width:14px;height:20px}.zan-radio__icon-wrap .zan-radio__icon{position:absolute;left:50%;top:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);border:1px solid #dcdfe6;border-radius:100%;width:14px;height:14px;background-color:#fff;cursor:pointer;box-sizing:border-box}.zan-radio__icon-wrap .zan-radio__icon .zan-radio__icon-inside{position:absolute;left:50%;top:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);width:4px;height:4px;border-radius:50%}.zan-radio__icon-wrap .zan-radio__icon.zan-radio--checked{border-color:#06bf04;background:#06bf04}.zan-radio__icon-wrap .zan-radio__icon.zan-radio--checked .zan-radio__icon-inside{background-color:#fff}.zan-radio__icon-wrap .zan-radio__icon.zan-radio--disabled{opacity:.6}.zan-radio__name{display:inline-block;margin-left:10px} \ No newline at end of file