├── .gitattributes ├── .gitignore ├── README.md ├── app.js ├── app.json ├── app.wxss ├── dist ├── actionsheet │ ├── index.js │ ├── index.wxml │ └── index.wxss ├── badge │ └── index.wxss ├── btn │ └── index.wxss ├── capsule │ ├── index.wxml │ └── index.wxss ├── card │ └── index.wxss ├── cell │ └── index.wxss ├── col │ └── index.wxss ├── color │ └── index.wxss ├── common │ └── helper.js ├── dialog │ ├── index.js │ ├── index.wxml │ └── index.wxss ├── field │ ├── index.js │ ├── index.wxml │ └── index.wxss ├── helper │ └── index.wxss ├── icon │ └── index.wxss ├── index.js ├── index.wxss ├── loadmore │ ├── index.wxml │ └── index.wxss ├── noticebar │ ├── index.js │ ├── index.wxml │ └── index.wxss ├── panel │ └── index.wxss ├── popup │ └── index.wxss ├── row │ └── index.wxss ├── select │ ├── index.js │ ├── index.wxml │ └── index.wxss ├── stepper │ ├── index.js │ ├── index.wxml │ └── index.wxss ├── steps │ ├── index.wxml │ ├── index.wxss │ └── wxss │ │ ├── step.wxss │ │ └── vstep.wxss ├── switch │ ├── index.js │ ├── index.wxml │ └── index.wxss ├── tab │ ├── index.js │ ├── index.wxml │ └── index.wxss ├── tag │ └── index.wxss ├── toast │ ├── index.js │ ├── index.wxml │ └── index.wxss └── toptips │ ├── index.js │ ├── index.wxml │ └── index.wxss ├── img ├── calendar.png ├── express.png ├── index_n.png ├── index_p.png ├── jiantou.png ├── loginme.png ├── more_n.png ├── more_p.png ├── weather.png ├── weather │ ├── 0.png │ ├── 1.png │ ├── 10.png │ ├── 11.png │ ├── 12.png │ ├── 13.png │ ├── 14.png │ ├── 15.png │ ├── 16.png │ ├── 17.png │ ├── 18.png │ ├── 19.png │ ├── 2.png │ ├── 20.png │ ├── 21.png │ ├── 22.png │ ├── 23.png │ ├── 24.png │ ├── 25.png │ ├── 26.png │ ├── 27.png │ ├── 28.png │ ├── 29.png │ ├── 3.png │ ├── 30.png │ ├── 301.png │ ├── 302.png │ ├── 31.png │ ├── 32.png │ ├── 39.png │ ├── 4.png │ ├── 49.png │ ├── 5.png │ ├── 53.png │ ├── 54.png │ ├── 55.png │ ├── 56.png │ ├── 57.png │ ├── 58.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ ├── 9.png │ └── 99.png └── weixinarticle.png ├── pages ├── content │ ├── content.js │ ├── content.json │ ├── content.wxml │ └── content.wxss ├── index │ ├── index.js │ ├── index.json │ ├── index.wxml │ └── index.wxss ├── kdselect │ ├── kdselect.js │ ├── kdselect.json │ ├── kdselect.wxml │ └── kdselect.wxss ├── other │ ├── other.js │ ├── other.json │ ├── other.wxml │ └── other.wxss ├── weather │ ├── weather.js │ ├── weather.json │ ├── weather.wxml │ └── weather.wxss └── wxarticle │ ├── wxarticle.js │ ├── wxarticle.json │ ├── wxarticle.wxml │ └── wxarticle.wxss ├── screen ├── 1.png ├── 2.png ├── 3.png ├── 4.png ├── 5.png ├── 6.png └── 7.png ├── utils ├── bmob.js ├── underscore.js └── util.js └── wxParse ├── emojis ├── 00.gif ├── 01.gif ├── 02.gif ├── 03.gif ├── 04.gif ├── 05.gif ├── 06.gif ├── 07.gif ├── 08.gif ├── 09.gif ├── 10.gif ├── 100.gif ├── 101.gif ├── 102.gif ├── 103.gif ├── 104.gif ├── 105.gif ├── 106.gif ├── 107.gif ├── 108.gif ├── 109.gif ├── 11.gif ├── 110.gif ├── 111.gif ├── 112.gif ├── 113.gif ├── 114.gif ├── 115.gif ├── 116.gif ├── 117.gif ├── 118.gif ├── 119.gif ├── 12.gif ├── 120.gif ├── 121.gif ├── 122.gif ├── 123.gif ├── 124.gif ├── 125.gif ├── 126.gif ├── 127.gif ├── 128.gif ├── 129.gif ├── 13.gif ├── 130.gif ├── 131.gif ├── 132.gif ├── 133.gif ├── 134.gif ├── 14.gif ├── 15.gif ├── 16.gif ├── 17.gif ├── 18.gif ├── 19.gif ├── 20.gif ├── 21.gif ├── 22.gif ├── 23.gif ├── 24.gif ├── 25.gif ├── 26.gif ├── 27.gif ├── 28.gif ├── 29.gif ├── 30.gif ├── 31.gif ├── 32.gif ├── 33.gif ├── 34.gif ├── 35.gif ├── 36.gif ├── 37.gif ├── 38.gif ├── 39.gif ├── 40.gif ├── 41.gif ├── 42.gif ├── 43.gif ├── 44.gif ├── 45.gif ├── 46.gif ├── 47.gif ├── 48.gif ├── 49.gif ├── 50.gif ├── 51.gif ├── 52.gif ├── 53.gif ├── 54.gif ├── 55.gif ├── 56.gif ├── 57.gif ├── 58.gif ├── 59.gif ├── 60.gif ├── 61.gif ├── 62.gif ├── 63.gif ├── 64.gif ├── 65.gif ├── 66.gif ├── 67.gif ├── 68.gif ├── 69.gif ├── 70.gif ├── 71.gif ├── 72.gif ├── 73.gif ├── 74.gif ├── 75.gif ├── 76.gif ├── 77.gif ├── 78.gif ├── 79.gif ├── 80.gif ├── 81.gif ├── 82.gif ├── 83.gif ├── 84.gif ├── 85.gif ├── 86.gif ├── 87.gif ├── 88.gif ├── 89.gif ├── 90.gif ├── 91.gif ├── 92.gif ├── 93.gif ├── 94.gif ├── 95.gif ├── 96.gif ├── 97.gif ├── 98.gif └── 99.gif ├── html2json.js ├── htmlparser.js ├── showdown.js ├── wxDiscode.js ├── wxParse.js ├── wxParse.wxml └── wxParse.wxss /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 微信小程序历史上的今天 2 | 毕业设计项目 3 | 主要功能为历史上的今天 指定日期的历史上今天,历史上的今天的详情、评论; 4 | 其他功能:天气预报、快递查询、微信热门文章 5 | 6 | ## 项目截图: 7 | ### 历史上今天界面 8 | ![历史上今天](https://github.com/best-fan/wechat-app-history/blob/master/screen/1.png) 9 | ### 日期选择 10 | ![日期选择](https://github.com/best-fan/wechat-app-history/blob/master/screen/2.png) 11 | ### 文章详情 12 | ![文章详情](https://github.com/best-fan/wechat-app-history/blob/master/screen/3.png) 13 | ### 天气预报 14 | ![天气预报](https://github.com/best-fan/wechat-app-history/blob/master/screen/4.png) 15 | ### 微信热门文章 16 | ![微信热门文章](https://github.com/best-fan/wechat-app-history/blob/master/screen/5.png) 17 | ### 快递查询 18 | ![快递查询](https://github.com/best-fan/wechat-app-history/blob/master/screen/6.png) 19 | ## 接口来源: 20 | 极速数据: 21 | 全国天气预报 22 | 快递查询 23 | 历史上的今天 24 | 微信文章精选 25 | ## 技术框架: 26 | 有赞UI框架 27 | 微信小程序富文本解析 28 | ## 使用说明: 29 | 替换app.js文件中对应的Bmob.initialize("你的Application ID", "你的REST API Key"); 30 | 替换页面js中appkey(appkey 在极速数据申请) 31 | 32 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | //app.js 2 | 3 | const Bmob = require('utils/bmob.js'); 4 | Bmob.initialize("你的Application ID", "你的REST API Key"); 5 | App({ 6 | onLaunch: function () { 7 | var that=this; 8 | // 登录 9 | wx.login({ 10 | success: res => { 11 | // 发送 res.code 到后台换取 openId, sessionKey, unionId 12 | } 13 | }) 14 | // 获取用户信息 15 | wx.getUserInfo({ 16 | success: function (res) { 17 | var userInfo = res.userInfo 18 | that.globalData.userInfo = userInfo 19 | console.log(userInfo) 20 | } 21 | }) 22 | 23 | }, 24 | globalData: { 25 | userInfo: null, 26 | //历史事件数据 27 | data:'', 28 | //微信文章数据 29 | wxlist:'', 30 | //判断文章类型 0 历史 1 微信 31 | wztype:'', 32 | 33 | } 34 | }) -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages": [ 3 | "pages/index/index", 4 | "pages/other/other", 5 | "pages/content/content", 6 | "pages/weather/weather", 7 | "pages/kdselect/kdselect", 8 | "pages/wxarticle/wxarticle" 9 | ], 10 | "window": { 11 | "backgroundTextStyle": "light", 12 | "navigationBarBackgroundColor": "#fff", 13 | "navigationBarTitleText": "历史上的今天", 14 | "navigationBarTextStyle": "black" 15 | }, 16 | "tabBar": { 17 | "color": "#a9b7b7", 18 | "selectedColor": "#11cd6e", 19 | "borderStyle": "white", 20 | "list": [ 21 | { 22 | "selectedIconPath": "img/index_p.png", 23 | "iconPath": "img/index_n.png", 24 | "pagePath": "pages/index/index", 25 | "text": "首页" 26 | }, 27 | { 28 | "selectedIconPath": "img/more_p.png", 29 | "iconPath": "img/more_n.png", 30 | "pagePath": "pages/other/other", 31 | "text": "更多" 32 | } 33 | ] 34 | } 35 | } -------------------------------------------------------------------------------- /app.wxss: -------------------------------------------------------------------------------- 1 | /**app.wxss**/ 2 | @import "/dist/index.wxss"; -------------------------------------------------------------------------------- /dist/actionsheet/index.js: -------------------------------------------------------------------------------- 1 | const { extractComponentId } = require('../common/helper'); 2 | 3 | module.exports = { 4 | _handleZanActionsheetMaskClick({ currentTarget = {} }) { 5 | const dataset = currentTarget.dataset || {}; 6 | const { componentId, closeOnClickOverlay } = dataset; 7 | 8 | // 判断是否在点击背景时需要关闭弹层 9 | if (!closeOnClickOverlay) { 10 | return; 11 | } 12 | 13 | resolveCancelClick.call(this, { componentId }); 14 | }, 15 | 16 | _handleZanActionsheetCancelBtnClick(e) { 17 | const componentId = extractComponentId(e); 18 | 19 | resolveCancelClick.call(this, { componentId }); 20 | }, 21 | 22 | _handleZanActionsheetBtnClick({ currentTarget = {} }) { 23 | const dataset = currentTarget.dataset || {}; 24 | const { componentId, index } = dataset; 25 | 26 | if (this.handleZanActionsheetClick) { 27 | this.handleZanActionsheetClick({ componentId, index }); 28 | } else { 29 | console.warn('页面缺少 handleZanActionsheetClick 回调函数'); 30 | } 31 | } 32 | }; 33 | 34 | function resolveCancelClick({ componentId }) { 35 | 36 | if (this.handleZanActionsheetCancel) { 37 | this.handleZanActionsheetCancel({ componentId }); 38 | } else { 39 | console.warn('页面缺少 handleZanActionsheetCancel 回调函数'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /dist/actionsheet/index.wxml: -------------------------------------------------------------------------------- 1 | 41 | -------------------------------------------------------------------------------- /dist/actionsheet/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-actionsheet{background-color:#f8f8f8}.zan-actionsheet__mask{position:fixed;top:0;left:0;right:0;bottom:0;z-index:10;background:rgba(0,0,0,.7);display:none}.zan-actionsheet__container{position:fixed;left:0;right:0;bottom:0;background:#f8f8f8;transform:translate3d(0,50%,0);transform-origin:center;transition:all .2s ease;z-index:11;opacity:0;visibility:hidden}.zan-actionsheet__btn.zan-btn{height:50px;line-height:50px;margin-bottom:0}.zan-actionsheet__btn.zan-btn::after{border-width:0;border-bottom-width:1px}.zan-actionsheet__btn.zan-btn:last-child::after{border-bottom-width:0}.zan-actionsheet__subname{margin-left:2px;font-size:12px;color:#666}.zan-actionsheet__footer{margin-top:10px}.zan-actionsheet__btn.zan-btn--loading .zan-actionsheet__subname{color:transparent}.zan-actionsheet--show .zan-actionsheet__container{opacity:1;transform:translate3d(0,0,0);visibility:visible}.zan-actionsheet--show .zan-actionsheet__mask{display:block} -------------------------------------------------------------------------------- /dist/badge/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-badge{position:relative}.zan-badge__count{position:absolute;top:-16px;right:0;height:1.6em;min-width:1.6em;line-height:1.6;padding:0 .4em;font-size:20px;border-radius:.8em;background:#f44;color:#fff;text-align:center;white-space:nowrap;transform:translateX(50%) scale(.5);transform-origin:center;z-index:10;box-shadow:0 0 0 2px #fff;box-sizing:border-box} -------------------------------------------------------------------------------- /dist/btn/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-btn{position:relative;color:#333;background-color:#fff;margin-bottom:10px;padding-left:15px;padding-right:15px;border-radius:2px;font-size:16px;line-height:45px;height:45px;box-sizing:border-box;text-decoration:none;text-align:center;vertical-align:middle}.zan-btn::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e5e5e5;border-width:1px;border-radius:4px}.zan-btns{margin:15px}.zan-btn--primary{color:#fff;background-color:#4b0}.zan-btn--primary::after{border-color:#0a0}.zan-btn--warn{color:#fff;background-color:#f85}.zan-btn--warn::after{border-color:#f85}.zan-btn--danger{color:#fff;background-color:#f44}.zan-btn--danger::after{border-color:#e33}.zan-btn--small{display:inline-block;height:30px;line-height:30px;font-size:12px;margin-right:5px;margin-bottom:0}.zan-btn--mini{display:inline-block;line-height:21px;height:22px;font-size:10px;margin-right:5px;margin-bottom:0;padding-left:5px;padding-right:5px}.zan-btn--large{border-radius:0;margin-bottom:0;border:none;line-height:50px;height:50px}.zan-btn--plain.zan-btn{background-color:transparent}.zan-btn--plain.zan-btn--primary{color:#06bf04}.zan-btn--plain.zan-btn--warn{color:#f60}.zan-btn--plain.zan-btn--danger{color:#f44}.button-hover{opacity:.9}.zan-btn--loading{color:transparent;opacity:1}.zan-btn--loading::before{position:absolute;left:50%;top:50%;content:' ';width:16px;height:16px;margin-left:-8px;margin-top:-8px;border:3px solid #e5e5e5;border-color:#666 #e5e5e5 #e5e5e5 #e5e5e5;border-radius:8px;box-sizing:border-box;animation:btn-spin .6s linear;animation-iteration-count:infinite}.zan-btn--danger.zan-btn--loading::before,.zan-btn--primary.zan-btn--loading::before,.zan-btn--warn.zan-btn--loading::before{border-color:#fff rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.1)}@keyframes btn-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}.zan-btn.zan-btn--disabled{color:#999!important;background:#f8f8f8!important;border-color:#e5e5e5!important;cursor:not-allowed!important;opacity:1!important}.zan-btn.zan-btn--disabled::after{border-color:#e5e5e5!important}.zan-btn--last-child,.zan-btn:last-child{margin-bottom:0;margin-right:0} -------------------------------------------------------------------------------- /dist/capsule/index.wxml: -------------------------------------------------------------------------------- 1 | 19 | -------------------------------------------------------------------------------- /dist/capsule/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-capsule{display:inline-block;font-size:12px;vertical-align:middle;line-height:19px;transform:scale(.83)}.zan-capsule__left,.zan-capsule__right{display:inline-block;line-height:17px;height:19px;vertical-align:middle;box-sizing:border-box}.zan-capsule__left{padding:0 2px;color:#fff;background:#999;border-radius:2px 0 0 2px;border:1rpx solid #999}.zan-capsule__right{padding:0 5px;color:#999;border-radius:0 2px 2px 0;border:1rpx solid #999}.zan-capsule--danger .zan-capsule__left{color:#fff;background:#f24544;border-color:#f24544}.zan-capsule--danger .zan-capsule__right{color:#f24544;border-color:#f24544} -------------------------------------------------------------------------------- /dist/card/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-card{margin-left:0;width:auto;padding:5px 15px;overflow:hidden;position:relative;font-size:14px}.zan-card__thumb{width:90px;height:90px;float:left;position:relative;margin-left:auto;margin-right:auto;overflow:hidden;background-size:cover}.zan-card__img{position:absolute;top:0;left:0;right:0;bottom:0;width:auto;height:auto;max-width:100%;max-height:100%}.zan-card__detail{margin-left:100px;width:auto;position:relative}.zan-card__detail-row{overflow:hidden;line-height:20px;min-height:20px;margin-bottom:3px}.zan-card__right-col{float:right}.zan-card__left-col{margin-right:80px} -------------------------------------------------------------------------------- /dist/cell/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-cell{position:relative;padding:12px 15px;display:flex;align-items:center;line-height:1.4;font-size:14px}.zan-cell::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);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__bd{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-child::after,.zan-cell:last-child::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;transform:translateY(-50%) matrix(.71,.71,-.71,.71,0,0)}.zan-cell--switch{padding-top:6px;padding-bottom:6px} -------------------------------------------------------------------------------- /dist/col/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-col{float:left;box-sizing:border-box;width:0}.zan-col-1{width:4.16667%}.zan-col-offset-1{margin-left:4.16667%}.zan-col-2{width:8.33333%}.zan-col-offset-2{margin-left:8.33333%}.zan-col-3{width:12.5%}.zan-col-offset-3{margin-left:12.5%}.zan-col-4{width:16.66667%}.zan-col-offset-4{margin-left:16.66667%}.zan-col-5{width:20.83333%}.zan-col-offset-5{margin-left:20.83333%}.zan-col-6{width:25%}.zan-col-offset-6{margin-left:25%}.zan-col-7{width:29.16667%}.zan-col-offset-7{margin-left:29.16667%}.zan-col-8{width:33.33333%}.zan-col-offset-8{margin-left:33.33333%}.zan-col-9{width:37.5%}.zan-col-offset-9{margin-left:37.5%}.zan-col-10{width:41.66667%}.zan-col-offset-10{margin-left:41.66667%}.zan-col-11{width:45.83333%}.zan-col-offset-11{margin-left:45.83333%}.zan-col-12{width:50%}.zan-col-offset-12{margin-left:50%}.zan-col-13{width:54.16667%}.zan-col-offset-13{margin-left:54.16667%}.zan-col-14{width:58.33333%}.zan-col-offset-14{margin-left:58.33333%}.zan-col-15{width:62.5%}.zan-col-offset-15{margin-left:62.5%}.zan-col-16{width:66.66667%}.zan-col-offset-16{margin-left:66.66667%}.zan-col-17{width:70.83333%}.zan-col-offset-17{margin-left:70.83333%}.zan-col-18{width:75%}.zan-col-offset-18{margin-left:75%}.zan-col-19{width:79.16667%}.zan-col-offset-19{margin-left:79.16667%}.zan-col-20{width:83.33333%}.zan-col-offset-20{margin-left:83.33333%}.zan-col-21{width:87.5%}.zan-col-offset-21{margin-left:87.5%}.zan-col-22{width:91.66667%}.zan-col-offset-22{margin-left:91.66667%}.zan-col-23{width:95.83333%}.zan-col-offset-23{margin-left:95.83333%}.zan-col-24{width:100%}.zan-col-offset-24{margin-left:100%} -------------------------------------------------------------------------------- /dist/color/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-c-red{color:#f44!important}.zan-c-gray{color:#c9c9c9!important}.zan-c-gray-dark{color:#999!important}.zan-c-gray-darker{color:#666!important}.zan-c-black{color:#333!important}.zan-c-blue{color:#38f!important}.zan-c-green{color:#06bf04!important} -------------------------------------------------------------------------------- /dist/common/helper.js: -------------------------------------------------------------------------------- 1 | // 从事件对象中解析得到 componentId 2 | // 需要在元素上声明 data-component-id 3 | function extractComponentId(event = {}) { 4 | const { dataset: { componentId } } = event.currentTarget || {}; 5 | return componentId; 6 | } 7 | 8 | /* 9 | 注:默认合并所有生命周期函数 10 | 配置合并指定的生命周期 or 忽略指定字段 11 | const extend = extendCreator({ 12 | life: ['onLoad', 'onPullDownRefresh'], 13 | exclude: ['binder'] 14 | }); 15 | 16 | Page(extend({}, { 17 | onLoad() {}, 18 | ... 19 | })); 20 | */ 21 | 22 | const LIFE_CYCLE = ['onLoad', 'onReady', 'onShow', 'onHide', 'onUnload', 'onPullDownRefresh', 'onReachBottom', 'onShareAppMessage', 'onPageScroll']; 23 | 24 | const extendCreator = (config = {}) => { 25 | const { 26 | life = LIFE_CYCLE, 27 | exclude = [] 28 | } = config; 29 | 30 | const excludeList = exclude.concat(LIFE_CYCLE.map(getFuncArrayName)); 31 | 32 | if (!Array.isArray(life) || !Array.isArray(exclude)) throw new Error('Invalid Extend Config'); 33 | let lifeCycleList = life.filter(item => LIFE_CYCLE.indexOf(item) >= 0); 34 | return function extend(target, ...objList) { 35 | objList.forEach((source) => { 36 | if (source) { 37 | let keys = Object.keys(source); 38 | keys.forEach((key) => { 39 | let value = source[key]; 40 | if (excludeList.indexOf(key) >= 0) return; 41 | if (lifeCycleList.indexOf(key) >= 0 && typeof value === 'function') { 42 | let funcArrayName = getFuncArrayName(key); 43 | if (!target[funcArrayName]) { 44 | target[funcArrayName] = []; 45 | if (target[key]) { 46 | target[funcArrayName].push(target[key]); 47 | } 48 | target[key] = function (...rest) { 49 | target[funcArrayName].forEach(func => func.apply(this, rest)); 50 | }; 51 | } 52 | 53 | if (source[funcArrayName]) { 54 | // 经过生命周期合并的组件直接整合函数列表 55 | target[funcArrayName].push(...source[funcArrayName]); 56 | } else { 57 | // 添加生命周期函数进入函数列表 58 | target[funcArrayName].push(value); 59 | } 60 | } else { 61 | target[key] = value; 62 | } 63 | }); 64 | } 65 | }); 66 | return target; 67 | }; 68 | }; 69 | 70 | const getFuncArrayName = name => `__$${name}`; 71 | 72 | module.exports = { 73 | extractComponentId, 74 | extend: Object.assign, 75 | extendCreator 76 | }; 77 | -------------------------------------------------------------------------------- /dist/dialog/index.js: -------------------------------------------------------------------------------- 1 | const _f = function () {}; 2 | 3 | module.exports = { 4 | showZanDialog(options = {}) { 5 | const { 6 | // 自定义 btn 列表 7 | // { type: 按钮类型,回调时以此作为区分依据,text: 按钮文案, color: 按钮文字颜色 } 8 | buttons = [], 9 | // 标题 10 | title = '', 11 | // 内容 12 | content = ' ', 13 | // 按钮是否展示为纵向 14 | buttonsShowVertical = false, 15 | // 是否展示确定 16 | showConfirm = true, 17 | // 确认按钮文案 18 | confirmText = '确定', 19 | // 确认按钮颜色 20 | confirmColor = '#3CC51F', 21 | // 是否展示取消 22 | showCancel = false, 23 | // 取消按钮文案 24 | cancelText = '取消', 25 | // 取消按钮颜色 26 | cancelColor = '#333' 27 | } = options; 28 | 29 | // 处理默认按钮的展示 30 | // 纵向排布确认按钮在上方 31 | let showCustomBtns = false; 32 | if (buttons.length === 0) { 33 | if (showConfirm) { 34 | buttons.push({ 35 | type: 'confirm', 36 | text: confirmText, 37 | color: confirmColor 38 | }); 39 | } 40 | 41 | if (showCancel) { 42 | const cancelButton = { 43 | type: 'cancel', 44 | text: cancelText, 45 | color: cancelColor 46 | }; 47 | if (buttonsShowVertical) { 48 | buttons.push(cancelButton); 49 | } else { 50 | buttons.unshift(cancelButton); 51 | } 52 | } 53 | } else { 54 | showCustomBtns = true; 55 | } 56 | 57 | return new Promise((resolve, reject) => { 58 | this.setData({ 59 | zanDialog: { 60 | show: true, 61 | showCustomBtns, 62 | buttons, 63 | title, 64 | content, 65 | buttonsShowVertical, 66 | showConfirm, 67 | confirmText, 68 | confirmColor, 69 | showCancel, 70 | cancelText, 71 | cancelColor, 72 | // 回调钩子 73 | resolve, 74 | reject 75 | } 76 | }); 77 | }); 78 | }, 79 | 80 | _handleZanDialogButtonClick(e) { 81 | const { currentTarget = {} } = e; 82 | const { dataset = {} } = currentTarget; 83 | 84 | // 获取当次弹出框的信息 85 | const zanDialogData = this.data.zanDialog || {}; 86 | const { resolve = _f, reject = _f } = zanDialogData; 87 | 88 | // 重置 zanDialog 里的内容 89 | this.setData({ 90 | zanDialog: { show: false } 91 | }); 92 | 93 | // 自定义按钮,全部 resolve 形式返回,根据 type 区分点击按钮 94 | if (zanDialogData.showCustomBtns) { 95 | resolve({ 96 | type: dataset.type 97 | }); 98 | return; 99 | } 100 | 101 | // 默认按钮,确认为 resolve,取消为 reject 102 | if (dataset.type === 'confirm') { 103 | resolve({ 104 | type: 'confirm' 105 | }); 106 | } else { 107 | reject({ 108 | type: 'cancel' 109 | }); 110 | } 111 | } 112 | }; 113 | -------------------------------------------------------------------------------- /dist/dialog/index.wxml: -------------------------------------------------------------------------------- 1 | 23 | -------------------------------------------------------------------------------- /dist/dialog/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-dialog--container{position:fixed;top:45%;left:50%;width:80%;height:0;font-size:16px;overflow:hidden;transition:all .2s linear;border-radius:4px;background-color:#fff;transform:translate3d(-50%,-50%,0);color:#333;opacity:0}.zan-dialog--mask{position:fixed;width:100%;height:100%;top:0;left:0;background-color:rgba(0,0,0,.6);transition:.3s;display:none}.zan-dialog__header{padding:15px 0 0;text-align:center}.zan-dialog__content{position:relative;padding:15px 20px;line-height:1.5;min-height:40px}.zan-dialog__content::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e5e5e5;border-bottom-width:1px}.zan-dialog__content--title{color:#999;font-size:14px}.zan-dialog__footer{overflow:hidden}.zan-dialog__button{line-height:50px;height:50px;padding:0 5px;border-radius:0;margin-bottom:0}.zan-dialog__button::after{border-width:0;border-radius:0}.zan-dialog--show .zan-dialog--container{opacity:1;height:auto}.zan-dialog--show .zan-dialog--mask{display:block}.zan-dialog__footer--horizon{display:flex}.zan-dialog__footer--horizon .zan-dialog__button{flex:1}.zan-dialog__footer--horizon .zan-dialog__button::after{border-right-width:1px}.zan-dialog__footer--horizon .zan-dialog__button:last-child::after{border-right-width:0}.zan-dialog__footer--vertical .zan-dialog__button{flex:1}.zan-dialog__footer--vertical .zan-dialog__button::after{border-bottom-width:1px}.zan-dialog__footer--vertical .zan-dialog__button:last-child::after{border-bottom-width:0} -------------------------------------------------------------------------------- /dist/field/index.js: -------------------------------------------------------------------------------- 1 | const { extractComponentId } = require('../common/helper'); 2 | 3 | module.exports = { 4 | _handleZanFieldChange(event) { 5 | const componentId = extractComponentId(event); 6 | event.componentId = componentId; 7 | 8 | 9 | 10 | if (this.handleZanFieldChange) { 11 | return this.handleZanFieldChange(event); 12 | } 13 | 14 | console.warn('页面缺少 handleZanFieldChange 回调函数'); 15 | }, 16 | 17 | _handleZanFieldFocus(event) { 18 | const componentId = extractComponentId(event); 19 | event.componentId = componentId; 20 | 21 | 22 | 23 | if (this.handleZanFieldFocus) { 24 | return this.handleZanFieldFocus(event); 25 | } 26 | }, 27 | 28 | _handleZanFieldBlur(event) { 29 | const componentId = extractComponentId(event); 30 | event.componentId = componentId; 31 | 32 | 33 | 34 | if (this.handleZanFieldBlur) { 35 | return this.handleZanFieldBlur(event); 36 | } 37 | } 38 | }; 39 | -------------------------------------------------------------------------------- /dist/field/index.wxml: -------------------------------------------------------------------------------- 1 | 34 | -------------------------------------------------------------------------------- /dist/field/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-cell{position:relative;padding:12px 15px;display:flex;align-items:center;line-height:1.4;font-size:14px}.zan-cell::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);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__bd{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-child::after,.zan-cell:last-child::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;transform:translateY(-50%) matrix(.71,.71,-.71,.71,0,0)}.zan-cell--switch{padding-top:6px;padding-bottom:6px}.zan-field{padding:7px 15px;color:#333}.zan-field--wrapped{margin:0 15px;background-color:#fff}.zan-field--wrapped::after{left:0;border-width:1px;border-radius:4px}.zan-field.zan-field--wrapped::after{display:block}.zan-field--wrapped+.zan-field--wrapped{margin-top:10px}.zan-field--error{color:#f40}.zan-field--wrapped.zan-field--error::after{border-color:#f40}.zan-field__title{color:#333;min-width:65px;padding-right:10px}.zan-field__input{flex:1;line-height:1.6;padding:4px 0;min-height:22px;height:auto;font-size:14px}.zan-field__placeholder{font-size:14px}.zan-field__input--right{text-align:right} -------------------------------------------------------------------------------- /dist/helper/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-pull-left{float:left}.zan-pull-right{float:right}.zan-center{text-align:center}.zan-right{text-align:right}.zan-text-deleted{text-decoration:line-through}.zan-font-8{font-size:8px}.zan-font-10{font-size:10px}.zan-font-12{font-size:12px}.zan-font-14{font-size:14px}.zan-font-16{font-size:16px}.zan-font-18{font-size:18px}.zan-font-20{font-size:20px}.zan-font-22{font-size:22px}.zan-font-24{font-size:22px}.zan-font-30{font-size:30px}.zan-font-bold{font-weight:700}.zan-arrow{position:absolute;right:15px;top:50%;display:inline-block;height:6px;width:6px;border-width:2px 2px 0 0;border-color:#c8c8c8;border-style:solid;transform:translateY(-50%) matrix(.71,.71,-.71,.71,0,0)}.zan-ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;word-wrap:normal}.zan-ellipsis--l2{max-height:40px;line-height:20px;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}.zan-ellipsis--l3{max-height:60px;line-height:20px;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical}.zan-clearfix{zoom:1}.zan-clearfix::after{content:'';display:table;clear:both}.zan-hairline,.zan-hairline--bottom,.zan-hairline--left,.zan-hairline--right,.zan-hairline--surround,.zan-hairline--top,.zan-hairline--top-bottom{position:relative}.zan-hairline--bottom::after,.zan-hairline--left::after,.zan-hairline--right::after,.zan-hairline--surround::after,.zan-hairline--top-bottom::after,.zan-hairline--top::after,.zan-hairline::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e5e5e5}.zan-hairline--top::after{border-top-width:1px}.zan-hairline--left::after{border-left-width:1px}.zan-hairline--right::after{border-right-width:1px}.zan-hairline--bottom::after{border-bottom-width:1px}.zan-hairline--top-bottom::after{border-width:1px 0}.zan-hairline--surround::after{border-width:1px} -------------------------------------------------------------------------------- /dist/icon/index.wxss: -------------------------------------------------------------------------------- 1 | @font-face{font-family:zanui-weapp-icon;src:url(https://b.yzcdn.cn/zanui-weapp/zanui-weapp-icon-4381aded05.eot);src:url(https://b.yzcdn.cn/zanui-weapp/zanui-weapp-icon-4381aded05.eot?#iefix) format('embedded-opentype'),url(https://b.yzcdn.cn/zanui-weapp/zanui-weapp-icon-4381aded05.woff2) format('woff2'),url(https://b.yzcdn.cn/zanui-weapp/zanui-weapp-icon-4381aded05.woff) format('woff'),url(https://b.yzcdn.cn/zanui-weapp/zanui-weapp-icon-4381aded05.ttf) format('truetype')}.zan-icon{display:inline-block}.zan-icon::before{font-family:zanui-weapp-icon!important;font-style:normal;font-weight:400;speak:none;display:inline-block;text-decoration:inherit;width:1em;text-align:center;font-variant:normal;text-transform:none;line-height:1em;-webkit-font-smoothing:antialiased}.zan-icon-qr-invalid:before{content:'\e800'}.zan-icon-qr:before{content:'\e801'}.zan-icon-exchange:before{content:'\e802'}.zan-icon-close:before{content:'\e803'}.zan-icon-location:before{content:'\e804'}.zan-icon-upgrade:before{content:'\e805'}.zan-icon-check:before{content:'\e806'}.zan-icon-checked:before{content:'\e807'}.zan-icon-like-o:before{content:'\e808'}.zan-icon-like:before{content:'\e809'}.zan-icon-chat:before{content:'\e80a'}.zan-icon-shop:before{content:'\e80b'}.zan-icon-photograph:before{content:'\e80c'}.zan-icon-add:before{content:'\e80d'}.zan-icon-add2:before{content:'\e80e'}.zan-icon-photo:before{content:'\e80f'}.zan-icon-logistics:before{content:'\e810'}.zan-icon-edit:before{content:'\e811'}.zan-icon-passed:before{content:'\e812'}.zan-icon-cart:before{content:'\e813'}.zan-icon-shopping-cart:before{content:'\e814'}.zan-icon-arrow:before{content:'\e815'}.zan-icon-gift:before{content:'\e816'}.zan-icon-search:before{content:'\e817'}.zan-icon-clear:before{content:'\e818'}.zan-icon-success:before{content:'\e819'}.zan-icon-fail:before{content:'\e81a'}.zan-icon-contact:before{content:'\e81b'}.zan-icon-wechat:before{content:'\e81c'}.zan-icon-alipay:before{content:'\e81d'}.zan-icon-password-view:before{content:'\e81e'}.zan-icon-password-not-view:before{content:'\e81f'}.zan-icon-wap-nav:before{content:'\e820'}.zan-icon-wap-home:before{content:'\e821'}.zan-icon-ecard-pay:before{content:'\e822'}.zan-icon-balance-pay:before{content:'\e823'}.zan-icon-peer-pay:before{content:'\e824'}.zan-icon-credit-pay:before{content:'\e825'}.zan-icon-debit-pay:before{content:'\e826'}.zan-icon-other-pay:before{content:'\e827'}.zan-icon-browsing-history:before{content:'\e828'}.zan-icon-goods-collect:before{content:'\e829'}.zan-icon-shop-collect:before{content:'\e82a'}.zan-icon-receive-gift:before{content:'\e82b'}.zan-icon-send-gift:before{content:'\e82c'}.zan-icon-setting:before{content:'\e82d'}.zan-icon-points:before{content:'\e82e'}.zan-icon-coupon:before{content:'\e82f'}.zan-icon-free-postage:before{content:'\e830'}.zan-icon-discount:before{content:'\e831'}.zan-icon-birthday-privilege:before{content:'\e832'}.zan-icon-member-day-privilege:before{content:'\e833'}.zan-icon-balance-details:before{content:'\e834'}.zan-icon-cash-back-record:before{content:'\e835'}.zan-icon-points-mall:before{content:'\e836'}.zan-icon-exchange-record:before{content:'\e837'}.zan-icon-pending-payment:before{content:'\e838'}.zan-icon-pending-orders:before{content:'\e839'}.zan-icon-pending-deliver:before{content:'\e83a'}.zan-icon-pending-evaluate:before{content:'\e83b'}.zan-icon-gift-card-pay:before{content:'\e83c'}.zan-icon-cash-on-deliver:before{content:'\e83d'}.zan-icon-underway:before{content:'\e83e'}.zan-icon-point-gift:before{content:'\e83f'}.zan-icon-after-sale:before{content:'\e840'}.zan-icon-edit-data:before{content:'\e841'}.zan-icon-question:before{content:'\e842'}.zan-icon-delete:before{content:'\e843'}.zan-icon-records:before{content:'\e844'}.zan-icon-description:before{content:'\e845'}.zan-icon-card:before{content:'\e846'}.zan-icon-gift-card:before{content:'\e847'}.zan-icon-clock:before{content:'\e848'}.zan-icon-gold-coin:before{content:'\e849'}.zan-icon-completed:before{content:'\e84a'}.zan-icon-value-card:before{content:'\e84b'}.zan-icon-certificate:before{content:'\e84c'}.zan-icon-tosend:before{content:'\e84d'}.zan-icon-sign:before{content:'\e84e'}.zan-icon-home:before{content:'\e84f'}.zan-icon-phone:before{content:'\e850'}.zan-icon-add-o:before{content:'\e851'}.zan-icon-play:before{content:'\e852'}.zan-icon-pause:before{content:'\e853'}.zan-icon-stop:before{content:'\e854'}.zan-icon-hot:before{content:'\e855'}.zan-icon-new:before{content:'\e856'}.zan-icon-new-arrival:before{content:'\e857'}.zan-icon-hot-sale:before{content:'\e858'} -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | exports.Actionsheet = require('./actionsheet/index'); 2 | exports.Dialog = require('./dialog/index'); 3 | exports.Field = require('./field/index'); 4 | exports.NoticeBar = require('./noticebar/index'); 5 | exports.Select = require('./select/index'); 6 | exports.Stepper = require('./stepper/index'); 7 | exports.Switch = require('./switch/index'); 8 | exports.Tab = require('./tab/index'); 9 | exports.Toast = require('./toast/index'); 10 | exports.TopTips = require('./toptips/index'); 11 | 12 | // 兼容老版本,在下次大版本发布时会被移除 13 | exports.CheckLabel = require('./select/index'); 14 | 15 | const { extend } = require('./common/helper'); 16 | exports.extend = extend; 17 | -------------------------------------------------------------------------------- /dist/loadmore/index.wxml: -------------------------------------------------------------------------------- 1 | 25 | -------------------------------------------------------------------------------- /dist/loadmore/index.wxss: -------------------------------------------------------------------------------- 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;animation:weuiLoading 1s steps(12,end) infinite;background:transparent url(data:image/svg+xml;base64,PHN2ZyBjbGFzcz0iciIgd2lkdGg9JzEyMHB4JyBoZWlnaHQ9JzEyMHB4JyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj4KICAgIDxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiBmaWxsPSJub25lIiBjbGFzcz0iYmsiPjwvcmVjdD4KICAgIDxyZWN0IHg9JzQ2LjUnIHk9JzQwJyB3aWR0aD0nNycgaGVpZ2h0PScyMCcgcng9JzUnIHJ5PSc1JyBmaWxsPScjRTlFOUU5JwogICAgICAgICAgdHJhbnNmb3JtPSdyb3RhdGUoMCA1MCA1MCkgdHJhbnNsYXRlKDAgLTMwKSc+CiAgICA8L3JlY3Q+CiAgICA8cmVjdCB4PSc0Ni41JyB5PSc0MCcgd2lkdGg9JzcnIGhlaWdodD0nMjAnIHJ4PSc1JyByeT0nNScgZmlsbD0nIzk4OTY5NycKICAgICAgICAgIHRyYW5zZm9ybT0ncm90YXRlKDMwIDUwIDUwKSB0cmFuc2xhdGUoMCAtMzApJz4KICAgICAgICAgICAgICAgICByZXBlYXRDb3VudD0naW5kZWZpbml0ZScvPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyM5Qjk5OUEnCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSg2MCA1MCA1MCkgdHJhbnNsYXRlKDAgLTMwKSc+CiAgICAgICAgICAgICAgICAgcmVwZWF0Q291bnQ9J2luZGVmaW5pdGUnLz4KICAgIDwvcmVjdD4KICAgIDxyZWN0IHg9JzQ2LjUnIHk9JzQwJyB3aWR0aD0nNycgaGVpZ2h0PScyMCcgcng9JzUnIHJ5PSc1JyBmaWxsPScjQTNBMUEyJwogICAgICAgICAgdHJhbnNmb3JtPSdyb3RhdGUoOTAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNBQkE5QUEnCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgxMjAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNCMkIyQjInCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgxNTAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNCQUI4QjknCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgxODAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNDMkMwQzEnCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgyMTAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNDQkNCQ0InCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgyNDAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNEMkQyRDInCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgyNzAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNEQURBREEnCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgzMDAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNFMkUyRTInCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgzMzAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0Pgo8L3N2Zz4=) no-repeat;-webkit-background-size:100%;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%;transform:scale(.5);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} -------------------------------------------------------------------------------- /dist/noticebar/index.js: -------------------------------------------------------------------------------- 1 | const ZanNoticeBar = { 2 | initZanNoticeBarScroll(componentId) { 3 | this.zanNoticeBarNode = this.zanNoticeBarNode || {}; 4 | this.zanNoticeBarNode[`${componentId}`] = { 5 | width: undefined, 6 | wrapWidth: undefined, 7 | animation: null, 8 | resetAnimation: null 9 | }; 10 | 11 | const currentComponent = this.zanNoticeBarNode[`${componentId}`]; 12 | wx.createSelectorQuery() 13 | .in(this) 14 | .select(`#${componentId}__content`) 15 | .boundingClientRect((rect) => { 16 | if (!rect || !rect.width) { 17 | console.warn('页面缺少 noticebar 元素'); 18 | return; 19 | } 20 | 21 | currentComponent.width = rect.width; 22 | wx 23 | .createSelectorQuery() 24 | .in(this) 25 | .select(`#${componentId}__content-wrap`) 26 | .boundingClientRect((rect) => { 27 | if (!rect || !rect.width) { 28 | return; 29 | } 30 | 31 | currentComponent.wrapWidth = rect.width; 32 | if (currentComponent.wrapWidth < currentComponent.width) { 33 | var mstime = currentComponent.width / 40 * 1000; 34 | currentComponent.animation = wx.createAnimation({ 35 | duration: mstime, 36 | timingFunction: 'linear' 37 | }); 38 | currentComponent.resetAnimation = wx.createAnimation({ 39 | duration: 0, 40 | timingFunction: 'linear' 41 | }); 42 | this.scrollZanNoticeBar(componentId, mstime); 43 | } 44 | }) 45 | .exec(); 46 | }) 47 | .exec(); 48 | }, 49 | 50 | scrollZanNoticeBar(componentId, mstime) { 51 | const currentComponent = this.zanNoticeBarNode[`${componentId}`]; 52 | const resetAnimationData = currentComponent.resetAnimation.translateX(currentComponent.wrapWidth).step(); 53 | this.setData({ 54 | [`${componentId}.animationData`]: resetAnimationData.export() 55 | }); 56 | const aninationData = currentComponent.animation.translateX(-mstime * 40 / 1000).step(); 57 | setTimeout(() => { 58 | this.setData({ 59 | [`${componentId}.animationData`]: aninationData.export() 60 | }); 61 | }, 100); 62 | 63 | setTimeout(() => { 64 | this.scrollZanNoticeBar(componentId, mstime); 65 | }, mstime); 66 | } 67 | }; 68 | 69 | module.exports = ZanNoticeBar; 70 | -------------------------------------------------------------------------------- /dist/noticebar/index.wxml: -------------------------------------------------------------------------------- 1 | 17 | -------------------------------------------------------------------------------- /dist/noticebar/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-noticebar{color:#f60;padding:9px 10px;font-size:12px;line-height:1.5;background-color:#fff7cc} -------------------------------------------------------------------------------- /dist/panel/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-panel{position:relative;background:#fff;margin-top:10px;overflow:hidden}.zan-panel::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e5e5e5;border-top-width:1px;border-bottom-width:1px}.zan-panel-title{font-size:14px;line-height:1;color:#999;padding:20px 15px 0 15px}.zan-panel--without-margin-top{margin-top:0}.zan-panel--without-border::after{border:0 none} -------------------------------------------------------------------------------- /dist/popup/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-popup{visibility:hidden}.zan-popup--show{visibility:visible}.zan-popup__mask{position:fixed;top:0;left:0;right:0;bottom:0;z-index:10;background:rgba(0,0,0,.7);display:none}.zan-popup__container{position:fixed;left:50%;top:50%;background:#fff;transform:translate3d(-50%,-50%,0);transform-origin:center;transition:all .4s ease;z-index:11;opacity:0}.zan-popup--show .zan-popup__container{opacity:1}.zan-popup--show .zan-popup__mask{display:block}.zan-popup--left .zan-popup__container{left:0;top:auto;transform:translate3d(-100%,0,0)}.zan-popup--show.zan-popup--left .zan-popup__container{transform:translate3d(0,0,0)}.zan-popup--right .zan-popup__container{right:0;top:auto;left:auto;transform:translate3d(100%,0,0)}.zan-popup--show.zan-popup--right .zan-popup__container{transform:translate3d(0,0,0)}.zan-popup--bottom .zan-popup__container{top:auto;left:auto;bottom:0;transform:translate3d(0,100%,0)}.zan-popup--show.zan-popup--bottom .zan-popup__container{transform:translate3d(0,0,0)}.zan-popup--top .zan-popup__container{top:0;left:auto;transform:translate3d(0,-100%,0)}.zan-popup--show.zan-popup--top .zan-popup__container{transform:translate3d(0,0,0)} -------------------------------------------------------------------------------- /dist/row/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-row:after{content:"";display:table;clear:both} -------------------------------------------------------------------------------- /dist/select/index.js: -------------------------------------------------------------------------------- 1 | const { extractComponentId } = require('../common/helper'); 2 | 3 | function handle(e) { 4 | const componentId = extractComponentId(e); 5 | const value = e.detail.value; 6 | 7 | callback.call(this, componentId, value); 8 | } 9 | 10 | function callback(componentId, value) { 11 | const e = { componentId, value }; 12 | 13 | 14 | if (this.handleZanSelectChange) { 15 | this.handleZanSelectChange(e); 16 | } else { 17 | console.warn('页面缺少 handleZanSelectChange 回调函数'); 18 | } 19 | } 20 | 21 | module.exports = { 22 | _handleZanSelectChange(e) { 23 | handle.call(this, e); 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /dist/select/index.wxml: -------------------------------------------------------------------------------- 1 | 22 | 23 | 24 | function getColor(color) { 25 | color = color || '#ff4444' 26 | return color; 27 | } 28 | 29 | module.exports = { 30 | getColor: getColor, 31 | getItemStyle: function(item, checkedValue, activeColor) { 32 | var padding = item.padding * 10; 33 | var style = 'padding-left: ' + padding + 'px;'; 34 | 35 | // 如果为选中状态,则高亮 36 | if (item.value === checkedValue) { 37 | style += 'color: ' + getColor(activeColor); 38 | } 39 | 40 | return style; 41 | } 42 | }; 43 | 44 | -------------------------------------------------------------------------------- /dist/select/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-select__list .zan-select__radio{display:none} -------------------------------------------------------------------------------- /dist/stepper/index.js: -------------------------------------------------------------------------------- 1 | function handle(e, num) { 2 | var dataset = e.currentTarget.dataset; 3 | var componentId = dataset.componentId; 4 | var disabled = dataset.disabled; 5 | var stepper = +dataset.stepper; 6 | 7 | if (disabled) return null; 8 | 9 | callback.call(this, componentId, stepper + num); 10 | } 11 | 12 | function callback(componentId, stepper) { 13 | stepper = +stepper; 14 | var e = { componentId, stepper }; 15 | 16 | 17 | if (this.handleZanStepperChange) { 18 | this.handleZanStepperChange(e); 19 | } else { 20 | console.warn('页面缺少 handleZanStepperChange 回调函数'); 21 | } 22 | } 23 | 24 | var Stepper = { 25 | _handleZanStepperMinus(e) { 26 | handle.call(this, e, -1); 27 | }, 28 | 29 | _handleZanStepperPlus(e) { 30 | handle.call(this, e, +1); 31 | }, 32 | 33 | _handleZanStepperBlur(e) { 34 | var dataset = e.currentTarget.dataset; 35 | var componentId = dataset.componentId; 36 | var max = +dataset.max; 37 | var min = +dataset.min; 38 | var value = e.detail.value; 39 | 40 | if (!value) { 41 | setTimeout(() => { 42 | callback.call(this, componentId, min); 43 | }, 16); 44 | callback.call(this, componentId, value); 45 | return '' + value; 46 | } 47 | 48 | value = +value; 49 | if (value > max) { 50 | value = max; 51 | } else if (value < min) { 52 | value = min; 53 | } 54 | 55 | callback.call(this, componentId, value); 56 | 57 | return '' + value; 58 | } 59 | }; 60 | 61 | module.exports = Stepper; 62 | -------------------------------------------------------------------------------- /dist/stepper/index.wxml: -------------------------------------------------------------------------------- 1 | 29 | -------------------------------------------------------------------------------- /dist/stepper/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-stepper{color:#666}.zan-stepper view{display:inline-block;line-height:20px;padding:5px 0;text-align:center;min-width:40px;box-sizing:border-box;vertical-align:middle;font-size:12px;border:1rpx solid #999}.zan-stepper .zan-stepper__minus{border-right:none;border-radius:2px 0 0 2px}.zan-stepper .zan-stepper__text{border:1rpx solid #999;display:inline-block;text-align:center;vertical-align:middle;height:30px;width:40px;min-height:auto;font-size:12px;line-height:30px}.zan-stepper .zan-stepper__plus{border-left:none;border-radius:0 2px 2px 0}.zan-stepper .zan-stepper--disabled{background:#f8f8f8;color:#bbb;border-color:#e8e8e8}.zan-stepper--small view{min-width:36px;line-height:18px}.zan-stepper--small .zan-stepper__text{width:36px;line-height:28px;height:28px} -------------------------------------------------------------------------------- /dist/steps/index.wxml: -------------------------------------------------------------------------------- 1 | 16 | -------------------------------------------------------------------------------- /dist/steps/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-steps--steps.zan-steps--5 .zan-steps__step{width:25%}.zan-steps--steps.zan-steps--4 .zan-steps__step{width:33%}.zan-steps--steps.zan-steps--3 .zan-steps__step{width:50%}.zan-steps--steps .zan-steps__step{position:relative;float:left;padding-bottom:25px;color:#b1b1b1}.zan-steps--steps .zan-steps__title{transform:translateX(-50%);font-size:10px;text-align:center}.zan-steps--steps .zan-steps__icons{position:absolute;top:30px;left:-10px;padding:0 8px;background-color:#fff;z-index:10}.zan-steps--steps .zan-steps__circle{display:block;position:relative;width:5px;height:5px;background-color:#e5e5e5;border-radius:50%}.zan-steps--steps .zan-steps__line{position:absolute;left:0;top:32px;width:100%;height:1px;background-color:#e5e5e5}.zan-steps--steps .zan-steps__step--done{color:#333}.zan-steps--steps .zan-steps__step--done .zan-steps__line{background-color:#06bf04}.zan-steps--steps .zan-steps__step--done .zan-steps__circle{width:5px;height:5px;background-color:#09bb07}.zan-steps--steps .zan-steps__step--cur .zan-steps__icons{top:25px;left:-14px}.zan-steps--steps .zan-steps__step--cur .zan-steps__circle{width:13px;height:13px;background-image:url(https://b.yzcdn.cn/v2/image/wap/success_small@2x.png);background-size:13px 13px}.zan-steps--steps .zan-steps__step--cur .zan-steps__line{background-color:#e5e5e5}.zan-steps--steps .zan-steps__step--first-child .zan-steps__title{margin-left:0;transform:none;text-align:left}.zan-steps--steps .zan-steps__step--first-child .zan-steps__icons{left:-7px}.zan-steps--steps .zan-steps__step--last-child{position:absolute;right:0;top:0;text-align:right}.zan-steps--steps .zan-steps__step--last-child .zan-steps__title{transform:none;text-align:right}.zan-steps--steps .zan-steps__step--last-child .zan-steps__icons{left:auto;right:-6px}.zan-steps--steps .zan-steps__step--last-child .zan-steps__line{display:none}.zan-steps--steps .zan-steps__step--db-title{min-height:29px}.zan-steps--steps .zan-steps__step--db-title .zan-steps__line{top:45px}.zan-steps--steps .zan-steps__step--db-title .zan-steps__icons{top:43px}.zan-steps--steps .zan-steps__step--db-title.zan-steps__step--cur .zan-steps__icons{top:39px}.zan-steps--vsteps{color:#999;font-size:14px}.zan-steps--vsteps .zan-steps__step{position:relative;padding:15px 0}.zan-steps--vsteps .zan-steps__step--done{color:#4b0}.zan-steps--vsteps .zan-steps__line{position:absolute;top:0;bottom:0;left:7px;width:1px;background-color:#e5e5e5}.zan-steps--vsteps .zan-steps__title{display:inline-block;line-height:20px;padding-left:27px}.zan-steps--vsteps .zan-steps__title--desc{padding-left:3px}.zan-steps--vsteps .zan-steps__icons{position:absolute;left:7px;top:50%;transform:translate(-50%,-50%);z-index:2;padding:3px 0;background-color:#fff}.zan-steps--vsteps .zan-steps__circle{width:5px;height:5px;background-color:#cacaca;border-radius:10px}.zan-steps--vsteps .zan-steps__step--done .zan-steps__circle{width:5px;height:5px;background-color:#09bb07}.zan-steps--vsteps .zan-steps__step--cur .zan-steps__circle{width:13px;height:13px;background:transparent url(https://b.yzcdn.cn/v2/image/wap/success_small@2x.png);background-size:13px 13px;border-radius:0}.zan-steps--vsteps .zan-steps__icon--active{width:13px;height:13px}.zan-steps--vsteps .zan-steps__step--first-child .zan-steps__title::before{content:'';position:absolute;top:0;bottom:50%;left:7px;width:1px;background-color:#fff;z-index:1}.zan-steps--vsteps .zan-steps__step--last-child .zan-steps__title::after{content:'';position:absolute;top:50%;bottom:0;left:7px;width:1px;background-color:#fff;z-index:1}.zan-steps{position:relative} -------------------------------------------------------------------------------- /dist/steps/wxss/step.wxss: -------------------------------------------------------------------------------- 1 | .zan-steps--steps.zan-steps--5 .zan-steps__step{width:25%}.zan-steps--steps.zan-steps--4 .zan-steps__step{width:33%}.zan-steps--steps.zan-steps--3 .zan-steps__step{width:50%}.zan-steps--steps .zan-steps__step{position:relative;float:left;padding-bottom:25px;color:#b1b1b1}.zan-steps--steps .zan-steps__title{transform:translateX(-50%);font-size:10px;text-align:center}.zan-steps--steps .zan-steps__icons{position:absolute;top:30px;left:-10px;padding:0 8px;background-color:#fff;z-index:10}.zan-steps--steps .zan-steps__circle{display:block;position:relative;width:5px;height:5px;background-color:#e5e5e5;border-radius:50%}.zan-steps--steps .zan-steps__line{position:absolute;left:0;top:32px;width:100%;height:1px;background-color:#e5e5e5}.zan-steps--steps .zan-steps__step--done{color:#333}.zan-steps--steps .zan-steps__step--done .zan-steps__line{background-color:#06bf04}.zan-steps--steps .zan-steps__step--done .zan-steps__circle{width:5px;height:5px;background-color:#09bb07}.zan-steps--steps .zan-steps__step--cur .zan-steps__icons{top:25px;left:-14px}.zan-steps--steps .zan-steps__step--cur .zan-steps__circle{width:13px;height:13px;background-image:url(https://b.yzcdn.cn/v2/image/wap/success_small@2x.png);background-size:13px 13px}.zan-steps--steps .zan-steps__step--cur .zan-steps__line{background-color:#e5e5e5}.zan-steps--steps .zan-steps__step--first-child .zan-steps__title{margin-left:0;transform:none;text-align:left}.zan-steps--steps .zan-steps__step--first-child .zan-steps__icons{left:-7px}.zan-steps--steps .zan-steps__step--last-child{position:absolute;right:0;top:0;text-align:right}.zan-steps--steps .zan-steps__step--last-child .zan-steps__title{transform:none;text-align:right}.zan-steps--steps .zan-steps__step--last-child .zan-steps__icons{left:auto;right:-6px}.zan-steps--steps .zan-steps__step--last-child .zan-steps__line{display:none}.zan-steps--steps .zan-steps__step--db-title{min-height:29px}.zan-steps--steps .zan-steps__step--db-title .zan-steps__line{top:45px}.zan-steps--steps .zan-steps__step--db-title .zan-steps__icons{top:43px}.zan-steps--steps .zan-steps__step--db-title.zan-steps__step--cur .zan-steps__icons{top:39px} -------------------------------------------------------------------------------- /dist/steps/wxss/vstep.wxss: -------------------------------------------------------------------------------- 1 | .zan-steps--vsteps{color:#999;font-size:14px}.zan-steps--vsteps .zan-steps__step{position:relative;padding:15px 0}.zan-steps--vsteps .zan-steps__step--done{color:#4b0}.zan-steps--vsteps .zan-steps__line{position:absolute;top:0;bottom:0;left:7px;width:1px;background-color:#e5e5e5}.zan-steps--vsteps .zan-steps__title{display:inline-block;line-height:20px;padding-left:27px}.zan-steps--vsteps .zan-steps__title--desc{padding-left:3px}.zan-steps--vsteps .zan-steps__icons{position:absolute;left:7px;top:50%;transform:translate(-50%,-50%);z-index:2;padding:3px 0;background-color:#fff}.zan-steps--vsteps .zan-steps__circle{width:5px;height:5px;background-color:#cacaca;border-radius:10px}.zan-steps--vsteps .zan-steps__step--done .zan-steps__circle{width:5px;height:5px;background-color:#09bb07}.zan-steps--vsteps .zan-steps__step--cur .zan-steps__circle{width:13px;height:13px;background:transparent url(https://b.yzcdn.cn/v2/image/wap/success_small@2x.png);background-size:13px 13px;border-radius:0}.zan-steps--vsteps .zan-steps__icon--active{width:13px;height:13px}.zan-steps--vsteps .zan-steps__step--first-child .zan-steps__title::before{content:'';position:absolute;top:0;bottom:50%;left:7px;width:1px;background-color:#fff;z-index:1}.zan-steps--vsteps .zan-steps__step--last-child .zan-steps__title::after{content:'';position:absolute;top:50%;bottom:0;left:7px;width:1px;background-color:#fff;z-index:1} -------------------------------------------------------------------------------- /dist/switch/index.js: -------------------------------------------------------------------------------- 1 | var Switch = { 2 | _handleZanSwitchChange(e) { 3 | var dataset = e.currentTarget.dataset; 4 | 5 | var checked = !dataset.checked; 6 | var loading = dataset.loading; 7 | var disabled = dataset.disabled; 8 | var componentId = dataset.componentId; 9 | 10 | if (loading || disabled) return; 11 | 12 | 13 | 14 | if (this.handleZanSwitchChange) { 15 | this.handleZanSwitchChange({ 16 | checked, 17 | componentId 18 | }); 19 | } else { 20 | console.warn('页面缺少 handleZanSwitchChange 回调函数'); 21 | } 22 | } 23 | }; 24 | 25 | module.exports = Switch; 26 | -------------------------------------------------------------------------------- /dist/switch/index.wxml: -------------------------------------------------------------------------------- 1 | 16 | -------------------------------------------------------------------------------- /dist/switch/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-switch{position:relative;display:inline-block;width:52px;height:32px;vertical-align:middle;box-sizing:border-box;border-radius:16px;background:#44db5e;border:1px solid #44db5e}.zan-switch__circle{position:absolute;top:0;left:0;width:30px;height:30px;display:inline-block;background:#fff;border-radius:15px;box-sizing:border-box;box-shadow:0 0 0 1px rgba(0,0,0,.1),0 3px 1px 0 rgba(0,0,0,.05),0 2px 2px 0 rgba(0,0,0,.1),0 3px 3px 0 rgba(0,0,0,.05);transition:transform .35s cubic-bezier(.45,1,.4,1);z-index:2}.zan-switch__bg{position:absolute;top:-1px;left:-1px;width:52px;height:32px;background:#fff;border-radius:26px;display:inline-block;border:1px solid #e5e5e5;box-sizing:border-box;transition:transform .35s cubic-bezier(.45,1,.4,1);transform:scale(0);transform-origin:36px 16px}.zan-switch--on .zan-switch__circle{transform:translateX(20px)}.zan-switch--off .zan-switch__bg{transform:scale(1)}.zan-swtich--disabled{opacity:.4}.zan-switch__loading{position:absolute;left:7px;top:7px;width:16px;height:16px;background:url(https://img.yzcdn.cn/public_files/2017/02/24/9acec77d91106cd15b8107c4633d9155.png) no-repeat;background-size:16px 16px;animation:zan-switch-loading .8s infinite linear}@keyframes zan-switch-loading{from{transform:rotate(0)}to{transform:rotate(360deg)}} -------------------------------------------------------------------------------- /dist/tab/index.js: -------------------------------------------------------------------------------- 1 | const { extractComponentId } = require('../common/helper'); 2 | 3 | var Tab = { 4 | _handleZanTabChange(e) { 5 | const componentId = extractComponentId(e); 6 | const dataset = e.currentTarget.dataset; 7 | const selectedId = dataset.itemId; 8 | const data = { componentId, selectedId }; 9 | 10 | 11 | if (this.handleZanTabChange) { 12 | this.handleZanTabChange(data); 13 | } else { 14 | console.warn('页面缺少 handleZanTabChange 回调函数'); 15 | } 16 | } 17 | }; 18 | 19 | module.exports = Tab; 20 | -------------------------------------------------------------------------------- /dist/tab/index.wxml: -------------------------------------------------------------------------------- 1 | 25 | 26 | 38 | -------------------------------------------------------------------------------- /dist/tab/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-tab{height:45px}.zan-tab__bd{width:750rpx;display:flex;flex-direction:row;border-bottom:1rpx solid #e5e5e5;background:#fff}.zan-tab__bd--fixed{position:fixed;top:0;z-index:2}.zan-tab__item{flex:1;display:inline-block;padding:0 10px;line-height:0;box-sizing:border-box;overflow:hidden;text-align:center}.zan-tab__title{display:inline-block;max-width:100%;height:44px;line-height:44px;overflow:hidden;text-overflow:ellipsis;box-sizing:border-box;word-break:keep-all;font-size:14px;color:#666}.zan-tab__item--selected .zan-tab__title{color:#f44;border-bottom:2px solid #f44}.zan-tab__bd--scroll{display:block;white-space:nowrap}.zan-tab__bd--scroll .zan-tab__item{min-width:80px} -------------------------------------------------------------------------------- /dist/tag/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-tag{display:inline-block;position:relative;box-sizing:border-box;line-height:16px;padding:0 5px;border-radius:2px;font-size:11px;background:#c9c9c9;text-align:center;color:#fff}.zan-tag::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e5e5e5;border-width:1px;border-radius:4px}.zan-tag--plain{color:#c9c9c9;background:#fff}.zan-tag--primary{color:#fff;background-color:#4b0}.zan-tag--primary::after{border-color:#4b0}.zan-tag--primary.zan-tag--plain{color:#4b0;background:#fff}.zan-tag--danger{color:#fff;background:#f44}.zan-tag--danger::after{border-color:#f44}.zan-tag--danger.zan-tag--plain{color:#f44;background:#fff}.zan-tag--warn{color:#fff;background:#f85}.zan-tag--warn::after{border-color:#f85}.zan-tag--warn.zan-tag--plain{color:#f85;background:#fff}.zan-tag--disabled{color:#999!important;background:#e5e5e5}.zan-tag--disabled::after{border-color:#ccc} -------------------------------------------------------------------------------- /dist/toast/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | showZanToast(title, timeout) { 3 | const options = formatParameter(title, timeout); 4 | 5 | // 清除上一轮的计时器 6 | const { timer = 0 } = this.data.zanToast || {}; 7 | clearTimeout(timer); 8 | 9 | // 弹层设置~ 10 | const zanToast = { 11 | show: true, 12 | icon: options.icon, 13 | image: options.image, 14 | title: options.title 15 | }; 16 | this.setData({ 17 | zanToast 18 | }); 19 | 20 | // 传入的显示时长小于0,就认为需要一直显示 21 | if (timeout < 0) { 22 | return; 23 | } 24 | 25 | // 下一轮计时器 26 | const nextTimer = setTimeout(() => { 27 | this.clearZanToast(); 28 | }, timeout || 3000); 29 | 30 | this.setData({ 31 | 'zanToast.timer': nextTimer 32 | }); 33 | }, 34 | 35 | // 清除所有 toast 36 | clearZanToast() { 37 | const { timer = 0 } = this.data.zanToast || {}; 38 | clearTimeout(timer); 39 | 40 | this.setData({ 41 | 'zanToast.show': false 42 | }); 43 | }, 44 | 45 | // 快捷方法,显示 loading 46 | showZanLoading(title) { 47 | const options = formatParameter(title); 48 | 49 | this.showZanToast({ 50 | ...options, 51 | icon: 'loading' 52 | }); 53 | } 54 | }; 55 | 56 | function formatParameter(title, timeout = 0) { 57 | // 如果传入的 title 是对象,那么认为所有的配置属性都在这个对象中了 58 | if (typeof title === 'object') { 59 | return title; 60 | } 61 | 62 | return { 63 | title, 64 | timeout 65 | }; 66 | } 67 | -------------------------------------------------------------------------------- /dist/toast/index.wxml: -------------------------------------------------------------------------------- 1 | 32 | -------------------------------------------------------------------------------- /dist/toast/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-toast{position:fixed;top:35%;left:50%;transform:translate3d(-50%,-50%,0);background:rgba(0,0,0,.7);color:#fff;font-size:14px;line-height:1.5em;margin:0 auto;box-sizing:border-box;padding:10px 18px;text-align:center;border-radius:4px;z-index:100}.zan-toast--notitle{padding:18px}.zan-toast__icon{width:40px;height:40px;line-height:40px;margin:0 auto;padding:12px 15px;font-size:38px;text-align:center}.zan-toast__icon-loading{line-height:0}.zan-toast__icon-loading .zan-loading{width:40px;height:40px}.zan-toast__icon-image{background-size:40px;background-position:center;background-repeat:no-repeat} -------------------------------------------------------------------------------- /dist/toptips/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | showZanTopTips(content = '', options = {}) { 3 | let zanTopTips = this.data.zanTopTips || {}; 4 | // 如果已经有一个计时器在了,就清理掉先 5 | if (zanTopTips.timer) { 6 | clearTimeout(zanTopTips.timer); 7 | zanTopTips.timer = 0; 8 | } 9 | 10 | if (typeof options === 'number') { 11 | options = { 12 | duration: options 13 | }; 14 | } 15 | 16 | // options参数默认参数扩展 17 | options = Object.assign({ 18 | duration: 3000 19 | }, options); 20 | 21 | // 设置定时器,定时关闭topTips 22 | let timer = setTimeout(() => { 23 | this.setData({ 24 | 'zanTopTips.show': false, 25 | 'zanTopTips.timer': 0 26 | }); 27 | }, options.duration); 28 | 29 | // 展示出topTips 30 | this.setData({ 31 | zanTopTips: { 32 | show: true, 33 | content, 34 | options, 35 | timer 36 | } 37 | }); 38 | } 39 | }; 40 | -------------------------------------------------------------------------------- /dist/toptips/index.wxml: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /dist/toptips/index.wxss: -------------------------------------------------------------------------------- 1 | .zan-toptips{display:block;position:fixed;-webkit-transform:translateZ(0) translateY(-100%);width:100%;min-height:32px;top:0;line-height:2.3;font-size:14px;text-align:center;color:#fff;background-color:#e64340;z-index:110;opacity:0;transition:all .4s ease}.zan-toptips--show{-webkit-transform:translateZ(0) translateY(0);opacity:1} -------------------------------------------------------------------------------- /img/calendar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/calendar.png -------------------------------------------------------------------------------- /img/express.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/express.png -------------------------------------------------------------------------------- /img/index_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/index_n.png -------------------------------------------------------------------------------- /img/index_p.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/index_p.png -------------------------------------------------------------------------------- /img/jiantou.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/jiantou.png -------------------------------------------------------------------------------- /img/loginme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/loginme.png -------------------------------------------------------------------------------- /img/more_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/more_n.png -------------------------------------------------------------------------------- /img/more_p.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/more_p.png -------------------------------------------------------------------------------- /img/weather.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather.png -------------------------------------------------------------------------------- /img/weather/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/0.png -------------------------------------------------------------------------------- /img/weather/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/1.png -------------------------------------------------------------------------------- /img/weather/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/10.png -------------------------------------------------------------------------------- /img/weather/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/11.png -------------------------------------------------------------------------------- /img/weather/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/12.png -------------------------------------------------------------------------------- /img/weather/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/13.png -------------------------------------------------------------------------------- /img/weather/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/14.png -------------------------------------------------------------------------------- /img/weather/15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/15.png -------------------------------------------------------------------------------- /img/weather/16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/16.png -------------------------------------------------------------------------------- /img/weather/17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/17.png -------------------------------------------------------------------------------- /img/weather/18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/18.png -------------------------------------------------------------------------------- /img/weather/19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/19.png -------------------------------------------------------------------------------- /img/weather/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/2.png -------------------------------------------------------------------------------- /img/weather/20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/20.png -------------------------------------------------------------------------------- /img/weather/21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/21.png -------------------------------------------------------------------------------- /img/weather/22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/22.png -------------------------------------------------------------------------------- /img/weather/23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/23.png -------------------------------------------------------------------------------- /img/weather/24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/24.png -------------------------------------------------------------------------------- /img/weather/25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/25.png -------------------------------------------------------------------------------- /img/weather/26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/26.png -------------------------------------------------------------------------------- /img/weather/27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/27.png -------------------------------------------------------------------------------- /img/weather/28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/28.png -------------------------------------------------------------------------------- /img/weather/29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/29.png -------------------------------------------------------------------------------- /img/weather/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/3.png -------------------------------------------------------------------------------- /img/weather/30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/30.png -------------------------------------------------------------------------------- /img/weather/301.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/301.png -------------------------------------------------------------------------------- /img/weather/302.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/302.png -------------------------------------------------------------------------------- /img/weather/31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/31.png -------------------------------------------------------------------------------- /img/weather/32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/32.png -------------------------------------------------------------------------------- /img/weather/39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/39.png -------------------------------------------------------------------------------- /img/weather/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/4.png -------------------------------------------------------------------------------- /img/weather/49.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/49.png -------------------------------------------------------------------------------- /img/weather/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/5.png -------------------------------------------------------------------------------- /img/weather/53.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/53.png -------------------------------------------------------------------------------- /img/weather/54.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/54.png -------------------------------------------------------------------------------- /img/weather/55.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/55.png -------------------------------------------------------------------------------- /img/weather/56.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/56.png -------------------------------------------------------------------------------- /img/weather/57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/57.png -------------------------------------------------------------------------------- /img/weather/58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/58.png -------------------------------------------------------------------------------- /img/weather/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/6.png -------------------------------------------------------------------------------- /img/weather/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/7.png -------------------------------------------------------------------------------- /img/weather/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/8.png -------------------------------------------------------------------------------- /img/weather/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/9.png -------------------------------------------------------------------------------- /img/weather/99.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weather/99.png -------------------------------------------------------------------------------- /img/weixinarticle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/best-fan/wechat-app-history/9de7e0962cbed3ddf0ca1d67f9798bd6f95104bf/img/weixinarticle.png -------------------------------------------------------------------------------- /pages/content/content.js: -------------------------------------------------------------------------------- 1 | // pages/content/content.js 2 | const app = getApp(); 3 | var Bmob = require('../../utils/bmob.js'); 4 | var WxParse = require('../../wxParse/wxParse.js'); 5 | var Zan = require('../../dist/index'); 6 | Page(Object.assign({}, Zan.TopTips, { 7 | 8 | /** 9 | * 页面的初始数据 10 | */ 11 | data: { 12 | //标题 13 | Title: '', 14 | //用户信息 15 | userinfor: '', 16 | //页面内容 17 | // content: '', 18 | //是否点击评论 19 | releaseFocus: false, 20 | //评论数量 21 | num: '', 22 | //输入的评论 23 | pl: '', 24 | //数据库评论列表 25 | plresult: '' 26 | }, 27 | 28 | /** 29 | * 生命周期函数--监听页面加载+ 30 | */ 31 | onLoad: function (options) { 32 | 33 | var that = this; 34 | // 获取传参 35 | if (options != null) { 36 | if (app.globalData.wztype=='0'){ 37 | var article = app.globalData.data[options.index].content; 38 | WxParse.wxParse('article', 'html', article, that, 5); 39 | that.setData({ 40 | // content: app.globalData.data[options.index].content, 41 | userinfor: app.globalData.userInfo, 42 | Title: app.globalData.data[options.index].title, 43 | }); 44 | wx.setNavigationBarTitle({ 45 | title: app.globalData.data[options.index].title, 46 | }) 47 | }else{ 48 | console.log(app.globalData.wxlist) 49 | var article = app.globalData.wxlist[options.index].content; 50 | WxParse.wxParse('article', 'html', article, that, 5); 51 | that.setData({ 52 | //content: app.globalData.wxlist[options.index].content, 53 | userinfor: app.globalData.userInfo, 54 | Title: app.globalData.wxlist[options.index].title, 55 | }); 56 | wx.setNavigationBarTitle({ 57 | title: app.globalData.wxlist[options.index].title, 58 | }) 59 | } 60 | 61 | //console.log('options不为空') 62 | } else { 63 | 64 | //console.log('options为空') 65 | } 66 | 67 | 68 | that.getcontent(); 69 | }, 70 | 71 | /** 72 | * 生命周期函数--监听页面初次渲染完成 73 | */ 74 | onReady: function () { 75 | 76 | }, 77 | 78 | /** 79 | * 点击回复 80 | **/ 81 | bindReply: function (e) { 82 | this.setData({ 83 | releaseFocus: true 84 | }) 85 | }, 86 | //获取评论内容 87 | getplnr: function (e) { 88 | this.setData({ 89 | pl: e.detail.value 90 | }) 91 | }, 92 | // 点击发送 93 | bindsubmit: function () { 94 | 95 | ////console.log(this.data.pl) 96 | this.putcontent(); 97 | this.getcontent(); 98 | }, 99 | 100 | //获取评论 101 | getcontent: function () { 102 | var that = this; 103 | var Diary = Bmob.Object.extend("comment"); 104 | var query = new Bmob.Query(Diary); 105 | query.equalTo("title", that.data.Title); 106 | query.descending("createdAt"); 107 | // 查询所有数据 108 | query.find({ 109 | success: function (results) { 110 | //console.log("共查询到 " + results.length + " 条记录"); 111 | that.setData({ 112 | num: results.length, 113 | plresult: results, 114 | }) 115 | 116 | }, 117 | error: function (error) { 118 | //console.log("查询失败: " + error.code + " " + error.message); 119 | } 120 | }); 121 | }, 122 | //上传评论 123 | putcontent: function () { 124 | var that = this; 125 | if (that.data.pl.length == 0) { 126 | ////console.log('评论为空'); 127 | that.showZanTopTips('评论不能为空,提交失败'); 128 | that.setData({ 129 | releaseFocus: false 130 | }) 131 | 132 | } else { 133 | var Diary = Bmob.Object.extend("comment"); 134 | var diary = new Diary(); 135 | diary.set("title", that.data.Title); 136 | diary.set("content", that.data.pl); 137 | diary.set("nickname", that.data.userinfor.nickName); 138 | diary.set("side", that.data.userinfor.city); 139 | diary.set("imgsrc", that.data.userinfor.avatarUrl); 140 | //添加数据,第一个入口参数是null 141 | diary.save(null, { 142 | success: function (result) { 143 | // 添加成功,返回成功之后的objectId(注意:返回的属性名字是id,不是objectId),你还可以在Bmob的Web管理后台看到对应的数据 144 | //console.log("日记创建成功, objectId:" + result.id); 145 | that.showZanTopTips('评论提交成功'); 146 | }, 147 | error: function (result, error) { 148 | // 添加失败 149 | //console.log('创建日记失败'); 150 | 151 | } 152 | }); 153 | that.setData({ 154 | releaseFocus: false, 155 | pl: '', 156 | }) 157 | } 158 | 159 | } 160 | 161 | 162 | //}) 163 | })); -------------------------------------------------------------------------------- /pages/content/content.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": {} 4 | } -------------------------------------------------------------------------------- /pages/content/content.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |