├── style ├── base │ ├── fn.wxss │ ├── mixin │ │ ├── text.wxss │ │ ├── setArrow.wxss │ │ └── setOnepx.wxss │ ├── variable │ │ ├── color.wxss │ │ ├── global.wxss │ │ ├── weui-msg.wxss │ │ ├── weui-button.wxss │ │ ├── weui-cell.wxss │ │ ├── weui-dialog.wxss │ │ ├── weui-grid.wxss │ │ └── weui-progress.wxss │ └── reset.wxss └── widget │ ├── weui-cell │ ├── weui-switch.wxss │ ├── weui-check.wxss │ ├── weui-form │ │ ├── weui-vcode.wxss │ │ ├── weui-select.wxss │ │ ├── weui-form_common.wxss │ │ └── weui-form-preview.wxss │ ├── weui-access.wxss │ ├── weui-cell.wxss │ ├── weui-uploader.wxss │ └── weui-form.wxss │ ├── weui-button │ └── weui-button.wxss │ ├── weui-flex │ └── weui-flex.wxss │ ├── weui-progress │ └── weui-progress.wxss │ ├── weui-page │ ├── weui-article.wxss │ └── weui-msg.wxss │ ├── weui-agree │ └── weui-agree.wxss │ ├── weui-grid │ └── weui-grid.wxss │ ├── weui-footer │ └── weui-footer.wxss │ ├── weui-tips │ └── weui-loadmore.wxss │ ├── weui-panel │ └── weui-panel.wxss │ ├── weui-tab │ ├── weui-navbar.wxss │ └── weui-tab.wxss │ ├── weui-searchbar │ └── weui-searchbar.wxss │ ├── weui-animate │ └── weui-animate.wxss │ ├── weui-media-box │ └── weui-media-box.wxss │ └── weui-loading │ └── weui-loading.wxss ├── pages ├── chat │ ├── chat.json │ ├── chat.wxml │ └── chat.js ├── demo │ ├── index.json │ ├── flex │ │ ├── index.json │ │ ├── index.js │ │ ├── index.wxss │ │ └── index.wxml │ ├── float │ │ ├── index.json │ │ ├── index.wxml │ │ ├── index.wxss │ │ └── index.js │ ├── index.js │ ├── index.wxml │ └── index.wxss ├── weui │ ├── index.json │ ├── flex │ │ ├── flex.json │ │ ├── flex.js │ │ ├── flex.wxss │ │ └── flex.wxml │ ├── grid │ │ ├── grid.json │ │ ├── grid.wxss │ │ ├── grid.js │ │ └── grid.wxml │ ├── list │ │ ├── list.json │ │ ├── list.wxss │ │ ├── list.js │ │ └── list.wxml │ ├── msg │ │ ├── msg.json │ │ ├── msg_fail.json │ │ ├── msg_success.json │ │ ├── msg_fail.js │ │ ├── msg_success.js │ │ ├── msg.wxss │ │ ├── msg_fail.wxss │ │ ├── msg_success.wxss │ │ ├── msg.js │ │ ├── msg.wxml │ │ ├── msg_fail.wxml │ │ └── msg_success.wxml │ ├── article │ │ ├── article.json │ │ ├── article.js │ │ ├── article.wxss │ │ └── article.wxml │ ├── badge │ │ ├── badge.json │ │ ├── badge.js │ │ ├── badge.wxss │ │ └── badge.wxml │ ├── button │ │ ├── button.json │ │ ├── button.js │ │ ├── button.wxss │ │ └── button.wxml │ ├── dialog │ │ ├── dialog.json │ │ ├── dialog.wxss │ │ ├── dialog.wxml │ │ └── dialog.js │ ├── footer │ │ ├── footer.json │ │ ├── footer.js │ │ ├── footer.wxss │ │ └── footer.wxml │ ├── gallery │ │ ├── gallery.json │ │ ├── gallery.js │ │ ├── gallery.wxss │ │ └── gallery.wxml │ ├── icons │ │ ├── icons.json │ │ ├── icons.js │ │ ├── icons.wxss │ │ └── icons.wxml │ ├── input │ │ ├── input.json │ │ ├── input.wxss │ │ └── input.js │ ├── navbar │ │ ├── navbar.json │ │ ├── navbar.wxss │ │ ├── navbar.js │ │ └── navbar.wxml │ ├── panel │ │ ├── panel.json │ │ ├── panel.wxss │ │ ├── panel.js │ │ └── panel.wxml │ ├── picker │ │ ├── picker.json │ │ ├── picker.wxss │ │ ├── picker.js │ │ └── picker.wxml │ ├── preview │ │ ├── preview.json │ │ ├── preview.js │ │ ├── preview.wxss │ │ └── preview.wxml │ ├── slider │ │ ├── slider.json │ │ ├── slider.js │ │ ├── slider.wxss │ │ └── slider.wxml │ ├── tabbar │ │ ├── tabbar.json │ │ ├── tabbar.js │ │ ├── tabbar.wxss │ │ └── tabbar.wxml │ ├── toast │ │ ├── toast.json │ │ ├── toast.wxss │ │ ├── toast.js │ │ └── toast.wxml │ ├── loadmore │ │ ├── loadmore.json │ │ ├── loadmore.js │ │ ├── loadmore.wxss │ │ └── loadmore.wxml │ ├── progress │ │ ├── progress.json │ │ ├── progress.wxss │ │ ├── progress.js │ │ └── progress.wxml │ ├── searchbar │ │ ├── searchbar.json │ │ ├── searchbar.wxss │ │ ├── searchbar.js │ │ └── searchbar.wxml │ ├── uploader │ │ ├── uploader.json │ │ ├── uploader.wxss │ │ ├── uploader.js │ │ └── uploader.wxml │ ├── actionsheet │ │ ├── actionsheet.json │ │ ├── actionsheet.wxss │ │ ├── actionsheet.js │ │ └── actionsheet.wxml │ ├── images │ │ ├── logo.png │ │ ├── vcode.jpg │ │ ├── pic_160.png │ │ ├── icon_footer.png │ │ ├── icon_intro.png │ │ ├── icon_tabbar.png │ │ ├── pic_article.png │ │ ├── icon_nav_form.png │ │ ├── icon_nav_nav.png │ │ ├── icon_footer_link.png │ │ ├── icon_nav_search.png │ │ ├── icon_nav_special.png │ │ ├── icon_nav_widget.png │ │ ├── icon_nav_z-index.png │ │ ├── icon_nav_feedback.png │ │ └── base64.js │ ├── index.wxss │ ├── index.js │ └── index.wxml ├── drawguess │ ├── index.json │ ├── index.wxml │ └── index.wxss ├── index │ ├── index.json │ ├── index.wxml │ ├── index.wxss │ └── index.js ├── qcloud │ ├── index.json │ ├── index.wxml │ ├── index.wxss │ └── index.js ├── video │ ├── create │ │ ├── index.json │ │ ├── index.wxss │ │ ├── index.wxml │ │ └── index.js │ ├── detail │ │ ├── index.json │ │ ├── index.wxml │ │ ├── index.wxss │ │ └── index.js │ ├── index.json │ ├── index.wxml │ ├── index.wxss │ └── index.js ├── upload │ ├── index.json │ ├── index.wxml │ ├── index.js │ └── index.wxss ├── drawguessnew │ ├── index.json │ ├── index.wxml │ └── index.wxss └── todo │ ├── index.wxss │ ├── index.json │ ├── index.wxml │ └── index.js ├── README.md ├── jsconfig.json ├── package.json ├── vendor └── qcloud-weapp-client-sdk │ ├── lib │ ├── utils.js │ ├── session.js │ ├── constants.js │ ├── wxTunnel.js │ ├── request.js │ └── login.js │ ├── bower.json │ ├── index.js │ ├── .bower.json │ └── LICENSE ├── app.js ├── bower.json ├── config.js ├── app.wxss ├── LICENSE └── app.json /style/base/fn.wxss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pages/chat/chat.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/demo/index.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/index.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/demo/flex/index.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/drawguess/index.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/index/index.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/qcloud/index.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/flex/flex.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/grid/grid.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/list/list.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/msg/msg.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /style/base/mixin/text.wxss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pages/demo/float/index.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/video/create/index.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/video/detail/index.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/article/article.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/badge/badge.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/button/button.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/dialog/dialog.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/flex/flex.js: -------------------------------------------------------------------------------- 1 | Page({}); -------------------------------------------------------------------------------- /pages/weui/footer/footer.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/gallery/gallery.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/icons/icons.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/input/input.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/msg/msg_fail.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/msg/msg_success.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/navbar/navbar.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/panel/panel.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/picker/picker.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/preview/preview.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/slider/slider.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/tabbar/tabbar.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/toast/toast.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /style/base/mixin/setArrow.wxss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /style/base/mixin/setOnepx.wxss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /style/base/variable/color.wxss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /style/base/variable/global.wxss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /style/base/variable/weui-msg.wxss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pages/weui/article/article.js: -------------------------------------------------------------------------------- 1 | Page({}); -------------------------------------------------------------------------------- /pages/weui/badge/badge.js: -------------------------------------------------------------------------------- 1 | Page({}); -------------------------------------------------------------------------------- /pages/weui/button/button.js: -------------------------------------------------------------------------------- 1 | Page({}); -------------------------------------------------------------------------------- /pages/weui/footer/footer.js: -------------------------------------------------------------------------------- 1 | Page({}); -------------------------------------------------------------------------------- /pages/weui/gallery/gallery.js: -------------------------------------------------------------------------------- 1 | Page({}); -------------------------------------------------------------------------------- /pages/weui/icons/icons.js: -------------------------------------------------------------------------------- 1 | Page({}); -------------------------------------------------------------------------------- /pages/weui/loadmore/loadmore.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/msg/msg_fail.js: -------------------------------------------------------------------------------- 1 | Page({}); -------------------------------------------------------------------------------- /pages/weui/msg/msg_success.js: -------------------------------------------------------------------------------- 1 | Page({}); -------------------------------------------------------------------------------- /pages/weui/preview/preview.js: -------------------------------------------------------------------------------- 1 | Page({}); -------------------------------------------------------------------------------- /pages/weui/progress/progress.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/searchbar/searchbar.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/slider/slider.js: -------------------------------------------------------------------------------- 1 | Page({}); -------------------------------------------------------------------------------- /pages/weui/tabbar/tabbar.js: -------------------------------------------------------------------------------- 1 | Page({}); -------------------------------------------------------------------------------- /pages/weui/uploader/uploader.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /style/base/variable/weui-button.wxss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /style/base/variable/weui-cell.wxss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /style/base/variable/weui-dialog.wxss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /style/base/variable/weui-grid.wxss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /style/base/variable/weui-progress.wxss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pages/weui/actionsheet/actionsheet.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/weui/loadmore/loadmore.js: -------------------------------------------------------------------------------- 1 | Page({}); -------------------------------------------------------------------------------- /pages/weui/grid/grid.wxss: -------------------------------------------------------------------------------- 1 | /* pages/weui/grid/grid.wxss */ -------------------------------------------------------------------------------- /pages/weui/list/list.wxss: -------------------------------------------------------------------------------- 1 | /* pages/weui/list/list.wxss */ -------------------------------------------------------------------------------- /pages/weui/badge/badge.wxss: -------------------------------------------------------------------------------- 1 | /* pages/weui/badge/badge.wxss */ -------------------------------------------------------------------------------- /pages/weui/input/input.wxss: -------------------------------------------------------------------------------- 1 | /* pages/weui/input/input.wxss */ -------------------------------------------------------------------------------- /pages/weui/panel/panel.wxss: -------------------------------------------------------------------------------- 1 | /* pages/weui/panel/panel.wxss */ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wxa_drawguess 2 | 微信小程序-你画我猜 3 | > 后台基于腾讯云提供的小程序解决方案 4 | -------------------------------------------------------------------------------- /pages/video/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "enablePullDownRefresh": true 3 | } -------------------------------------------------------------------------------- /pages/weui/gallery/gallery.wxss: -------------------------------------------------------------------------------- 1 | /* pages/weui/gallery/gallery.wxss */ -------------------------------------------------------------------------------- /pages/weui/tabbar/tabbar.wxss: -------------------------------------------------------------------------------- 1 | /* pages/weui/tabbar/tabbar.wxss */ -------------------------------------------------------------------------------- /pages/weui/msg/msg.wxss: -------------------------------------------------------------------------------- 1 | page{ 2 | background-color: #FFFFFF; 3 | } -------------------------------------------------------------------------------- /pages/weui/slider/slider.wxss: -------------------------------------------------------------------------------- 1 | slider{ 2 | margin-bottom: 30px; 3 | } -------------------------------------------------------------------------------- /pages/weui/toast/toast.wxss: -------------------------------------------------------------------------------- 1 | page{ 2 | background-color: #FFFFFF; 3 | } -------------------------------------------------------------------------------- /pages/weui/uploader/uploader.wxss: -------------------------------------------------------------------------------- 1 | /* pages/weui/uploader/uploader.wxss */ -------------------------------------------------------------------------------- /pages/upload/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "图片" 3 | } 4 | -------------------------------------------------------------------------------- /pages/weui/dialog/dialog.wxss: -------------------------------------------------------------------------------- 1 | page{ 2 | background-color: #FFFFFF; 3 | } -------------------------------------------------------------------------------- /pages/weui/msg/msg_fail.wxss: -------------------------------------------------------------------------------- 1 | page{ 2 | background-color: #FFFFFF; 3 | } -------------------------------------------------------------------------------- /pages/weui/msg/msg_success.wxss: -------------------------------------------------------------------------------- 1 | page{ 2 | background-color: #FFFFFF; 3 | } -------------------------------------------------------------------------------- /pages/weui/picker/picker.wxss: -------------------------------------------------------------------------------- 1 | page{ 2 | background-color: #FFFFFF; 3 | } -------------------------------------------------------------------------------- /pages/weui/loadmore/loadmore.wxss: -------------------------------------------------------------------------------- 1 | page{ 2 | background-color: #FFFFFF; 3 | } -------------------------------------------------------------------------------- /pages/weui/progress/progress.wxss: -------------------------------------------------------------------------------- 1 | .weui-progress{ 2 | margin-bottom: 24px; 3 | } -------------------------------------------------------------------------------- /pages/weui/actionsheet/actionsheet.wxss: -------------------------------------------------------------------------------- 1 | page{ 2 | background-color: #FFFFFF; 3 | } -------------------------------------------------------------------------------- /pages/weui/preview/preview.wxss: -------------------------------------------------------------------------------- 1 | .weui-form-preview{ 2 | margin-bottom: 25px; 3 | } -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | 4 | }, 5 | "exclude": [ 6 | ] 7 | } -------------------------------------------------------------------------------- /pages/drawguessnew/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "enablePullDownRefresh": false, 3 | "disableScroll": true 4 | } -------------------------------------------------------------------------------- /pages/weui/grid/grid.js: -------------------------------------------------------------------------------- 1 | Page({ 2 | data: { 3 | grids: [0, 1, 2, 3, 4, 5, 6, 7, 8] 4 | } 5 | }); -------------------------------------------------------------------------------- /pages/weui/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasondu/wxa_drawguess/HEAD/pages/weui/images/logo.png -------------------------------------------------------------------------------- /pages/weui/images/vcode.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasondu/wxa_drawguess/HEAD/pages/weui/images/vcode.jpg -------------------------------------------------------------------------------- /pages/video/create/index.wxss: -------------------------------------------------------------------------------- 1 | /* pages/video/create/index.wxss */ 2 | .video-label video { 3 | width: 100%; 4 | } -------------------------------------------------------------------------------- /pages/weui/article/article.wxss: -------------------------------------------------------------------------------- 1 | page{ 2 | background-color: #FFFFFF; 3 | } 4 | image{ 5 | margin: 4px 0; 6 | } -------------------------------------------------------------------------------- /pages/weui/images/pic_160.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasondu/wxa_drawguess/HEAD/pages/weui/images/pic_160.png -------------------------------------------------------------------------------- /pages/weui/images/icon_footer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasondu/wxa_drawguess/HEAD/pages/weui/images/icon_footer.png -------------------------------------------------------------------------------- /pages/weui/images/icon_intro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasondu/wxa_drawguess/HEAD/pages/weui/images/icon_intro.png -------------------------------------------------------------------------------- /pages/weui/images/icon_tabbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasondu/wxa_drawguess/HEAD/pages/weui/images/icon_tabbar.png -------------------------------------------------------------------------------- /pages/weui/images/pic_article.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasondu/wxa_drawguess/HEAD/pages/weui/images/pic_article.png -------------------------------------------------------------------------------- /style/widget/weui-cell/weui-switch.wxss: -------------------------------------------------------------------------------- 1 | .weui-cell_switch { 2 | padding-top: 6px; 3 | padding-bottom: 6px; 4 | } 5 | -------------------------------------------------------------------------------- /pages/weui/images/icon_nav_form.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasondu/wxa_drawguess/HEAD/pages/weui/images/icon_nav_form.png -------------------------------------------------------------------------------- /pages/weui/images/icon_nav_nav.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasondu/wxa_drawguess/HEAD/pages/weui/images/icon_nav_nav.png -------------------------------------------------------------------------------- /pages/weui/images/icon_footer_link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasondu/wxa_drawguess/HEAD/pages/weui/images/icon_footer_link.png -------------------------------------------------------------------------------- /pages/weui/images/icon_nav_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasondu/wxa_drawguess/HEAD/pages/weui/images/icon_nav_search.png -------------------------------------------------------------------------------- /pages/weui/images/icon_nav_special.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasondu/wxa_drawguess/HEAD/pages/weui/images/icon_nav_special.png -------------------------------------------------------------------------------- /pages/weui/images/icon_nav_widget.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasondu/wxa_drawguess/HEAD/pages/weui/images/icon_nav_widget.png -------------------------------------------------------------------------------- /pages/weui/images/icon_nav_z-index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasondu/wxa_drawguess/HEAD/pages/weui/images/icon_nav_z-index.png -------------------------------------------------------------------------------- /pages/weui/images/icon_nav_feedback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasondu/wxa_drawguess/HEAD/pages/weui/images/icon_nav_feedback.png -------------------------------------------------------------------------------- /pages/demo/float/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /pages/todo/index.wxss: -------------------------------------------------------------------------------- 1 | /* pages/todo/index.wxss */ 2 | .input-label input { 3 | height: 100rpx; 4 | padding: 0 30rpx; 5 | background-color: #fff; 6 | } -------------------------------------------------------------------------------- /pages/weui/footer/footer.wxss: -------------------------------------------------------------------------------- 1 | /* 作为展示用的样式 */ 2 | 3 | .weui-footer{ 4 | margin-bottom: 50px; 5 | } 6 | .weui-footer_fixed-bottom{ 7 | margin-bottom: 0; 8 | } -------------------------------------------------------------------------------- /pages/weui/button/button.wxss: -------------------------------------------------------------------------------- 1 | .button-sp-area{ 2 | margin: 0 auto; 3 | padding-top: 15px; 4 | width: 60%; 5 | } 6 | .mini-btn{ 7 | margin-right: 5px; 8 | } -------------------------------------------------------------------------------- /style/base/reset.wxss: -------------------------------------------------------------------------------- 1 | page { 2 | line-height: 1.6; 3 | font-family: -apple-system-font, "Helvetica Neue", sans-serif; 4 | } 5 | icon { 6 | vertical-align: middle; 7 | } 8 | -------------------------------------------------------------------------------- /pages/weui/list/list.js: -------------------------------------------------------------------------------- 1 | var base64 = require("../images/base64"); 2 | Page({ 3 | onLoad: function(){ 4 | this.setData({ 5 | icon: base64.icon20 6 | }); 7 | } 8 | }); -------------------------------------------------------------------------------- /style/widget/weui-button/weui-button.wxss: -------------------------------------------------------------------------------- 1 | .weui-btn { 2 | margin-top: 15px; 3 | } 4 | .weui-btn:first-child { 5 | margin-top: 0; 6 | } 7 | .weui-btn-area { 8 | margin: 1.17647059em 15px 0.3em; 9 | } 10 | -------------------------------------------------------------------------------- /pages/weui/flex/flex.wxss: -------------------------------------------------------------------------------- 1 | .placeholder{ 2 | margin: 5px; 3 | padding: 0 10px; 4 | text-align: center; 5 | background-color: #EBEBEB; 6 | height: 2.3em; 7 | line-height: 2.3em; 8 | color: #cfcfcf; 9 | } -------------------------------------------------------------------------------- /pages/weui/navbar/navbar.wxss: -------------------------------------------------------------------------------- 1 | page, 2 | .page, 3 | .page__bd{ 4 | height: 100%; 5 | } 6 | .page__bd{ 7 | padding-bottom: 0; 8 | } 9 | .weui-tab__content{ 10 | padding-top: 60px; 11 | text-align: center; 12 | } -------------------------------------------------------------------------------- /pages/weui/searchbar/searchbar.wxss: -------------------------------------------------------------------------------- 1 | .searchbar-result{ 2 | margin-top: 0; 3 | font-size: 14px; 4 | } 5 | .searchbar-result:before{ 6 | display: none; 7 | } 8 | .weui-cell{ 9 | padding: 12px 15px 12px 35px; 10 | } -------------------------------------------------------------------------------- /pages/weui/gallery/gallery.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Gallery 4 | 画廊,建议采用小程序原生的wx.previewImage来实现。详情请看小程序文档。 5 | 6 | -------------------------------------------------------------------------------- /pages/weui/tabbar/tabbar.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Tabbar 4 | 底部导航,建议采用小程序原生的tabbar,通过设置app.json来实现。详情请看小程序文档。 5 | 6 | -------------------------------------------------------------------------------- /style/widget/weui-flex/weui-flex.wxss: -------------------------------------------------------------------------------- 1 | .weui-flex { 2 | display: -webkit-box; 3 | display: -webkit-flex; 4 | display: flex; 5 | } 6 | .weui-flex__item { 7 | -webkit-box-flex: 1; 8 | -webkit-flex: 1; 9 | flex: 1; 10 | } 11 | -------------------------------------------------------------------------------- /pages/weui/panel/panel.js: -------------------------------------------------------------------------------- 1 | var base64 = require("../images/base64"); 2 | 3 | Page({ 4 | onLoad: function(){ 5 | this.setData({ 6 | icon20: base64.icon20, 7 | icon60: base64.icon60 8 | }); 9 | } 10 | }); -------------------------------------------------------------------------------- /pages/weui/msg/msg.js: -------------------------------------------------------------------------------- 1 | Page({ 2 | openSuccess: function () { 3 | wx.navigateTo({ 4 | url: 'msg_success' 5 | }) 6 | }, 7 | openFail: function () { 8 | wx.navigateTo({ 9 | url: 'msg_fail' 10 | }) 11 | } 12 | }); -------------------------------------------------------------------------------- /pages/video/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /pages/todo/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarBackgroundColor": "#ffffff", 3 | "navigationBarTextStyle": "black", 4 | "navigationBarTitleText": "待办事项", 5 | "backgroundColor": "#ffffff", 6 | "backgroundTextStyle": "dark", 7 | "disableScroll": false, 8 | "enablePullDownRefresh": true 9 | } -------------------------------------------------------------------------------- /pages/weui/actionsheet/actionsheet.js: -------------------------------------------------------------------------------- 1 | Page({ 2 | open: function(){ 3 | wx.showActionSheet({ 4 | itemList: ['A', 'B', 'C'], 5 | success: function(res) { 6 | if (!res.cancel) { 7 | console.log(res.tapIndex) 8 | } 9 | } 10 | }); 11 | } 12 | }); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "qcloud-weapp-client-demo", 3 | "version": "1.0.0", 4 | "description": "腾讯云微信小程序客户端 DEMO", 5 | "main": "app.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/tencentyun/weapp-client-demo.git" 9 | }, 10 | "keywords": [], 11 | "author": "CFETeam", 12 | "license": "MIT" 13 | } 14 | -------------------------------------------------------------------------------- /pages/weui/slider/slider.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Slider 4 | 滑块,这里采用小程序原生的slider。 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /pages/video/detail/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /pages/weui/toast/toast.js: -------------------------------------------------------------------------------- 1 | Page({ 2 | openToast: function () { 3 | wx.showToast({ 4 | title: '已完成', 5 | icon: 'success', 6 | duration: 3000 7 | }); 8 | }, 9 | openLoading: function () { 10 | wx.showToast({ 11 | title: '数据加载中', 12 | icon: 'loading', 13 | duration: 3000 14 | }); 15 | } 16 | }); -------------------------------------------------------------------------------- /pages/weui/actionsheet/actionsheet.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ActionSheet 4 | 弹出式菜单,采用小程序原生的actionsheet 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /style/widget/weui-progress/weui-progress.wxss: -------------------------------------------------------------------------------- 1 | .weui-progress { 2 | display: -webkit-box; 3 | display: -webkit-flex; 4 | display: flex; 5 | -webkit-box-align: center; 6 | -webkit-align-items: center; 7 | align-items: center; 8 | } 9 | .weui-progress__bar { 10 | -webkit-box-flex: 1; 11 | -webkit-flex: 1; 12 | flex: 1; 13 | } 14 | .weui-progress__opr { 15 | margin-left: 15px; 16 | font-size: 0; 17 | } 18 | -------------------------------------------------------------------------------- /pages/demo/float/index.wxss: -------------------------------------------------------------------------------- 1 | .box { 2 | border: 1px solid #000; 3 | } 4 | .box_1 { 5 | background-color: rebeccapurple; 6 | } 7 | .box_2 { 8 | background-color: blueviolet; 9 | } 10 | .float { 11 | width: 300rpx; 12 | height: 300rpx; 13 | float: left; 14 | } 15 | .box::after { 16 | content:"."; 17 | display:block; 18 | height:0; 19 | clear:both; 20 | visibility:hidden; 21 | } -------------------------------------------------------------------------------- /pages/weui/msg/msg.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Msg 4 | 提示页 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /vendor/qcloud-weapp-client-sdk/lib/utils.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * 拓展对象 4 | */ 5 | exports.extend = function extend(target) { 6 | var sources = Array.prototype.slice.call(arguments, 1); 7 | 8 | for (var i = 0; i < sources.length; i += 1) { 9 | var source = sources[i]; 10 | for (var key in source) { 11 | if (source.hasOwnProperty(key)) { 12 | target[key] = source[key]; 13 | } 14 | } 15 | } 16 | 17 | return target; 18 | }; -------------------------------------------------------------------------------- /pages/weui/toast/toast.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Toast 4 | 弹出式提示,采用小程序原生的toast 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /vendor/qcloud-weapp-client-sdk/lib/session.js: -------------------------------------------------------------------------------- 1 | var constants = require('./constants'); 2 | var SESSION_KEY = 'weapp_session_' + constants.WX_SESSION_MAGIC_ID; 3 | 4 | var Session = { 5 | get: function () { 6 | return wx.getStorageSync(SESSION_KEY) || null; 7 | }, 8 | 9 | set: function (session) { 10 | wx.setStorageSync(SESSION_KEY, session); 11 | }, 12 | 13 | clear: function () { 14 | wx.removeStorageSync(SESSION_KEY); 15 | }, 16 | }; 17 | 18 | module.exports = Session; -------------------------------------------------------------------------------- /pages/weui/dialog/dialog.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Dialog 4 | 对话框,采用小程序原生的modal 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /style/widget/weui-cell/weui-check.wxss: -------------------------------------------------------------------------------- 1 | .weui-icon-radio { 2 | margin-left: 3.2px; 3 | margin-right: 3.2px; 4 | } 5 | .weui-icon-checkbox_circle, 6 | .weui-icon-checkbox_success { 7 | margin-left: 4.6px; 8 | margin-right: 4.6px; 9 | } 10 | .weui-check__label:active { 11 | background-color: #ECECEC; 12 | } 13 | .weui-check { 14 | position: absolute; 15 | left: -9999px; 16 | } 17 | .weui-check__hd_in-checkbox { 18 | padding-right: 0.35em; 19 | } 20 | .weui-cell__ft_in-radio { 21 | padding-left: 0.35em; 22 | } 23 | -------------------------------------------------------------------------------- /pages/video/detail/index.wxss: -------------------------------------------------------------------------------- 1 | /* pages/video/index.wxss */ 2 | .video-label video { 3 | width: 100%; 4 | } 5 | .input-label { 6 | padding: 10rpx; 7 | display: flex; 8 | } 9 | .input-label input { 10 | flex: 1; 11 | background-color: #fff; 12 | border: 1rpx solid #ccc; 13 | height: 80rpx; 14 | border-radius: 10rpx; 15 | padding: 0 10rpx; 16 | } 17 | .input-label button { 18 | width: 200rpx; 19 | height: 80rpx; 20 | line-height: 80rpx; 21 | border: 1rpx solid #ccc; 22 | margin-left: 10rpx; 23 | } -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileOverview 微信小程序的入口文件 3 | */ 4 | 5 | var qcloud = require('./vendor/qcloud-weapp-client-sdk/index'); 6 | var config = require('./config'); 7 | 8 | var AV = require('./libs/av-weapp-min.js'); 9 | 10 | App({ 11 | /** 12 | * 小程序初始化时执行,我们初始化客户端的登录地址,以支持所有的会话操作 13 | */ 14 | onLaunch() { 15 | qcloud.setLoginUrl(config.service.loginUrl); 16 | AV.init({ 17 | appId: 'I0j7ktVKS8It7VRU8iEfQF2f-gzGzoHsz', 18 | appKey: 'HQnWJgW74MBMDCB7Es43nzQy', 19 | }); 20 | } 21 | }); -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "qcloud-weapp-client-demo", 3 | "description": "QCloud Wechat App Demo", 4 | "main": "app.js", 5 | "authors": [ 6 | "Tencent Clound" 7 | ], 8 | "license": "MIT", 9 | "keywords": [ 10 | "qcloud", 11 | "wechat", 12 | "weapp", 13 | "demo", 14 | "sdk" 15 | ], 16 | "homepage": "", 17 | "ignore": [ 18 | "**/.*", 19 | "node_modules", 20 | "bower_components", 21 | "test", 22 | "tests" 23 | ], 24 | "dependencies": { 25 | "qcloud-weapp-client-sdk": "*" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 小程序配置文件 3 | */ 4 | 5 | // 此处主机域名修改成腾讯云解决方案分配的域名 6 | var host = '32102523.ddgggww.com'; 7 | 8 | var config = { 9 | 10 | // 下面的地址配合云端 Demo 工作 11 | service: { 12 | host, 13 | 14 | // 登录地址,用于建立会话 15 | loginUrl: `https://${host}/login`, 16 | 17 | // 测试的请求地址,用于测试会话 18 | requestUrl: `https://${host}/user`, 19 | 20 | // 测试的信道服务地址 21 | tunnelUrl: `https://${host}/tunnel`, 22 | 23 | uploadUrl: `https://${host}/cos`, 24 | } 25 | }; 26 | 27 | module.exports = config; -------------------------------------------------------------------------------- /style/widget/weui-page/weui-article.wxss: -------------------------------------------------------------------------------- 1 | .weui-article { 2 | padding: 20px 15px; 3 | font-size: 15px; 4 | } 5 | .weui-article__section { 6 | margin-bottom: 1.5em; 7 | } 8 | .weui-article__h1 { 9 | font-size: 18px; 10 | font-weight: 400; 11 | margin-bottom: .9em; 12 | } 13 | .weui-article__h2 { 14 | font-size: 16px; 15 | font-weight: 400; 16 | margin-bottom: .34em; 17 | } 18 | .weui-article__h3 { 19 | font-weight: 400; 20 | font-size: 15px; 21 | margin-bottom: .34em; 22 | } 23 | .weui-article__p { 24 | margin: 0 0 .8em; 25 | } 26 | -------------------------------------------------------------------------------- /pages/weui/icons/icons.wxss: -------------------------------------------------------------------------------- 1 | icon{ 2 | margin-right: 13px; 3 | } 4 | .page__bd { 5 | padding-left: 40px; 6 | padding-right: 40px; 7 | text-align: left; 8 | } 9 | .icon-box{ 10 | margin-bottom: 25px; 11 | display: flex; 12 | align-items: center; 13 | } 14 | .icon-box__ctn{ 15 | flex-shrink: 100; 16 | } 17 | .icon-box__title{ 18 | font-size: 20px; 19 | } 20 | .icon-box__desc{ 21 | margin-top: 6px; 22 | font-size: 12px; 23 | color: #888888; 24 | } 25 | .icon_sp_area { 26 | margin-top: 10px; 27 | text-align: left; 28 | } -------------------------------------------------------------------------------- /pages/demo/index.js: -------------------------------------------------------------------------------- 1 | Page({ 2 | data: { 3 | 4 | }, 5 | onLoad: function(options) { 6 | //Do some initialize when page load. 7 | 8 | }, 9 | onReady: function() { 10 | //Do some when page ready. 11 | 12 | }, 13 | onShow: function() { 14 | //Do some when page show. 15 | 16 | }, 17 | onHide: function() { 18 | //Do some when page hide. 19 | 20 | }, 21 | onUnload: function() { 22 | //Do some when page unload. 23 | 24 | }, 25 | onPullDownRefresh: function() { 26 | //Do some when page pull down. 27 | 28 | } 29 | }) -------------------------------------------------------------------------------- /style/widget/weui-cell/weui-form/weui-vcode.wxss: -------------------------------------------------------------------------------- 1 | .weui-cell_vcode { 2 | padding-right: 0; 3 | } 4 | .weui-vcode-img { 5 | margin-left: 5px; 6 | height: 2.58823529em; 7 | vertical-align: middle; 8 | } 9 | .weui-vcode-btn { 10 | display: inline-block; 11 | height: 2.58823529em; 12 | margin-left: 5px; 13 | padding: 0 0.6em 0 0.7em; 14 | border-left: 1px solid #E5E5E5; 15 | line-height: 2.58823529em; 16 | vertical-align: middle; 17 | font-size: 17px; 18 | color: #3CC51F; 19 | white-space: nowrap; 20 | } 21 | .weui-vcode-btn:active { 22 | color: #52a341; 23 | } 24 | -------------------------------------------------------------------------------- /pages/demo/flex/index.js: -------------------------------------------------------------------------------- 1 | Page({ 2 | data: { 3 | 4 | }, 5 | onLoad: function(options) { 6 | //Do some initialize when page load. 7 | 8 | }, 9 | onReady: function() { 10 | //Do some when page ready. 11 | 12 | }, 13 | onShow: function() { 14 | //Do some when page show. 15 | 16 | }, 17 | onHide: function() { 18 | //Do some when page hide. 19 | 20 | }, 21 | onUnload: function() { 22 | //Do some when page unload. 23 | 24 | }, 25 | onPullDownRefresh: function() { 26 | //Do some when page pull down. 27 | 28 | } 29 | }) -------------------------------------------------------------------------------- /pages/demo/float/index.js: -------------------------------------------------------------------------------- 1 | Page({ 2 | data: { 3 | 4 | }, 5 | onLoad: function(options) { 6 | //Do some initialize when page load. 7 | 8 | }, 9 | onReady: function() { 10 | //Do some when page ready. 11 | 12 | }, 13 | onShow: function() { 14 | //Do some when page show. 15 | 16 | }, 17 | onHide: function() { 18 | //Do some when page hide. 19 | 20 | }, 21 | onUnload: function() { 22 | //Do some when page unload. 23 | 24 | }, 25 | onPullDownRefresh: function() { 26 | //Do some when page pull down. 27 | 28 | } 29 | }) -------------------------------------------------------------------------------- /pages/weui/picker/picker.js: -------------------------------------------------------------------------------- 1 | Page({ 2 | data: { 3 | array: ['美国', '中国', '巴西', '日本'], 4 | index: 0, 5 | date: '2016-09-01', 6 | time: '12:01' 7 | }, 8 | bindPickerChange: function(e) { 9 | console.log('picker发送选择改变,携带值为', e.detail.value) 10 | this.setData({ 11 | index: e.detail.value 12 | }) 13 | }, 14 | bindDateChange: function(e) { 15 | this.setData({ 16 | date: e.detail.value 17 | }) 18 | }, 19 | bindTimeChange: function(e) { 20 | this.setData({ 21 | time: e.detail.value 22 | }) 23 | } 24 | }); -------------------------------------------------------------------------------- /pages/demo/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | flex 4 | 5 | 6 | 7 | float 8 | 9 | 10 | -------------------------------------------------------------------------------- /pages/weui/searchbar/searchbar.js: -------------------------------------------------------------------------------- 1 | Page({ 2 | data: { 3 | inputShowed: false, 4 | inputVal: "" 5 | }, 6 | showInput: function () { 7 | this.setData({ 8 | inputShowed: true 9 | }); 10 | }, 11 | hideInput: function () { 12 | this.setData({ 13 | inputVal: "", 14 | inputShowed: false 15 | }); 16 | }, 17 | clearInput: function () { 18 | this.setData({ 19 | inputVal: "" 20 | }); 21 | }, 22 | inputTyping: function (e) { 23 | this.setData({ 24 | inputVal: e.detail.value 25 | }); 26 | } 27 | }); -------------------------------------------------------------------------------- /pages/weui/grid/grid.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Grid 4 | 九宫格 5 | 6 | 7 | 8 | 9 | 10 | 11 | Grid 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /pages/video/index.wxss: -------------------------------------------------------------------------------- 1 | /* pages/video/index.wxss */ 2 | .image-label { 3 | line-height: 0; 4 | } 5 | .image-label image { 6 | width: 100%; 7 | } 8 | .input-label { 9 | padding: 10rpx; 10 | display: flex; 11 | } 12 | .input-label input { 13 | flex: 1; 14 | background-color: #fff; 15 | border: 1rpx solid #ccc; 16 | height: 80rpx; 17 | border-radius: 10rpx; 18 | padding: 0 10rpx; 19 | } 20 | .input-label button { 21 | width: 200rpx; 22 | height: 80rpx; 23 | line-height: 80rpx; 24 | border: 1rpx solid #ccc; 25 | margin-left: 10rpx; 26 | } 27 | .take-btn { 28 | position: fixed; 29 | bottom: 0; 30 | width: 100%; 31 | } -------------------------------------------------------------------------------- /vendor/qcloud-weapp-client-sdk/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "qcloud-weapp-client-sdk", 3 | "description": "QCloud 微信小程序客户端 SDK", 4 | "main": "index.js", 5 | "authors": [ 6 | "Tencent Cloud" 7 | ], 8 | "license": "MIT", 9 | "keywords": [ 10 | "qcloud", 11 | "weapp", 12 | "wechat", 13 | "sdk", 14 | "client", 15 | "auth", 16 | "websocket" 17 | ], 18 | "homepage": "", 19 | "ignore": [ 20 | "**/.*", 21 | "node_modules", 22 | "bower_components", 23 | "test", 24 | "tests", 25 | "typings.json", 26 | "jsconfig.json", 27 | "package.json", 28 | ".npmignore", 29 | ".travis.yml", 30 | ".gitignore" 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /style/widget/weui-agree/weui-agree.wxss: -------------------------------------------------------------------------------- 1 | .weui-agree { 2 | display: block; 3 | padding: .5em 15px; 4 | font-size: 13px; 5 | } 6 | .weui-agree__text { 7 | color: #999999; 8 | } 9 | .weui-agree__link { 10 | display: inline; 11 | color: #586C94; 12 | } 13 | .weui-agree__checkbox { 14 | position: absolute; 15 | left: -9999px; 16 | } 17 | .weui-agree__checkbox-icon { 18 | position: relative; 19 | top: 2px; 20 | display: inline-block; 21 | border: 1px solid #D1D1D1; 22 | background-color: #FFFFFF; 23 | border-radius: 3px; 24 | width: 11px; 25 | height: 11px; 26 | } 27 | .weui-agree__checkbox-icon-check { 28 | position: absolute; 29 | top: 1px; 30 | left: 1px; 31 | } 32 | -------------------------------------------------------------------------------- /app.wxss: -------------------------------------------------------------------------------- 1 | @import 'style/weui.wxss'; 2 | 3 | page{ 4 | background-color: #F8F8F8; 5 | font-size: 16px; 6 | font-family: -apple-system-font,Helvetica Neue,Helvetica,sans-serif; 7 | } 8 | .page__hd { 9 | padding: 40px; 10 | } 11 | .page__bd { 12 | padding-bottom: 40px; 13 | } 14 | .page__bd_spacing { 15 | padding-left: 15px; 16 | padding-right: 15px; 17 | } 18 | 19 | .page__ft{ 20 | padding-bottom: 10px; 21 | text-align: center; 22 | } 23 | 24 | .page__title { 25 | text-align: left; 26 | font-size: 20px; 27 | font-weight: 400; 28 | } 29 | 30 | .page__desc { 31 | margin-top: 5px; 32 | color: #888888; 33 | text-align: left; 34 | font-size: 14px; 35 | } -------------------------------------------------------------------------------- /pages/weui/progress/progress.js: -------------------------------------------------------------------------------- 1 | function _next(){ 2 | var that = this; 3 | if(this.data.progress >= 100){ 4 | this.setData({ 5 | disabled: false 6 | }); 7 | return true; 8 | } 9 | this.setData({ 10 | progress: ++this.data.progress 11 | }); 12 | setTimeout(function(){ 13 | _next.call(that); 14 | }, 20); 15 | } 16 | 17 | Page({ 18 | data: { 19 | progress: 0, 20 | disabled: false 21 | }, 22 | upload: function(){ 23 | if(this.data.disabled) return; 24 | 25 | this.setData({ 26 | progress: 0, 27 | disabled: true 28 | }); 29 | _next.call(this); 30 | } 31 | }); -------------------------------------------------------------------------------- /vendor/qcloud-weapp-client-sdk/index.js: -------------------------------------------------------------------------------- 1 | var constants = require('./lib/constants'); 2 | var login = require('./lib/login'); 3 | var Session = require('./lib/session'); 4 | var request = require('./lib/request'); 5 | var Tunnel = require('./lib/tunnel'); 6 | 7 | var exports = module.exports = { 8 | login: login.login, 9 | setLoginUrl: login.setLoginUrl, 10 | LoginError: login.LoginError, 11 | 12 | clearSession: Session.clear, 13 | 14 | request: request.request, 15 | RequestError: request.RequestError, 16 | 17 | Tunnel: Tunnel, 18 | }; 19 | 20 | // 导出错误类型码 21 | Object.keys(constants).forEach(function (key) { 22 | if (key.indexOf('ERR_') === 0) { 23 | exports[key] = constants[key]; 24 | } 25 | }); -------------------------------------------------------------------------------- /pages/weui/navbar/navbar.js: -------------------------------------------------------------------------------- 1 | var sliderWidth = 96; // 需要设置slider的宽度,用于计算中间位置 2 | 3 | Page({ 4 | data: { 5 | tabs: ["选项一", "选项二", "选项三"], 6 | activeIndex: "0", 7 | sliderOffset: 0, 8 | sliderLeft: 0 9 | }, 10 | onLoad: function () { 11 | var that = this; 12 | wx.getSystemInfo({ 13 | success: function(res) { 14 | that.setData({ 15 | sliderLeft: (res.windowWidth / that.data.tabs.length - sliderWidth) / 2 16 | }); 17 | } 18 | }); 19 | }, 20 | tabClick: function (e) { 21 | this.setData({ 22 | sliderOffset: e.currentTarget.offsetLeft, 23 | activeIndex: e.currentTarget.id 24 | }); 25 | } 26 | }); -------------------------------------------------------------------------------- /style/widget/weui-grid/weui-grid.wxss: -------------------------------------------------------------------------------- 1 | .weui-grids { 2 | border-top: 1rpx solid #D9D9D9; 3 | border-left: 1rpx solid #D9D9D9; 4 | } 5 | .weui-grid { 6 | position: relative; 7 | float: left; 8 | padding: 20px 10px; 9 | width: 33.33333333%; 10 | box-sizing: border-box; 11 | border-right: 1rpx solid #D9D9D9; 12 | border-bottom: 1rpx solid #D9D9D9; 13 | } 14 | .weui-grid_active { 15 | background-color: #ECECEC; 16 | } 17 | .weui-grid__icon { 18 | display: block; 19 | width: 28px; 20 | height: 28px; 21 | margin: 0 auto; 22 | } 23 | .weui-grid__label { 24 | margin-top: 5px; 25 | display: block; 26 | text-align: center; 27 | color: #000000; 28 | font-size: 14px; 29 | white-space: nowrap; 30 | text-overflow: ellipsis; 31 | overflow: hidden; 32 | } 33 | -------------------------------------------------------------------------------- /vendor/qcloud-weapp-client-sdk/lib/constants.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | WX_HEADER_CODE: 'X-WX-Code', 3 | WX_HEADER_ENCRYPTED_DATA: 'X-WX-Encrypted-Data', 4 | WX_HEADER_IV: 'X-WX-IV', 5 | WX_HEADER_ID: 'X-WX-Id', 6 | WX_HEADER_SKEY: 'X-WX-Skey', 7 | 8 | WX_SESSION_MAGIC_ID: 'F2C224D4-2BCE-4C64-AF9F-A6D872000D1A', 9 | 10 | ERR_INVALID_PARAMS: 'ERR_INVALID_PARAMS', 11 | 12 | ERR_WX_LOGIN_FAILED: 'ERR_WX_LOGIN_FAILED', 13 | ERR_WX_GET_USER_INFO: 'ERR_WX_GET_USER_INFO', 14 | ERR_LOGIN_TIMEOUT: 'ERR_LOGIN_TIMEOUT', 15 | ERR_LOGIN_FAILED: 'ERR_LOGIN_FAILED', 16 | ERR_LOGIN_SESSION_NOT_RECEIVED: 'ERR_LOGIN_MISSING_SESSION', 17 | 18 | ERR_INVALID_SESSION: 'ERR_INVALID_SESSION', 19 | ERR_CHECK_LOGIN_FAILED: 'ERR_CHECK_LOGIN_FAILED', 20 | }; -------------------------------------------------------------------------------- /pages/weui/loadmore/loadmore.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Loadmore 4 | 加载更多 5 | 6 | 7 | 8 | 9 | 正在加载 10 | 11 | 12 | 暂无数据 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /pages/weui/uploader/uploader.js: -------------------------------------------------------------------------------- 1 | Page({ 2 | data: { 3 | files: [] 4 | }, 5 | chooseImage: function (e) { 6 | var that = this; 7 | wx.chooseImage({ 8 | sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 9 | sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 10 | success: function (res) { 11 | // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片 12 | that.setData({ 13 | files: that.data.files.concat(res.tempFilePaths) 14 | }); 15 | } 16 | }) 17 | }, 18 | previewImage: function(e){ 19 | wx.previewImage({ 20 | current: e.currentTarget.id, // 当前显示图片的http链接 21 | urls: this.data.files // 需要预览的图片http链接列表 22 | }) 23 | } 24 | }); -------------------------------------------------------------------------------- /style/widget/weui-cell/weui-access.wxss: -------------------------------------------------------------------------------- 1 | .weui-cell_access { 2 | color: inherit; 3 | } 4 | .weui-cell__ft_in-access { 5 | padding-right: 13px; 6 | position: relative; 7 | } 8 | .weui-cell__ft_in-access:after { 9 | content: " "; 10 | display: inline-block; 11 | height: 6px; 12 | width: 6px; 13 | border-width: 2px 2px 0 0; 14 | border-color: #C8C8CD; 15 | border-style: solid; 16 | -webkit-transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0); 17 | transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0); 18 | position: relative; 19 | top: -2px; 20 | position: absolute; 21 | top: 50%; 22 | margin-top: -4px; 23 | right: 2px; 24 | } 25 | .weui-cell_link { 26 | color: #586C94; 27 | font-size: 14px; 28 | } 29 | .weui-cell_link:active { 30 | background-color: #ECECEC; 31 | } 32 | .weui-cell_link:first-child:before { 33 | display: block; 34 | } 35 | -------------------------------------------------------------------------------- /pages/demo/index.wxss: -------------------------------------------------------------------------------- 1 | page { 2 | height: 100%; 3 | } 4 | .y-box { 5 | height: 100%; 6 | display: flex; 7 | flex-direction: column; 8 | background-color: #ccc; 9 | } 10 | .y-box .box-item { 11 | flex: 1; 12 | background-color: #f8777b; 13 | } 14 | .y-box .box-custom { 15 | height: 750rpx; 16 | background-color: brown; 17 | } 18 | .y-box .box-scroll { 19 | width: 750rpx; 20 | height: 300rpx; 21 | background-color: bisque; 22 | } 23 | .y-box .box-footer { 24 | height: 100rpx; 25 | } 26 | 27 | .x-box { 28 | width: 750rpx; 29 | display: flex; 30 | flex-direction: row; /*默认*/ 31 | } 32 | .x-box .box-item { 33 | flex: 1; 34 | background: rebeccapurple; 35 | } 36 | .x-box .box-custom-2 { 37 | width: 200rpx; 38 | background-color: lightblue; 39 | } 40 | /***********/ 41 | .test-label { 42 | height: 750rpx; 43 | } -------------------------------------------------------------------------------- /style/widget/weui-page/weui-msg.wxss: -------------------------------------------------------------------------------- 1 | .weui-msg { 2 | padding-top: 36px; 3 | text-align: center; 4 | } 5 | .weui-msg__link { 6 | display: inline; 7 | color: #586C94; 8 | } 9 | .weui-msg__icon-area { 10 | margin-bottom: 30px; 11 | } 12 | .weui-msg__text-area { 13 | margin-bottom: 25px; 14 | padding: 0 20px; 15 | } 16 | .weui-msg__title { 17 | margin-bottom: 5px; 18 | font-weight: 400; 19 | font-size: 20px; 20 | } 21 | .weui-msg__desc { 22 | font-size: 14px; 23 | color: #999999; 24 | } 25 | .weui-msg__opr-area { 26 | margin-bottom: 25px; 27 | } 28 | .weui-msg__extra-area { 29 | margin-bottom: 15px; 30 | font-size: 14px; 31 | color: #999999; 32 | } 33 | @media screen and (min-height: 438px) { 34 | .weui-msg__extra-area { 35 | position: fixed; 36 | left: 0; 37 | bottom: 0; 38 | width: 100%; 39 | text-align: center; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /pages/demo/flex/index.wxss: -------------------------------------------------------------------------------- 1 | page { 2 | height: 100%; 3 | } 4 | .y-box { 5 | height: 100%; 6 | display: flex; 7 | flex-direction: column; 8 | background-color: #ccc; 9 | } 10 | .y-box .box-item { 11 | flex: 1; 12 | background-color: #f8777b; 13 | } 14 | .y-box .box-custom { 15 | height: 750rpx; 16 | background-color: brown; 17 | } 18 | .y-box .box-scroll { 19 | width: 750rpx; 20 | height: 300rpx; 21 | background-color: bisque; 22 | } 23 | .y-box .box-footer { 24 | height: 100rpx; 25 | } 26 | 27 | .x-box { 28 | width: 750rpx; 29 | display: flex; 30 | flex-direction: row; /*默认*/ 31 | } 32 | .x-box .box-item { 33 | flex: 1; 34 | background: rebeccapurple; 35 | } 36 | .x-box .box-custom-2 { 37 | width: 200rpx; 38 | background-color: lightblue; 39 | } 40 | /***********/ 41 | .test-label { 42 | height: 750rpx; 43 | } -------------------------------------------------------------------------------- /vendor/qcloud-weapp-client-sdk/lib/wxTunnel.js: -------------------------------------------------------------------------------- 1 | /* istanbul ignore next */ 2 | const noop = () => void(0); 3 | 4 | let onOpen, onClose, onMessage, onError; 5 | 6 | /* istanbul ignore next */ 7 | function listen(listener) { 8 | if (listener) { 9 | onOpen = listener.onOpen; 10 | onClose = listener.onClose; 11 | onMessage = listener.onMessage; 12 | onError = listener.onError; 13 | } else { 14 | onOpen = noop; 15 | onClose = noop; 16 | onMessage = noop; 17 | onError = noop; 18 | } 19 | } 20 | 21 | /* istanbul ignore next */ 22 | function bind() { 23 | wx.onSocketOpen(result => onOpen(result)); 24 | wx.onSocketClose(result => onClose(result)); 25 | wx.onSocketMessage(result => onMessage(result)); 26 | wx.onSocketError(error => onError(error)); 27 | } 28 | 29 | listen(null); 30 | bind(); 31 | 32 | module.exports = { listen }; -------------------------------------------------------------------------------- /style/widget/weui-footer/weui-footer.wxss: -------------------------------------------------------------------------------- 1 | .weui-footer { 2 | color: #999999; 3 | font-size: 14px; 4 | text-align: center; 5 | } 6 | .weui-footer_fixed-bottom { 7 | position: fixed; 8 | bottom: .52em; 9 | left: 0; 10 | right: 0; 11 | } 12 | .weui-footer__links { 13 | font-size: 0; 14 | } 15 | .weui-footer__link { 16 | display: inline-block; 17 | vertical-align: top; 18 | margin: 0 .62em; 19 | position: relative; 20 | font-size: 14px; 21 | color: #586C94; 22 | } 23 | .weui-footer__link:before { 24 | content: " "; 25 | position: absolute; 26 | left: 0; 27 | top: 0; 28 | width: 1px; 29 | bottom: 0; 30 | border-left: 1rpx solid #C7C7C7; 31 | color: #C7C7C7; 32 | left: -0.65em; 33 | top: .36em; 34 | bottom: .36em; 35 | } 36 | .weui-footer__link:first-child:before { 37 | display: none; 38 | } 39 | .weui-footer__text { 40 | padding: 0 .34em; 41 | font-size: 12px; 42 | } 43 | -------------------------------------------------------------------------------- /pages/weui/dialog/dialog.js: -------------------------------------------------------------------------------- 1 | Page({ 2 | openConfirm: function () { 3 | wx.showModal({ 4 | title: '弹窗标题', 5 | content: '弹窗内容,告知当前状态、信息和解决方法,描述文字尽量控制在三行内', 6 | confirmText: "主操作", 7 | cancelText: "辅助操作", 8 | success: function (res) { 9 | console.log(res); 10 | if (res.confirm) { 11 | console.log('用户点击主操作') 12 | }else{ 13 | console.log('用户点击辅助操作') 14 | } 15 | } 16 | }); 17 | }, 18 | openAlert: function () { 19 | wx.showModal({ 20 | content: '弹窗内容,告知当前状态、信息和解决方法,描述文字尽量控制在三行内', 21 | showCancel: false, 22 | success: function (res) { 23 | if (res.confirm) { 24 | console.log('用户点击确定') 25 | } 26 | } 27 | }); 28 | } 29 | }); -------------------------------------------------------------------------------- /pages/weui/picker/picker.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Picker 4 | 选择器,这里使用小程序原生的picker。 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /style/widget/weui-tips/weui-loadmore.wxss: -------------------------------------------------------------------------------- 1 | .weui-loadmore { 2 | width: 65%; 3 | margin: 1.5em auto; 4 | line-height: 1.6em; 5 | font-size: 14px; 6 | text-align: center; 7 | } 8 | .weui-loadmore__tips { 9 | display: inline-block; 10 | vertical-align: middle; 11 | } 12 | .weui-loadmore_line { 13 | border-top: 1px solid #E5E5E5; 14 | margin-top: 2.4em; 15 | } 16 | .weui-loadmore__tips_in-line { 17 | position: relative; 18 | top: -0.9em; 19 | padding: 0 .55em; 20 | background-color: #FFFFFF; 21 | color: #999999; 22 | } 23 | .weui-loadmore__tips_in-dot { 24 | position: relative; 25 | padding: 0 .16em; 26 | width: 4px; 27 | height: 1.6em; 28 | } 29 | .weui-loadmore__tips_in-dot:before { 30 | content: " "; 31 | position: absolute; 32 | top: 50%; 33 | left: 50%; 34 | margin-top: -1px; 35 | margin-left: -2px; 36 | width: 4px; 37 | height: 4px; 38 | border-radius: 50%; 39 | background-color: #E5E5E5; 40 | } 41 | -------------------------------------------------------------------------------- /style/widget/weui-cell/weui-form/weui-select.wxss: -------------------------------------------------------------------------------- 1 | .weui-cell_select { 2 | padding: 0; 3 | } 4 | .weui-select { 5 | position: relative; 6 | padding-left: 15px; 7 | padding-right: 30px; 8 | height: 2.58823529em; 9 | min-height: 2.58823529em; 10 | line-height: 2.58823529em; 11 | border-right: 1rpx solid #D9D9D9; 12 | } 13 | .weui-select:before { 14 | content: " "; 15 | display: inline-block; 16 | height: 6px; 17 | width: 6px; 18 | border-width: 2px 2px 0 0; 19 | border-color: #C8C8CD; 20 | border-style: solid; 21 | -webkit-transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0); 22 | transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0); 23 | position: relative; 24 | top: -2px; 25 | position: absolute; 26 | top: 50%; 27 | right: 15px; 28 | margin-top: -4px; 29 | } 30 | .weui-select_in-select-after { 31 | padding-left: 0; 32 | } 33 | .weui-cell__hd_in-select-after, 34 | .weui-cell__bd_in-select-before { 35 | padding-left: 15px; 36 | } 37 | -------------------------------------------------------------------------------- /pages/index/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 综合示例 4 | 5 | 样式问题 6 | weui 7 | 8 | 你猜我画 9 | 10 | 视频 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /style/widget/weui-panel/weui-panel.wxss: -------------------------------------------------------------------------------- 1 | .weui-panel { 2 | background-color: #FFFFFF; 3 | margin-top: 10px; 4 | position: relative; 5 | overflow: hidden; 6 | } 7 | .weui-panel:first-child { 8 | margin-top: 0; 9 | } 10 | .weui-panel:before { 11 | content: " "; 12 | position: absolute; 13 | left: 0; 14 | top: 0; 15 | right: 0; 16 | height: 1px; 17 | border-top: 1rpx solid #E5E5E5; 18 | color: #E5E5E5; 19 | } 20 | .weui-panel:after { 21 | content: " "; 22 | position: absolute; 23 | left: 0; 24 | bottom: 0; 25 | right: 0; 26 | height: 1px; 27 | border-bottom: 1rpx solid #E5E5E5; 28 | color: #E5E5E5; 29 | } 30 | .weui-panel__hd { 31 | padding: 14px 15px 10px; 32 | color: #999999; 33 | font-size: 13px; 34 | position: relative; 35 | } 36 | .weui-panel__hd:after { 37 | content: " "; 38 | position: absolute; 39 | left: 0; 40 | bottom: 0; 41 | right: 0; 42 | height: 1px; 43 | border-bottom: 1rpx solid #E5E5E5; 44 | color: #E5E5E5; 45 | left: 15px; 46 | } 47 | -------------------------------------------------------------------------------- /style/widget/weui-cell/weui-form/weui-form_common.wxss: -------------------------------------------------------------------------------- 1 | .weui-cell_input { 2 | padding-top: 0; 3 | padding-bottom: 0; 4 | } 5 | .weui-label { 6 | width: 105px; 7 | word-wrap: break-word; 8 | word-break: break-all; 9 | } 10 | .weui-input { 11 | height: 2.58823529em; 12 | min-height: 2.58823529em; 13 | line-height: 2.58823529em; 14 | } 15 | .weui-toptips { 16 | position: fixed; 17 | -webkit-transform: translateZ(0); 18 | transform: translateZ(0); 19 | top: 0; 20 | left: 0; 21 | right: 0; 22 | padding: 5px; 23 | font-size: 14px; 24 | text-align: center; 25 | color: #FFFFFF; 26 | z-index: 5000; 27 | word-wrap: break-word; 28 | word-break: break-all; 29 | } 30 | .weui-toptips_warn { 31 | background-color: #E64340; 32 | } 33 | .weui-textarea { 34 | display: block; 35 | width: 100%; 36 | } 37 | .weui-textarea-counter { 38 | color: #B2B2B2; 39 | text-align: right; 40 | } 41 | .weui-textarea-counter_warn { 42 | color: #E64340; 43 | } 44 | .weui-cell_warn { 45 | color: #E64340; 46 | } 47 | -------------------------------------------------------------------------------- /pages/todo/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /pages/demo/flex/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 自适应 3 | 固定 4 | 5 | 滚动 6 | 7 | 8 | 9 | 自适应 10 | 固定 11 | 12 | 13 | 14 | 15 | 16 | cell standard 17 | 18 | 19 | 20 | cell standard 21 | 22 | 23 | -------------------------------------------------------------------------------- /vendor/qcloud-weapp-client-sdk/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "qcloud-weapp-client-sdk", 3 | "description": "QCloud 微信小程序客户端 SDK", 4 | "main": "index.js", 5 | "authors": [ 6 | "Tencent Cloud" 7 | ], 8 | "license": "MIT", 9 | "keywords": [ 10 | "qcloud", 11 | "weapp", 12 | "wechat", 13 | "sdk", 14 | "client", 15 | "auth", 16 | "websocket" 17 | ], 18 | "homepage": "https://github.com/tencentyun/weapp-client-sdk", 19 | "ignore": [ 20 | "**/.*", 21 | "node_modules", 22 | "bower_components", 23 | "test", 24 | "tests", 25 | "typings.json", 26 | "jsconfig.json", 27 | "package.json", 28 | ".npmignore", 29 | ".travis.yml", 30 | ".gitignore" 31 | ], 32 | "version": "0.8.0", 33 | "_release": "0.8.0", 34 | "_resolution": { 35 | "type": "version", 36 | "tag": "v0.8.0", 37 | "commit": "3d27999767b62fb113de47283b0945a85c633254" 38 | }, 39 | "_source": "https://github.com/tencentyun/weapp-client-sdk.git", 40 | "_target": "*", 41 | "_originalSource": "qcloud-weapp-client-sdk" 42 | } -------------------------------------------------------------------------------- /pages/weui/navbar/navbar.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {{item}} 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /style/widget/weui-tab/weui-navbar.wxss: -------------------------------------------------------------------------------- 1 | .weui-navbar { 2 | display: -webkit-box; 3 | display: -webkit-flex; 4 | display: flex; 5 | position: absolute; 6 | z-index: 500; 7 | top: 0; 8 | width: 100%; 9 | border-bottom: 1rpx solid #CCCCCC; 10 | } 11 | .weui-navbar__item { 12 | position: relative; 13 | display: block; 14 | -webkit-box-flex: 1; 15 | -webkit-flex: 1; 16 | flex: 1; 17 | padding: 13px 0; 18 | text-align: center; 19 | font-size: 0; 20 | } 21 | .weui-navbar__item.weui-bar__item_on { 22 | color: #1AAD19; 23 | } 24 | .weui-navbar__slider { 25 | position: absolute; 26 | content: " "; 27 | left: 0; 28 | bottom: 0; 29 | width: 6em; 30 | height: 3px; 31 | background-color: #1AAD19; 32 | -webkit-transition: -webkit-transform .3s; 33 | transition: -webkit-transform .3s; 34 | transition: transform .3s; 35 | transition: transform .3s, -webkit-transform .3s; 36 | } 37 | .weui-navbar__title { 38 | display: inline-block; 39 | font-size: 15px; 40 | max-width: 8em; 41 | width: auto; 42 | overflow: hidden; 43 | text-overflow: ellipsis; 44 | white-space: nowrap; 45 | word-wrap: normal; 46 | } 47 | -------------------------------------------------------------------------------- /pages/weui/msg/msg_fail.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 操作失败 8 | 内容详情,可根据实际需要安排,如果换行则不超过规定长度,居中展现文字链接 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 底部链接文本 20 | 21 | Copyright © 2008-2016 weui.io 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /pages/weui/msg/msg_success.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 操作成功 8 | 内容详情,可根据实际需要安排,如果换行则不超过规定长度,居中展现文字链接 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 底部链接文本 20 | 21 | Copyright © 2008-2016 weui.io 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | LICENSE - "MIT License" 2 | 3 | Copyright (c) 2016 by Tencent Cloud 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without 8 | restriction, including without limitation the rights to use, 9 | copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the 11 | Software is furnished to do so, subject to the following 12 | conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /pages/weui/index.wxss: -------------------------------------------------------------------------------- 1 | .weui-flex { 2 | -webkit-box-align: center; 3 | -webkit-align-items: center; 4 | align-items: center; 5 | } 6 | .weui-cells { 7 | margin-top: 0; 8 | opacity: 0; 9 | -webkit-transform: translateY(-50%); 10 | transform: translateY(-50%); 11 | -webkit-transition: .3s; 12 | transition: .3s; 13 | } 14 | .weui-cells:before, 15 | .weui-cells:after { 16 | display: none; 17 | } 18 | .weui-cells_show { 19 | opacity: 1; 20 | -webkit-transform: translateY(0); 21 | transform: translateY(0); 22 | } 23 | .weui-cell:before { 24 | right: 15px; 25 | } 26 | .kind-list__item { 27 | margin: 10px 0; 28 | background-color: #FFFFFF; 29 | border-radius: 2px; 30 | overflow: hidden; 31 | } 32 | .kind-list__item:first-child { 33 | margin-top: 0; 34 | } 35 | .kind-list__img { 36 | width: 30px; 37 | height: 30px; 38 | } 39 | .kind-list__item-hd { 40 | padding: 20px; 41 | -webkit-transition: opacity .3s; 42 | transition: opacity .3s; 43 | } 44 | .kind-list__item-hd_show { 45 | opacity: .4; 46 | } 47 | .kind-list__item-bd { 48 | height: 0; 49 | overflow: hidden; 50 | } 51 | .kind-list__item-bd_show { 52 | height: auto; 53 | } 54 | -------------------------------------------------------------------------------- /vendor/qcloud-weapp-client-sdk/LICENSE: -------------------------------------------------------------------------------- 1 | LICENSE - "MIT License" 2 | 3 | Copyright (c) 2016 by Tencent Cloud 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without 8 | restriction, including without limitation the rights to use, 9 | copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the 11 | Software is furnished to do so, subject to the following 12 | conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /pages/chat/chat.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {{message.user.nickName}} 8 | {{message.content}} 9 | 10 | 11 | 12 | {{message.content}} 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /style/widget/weui-tab/weui-tab.wxss: -------------------------------------------------------------------------------- 1 | .weui-navbar { 2 | display: -webkit-box; 3 | display: -webkit-flex; 4 | display: flex; 5 | position: absolute; 6 | z-index: 500; 7 | top: 0; 8 | width: 100%; 9 | border-bottom: 1rpx solid #CCCCCC; 10 | } 11 | .weui-navbar__item { 12 | position: relative; 13 | display: block; 14 | -webkit-box-flex: 1; 15 | -webkit-flex: 1; 16 | flex: 1; 17 | padding: 13px 0; 18 | text-align: center; 19 | font-size: 0; 20 | } 21 | .weui-navbar__item.weui-bar__item_on { 22 | color: #1AAD19; 23 | } 24 | .weui-navbar__slider { 25 | position: absolute; 26 | content: " "; 27 | left: 0; 28 | bottom: 0; 29 | width: 6em; 30 | height: 3px; 31 | background-color: #1AAD19; 32 | -webkit-transition: -webkit-transform .3s; 33 | transition: -webkit-transform .3s; 34 | transition: transform .3s; 35 | transition: transform .3s, -webkit-transform .3s; 36 | } 37 | .weui-navbar__title { 38 | display: inline-block; 39 | font-size: 15px; 40 | max-width: 8em; 41 | width: auto; 42 | overflow: hidden; 43 | text-overflow: ellipsis; 44 | white-space: nowrap; 45 | word-wrap: normal; 46 | } 47 | .weui-tab { 48 | position: relative; 49 | height: 100%; 50 | } 51 | .weui-tab__panel { 52 | box-sizing: border-box; 53 | height: 100%; 54 | padding-top: 50px; 55 | overflow: auto; 56 | -webkit-overflow-scrolling: touch; 57 | } 58 | -------------------------------------------------------------------------------- /pages/video/detail/index.js: -------------------------------------------------------------------------------- 1 | // pages/video/index.js 2 | var AV = require('../../../libs/av-weapp-min.js'); 3 | 4 | function getRandomColor() { 5 | let rgb = [] 6 | for (let i = 0; i < 3; ++i) { 7 | let color = Math.floor(Math.random() * 256).toString(16) 8 | color = color.length == 1 ? '0' + color : color 9 | rgb.push(color) 10 | } 11 | return '#' + rgb.join('') 12 | } 13 | Page({ 14 | data: {}, 15 | onLoad: function (options) { 16 | // 页面初始化 options为页面跳转所带来的参数 17 | console.log(options); 18 | var self = this; 19 | var id = options.id; 20 | var query = new AV.Query('Video'); 21 | query.get(id).then(function (video) { 22 | // 成功获得实例 23 | self.setData({ 24 | video 25 | }) 26 | }, function (error) { 27 | // 异常处理 28 | console.log(error); 29 | }); 30 | }, 31 | onReady: function () { 32 | // 页面渲染完成 33 | this.videoContext = wx.createVideoContext('myVideo'); 34 | }, 35 | onShow: function () { 36 | // 页面显示 37 | }, 38 | onHide: function () { 39 | // 页面隐藏 40 | }, 41 | onUnload: function () { 42 | // 页面关闭 43 | }, 44 | inputValue: '', 45 | bindInputBlur: function (e) { 46 | this.inputValue = e.detail.value 47 | }, 48 | bindSendDanmu: function () { 49 | this.videoContext.sendDanmu({ 50 | text: this.inputValue, 51 | color: getRandomColor() 52 | }) 53 | } 54 | }) -------------------------------------------------------------------------------- /pages/weui/footer/footer.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Footer 4 | 页脚 5 | 6 | 7 | 8 | Copyright © 2008-2016 weui.io 9 | 10 | 11 | 12 | 13 | 14 | 底部链接 15 | 16 | Copyright © 2008-2016 weui.io 17 | 18 | 19 | 20 | 21 | 22 | 底部链接 23 | 底部链接 24 | 25 | Copyright © 2008-2016 weui.io 26 | 27 | 28 | 29 | 30 | 31 | WeUI首页 32 | 33 | Copyright © 2008-2016 weui.io 34 | 35 | 36 | -------------------------------------------------------------------------------- /pages/weui/button/button.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Button 4 | 按钮,WeUI采用小程序原生的按钮为主体,加入一些间距的样式。 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /pages/video/create/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 标题 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 封面照片 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /pages/video/index.js: -------------------------------------------------------------------------------- 1 | // pages/video/index.js 2 | var AV = require('../../libs/av-weapp-min.js'); 3 | 4 | Page({ 5 | data: {}, 6 | onLoad: function (options) { 7 | // 页面初始化 options为页面跳转所带来的参数 8 | }, 9 | onReady: function () { 10 | // 页面渲染完成 11 | new AV.Query('Video') 12 | .descending('createdAt') 13 | .find() 14 | .then(video => { 15 | console.log(video); 16 | this.videoContexts = video; 17 | this.setData({ video }) 18 | }) 19 | .catch(console.error); 20 | }, 21 | onShow: function () { 22 | // 页面显示 23 | }, 24 | onHide: function () { 25 | // 页面隐藏 26 | }, 27 | onUnload: function () { 28 | // 页面关闭 29 | }, 30 | videoPlay: function (event) { 31 | console.log(event); 32 | }, 33 | takeVideo: function () { 34 | // 录像 35 | wx.chooseVideo({ 36 | sourceType: ['camera'], 37 | maxDuration: 10, 38 | camera: 'back', 39 | success: function (res) { 40 | var tempFilePath = res.tempFilePath; 41 | var app = getApp(); 42 | app.videoUrl = tempFilePath; // save in global data 43 | wx.navigateTo({ 44 | url: '/pages/video/create/index' 45 | }); 46 | } 47 | }) 48 | }, 49 | onPullDownRefresh: function () { 50 | new AV.Query('Video') 51 | .descending('createdAt') 52 | .find() 53 | .then(video => { 54 | console.log(video); 55 | this.setData({ video }); 56 | wx.stopPullDownRefresh(); 57 | }) 58 | .catch(console.error); 59 | } 60 | }) -------------------------------------------------------------------------------- /pages/weui/index.js: -------------------------------------------------------------------------------- 1 | Page({ 2 | data: { 3 | list: [ 4 | { 5 | id: 'form', 6 | name: '表单', 7 | open: false, 8 | pages: ['button', 'list', 'input', 'slider', 'uploader'] 9 | }, 10 | { 11 | id: 'widget', 12 | name: '基础组件', 13 | open: false, 14 | pages: ['article', 'badge', 'flex', 'footer', 'gallery', 'grid', 'icons', 'loadmore', 'panel', 'preview', 'progress'] 15 | }, 16 | { 17 | id: 'feedback', 18 | name: '操作反馈', 19 | open: false, 20 | pages: ['actionsheet', 'dialog', 'msg', 'picker', 'toast'] 21 | }, 22 | { 23 | id: 'nav', 24 | name: '导航相关', 25 | open: false, 26 | pages: ['navbar', 'tabbar'] 27 | }, 28 | { 29 | id: 'search', 30 | name: '搜索相关', 31 | open: false, 32 | pages: ['searchbar'] 33 | } 34 | ] 35 | }, 36 | kindToggle: function (e) { 37 | var id = e.currentTarget.id, list = this.data.list; 38 | for (var i = 0, len = list.length; i < len; ++i) { 39 | if (list[i].id == id) { 40 | list[i].open = !list[i].open 41 | } else { 42 | list[i].open = false 43 | } 44 | } 45 | this.setData({ 46 | list: list 47 | }); 48 | } 49 | }); 50 | -------------------------------------------------------------------------------- /pages/weui/flex/flex.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex 4 | Flex布局 5 | 6 | 7 | 8 | weui 9 | 10 | 11 | weui 12 | weui 13 | 14 | 15 | weui 16 | weui 17 | weui 18 | 19 | 20 | weui 21 | weui 22 | weui 23 | weui 24 | 25 | 26 | weui 27 | weui 28 | weui 29 | 30 | 31 | -------------------------------------------------------------------------------- /style/widget/weui-searchbar/weui-searchbar.wxss: -------------------------------------------------------------------------------- 1 | .weui-search-bar { 2 | position: relative; 3 | padding: 8px 10px; 4 | display: -webkit-box; 5 | display: -webkit-flex; 6 | display: flex; 7 | box-sizing: border-box; 8 | background-color: #EFEFF4; 9 | border-top: 1rpx solid #D7D6DC; 10 | border-bottom: 1rpx solid #D7D6DC; 11 | } 12 | .weui-icon-search { 13 | margin-right: 8px; 14 | } 15 | .weui-icon-search_in-box { 16 | position: absolute; 17 | left: 10px; 18 | top: 7px; 19 | } 20 | .weui-search-bar__text { 21 | display: inline-block; 22 | font-size: 14px; 23 | vertical-align: middle; 24 | } 25 | .weui-search-bar__form { 26 | position: relative; 27 | -webkit-box-flex: 1; 28 | -webkit-flex: auto; 29 | flex: auto; 30 | border-radius: 5px; 31 | background: #FFFFFF; 32 | border: 1rpx solid #E6E6EA; 33 | } 34 | .weui-search-bar__box { 35 | position: relative; 36 | padding-left: 30px; 37 | padding-right: 30px; 38 | width: 100%; 39 | box-sizing: border-box; 40 | z-index: 1; 41 | } 42 | .weui-search-bar__input { 43 | height: 28px; 44 | line-height: 28px; 45 | font-size: 14px; 46 | } 47 | .weui-icon-clear { 48 | position: absolute; 49 | top: 0; 50 | right: 0; 51 | padding: 7px 8px; 52 | font-size: 0; 53 | } 54 | .weui-search-bar__label { 55 | position: absolute; 56 | top: 0; 57 | right: 0; 58 | bottom: 0; 59 | left: 0; 60 | z-index: 2; 61 | border-radius: 3px; 62 | text-align: center; 63 | color: #9B9B9B; 64 | background: #FFFFFF; 65 | line-height: 28px; 66 | } 67 | .weui-search-bar__cancel-btn { 68 | margin-left: 10px; 69 | line-height: 28px; 70 | color: #09BB07; 71 | white-space: nowrap; 72 | } 73 | -------------------------------------------------------------------------------- /pages/weui/progress/progress.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Progress 4 | 进度条,这里采用小程序原生的progress 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /pages/weui/images/base64.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | icon20: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC4AAAAuCAMAAABgZ9sFAAAAVFBMVEXx8fHMzMzr6+vn5+fv7+/t7e3d3d2+vr7W1tbHx8eysrKdnZ3p6enk5OTR0dG7u7u3t7ejo6PY2Njh4eHf39/T09PExMSvr6+goKCqqqqnp6e4uLgcLY/OAAAAnklEQVRIx+3RSRLDIAxE0QYhAbGZPNu5/z0zrXHiqiz5W72FqhqtVuuXAl3iOV7iPV/iSsAqZa9BS7YOmMXnNNX4TWGxRMn3R6SxRNgy0bzXOW8EBO8SAClsPdB3psqlvG+Lw7ONXg/pTld52BjgSSkA3PV2OOemjIDcZQWgVvONw60q7sIpR38EnHPSMDQ4MjDjLPozhAkGrVbr/z0ANjAF4AcbXmYAAAAASUVORK5CYII=", 3 | icon60: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAeFBMVEUAwAD///+U5ZTc9twOww7G8MYwzDCH4YcfyR9x23Hw+/DY9dhm2WZG0kbT9NP0/PTL8sux7LFe115T1VM+zz7i+OIXxhes6qxr2mvA8MCe6J6M4oz6/frr+us5zjn2/fa67rqB4IF13XWn6ad83nxa1loqyirn+eccHxx4AAAC/klEQVRo3u2W2ZKiQBBF8wpCNSCyLwri7v//4bRIFVXoTBBB+DAReV5sG6lTXDITiGEYhmEYhmEYhmEYhmEY5v9i5fsZGRx9PyGDne8f6K9cfd+mKXe1yNG/0CcqYE86AkBMBh66f20deBc7wA/1WFiTwvSEpBMA2JJOBsSLxe/4QEEaJRrASP8EVF8Q74GbmevKg0saa0B8QbwBdjRyADYxIhqxAZ++IKYtciPXLQVG+imw+oo4Bu56rjEJ4GYsvPmKOAB+xlz7L5aevqUXuePWVhvWJ4eWiwUQ67mK51qPj4dFDMlRLBZTqF3SDvmr4BwtkECu5gHWPkmDfQh02WLxXuvbvC8ku8F57GsI5e0CmUwLz1kq3kD17R1In5816rGvQ5VMk5FEtIiWislTffuDpl/k/PzscdQsv8r9qWq4LRWX6tQYtTxvI3XyrwdyQxChXioOngH3dLgOFjk0all56XRi/wDFQrGQU3Os5t0wJu1GNtNKHdPqYaGYQuRDfbfDf26AGLYSyGS3ZAK4S8XuoAlxGSdYMKwqZKM9XJMtyqXi7HX/CiAZS6d8bSVUz5J36mEMFDTlAFQzxOT1dzLRljjB6+++ejFqka+mXIe6F59mw22OuOw1F4T6lg/9VjL1rLDoI9Xzl1MSYDNHnPQnt3D1EE7PrXjye/3pVpr1Z45hMUdcACc5NVQI0bOdS1WA0wuz73e7/5TNqBPhQXPEFGJNV2zNqWI7QKBd2Gn6AiBko02zuAOXeWIXjV0jNqdKegaE/kJQ6Bfs4aju04lMLkA2T5wBSYPKDGF3RKhFYEa6A1L1LG2yacmsaZ6YPOSAMKNsO+N5dNTfkc5Aqe26uxHpx7ZirvgCwJpWq/lmX1hA7LyabQ34tt5RiJKXSwQ+0KU0V5xg+hZrd4Bn1n4EID+WkQdgLfRNtvil9SPfwy+WQ7PFBWQz6dGWZBLkeJFXZGCfLUjCgGgqXo5TuSu3cugdcTv/HjqnBTEMwzAMwzAMwzAMwzAMw/zf/AFbXiOA6frlMAAAAABJRU5ErkJggg==" 4 | }; -------------------------------------------------------------------------------- /pages/weui/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | WeUI 4 | WeUI 是一套同微信原生视觉体验一致的基础样式库,由微信官方设计团队为微信内网页和微信小程序量身设计,令用户的使用感知更加统一。 5 | 6 | 7 | 8 | 9 | 10 | 11 | {{item.name}} 12 | 13 | 14 | 15 | 16 | 17 | 18 | {{page}} 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages": [ 3 | "pages/index/index", 4 | "pages/drawguessnew/index", 5 | 6 | "pages/video/index", 7 | "pages/video/detail/index", 8 | "pages/video/create/index", 9 | 10 | 11 | "pages/demo/index", 12 | "pages/weui/index", 13 | "pages/qcloud/index", 14 | 15 | "pages/chat/chat", 16 | "pages/upload/index", 17 | 18 | "pages/demo/flex/index", 19 | "pages/demo/float/index", 20 | 21 | "pages/weui/button/button", 22 | "pages/weui/list/list", 23 | "pages/weui/input/input", 24 | "pages/weui/slider/slider", 25 | "pages/weui/uploader/uploader", 26 | 27 | "pages/weui/article/article", 28 | "pages/weui/badge/badge", 29 | "pages/weui/flex/flex", 30 | "pages/weui/footer/footer", 31 | "pages/weui/gallery/gallery", 32 | "pages/weui/grid/grid", 33 | "pages/weui/icons/icons", 34 | "pages/weui/loadmore/loadmore", 35 | "pages/weui/panel/panel", 36 | "pages/weui/preview/preview", 37 | "pages/weui/progress/progress", 38 | 39 | "pages/weui/actionsheet/actionsheet", 40 | "pages/weui/dialog/dialog", 41 | "pages/weui/msg/msg", 42 | "pages/weui/msg/msg_success", 43 | "pages/weui/msg/msg_fail", 44 | "pages/weui/picker/picker", 45 | "pages/weui/toast/toast", 46 | 47 | "pages/weui/navbar/navbar", 48 | "pages/weui/tabbar/tabbar", 49 | 50 | "pages/weui/searchbar/searchbar" 51 | ], 52 | "window": { 53 | "enablePullDownRefresh": false, 54 | "backgroundTextStyle": "light", 55 | "navigationBarBackgroundColor": "#f8777b", 56 | "navigationBarTitleText": "微信小程序demo", 57 | "navigationBarTextStyle": "white", 58 | "backgroundColor": "#f8777b" 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /style/widget/weui-cell/weui-cell.wxss: -------------------------------------------------------------------------------- 1 | .weui-cells { 2 | position: relative; 3 | margin-top: 1.17647059em; 4 | background-color: #FFFFFF; 5 | line-height: 1.41176471; 6 | font-size: 17px; 7 | } 8 | .weui-cells:before { 9 | content: " "; 10 | position: absolute; 11 | left: 0; 12 | top: 0; 13 | right: 0; 14 | height: 1px; 15 | border-top: 1rpx solid #D9D9D9; 16 | color: #D9D9D9; 17 | } 18 | .weui-cells:after { 19 | content: " "; 20 | position: absolute; 21 | left: 0; 22 | bottom: 0; 23 | right: 0; 24 | height: 1px; 25 | border-bottom: 1rpx solid #D9D9D9; 26 | color: #D9D9D9; 27 | } 28 | .weui-cells__title { 29 | margin-top: .77em; 30 | margin-bottom: .3em; 31 | padding-left: 15px; 32 | padding-right: 15px; 33 | color: #999999; 34 | font-size: 14px; 35 | } 36 | .weui-cells_after-title { 37 | margin-top: 0; 38 | } 39 | .weui-cells__tips { 40 | margin-top: .3em; 41 | color: #999999; 42 | padding-left: 15px; 43 | padding-right: 15px; 44 | font-size: 14px; 45 | } 46 | .weui-cell { 47 | padding: 10px 15px; 48 | position: relative; 49 | display: -webkit-box; 50 | display: -webkit-flex; 51 | display: flex; 52 | -webkit-box-align: center; 53 | -webkit-align-items: center; 54 | align-items: center; 55 | } 56 | .weui-cell:before { 57 | content: " "; 58 | position: absolute; 59 | left: 0; 60 | top: 0; 61 | right: 0; 62 | height: 1px; 63 | border-top: 1rpx solid #D9D9D9; 64 | color: #D9D9D9; 65 | left: 15px; 66 | } 67 | .weui-cell:first-child:before { 68 | display: none; 69 | } 70 | .weui-cell_active { 71 | background-color: #ECECEC; 72 | } 73 | .weui-cell_primary { 74 | -webkit-box-align: start; 75 | -webkit-align-items: flex-start; 76 | align-items: flex-start; 77 | } 78 | .weui-cell__bd { 79 | -webkit-box-flex: 1; 80 | -webkit-flex: 1; 81 | flex: 1; 82 | } 83 | .weui-cell__ft { 84 | text-align: right; 85 | color: #999999; 86 | } 87 | -------------------------------------------------------------------------------- /pages/weui/article/article.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Article 4 | 文章 5 | 6 | 7 | 8 | 大标题 9 | 10 | 章标题 11 | 12 | 1.1 节标题 13 | 14 | Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod 15 | tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 16 | quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo 17 | consequat. 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 1.2 节标题 26 | 27 | Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod 28 | tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 29 | cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non 30 | proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /pages/upload/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 图片来源 10 | {{sourceType[sourceTypeIndex]}} 11 | 12 | 13 | 14 | 15 | 图片质量 16 | {{sizeType[sizeTypeIndex]}} 17 | 18 | 19 | 20 | 21 | 数量限制 22 | {{count[countIndex]}} 23 | 24 | 25 | 26 | 27 | 请选择图片 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 |
39 |
40 | 41 | 42 | 43 |
44 | 45 |
-------------------------------------------------------------------------------- /pages/qcloud/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 综合示例 4 | 5 | 三木聊天室 6 | 你猜我画 7 | 文件上传 8 | 9 | 10 | 11 | 登录接口测试 12 | 13 | 14 | 登录 15 | 清除登录会话 16 | 17 | 18 | 19 | 带会话请求测试 20 | 21 | 22 | 请求 23 | 24 | 25 | 26 | WebSocket 信道服务测试 27 | 28 | 29 | 30 | 信道 31 | 32 | {{tunnelStatusText[tunnelStatus]}} 33 | 34 | 35 | 36 | 37 | 发送消息 38 | 测试重连 39 | 40 | 41 | -------------------------------------------------------------------------------- /style/widget/weui-animate/weui-animate.wxss: -------------------------------------------------------------------------------- 1 | @-webkit-keyframes slideUp { 2 | from { 3 | -webkit-transform: translate3d(0, 100%, 0); 4 | transform: translate3d(0, 100%, 0); 5 | } 6 | to { 7 | -webkit-transform: translate3d(0, 0, 0); 8 | transform: translate3d(0, 0, 0); 9 | } 10 | } 11 | @keyframes slideUp { 12 | from { 13 | -webkit-transform: translate3d(0, 100%, 0); 14 | transform: translate3d(0, 100%, 0); 15 | } 16 | to { 17 | -webkit-transform: translate3d(0, 0, 0); 18 | transform: translate3d(0, 0, 0); 19 | } 20 | } 21 | .weui-animate-slide-up { 22 | -webkit-animation: slideUp ease .3s forwards; 23 | animation: slideUp ease .3s forwards; 24 | } 25 | @-webkit-keyframes slideDown { 26 | from { 27 | -webkit-transform: translate3d(0, 0, 0); 28 | transform: translate3d(0, 0, 0); 29 | } 30 | to { 31 | -webkit-transform: translate3d(0, 100%, 0); 32 | transform: translate3d(0, 100%, 0); 33 | } 34 | } 35 | @keyframes slideDown { 36 | from { 37 | -webkit-transform: translate3d(0, 0, 0); 38 | transform: translate3d(0, 0, 0); 39 | } 40 | to { 41 | -webkit-transform: translate3d(0, 100%, 0); 42 | transform: translate3d(0, 100%, 0); 43 | } 44 | } 45 | .weui-animate-slide-down { 46 | -webkit-animation: slideDown ease .3s forwards; 47 | animation: slideDown ease .3s forwards; 48 | } 49 | @-webkit-keyframes fadeIn { 50 | from { 51 | opacity: 0; 52 | } 53 | to { 54 | opacity: 1; 55 | } 56 | } 57 | @keyframes fadeIn { 58 | from { 59 | opacity: 0; 60 | } 61 | to { 62 | opacity: 1; 63 | } 64 | } 65 | .weui-animate-fade-in { 66 | -webkit-animation: fadeIn ease .3s forwards; 67 | animation: fadeIn ease .3s forwards; 68 | } 69 | @-webkit-keyframes fadeOut { 70 | from { 71 | opacity: 1; 72 | } 73 | to { 74 | opacity: 0; 75 | } 76 | } 77 | @keyframes fadeOut { 78 | from { 79 | opacity: 1; 80 | } 81 | to { 82 | opacity: 0; 83 | } 84 | } 85 | .weui-animate-fade-out { 86 | -webkit-animation: fadeOut ease .3s forwards; 87 | animation: fadeOut ease .3s forwards; 88 | } 89 | -------------------------------------------------------------------------------- /style/widget/weui-media-box/weui-media-box.wxss: -------------------------------------------------------------------------------- 1 | .weui-media-box { 2 | padding: 15px; 3 | position: relative; 4 | } 5 | .weui-media-box:before { 6 | content: " "; 7 | position: absolute; 8 | left: 0; 9 | top: 0; 10 | right: 0; 11 | height: 1px; 12 | border-top: 1rpx solid #E5E5E5; 13 | color: #E5E5E5; 14 | left: 15px; 15 | } 16 | .weui-media-box:first-child:before { 17 | display: none; 18 | } 19 | .weui-media-box__title { 20 | font-weight: 400; 21 | font-size: 17px; 22 | width: auto; 23 | overflow: hidden; 24 | text-overflow: ellipsis; 25 | white-space: nowrap; 26 | word-wrap: normal; 27 | word-wrap: break-word; 28 | word-break: break-all; 29 | } 30 | .weui-media-box__desc { 31 | color: #999999; 32 | font-size: 13px; 33 | line-height: 1.2; 34 | overflow: hidden; 35 | text-overflow: ellipsis; 36 | display: -webkit-box; 37 | -webkit-box-orient: vertical; 38 | -webkit-line-clamp: 2; 39 | } 40 | .weui-media-box__info { 41 | margin-top: 15px; 42 | padding-bottom: 5px; 43 | font-size: 13px; 44 | color: #CECECE; 45 | line-height: 1em; 46 | list-style: none; 47 | overflow: hidden; 48 | } 49 | .weui-media-box__info__meta { 50 | float: left; 51 | padding-right: 1em; 52 | } 53 | .weui-media-box__info__meta_extra { 54 | padding-left: 1em; 55 | border-left: 1px solid #CECECE; 56 | } 57 | .weui-media-box__title_in-text { 58 | margin-bottom: 8px; 59 | } 60 | .weui-media-box_appmsg { 61 | display: -webkit-box; 62 | display: -webkit-flex; 63 | display: flex; 64 | -webkit-box-align: center; 65 | -webkit-align-items: center; 66 | align-items: center; 67 | } 68 | .weui-media-box__thumb { 69 | width: 100%; 70 | height: 100%; 71 | vertical-align: top; 72 | } 73 | .weui-media-box__hd_in-appmsg { 74 | margin-right: .8em; 75 | width: 60px; 76 | height: 60px; 77 | line-height: 60px; 78 | text-align: center; 79 | } 80 | .weui-media-box__bd_in-appmsg { 81 | -webkit-box-flex: 1; 82 | -webkit-flex: 1; 83 | flex: 1; 84 | min-width: 0; 85 | } 86 | .weui-media-box_small-appmsg { 87 | padding: 0; 88 | } 89 | .weui-cells_in-small-appmsg { 90 | margin-top: 0; 91 | } 92 | .weui-cells_in-small-appmsg:before { 93 | display: none; 94 | } 95 | -------------------------------------------------------------------------------- /pages/upload/index.js: -------------------------------------------------------------------------------- 1 | // 引入配置 2 | var config = require('../../config'); 3 | // 显示失败提示 4 | var showModel = (title, content) => { 5 | wx.hideToast(); 6 | 7 | wx.showModal({ 8 | title, 9 | content: JSON.stringify(content), 10 | showCancel: false 11 | }); 12 | }; 13 | 14 | var sourceType = [ ['camera'], ['album'], ['camera', 'album'] ] 15 | var sizeType = [ ['compressed'], ['original'], ['compressed', 'original'] ] 16 | 17 | Page({ 18 | data: { 19 | sourceTypeIndex: 2, 20 | sourceType: ['拍照', '相册', '拍照或相册'], 21 | 22 | sizeTypeIndex: 2, 23 | sizeType: ['压缩', '原图', '压缩或原图'], 24 | 25 | countIndex: 8, 26 | count: [1, 2, 3, 4, 5, 6, 7, 8, 9], 27 | 28 | uploadUrl: config.service.uploadUrl, 29 | }, 30 | sourceTypeChange: function (e) { 31 | this.setData({ 32 | sourceTypeIndex: e.detail.value 33 | }) 34 | }, 35 | sizeTypeChange: function (e) { 36 | this.setData({ 37 | sizeTypeIndex: e.detail.value 38 | }) 39 | }, 40 | countChange: function (e) { 41 | this.setData({ 42 | countIndex: e.detail.value 43 | }) 44 | }, 45 | chooseImage: function () { 46 | var that = this 47 | wx.chooseImage({ 48 | sourceType: sourceType[this.data.sourceTypeIndex], 49 | sizeType: sizeType[this.data.sizeTypeIndex], 50 | count: this.data.count[this.data.countIndex], 51 | success: function (res) { 52 | console.log(res) 53 | that.setData({ 54 | imageList: res.tempFilePaths 55 | }) 56 | } 57 | }) 58 | }, 59 | previewImage: function (e) { 60 | var current = e.target.dataset.src 61 | 62 | wx.previewImage({ 63 | current: current, 64 | urls: this.data.imageList 65 | }) 66 | }, 67 | upload: function (e) { 68 | // 上传照片 69 | debugger; 70 | wx.uploadFile({ 71 | url: this.data.uploadUrl, 72 | filePath: this.data.imageList[0], 73 | name: 'file', 74 | formData:{ 75 | 'user': 'test' 76 | }, 77 | success: function(res){ 78 | var data = res.data 79 | showModel('上传成功', ''); 80 | }, 81 | fail: function (res) { 82 | console.log(data); 83 | showModel('上传失败', ''); 84 | } 85 | }) 86 | } 87 | }) 88 | -------------------------------------------------------------------------------- /style/widget/weui-cell/weui-uploader.wxss: -------------------------------------------------------------------------------- 1 | .weui-uploader__hd { 2 | display: -webkit-box; 3 | display: -webkit-flex; 4 | display: flex; 5 | padding-bottom: 10px; 6 | -webkit-box-align: center; 7 | -webkit-align-items: center; 8 | align-items: center; 9 | } 10 | .weui-uploader__title { 11 | -webkit-box-flex: 1; 12 | -webkit-flex: 1; 13 | flex: 1; 14 | } 15 | .weui-uploader__info { 16 | color: #B2B2B2; 17 | } 18 | .weui-uploader__bd { 19 | margin-bottom: -4px; 20 | margin-right: -9px; 21 | overflow: hidden; 22 | } 23 | .weui-uploader__file { 24 | float: left; 25 | margin-right: 9px; 26 | margin-bottom: 9px; 27 | } 28 | .weui-uploader__img { 29 | display: block; 30 | width: 79px; 31 | height: 79px; 32 | } 33 | .weui-uploader__file_status { 34 | position: relative; 35 | } 36 | .weui-uploader__file_status:before { 37 | content: " "; 38 | position: absolute; 39 | top: 0; 40 | right: 0; 41 | bottom: 0; 42 | left: 0; 43 | background-color: rgba(0, 0, 0, 0.5); 44 | } 45 | .weui-uploader__file-content { 46 | position: absolute; 47 | top: 50%; 48 | left: 50%; 49 | -webkit-transform: translate(-50%, -50%); 50 | transform: translate(-50%, -50%); 51 | color: #FFFFFF; 52 | } 53 | .weui-uploader__input-box { 54 | float: left; 55 | position: relative; 56 | margin-right: 9px; 57 | margin-bottom: 9px; 58 | width: 77px; 59 | height: 77px; 60 | border: 1px solid #D9D9D9; 61 | } 62 | .weui-uploader__input-box:before, 63 | .weui-uploader__input-box:after { 64 | content: " "; 65 | position: absolute; 66 | top: 50%; 67 | left: 50%; 68 | -webkit-transform: translate(-50%, -50%); 69 | transform: translate(-50%, -50%); 70 | background-color: #D9D9D9; 71 | } 72 | .weui-uploader__input-box:before { 73 | width: 2px; 74 | height: 39.5px; 75 | } 76 | .weui-uploader__input-box:after { 77 | width: 39.5px; 78 | height: 2px; 79 | } 80 | .weui-uploader__input-box:active { 81 | border-color: #999999; 82 | } 83 | .weui-uploader__input-box:active:before, 84 | .weui-uploader__input-box:active:after { 85 | background-color: #999999; 86 | } 87 | .weui-uploader__input { 88 | position: absolute; 89 | z-index: 1; 90 | top: 0; 91 | left: 0; 92 | width: 100%; 93 | height: 100%; 94 | opacity: 0; 95 | } 96 | -------------------------------------------------------------------------------- /pages/weui/icons/icons.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Icons 4 | 图标 5 | 6 | 7 | 8 | 9 | 10 | 成功 11 | 用于表示操作顺利达成 12 | 13 | 14 | 15 | 16 | 17 | 提示 18 | 用于表示信息提示;也常用于缺乏条件的操作拦截,提示用户所需信息 19 | 20 | 21 | 22 | 23 | 24 | 普通警告 25 | 用于表示操作后将引起一定后果的情况 26 | 27 | 28 | 29 | 30 | 31 | 强烈警告 32 | 用于表示操作后将引起严重的不可挽回的后果的情况 33 | 34 | 35 | 36 | 37 | 38 | 等待 39 | 用于表示等待 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /pages/weui/searchbar/searchbar.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | SearchBar 4 | 搜索栏 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 实时搜索文本 27 | 28 | 29 | 30 | 31 | 实时搜索文本 32 | 33 | 34 | 35 | 36 | 实时搜索文本 37 | 38 | 39 | 40 | 41 | 实时搜索文本 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /style/widget/weui-cell/weui-form/weui-form-preview.wxss: -------------------------------------------------------------------------------- 1 | .weui-form-preview { 2 | position: relative; 3 | background-color: #FFFFFF; 4 | } 5 | .weui-form-preview:before { 6 | content: " "; 7 | position: absolute; 8 | left: 0; 9 | top: 0; 10 | right: 0; 11 | height: 1px; 12 | border-top: 1rpx solid #D9D9D9; 13 | color: #D9D9D9; 14 | } 15 | .weui-form-preview:after { 16 | content: " "; 17 | position: absolute; 18 | left: 0; 19 | bottom: 0; 20 | right: 0; 21 | height: 1px; 22 | border-bottom: 1rpx solid #D9D9D9; 23 | color: #D9D9D9; 24 | } 25 | .weui-form-preview__value { 26 | font-size: 14px; 27 | } 28 | .weui-form-preview__value_in-hd { 29 | font-size: 26px; 30 | } 31 | .weui-form-preview__hd { 32 | position: relative; 33 | padding: 10px 15px; 34 | text-align: right; 35 | line-height: 2.5em; 36 | } 37 | .weui-form-preview__hd:after { 38 | content: " "; 39 | position: absolute; 40 | left: 0; 41 | bottom: 0; 42 | right: 0; 43 | height: 1px; 44 | border-bottom: 1rpx solid #D9D9D9; 45 | color: #D9D9D9; 46 | left: 15px; 47 | } 48 | .weui-form-preview__bd { 49 | padding: 10px 15px; 50 | font-size: .9em; 51 | text-align: right; 52 | color: #999999; 53 | line-height: 2; 54 | } 55 | .weui-form-preview__ft { 56 | position: relative; 57 | line-height: 50px; 58 | display: -webkit-box; 59 | display: -webkit-flex; 60 | display: flex; 61 | } 62 | .weui-form-preview__ft:after { 63 | content: " "; 64 | position: absolute; 65 | left: 0; 66 | top: 0; 67 | right: 0; 68 | height: 1px; 69 | border-top: 1rpx solid #D5D5D6; 70 | color: #D5D5D6; 71 | } 72 | .weui-form-preview__item { 73 | overflow: hidden; 74 | } 75 | .weui-form-preview__label { 76 | float: left; 77 | margin-right: 1em; 78 | min-width: 4em; 79 | color: #999999; 80 | text-align: justify; 81 | text-align-last: justify; 82 | } 83 | .weui-form-preview__value { 84 | display: block; 85 | overflow: hidden; 86 | word-break: normal; 87 | word-wrap: break-word; 88 | } 89 | .weui-form-preview__btn { 90 | position: relative; 91 | display: block; 92 | -webkit-box-flex: 1; 93 | -webkit-flex: 1; 94 | flex: 1; 95 | color: #3CC51F; 96 | text-align: center; 97 | } 98 | .weui-form-preview__btn:after { 99 | content: " "; 100 | position: absolute; 101 | left: 0; 102 | top: 0; 103 | width: 1px; 104 | bottom: 0; 105 | border-left: 1rpx solid #D5D5D6; 106 | color: #D5D5D6; 107 | } 108 | .weui-form-preview__btn:first-child:after { 109 | display: none; 110 | } 111 | .weui-form-preview__btn_active { 112 | background-color: #EEEEEE; 113 | } 114 | .weui-form-preview__btn_default { 115 | color: #999999; 116 | } 117 | .weui-form-preview__btn_primary { 118 | color: #0BB20C; 119 | } 120 | -------------------------------------------------------------------------------- /pages/index/index.wxss: -------------------------------------------------------------------------------- 1 | .root { 2 | background: #efeff4; 3 | position: absolute; 4 | top: 0; 5 | left: 0; 6 | right: 0; 7 | bottom:0; 8 | } 9 | .line { 10 | padding-top: 30rpx; 11 | } 12 | .line text { 13 | color: #6D6D72; 14 | font-size: 28rpx; 15 | margin-left: 40rpx; 16 | } 17 | .line-control { 18 | border-bottom: #d9d9d9 1px solid; 19 | border-top: #d9d9d9 1px solid; 20 | background-color: #fff; 21 | margin-top: 10rpx; 22 | } 23 | .line-control .item { 24 | box-sizing: border-box; 25 | text-align: left; 26 | color: #007AFF; 27 | font-size: 32rpx; 28 | padding-left: 40rpx; 29 | position: relative 30 | } 31 | .line-control .item:active { 32 | background: #d9d9d9; 33 | } 34 | .line-control .item.flag { 35 | color: #333; 36 | } 37 | .line-control .item.flag:active { 38 | background: #fff; 39 | } 40 | .line-control .item-inner { 41 | border-bottom: #d9d9d9 1px solid; 42 | height: 90rpx; 43 | line-height: 90rpx; 44 | } 45 | .line-control .item:last-child .item-inner { 46 | border:none; 47 | } 48 | .line-control .switch { 49 | vertical-align: middle; 50 | line-height: normal; 51 | } 52 | .line-control text { 53 | display: inline-block; 54 | vertical-align: middle; 55 | margin-right: 10rpx; 56 | color: #8E8E93; 57 | margin-left: 0; 58 | } 59 | .line-control .switch-status { 60 | color: #999; 61 | position: absolute; 62 | right: 40rpx; 63 | top: 0; 64 | } 65 | .line-control .item.disabled { 66 | color: #999 67 | } 68 | .line-control .item.disabled:active { 69 | background: none; 70 | } 71 | .line .demo { 72 | height: 90rpx; 73 | line-height: 90rpx; 74 | box-sizing: border-box; 75 | text-align: left; 76 | color: #333; 77 | background-color: #fff; 78 | position: relative; 79 | font-size: 32rpx; 80 | padding-left: 40rpx; 81 | } 82 | .line .demo .link { 83 | position: absolute; 84 | right: 40rpx; 85 | top: 0rpx; 86 | color: #8E8E93; 87 | } 88 | .hide { 89 | display: none 90 | } 91 | 92 | @media (max-width : 360px) { 93 | .line text { 94 | font-size: 36rpx; 95 | } 96 | .line-control .item-inner { 97 | border-bottom: #d9d9d9 1px solid; 98 | height: 110rpx; 99 | line-height: 110rpx; 100 | } 101 | .line-control .item { 102 | height: 110rpx; 103 | line-height: 110rpx; 104 | box-sizing: border-box; 105 | text-align: left; 106 | color: #007AFF; 107 | font-size: 38rpx; 108 | padding-left: 40rpx; 109 | position: relative 110 | } 111 | .line .demo { 112 | height: 110rpx; 113 | line-height: 110rpx; 114 | font-size: 38rpx; 115 | padding-left: 40rpx; 116 | } 117 | } -------------------------------------------------------------------------------- /pages/qcloud/index.wxss: -------------------------------------------------------------------------------- 1 | .root { 2 | background: #efeff4; 3 | position: absolute; 4 | top: 0; 5 | left: 0; 6 | right: 0; 7 | bottom:0; 8 | } 9 | .line { 10 | padding-top: 30rpx; 11 | } 12 | .line text { 13 | color: #6D6D72; 14 | font-size: 28rpx; 15 | margin-left: 40rpx; 16 | } 17 | .line-control { 18 | border-bottom: #d9d9d9 1px solid; 19 | border-top: #d9d9d9 1px solid; 20 | background-color: #fff; 21 | margin-top: 10rpx; 22 | } 23 | .line-control .item { 24 | box-sizing: border-box; 25 | text-align: left; 26 | color: #007AFF; 27 | font-size: 32rpx; 28 | padding-left: 40rpx; 29 | position: relative 30 | } 31 | .line-control .item:active { 32 | background: #d9d9d9; 33 | } 34 | .line-control .item.flag { 35 | color: #333; 36 | } 37 | .line-control .item.flag:active { 38 | background: #fff; 39 | } 40 | .line-control .item-inner { 41 | border-bottom: #d9d9d9 1px solid; 42 | height: 90rpx; 43 | line-height: 90rpx; 44 | } 45 | .line-control .item:last-child .item-inner { 46 | border:none; 47 | } 48 | .line-control .switch { 49 | vertical-align: middle; 50 | line-height: normal; 51 | } 52 | .line-control text { 53 | display: inline-block; 54 | vertical-align: middle; 55 | margin-right: 10rpx; 56 | color: #8E8E93; 57 | margin-left: 0; 58 | } 59 | .line-control .switch-status { 60 | color: #999; 61 | position: absolute; 62 | right: 40rpx; 63 | top: 0; 64 | } 65 | .line-control .item.disabled { 66 | color: #999 67 | } 68 | .line-control .item.disabled:active { 69 | background: none; 70 | } 71 | .line .demo { 72 | height: 90rpx; 73 | line-height: 90rpx; 74 | box-sizing: border-box; 75 | text-align: left; 76 | color: #333; 77 | background-color: #fff; 78 | position: relative; 79 | font-size: 32rpx; 80 | padding-left: 40rpx; 81 | } 82 | .line .demo .link { 83 | position: absolute; 84 | right: 40rpx; 85 | top: 0rpx; 86 | color: #8E8E93; 87 | } 88 | .hide { 89 | display: none 90 | } 91 | 92 | @media (max-width : 360px) { 93 | .line text { 94 | font-size: 36rpx; 95 | } 96 | .line-control .item-inner { 97 | border-bottom: #d9d9d9 1px solid; 98 | height: 110rpx; 99 | line-height: 110rpx; 100 | } 101 | .line-control .item { 102 | height: 110rpx; 103 | line-height: 110rpx; 104 | box-sizing: border-box; 105 | text-align: left; 106 | color: #007AFF; 107 | font-size: 38rpx; 108 | padding-left: 40rpx; 109 | position: relative 110 | } 111 | .line .demo { 112 | height: 110rpx; 113 | line-height: 110rpx; 114 | font-size: 38rpx; 115 | padding-left: 40rpx; 116 | } 117 | } -------------------------------------------------------------------------------- /pages/weui/badge/badge.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Badge 4 | 徽章 5 | 6 | 7 | 8 | 新消息提示跟摘要信息后,统一在列表右侧 9 | 10 | 11 | 单行列表 12 | 13 | 详细信息 14 | 15 | 16 | 17 | 18 | 19 | 未读数红点跟在主题信息后,统一在列表左侧 20 | 21 | 22 | 23 | 24 | 8 25 | 26 | 27 | 联系人名称 28 | 摘要信息 29 | 30 | 31 | 32 | 33 | 单行列表 34 | 8 35 | 36 | 37 | 38 | 39 | 40 | 单行列表 41 | 8 42 | 43 | 详细信息 44 | 45 | 46 | 47 | 单行列表 48 | New 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /pages/weui/preview/preview.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Preview 4 | 表单预览 5 | 6 | 7 | 8 | 9 | 10 | 付款金额 11 | ¥2400.00 12 | 13 | 14 | 15 | 16 | 商品 17 | 电动打蛋机 18 | 19 | 20 | 标题标题 21 | 名字名字名字 22 | 23 | 24 | 标题标题 25 | 很长很长的名字很长很长的名字很长很长的名字很长很长的名字很长很长的名字 26 | 27 | 28 | 29 | 操作 30 | 31 | 32 | 33 | 34 | 付款金额 35 | ¥2400.00 36 | 37 | 38 | 39 | 商品 40 | 电动打蛋机 41 | 42 | 43 | 标题标题 44 | 名字名字名字 45 | 46 | 47 | 标题标题 48 | 很长很长的名字很长很长的名字很长很长的名字很长很长的名字很长很长的名字 49 | 50 | 51 | 52 | 辅助操作 53 | 操作 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /pages/weui/uploader/uploader.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Uploader 4 | 上传组件 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 图片上传 13 | {{files.length}}/2 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 50% 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /pages/video/create/index.js: -------------------------------------------------------------------------------- 1 | // pages/video/create/index.js 2 | var AV = require('../../../libs/av-weapp-min.js'); 3 | 4 | Page({ 5 | data: { 6 | url: "", 7 | title: "", 8 | thumb: "" 9 | }, 10 | onLoad: function (options) { 11 | // 页面初始化 options为页面跳转所带来的参数 12 | var app = getApp(); // 获取全局变量 13 | this.setData({ 14 | url: app.videoUrl 15 | }); 16 | }, 17 | onReady: function () { 18 | // 页面渲染完成 19 | }, 20 | onShow: function () { 21 | // 页面显示 22 | }, 23 | onHide: function () { 24 | // 页面隐藏 25 | }, 26 | onUnload: function () { 27 | // 页面关闭 28 | }, 29 | 30 | changeInputContent(e) { 31 | this.setData({ title: e.detail.value }); 32 | }, 33 | chooseImage: function () { 34 | var self = this; 35 | wx.chooseImage({ 36 | count: 1, // 默认9 37 | sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 38 | sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 39 | success: function (res) { 40 | var tempFilePaths = res.tempFilePaths[0]; 41 | self.setData({ 42 | thumb: tempFilePaths 43 | }) 44 | } 45 | }) 46 | }, 47 | submitVideo: function () { 48 | console.log(this.data); 49 | if (this.data.title.trim() === '') { 50 | wx.showModal({ 51 | title: '提示', 52 | content: '请输入标题', 53 | showCancel: false 54 | }) 55 | } else { 56 | wx.showNavigationBarLoading(); 57 | new AV.File(this.data.title + '-video', { 58 | blob: { 59 | uri: this.data.url, 60 | }, 61 | }).save().then( 62 | // 上传视频成功 63 | file => { 64 | console.log('上传视频成功'); 65 | console.log(this.data.title); 66 | new AV.File(this.data.title + '-thumb', { 67 | blob: { 68 | uri: this.data.thumb, 69 | }, 70 | }).save().then( 71 | thumbFile => { 72 | console.log('上传封面成功'); 73 | // 上传封面成功 74 | wx.hideNavigationBarLoading(); 75 | var Video = AV.Object.extend('Video'); 76 | // 新建一个 Todo 对象 77 | var video = new Video(); 78 | video.set('title', this.data.title); 79 | video.set('video', file); 80 | video.set('thumb', thumbFile); 81 | video.save().then(function (video) { 82 | wx.showModal({ 83 | title: '提示', 84 | content: '提交成功', 85 | showCancel: false, 86 | success: function (res) { 87 | if (res.confirm) { 88 | wx.navigateBack(); 89 | } 90 | } 91 | }) 92 | }, function (error) { 93 | // 异常处理 94 | wx.showToast({ 95 | title: error.message 96 | }) 97 | }) 98 | 99 | }, function () { 100 | console.log('错误'); 101 | console.log(arguments); 102 | }).catch(console.error); 103 | } 104 | ) 105 | } 106 | } 107 | }) -------------------------------------------------------------------------------- /pages/weui/input/input.js: -------------------------------------------------------------------------------- 1 | Page({ 2 | data: { 3 | showTopTips: false, 4 | 5 | radioItems: [ 6 | {name: 'cell standard', value: '0'}, 7 | {name: 'cell standard', value: '1', checked: true} 8 | ], 9 | checkboxItems: [ 10 | {name: 'standard is dealt for u.', value: '0', checked: true}, 11 | {name: 'standard is dealicient for u.', value: '1'} 12 | ], 13 | 14 | date: "2016-09-01", 15 | time: "12:01", 16 | 17 | countryCodes: ["+86", "+80", "+84", "+87"], 18 | countryCodeIndex: 0, 19 | 20 | countries: ["中国", "美国", "英国"], 21 | countryIndex: 0, 22 | 23 | accounts: ["微信号", "QQ", "Email"], 24 | accountIndex: 0, 25 | 26 | isAgree: false 27 | }, 28 | showTopTips: function(){ 29 | var that = this; 30 | this.setData({ 31 | showTopTips: true 32 | }); 33 | setTimeout(function(){ 34 | that.setData({ 35 | showTopTips: false 36 | }); 37 | }, 3000); 38 | }, 39 | radioChange: function (e) { 40 | console.log('radio发生change事件,携带value值为:', e.detail.value); 41 | 42 | var radioItems = this.data.radioItems; 43 | for (var i = 0, len = radioItems.length; i < len; ++i) { 44 | radioItems[i].checked = radioItems[i].value == e.detail.value; 45 | } 46 | 47 | this.setData({ 48 | radioItems: radioItems 49 | }); 50 | }, 51 | checkboxChange: function (e) { 52 | console.log('checkbox发生change事件,携带value值为:', e.detail.value); 53 | 54 | var checkboxItems = this.data.checkboxItems, values = e.detail.value; 55 | for (var i = 0, lenI = checkboxItems.length; i < lenI; ++i) { 56 | checkboxItems[i].checked = false; 57 | 58 | for (var j = 0, lenJ = values.length; j < lenJ; ++j) { 59 | if(checkboxItems[i].value == values[j]){ 60 | checkboxItems[i].checked = true; 61 | break; 62 | } 63 | } 64 | } 65 | 66 | this.setData({ 67 | checkboxItems: checkboxItems 68 | }); 69 | }, 70 | bindDateChange: function (e) { 71 | this.setData({ 72 | date: e.detail.value 73 | }) 74 | }, 75 | bindTimeChange: function (e) { 76 | this.setData({ 77 | time: e.detail.value 78 | }) 79 | }, 80 | bindCountryCodeChange: function(e){ 81 | console.log('picker country code 发生选择改变,携带值为', e.detail.value); 82 | 83 | this.setData({ 84 | countryCodeIndex: e.detail.value 85 | }) 86 | }, 87 | bindCountryChange: function(e) { 88 | console.log('picker country 发生选择改变,携带值为', e.detail.value); 89 | 90 | this.setData({ 91 | countryIndex: e.detail.value 92 | }) 93 | }, 94 | bindAccountChange: function(e) { 95 | console.log('picker account 发生选择改变,携带值为', e.detail.value); 96 | 97 | this.setData({ 98 | accountIndex: e.detail.value 99 | }) 100 | }, 101 | bindAgreeChange: function (e) { 102 | this.setData({ 103 | isAgree: !!e.detail.value.length 104 | }); 105 | } 106 | }); -------------------------------------------------------------------------------- /style/widget/weui-loading/weui-loading.wxss: -------------------------------------------------------------------------------- 1 | .weui-loading { 2 | margin: 0 5px; 3 | width: 20px; 4 | height: 20px; 5 | display: inline-block; 6 | vertical-align: middle; 7 | -webkit-animation: weuiLoading 1s steps(12, end) infinite; 8 | animation: weuiLoading 1s steps(12, end) infinite; 9 | background: transparent url(data:image/svg+xml;base64,PHN2ZyBjbGFzcz0iciIgd2lkdGg9JzEyMHB4JyBoZWlnaHQ9JzEyMHB4JyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj4KICAgIDxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiBmaWxsPSJub25lIiBjbGFzcz0iYmsiPjwvcmVjdD4KICAgIDxyZWN0IHg9JzQ2LjUnIHk9JzQwJyB3aWR0aD0nNycgaGVpZ2h0PScyMCcgcng9JzUnIHJ5PSc1JyBmaWxsPScjRTlFOUU5JwogICAgICAgICAgdHJhbnNmb3JtPSdyb3RhdGUoMCA1MCA1MCkgdHJhbnNsYXRlKDAgLTMwKSc+CiAgICA8L3JlY3Q+CiAgICA8cmVjdCB4PSc0Ni41JyB5PSc0MCcgd2lkdGg9JzcnIGhlaWdodD0nMjAnIHJ4PSc1JyByeT0nNScgZmlsbD0nIzk4OTY5NycKICAgICAgICAgIHRyYW5zZm9ybT0ncm90YXRlKDMwIDUwIDUwKSB0cmFuc2xhdGUoMCAtMzApJz4KICAgICAgICAgICAgICAgICByZXBlYXRDb3VudD0naW5kZWZpbml0ZScvPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyM5Qjk5OUEnCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSg2MCA1MCA1MCkgdHJhbnNsYXRlKDAgLTMwKSc+CiAgICAgICAgICAgICAgICAgcmVwZWF0Q291bnQ9J2luZGVmaW5pdGUnLz4KICAgIDwvcmVjdD4KICAgIDxyZWN0IHg9JzQ2LjUnIHk9JzQwJyB3aWR0aD0nNycgaGVpZ2h0PScyMCcgcng9JzUnIHJ5PSc1JyBmaWxsPScjQTNBMUEyJwogICAgICAgICAgdHJhbnNmb3JtPSdyb3RhdGUoOTAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNBQkE5QUEnCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgxMjAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNCMkIyQjInCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgxNTAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNCQUI4QjknCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgxODAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNDMkMwQzEnCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgyMTAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNDQkNCQ0InCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgyNDAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNEMkQyRDInCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgyNzAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNEQURBREEnCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgzMDAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNFMkUyRTInCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgzMzAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0Pgo8L3N2Zz4=) no-repeat; 10 | background-size: 100%; 11 | } 12 | @-webkit-keyframes weuiLoading { 13 | 0% { 14 | -webkit-transform: rotate3d(0, 0, 1, 0deg); 15 | transform: rotate3d(0, 0, 1, 0deg); 16 | } 17 | 100% { 18 | -webkit-transform: rotate3d(0, 0, 1, 360deg); 19 | transform: rotate3d(0, 0, 1, 360deg); 20 | } 21 | } 22 | @keyframes weuiLoading { 23 | 0% { 24 | -webkit-transform: rotate3d(0, 0, 1, 0deg); 25 | transform: rotate3d(0, 0, 1, 0deg); 26 | } 27 | 100% { 28 | -webkit-transform: rotate3d(0, 0, 1, 360deg); 29 | transform: rotate3d(0, 0, 1, 360deg); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vendor/qcloud-weapp-client-sdk/lib/request.js: -------------------------------------------------------------------------------- 1 | var constants = require('./constants'); 2 | var utils = require('./utils'); 3 | var Session = require('./session'); 4 | var loginLib = require('./login'); 5 | 6 | var noop = function noop() {}; 7 | 8 | var buildAuthHeader = function buildAuthHeader(session) { 9 | var header = {}; 10 | 11 | if (session && session.id && session.skey) { 12 | header[constants.WX_HEADER_ID] = session.id; 13 | header[constants.WX_HEADER_SKEY] = session.skey; 14 | } 15 | 16 | return header; 17 | }; 18 | 19 | /*** 20 | * @class 21 | * 表示请求过程中发生的异常 22 | */ 23 | var RequestError = (function () { 24 | function RequestError(type, message) { 25 | Error.call(this, message); 26 | this.type = type; 27 | this.message = message; 28 | } 29 | 30 | RequestError.prototype = new Error(); 31 | RequestError.prototype.constructor = RequestError; 32 | 33 | return RequestError; 34 | })(); 35 | 36 | function request(options) { 37 | if (typeof options !== 'object') { 38 | var message = '请求传参应为 object 类型,但实际传了 ' + (typeof options) + ' 类型'; 39 | throw new RequestError(constants.ERR_INVALID_PARAMS, message); 40 | } 41 | 42 | var requireLogin = options.login; 43 | var success = options.success || noop; 44 | var fail = options.fail || noop; 45 | var complete = options.complete || noop; 46 | var originHeader = options.header || {}; 47 | 48 | // 成功回调 49 | var callSuccess = function () { 50 | success.apply(null, arguments); 51 | complete.apply(null, arguments); 52 | }; 53 | 54 | // 失败回调 55 | var callFail = function (error) { 56 | fail.call(null, error); 57 | complete.call(null, error); 58 | }; 59 | 60 | // 是否已经进行过重试 61 | var hasRetried = false; 62 | 63 | if (requireLogin) { 64 | doRequestWithLogin(); 65 | } else { 66 | doRequest(); 67 | } 68 | 69 | // 登录后再请求 70 | function doRequestWithLogin() { 71 | loginLib.login({ success: doRequest, fail: callFail }); 72 | } 73 | 74 | // 实际进行请求的方法 75 | function doRequest() { 76 | var authHeader = buildAuthHeader(Session.get()); 77 | 78 | wx.request(utils.extend({}, options, { 79 | header: utils.extend({}, originHeader, authHeader), 80 | 81 | success: function (response) { 82 | var data = response.data; 83 | 84 | // 如果响应的数据里面包含 SDK Magic ID,表示被服务端 SDK 处理过,此时一定包含登录态失败的信息 85 | if (data && data[constants.WX_SESSION_MAGIC_ID]) { 86 | // 清除登录态 87 | Session.clear(); 88 | 89 | var error, message; 90 | if (data.error === constants.ERR_INVALID_SESSION) { 91 | // 如果是登录态无效,并且还没重试过,会尝试登录后刷新凭据重新请求 92 | if (!hasRetried) { 93 | hasRetried = true; 94 | doRequestWithLogin(); 95 | return; 96 | } 97 | 98 | message = '登录态已过期'; 99 | error = new RequestError(data.error, message); 100 | 101 | } else { 102 | message = '鉴权服务器检查登录态发生错误(' + (data.error || 'OTHER') + '):' + (data.message || '未知错误'); 103 | error = new RequestError(constants.ERR_CHECK_LOGIN_FAILED, message); 104 | } 105 | 106 | callFail(error); 107 | return; 108 | } 109 | 110 | callSuccess.apply(null, arguments); 111 | }, 112 | 113 | fail: callFail, 114 | complete: noop, 115 | })); 116 | }; 117 | 118 | }; 119 | 120 | module.exports = { 121 | RequestError: RequestError, 122 | request: request, 123 | }; -------------------------------------------------------------------------------- /pages/weui/list/list.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | List 4 | 列表 5 | 6 | 7 | 带说明的列表项 8 | 9 | 10 | 标题文字 11 | 说明文字 12 | 13 | 14 | 15 | 带图标、说明的列表项 16 | 17 | 18 | 19 | 20 | 21 | 标题文字 22 | 说明文字 23 | 24 | 25 | 26 | 27 | 28 | 标题文字 29 | 说明文字 30 | 31 | 32 | 33 | 带跳转的列表项 34 | 35 | 36 | cell standard 37 | 38 | 39 | 40 | cell standard 41 | 42 | 43 | 44 | 45 | 带说明、跳转的列表项 46 | 47 | 48 | cell standard 49 | 说明文字 50 | 51 | 52 | cell standard 53 | 说明文字 54 | 55 | 56 | 57 | 带图标、说明、跳转的列表项 58 | 59 | 60 | 61 | 62 | 63 | cell standard 64 | 说明文字 65 | 66 | 67 | 68 | 69 | 70 | cell standard 71 | 说明文字 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /pages/todo/index.js: -------------------------------------------------------------------------------- 1 | // pages/todo/index.js 2 | var AV = require('../../libs/av-weapp-min.js'); 3 | var Realtime = require('../../libs/realtime.weapp.min.js').Realtime; 4 | var TextMessage = require('../../libs/realtime.weapp.min.js').TextMessage; 5 | Page({ 6 | data:{ 7 | value: '', 8 | code: '', 9 | todos: [], 10 | }, 11 | onLoad:function(options){ 12 | // 页面初始化 options为页面跳转所带来的参数 13 | }, 14 | fetch: function () { 15 | new AV.Query('Todo') 16 | .descending('createdAt') 17 | .find() 18 | .then(todos => this.setData({ todos })) 19 | .catch(console.error); 20 | }, 21 | onReady:function(){ 22 | var self = this; 23 | // 页面渲染完成 24 | this.fetch(); 25 | this.realtime = new Realtime({ 26 | appId: 'I0j7ktVKS8It7VRU8iEfQF2f-gzGzoHsz', 27 | noBinary: true, 28 | }); 29 | this.realtime.on('disconnect', function() { 30 | console.log('网络连接已断开'); 31 | }); 32 | this.realtime.on('schedule', function(attempt, delay) { 33 | console.log(delay + 'ms 后进行第' + (attempt + 1) + '次重连'); 34 | }); 35 | this.realtime.on('retry', function(attempt) { 36 | console.log('正在进行第' + attempt + '次重连'); 37 | }); 38 | this.realtime.on('reconnect', function() { 39 | console.log('网络连接已恢复'); 40 | }); 41 | // 登陆 42 | wx.login({ 43 | success: function(res) { 44 | let code = res.code; 45 | // 加入 46 | var id = '587c7dd12f301e00591b03f7'; 47 | self.realtime.createIMClient(code).then(function(mine) { 48 | console.log('login success: ' + code); 49 | mine.on('message', function(message, conversation) { 50 | console.log('get message'); 51 | self.fetch(); 52 | }); 53 | return mine.getConversation(id); 54 | }) 55 | .then(function(conversation) { 56 | self.conversation = conversation; 57 | return conversation.add([code]) 58 | }) 59 | .then(function(conversation) { 60 | console.log('加入成功', conversation.members); 61 | return conversation.count() 62 | }) 63 | .then(function(count) { 64 | console.log('在线人数: ' + count); 65 | }) 66 | .catch(console.error.bind(console)); 67 | } 68 | }); 69 | }, 70 | onShow:function(){ 71 | // 页面显示 72 | console.log('页面显示'); 73 | }, 74 | onHide:function(){ 75 | // 页面隐藏 76 | }, 77 | onUnload:function(){ 78 | // 页面关闭 79 | }, 80 | okInput: function (e) { 81 | var self = this; 82 | var value = e.detail.value; 83 | var Todo = AV.Object.extend('Todo'); 84 | // 新建一个 Todo 对象 85 | var todo = new Todo(); 86 | todo.set('title', value); 87 | todo.set('content', ''); 88 | todo.save().then(function (todo) { 89 | // 成功保存之后,执行其他逻辑. 90 | self.fetch(); 91 | self.setData({value: ''}); 92 | self.conversation.send(new TextMessage(' ')); 93 | }, function (error) { 94 | // 异常处理 95 | console.error('Failed to create new object, with error message: ' + error.message); 96 | }); 97 | }, 98 | 99 | checkboxChange: function (e) { 100 | this.conversation.send(new TextMessage(' ')); 101 | 102 | var checkboxItems = this.data.todos, values = e.detail.value; 103 | for (var i = 0, lenI = checkboxItems.length; i < lenI; ++i) { 104 | var todo = AV.Object.createWithoutData('Todo', checkboxItems[i].get('objectId')); 105 | todo.set('checked', false); 106 | checkboxItems[i].set('checked', false); 107 | 108 | for (var j = 0, lenJ = values.length; j < lenJ; ++j) { 109 | if(checkboxItems[i].get('objectId') == values[j]){ 110 | todo.set('checked', true); 111 | checkboxItems[i].set('checked', true); 112 | break; 113 | } 114 | } 115 | todo.save(); 116 | } 117 | this.setData({ 118 | todos: checkboxItems 119 | }); 120 | }, 121 | 122 | onShareAppMessage: function () { 123 | return { 124 | title: '微待办', 125 | desc: '同步协作待办小程序', 126 | path: '/pages/todo/index' 127 | } 128 | }, 129 | onPullDownRefresh: function () { 130 | new AV.Query('Todo') 131 | .descending('createdAt') 132 | .find() 133 | .then(todos => { 134 | this.setData({ todos }); 135 | wx.stopPullDownRefresh(); 136 | }) 137 | .catch(console.error); 138 | } 139 | }) -------------------------------------------------------------------------------- /pages/drawguess/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 标题 6 | 7 | 8 | 9 | 10 | 11 | 金币 12 | 13 | 0 14 | 15 | 16 | 17 | 18 | 音乐 19 | 20 | 21 | 22 | 23 | 24 | 25 | 成员列表 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 时间 38 | 20 39 | 40 | 41 | 你画我猜 VIP 42 | 100房间 43 | 44 | 45 | 设置 46 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | {{people.nickName}} 63 | 已准备 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 召好友 72 | 73 | 74 | 喊同房 75 | 76 | 77 | 退出 78 | 79 | 80 | 81 | 82 | 83 | 84 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 108 | 109 | 110 | {{message.user.nickName}}:{{message.content}} 111 | 112 | 113 | {{message.content}} 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /style/widget/weui-cell/weui-form.wxss: -------------------------------------------------------------------------------- 1 | .weui-cell_input { 2 | padding-top: 0; 3 | padding-bottom: 0; 4 | } 5 | .weui-label { 6 | width: 105px; 7 | word-wrap: break-word; 8 | word-break: break-all; 9 | } 10 | .weui-input { 11 | height: 2.58823529em; 12 | min-height: 2.58823529em; 13 | line-height: 2.58823529em; 14 | } 15 | .weui-toptips { 16 | position: fixed; 17 | -webkit-transform: translateZ(0); 18 | transform: translateZ(0); 19 | top: 0; 20 | left: 0; 21 | right: 0; 22 | padding: 5px; 23 | font-size: 14px; 24 | text-align: center; 25 | color: #FFFFFF; 26 | z-index: 5000; 27 | word-wrap: break-word; 28 | word-break: break-all; 29 | } 30 | .weui-toptips_warn { 31 | background-color: #E64340; 32 | } 33 | .weui-textarea { 34 | display: block; 35 | width: 100%; 36 | } 37 | .weui-textarea-counter { 38 | color: #B2B2B2; 39 | text-align: right; 40 | } 41 | .weui-textarea-counter_warn { 42 | color: #E64340; 43 | } 44 | .weui-cell_warn { 45 | color: #E64340; 46 | } 47 | .weui-form-preview { 48 | position: relative; 49 | background-color: #FFFFFF; 50 | } 51 | .weui-form-preview:before { 52 | content: " "; 53 | position: absolute; 54 | left: 0; 55 | top: 0; 56 | right: 0; 57 | height: 1px; 58 | border-top: 1rpx solid #D9D9D9; 59 | color: #D9D9D9; 60 | } 61 | .weui-form-preview:after { 62 | content: " "; 63 | position: absolute; 64 | left: 0; 65 | bottom: 0; 66 | right: 0; 67 | height: 1px; 68 | border-bottom: 1rpx solid #D9D9D9; 69 | color: #D9D9D9; 70 | } 71 | .weui-form-preview__value { 72 | font-size: 14px; 73 | } 74 | .weui-form-preview__value_in-hd { 75 | font-size: 26px; 76 | } 77 | .weui-form-preview__hd { 78 | position: relative; 79 | padding: 10px 15px; 80 | text-align: right; 81 | line-height: 2.5em; 82 | } 83 | .weui-form-preview__hd:after { 84 | content: " "; 85 | position: absolute; 86 | left: 0; 87 | bottom: 0; 88 | right: 0; 89 | height: 1px; 90 | border-bottom: 1rpx solid #D9D9D9; 91 | color: #D9D9D9; 92 | left: 15px; 93 | } 94 | .weui-form-preview__bd { 95 | padding: 10px 15px; 96 | font-size: .9em; 97 | text-align: right; 98 | color: #999999; 99 | line-height: 2; 100 | } 101 | .weui-form-preview__ft { 102 | position: relative; 103 | line-height: 50px; 104 | display: -webkit-box; 105 | display: -webkit-flex; 106 | display: flex; 107 | } 108 | .weui-form-preview__ft:after { 109 | content: " "; 110 | position: absolute; 111 | left: 0; 112 | top: 0; 113 | right: 0; 114 | height: 1px; 115 | border-top: 1rpx solid #D5D5D6; 116 | color: #D5D5D6; 117 | } 118 | .weui-form-preview__item { 119 | overflow: hidden; 120 | } 121 | .weui-form-preview__label { 122 | float: left; 123 | margin-right: 1em; 124 | min-width: 4em; 125 | color: #999999; 126 | text-align: justify; 127 | text-align-last: justify; 128 | } 129 | .weui-form-preview__value { 130 | display: block; 131 | overflow: hidden; 132 | word-break: normal; 133 | word-wrap: break-word; 134 | } 135 | .weui-form-preview__btn { 136 | position: relative; 137 | display: block; 138 | -webkit-box-flex: 1; 139 | -webkit-flex: 1; 140 | flex: 1; 141 | color: #3CC51F; 142 | text-align: center; 143 | } 144 | .weui-form-preview__btn:after { 145 | content: " "; 146 | position: absolute; 147 | left: 0; 148 | top: 0; 149 | width: 1px; 150 | bottom: 0; 151 | border-left: 1rpx solid #D5D5D6; 152 | color: #D5D5D6; 153 | } 154 | .weui-form-preview__btn:first-child:after { 155 | display: none; 156 | } 157 | .weui-form-preview__btn_active { 158 | background-color: #EEEEEE; 159 | } 160 | .weui-form-preview__btn_default { 161 | color: #999999; 162 | } 163 | .weui-form-preview__btn_primary { 164 | color: #0BB20C; 165 | } 166 | .weui-cell_select { 167 | padding: 0; 168 | } 169 | .weui-select { 170 | position: relative; 171 | padding-left: 15px; 172 | padding-right: 30px; 173 | height: 2.58823529em; 174 | min-height: 2.58823529em; 175 | line-height: 2.58823529em; 176 | border-right: 1rpx solid #D9D9D9; 177 | } 178 | .weui-select:before { 179 | content: " "; 180 | display: inline-block; 181 | height: 6px; 182 | width: 6px; 183 | border-width: 2px 2px 0 0; 184 | border-color: #C8C8CD; 185 | border-style: solid; 186 | -webkit-transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0); 187 | transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0); 188 | position: relative; 189 | top: -2px; 190 | position: absolute; 191 | top: 50%; 192 | right: 15px; 193 | margin-top: -4px; 194 | } 195 | .weui-select_in-select-after { 196 | padding-left: 0; 197 | } 198 | .weui-cell__hd_in-select-after, 199 | .weui-cell__bd_in-select-before { 200 | padding-left: 15px; 201 | } 202 | .weui-cell_vcode { 203 | padding-right: 0; 204 | } 205 | .weui-vcode-img { 206 | margin-left: 5px; 207 | height: 2.58823529em; 208 | vertical-align: middle; 209 | } 210 | .weui-vcode-btn { 211 | display: inline-block; 212 | height: 2.58823529em; 213 | margin-left: 5px; 214 | padding: 0 0.6em 0 0.7em; 215 | border-left: 1px solid #E5E5E5; 216 | line-height: 2.58823529em; 217 | vertical-align: middle; 218 | font-size: 17px; 219 | color: #3CC51F; 220 | white-space: nowrap; 221 | } 222 | .weui-vcode-btn:active { 223 | color: #52a341; 224 | } 225 | -------------------------------------------------------------------------------- /pages/weui/panel/panel.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Panel 4 | 面板 5 | 6 | 7 | 8 | 图文组合列表 9 | 10 | 11 | 12 | 13 | 14 | 15 | 标题一 16 | 由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 标题二 25 | 由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。 26 | 27 | 28 | 29 | 30 | 31 | 查看更多 32 | 33 | 34 | 35 | 36 | 37 | 文字组合列表 38 | 39 | 40 | 标题一 41 | 由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。 42 | 43 | 44 | 标题二 45 | 由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。 46 | 47 | 48 | 49 | 50 | 查看更多 51 | 52 | 53 | 54 | 55 | 56 | 小图文组合列表 57 | 58 | 59 | 60 | 61 | 62 | 63 | 文字标题 64 | 65 | 66 | 67 | 68 | 69 | 70 | 文字标题 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 文字列表附来源 80 | 81 | 82 | 标题一 83 | 由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。 84 | 85 | 文字来源 86 | 时间 87 | 其它信息 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /pages/drawguessnew/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 标题 6 | 7 | 8 | 9 | 10 | 11 | 金币 12 | 13 | 0 14 | 15 | 16 | 17 | 18 | 音乐 19 | 20 | 21 | 22 | 23 | 24 | 25 | 成员列表 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 时间 38 | 0 39 | 40 | 41 | 你画我猜 42 | {{nickname}}的房间 43 | 44 | 45 | 设置 46 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | {{people.nickName}} 63 | 已准备 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 召好友 72 | 73 | 74 | 喊同房 75 | 76 | 77 | 退出 78 | 79 | 80 | 81 | 82 | 83 | 84 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 112 | 113 | 114 | {{message.user.nickName}}:{{message.content}} 115 | 116 | 117 | {{message.content}} 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /vendor/qcloud-weapp-client-sdk/lib/login.js: -------------------------------------------------------------------------------- 1 | var utils = require('./utils'); 2 | var constants = require('./constants'); 3 | var Session = require('./session'); 4 | 5 | /*** 6 | * @class 7 | * 表示登录过程中发生的异常 8 | */ 9 | var LoginError = (function () { 10 | function LoginError(type, message) { 11 | Error.call(this, message); 12 | this.type = type; 13 | this.message = message; 14 | } 15 | 16 | LoginError.prototype = new Error(); 17 | LoginError.prototype.constructor = LoginError; 18 | 19 | return LoginError; 20 | })(); 21 | 22 | /** 23 | * 微信登录,获取 code 和 encryptData 24 | */ 25 | var getWxLoginResult = function getLoginCode(callback) { 26 | wx.login({ 27 | success: function (loginResult) { 28 | wx.getUserInfo({ 29 | success: function (userResult) { 30 | callback(null, { 31 | code: loginResult.code, 32 | encryptedData: userResult.encryptedData, 33 | iv: userResult.iv, 34 | userInfo: userResult.userInfo, 35 | }); 36 | }, 37 | 38 | fail: function (userError) { 39 | var error = new LoginError(constants.ERR_WX_GET_USER_INFO, '获取微信用户信息失败,请检查网络状态'); 40 | error.detail = userError; 41 | callback(error, null); 42 | }, 43 | }); 44 | }, 45 | 46 | fail: function (loginError) { 47 | var error = new LoginError(constants.ERR_WX_LOGIN_FAILED, '微信登录失败,请检查网络状态'); 48 | error.detail = loginError; 49 | callback(error, null); 50 | }, 51 | }); 52 | }; 53 | 54 | var noop = function noop() {}; 55 | var defaultOptions = { 56 | method: 'GET', 57 | success: noop, 58 | fail: noop, 59 | loginUrl: null, 60 | }; 61 | 62 | /** 63 | * @method 64 | * 进行服务器登录,以获得登录会话 65 | * 66 | * @param {Object} options 登录配置 67 | * @param {string} options.loginUrl 登录使用的 URL,服务器应该在这个 URL 上处理登录请求 68 | * @param {string} [options.method] 请求使用的 HTTP 方法,默认为 "GET" 69 | * @param {Function} options.success(userInfo) 登录成功后的回调函数,参数 userInfo 微信用户信息 70 | * @param {Function} options.fail(error) 登录失败后的回调函数,参数 error 错误信息 71 | */ 72 | var login = function login(options) { 73 | options = utils.extend({}, defaultOptions, options); 74 | 75 | if (!defaultOptions.loginUrl) { 76 | options.fail(new LoginError(constants.ERR_INVALID_PARAMS, '登录错误:缺少登录地址,请通过 setLoginUrl() 方法设置登录地址')); 77 | return; 78 | } 79 | 80 | var doLogin = () => getWxLoginResult(function (wxLoginError, wxLoginResult) { 81 | if (wxLoginError) { 82 | options.fail(wxLoginError); 83 | return; 84 | } 85 | 86 | var userInfo = wxLoginResult.userInfo; 87 | 88 | // 构造请求头,包含 code、encryptedData 和 iv 89 | var code = wxLoginResult.code; 90 | var encryptedData = wxLoginResult.encryptedData; 91 | var iv = wxLoginResult.iv; 92 | var header = {}; 93 | 94 | header[constants.WX_HEADER_CODE] = code; 95 | header[constants.WX_HEADER_ENCRYPTED_DATA] = encryptedData; 96 | header[constants.WX_HEADER_IV] = iv; 97 | 98 | // 请求服务器登录地址,获得会话信息 99 | wx.request({ 100 | url: options.loginUrl, 101 | header: header, 102 | method: options.method, 103 | data: options.data, 104 | 105 | success: function (result) { 106 | var data = result.data; 107 | 108 | // 成功地响应会话信息 109 | if (data && data[constants.WX_SESSION_MAGIC_ID]) { 110 | if (data.session) { 111 | data.session.userInfo = userInfo; 112 | Session.set(data.session); 113 | options.success(userInfo); 114 | } else { 115 | var errorMessage = '登录失败(' + data.error + '):' + (data.message || '未知错误'); 116 | var noSessionError = new LoginError(constants.ERR_LOGIN_SESSION_NOT_RECEIVED, errorMessage); 117 | options.fail(noSessionError); 118 | } 119 | 120 | // 没有正确响应会话信息 121 | } else { 122 | var errorMessage = '登录请求没有包含会话响应,请确保服务器处理 `' + options.loginUrl + '` 的时候正确使用了 SDK 输出登录结果'; 123 | var noSessionError = new LoginError(constants.ERR_LOGIN_SESSION_NOT_RECEIVED, errorMessage); 124 | options.fail(noSessionError); 125 | } 126 | }, 127 | 128 | // 响应错误 129 | fail: function (loginResponseError) { 130 | var error = new LoginError(constants.ERR_LOGIN_FAILED, '登录失败,可能是网络错误或者服务器发生异常'); 131 | options.fail(error); 132 | }, 133 | }); 134 | }); 135 | 136 | var session = Session.get(); 137 | if (session) { 138 | wx.checkSession({ 139 | success: function () { 140 | options.success(session.userInfo); 141 | }, 142 | 143 | fail: function () { 144 | Session.clear(); 145 | doLogin(); 146 | }, 147 | }); 148 | } else { 149 | doLogin(); 150 | } 151 | }; 152 | 153 | var setLoginUrl = function (loginUrl) { 154 | defaultOptions.loginUrl = loginUrl; 155 | }; 156 | 157 | module.exports = { 158 | LoginError: LoginError, 159 | login: login, 160 | setLoginUrl: setLoginUrl, 161 | }; 162 | -------------------------------------------------------------------------------- /pages/chat/chat.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileOverview 聊天室综合 Demo 示例 3 | */ 4 | 5 | 6 | // 引入 QCloud 小程序增强 SDK 7 | var qcloud = require('../../vendor/qcloud-weapp-client-sdk/index'); 8 | 9 | // 引入配置 10 | var config = require('../../config'); 11 | 12 | /** 13 | * 生成一条聊天室的消息的唯一 ID 14 | */ 15 | function msgUuid() { 16 | if (!msgUuid.next) { 17 | msgUuid.next = 0; 18 | } 19 | return 'msg-' + (++msgUuid.next); 20 | } 21 | 22 | /** 23 | * 生成聊天室的系统消息 24 | */ 25 | function createSystemMessage(content) { 26 | return { id: msgUuid(), type: 'system', content }; 27 | } 28 | 29 | /** 30 | * 生成聊天室的聊天消息 31 | */ 32 | function createUserMessage(content, user, isMe) { 33 | return { id: msgUuid(), type: 'speak', content, user, isMe }; 34 | } 35 | 36 | // 声明聊天室页面 37 | Page({ 38 | 39 | /** 40 | * 聊天室使用到的数据,主要是消息集合以及当前输入框的文本 41 | */ 42 | data: { 43 | messages: [], 44 | inputContent: '大家好啊', 45 | lastMessageId: 'none', 46 | }, 47 | 48 | /** 49 | * 页面渲染完成后,启动聊天室 50 | * */ 51 | onReady() { 52 | wx.setNavigationBarTitle({ title: '三木聊天室' }); 53 | 54 | if (!this.pageReady) { 55 | this.pageReady = true; 56 | this.enter(); 57 | } 58 | }, 59 | 60 | /** 61 | * 后续后台切换回前台的时候,也要重新启动聊天室 62 | */ 63 | onShow() { 64 | if (this.pageReady) { 65 | this.enter(); 66 | } 67 | }, 68 | 69 | /** 70 | * 页面卸载时,退出聊天室 71 | */ 72 | onUnload() { 73 | this.quit(); 74 | }, 75 | 76 | /** 77 | * 页面切换到后台运行时,退出聊天室 78 | */ 79 | onHide() { 80 | this.quit(); 81 | }, 82 | 83 | /** 84 | * 启动聊天室 85 | */ 86 | enter() { 87 | this.pushMessage(createSystemMessage('正在登录...')); 88 | 89 | // 如果登录过,会记录当前用户在 this.me 上 90 | if (!this.me) { 91 | qcloud.request({ 92 | url: `https://${config.service.host}/user`, 93 | login: true, 94 | success: (response) => { 95 | this.me = response.data.data.userInfo; 96 | this.connect(); 97 | } 98 | }); 99 | } else { 100 | this.connect(); 101 | } 102 | }, 103 | 104 | /** 105 | * 连接到聊天室信道服务 106 | */ 107 | connect() { 108 | this.amendMessage(createSystemMessage('正在加入群聊...')); 109 | 110 | // 创建信道 111 | var tunnel = this.tunnel = new qcloud.Tunnel(config.service.tunnelUrl); 112 | 113 | // 连接成功后,去掉「正在加入群聊」的系统提示 114 | tunnel.on('connect', () => this.popMessage()); 115 | 116 | // 聊天室有人加入或退出,反馈到 UI 上 117 | tunnel.on('people', people => { 118 | const { total, enter, leave } = people; 119 | 120 | if (enter) { 121 | this.pushMessage(createSystemMessage(`${enter.nickName}已加入群聊,当前共 ${total} 人`)); 122 | } else { 123 | this.pushMessage(createSystemMessage(`${leave.nickName}已退出群聊,当前共 ${total} 人`)); 124 | } 125 | }); 126 | 127 | // 有人说话,创建一条消息 128 | tunnel.on('speak', speak => { 129 | const { word, who } = speak; 130 | this.pushMessage(createUserMessage(word, who, who.openId === this.me.openId)); 131 | }); 132 | 133 | // 信道关闭后,显示退出群聊 134 | tunnel.on('close', () => { 135 | this.pushMessage(createSystemMessage('您已退出群聊')); 136 | }); 137 | 138 | // 重连提醒 139 | tunnel.on('reconnecting', () => { 140 | this.pushMessage(createSystemMessage('已断线,正在重连...')); 141 | }); 142 | 143 | tunnel.on('reconnect', () => { 144 | this.amendMessage(createSystemMessage('重连成功')); 145 | }); 146 | 147 | // 打开信道 148 | tunnel.open(); 149 | }, 150 | 151 | /** 152 | * 退出聊天室 153 | */ 154 | quit() { 155 | if (this.tunnel) { 156 | this.tunnel.close(); 157 | } 158 | }, 159 | 160 | /** 161 | * 通用更新当前消息集合的方法 162 | */ 163 | updateMessages(updater) { 164 | var messages = this.data.messages; 165 | updater(messages); 166 | 167 | var lastMessageId = messages.length && messages[messages.length - 1].id; 168 | this.setData({ messages, lastMessageId }); 169 | }, 170 | 171 | /** 172 | * 追加一条消息 173 | */ 174 | pushMessage(message) { 175 | this.updateMessages(messages => messages.push(message)); 176 | }, 177 | 178 | /** 179 | * 替换上一条消息 180 | */ 181 | amendMessage(message) { 182 | this.updateMessages(messages => messages.splice(-1, 1, message)); 183 | }, 184 | 185 | /** 186 | * 删除上一条消息 187 | */ 188 | popMessage() { 189 | this.updateMessages(messages => messages.pop()); 190 | }, 191 | 192 | /** 193 | * 用户输入的内容改变之后 194 | */ 195 | changeInputContent(e) { 196 | this.setData({ inputContent: e.detail.value }); 197 | }, 198 | 199 | /** 200 | * 点击「发送」按钮,通过信道推送消息到服务器 201 | **/ 202 | sendMessage(e) { 203 | // 信道当前不可用 204 | if (!this.tunnel || !this.tunnel.isActive()) { 205 | this.pushMessage(createSystemMessage('您还没有加入群聊,请稍后重试')); 206 | if (this.tunnel.isClosed()) { 207 | this.enter(); 208 | } 209 | return; 210 | } 211 | 212 | setTimeout(() => { 213 | if (this.data.inputContent && this.tunnel) { 214 | this.tunnel.emit('speak', { word: this.data.inputContent }); 215 | this.setData({ inputContent: '' }); 216 | } 217 | }); 218 | }, 219 | }); -------------------------------------------------------------------------------- /pages/drawguess/index.wxss: -------------------------------------------------------------------------------- 1 | .section { 2 | height: 100%; 3 | } 4 | .dsn { 5 | display: none; 6 | } 7 | .flex-wrp { 8 | height: 100%; 9 | flex-direction:column; 10 | display: flex; 11 | }wx-inputwx-inputfoot_label 12 | .t 13 | ext-left { 14 | text-align: left; 15 | } 16 | .weui-col { 17 | text-align: center; 18 | float: left; 19 | -webkit-box-sizing: border-box; 20 | box-sizing: border-box; 21 | width: 100% 22 | } 23 | .weui-col-33 { 24 | width: 33.3333%; 25 | } 26 | .fix_label { 27 | position: fixed; 28 | width: 100%; 29 | height: 100%; 30 | background-color: rgba(0, 0, 0, 0.5); 31 | z-index: 999; 32 | } 33 | .fix_label .fix_con { 34 | position: absolute; 35 | width: 15rem; 36 | border-radius: 0.8rem; 37 | background-color: #fff; 38 | left: 50%; 39 | top: 50%; 40 | transform: translate3d(-50%, -50%, 0); 41 | overflow: hidden; 42 | } 43 | .fix_label .fix_con .weui-cells { 44 | color: #f5a923; 45 | } 46 | .fix_con .weui-cell__ft { 47 | color: #f5a923; 48 | } 49 | .fix_label .fix_con .fix_header { 50 | height: 2.5rem; 51 | width: 100%; 52 | background-color: #f5a923; 53 | } 54 | .fix_label .fix_con .fix_header text { 55 | color: #fff; 56 | display: inline-block; 57 | width: 100%; 58 | line-height: 2.5rem; 59 | text-align: center; 60 | } 61 | .fix_con switch { 62 | display: block; 63 | height: 1.7rem; 64 | } 65 | .fix_con .fix_btn { 66 | margin: 0.5rem auto; 67 | background-color: #fff; 68 | width: 12rem; 69 | border-radius: 2rem; 70 | border: 1px solid #f5a923; 71 | color: #f5a923; 72 | } 73 | .fix_btn_hover { 74 | opacity: 0.5; 75 | } 76 | .header_label { 77 | background-color: #f8777b; 78 | color: #fff; 79 | text-align: center; 80 | height: 60px; 81 | } 82 | .header_label text { 83 | display: inline-block; 84 | width: 100%; 85 | } 86 | text.big_txt { 87 | font-size: 1.2rem; 88 | } 89 | .wait_label { 90 | height: 20rem; 91 | width: 100%; 92 | display: flex; 93 | background-color: #f8777b; 94 | position: relative; 95 | } 96 | .wait_label .header_label { 97 | width: 100%; 98 | text-align: center; 99 | margin-top: 1rem; 100 | } 101 | .wait_label .header_label text { 102 | display: inline-block; 103 | width: 100%; 104 | color: #fff; 105 | } 106 | .wait_label .header_label .weui-col { 107 | position: relative; 108 | margin-bottom: 0.4rem; 109 | } 110 | .wait_label .header_label .status_txt { 111 | position: absolute; 112 | top: 2.2rem; 113 | left: 50%; 114 | transform: translateX(-50%); 115 | padding: 0.2rem; 116 | border-radius: 1rem; 117 | border: 1px solid #fff; 118 | background-color: #ffad00; 119 | color: #fff; 120 | } 121 | .wait_label .bottom_btns { 122 | text-align: center; 123 | color: #fff; 124 | position: absolute; 125 | bottom: 0.5rem; 126 | left: 0; 127 | width: 100%; 128 | box-sizing: border-box; 129 | padding: 0 2rem; 130 | } 131 | .wait_label .ready_btn { 132 | position: absolute; 133 | width: 4rem; 134 | height: 4rem; 135 | border-radius: 4rem; 136 | line-height: 4rem; 137 | background-color: #ffab00; 138 | bottom: 2.5rem; 139 | left: 50%; 140 | transform: translateX(-50%); 141 | text-align: center; 142 | color: #fff; 143 | font-size: 1rem; 144 | border: 2px solid #fff; 145 | padding: 0; 146 | } 147 | .hover { 148 | opacity: 0.5; 149 | } 150 | .header_img { 151 | display: inline-block; 152 | background-color: #fff; 153 | width: 4rem; 154 | height: 4rem; 155 | border-radius: 4rem; 156 | } 157 | .draw_label { 158 | position: relative; 159 | width: 100%; 160 | height: 15rem; 161 | display: flex; 162 | box-sizing: border-box; 163 | } 164 | .draw_label canvas { 165 | width: 100%; 166 | height: 100%; 167 | background-color: #ebe8bb; 168 | } 169 | .scroll_user { 170 | width: 100%; 171 | height: 3rem; 172 | background-color: #f1f1d0; 173 | padding: 0.5rem; 174 | box-sizing: border-box; 175 | white-space: nowrap; 176 | } 177 | .scroll_user image { 178 | display: inline-block; 179 | width: 2rem; 180 | height: 2rem; 181 | border-radius: 2rem; 182 | background-color: #ffffff; 183 | margin: 0 0.2rem; 184 | } 185 | .scroll_chat { 186 | width: 100%; 187 | height: 8rem; 188 | padding: 0.5rem 0.5rem 0 0.5rem; 189 | box-sizing: border-box; 190 | } 191 | .scroll_chat text { 192 | display: inline-block; 193 | width: 100%; 194 | margin: 0.2rem 0; 195 | line-height: 1.2; 196 | color: #364149; 197 | font-size: 0.8rem; 198 | } 199 | .foot_label { 200 | position: absolute; 201 | bottom: 0; 202 | width: 100%; 203 | height: 2.5rem; 204 | padding: 0.2rem 0.4rem; 205 | box-sizing: border-box; 206 | background-color: #ccc; 207 | display: flex; 208 | } 209 | .foot_label .msg_input { 210 | flex: 1; 211 | background-color: #fff; 212 | height: 100%; 213 | border-radius: 10rem; 214 | padding: 0 10rpx; 215 | width: 500rpx; 216 | } 217 | .foot_label .send_btn { 218 | width: 170rpx; 219 | margin: 0 15rpx; 220 | background-color:#f8777b; 221 | color: #fff; 222 | line-height: 2.1rem; 223 | } 224 | .message { 225 | color: #666666; 226 | } 227 | .system-message { 228 | width: 100%; 229 | text-align: center; 230 | } 231 | .system-message text { 232 | font-size: 14px; 233 | line-height: 20px; 234 | color: #fff; 235 | background: #cecece; 236 | border-radius: 4px; 237 | padding: 0 15rpx; 238 | margin: 0 10rpx; 239 | display: inline; 240 | } -------------------------------------------------------------------------------- /pages/drawguessnew/index.wxss: -------------------------------------------------------------------------------- 1 | .section { 2 | height: 100%; 3 | } 4 | .dsn { 5 | display: none; 6 | } 7 | .flex-wrp { 8 | height: 100%; 9 | flex-direction:column; 10 | display: flex; 11 | }wx-inputwx-inputfoot_label 12 | .t 13 | ext-left { 14 | text-align: left; 15 | } 16 | .weui-col { 17 | text-align: center; 18 | float: left; 19 | -webkit-box-sizing: border-box; 20 | box-sizing: border-box; 21 | width: 100% 22 | } 23 | .weui-col-33 { 24 | width: 33.3333%; 25 | } 26 | .fix_label { 27 | position: fixed; 28 | width: 100%; 29 | height: 100%; 30 | background-color: rgba(0, 0, 0, 0.5); 31 | z-index: 999; 32 | } 33 | .fix_label .fix_con { 34 | position: absolute; 35 | width: 15rem; 36 | border-radius: 0.8rem; 37 | background-color: #fff; 38 | left: 50%; 39 | top: 50%; 40 | transform: translate3d(-50%, -50%, 0); 41 | overflow: hidden; 42 | } 43 | .fix_label .fix_con .weui-cells { 44 | color: #f5a923; 45 | } 46 | .fix_con .weui-cell__ft { 47 | color: #f5a923; 48 | } 49 | .fix_label .fix_con .fix_header { 50 | height: 2.5rem; 51 | width: 100%; 52 | background-color: #f5a923; 53 | } 54 | .fix_label .fix_con .fix_header text { 55 | color: #fff; 56 | display: inline-block; 57 | width: 100%; 58 | line-height: 2.5rem; 59 | text-align: center; 60 | } 61 | .fix_con switch { 62 | display: block; 63 | height: 1.7rem; 64 | } 65 | .fix_con .fix_btn { 66 | margin: 0.5rem auto; 67 | background-color: #fff; 68 | width: 12rem; 69 | border-radius: 2rem; 70 | border: 1px solid #f5a923; 71 | color: #f5a923; 72 | } 73 | .fix_btn_hover { 74 | opacity: 0.5; 75 | } 76 | .header_label { 77 | background-color: #f8777b; 78 | color: #fff; 79 | text-align: center; 80 | height: 60px; 81 | } 82 | .header_label text { 83 | display: inline-block; 84 | width: 100%; 85 | } 86 | text.big_txt { 87 | font-size: 1.2rem; 88 | } 89 | .wait_label { 90 | height: 20rem; 91 | width: 100%; 92 | display: flex; 93 | background-color: #f8777b; 94 | position: relative; 95 | } 96 | .wait_label .header_label { 97 | width: 100%; 98 | text-align: center; 99 | margin-top: 1rem; 100 | } 101 | .wait_label .header_label text { 102 | display: inline-block; 103 | width: 100%; 104 | color: #fff; 105 | } 106 | .wait_label .header_label .weui-col { 107 | position: relative; 108 | margin-bottom: 0.4rem; 109 | } 110 | .wait_label .header_label .status_txt { 111 | position: absolute; 112 | top: 2.2rem; 113 | left: 50%; 114 | transform: translateX(-50%); 115 | padding: 0.2rem; 116 | border-radius: 1rem; 117 | border: 1px solid #fff; 118 | background-color: #ffad00; 119 | color: #fff; 120 | } 121 | .wait_label .bottom_btns { 122 | text-align: center; 123 | color: #fff; 124 | position: absolute; 125 | bottom: 0.5rem; 126 | left: 0; 127 | width: 100%; 128 | box-sizing: border-box; 129 | padding: 0 2rem; 130 | } 131 | .wait_label .ready_btn { 132 | position: absolute; 133 | width: 4rem; 134 | height: 4rem; 135 | border-radius: 4rem; 136 | line-height: 4rem; 137 | background-color: #ffab00; 138 | bottom: 2.5rem; 139 | left: 50%; 140 | transform: translateX(-50%); 141 | text-align: center; 142 | color: #fff; 143 | font-size: 1rem; 144 | border: 2px solid #fff; 145 | padding: 0; 146 | } 147 | .hover { 148 | opacity: 0.5; 149 | } 150 | .header_img { 151 | display: inline-block; 152 | background-color: #fff; 153 | width: 4rem; 154 | height: 4rem; 155 | border-radius: 4rem; 156 | } 157 | .draw_label { 158 | position: relative; 159 | width: 100%; 160 | height:750rpx; 161 | display: flex; 162 | box-sizing: border-box; 163 | } 164 | .draw_label canvas { 165 | width: 100%; 166 | height: 100%; 167 | background-color: #ebe8bb; 168 | } 169 | .scroll_user { 170 | width: 100%; 171 | height: 3rem; 172 | background-color: #f1f1d0; 173 | padding: 0.5rem; 174 | box-sizing: border-box; 175 | white-space: nowrap; 176 | } 177 | .scroll_user image { 178 | display: inline-block; 179 | width: 2rem; 180 | height: 2rem; 181 | border-radius: 2rem; 182 | background-color: #ffffff; 183 | margin: 0 0.2rem; 184 | } 185 | .scroll_chat { 186 | width: 100%; 187 | height: 8rem; 188 | padding: 0.5rem 0.5rem 0 0.5rem; 189 | box-sizing: border-box; 190 | } 191 | .scroll_chat text { 192 | display: inline-block; 193 | width: 100%; 194 | margin: 0.2rem 0; 195 | line-height: 1.2; 196 | color: #364149; 197 | font-size: 0.8rem; 198 | } 199 | .foot_label { 200 | position: absolute; 201 | bottom: 0; 202 | width: 100%; 203 | height: 2.5rem; 204 | padding: 0.2rem 0.4rem; 205 | box-sizing: border-box; 206 | background-color: #ccc; 207 | display: flex; 208 | } 209 | .foot_label .msg_input { 210 | flex: 1; 211 | background-color: #fff; 212 | height: 100%; 213 | border-radius: 10rem; 214 | padding: 0 10rpx; 215 | width: 500rpx; 216 | } 217 | .foot_label .send_btn { 218 | width: 170rpx; 219 | margin: 0 15rpx; 220 | background-color:#f8777b; 221 | color: #fff; 222 | line-height: 2.1rem; 223 | } 224 | .message { 225 | color: #666666; 226 | } 227 | .system-message { 228 | width: 100%; 229 | text-align: center; 230 | } 231 | .system-message text { 232 | font-size: 14px; 233 | line-height: 20px; 234 | color: #fff; 235 | background: #cecece; 236 | border-radius: 4px; 237 | padding: 0 15rpx; 238 | margin: 0 10rpx; 239 | display: inline; 240 | } -------------------------------------------------------------------------------- /pages/upload/index.wxss: -------------------------------------------------------------------------------- 1 | page { 2 | background-color: #fbf9fe; 3 | height: 100%; 4 | } 5 | .container { 6 | display: flex; 7 | flex-direction: column; 8 | min-height: 100%; 9 | justify-content: space-between; 10 | } 11 | .page-header { 12 | display: flex; 13 | font-size: 32rpx; 14 | color: #aaa; 15 | margin-top: 50rpx; 16 | flex-direction: column; 17 | align-items: center; 18 | } 19 | .page-header-text { 20 | padding: 20rpx 40rpx; 21 | } 22 | .page-header-line { 23 | width: 150rpx; 24 | height: 1px; 25 | border-bottom: 1px solid #ccc; 26 | } 27 | 28 | .page-body { 29 | width: 100%; 30 | display: flex; 31 | flex-direction: column; 32 | align-items: center; 33 | flex-grow: 1; 34 | overflow-x: hidden; 35 | } 36 | .page-body-wrapper { 37 | margin-top: 100rpx; 38 | display: flex; 39 | flex-direction: column; 40 | align-items: center; 41 | width: 100%; 42 | } 43 | .page-body-wrapper form { 44 | width: 100%; 45 | } 46 | .page-body-wording { 47 | text-align: center; 48 | padding: 200rpx 100rpx; 49 | } 50 | .page-body-info { 51 | display: flex; 52 | flex-direction: column; 53 | align-items: center; 54 | background-color: #fff; 55 | margin-bottom: 50rpx; 56 | width: 100%; 57 | padding: 50rpx 0 150rpx 0; 58 | } 59 | .page-body-title { 60 | margin-bottom: 100rpx; 61 | font-size: 32rpx; 62 | } 63 | .page-body-text { 64 | font-size: 30rpx; 65 | line-height: 26px; 66 | color: #ccc; 67 | } 68 | .page-body-text-small { 69 | font-size: 24rpx; 70 | color: #000; 71 | margin-bottom: 100rpx; 72 | } 73 | .page-body-form { 74 | width: 100%; 75 | background-color: #fff; 76 | display: flex; 77 | flex-direction: column; 78 | width: 100%; 79 | border: 1px solid #eee; 80 | } 81 | .page-body-form-item { 82 | display: flex; 83 | align-items: center; 84 | margin-left: 30rpx; 85 | border-bottom: 1px solid #eee; 86 | height: 88rpx; 87 | font-size: 34rpx; 88 | } 89 | .page-body-form-key { 90 | width: 180rpx; 91 | color: #000; 92 | } 93 | .page-body-form-value { 94 | flex-grow: 1; 95 | } 96 | .page-body-form-value .input-placeholder { 97 | color: #b2b2b2; 98 | } 99 | 100 | .page-body-form-picker { 101 | display: flex; 102 | justify-content: space-between; 103 | height: 100rpx; 104 | align-items: center; 105 | font-size: 36rpx; 106 | margin-left: 20rpx; 107 | padding-right: 20rpx; 108 | border-bottom: 1px solid #eee; 109 | } 110 | .page-body-form-picker-value { 111 | color: #ccc; 112 | } 113 | 114 | .page-body-buttons { 115 | width: 100%; 116 | } 117 | .page-body-button { 118 | margin: 25rpx; 119 | } 120 | .page-body-button image { 121 | width: 150rpx; 122 | height: 150rpx; 123 | } 124 | .page-footer { 125 | text-align: center; 126 | color: #1aad19; 127 | font-size: 24rpx; 128 | margin: 20rpx 0; 129 | } 130 | 131 | .green{ 132 | color: #09BB07; 133 | } 134 | .red{ 135 | color: #F76260; 136 | } 137 | .blue{ 138 | color: #10AEFF; 139 | } 140 | .yellow{ 141 | color: #FFBE00; 142 | } 143 | .gray{ 144 | color: #C9C9C9; 145 | } 146 | 147 | .strong{ 148 | font-weight: bold; 149 | } 150 | 151 | .bc_green{ 152 | background-color: #09BB07; 153 | } 154 | .bc_red{ 155 | background-color: #F76260; 156 | } 157 | .bc_blue{ 158 | background-color: #10AEFF; 159 | } 160 | .bc_yellow{ 161 | background-color: #FFBE00; 162 | } 163 | .bc_gray{ 164 | background-color: #C9C9C9; 165 | } 166 | 167 | .tc{ 168 | text-align: center; 169 | } 170 | 171 | .page input{ 172 | padding: 20rpx 30rpx; 173 | background-color: #fff; 174 | } 175 | checkbox, radio{ 176 | margin-right: 10rpx; 177 | } 178 | 179 | .btn-area{ 180 | padding: 0 30px; 181 | } 182 | .btn-area button{ 183 | margin-top: 20rpx; 184 | margin-bottom: 20rpx; 185 | } 186 | 187 | .page { 188 | min-height: 100%; 189 | flex: 1; 190 | background-color: #FBF9FE; 191 | font-size: 32rpx; 192 | font-family: -apple-system-font,Helvetica Neue,Helvetica,sans-serif; 193 | overflow: hidden; 194 | } 195 | .page__hd{ 196 | padding: 50rpx 50rpx 100rpx 50rpx; 197 | text-align: center; 198 | } 199 | .page__title{ 200 | display: inline-block; 201 | padding: 20rpx 40rpx; 202 | font-size: 32rpx; 203 | color: #AAAAAA; 204 | border-bottom: 1px solid #CCCCCC; 205 | } 206 | .page__desc{ 207 | display: none; 208 | margin-top: 20rpx; 209 | font-size: 26rpx; 210 | color: #BBBBBB; 211 | } 212 | 213 | .section{ 214 | margin-bottom: 80rpx; 215 | } 216 | .section_gap{ 217 | padding: 0 30rpx; 218 | } 219 | .section__title{ 220 | margin-bottom: 16rpx; 221 | padding-left: 30rpx; 222 | padding-right: 30rpx; 223 | } 224 | .section_gap .section__title{ 225 | padding-left: 0; 226 | padding-right: 0; 227 | } 228 | .section__ctn{ 229 | 230 | } 231 | 232 | 233 | .images-wrapper { 234 | padding: 20rpx; 235 | background-color: #fff; 236 | margin-top: 20rpx; 237 | } 238 | .images-wrapper-text { 239 | font-size: 28rpx; 240 | } 241 | .images-list { 242 | display: flex; 243 | margin-top: 20rpx; 244 | flex-wrap: wrap; 245 | } 246 | .images-image { 247 | width: 150rpx; 248 | height: 150rpx; 249 | margin: 10rpx; 250 | } 251 | .image-plus { 252 | border: 1px solid #999; 253 | position: relative; 254 | } 255 | .image-plus-horizontal { 256 | position: absolute; 257 | top: 50%; 258 | left: 50%; 259 | background-color: #d9d9d9; 260 | width: 4rpx; 261 | height: 80rpx; 262 | transform: translate(-50%, -50%); 263 | } 264 | .image-plus-vertical { 265 | position: absolute; 266 | top: 50%; 267 | left: 50%; 268 | background-color: #d9d9d9; 269 | width: 80rpx; 270 | height: 4rpx; 271 | transform: translate(-50%, -50%); 272 | } 273 | -------------------------------------------------------------------------------- /pages/index/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileOverview 演示会话服务和 WebSocket 信道服务的使用方式 3 | */ 4 | 5 | // 引入 QCloud 小程序增强 SDK 6 | var qcloud = require('../../vendor/qcloud-weapp-client-sdk/index'); 7 | 8 | // 引入配置 9 | var config = require('../../config'); 10 | 11 | // 显示繁忙提示 12 | var showBusy = text => wx.showToast({ 13 | title: text, 14 | icon: 'loading', 15 | duration: 10000 16 | }); 17 | 18 | // 显示成功提示 19 | var showSuccess = text => wx.showToast({ 20 | title: text, 21 | icon: 'success' 22 | }); 23 | 24 | // 显示失败提示 25 | var showModel = (title, content) => { 26 | wx.hideToast(); 27 | 28 | wx.showModal({ 29 | title, 30 | content: JSON.stringify(content), 31 | showCancel: false 32 | }); 33 | }; 34 | 35 | /** 36 | * 使用 Page 初始化页面,具体可参考微信公众平台上的文档 37 | */ 38 | Page({ 39 | 40 | /** 41 | * 初始数据,我们把服务地址显示在页面上 42 | */ 43 | data: { 44 | loginUrl: config.service.loginUrl, 45 | requestUrl: config.service.requestUrl, 46 | tunnelUrl: config.service.tunnelUrl, 47 | tunnelStatus: 'closed', 48 | tunnelStatusText: { 49 | closed: '已关闭', 50 | connecting: '正在连接...', 51 | connected: '已连接' 52 | } 53 | }, 54 | 55 | /** 56 | * 点击「登录」按钮,测试登录功能 57 | */ 58 | doLogin() { 59 | showBusy('正在登录'); 60 | 61 | // 登录之前需要调用 qcloud.setLoginUrl() 设置登录地址,不过我们在 app.js 的入口里面已经调用过了,后面就不用再调用了 62 | qcloud.login({ 63 | success(result) { 64 | showSuccess('登录成功'); 65 | console.log('登录成功', result); 66 | }, 67 | 68 | fail(error) { 69 | showModel('登录失败', error); 70 | console.log('登录失败', error); 71 | } 72 | }); 73 | }, 74 | 75 | /** 76 | * 点击「清除会话」按钮 77 | */ 78 | clearSession() { 79 | // 清除保存在 storage 的会话信息 80 | qcloud.clearSession(); 81 | showSuccess('会话已清除'); 82 | }, 83 | 84 | /** 85 | * 点击「请求」按钮,测试带会话请求的功能 86 | */ 87 | doRequest() { 88 | showBusy('正在请求'); 89 | 90 | // qcloud.request() 方法和 wx.request() 方法使用是一致的,不过如果用户已经登录的情况下,会把用户的会话信息带给服务器,服务器可以跟踪用户 91 | qcloud.request({ 92 | // 要请求的地址 93 | url: this.data.requestUrl, 94 | 95 | // 请求之前是否登陆,如果该项指定为 true,会在请求之前进行登录 96 | login: true, 97 | 98 | success(result) { 99 | showSuccess('请求成功完成'); 100 | console.log('request success', result); 101 | }, 102 | 103 | fail(error) { 104 | showModel('请求失败', error); 105 | console.log('request fail', error); 106 | }, 107 | 108 | complete() { 109 | console.log('request complete'); 110 | } 111 | }); 112 | }, 113 | 114 | switchTunnel(e) { 115 | const turnedOn = e.detail.value; 116 | 117 | if (turnedOn && this.data.tunnelStatus == 'closed') { 118 | this.openTunnel(); 119 | 120 | } else if (!turnedOn && this.data.tunnelStatus == 'connected') { 121 | this.closeTunnel(); 122 | } 123 | }, 124 | 125 | /** 126 | * 点击「打开信道」,测试 WebSocket 信道服务 127 | */ 128 | openTunnel() { 129 | // 创建信道,需要给定后台服务地址 130 | var tunnel = this.tunnel = new qcloud.Tunnel(this.data.tunnelUrl); 131 | 132 | // 监听信道内置消息,包括 connect/close/reconnecting/reconnect/error 133 | tunnel.on('connect', () => { 134 | console.log('WebSocket 信道已连接'); 135 | this.setData({ tunnelStatus: 'connected' }); 136 | }); 137 | 138 | tunnel.on('close', () => { 139 | console.log('WebSocket 信道已断开'); 140 | this.setData({ tunnelStatus: 'closed' }); 141 | }); 142 | 143 | tunnel.on('reconnecting', () => { 144 | console.log('WebSocket 信道正在重连...') 145 | showBusy('正在重连'); 146 | }); 147 | 148 | tunnel.on('reconnect', () => { 149 | console.log('WebSocket 信道重连成功') 150 | showSuccess('重连成功'); 151 | }); 152 | 153 | tunnel.on('error', error => { 154 | showModel('信道发生错误', error); 155 | console.error('信道发生错误:', error); 156 | }); 157 | 158 | // 监听自定义消息(服务器进行推送) 159 | tunnel.on('speak', speak => { 160 | showModel('信道消息', speak); 161 | console.log('收到说话消息:', speak); 162 | }); 163 | 164 | // 打开信道 165 | tunnel.open(); 166 | 167 | this.setData({ tunnelStatus: 'connecting' }); 168 | }, 169 | 170 | /** 171 | * 点击「发送消息」按钮,测试使用信道发送消息 172 | */ 173 | sendMessage() { 174 | // 使用 tunnel.isActive() 来检测当前信道是否处于可用状态 175 | if (this.tunnel && this.tunnel.isActive()) { 176 | // 使用信道给服务器推送「speak」消息 177 | this.tunnel.emit('speak', { 178 | 'word': 'I say something at ' + new Date(), 179 | }); 180 | } 181 | }, 182 | 183 | /** 184 | * 点击「测试重连」按钮,测试重连 185 | * 也可以断开网络一段时间之后再连接,测试重连能力 186 | */ 187 | testReconnect() { 188 | // 不通过 SDK 关闭连接,而是直接用微信断开来模拟连接断开的情况下,考察 SDK 自动重连的能力 189 | wx.closeSocket(); 190 | }, 191 | 192 | /** 193 | * 点击「关闭信道」按钮,关闭已经打开的信道 194 | */ 195 | closeTunnel() { 196 | if (this.tunnel) { 197 | this.tunnel.close(); 198 | } 199 | 200 | this.setData({ tunnelStatus: 'closed' }); 201 | }, 202 | 203 | /** 204 | * 点击「聊天室」按钮,跳转到聊天室综合 Demo 的页面 205 | */ 206 | openChat() { 207 | // 微信只允许一个信道再运行,聊天室使用信道前,我们先把当前的关闭 208 | this.closeTunnel(); 209 | wx.navigateTo({ url: '../chat/chat' }); 210 | }, 211 | openDrawguess() { 212 | this.closeTunnel(); 213 | wx.navigateTo({ url: '../drawguess/index' }); 214 | }, 215 | openUpload() { 216 | wx.navigateTo({ url: '../upload/index' }); 217 | } 218 | }); 219 | -------------------------------------------------------------------------------- /pages/qcloud/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileOverview 演示会话服务和 WebSocket 信道服务的使用方式 3 | */ 4 | 5 | // 引入 QCloud 小程序增强 SDK 6 | var qcloud = require('../../vendor/qcloud-weapp-client-sdk/index'); 7 | 8 | // 引入配置 9 | var config = require('../../config'); 10 | 11 | // 显示繁忙提示 12 | var showBusy = text => wx.showToast({ 13 | title: text, 14 | icon: 'loading', 15 | duration: 10000 16 | }); 17 | 18 | // 显示成功提示 19 | var showSuccess = text => wx.showToast({ 20 | title: text, 21 | icon: 'success' 22 | }); 23 | 24 | // 显示失败提示 25 | var showModel = (title, content) => { 26 | wx.hideToast(); 27 | 28 | wx.showModal({ 29 | title, 30 | content: JSON.stringify(content), 31 | showCancel: false 32 | }); 33 | }; 34 | 35 | /** 36 | * 使用 Page 初始化页面,具体可参考微信公众平台上的文档 37 | */ 38 | Page({ 39 | 40 | /** 41 | * 初始数据,我们把服务地址显示在页面上 42 | */ 43 | data: { 44 | loginUrl: config.service.loginUrl, 45 | requestUrl: config.service.requestUrl, 46 | tunnelUrl: config.service.tunnelUrl, 47 | tunnelStatus: 'closed', 48 | tunnelStatusText: { 49 | closed: '已关闭', 50 | connecting: '正在连接...', 51 | connected: '已连接' 52 | } 53 | }, 54 | 55 | /** 56 | * 点击「登录」按钮,测试登录功能 57 | */ 58 | doLogin() { 59 | showBusy('正在登录'); 60 | 61 | // 登录之前需要调用 qcloud.setLoginUrl() 设置登录地址,不过我们在 app.js 的入口里面已经调用过了,后面就不用再调用了 62 | qcloud.login({ 63 | success(result) { 64 | showSuccess('登录成功'); 65 | console.log('登录成功', result); 66 | }, 67 | 68 | fail(error) { 69 | showModel('登录失败', error); 70 | console.log('登录失败', error); 71 | } 72 | }); 73 | }, 74 | 75 | /** 76 | * 点击「清除会话」按钮 77 | */ 78 | clearSession() { 79 | // 清除保存在 storage 的会话信息 80 | qcloud.clearSession(); 81 | showSuccess('会话已清除'); 82 | }, 83 | 84 | /** 85 | * 点击「请求」按钮,测试带会话请求的功能 86 | */ 87 | doRequest() { 88 | showBusy('正在请求'); 89 | 90 | // qcloud.request() 方法和 wx.request() 方法使用是一致的,不过如果用户已经登录的情况下,会把用户的会话信息带给服务器,服务器可以跟踪用户 91 | qcloud.request({ 92 | // 要请求的地址 93 | url: this.data.requestUrl, 94 | 95 | // 请求之前是否登陆,如果该项指定为 true,会在请求之前进行登录 96 | login: true, 97 | 98 | success(result) { 99 | showSuccess('请求成功完成'); 100 | console.log('request success', result); 101 | }, 102 | 103 | fail(error) { 104 | showModel('请求失败', error); 105 | console.log('request fail', error); 106 | }, 107 | 108 | complete() { 109 | console.log('request complete'); 110 | } 111 | }); 112 | }, 113 | 114 | switchTunnel(e) { 115 | const turnedOn = e.detail.value; 116 | 117 | if (turnedOn && this.data.tunnelStatus == 'closed') { 118 | this.openTunnel(); 119 | 120 | } else if (!turnedOn && this.data.tunnelStatus == 'connected') { 121 | this.closeTunnel(); 122 | } 123 | }, 124 | 125 | /** 126 | * 点击「打开信道」,测试 WebSocket 信道服务 127 | */ 128 | openTunnel() { 129 | // 创建信道,需要给定后台服务地址 130 | var tunnel = this.tunnel = new qcloud.Tunnel(this.data.tunnelUrl); 131 | 132 | // 监听信道内置消息,包括 connect/close/reconnecting/reconnect/error 133 | tunnel.on('connect', () => { 134 | console.log('WebSocket 信道已连接'); 135 | this.setData({ tunnelStatus: 'connected' }); 136 | }); 137 | 138 | tunnel.on('close', () => { 139 | console.log('WebSocket 信道已断开'); 140 | this.setData({ tunnelStatus: 'closed' }); 141 | }); 142 | 143 | tunnel.on('reconnecting', () => { 144 | console.log('WebSocket 信道正在重连...') 145 | showBusy('正在重连'); 146 | }); 147 | 148 | tunnel.on('reconnect', () => { 149 | console.log('WebSocket 信道重连成功') 150 | showSuccess('重连成功'); 151 | }); 152 | 153 | tunnel.on('error', error => { 154 | showModel('信道发生错误', error); 155 | console.error('信道发生错误:', error); 156 | }); 157 | 158 | // 监听自定义消息(服务器进行推送) 159 | tunnel.on('speak', speak => { 160 | showModel('信道消息', speak); 161 | console.log('收到说话消息:', speak); 162 | }); 163 | 164 | // 打开信道 165 | tunnel.open(); 166 | 167 | this.setData({ tunnelStatus: 'connecting' }); 168 | }, 169 | 170 | /** 171 | * 点击「发送消息」按钮,测试使用信道发送消息 172 | */ 173 | sendMessage() { 174 | // 使用 tunnel.isActive() 来检测当前信道是否处于可用状态 175 | if (this.tunnel && this.tunnel.isActive()) { 176 | // 使用信道给服务器推送「speak」消息 177 | this.tunnel.emit('speak', { 178 | 'word': 'I say something at ' + new Date(), 179 | }); 180 | } 181 | }, 182 | 183 | /** 184 | * 点击「测试重连」按钮,测试重连 185 | * 也可以断开网络一段时间之后再连接,测试重连能力 186 | */ 187 | testReconnect() { 188 | // 不通过 SDK 关闭连接,而是直接用微信断开来模拟连接断开的情况下,考察 SDK 自动重连的能力 189 | wx.closeSocket(); 190 | }, 191 | 192 | /** 193 | * 点击「关闭信道」按钮,关闭已经打开的信道 194 | */ 195 | closeTunnel() { 196 | if (this.tunnel) { 197 | this.tunnel.close(); 198 | } 199 | 200 | this.setData({ tunnelStatus: 'closed' }); 201 | }, 202 | 203 | /** 204 | * 点击「聊天室」按钮,跳转到聊天室综合 Demo 的页面 205 | */ 206 | openChat() { 207 | // 微信只允许一个信道再运行,聊天室使用信道前,我们先把当前的关闭 208 | this.closeTunnel(); 209 | wx.navigateTo({ url: '../chat/chat' }); 210 | }, 211 | openDrawguess() { 212 | this.closeTunnel(); 213 | wx.navigateTo({ url: '../drawguess/index' }); 214 | }, 215 | openUpload() { 216 | wx.navigateTo({ url: '../upload/index' }); 217 | } 218 | }); 219 | --------------------------------------------------------------------------------