├── pages ├── rank │ ├── rank.json │ ├── rank.wxml │ ├── rank.js │ └── rank.wxss ├── check │ ├── check.json │ ├── check.wxml │ ├── check.wxss │ └── check.js └── index │ ├── index.json │ ├── index.wxml │ ├── index.wxss │ └── index.js ├── img ├── examples │ ├── 1.png │ ├── 2.png │ ├── 3.png │ └── 4.png └── icon │ └── arrow.svg ├── jsconfig.json ├── app.json ├── project.config.json ├── utils ├── util.js ├── storage.js └── date_format.js ├── LICENSE ├── .gitignore ├── README.md ├── app.wxss ├── app.js └── libs ├── es6-promise.min.js └── av-weapp-min.js /pages/rank/rank.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/check/check.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/index/index.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /img/examples/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/algorithmdaybyday/Keepunch/HEAD/img/examples/1.png -------------------------------------------------------------------------------- /img/examples/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/algorithmdaybyday/Keepunch/HEAD/img/examples/2.png -------------------------------------------------------------------------------- /img/examples/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/algorithmdaybyday/Keepunch/HEAD/img/examples/3.png -------------------------------------------------------------------------------- /img/examples/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/algorithmdaybyday/Keepunch/HEAD/img/examples/4.png -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2015", 4 | "module": "commonjs" 5 | } 6 | } -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages":[ 3 | "pages/index/index", 4 | "pages/rank/rank", 5 | "pages/check/check" 6 | ], 7 | "window":{ 8 | "backgroundTextStyle":"light", 9 | "navigationBarBackgroundColor": "#F8F8F8", 10 | "navigationBarTitleText": "每日一题", 11 | "navigationBarTextStyle":"black", 12 | "enablePullDownRefresh": true 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /pages/rank/rank.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Rank 5 | 排名 6 | 7 | 8 | 9 | 10 | {{user.nickName}} 11 | {{user.times}} times 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /pages/index/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{date}} 5 | {{question_of_the_day.title}} 6 | 7 | 8 | 9 | 每日一道算法题 10 | 11 | 12 | A problem a day keeps foolishness away 13 | 14 | 15 | 16 | 17 | 18 | 19 | Copyright © 2017 20 | 21 | 22 | -------------------------------------------------------------------------------- /img/icon/arrow.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /project.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "项目配置文件。", 3 | "setting": { 4 | "urlCheck": true, 5 | "es6": true, 6 | "postcss": true, 7 | "minified": true 8 | }, 9 | "compileType": "weapp", 10 | "libVersion": "1.1.1", 11 | "appid": "wxca72f83dd031712b", 12 | "projectname": "Algorithm_day_by_day", 13 | "condition": { 14 | "weapp": { 15 | "current": -1, 16 | "list": [ 17 | { 18 | "id": -1, 19 | "name": "rank", 20 | "pathName": "pages/rank/rank", 21 | "query": "", 22 | "scene": "1044" 23 | }, 24 | { 25 | "id": 1, 26 | "name": "success", 27 | "pathName": "pages/check/check", 28 | "query": "", 29 | "scene": "1044" 30 | }, 31 | { 32 | "id": -1, 33 | "name": "check", 34 | "pathName": "pages/check/check", 35 | "query": "", 36 | "scene": "1044" 37 | } 38 | ] 39 | }, 40 | "search": { 41 | "current": -1, 42 | "list": [] 43 | }, 44 | "conversation": { 45 | "current": -1, 46 | "list": [] 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /utils/util.js: -------------------------------------------------------------------------------- 1 | const formatTime = date => { 2 | const year = date.getFullYear() 3 | const month = date.getMonth() + 1 4 | const day = date.getDate() 5 | const hour = date.getHours() 6 | const minute = date.getMinutes() 7 | const second = date.getSeconds() 8 | 9 | return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':') 10 | } 11 | 12 | const formatDate = date => { 13 | const year = date.getUTCFullYear() 14 | const month = date.getUTCMonth() + 1 15 | const day = date.getUTCDate() 16 | 17 | return [year, month, day].join("-") 18 | } 19 | 20 | const dateToday = function(){ 21 | // setup question 22 | const date = new Date() 23 | const date_today_num = 24 | Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()); 25 | const date_today = new Date(date_today_num); 26 | return date_today 27 | } 28 | 29 | const formatNumber = n => { 30 | n = n.toString() 31 | return n[1] ? n : '0' + n 32 | } 33 | 34 | module.exports = { 35 | formatTime: formatTime, 36 | formatDate: formatDate, 37 | dateToday: dateToday 38 | } 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 每日一道算法题 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # custom 61 | leancloud.config.js 62 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 每日一道算法题 - 2 | 3 | ## 微信打卡小程序 4 | 5 | 前端直接用微信提供的开发者工具写的,后端采用的是 leancloud。 6 | 7 | leancloud sdk 需要依赖一个在名为 leancloud.config.js 的文件,它被放在 utils 文件夹里,我push代码时没有包括 leancloud.config.js 。 8 | 9 | leancloud.config.js 包含了 leancloud 应用的 AppID 和 AppKey 信息: 10 | 11 | ``` 12 | module.exports = { 13 | appId: '你的AppID', 14 | appKey: '你的AppKey' 15 | } 16 | ``` 17 | 18 | ### Database design 19 | 20 | 数据库的设计采用了一个中间表 `Check` 来确定打卡的动作。 21 | 22 | 由于 leancloud 提供的数据库的性能有限,对子查询的支持也不太好。 23 | 24 | 所以设计数据库的时候冗余设计了 `rank` 表。 25 | 26 | 27 | ``` 28 | User: 29 | nickname: (string) 30 | gender: (number) 31 | avatarUrl: (string) 32 | location: { "country" : (string) , "province": (string) , "city": (string) } 33 | language: (string) 34 | belongsTo: (group) 35 | checktime: (number) 36 | lastcheckDate: (date) 37 | longestAttendence: (number) 38 | 39 | Check: 40 | checkedAt (datatime) 41 | question (Question) 42 | user (User) 43 | image (file) 44 | 45 | Group: 46 | hasMany: User 47 | 48 | Question: 49 | date: (date) 50 | title: (string) 51 | content: (string) 52 | url: (string) 53 | 54 | Rank: 55 | user: (string) 56 | avatarUrl: (string) 57 | checktime: (number) 58 | 59 | ``` 60 | 61 | 程序还很新,而且我第一次开发小程序,难免会有不完善的地方。 62 | 63 | ### 程序截图 64 | 65 | 主页 66 | 67 | ![1](img/examples/1.png) 68 | 69 | --- 70 | 71 | 打卡页 72 | 73 | ![1](img/examples/2.png) 74 | 75 | --- 76 | 77 | 打卡成功 78 | 79 | ![1](img/examples/3.png) 80 | 81 | --- 82 | 83 | 查看排名 84 | 85 | ![1](img/examples/4.png) 86 | 87 | (Also Thanks for the Contributors in the image) 88 | 89 | -------------------------------------------------------------------------------- /pages/index/index.wxss: -------------------------------------------------------------------------------- 1 | /* pages/check/check.wxss */ 2 | 3 | page { 4 | background: #F3F9FE; 5 | position: absolute; 6 | top: 0; 7 | bottom: 0; 8 | } 9 | 10 | .card { 11 | display: flex; 12 | justify-content: center; 13 | margin-left:10%; 14 | margin-right:10%; 15 | width: 80%; 16 | flex-direction: column; 17 | } 18 | 19 | .card_date { 20 | color:#ddd; 21 | align-self: center; 22 | font-size:33rpx; 23 | } 24 | 25 | .card_title { 26 | text-align:center; 27 | color:#666; 28 | padding-top:20rpx; 29 | padding-bottom:20rpx; 30 | width:100%; 31 | border-bottom:1px rgba(0, 0, 0, 0.27) solid; 32 | font-size:33rpx; 33 | } 34 | 35 | .card_content { 36 | font-size: 28rpx; 37 | padding-top:20rpx; 38 | color:#999; 39 | line-height:1.5em; 40 | text-align:center; 41 | } 42 | .login { 43 | display: flex; 44 | flex-direction: column; 45 | justify-content: space-between; 46 | align-items: center; 47 | width: 100%; 48 | } 49 | 50 | .page_hd { 51 | /* padding: 40px; */ 52 | height: 450rpx; 53 | width:100%; 54 | /* background: greenyellow;*/ 55 | } 56 | 57 | .header image { 58 | height: 808rpx; 59 | width: 100%; 60 | } 61 | 62 | .title { 63 | line-height: 130rpx; 64 | font-size: 23px; 65 | color: #ff525d; 66 | } 67 | 68 | .info { 69 | padding: 0 60rpx; 70 | font-size: 13px; 71 | line-height:37rpx; 72 | color: rgba(0, 0, 0, 0.27); 73 | } 74 | 75 | .button { 76 | margin: 60rpx auto 30rpx auto; 77 | width: 80%; 78 | } 79 | 80 | .btn { 81 | background-color: #ff525d; 82 | color: #ffffff; 83 | } 84 | 85 | .btn-hover { 86 | background-color: #dd1200; 87 | opacity: 0.7; 88 | } 89 | 90 | -------------------------------------------------------------------------------- /pages/check/check.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 打卡成功 14 | 共打卡 15 | {{checktime}}次,连续打卡 16 | {{longestAttendance}} 17 | 点击头像查看排名 18 | 19 | 20 | 打卡关闭中 21 | 今日题目还未发布 22 | 23 | 24 | 确认已完成今天的题目 25 | 26 | 长按这里打卡 27 | 请上传AC后的截图 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 每日一道算法题 36 | 37 | Copyright © 2017 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /pages/rank/rank.js: -------------------------------------------------------------------------------- 1 | const storage = require("../../utils/storage.js") 2 | 3 | const loadingRankData = function(res, _this_page) { 4 | let users = [] 5 | res.forEach((rank) => { 6 | const user = rank.get("user") 7 | const nickname = user.get("nickName") 8 | const avatarUrl = user.get("avatarUrl") 9 | const times = rank.get("times") 10 | users.push({ nickName: nickname, avatarUrl: avatarUrl, times: times }) 11 | }) 12 | _this_page.setData({ 13 | users: users 14 | }) 15 | } 16 | 17 | // pages/rank/rank.js 18 | Page({ 19 | 20 | /** 21 | * 页面的初始数据 22 | */ 23 | data: { 24 | users: [{ 25 | nickName: "wild-flame", 26 | avatarUrl: "https://wx.qlogo.cn/mmopen/vi_32/DYAIOgq83epwO7nM7ShxZuLzcHic2ra38tkVcVOYlmP1ETITEaLhjUqYvLeEzrslPuNnibibAibhBgdxTbdq5iax8bg/0", 27 | times: 5 28 | }] 29 | }, 30 | 31 | /** 32 | * 生命周期函数--监听页面加载 33 | */ 34 | onLoad: function () { 35 | const _this = this 36 | storage.queryRankAll().then(res=> { 37 | loadingRankData(res, _this) 38 | }).catch(console.log) 39 | }, 40 | 41 | /** 42 | * 生命周期函数--监听页面初次渲染完成 43 | */ 44 | onReady: function () { 45 | 46 | }, 47 | 48 | /** 49 | * 生命周期函数--监听页面显示 50 | */ 51 | onShow: function () { 52 | 53 | }, 54 | 55 | /** 56 | * 生命周期函数--监听页面隐藏 57 | */ 58 | onHide: function () { 59 | 60 | }, 61 | 62 | /** 63 | * 生命周期函数--监听页面卸载 64 | */ 65 | onUnload: function () { 66 | 67 | }, 68 | 69 | /** 70 | * 页面相关事件处理函数--监听用户下拉动作 71 | */ 72 | onPullDownRefresh: function () { 73 | const _this = this 74 | storage.queryRankAll().then(res => { 75 | wx.stopPullDownRefresh() 76 | loadingRankData(res, _this) 77 | }).catch(console.log) 78 | }, 79 | 80 | /** 81 | * 页面上拉触底事件的处理函数 82 | */ 83 | onReachBottom: function () { 84 | 85 | }, 86 | 87 | /** 88 | * 用户点击右上角分享 89 | */ 90 | onShareAppMessage: function () { 91 | 92 | } 93 | }) -------------------------------------------------------------------------------- /pages/check/check.wxss: -------------------------------------------------------------------------------- 1 | .extra-area{ 2 | position:fixed; 3 | left:0; 4 | bottom:0; 5 | width:100%; 6 | text-align:center; 7 | margin-bottom:15px; 8 | font-size:14px; 9 | color:#999; 10 | } 11 | 12 | .check { 13 | padding: 50rpx 50rpx 50rpx 50rpx; 14 | width: 100rpx; 15 | height: 100rpx; 16 | margin: auto; 17 | border: none; 18 | border-radius: 50%; 19 | box-shadow: 0 0 2px rgba(0,0,0,.12), 0 2px 2px rgba(0,0,0,.2); 20 | } 21 | 22 | .btn-area { 23 | margin: 1.17647059em 15px .3em 24 | } 25 | 26 | .btn { 27 | position: relative; 28 | 29 | padding: 30rpx 30rpx 30rpx 30rpx; 30 | display: block; 31 | 32 | overflow: hidden; 33 | 34 | border-width: 0; 35 | outline: none; 36 | border-radius: 2px; 37 | box-shadow: 0 1px 4px rgba(0, 0, 0, .6); 38 | 39 | background-color: #2ecc71; 40 | color: #ecf0f1; 41 | 42 | transition: background-color 1s; 43 | } 44 | 45 | .btn:active { 46 | background-color: #ff525d; 47 | } 48 | 49 | .btn span { 50 | display: block; 51 | padding: 12px 24px; 52 | } 53 | 54 | image.preview { 55 | width: 90%; 56 | } 57 | 58 | .msg { 59 | padding-top: 36px; 60 | text-align: center; 61 | } 62 | 63 | .msg__title { 64 | color:#ff525d; 65 | margin-bottom:5px; 66 | font-weight:400; 67 | font-size:20px; 68 | } 69 | 70 | .msg__desc { 71 | font-size:14px; 72 | color:#999; 73 | } 74 | 75 | .msg__link { 76 | display:inline; 77 | color:#586c94; 78 | } 79 | 80 | .text-area { 81 | margin-bottom:25px; 82 | padding:0 20px; 83 | } 84 | 85 | .userinfo { 86 | display: flex; 87 | flex-direction: column; 88 | align-items: center; 89 | } 90 | 91 | .userinfo-avatar { 92 | width: 128rpx; 93 | height: 128rpx; 94 | margin: 20rpx; 95 | border-radius: 50%; 96 | } 97 | 98 | .userinfo-nickname { 99 | color: #aaa; 100 | } 101 | 102 | .usermotto { 103 | margin-top: 200px; 104 | } -------------------------------------------------------------------------------- /app.wxss: -------------------------------------------------------------------------------- 1 | /**app.wxss**/ 2 | 3 | page{ 4 | height:100%; 5 | background-color: #F8F8F8; 6 | font-size: 16px; 7 | font-family: -apple-system-font,Helvetica Neue,Helvetica,sans-serif; 8 | } 9 | 10 | .container { 11 | background: #F8F8F8; 12 | height: 100%; 13 | display: flex; 14 | flex-direction: column; 15 | align-items: center; 16 | justify-content: space-between; 17 | padding: 200rpx 0; 18 | box-sizing: border-box; 19 | } 20 | 21 | .page__hd { 22 | padding: 40px; 23 | } 24 | .page__bd { 25 | padding-bottom: 40px; 26 | } 27 | .page__bd_spacing { 28 | padding-left: 15px; 29 | padding-right: 15px; 30 | } 31 | 32 | .page__ft{ 33 | padding-bottom: 10px; 34 | text-align: center; 35 | } 36 | 37 | .page__title { 38 | text-align: left; 39 | font-size: 20px; 40 | font-weight: 400; 41 | } 42 | 43 | .page__desc { 44 | margin-top: 5px; 45 | color: #888888; 46 | text-align: left; 47 | font-size: 14px; 48 | } 49 | 50 | /* button */ 51 | .button { 52 | margin: 60rpx auto 30rpx auto; 53 | width: 80%; 54 | } 55 | 56 | .btn { 57 | background-color: #ff525d; 58 | color: #ffffff; 59 | margin-top:15px; 60 | } 61 | 62 | .btn:first-child { 63 | margin-top:0px; 64 | } 65 | 66 | .btn-hover { 67 | background-color: #1976d2; 68 | opacity: 0.7; 69 | } 70 | 71 | /* footer */ 72 | 73 | .extra-area{ 74 | position:fixed; 75 | left:0; 76 | bottom:0; 77 | width:100%; 78 | text-align:center; 79 | margin-bottom:15px; 80 | font-size:14px; 81 | color:#999; 82 | } 83 | 84 | .btn-area { 85 | margin: 1.17647059em 15px .3em 86 | } 87 | 88 | .msg { 89 | padding-top: 36px; 90 | text-align: center; 91 | } 92 | 93 | .msg__title { 94 | margin-bottom:5px; 95 | font-weight:400; 96 | font-size:20px; 97 | } 98 | 99 | .msg__desc { 100 | font-size:14px; 101 | color:#999; 102 | } 103 | 104 | .msg__link { 105 | display:inline; 106 | color:#586c94; 107 | } 108 | 109 | .text-area { 110 | margin-bottom:25px; 111 | padding:0 20px; 112 | } -------------------------------------------------------------------------------- /pages/rank/rank.wxss: -------------------------------------------------------------------------------- 1 | /* pages/rank/rank.wxss */ 2 | 3 | .page { 4 | min-height: 100%; 5 | position: relative; 6 | } 7 | 8 | image.cell__primary { 9 | width:60rpx; 10 | height:60rpx; 11 | margin-right: 20rpx; 12 | } 13 | 14 | .main { 15 | padding-bottom: 100rpx; 16 | } 17 | 18 | .cells { 19 | position: relative; 20 | margin-top: 1.17647059em; 21 | background-color: #fff; 22 | line-height: 1.41176471; 23 | font-size: 17px; 24 | } 25 | 26 | .cells:before { 27 | top: 0; 28 | border-top: 1rpx solid #d9d9d9; 29 | } 30 | 31 | .cells:after, .cells:before { 32 | content: " "; 33 | position: absolute; 34 | left: 0; 35 | right: 0; 36 | height: 1px; 37 | color: #d9d9d9; 38 | } 39 | 40 | .cells:after { 41 | bottom: 0; 42 | border-bottom: 1rpx solid #d9d9d9; 43 | } 44 | 45 | .cells__title { 46 | margin-top: 0.77em; 47 | margin-bottom: 0.3em; 48 | padding-left: 15px; 49 | padding-right: 15px; 50 | color: #999; 51 | font-size: 14px; 52 | } 53 | 54 | .cell { 55 | padding: 10px 15px; 56 | position: relative; 57 | display: -webkit-box; 58 | display: -webkit-flex; 59 | display: flex; 60 | -webkit-box-align: center; 61 | -webkit-align-items: center; 62 | align-items: center; 63 | } 64 | 65 | .cell:before { 66 | content: " "; 67 | position: absolute; 68 | left: 0; 69 | top: 0; 70 | right: 0; 71 | height: 1px; 72 | border-top: 1rpx solid #d9d9d9; 73 | color: #d9d9d9; 74 | left: 15px; 75 | } 76 | 77 | .cell:first-child:before { 78 | display: none; 79 | } 80 | 81 | .cell_active { 82 | background-color: #ececec; 83 | } 84 | 85 | .cell_primary { 86 | -webkit-box-align: start; 87 | -webkit-align-items: flex-start; 88 | align-items: flex-start; 89 | } 90 | 91 | .cell__bd { 92 | -webkit-box-flex: 1; 93 | -webkit-flex: 1; 94 | flex: 1; 95 | } 96 | 97 | .cell__ft { 98 | text-align: right; 99 | color: #999; 100 | } 101 | 102 | .footer-area { 103 | position: absolute; 104 | left: 0; 105 | bottom: 0; 106 | text-align: center; 107 | margin: 15rpx 15rpx 15rpx 15rpx; 108 | font-size: 14px; 109 | color: #999; 110 | width: 100%; 111 | } 112 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | const AV = require("./libs/av-weapp-min.js") 2 | const config = require("./utils/leancloud.config.js") 3 | const storage = require("./utils/storage.js") 4 | const util = require("./utils/util.js") 5 | 6 | console.log('Init leancloud') 7 | 8 | AV.init({ 9 | appId: config.appId, 10 | appKey: config.appKey 11 | }); 12 | 13 | //app.js 14 | App({ 15 | onLaunch: function () { 16 | const _this_app = this; 17 | // console.log(wx.getSystemInfoSync()) 18 | // setup date 19 | const date = new Date() 20 | const date_today = util.dateToday() 21 | _this_app.globalData.date_today = date_today 22 | 23 | // 展示本地存储能力 24 | // var logs = wx.getStorageSync('logs') || [] 25 | // logs.unshift(Date.now()) 26 | // wx.setStorageSync('logs', logs) 27 | 28 | // 登录 29 | AV.User.loginWithWeapp().then(user => { 30 | _this_app.globalData.user = user; 31 | console.log("Login with weapp success") 32 | }).then(() => { 33 | wx.getUserInfo({ 34 | success: res => { 35 | // 可以将 res 发送给后台解码出 unionId 36 | _this_app.globalData.userInfo = res.userInfo 37 | 38 | // TODO:同步用户信息到服务器 39 | 40 | // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 41 | // 所以此处加入 callback 以防止这种情况 42 | if (this.userInfoReadyCallback) { 43 | this.userInfoReadyCallback(res) 44 | } 45 | } 46 | }) 47 | }).catch(function(err) { 48 | wx.showToast({ 49 | title: '失败', 50 | icon: 'failed', 51 | duration: 2000 52 | }) 53 | console.log(err) 54 | }) 55 | 56 | // Query question 57 | storage.queryQuestion(date_today).then(function (ques) { 58 | wx.showToast({ 59 | title: "查询完成", 60 | icon: 'success', 61 | duration: 2000 62 | }) 63 | if (ques !== false) { 64 | _this_app.globalData.question = ques 65 | _this_app.globalData.checkable = true 66 | if (_this_app.quesReadyCallback) { 67 | _this_app.quesReadyCallback(ques) 68 | } 69 | } else { 70 | console.log("Question of the day is unset"); 71 | } 72 | }).catch(function(err) { 73 | console.log(err); 74 | wx.showModal({ 75 | title: '获取问题失败', 76 | content: '请检查网络连接,下拉刷新重试', 77 | showCancel: false 78 | }) 79 | }) 80 | }, 81 | 82 | globalData: { 83 | user: null, 84 | userInfo: null, 85 | checked: false, 86 | checkable: false, 87 | question: null, 88 | date_today: null, 89 | } 90 | }) -------------------------------------------------------------------------------- /pages/index/index.js: -------------------------------------------------------------------------------- 1 | const util = require("../../utils/util"); 2 | const dateFormat = require("../../utils/date_format") 3 | const storage = require("../../utils/storage") 4 | const app = getApp(); 5 | 6 | // pages/check/check.js 7 | Page({ 8 | 9 | /** 10 | * 页面的初始数据 11 | */ 12 | data: { 13 | question_of_the_day: { 14 | title: "Question of the Day is not ready yet", 15 | url:""}, 16 | checkable: false, 17 | date: "Oct.00 2000" 18 | }, 19 | 20 | /** 21 | * 生命周期函数--监听页面加载 22 | */ 23 | onLoad: function (options) { 24 | const now = new Date() 25 | this.setData({ 26 | date: now.format("dd mmm. yyyy") 27 | }) 28 | if (app.globalData.question !== null) { 29 | this.setData({ 30 | question_of_the_day: app.globalData.question.attributes, 31 | checkable: true 32 | }) 33 | console.log("setdata") 34 | } else { 35 | app.quesReadyCallback = ques => { 36 | this.setData({ 37 | question_of_the_day: ques.attributes, 38 | checkable: true 39 | }) 40 | app.globalData.checkable = true 41 | console.log("callback") 42 | } 43 | } 44 | }, 45 | 46 | /** 47 | * 生命周期函数--监听页面初次渲染完成 48 | */ 49 | onReady: function () { 50 | 51 | }, 52 | 53 | /** 54 | * 生命周期函数--监听页面显示 55 | */ 56 | onShow: function () { 57 | 58 | }, 59 | 60 | /** 61 | * 生命周期函数--监听页面隐藏 62 | */ 63 | onHide: function () { 64 | 65 | }, 66 | 67 | /** 68 | * 生命周期函数--监听页面卸载 69 | */ 70 | onUnload: function () { 71 | 72 | }, 73 | 74 | /** 75 | * 页面相关事件处理函数--监听用户下拉动作 76 | */ 77 | onPullDownRefresh: function () { 78 | storage.queryQuestion(util.dateToday()).then(function (ques) { 79 | wx.stopPullDownRefresh() 80 | wx.showToast({ 81 | title: "查询完成", 82 | icon: 'success', 83 | duration: 2000 84 | }) 85 | if (ques !== false) { 86 | app.globalData.question = ques 87 | app.globalData.checkable = true 88 | if (app.quesReadyCallback) { 89 | app.quesReadyCallback(ques) 90 | } 91 | } else { 92 | console.log("Question of the day is unset"); 93 | } 94 | }).catch(function (err) { 95 | console.log(err); 96 | wx.stopPullDownRefresh() 97 | wx.showToast({ 98 | title: "获取问题失败", 99 | icon: 'loading', 100 | duration: 2000, 101 | }) 102 | }) 103 | }, 104 | 105 | /** 106 | * 页面上拉触底事件的处理函数 107 | */ 108 | onReachBottom: function () { 109 | 110 | }, 111 | 112 | bindCheckTap: function () { 113 | wx.getUserInfo({ 114 | success: res => { 115 | // 可以将 res 发送给后台解码出 unionId 116 | app.globalData.userInfo = res.userInfo 117 | wx.navigateTo({ 118 | url: '../check/check' 119 | }) 120 | } 121 | }) 122 | }, 123 | 124 | /** 125 | * 用户点击右上角分享 126 | */ 127 | onShareAppMessage: function () { 128 | 129 | } 130 | }) -------------------------------------------------------------------------------- /utils/storage.js: -------------------------------------------------------------------------------- 1 | var AV = require('../libs/av-weapp-min.js'), 2 | config = require('leancloud.config.js'); 3 | 4 | const Promise = require('../libs/es6-promise.min.js').Promise 5 | 6 | module.exports = { 7 | 8 | init: function () { 9 | AV.init({ 10 | appId: config.appId, 11 | appKey: config.appKey 12 | }); 13 | console.log('初始化 leancloud...') 14 | }, 15 | 16 | update(objectId, className, data) { 17 | return new Promise((resolve, reject) => { 18 | console.log('更新...'); 19 | let klass = AV.Object.createWithoutData(className, objectId); 20 | // 保存更新 21 | klass.save(data).then( 22 | function (res) { 23 | console.log('数据更新成功'); 24 | resolve() 25 | }, 26 | err => { console.error(err); reject(); } 27 | ); 28 | }) 29 | }, 30 | 31 | queryQuestion: function (date) { 32 | // get today's question 33 | // data Format year-mm-dd 34 | return new Promise((resolve, reject) => { 35 | console.log("查询今天的题目") 36 | wx.showLoading({ 37 | title: '查询题目', 38 | }) 39 | let query = new AV.Query("Question"); 40 | query.greaterThanOrEqualTo("date", new Date(date)) 41 | query.find().then(res => { 42 | if (res.length === 0) { 43 | console.log("尚无今日题目"); 44 | resolve(false) 45 | } else { 46 | console.log(res[0]) 47 | console.log("获取题目成功"); 48 | resolve(res[0]) 49 | } 50 | wx.hideLoading() 51 | }).catch((err) => { 52 | wx.hideLoading() 53 | console.log(err); 54 | reject(err); 55 | }) 56 | }) 57 | }, 58 | 59 | queryCheck(user, date) { 60 | return new Promise((resolve, reject) => { 61 | wx.showLoading({ 62 | title: '查询打卡结果', 63 | }) 64 | let query = new AV.Query("Check"); 65 | query.equalTo("user", user) 66 | query.equalTo("date", new Date(date)) 67 | query.include(["user", "question"]) 68 | query.find().then(res => { 69 | if (res.length !== 0) { 70 | console.log("查询打卡结果") 71 | resolve(res) 72 | } else { 73 | console.log("无打卡") 74 | resolve(false) 75 | } 76 | wx.hideLoading() 77 | }).catch(function (err) { 78 | wx.hideLoading() 79 | console.log(err); reject(err) 80 | }) 81 | }) 82 | }, 83 | 84 | queryRank(user) { 85 | return new Promise((resolve, reject) => { 86 | wx.showLoading({ 87 | title: '查询排名', 88 | }) 89 | let query = new AV.Query("Rank") 90 | query.equalTo("user", user) 91 | query.find().then(function (res) { 92 | if (res.length === 0) { 93 | console.log("用户无排名") 94 | resolve(false) 95 | } else { 96 | console.log("用户有排名") 97 | resolve(res[0]) 98 | } 99 | return 100 | wx.hideLoading() 101 | }).catch((err) => { 102 | reject(err) 103 | }) 104 | }) 105 | }, 106 | 107 | queryRankAll() { 108 | return new Promise((resolve, reject) => { 109 | wx.showLoading({ 110 | title: '查询全部排名', 111 | }) 112 | console.log("queryRankAll") 113 | let query = new AV.Query("Rank") 114 | query.addDescending("times") 115 | query.addAscending('updatedAt'); 116 | query.include(["user"]) 117 | query.find().then(function (res) { 118 | if (res.length === 0) { 119 | throw new Error("没有任何排名数据。") 120 | } else { 121 | console.log("有排名") 122 | resolve(res) 123 | } 124 | wx.hideLoading() 125 | return 126 | }).catch((err) => { 127 | reject(err) 128 | }) 129 | }) 130 | } 131 | } -------------------------------------------------------------------------------- /utils/date_format.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Date Format 1.2.3 3 | * (c) 2007-2009 Steven Levithan 4 | * MIT license 5 | * 6 | * Includes enhancements by Scott Trenda 7 | * and Kris Kowal 8 | * 9 | * Accepts a date, a mask, or a date and a mask. 10 | * Returns a formatted version of the given date. 11 | * The date defaults to the current date/time. 12 | * The mask defaults to dateFormat.masks.default. 13 | */ 14 | 15 | var dateFormat = function () { 16 | var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g, 17 | timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, 18 | timezoneClip = /[^-+\dA-Z]/g, 19 | pad = function (val, len) { 20 | val = String(val); 21 | len = len || 2; 22 | while (val.length < len) val = "0" + val; 23 | return val; 24 | }; 25 | 26 | // Regexes and supporting functions are cached through closure 27 | return function (date, mask, utc) { 28 | var dF = dateFormat; 29 | 30 | // You can't provide utc if you skip other args (use the "UTC:" mask prefix) 31 | if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) { 32 | mask = date; 33 | date = undefined; 34 | } 35 | 36 | // Passing date through Date applies Date.parse, if necessary 37 | date = date ? new Date(date) : new Date; 38 | if (isNaN(date)) throw SyntaxError("invalid date"); 39 | 40 | mask = String(dF.masks[mask] || mask || dF.masks["default"]); 41 | 42 | // Allow setting the utc argument via the mask 43 | if (mask.slice(0, 4) == "UTC:") { 44 | mask = mask.slice(4); 45 | utc = true; 46 | } 47 | 48 | var _ = utc ? "getUTC" : "get", 49 | d = date[_ + "Date"](), 50 | D = date[_ + "Day"](), 51 | m = date[_ + "Month"](), 52 | y = date[_ + "FullYear"](), 53 | H = date[_ + "Hours"](), 54 | M = date[_ + "Minutes"](), 55 | s = date[_ + "Seconds"](), 56 | L = date[_ + "Milliseconds"](), 57 | o = utc ? 0 : date.getTimezoneOffset(), 58 | flags = { 59 | d: d, 60 | dd: pad(d), 61 | ddd: dF.i18n.dayNames[D], 62 | dddd: dF.i18n.dayNames[D + 7], 63 | m: m + 1, 64 | mm: pad(m + 1), 65 | mmm: dF.i18n.monthNames[m], 66 | mmmm: dF.i18n.monthNames[m + 12], 67 | yy: String(y).slice(2), 68 | yyyy: y, 69 | h: H % 12 || 12, 70 | hh: pad(H % 12 || 12), 71 | H: H, 72 | HH: pad(H), 73 | M: M, 74 | MM: pad(M), 75 | s: s, 76 | ss: pad(s), 77 | l: pad(L, 3), 78 | L: pad(L > 99 ? Math.round(L / 10) : L), 79 | t: H < 12 ? "a" : "p", 80 | tt: H < 12 ? "am" : "pm", 81 | T: H < 12 ? "A" : "P", 82 | TT: H < 12 ? "AM" : "PM", 83 | Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""), 84 | o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4), 85 | S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10] 86 | }; 87 | 88 | return mask.replace(token, function ($0) { 89 | return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1); 90 | }); 91 | }; 92 | }(); 93 | 94 | // Some common format strings 95 | dateFormat.masks = { 96 | "default": "ddd mmm dd yyyy HH:MM:ss", 97 | shortDate: "m/d/yy", 98 | mediumDate: "mmm d, yyyy", 99 | longDate: "mmmm d, yyyy", 100 | fullDate: "dddd, mmmm d, yyyy", 101 | shortTime: "h:MM TT", 102 | mediumTime: "h:MM:ss TT", 103 | longTime: "h:MM:ss TT Z", 104 | isoDate: "yyyy-mm-dd", 105 | isoTime: "HH:MM:ss", 106 | isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", 107 | isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'" 108 | }; 109 | 110 | // Internationalization strings 111 | dateFormat.i18n = { 112 | dayNames: [ 113 | "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", 114 | "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" 115 | ], 116 | monthNames: [ 117 | "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", 118 | "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" 119 | ] 120 | }; 121 | 122 | // For convenience... 123 | Date.prototype.format = function (mask, utc) { 124 | return dateFormat(this, mask, utc); 125 | }; 126 | -------------------------------------------------------------------------------- /pages/check/check.js: -------------------------------------------------------------------------------- 1 | //index.js 2 | const storage = require("../../utils/storage.js") 3 | const AV = require("../../libs/av-weapp-min.js") 4 | const util = require("../../utils/util"); 5 | const Promise = require('../../libs/es6-promise.min.js').Promise 6 | 7 | //获取应用实例 8 | const app = getApp() 9 | 10 | const check = function (user, question, date, imageUrl) { 11 | return new Promise((resolve, reject) => { 12 | wx.showLoading({ 13 | title: '打卡中', 14 | }) 15 | // update check 16 | let check = null; 17 | let rank = null; 18 | let checktime = 0; 19 | let longestAttendance = 0; 20 | storage.queryCheck(user, date).then((res) => { 21 | if (res === false) { 22 | check = new AV.Object("Check") 23 | check.set("user", user) 24 | check.set("question", question) 25 | check.set("date", new Date(date)) 26 | check.set("image", imageUrl) 27 | } else { 28 | throw new Error("已打卡") 29 | } 30 | const lastcheckDate = user.get("lastcheckDate") 31 | if (lastcheckDate >= date - 86400003) { 32 | console.log("连续打卡") 33 | user.increment("longestAttendance", 1) 34 | } else { 35 | console.log("新打卡") 36 | user.set("longestAttendance", 1) 37 | } 38 | user.set("lastcheckDate", new Date(date)) 39 | user.increment("checktime", 1) 40 | return storage.queryRank(user) 41 | }).then(res => { 42 | console.log("设置 Rank") 43 | if (res === false) { 44 | rank = new AV.Object("Rank") 45 | rank.set("user", user) 46 | rank.increment("times", 1) 47 | } else { 48 | rank = res 49 | rank.increment("times", 1) 50 | } 51 | return AV.Object.saveAll([user, rank, check]) 52 | }).then(function () { 53 | console.log("打卡成功") 54 | wx.hideLoading() 55 | wx.showToast({ 56 | title: '打卡成功', 57 | duration: 2000 58 | }) 59 | longestAttendance = user.get("longestAttendance") 60 | checktime = user.get("checktime") 61 | resolve() 62 | }).catch((err) => { 63 | wx.hideLoading() 64 | console.log(err); 65 | wx.showToast({ 66 | title: '打卡失败', 67 | icon: 'loading', 68 | duration: 2000 69 | }) 70 | reject(); 71 | }) 72 | }) 73 | } 74 | 75 | Page({ 76 | data: { 77 | userInfo: {}, 78 | hasUserInfo: false, 79 | checktime: 0, 80 | longestAttendance: 0, 81 | checked: true, 82 | checkable: false, 83 | imageFile: { uploaded: false, tempFilePath:"", url: ""} 84 | }, 85 | 86 | checkTap: function () { 87 | const _thisPage = this 88 | check(app.globalData.user, app.globalData.question, util.dateToday(),_thisPage.data.imageFile.url).then(() => { 89 | _thisPage.setData({ 90 | checked: true, 91 | checktime: app.globalData.user.attributes.checktime, 92 | longestAttendance: app.globalData.user.attributes.longestAttendance 93 | }) 94 | }) 95 | }, 96 | 97 | uploadImage: function() { 98 | const _thisPage = this 99 | wx.chooseImage({ 100 | count: 1, 101 | sizeType: ['original', 'compressed'], 102 | sourceType: ['album', 'camera'], 103 | success: function (res) { 104 | wx.showLoading({title: '上传中'}) 105 | const tempFilePath = res.tempFilePaths[0]; 106 | new AV.File('file-name', { 107 | blob: { 108 | uri: tempFilePath, 109 | }, 110 | }).save().then( 111 | file => { 112 | _thisPage.setData({ 113 | imageFile: { 114 | uploaded: true, 115 | tempFilePath: tempFilePath, 116 | url: file.url() 117 | } 118 | }) 119 | wx.hideLoading() 120 | wx.showToast({ 121 | title:"上传成功" 122 | }) 123 | } 124 | ).catch(function(err) { 125 | wx.hideLoading() 126 | wx.showToast({ 127 | title: "上传失败", 128 | icon: "loading" 129 | }) 130 | console.error(err) 131 | }); 132 | } 133 | }); 134 | }, 135 | 136 | //事件处理函数 137 | bindViewTap: function () { 138 | if (this.data.checked) { 139 | wx.navigateTo({ 140 | url: '../rank/rank' 141 | }) 142 | } 143 | }, 144 | 145 | onLoad: function () { 146 | if (app.globalData.userInfo) { 147 | this.setData({ 148 | userInfo: app.globalData.userInfo, 149 | checkable: app.globalData.checkable, 150 | hasUserInfo: true, 151 | longestAttendance: app.globalData.user.get("longestAttendance"), 152 | checktime: app.globalData.user.get("checktime") 153 | }) 154 | 155 | // update userinfo 156 | const user = AV.User.current(); 157 | user.set(app.globalData.userInfo).save().then(user => { 158 | // 成功,此时可在控制台中看到更新后的用户信息 159 | app.globalData.user = user; 160 | }).catch(console.error); 161 | } else { 162 | wx.getUserInfo({ 163 | success: res => { 164 | app.globalData.userInfo = res.userInfo 165 | this.setData({ 166 | userInfo: res.userInfo, 167 | hasUserInfo: true 168 | }) 169 | 170 | // update userinfo to user in callback 171 | const user = AV.User.current(); 172 | user.set(res.userInfo).save().then(user => { 173 | // 成功,此时可在控制台中看到更新后的用户信息 174 | app.globalData.user = user; 175 | this.setData({ 176 | longestAttendance: app.globalData.user.get("longestAttendance"), 177 | checktime: app.globalData.user.get("checktime") 178 | }) 179 | }).catch(console.error); 180 | 181 | } 182 | }) 183 | } 184 | 185 | // querycheck 186 | if (app.globalData.checkable === true) { 187 | storage.queryCheck(app.globalData.user, util.dateToday()).then((res) => { 188 | console.log(res) 189 | if (res === false) { 190 | app.globalData.checked = false 191 | this.setData({ 192 | checked: false 193 | }) 194 | } else { 195 | app.globalData.checked = true 196 | this.setData({ 197 | checked: true 198 | }) 199 | } 200 | }) 201 | } 202 | }, 203 | }) 204 | -------------------------------------------------------------------------------- /libs/es6-promise.min.js: -------------------------------------------------------------------------------- 1 | !function (t, e) { "object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : t.ES6Promise = e() }(this, function () { "use strict"; function t(t) { var e = typeof t; return null !== t && ("object" === e || "function" === e) } function e(t) { return "function" == typeof t } function n(t) { I = t } function r(t) { J = t } function o() { return function () { return process.nextTick(a) } } function i() { return "undefined" != typeof H ? function () { H(a) } : c() } function s() { var t = 0, e = new V(a), n = document.createTextNode(""); return e.observe(n, { characterData: !0 }), function () { n.data = t = ++t % 2 } } function u() { var t = new MessageChannel; return t.port1.onmessage = a, function () { return t.port2.postMessage(0) } } function c() { var t = setTimeout; return function () { return t(a, 1) } } function a() { for (var t = 0; t < G; t += 2) { var e = $[t], n = $[t + 1]; e(n), $[t] = void 0, $[t + 1] = void 0 } G = 0 } function f() { try { var t = require, e = t("vertx"); return H = e.runOnLoop || e.runOnContext, i() } catch (n) { return c() } } function l(t, e) { var n = arguments, r = this, o = new this.constructor(p); void 0 === o[et] && k(o); var i = r._state; return i ? !function () { var t = n[i - 1]; J(function () { return x(i, o, t, r._result) }) }() : E(r, o, t, e), o } function h(t) { var e = this; if (t && "object" == typeof t && t.constructor === e) return t; var n = new e(p); return g(n, t), n } function p() { } function v() { return new TypeError("You cannot resolve a promise with itself") } function d() { return new TypeError("A promises callback cannot return that same promise.") } function _(t) { try { return t.then } catch (e) { return it.error = e, it } } function y(t, e, n, r) { try { t.call(e, n, r) } catch (o) { return o } } function m(t, e, n) { J(function (t) { var r = !1, o = y(n, e, function (n) { r || (r = !0, e !== n ? g(t, n) : S(t, n)) }, function (e) { r || (r = !0, j(t, e)) }, "Settle: " + (t._label || " unknown promise")); !r && o && (r = !0, j(t, o)) }, t) } function b(t, e) { e._state === rt ? S(t, e._result) : e._state === ot ? j(t, e._result) : E(e, void 0, function (e) { return g(t, e) }, function (e) { return j(t, e) }) } function w(t, n, r) { n.constructor === t.constructor && r === l && n.constructor.resolve === h ? b(t, n) : r === it ? (j(t, it.error), it.error = null) : void 0 === r ? S(t, n) : e(r) ? m(t, n, r) : S(t, n) } function g(e, n) { e === n ? j(e, v()) : t(n) ? w(e, n, _(n)) : S(e, n) } function A(t) { t._onerror && t._onerror(t._result), T(t) } function S(t, e) { t._state === nt && (t._result = e, t._state = rt, 0 !== t._subscribers.length && J(T, t)) } function j(t, e) { t._state === nt && (t._state = ot, t._result = e, J(A, t)) } function E(t, e, n, r) { var o = t._subscribers, i = o.length; t._onerror = null, o[i] = e, o[i + rt] = n, o[i + ot] = r, 0 === i && t._state && J(T, t) } function T(t) { var e = t._subscribers, n = t._state; if (0 !== e.length) { for (var r = void 0, o = void 0, i = t._result, s = 0; s < e.length; s += 3)r = e[s], o = e[s + n], r ? x(n, r, o, i) : o(i); t._subscribers.length = 0 } } function M() { this.error = null } function P(t, e) { try { return t(e) } catch (n) { return st.error = n, st } } function x(t, n, r, o) { var i = e(r), s = void 0, u = void 0, c = void 0, a = void 0; if (i) { if (s = P(r, o), s === st ? (a = !0, u = s.error, s.error = null) : c = !0, n === s) return void j(n, d()) } else s = o, c = !0; n._state !== nt || (i && c ? g(n, s) : a ? j(n, u) : t === rt ? S(n, s) : t === ot && j(n, s)) } function C(t, e) { try { e(function (e) { g(t, e) }, function (e) { j(t, e) }) } catch (n) { j(t, n) } } function O() { return ut++ } function k(t) { t[et] = ut++ , t._state = void 0, t._result = void 0, t._subscribers = [] } function Y(t, e) { this._instanceConstructor = t, this.promise = new t(p), this.promise[et] || k(this.promise), B(e) ? (this.length = e.length, this._remaining = e.length, this._result = new Array(this.length), 0 === this.length ? S(this.promise, this._result) : (this.length = this.length || 0, this._enumerate(e), 0 === this._remaining && S(this.promise, this._result))) : j(this.promise, q()) } function q() { return new Error("Array Methods must be provided an Array") } function F(t) { return new Y(this, t).promise } function D(t) { var e = this; return new e(B(t) ? function (n, r) { for (var o = t.length, i = 0; i < o; i++)e.resolve(t[i]).then(n, r) } : function (t, e) { return e(new TypeError("You must pass an array to race.")) }) } function K(t) { var e = this, n = new e(p); return j(n, t), n } function L() { throw new TypeError("You must pass a resolver function as the first argument to the promise constructor") } function N() { throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.") } function U(t) { this[et] = O(), this._result = this._state = void 0, this._subscribers = [], p !== t && ("function" != typeof t && L(), this instanceof U ? C(this, t) : N()) } function W() { var t = void 0; if ("undefined" != typeof global) t = global; else if ("undefined" != typeof self) t = self; else try { t = Function("return this")() } catch (e) { throw new Error("polyfill failed because global object is unavailable in this environment") } var n = t.Promise; if (n) { var r = null; try { r = Object.prototype.toString.call(n.resolve()) } catch (e) { } if ("[object Promise]" === r && !n.cast) return } t.Promise = U } var z = void 0; z = Array.isArray ? Array.isArray : function (t) { return "[object Array]" === Object.prototype.toString.call(t) }; var B = z, G = 0, H = void 0, I = void 0, J = function (t, e) { $[G] = t, $[G + 1] = e, G += 2, 2 === G && (I ? I(a) : tt()) }, Q = "undefined" != typeof window ? window : void 0, R = Q || {}, V = R.MutationObserver || R.WebKitMutationObserver, X = "undefined" == typeof self && "undefined" != typeof process && "[object process]" === {}.toString.call(process), Z = "undefined" != typeof Uint8ClampedArray && "undefined" != typeof importScripts && "undefined" != typeof MessageChannel, $ = new Array(1e3), tt = void 0; tt = X ? o() : V ? s() : Z ? u() : void 0 === Q && "function" == typeof require ? f() : c(); var et = Math.random().toString(36).substring(16), nt = void 0, rt = 1, ot = 2, it = new M, st = new M, ut = 0; return Y.prototype._enumerate = function (t) { for (var e = 0; this._state === nt && e < t.length; e++)this._eachEntry(t[e], e) }, Y.prototype._eachEntry = function (t, e) { var n = this._instanceConstructor, r = n.resolve; if (r === h) { var o = _(t); if (o === l && t._state !== nt) this._settledAt(t._state, e, t._result); else if ("function" != typeof o) this._remaining-- , this._result[e] = t; else if (n === U) { var i = new n(p); w(i, t, o), this._willSettleAt(i, e) } else this._willSettleAt(new n(function (e) { return e(t) }), e) } else this._willSettleAt(r(t), e) }, Y.prototype._settledAt = function (t, e, n) { var r = this.promise; r._state === nt && (this._remaining-- , t === ot ? j(r, n) : this._result[e] = n), 0 === this._remaining && S(r, this._result) }, Y.prototype._willSettleAt = function (t, e) { var n = this; E(t, void 0, function (t) { return n._settledAt(rt, e, t) }, function (t) { return n._settledAt(ot, e, t) }) }, U.all = F, U.race = D, U.resolve = h, U.reject = K, U._setScheduler = n, U._setAsap = r, U._asap = J, U.prototype = { constructor: U, then: l, "catch": function (t) { return this.then(null, t) } }, U.polyfill = W, U.Promise = U, U }); -------------------------------------------------------------------------------- /libs/av-weapp-min.js: -------------------------------------------------------------------------------- 1 | !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AV=t():e.AV=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=63)}([function(e,t,n){var r,i;(function(){function n(e){function t(t,n,r,i,o,s){for(;o>=0&&o0?0:a-1;return arguments.length<3&&(i=n[s?s[u]:u],u+=e),t(n,r,i,s,u,a)}}function o(e){return function(t,n,r){n=A(n,r);for(var i=C(t),o=e>0?0:i-1;o>=0&&o0?s=o>=0?o:Math.max(o+a,s):a=o>=0?Math.min(o+1,a):o+a+1;else if(n&&o&&a)return o=n(r,i),r[o]===i?o:-1;if(i!==i)return o=t(p.call(r,s,a),S.isNaN),o>=0?o+s:-1;for(o=e>0?s:a-1;o>=0&&o=0&&t<=N};S.each=S.forEach=function(e,t,n){t=O(t,n);var r,i;if(x(e))for(r=0,i=e.length;r=0},S.invoke=function(e,t){var n=p.call(arguments,2),r=S.isFunction(t);return S.map(e,function(e){var i=r?t:e[t];return null==i?i:i.apply(e,n)})},S.pluck=function(e,t){return S.map(e,S.property(t))},S.where=function(e,t){return S.filter(e,S.matcher(t))},S.findWhere=function(e,t){return S.find(e,S.matcher(t))},S.max=function(e,t,n){var r,i,o=-(1/0),s=-(1/0);if(null==t&&null!=e){e=x(e)?e:S.values(e);for(var a=0,u=e.length;ao&&(o=r)}else t=A(t,n),S.each(e,function(e,n,r){i=t(e,n,r),(i>s||i===-(1/0)&&o===-(1/0))&&(o=e,s=i)});return o},S.min=function(e,t,n){var r,i,o=1/0,s=1/0;if(null==t&&null!=e){e=x(e)?e:S.values(e);for(var a=0,u=e.length;ar||void 0===n)return 1;if(nt?(s&&(clearTimeout(s),s=null),a=c,o=e.apply(r,i),s||(r=i=null)):s||n.trailing===!1||(s=setTimeout(u,l)),o}},S.debounce=function(e,t,n){var r,i,o,s,a,u=function(){var c=S.now()-s;c=0?r=setTimeout(u,t-c):(r=null,n||(a=e.apply(o,i),r||(o=i=null)))};return function(){o=this,i=arguments,s=S.now();var c=n&&!r;return r||(r=setTimeout(u,t)),c&&(a=e.apply(o,i),o=i=null),a}},S.wrap=function(e,t){return S.partial(t,e)},S.negate=function(e){return function(){return!e.apply(this,arguments)}},S.compose=function(){var e=arguments,t=e.length-1;return function(){for(var n=t,r=e[t].apply(this,arguments);n--;)r=e[n].call(this,r);return r}},S.after=function(e,t){return function(){if(--e<1)return t.apply(this,arguments)}},S.before=function(e,t){var n;return function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=null),n}},S.once=S.partial(S.before,2);var P=!{toString:null}.propertyIsEnumerable("toString"),R=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];S.keys=function(e){if(!S.isObject(e))return[];if(m)return m(e);var t=[];for(var n in e)S.has(e,n)&&t.push(n);return P&&a(e,t),t},S.allKeys=function(e){if(!S.isObject(e))return[];var t=[];for(var n in e)t.push(n);return P&&a(e,t),t},S.values=function(e){for(var t=S.keys(e),n=t.length,r=Array(n),i=0;i":">",'"':""","'":"'","`":"`"},q=S.invert(L),M=function(e){var t=function(t){return e[t]},n="(?:"+S.keys(e).join("|")+")",r=RegExp(n),i=RegExp(n,"g");return function(e){return e=null==e?"":""+e,r.test(e)?e.replace(i,t):e}};S.escape=M(L),S.unescape=M(q),S.result=function(e,t,n){var r=null==e?void 0:e[t];return void 0===r&&(r=n),S.isFunction(r)?r.call(e):r};var F=0;S.uniqueId=function(e){var t=++F+"";return e?e+t:t},S.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var B=/(.)^/,J={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},W=/\\|'|\r|\n|\u2028|\u2029/g,V=function(e){return"\\"+J[e]};S.template=function(e,t,n){!t&&n&&(t=n),t=S.defaults({},t,S.templateSettings);var r=RegExp([(t.escape||B).source,(t.interpolate||B).source,(t.evaluate||B).source].join("|")+"|$","g"),i=0,o="__p+='";e.replace(r,function(t,n,r,s,a){return o+=e.slice(i,a).replace(W,V),i=a+t.length,n?o+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'":r?o+="'+\n((__t=("+r+"))==null?'':__t)+\n'":s&&(o+="';\n"+s+"\n__p+='"),t}),o+="';\n",t.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{var s=new Function(t.variable||"obj","_",o)}catch(e){throw e.source=o,e}var a=function(e){return s.call(this,e,S)},u=t.variable||"obj";return a.source="function("+u+"){\n"+o+"}",a},S.chain=function(e){var t=S(e);return t._chain=!0,t};var Q=function(e,t){return e._chain?S(t).chain():t};S.mixin=function(e){S.each(S.functions(e),function(t){var n=S[t]=e[t];S.prototype[t]=function(){var e=[this._wrapped];return d.apply(e,arguments),Q(this,n.apply(S,e))}})},S.mixin(S),S.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=l[e];S.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),"shift"!==e&&"splice"!==e||0!==n.length||delete n[0],Q(this,n)}}),S.each(["concat","join","slice"],function(e){var t=l[e];S.prototype[e]=function(){return Q(this,t.apply(this._wrapped,arguments))}}),S.prototype.value=function(){return this._wrapped},S.prototype.valueOf=S.prototype.toJSON=S.prototype.value,S.prototype.toString=function(){return""+this._wrapped},r=[],i=function(){return S}.apply(t,r),!(void 0!==i&&(e.exports=i))}).call(this)},function(e,t,n){"use strict";var r=(n(0),n(51).Promise);r._continueWhile=function(e,t){return e()?t().then(function(){return r._continueWhile(e,t)}):r.resolve()},e.exports=r},function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=n(7),o=n(5)("leancloud:request"),s=n(56),a=n(1),u=n(16),c=n(3),l=n(6),f=n(0),h=n(4),d=h.getSessionToken,p=void 0,_={cn:"https://api.leancloud.cn",us:"https://us-api.leancloud.cn"},v=function(e,t){var n=(new Date).getTime(),r=s(n+e);return t?r+","+n+",master":r+","+n},y=0,m=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},s=arguments[4],u=y++;return o("request("+u+")",e,t,n,r),new a(function(a,c){var l=i(e,t).set(r).send(n);s&&l.on("progress",s),l.end(function(e,t){return t&&o("response("+u+")",t.status,t.body||t.text,t.header),e?(t&&(e.statusCode=t.status,e.responseText=t.text,e.response=t.body),c(e)):a(t.body)})})},g=function(e,t){t?e["X-LC-Sign"]=v(l.applicationKey):e["X-LC-Key"]=l.applicationKey},b=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1],n={"X-LC-Id":l.applicationId,"Content-Type":"application/json;charset=UTF-8"},r=!1;return"boolean"==typeof e.useMasterKey?r=e.useMasterKey:"boolean"==typeof l._useMasterKey&&(r=l._useMasterKey),r?l.masterKey?t?n["X-LC-Sign"]=v(l.masterKey,!0):n["X-LC-Key"]=l.masterKey+",master":(console.warn("masterKey is not set, fall back to use appKey"),g(n,t)):g(n,t),l.hookKey&&(n["X-LC-Hook-Key"]=l.hookKey),null!==l._config.applicationProduction&&(n["X-LC-Prod"]=String(l._config.applicationProduction)),n["X-LC-UA"]=l._config.userAgent,a.resolve().then(function(){var t=d(e);if(t)n["X-LC-Session"]=t;else if(!l._config.disableCurrentUser)return l.User.currentAsync().then(function(e){return e&&e._sessionToken&&(n["X-LC-Session"]=e._sessionToken),n});return n})},w=function(e,t,n,i,o){l.serverURL&&(l._config.APIServerURL=l.serverURL,console.warn("Please use AV._config.APIServerURL to replace AV.serverURL, and it is an internal interface."));var s=l._config.APIServerURL||_.cn;if("/"!==s.charAt(s.length-1)&&(s+="/"),s+="1.1/"+e,t&&(s+="/"+t),n&&(s+="/"+n),"users"!==e&&"classes"!==e||!o||(s+="?",o._fetchWhenSave&&(delete o._fetchWhenSave,s+="&new=true"),o._where&&(s+="&where="+encodeURIComponent(JSON.stringify(o._where)),delete o._where)),"get"===i.toLowerCase()){s.indexOf("?")===-1&&(s+="?");for(var a in o)"object"===r(o[a])&&(o[a]=JSON.stringify(o[a])),s+="&"+a+"="+encodeURIComponent(o[a])}return s},S=function(e,t){return"number"!=typeof t&&(t=3600),u.setAsync("APIServerURL",e,1e3*t)},O=function(e){return new a(function(t,n){if(410===e.statusCode)S(e.response.api_server,e.response.ttl).then(function(){t(e.response.location)}).catch(n);else{var r={code:e.code||-1,error:e.message||e.responseText};if(e.response&&e.response.code)r=e.response;else if(e.responseText)try{r=JSON.parse(e.responseText)}catch(e){}n(new c(r.code,r.error))}})},A=function(e){l._config.APIServerURL="https://"+e;var t=f.findKey(_,function(e){return e===l._config.APIServerURL});t&&(l._config.region=t)},E=function(){var e="https://app-router.leancloud.cn/1/route?appId="+l.applicationId;return m("get",e).then(function(e){if(e.api_server)return A(e.api_server),S(e.api_server,e.ttl)},function(e){if(e.statusCode>=400&&e.statusCode<500)throw e})},j=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"cn";p=new a(function(t,n){return l._config.APIServerURL?void t():"cn"===e?u.getAsync("APIServerURL").then(function(e){return e?void A(e):E()}).then(function(){t()}).catch(function(e){n(e)}):(l._config.region=e,l._config.APIServerURL=_[e],t(),void 0)})},T=function(e,t,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o=arguments[5];if(!l.applicationId)throw new Error("You must specify your applicationId using AV.init()");if(!l.applicationKey&&!l.masterKey)throw new Error("You must specify a AppKey using AV.init()");return p?p.then(function(){var s=w(e,t,n,r,i);return b(o).then(function(e){return m(r,s,i,e).then(null,function(t){return O(t).then(function(t){return m(r,t,i,e)})})})}):a.reject(new Error("Not initialized"))};e.exports={ajax:m,request:T,setServerUrlByRegion:j}},function(e,t,n){"use strict";function r(e,t){var n=new Error(t);return n.code=e,n}var i=n(0);i.extend(r,{OTHER_CAUSE:-1,INTERNAL_SERVER_ERROR:1,CONNECTION_FAILED:100,OBJECT_NOT_FOUND:101,INVALID_QUERY:102,INVALID_CLASS_NAME:103,MISSING_OBJECT_ID:104,INVALID_KEY_NAME:105,INVALID_POINTER:106,INVALID_JSON:107,COMMAND_UNAVAILABLE:108,NOT_INITIALIZED:109,INCORRECT_TYPE:111,INVALID_CHANNEL_NAME:112,PUSH_MISCONFIGURED:115,OBJECT_TOO_LARGE:116,OPERATION_FORBIDDEN:119,CACHE_MISS:120,INVALID_NESTED_KEY:121,INVALID_FILE_NAME:122,INVALID_ACL:123,TIMEOUT:124,INVALID_EMAIL_ADDRESS:125,MISSING_CONTENT_TYPE:126,MISSING_CONTENT_LENGTH:127,INVALID_CONTENT_LENGTH:128,FILE_TOO_LARGE:129,FILE_SAVE_ERROR:130,FILE_DELETE_ERROR:153,DUPLICATE_VALUE:137,INVALID_ROLE_NAME:139,EXCEEDED_QUOTA:140,SCRIPT_FAILED:141,VALIDATION_ERROR:142,INVALID_IMAGE_DATA:150,UNSAVED_FILE_ERROR:151,INVALID_PUSH_TIME_ERROR:152,USERNAME_MISSING:200,PASSWORD_MISSING:201,USERNAME_TAKEN:202,EMAIL_TAKEN:203,EMAIL_MISSING:204,EMAIL_NOT_FOUND:205,SESSION_MISSING:206,MUST_CREATE_USER_THROUGH_SIGNUP:207,ACCOUNT_ALREADY_LINKED:208,LINKED_ID_MISSING:250,INVALID_LINKED_SESSION:251,UNSUPPORTED_SERVICE:252,X_DOMAIN_REQUEST:602}),e.exports=r},function(e,t,n){"use strict";var r=n(0),i=function(e){return r.isNull(e)||r.isUndefined(e)},o=function(e){return r.isArray(e)?e:void 0===e||null===e?[]:[e]},s=function(e){return e.sessionToken?e.sessionToken:e.user&&"function"==typeof e.user.getSessionToken?e.user.getSessionToken():void 0},a=function(e){return function(t){return e(t),t}};e.exports={isNullOrUndefined:i,ensureArray:o,getSessionToken:s,tap:a}},function(e,t,n){function r(){return!("undefined"==typeof window||!window||"undefined"==typeof window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document&&"WebkitAppearance"in document.documentElement.style||"undefined"!=typeof window&&window&&window.console&&(console.firebug||console.exception&&console.table)||"undefined"!=typeof navigator&&navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),n){var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(i++,"%c"===e&&(o=i))}),e.splice(o,0,r)}}function o(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function s(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}}function a(){try{return t.storage.debug}catch(e){}if("undefined"!=typeof process&&"env"in process)return process.env.DEBUG}function u(){try{return window.localStorage}catch(e){}}t=e.exports=n(50),t.log=o,t.formatArgs=i,t.save=s,t.load=a,t.useColors=r,t.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:u(),t.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(a())},function(e,t,n){"use strict";(function(t){var r=n(0),i=n(41),o=n(4),s=o.isNullOrUndefined,a=t.AV||{};a._config=a._config||{};var u=a._config;r.extend(u,{region:"cn",APIServerURL:u.APIServerURL||"",disableCurrentUser:!1,userAgent:i,applicationProduction:null});var c=function(){},l=function(e,t,n){var i;return i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){e.apply(this,arguments)},r.extend(i,e),c.prototype=e.prototype,i.prototype=new c,t&&r.extend(i.prototype,t),n&&r.extend(i,n),i.prototype.constructor=i,i.__super__=e.prototype,i};a.setProduction=function(e){s(e)?u.applicationProduction=null:u.applicationProduction=e?1:0},a._getAVPath=function(e){if(!a.applicationId)throw new Error("You need to call AV.initialize before using AV.");if(e||(e=""),!r.isString(e))throw new Error("Tried to get a localStorage path that wasn't a String.");return"/"===e[0]&&(e=e.substring(1)),"AV/"+a.applicationId+"/"+e},a._installationId=null,a._getInstallationId=function(){if(a._installationId)return a.Promise.resolve(a._installationId);var e=a._getAVPath("installationId");return a.localStorage.getItemAsync(e).then(function(t){if(a._installationId=t,a._installationId)return t;var n=function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)};return a._installationId=n()+n()+"-"+n()+"-"+n()+"-"+n()+"-"+n()+n()+n(),a.localStorage.setItemAsync(e,a._installationId)})},a._parseDate=function(e){var t=new RegExp("^([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2})T([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})(.([0-9]+))?Z$"),n=t.exec(e);if(!n)return null;var r=n[1]||0,i=(n[2]||1)-1,o=n[3]||0,s=n[4]||0,a=n[5]||0,u=n[6]||0,c=n[8]||0;return new Date(Date.UTC(r,i,o,s,a,u,c))},a._extend=function(e,t){var n=l(this,e,t);return n.extend=this.extend,n},a._getValue=function(e,t){return e&&e[t]?r.isFunction(e[t])?e[t]():e[t]:null},a._encode=function(e,t,n){if(e instanceof a.Object){if(n)throw new Error("AV.Objects not allowed here");if(!t||r.include(t,e)||!e._hasData)return e._toPointer();if(!e.dirty())return t=t.concat(e),a._encode(e._toFullJSON(t),t,n);throw new Error("Tried to save an object with a pointer to a new, unsaved object.")}if(e instanceof a.ACL)return e.toJSON();if(r.isDate(e))return{__type:"Date",iso:e.toJSON()};if(e instanceof a.GeoPoint)return e.toJSON();if(r.isArray(e))return r.map(e,function(e){return a._encode(e,t,n)});if(r.isRegExp(e))return e.source;if(e instanceof a.Relation)return e.toJSON();if(e instanceof a.Op)return e.toJSON();if(e instanceof a.File){if(!e.url()&&!e.id)throw new Error("Tried to save an object containing an unsaved file.");return e._toFullJSON()}return r.isObject(e)?r.mapObject(e,function(e,r){return a._encode(e,t,n)}):e},a._decode=function(e,t){if(!r.isObject(e)||r.isDate(e))return e;if(r.isArray(e))return r.map(e,function(e){return a._decode(e)});if(e instanceof a.Object)return e;if(e instanceof a.File)return e;if(e instanceof a.Op)return e;if(e instanceof a.GeoPoint)return e;if(e instanceof a.ACL)return e;if(e.__op)return a.Op._decode(e);var n;if("Pointer"===e.__type){n=e.className;var i=a.Object._create(n);if(Object.keys(e).length>3){var o=r.clone(e);delete o.__type,delete o.className,i._finishFetch(o,!0)}else i._finishFetch({objectId:e.objectId},!1);return i}if("Object"===e.__type){n=e.className;var s=r.clone(e);delete s.__type,delete s.className;var u=a.Object._create(n);return u._finishFetch(s,!0),u}if("Date"===e.__type)return a._parseDate(e.iso);if("GeoPoint"===e.__type)return new a.GeoPoint({latitude:e.latitude,longitude:e.longitude});if("Relation"===e.__type){if(!t)throw new Error("key missing decoding a Relation");var c=new a.Relation(null,t);return c.targetClassName=e.className,c}if("File"===e.__type){var l=new a.File(e.name),f=r.clone(e);return delete f.__type,l._finishFetch(f),l}return r.mapObject(e,function(e,t){return"ACL"===t?new a.ACL(e):a._decode(e,t)})},a._encodeObjectOrArray=function(e){var t=function(e){return e&&e._toFullJSON&&(e=e._toFullJSON([])),r.mapObject(e,function(e){return a._encode(e,[])})};return r.isArray(e)?e.map(function(e){return t(e)}):t(e)},a._arrayEach=r.each,a._traverse=function(e,t,n){if(e instanceof a.Object){if(n=n||[],r.indexOf(n,e)>=0)return;return n.push(e),a._traverse(e.attributes,t,n),t(e)}return e instanceof a.Relation||e instanceof a.File?t(e):r.isArray(e)?(r.each(e,function(r,i){var o=a._traverse(r,t,n);o&&(e[i]=o)}),t(e)):r.isObject(e)?(a._each(e,function(r,i){var o=a._traverse(r,t,n);o&&(e[i]=o)}),t(e)):t(e)},a._objectEach=a._each=function(e,t){r.isObject(e)?r.each(r.keys(e),function(n){t(e[n],n)}):r.each(e,t)},e.exports=a}).call(t,n(8))},function(e,t,n){function r(){}function i(e){if(!_(e))return e;var t=[];for(var n in e)o(t,n,e[n]);return t.join("&")}function o(e,t,n){if(null!=n)if(Array.isArray(n))n.forEach(function(n){o(e,t,n)});else if(_(n))for(var r in n)o(e,t+"["+r+"]",n[r]);else e.push(encodeURIComponent(t)+"="+encodeURIComponent(n));else null===n&&e.push(encodeURIComponent(t))}function s(e){for(var t,n,r={},i=e.split("&"),o=0,s=i.length;o=0?"&":"?")+e),this._sort){var t=this.url.indexOf("?");if(t>=0){var n=this.url.substring(t+1).split("&");v(this._sort)?n.sort(this._sort):n.sort(),this.url=this.url.substring(0,t)+"?"+n.join("&")}}},l.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},l.prototype.end=function(e){var t=this,n=this.xhr=m.getXHR(),i=this._formData||this._data;this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||r,n.onreadystatechange=function(){var e=n.readyState;if(e>=2&&t._responseTimeoutTimer&&clearTimeout(t._responseTimeoutTimer),4==e){var r;try{r=n.status}catch(e){r=0}if(!r){if(t.timedout||t._aborted)return;return t.crossDomainError()}t.emit("end")}};var o=function(e,n){n.total>0&&(n.percent=n.loaded/n.total*100),n.direction=e,t.emit("progress",n)};if(this.hasListeners("progress"))try{n.onprogress=o.bind(null,"download"),n.upload&&(n.upload.onprogress=o.bind(null,"upload"))}catch(e){}this._appendQueryString(),this._setTimeouts();try{this.username&&this.password?n.open(this.method,this.url,!0,this.username,this.password):n.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(n.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof i&&!this._isHost(i)){var s=this._header["content-type"],a=this._serializer||m.serialize[s?s.split(";")[0]:""];!a&&u(s)&&(a=m.serialize["application/json"]),a&&(i=a(i))}for(var c in this.header)null!=this.header[c]&&n.setRequestHeader(c,this.header[c]);return this._responseType&&(n.responseType=this._responseType),this.emit("request",this),n.send("undefined"!=typeof i?i:null),this},m.get=function(e,t,n){var r=m("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},m.head=function(e,t,n){var r=m("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},m.options=function(e,t,n){var r=m("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},m.del=f,m.delete=f,m.patch=function(e,t,n){var r=m("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},m.post=function(e,t,n){var r=m("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},m.put=function(e,t,n){var r=m("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(){function e(e,t){for(var n=0;n2&&void 0!==arguments[2])||arguments[2];if(this.readyState!==h)throw new Error("request is already opened");if(!n)throw new Error("sync request is not supported");this._method=e,this._url=t,this.readyState=d,this.dispatchEvent({type:"readystatechange"})}},{key:"setRequestHeader",value:function(e,t){if(this.readyState!==d)throw new Error("request is not opened");this._headers[e.toLowerCase()]=t}},{key:"send",value:function(e){var t=this;if(this.readyState!==d)throw new Error("request is not opened");if(e instanceof f){var n=e.entries(),i=n.filter(function(e){return"string"!=typeof e[1]});if(0===i.length)throw new Error("Must specify a Blob field in FormData");i.length>1&&console.warn("Only the first Blob will be send in Weapp");var o=n.filter(function(e){return"string"==typeof e[1]}).reduce(function(e,t){return c(e,r({},t[0],t[1]))},{});wx.uploadFile({url:this._url,name:i[0][0],filePath:i[0][1].uri,formData:o,header:this._headers,success:a.bind(this),fail:function(e){t.status=0,t.readyState=v,t.dispatchEvent({type:"readystatechange"}),t.dispatchEvent({type:"error"})}})}else wx.request({url:this._url,data:e||"",method:this._method.toUpperCase(),header:this._headers,success:a.bind(this),fail:function(e){t.status=0,t.readyState=v,t.dispatchEvent({type:"readystatechange"}),t.dispatchEvent({type:"error"})}})}}]),t}(l(y));c(m,{UNSENT:h,OPENED:d,HEADERS_RECEIVED:p,LOADING:_,DONE:v}),e.exports=m},function(e,t,n){"use strict";var r=n(17),i=n(6),o=t.removeAsync=r.removeItemAsync.bind(r),s=function(e,t){try{e=JSON.parse(e)}catch(e){return null}if(e){var n=e.expiredAt&&e.expiredAt0){for(var t=Array(arguments.length),n=0;n0&&void 0!==arguments[0]?arguments[0]:t||window;if("object"!==("undefined"==typeof e?"undefined":r(e)))throw new Error("polyfill target is not an Object");var n={localStorage:i,XMLHttpRequest:o,FormData:s,WebSocket:a,Object:Object,navigator:u};for(var c in n)e[c]||(e[c]=n[c])},localStorage:i,XMLHttpRequest:o,FormData:s,WebSocket:a}}).call(t,n(8))},function(e,t,n){"use strict";var r=n(0);e.exports=function(e){var t="*";e.ACL=function(t){var n=this;if(n.permissionsById={},r.isObject(t))if(t instanceof e.User)n.setReadAccess(t,!0),n.setWriteAccess(t,!0);else{if(r.isFunction(t))throw new Error("AV.ACL() called with a function. Did you forget ()?");e._objectEach(t,function(t,i){if(!r.isString(i))throw new Error("Tried to create an ACL with an invalid userId.");n.permissionsById[i]={},e._objectEach(t,function(e,t){if("read"!==t&&"write"!==t)throw new Error("Tried to create an ACL with an invalid permission type.");if(!r.isBoolean(e))throw new Error("Tried to create an ACL with an invalid permission value.");n.permissionsById[i][t]=e})})}},e.ACL.prototype.toJSON=function(){return r.clone(this.permissionsById)},e.ACL.prototype._setAccess=function(t,n,i){if(n instanceof e.User?n=n.id:n instanceof e.Role&&(n="role:"+n.getName()),!r.isString(n))throw new Error("userId must be a string.");if(!r.isBoolean(i))throw new Error("allowed must be either true or false.");var o=this.permissionsById[n];if(!o){if(!i)return;o={},this.permissionsById[n]=o}i?this.permissionsById[n][t]=!0:(delete o[t],r.isEmpty(o)&&delete o[n])},e.ACL.prototype._getAccess=function(t,n){n instanceof e.User?n=n.id:n instanceof e.Role&&(n="role:"+n.getName());var r=this.permissionsById[n];return!!r&&!!r[t]},e.ACL.prototype.setReadAccess=function(e,t){this._setAccess("read",e,t)},e.ACL.prototype.getReadAccess=function(e){return this._getAccess("read",e)},e.ACL.prototype.setWriteAccess=function(e,t){this._setAccess("write",e,t)},e.ACL.prototype.getWriteAccess=function(e){return this._getAccess("write",e)},e.ACL.prototype.setPublicReadAccess=function(e){this.setReadAccess(t,e)},e.ACL.prototype.getPublicReadAccess=function(){return this.getReadAccess(t)},e.ACL.prototype.setPublicWriteAccess=function(e){this.setWriteAccess(t,e)},e.ACL.prototype.getPublicWriteAccess=function(){return this.getWriteAccess(t)},e.ACL.prototype.getRoleReadAccess=function(t){if(t instanceof e.Role&&(t=t.getName()),r.isString(t))return this.getReadAccess("role:"+t);throw new Error("role must be a AV.Role or a String")},e.ACL.prototype.getRoleWriteAccess=function(t){if(t instanceof e.Role&&(t=t.getName()),r.isString(t))return this.getWriteAccess("role:"+t);throw new Error("role must be a AV.Role or a String")},e.ACL.prototype.setRoleReadAccess=function(t,n){if(t instanceof e.Role&&(t=t.getName()),r.isString(t))return void this.setReadAccess("role:"+t,n);throw new Error("role must be a AV.Role or a String")},e.ACL.prototype.setRoleWriteAccess=function(t,n){if(t instanceof e.Role&&(t=t.getName()),r.isString(t))return void this.setWriteAccess("role:"+t,n);throw new Error("role must be a AV.Role or a String")}}},function(e,t,n){"use strict";var r=n(0),i=n(2).request;e.exports=function(e){e.Cloud=e.Cloud||{},r.extend(e.Cloud,{run:function(t,n,r){var o=i("functions",t,null,"POST",e._encode(n,null,!0),r);return o.then(function(t){return e._decode(t).result})},rpc:function(t,n,o){return r.isArray(n)?Promise.reject(new Error("Can't pass Array as the param of rpc function in JavaScript SDK.")):i("call",t,null,"POST",e._encodeObjectOrArray(n),o).then(function(t){return e._decode(t).result})},getServerDate:function(){var t=i("date",null,null,"GET");return t.then(function(t){return e._decode(t)})},requestSmsCode:function(e){if(r.isString(e)&&(e={mobilePhoneNumber:e}),!e.mobilePhoneNumber)throw new Error("Missing mobilePhoneNumber.");var t=i("requestSmsCode",null,null,"POST",e);return t},verifySmsCode:function(e,t){if(!e)throw new Error("Missing sms code.");var n={};r.isString(t)&&(n.mobilePhoneNumber=t);var o=i("verifySmsCode",e,null,"POST",n);return o}})}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e){var t=/\s+/,n=Array.prototype.slice;e.Events={on:function(e,n,r){var i,o,s,a,u;if(!n)return this;for(e=e.split(t),i=this._callbacks||(this._callbacks={}),o=e.shift();o;)u=i[o],s=u?u.tail:{},s.next=a={},s.context=r,s.callback=n,i[o]={tail:a,next:u?u.next:s},o=e.shift();return this},off:function(e,n,i){var o,s,a,u,c,l;if(s=this._callbacks){if(!(e||n||i))return delete this._callbacks,this;for(e=e?e.split(t):r.keys(s),o=e.shift();o;)if(a=s[o],delete s[o],a&&(n||i)){for(u=a.tail,a=a.next;a!==u;)c=a.callback,l=a.context,(n&&c!==n||i&&l!==i)&&this.on(o,c,l),a=a.next;o=e.shift()}return this}},trigger:function(e){var r,i,o,s,a,u,c;if(!(o=this._callbacks))return this;for(u=o.all,e=e.split(t),c=n.call(arguments,1),r=e.shift();r;){if(i=o[r])for(s=i.tail;(i=i.next)!==s;)i.callback.apply(i.context||this,c);if(i=u)for(s=i.tail,a=[r].concat(c);(i=i.next)!==s;)i.callback.apply(i.context||this,a);r=e.shift()}return this}},e.Events.bind=e.Events.on,e.Events.unbind=e.Events.off}},function(e,t,n){"use strict";var r=n(0),i=n(42),o=n(43),s=n(44),a=n(3),u=n(2).request,c=n(1),l=n(4),f=l.tap,h=n(5)("leancloud:file");e.exports=function(e){var t=(e._config,function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}),l=function(e){return e.match(/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/)[4]},d=function(e){if(e<26)return String.fromCharCode(65+e);if(e<52)return String.fromCharCode(97+(e-26));if(e<62)return String.fromCharCode(48+(e-52));if(62===e)return"+";if(63===e)return"/";throw new Error("Tried to encode large digit "+e+" in base64.")},p=function(e){var t=[];return t.length=Math.ceil(e.length/3),r.times(t.length,function(n){var r=e[3*n],i=e[3*n+1]||0,o=e[3*n+2]||0,s=3*n+1>2&63),d(r<<4&48|i>>4&15),s?d(i<<2&60|o>>6&3):"=",a?d(63&o):"="].join("")}),t.join("")};e.File=function(t,i,o){this.attributes={name:t,url:"",metaData:{},base64:""},this._extName="";var s=void 0;if(i&&i.owner)s=i.owner;else if(!e._config.disableCurrentUser)try{s=e.User.current()}catch(e){if("SYNC_API_NOT_AVAILABLE"!==e.code)throw e;console.warn("Get current user failed. It seems this runtime use an async storage system, please create AV.File in the callback of AV.User.currentAsync().")}if(this.attributes.metaData={owner:s?s.id:"unknown"},this.set("mime_type",o),r.isArray(i)&&(this.attributes.metaData.size=i.length,i={base64:p(i)}),i&&i.base64){var a=n(47),u=a(i.base64,o);this._source=c.resolve({data:u,type:o})}else if(i&&i.blob)!i.blob.type&&o&&(i.blob.type=o),i.blob.name||(i.blob.name=t),this._extName=l(i.blob.uri),this._source=c.resolve({data:i.blob,type:o});else if("undefined"!=typeof File&&i instanceof File)i.size&&(this.attributes.metaData.size=i.size),i.name&&(this._extName=l(i.name)),this._source=c.resolve({data:i,type:o});else if("undefined"!=typeof Buffer&&Buffer.isBuffer(i))this.attributes.metaData.size=i.length,this._source=c.resolve({data:i,type:o});else if(r.isString(i))throw new Error("Creating a AV.File from a String is not yet supported.")},e.File.withURL=function(t,n,r,i){if(!t||!n)throw new Error("Please provide file name and url");var o=new e.File(t,null,i);if(r)for(var s in r)o.attributes.metaData[s]||(o.attributes.metaData[s]=r[s]);return o.attributes.url=n,o.attributes.metaData.__source="external",o},e.File.createWithoutData=function(t){var n=new e.File;return n.id=t,n},e.File.prototype={className:"_File",_toFullJSON:function(t){var n=this,i=r.clone(this.attributes);return e._objectEach(i,function(n,r){i[r]=e._encode(n,t)}),e._objectEach(this._operations,function(e,t){i[t]=e}),r.has(this,"id")&&(i.objectId=this.id),r(["createdAt","updatedAt"]).each(function(e){if(r.has(n,e)){var t=n[e];i[e]=r.isDate(t)?t.toJSON():t}}),i.__type="File",i},toJSON:function(){var e=this._toFullJSON();return r.has(this,"id")&&(e.id=this.id),e},getACL:function(){return this._acl},setACL:function(t){return t instanceof e.ACL?void(this._acl=t):new a(a.OTHER_CAUSE,"ACL must be a AV.ACL.")},name:function(){return this.get("name")},url:function(){return this.get("url")},get:function(e){switch(e){case"objectId":return this.id;case"url":case"name":case"mime_type":case"metaData":case"createdAt":case"updatedAt":return this.attributes[e];default:return this.attributes.metaData[e]}},set:function e(){for(var t=this,e=function(e,n){switch(e){case"name":case"url":case"mime_type":case"base64":case"metaData":t.attributes[e]=n;break;default:t.attributes.metaData[e]=n}},n=arguments.length,r=Array(n),i=0;i100)throw new Error("Invalid quality value.");i=i||"png";var s=r?2:1;return o+"?imageView/"+s+"/w/"+e+"/h/"+t+"/q/"+n+"/format/"+i},size:function(){return this.metaData().size},ownerId:function(){return this.metaData().owner},destroy:function(e){if(!this.id)return c.reject(new Error("The file id is not eixsts."));var t=u("files",null,this.id,"DELETE",null,e);return t},_fileToken:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"fileTokens",r=this.attributes.name,i=l(r)||this._extName,o=t()+t()+t()+t()+t()+i,s={key:o,name:r,ACL:this._acl,mime_type:e,metaData:this.attributes.metaData};return this._qiniu_key=o,u(n,null,null,"POST",s)},save:function(e){var t=this;if(this.id)throw new Error("File already saved. If you want to manipulate a file, use AV.Query to get it.");if(!this._previousSave)if(this._source)this._previousSave=this._source.then(function(n){var r=n.data,a=n.type;return t._fileToken(a).then(function(n){n.mime_type&&t.set("mime_type",n.mime_type),t._token=n.token;var a=void 0;switch(n.provider){case"s3":a=s(n,r,t,e);break;case"qcloud":a=i(n,r,t,e);break;case"qiniu":default:a=o(n,r,t,e)}return a.then(f(function(){return t._callback(!0)}),function(e){throw t._callback(!1),e})})});else if(this.attributes.url&&"external"===this.attributes.metaData.__source){var n={name:this.attributes.name,ACL:this._acl,metaData:this.attributes.metaData,mime_type:this.mimeType,url:this.attributes.url};this._previousSave=u("files",this.attributes.name,null,"post",n).then(function(e){return t.attributes.name=e.name,t.attributes.url=e.url,t.id=e.objectId,e.size&&(t.attributes.metaData.size=e.size),t})}return this._previousSave},_callback:function(e){u("fileCallback",null,null,"post",{token:this._token,result:e}).catch(h),delete this._token},fetch:function(e){var e=null,t=u("files",null,this.id,"GET",e);return t.then(this._finishFetch.bind(this))},_finishFetch:function(t){var n=e.Object.prototype.parse(t);return n.attributes={name:n.name,url:n.url,mime_type:n.mime_type,bucket:n.bucket},n.attributes.metaData=n.metaData||{},n.id=n.objectId,delete n.objectId,delete n.metaData,delete n.url,delete n.name,delete n.mime_type,delete n.bucket,r.extend(this,n),this}}}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e){e.GeoPoint=function(t,n){r.isArray(t)?(e.GeoPoint._validate(t[0],t[1]),this.latitude=t[0],this.longitude=t[1]):r.isObject(t)?(e.GeoPoint._validate(t.latitude,t.longitude),this.latitude=t.latitude,this.longitude=t.longitude):r.isNumber(t)&&r.isNumber(n)?(e.GeoPoint._validate(t,n),this.latitude=t,this.longitude=n):(this.latitude=0,this.longitude=0);var i=this;this.__defineGetter__&&this.__defineSetter__&&(this._latitude=this.latitude,this._longitude=this.longitude,this.__defineGetter__("latitude",function(){return i._latitude}),this.__defineGetter__("longitude",function(){return i._longitude}),this.__defineSetter__("latitude",function(t){e.GeoPoint._validate(t,i.longitude),i._latitude=t}),this.__defineSetter__("longitude",function(t){e.GeoPoint._validate(i.latitude,t),i._longitude=t}))},e.GeoPoint._validate=function(e,t){if(e<-90)throw new Error("AV.GeoPoint latitude "+e+" < -90.0.");if(e>90)throw new Error("AV.GeoPoint latitude "+e+" > 90.0.");if(t<-180)throw new Error("AV.GeoPoint longitude "+t+" < -180.0.");if(t>180)throw new Error("AV.GeoPoint longitude "+t+" > 180.0.")},e.GeoPoint.current=function(){return new e.Promise(function(t,n){navigator.geolocation.getCurrentPosition(function(n){t(new e.GeoPoint({latitude:n.coords.latitude,longitude:n.coords.longitude}))},n)})},e.GeoPoint.prototype={toJSON:function(){return e.GeoPoint._validate(this.latitude,this.longitude),{__type:"GeoPoint",latitude:this.latitude,longitude:this.longitude}},radiansTo:function(e){var t=Math.PI/180,n=this.latitude*t,r=this.longitude*t,i=e.latitude*t,o=e.longitude*t,s=n-i,a=r-o,u=Math.sin(s/2),c=Math.sin(a/2),l=u*u+Math.cos(n)*Math.cos(i)*c*c;return l=Math.min(1,l),2*Math.asin(Math.sqrt(l))},kilometersTo:function(e){return 6371*this.radiansTo(e)},milesTo:function(e){return 3958.8*this.radiansTo(e)}}}},function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e; 3 | },i=n(6),o=n(2),s=function(e,t,n,r){i.applicationId&&e!==i.applicationId&&t!==i.applicationKey&&n!==i.masterKey&&console.warn("LeanCloud SDK is already initialized, please do not reinitialize it."),i.applicationId=e,i.applicationKey=t,i.masterKey=n,i._useMasterKey=!1},a=function(){console.warn("MasterKey is not supposed to be used in browser.")};i.init=function(){switch(arguments.length){case 1:var e=arguments.length<=0?void 0:arguments[0];if("object"!==("undefined"==typeof e?"undefined":r(e)))throw new Error("AV.init(): Parameter is not correct.");e.masterKey&&a(),s(e.appId,e.appKey,e.masterKey,e.hookKey),o.setServerUrlByRegion(e.region),i._config.disableCurrentUser=e.disableCurrentUser;break;case 2:case 3:console.warn("Please use AV.init() to replace AV.initialize(), AV.init() need an Object param, like { appId: 'YOUR_APP_ID', appKey: 'YOUR_APP_KEY' } . Docs: https://leancloud.cn/docs/sdk_setup-js.html"),3===arguments.length&&a(),s.apply(void 0,arguments),o.setServerUrlByRegion("cn")}},i.initialize=i.init},function(e,t,n){"use strict";var r=n(0),i=n(3),o=n(2).request;e.exports=function(e){e.Insight=e.Insight||{},r.extend(e.Insight,{startJob:function(t,n){if(!t||!t.sql)throw new Error("Please provide the sql to run the job.");var r={jobConfig:t,appId:e.applicationId},i=o("bigquery","jobs",null,"POST",e._encode(r,null,!0),n);return i.then(function(t){return e._decode(t).id})},on:function(e,t){}}),e.Insight.JobQuery=function(e,t){if(!e)throw new Error("Please provide the job id.");this.id=e,this.className=t,this._skip=0,this._limit=100},e.Insight.JobQuery.prototype={skip:function(e){return this._skip=e,this},limit:function(e){return this._limit=e,this},find:function(t){var n={skip:this._skip,limit:this._limit},r=o("bigquery","jobs",this.id,"GET",n,t);return r.then(function(t){return t.error?e.Promise.reject(new i(t.code,t.error)):e.Promise.resolve(t)})}}}},function(e,t,n){"use strict";var r=n(0),i=n(3),o=n(2).request,s=n(4),a=["objectId","createdAt","updatedAt"],u=function(e){if(a.indexOf(e)!==-1)throw new Error("key["+e+"] is reserved")};e.exports=function(e){e.Object=function(t,n){if(r.isString(t))return e.Object._create.apply(this,arguments);t=t||{},n&&n.parse&&(t=this.parse(t),t=this._mergeMagicFields(t));var i=e._getValue(this,"defaults");i&&(t=r.extend({},i,t)),n&&n.collection&&(this.collection=n.collection),this._serverData={},this._opSetQueue=[{}],this._flags={},this.attributes={},this._hashedJSON={},this._escapedAttributes={},this.cid=r.uniqueId("c"),this.changed={},this._silent={},this._pending={},this.set(t,{silent:!0}),this.changed={},this._silent={},this._pending={},this._hasData=!0,this._previousAttributes=r.clone(this.attributes),this.initialize.apply(this,arguments)},e.Object.saveAll=function(t,n){return e.Object._deepSaveAsync(t,null,n)},e.Object.fetchAll=function(t,n){return e.Promise.resolve().then(function(){return o("batch",null,null,"POST",{requests:r.map(t,function(e){if(!e.className)throw new Error("object must have className to fetch");if(!e.id)throw new Error("object must have id to fetch");if(e.dirty())throw new Error("object is modified but not saved");return{method:"GET",path:"/1.1/classes/"+e.className+"/"+e.id}})},n)}).then(function(e){return r.forEach(t,function(t,n){if(!e[n].success){var r=new Error(e[n].error.error);throw r.code=e[n].error.code,r}t._finishFetch(t.parse(e[n].success))}),t})},r.extend(e.Object.prototype,e.Events,{_fetchWhenSave:!1,initialize:function(){},fetchWhenSave:function(e){if(console.warn("AV.Object#fetchWhenSave is deprecated, use AV.Object#save with options.fetchWhenSave instead."),!r.isBoolean(e))throw new Error("Expect boolean value for fetchWhenSave");this._fetchWhenSave=e},getObjectId:function(){return this.id},getCreatedAt:function(){return this.createdAt||this.get("createdAt")},getUpdatedAt:function(){return this.updatedAt||this.get("updatedAt")},toJSON:function(){var t=this._toFullJSON();return e._arrayEach(["__type","className"],function(e){delete t[e]}),t},_toFullJSON:function(t){var n=this,i=r.clone(this.attributes);return e._objectEach(i,function(n,r){i[r]=e._encode(n,t)}),e._objectEach(this._operations,function(e,t){i[t]=e}),r.has(this,"id")&&(i.objectId=this.id),r(["createdAt","updatedAt"]).each(function(e){if(r.has(n,e)){var t=n[e];i[e]=r.isDate(t)?t.toJSON():t}}),i.__type="Object",i.className=this.className,i},_refreshCache:function(){var t=this;t._refreshingCache||(t._refreshingCache=!0,e._objectEach(this.attributes,function(n,i){n instanceof e.Object?n._refreshCache():r.isObject(n)&&t._resetCacheForKey(i)&&t.set(i,new e.Op.Set(n),{silent:!0})}),delete t._refreshingCache)},dirty:function(e){this._refreshCache();var t=r.last(this._opSetQueue);return e?!!t[e]:!this.id||r.keys(t).length>0},_toPointer:function(){return{__type:"Pointer",className:this.className,objectId:this.id}},get:function(e){switch(e){case"objectId":return this.id;case"createdAt":case"updatedAt":return this[e];default:return this.attributes[e]}},relation:function(t){var n=this.get(t);if(n){if(!(n instanceof e.Relation))throw new Error("Called relation() on non-relation field "+t);return n._ensureParentAndKey(this,t),n}return new e.Relation(this,t)},escape:function(e){var t=this._escapedAttributes[e];if(t)return t;var n,i=this.attributes[e];return n=s.isNullOrUndefined(i)?"":r.escape(i.toString()),this._escapedAttributes[e]=n,n},has:function(e){return!s.isNullOrUndefined(this.attributes[e])},_mergeMagicFields:function(t){var n=this,i=["objectId","createdAt","updatedAt"];return e._arrayEach(i,function(i){t[i]&&("objectId"===i?n.id=t[i]:"createdAt"!==i&&"updatedAt"!==i||r.isDate(t[i])?n[i]=t[i]:n[i]=e._parseDate(t[i]),delete t[i])}),t},_startSave:function(){this._opSetQueue.push({})},_cancelSave:function(){var t=r.first(this._opSetQueue);this._opSetQueue=r.rest(this._opSetQueue);var n=r.first(this._opSetQueue);e._objectEach(t,function(e,r){var i=t[r],o=n[r];i&&o?n[r]=o._mergeWithPrevious(i):i&&(n[r]=i)}),this._saving=this._saving-1},_finishSave:function(t){var n={};e._traverse(this.attributes,function(t){t instanceof e.Object&&t.id&&t._hasData&&(n[t.id]=t)});var i=r.first(this._opSetQueue);this._opSetQueue=r.rest(this._opSetQueue),this._applyOpSet(i,this._serverData),this._mergeMagicFields(t);var o=this;e._objectEach(t,function(t,r){o._serverData[r]=e._decode(t,r);var i=e._traverse(o._serverData[r],function(t){if(t instanceof e.Object&&n[t.id])return n[t.id]});i&&(o._serverData[r]=i)}),this._rebuildAllEstimatedData(),this._saving=this._saving-1},_finishFetch:function(t,n){this._opSetQueue=[{}],this._mergeMagicFields(t);var r=this;e._objectEach(t,function(t,n){r._serverData[n]=e._decode(t,n)}),this._rebuildAllEstimatedData(),this._refreshCache(),this._opSetQueue=[{}],this._hasData=n},_applyOpSet:function(t,n){var r=this;e._objectEach(t,function(t,i){n[i]=t._estimate(n[i],r,i),n[i]===e.Op._UNSET&&delete n[i]})},_resetCacheForKey:function(t){var n=this.attributes[t];if(r.isObject(n)&&!(n instanceof e.Object)&&!(n instanceof e.File)){n=n.toJSON?n.toJSON():n;var i=JSON.stringify(n);if(this._hashedJSON[t]!==i){var o=!!this._hashedJSON[t];return this._hashedJSON[t]=i,o}}return!1},_rebuildEstimatedDataForKey:function(t){var n=this;delete this.attributes[t],this._serverData[t]&&(this.attributes[t]=this._serverData[t]),e._arrayEach(this._opSetQueue,function(r){var i=r[t];i&&(n.attributes[t]=i._estimate(n.attributes[t],n,t),n.attributes[t]===e.Op._UNSET?delete n.attributes[t]:n._resetCacheForKey(t))})},_rebuildAllEstimatedData:function(){var t=this,n=r.clone(this.attributes);this.attributes=r.clone(this._serverData),e._arrayEach(this._opSetQueue,function(n){t._applyOpSet(n,t.attributes),e._objectEach(n,function(e,n){t._resetCacheForKey(n)})}),e._objectEach(n,function(e,n){t.attributes[n]!==e&&t.trigger("change:"+n,t,t.attributes[n],{})}),e._objectEach(this.attributes,function(e,i){r.has(n,i)||t.trigger("change:"+i,t,e,{})})},set:function(t,n,i){var o;if(r.isObject(t)||s.isNullOrUndefined(t)?(o=r.mapObject(t,function(t,n){return u(n),e._decode(t,n)}),i=n):(o={},u(t),o[t]=e._decode(n,t)),i=i||{},!o)return this;o instanceof e.Object&&(o=o.attributes),i.unset&&e._objectEach(o,function(t,n){o[n]=new e.Op.Unset});var a=r.clone(o),c=this;e._objectEach(a,function(t,n){t instanceof e.Op&&(a[n]=t._estimate(c.attributes[n],c,n),a[n]===e.Op._UNSET&&delete a[n])}),this._validate(o,i),i.changes={};var l=this._escapedAttributes;this._previousAttributes||{};return e._arrayEach(r.keys(o),function(t){var n=o[t];n instanceof e.Relation&&(n.parent=c),n instanceof e.Op||(n=new e.Op.Set(n));var s=!0;n instanceof e.Op.Set&&r.isEqual(c.attributes[t],n.value)&&(s=!1),s&&(delete l[t],i.silent?c._silent[t]=!0:i.changes[t]=!0);var a=r.last(c._opSetQueue);a[t]=n._mergeWithPrevious(a[t]),c._rebuildEstimatedDataForKey(t),s?(c.changed[t]=c.attributes[t],i.silent||(c._pending[t]=!0)):(delete c.changed[t],delete c._pending[t])}),i.silent||this.change(i),this},unset:function(e,t){return t=t||{},t.unset=!0,this.set(e,null,t)},increment:function(t,n){return(r.isUndefined(n)||r.isNull(n))&&(n=1),this.set(t,new e.Op.Increment(n))},add:function(t,n){return this.set(t,new e.Op.Add(s.ensureArray(n)))},addUnique:function(t,n){return this.set(t,new e.Op.AddUnique(s.ensureArray(n)))},remove:function(t,n){return this.set(t,new e.Op.Remove(s.ensureArray(n)))},op:function(e){return r.last(this._opSetQueue)[e]},clear:function(e){e=e||{},e.unset=!0;var t=r.extend(this.attributes,this._operations);return this.set(t,e)},_getSaveJSON:function(){var t=r.clone(r.first(this._opSetQueue));return e._objectEach(t,function(e,n){t[n]=e.toJSON()}),t},_canBeSerialized:function(){return e.Object._canBeSerializedAsValue(this.attributes)},fetch:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1];r.isArray(e.keys)&&(e.keys=e.keys.join(",")),r.isArray(e.include)&&(e.include=e.include.join(","));var n=this,i=o("classes",this.className,this.id,"GET",e,t);return i.then(function(e){return n._finishFetch(n.parse(e),!0),n})},save:function(t,n,i){var a,u,c;r.isObject(t)||s.isNullOrUndefined(t)?(a=t,c=n):(a={},a[t]=n,c=i),c=r.clone(c)||{},c.wait&&(u=r.clone(this.attributes));var l=r.clone(c)||{};l.wait&&(l.silent=!0),a&&this.set(a,l);var f=this;f._refreshCache();var h=[],d=[];return e.Object._findUnsavedChildren(f.attributes,h,d),h.length+d.length>0?e.Object._deepSaveAsync(this.attributes,f,c).then(function(){return f.save(null,c)}):(this._startSave(),this._saving=(this._saving||0)+1,this._allPreviousSaves=this._allPreviousSaves||e.Promise.resolve(),this._allPreviousSaves=this._allPreviousSaves.catch(function(e){}).then(function(){var e=f.id?"PUT":"POST",t=f._getSaveJSON();if(f._fetchWhenSave&&(t._fetchWhenSave=!0),c.fetchWhenSave&&(t._fetchWhenSave=!0),c.query){var n;if("function"==typeof c.query.toJSON&&(n=c.query.toJSON(),n&&(t._where=n.where)),!t._where){var i=new Error("options.query is not an AV.Query");throw i}}r.extend(t,f._flags);var s="classes",h=f.className;"_User"!==f.className||f.id||(s="users",h=null);var d=c._makeRequest||o,p=d(s,h,f.id,e,t,c);return p=p.then(function(e){var t=f.parse(e);return c.wait&&(t=r.extend(a||{},t)),f._finishSave(t),c.wait&&f.set(u,l),f},function(e){throw f._cancelSave(),e})}),this._allPreviousSaves)},destroy:function(e){e=e||{};var t=this,n=function(){t.trigger("destroy",t,t.collection,e)};if(!this.id)return n();e.wait||n();var r=o("classes",this.className,this.id,"DELETE",this._flags,e);return r.then(function(){return e.wait&&n(),t})},parse:function(t){var n=r.clone(t);return r(["createdAt","updatedAt"]).each(function(t){n[t]&&(n[t]=e._parseDate(n[t]))}),n.updatedAt||(n.updatedAt=n.createdAt),n},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return!this.id},change:function(t){t=t||{};var n=this._changing;this._changing=!0;var i=this;e._objectEach(this._silent,function(e){i._pending[e]=!0});var o=r.extend({},t.changes,this._silent);if(this._silent={},e._objectEach(o,function(e,n){i.trigger("change:"+n,i,i.get(n),t)}),n)return this;for(var s=function(e,t){i._pending[t]||i._silent[t]||delete i.changed[t]};!r.isEmpty(this._pending);)this._pending={},this.trigger("change",this,t),e._objectEach(this.changed,s),i._previousAttributes=r.clone(this.attributes);return this._changing=!1,this},hasChanged:function(e){return arguments.length?this.changed&&r.has(this.changed,e):!r.isEmpty(this.changed)},changedAttributes:function(t){if(!t)return!!this.hasChanged()&&r.clone(this.changed);var n={},i=this._previousAttributes;return e._objectEach(t,function(e,t){r.isEqual(i[t],e)||(n[t]=e)}),n},previous:function(e){return arguments.length&&this._previousAttributes?this._previousAttributes[e]:null},previousAttributes:function(){return r.clone(this._previousAttributes)},isValid:function(){try{this.validate(this.attributes)}catch(e){return!1}return!0},validate:function(t){if(r.has(t,"ACL")&&!(t.ACL instanceof e.ACL))throw new i(i.OTHER_CAUSE,"ACL must be a AV.ACL.")},_validate:function(e,t){!t.silent&&this.validate&&(e=r.extend({},this.attributes,e),this.validate(e))},getACL:function(){return this.get("ACL")},setACL:function(e,t){return this.set("ACL",e,t)},disableBeforeHook:function(){this.ignoreHook("beforeSave"),this.ignoreHook("beforeUpdate"),this.ignoreHook("beforeDelete")},disableAfterHook:function(){this.ignoreHook("afterSave"),this.ignoreHook("afterUpdate"),this.ignoreHook("afterDelete")},ignoreHook:function(t){r.contains(["beforeSave","afterSave","beforeUpdate","afterUpdate","beforeDelete","afterDelete"],t)||console.trace("Unsupported hookName: "+t),e.hookKey||console.trace("ignoreHook required hookKey"),this._flags.__ignore_hooks||(this._flags.__ignore_hooks=[]),this._flags.__ignore_hooks.push(t)}}),e.Object.createWithoutData=function(t,n,r){var i=new e.Object(t);return i.id=n,i._hasData=r,i},e.Object.destroyAll=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!t||0===t.length)return e.Promise.resolve();var i=r.groupBy(t,function(e){return JSON.stringify({className:e.className,flags:e._flags})}),s={requests:r.map(i,function(e){var t=r.map(e,"id").join(",");return{method:"DELETE",path:"/1.1/classes/"+e[0].className+"/"+t,body:e[0]._flags}})};return o("batch",null,null,"POST",s,n)},e.Object._getSubclass=function(t){if(!r.isString(t))throw new Error("AV.Object._getSubclass requires a string argument.");var n=e.Object._classMap[t];return n||(n=e.Object.extend(t),e.Object._classMap[t]=n),n},e.Object._create=function(t,n,r){var i=e.Object._getSubclass(t);return new i(n,r)},e.Object._classMap={},e.Object._extend=e._extend,e.Object.new=function(t,n){return new e.Object(t,n)},e.Object.extend=function(t,n,i){if(!r.isString(t)){if(t&&r.has(t,"className"))return e.Object.extend(t.className,t,n);throw new Error("AV.Object.extend's first argument should be the className.")}"User"===t&&(t="_User");var o=null;if(r.has(e.Object._classMap,t)){var s=e.Object._classMap[t];if(!n&&!i)return s;o=s._extend(n,i)}else n=n||{},n._className=t,o=this._extend(n,i);return o.extend=function(n){if(r.isString(n)||n&&r.has(n,"className"))return e.Object.extend.apply(o,arguments);var i=[t].concat(r.toArray(arguments));return e.Object.extend.apply(o,i)},o.new=function(e,t){return new o(e,t)},e.Object._classMap[t]=o,o},Object.defineProperty(e.Object.prototype,"className",{get:function(){var e=this._className||this.constructor._LCClassName||this.constructor.name;return"User"===e?"_User":e}}),e.Object.register=function(t,n){if(!(t.prototype instanceof e.Object))throw new Error("registered class is not a subclass of AV.Object");var r=n||t.name;if(!r.length)throw new Error("registered class must be named");n&&(t._LCClassName=n),e.Object._classMap[r]=t},e.Object._findUnsavedChildren=function(t,n,r){e._traverse(t,function(t){return t instanceof e.Object?(t._refreshCache(),void(t.dirty()&&n.push(t))):t instanceof e.File?void(t.url()||t.id||r.push(t)):void 0})},e.Object._canBeSerializedAsValue=function(t){var n=!0;return t instanceof e.Object||t instanceof e.File?n=!!t.id:r.isArray(t)?e._arrayEach(t,function(t){e.Object._canBeSerializedAsValue(t)||(n=!1)}):r.isObject(t)&&e._objectEach(t,function(t){e.Object._canBeSerializedAsValue(t)||(n=!1)}),n},e.Object._deepSaveAsync=function(t,n,s){var a=[],u=[];e.Object._findUnsavedChildren(t,a,u),n&&(a=r.filter(a,function(e){return e!=n}));var c=e.Promise.resolve();r.each(u,function(e){c=c.then(function(){return e.save()})});var l=r.uniq(a),f=r.uniq(l);return c.then(function(){return e.Promise._continueWhile(function(){return f.length>0},function(){var t=[],n=[];if(e._arrayEach(f,function(e){return t.length>20?void n.push(e):void(e._canBeSerialized()?t.push(e):n.push(e))}),f=n,0===t.length)return e.Promise.reject(new i(i.OTHER_CAUSE,"Tried to save a batch with a cycle."));var a=e.Promise.resolve(r.map(t,function(t){return t._allPreviousSaves||e.Promise.resolve()})),u=a.then(function(){return o("batch",null,null,"POST",{requests:r.map(t,function(e){var t=e._getSaveJSON();r.extend(t,e._flags);var n="POST",i="/1.1/classes/"+e.className;return e.id&&(i=i+"/"+e.id,n="PUT"),e._startSave(),{method:n,path:i,body:t}})},s).then(function(n){var r;if(e._arrayEach(t,function(e,t){n[t].success?e._finishSave(e.parse(n[t].success)):(r=r||n[t].error,e._cancelSave())}),r)return e.Promise.reject(new i(r.code,r.error))})});return e._arrayEach(t,function(e){e._allPreviousSaves=u}),u})}).then(function(){return t})}}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e){e.Op=function(){this._initialize.apply(this,arguments)},e.Op.prototype={_initialize:function(){}},r.extend(e.Op,{_extend:e._extend,_opDecoderMap:{},_registerDecoder:function(t,n){e.Op._opDecoderMap[t]=n},_decode:function(t){var n=e.Op._opDecoderMap[t.__op];return n?n(t):void 0}}),e.Op._registerDecoder("Batch",function(t){var n=null;return e._arrayEach(t.ops,function(t){t=e.Op._decode(t),n=t._mergeWithPrevious(n)}),n}),e.Op.Set=e.Op._extend({_initialize:function(e){this._value=e},value:function(){return this._value},toJSON:function(){return e._encode(this.value())},_mergeWithPrevious:function(e){return this},_estimate:function(e){return this.value()}}),e.Op._UNSET={},e.Op.Unset=e.Op._extend({toJSON:function(){return{__op:"Delete"}},_mergeWithPrevious:function(e){return this},_estimate:function(t){return e.Op._UNSET}}),e.Op._registerDecoder("Delete",function(t){return new e.Op.Unset}),e.Op.Increment=e.Op._extend({_initialize:function(e){this._amount=e},amount:function(){return this._amount},toJSON:function(){return{__op:"Increment",amount:this._amount}},_mergeWithPrevious:function(t){if(t){if(t instanceof e.Op.Unset)return new e.Op.Set(this.amount());if(t instanceof e.Op.Set)return new e.Op.Set(t.value()+this.amount());if(t instanceof e.Op.Increment)return new e.Op.Increment(this.amount()+t.amount());throw new Error("Op is invalid after previous op.")}return this},_estimate:function(e){return e?e+this.amount():this.amount()}}),e.Op._registerDecoder("Increment",function(t){return new e.Op.Increment(t.amount)}),e.Op.Add=e.Op._extend({_initialize:function(e){this._objects=e},objects:function(){return this._objects},toJSON:function(){return{__op:"Add",objects:e._encode(this.objects())}},_mergeWithPrevious:function(t){if(t){if(t instanceof e.Op.Unset)return new e.Op.Set(this.objects());if(t instanceof e.Op.Set)return new e.Op.Set(this._estimate(t.value()));if(t instanceof e.Op.Add)return new e.Op.Add(t.objects().concat(this.objects()));throw new Error("Op is invalid after previous op.")}return this},_estimate:function(e){return e?e.concat(this.objects()):r.clone(this.objects())}}),e.Op._registerDecoder("Add",function(t){return new e.Op.Add(e._decode(t.objects))}),e.Op.AddUnique=e.Op._extend({_initialize:function(e){this._objects=r.uniq(e)},objects:function(){return this._objects},toJSON:function(){return{__op:"AddUnique",objects:e._encode(this.objects())}},_mergeWithPrevious:function(t){if(t){if(t instanceof e.Op.Unset)return new e.Op.Set(this.objects());if(t instanceof e.Op.Set)return new e.Op.Set(this._estimate(t.value()));if(t instanceof e.Op.AddUnique)return new e.Op.AddUnique(this._estimate(t.objects()));throw new Error("Op is invalid after previous op.")}return this},_estimate:function(t){if(t){var n=r.clone(t);return e._arrayEach(this.objects(),function(t){if(t instanceof e.Object&&t.id){var i=r.find(n,function(n){return n instanceof e.Object&&n.id===t.id});if(i){var o=r.indexOf(n,i);n[o]=t}else n.push(t)}else r.contains(n,t)||n.push(t)}),n}return r.clone(this.objects())}}),e.Op._registerDecoder("AddUnique",function(t){return new e.Op.AddUnique(e._decode(t.objects))}),e.Op.Remove=e.Op._extend({_initialize:function(e){this._objects=r.uniq(e)},objects:function(){return this._objects},toJSON:function(){return{__op:"Remove",objects:e._encode(this.objects())}},_mergeWithPrevious:function(t){if(t){if(t instanceof e.Op.Unset)return t;if(t instanceof e.Op.Set)return new e.Op.Set(this._estimate(t.value()));if(t instanceof e.Op.Remove)return new e.Op.Remove(r.union(t.objects(),this.objects()));throw new Error("Op is invalid after previous op.")}return this},_estimate:function(t){if(t){var n=r.difference(t,this.objects());return e._arrayEach(this.objects(),function(t){t instanceof e.Object&&t.id&&(n=r.reject(n,function(n){return n instanceof e.Object&&n.id===t.id}))}),n}return[]}}),e.Op._registerDecoder("Remove",function(t){return new e.Op.Remove(e._decode(t.objects))}),e.Op.Relation=e.Op._extend({_initialize:function(t,n){this._targetClassName=null;var i=this,o=function(t){if(t instanceof e.Object){if(!t.id)throw new Error("You can't add an unsaved AV.Object to a relation.");if(i._targetClassName||(i._targetClassName=t.className),i._targetClassName!==t.className)throw new Error("Tried to create a AV.Relation with 2 different types: "+i._targetClassName+" and "+t.className+".");return t.id}return t};this.relationsToAdd=r.uniq(r.map(t,o)),this.relationsToRemove=r.uniq(r.map(n,o))},added:function(){var t=this;return r.map(this.relationsToAdd,function(n){var r=e.Object._create(t._targetClassName);return r.id=n,r})},removed:function(){var t=this;return r.map(this.relationsToRemove,function(n){var r=e.Object._create(t._targetClassName);return r.id=n,r})},toJSON:function(){var e=null,t=null,n=this,i=function(e){return{__type:"Pointer",className:n._targetClassName,objectId:e}},o=null;return this.relationsToAdd.length>0&&(o=r.map(this.relationsToAdd,i),e={__op:"AddRelation",objects:o}),this.relationsToRemove.length>0&&(o=r.map(this.relationsToRemove,i),t={__op:"RemoveRelation",objects:o}),e&&t?{__op:"Batch",ops:[e,t]}:e||t||{}},_mergeWithPrevious:function(t){if(t){if(t instanceof e.Op.Unset)throw new Error("You can't modify a relation after deleting it.");if(t instanceof e.Op.Relation){if(t._targetClassName&&t._targetClassName!==this._targetClassName)throw new Error("Related object must be of class "+t._targetClassName+", but "+this._targetClassName+" was passed in.");var n=r.union(r.difference(t.relationsToAdd,this.relationsToRemove),this.relationsToAdd),i=r.union(r.difference(t.relationsToRemove,this.relationsToAdd),this.relationsToRemove),o=new e.Op.Relation(n,i);return o._targetClassName=this._targetClassName,o}throw new Error("Op is invalid after previous op.")}return this},_estimate:function(t,n,r){if(t){if(t instanceof e.Relation){if(this._targetClassName)if(t.targetClassName){if(t.targetClassName!==this._targetClassName)throw new Error("Related object must be a "+t.targetClassName+", but a "+this._targetClassName+" was passed in.")}else t.targetClassName=this._targetClassName;return t}throw new Error("Op is invalid after previous op.")}var i=new e.Relation(n,r);i.targetClassName=this._targetClassName}}),e.Op._registerDecoder("AddRelation",function(t){return new e.Op.Relation(e._decode(t.objects),[])}),e.Op._registerDecoder("RemoveRelation",function(t){return new e.Op.Relation([],e._decode(t.objects))})}},function(e,t,n){"use strict";var r=n(2).request;e.exports=function(e){e.Installation=e.Object.extend("_Installation"),e.Push=e.Push||{},e.Push.send=function(e,t){if(e.where&&(e.where=e.where.toJSON().where),e.where&&e.cql)throw new Error("Both where and cql can't be set");if(e.push_time&&(e.push_time=e.push_time.toJSON()),e.expiration_time&&(e.expiration_time=e.expiration_time.toJSON()),e.expiration_time&&e.expiration_time_interval)throw new Error("Both expiration_time and expiration_time_interval can't be set");var n=r("push",null,null,"POST",e,t);return n}}},function(e,t,n){"use strict";var r=n(0),i=n(5)("leancloud:query"),o=n(1),s=n(3),a=n(2).request,u=n(4),c=u.ensureArray,l=function(e,t){if(void 0===e)throw new Error(t)};e.exports=function(e){e.Query=function(t){r.isString(t)&&(t=e.Object._getSubclass(t)),this.objectClass=t,this.className=t.prototype.className,this._where={},this._include=[],this._select=[],this._limit=-1,this._skip=0,this._extraOptions={}},e.Query.or=function(){var t=r.toArray(arguments),n=null;e._arrayEach(t,function(e){if(r.isNull(n)&&(n=e.className),n!==e.className)throw new Error("All queries must be for the same class")});var i=new e.Query(n);return i._orQuery(t),i},e.Query.and=function(){var t=r.toArray(arguments),n=null;e._arrayEach(t,function(e){if(r.isNull(n)&&(n=e.className),n!==e.className)throw new Error("All queries must be for the same class")});var i=new e.Query(n);return i._andQuery(t),i},e.Query.doCloudQuery=function(t,n,i){var o={cql:t};r.isArray(n)?o.pvalues=n:i=n;var s=a("cloudQuery",null,null,"GET",o,i);return s.then(function(t){var n=new e.Query(t.className),i=r.map(t.results,function(e){var r=n._newObject(t);return r._finishFetch&&r._finishFetch(n._processResult(e),!0),r});return{results:i,count:t.count,className:t.className}})},e.Query._extend=e._extend,e.Query.prototype={_processResult:function(e){return e},get:function(e,t){if(!e){var n=new s(s.OBJECT_NOT_FOUND,"Object not found.");throw n}var r=this,i=r._newObject();i.id=e;var o=r.toJSON(),a={};return o.keys&&(a.keys=o.keys),o.include&&(a.include=o.include),i.fetch(a,t)},toJSON:function(){var t={where:this._where};return this._include.length>0&&(t.include=this._include.join(",")),this._select.length>0&&(t.keys=this._select.join(",")),this._limit>=0&&(t.limit=this._limit),this._skip>0&&(t.skip=this._skip),void 0!==this._order&&(t.order=this._order),e._objectEach(this._extraOptions,function(e,n){t[n]=e}),t},_newObject:function(t){var n;return n=t&&t.className?new e.Object(t.className):new this.objectClass},_createRequest:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.toJSON(),t=arguments[1];if(JSON.stringify(e).length>2e3){var n={requests:[{method:"GET",path:"/1.1/classes/"+this.className,params:e}]};return a("batch",null,null,"POST",n,t).then(function(e){var t=e[0];if(t.success)return t.success;var n=new Error(t.error.error||"Unknown batch error");throw n.code=t.error.code,n})}return a("classes",this.className,null,"GET",e,t)},_parseResponse:function(e){var t=this;return r.map(e.results,function(n){var r=t._newObject(e);return r._finishFetch&&r._finishFetch(t._processResult(n),!0),r})},find:function(e){var t=this._createRequest(void 0,e);return t.then(this._parseResponse.bind(this))},scan:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.orderedBy,s=t.batchSize,u=arguments[1],c=this.toJSON();i("scan %O",c),c.order&&(console.warn("The order of the query is ignored for Query#scan. Checkout the orderedBy option of Query#scan."),delete c.order),c.skip&&(console.warn("The skip option of the query is ignored for Query#scan."),delete c.skip),c.limit&&(console.warn("The limit option of the query is ignored for Query#scan."),delete c.limit),n&&(c.scan_key=n),s&&(c.limit=s);var l=o.resolve([]),f=void 0,h=!1;return{next:function(){return l=l.then(function(t){return h?[]:t.length>1?t:f||0===t.length?a("scan/classes",e.className,null,"GET",f?r.extend({},c,{cursor:f}):c,u).then(function(t){return f=t.cursor,e._parseResponse(t)}).then(function(e){return e.length||(h=!0),t.concat(e)}):(h=!0,t)}),l.then(function(e){return e.shift()}).then(function(e){return{value:e,done:h}})}}},destroyAll:function(t){var n=this;return n.find(t).then(function(t){return e.Object.destroyAll(t)})},count:function(e){var t=this.toJSON();t.limit=0,t.count=1;var n=this._createRequest(t,e);return n.then(function(e){return e.count})},first:function(e){var t=this,n=this.toJSON();n.limit=1;var i=this._createRequest(n,e);return i.then(function(e){return r.map(e.results,function(e){var n=t._newObject();return n._finishFetch&&n._finishFetch(t._processResult(e),!0),n})[0]})},skip:function(e){return l(e,"undefined is not a valid skip value"),this._skip=e,this},limit:function(e){return l(e,"undefined is not a valid limit value"),this._limit=e,this},equalTo:function(t,n){return l(t,"undefined is not a valid key"),l(n,"undefined is not a valid value"),this._where[t]=e._encode(n),this},_addCondition:function(t,n,r){return l(t,"undefined is not a valid condition key"),l(n,"undefined is not a valid condition"),l(r,"undefined is not a valid condition value"),this._where[t]||(this._where[t]={}),this._where[t][n]=e._encode(r),this},sizeEqualTo:function(e,t){this._addCondition(e,"$size",t)},notEqualTo:function(e,t){return this._addCondition(e,"$ne",t),this},lessThan:function(e,t){return this._addCondition(e,"$lt",t),this},greaterThan:function(e,t){return this._addCondition(e,"$gt",t),this},lessThanOrEqualTo:function(e,t){return this._addCondition(e,"$lte",t),this},greaterThanOrEqualTo:function(e,t){return this._addCondition(e,"$gte",t),this},containedIn:function(e,t){return this._addCondition(e,"$in",t),this},notContainedIn:function(e,t){return this._addCondition(e,"$nin",t),this},containsAll:function(e,t){return this._addCondition(e,"$all",t),this},exists:function(e){return this._addCondition(e,"$exists",!0),this},doesNotExist:function(e){return this._addCondition(e,"$exists",!1),this},matches:function(e,t,n){return this._addCondition(e,"$regex",t),n||(n=""),t.ignoreCase&&(n+="i"),t.multiline&&(n+="m"),n&&n.length&&this._addCondition(e,"$options",n),this},matchesQuery:function(e,t){var n=t.toJSON();return n.className=t.className,this._addCondition(e,"$inQuery",n),this},doesNotMatchQuery:function(e,t){var n=t.toJSON();return n.className=t.className,this._addCondition(e,"$notInQuery",n),this},matchesKeyInQuery:function(e,t,n){var r=n.toJSON();return r.className=n.className,this._addCondition(e,"$select",{key:t,query:r}),this},doesNotMatchKeyInQuery:function(e,t,n){var r=n.toJSON();return r.className=n.className,this._addCondition(e,"$dontSelect",{key:t,query:r}),this},_orQuery:function(e){var t=r.map(e,function(e){return e.toJSON().where});return this._where.$or=t,this},_andQuery:function(e){var t=r.map(e,function(e){return e.toJSON().where});return this._where.$and=t,this},_quote:function(e){return"\\Q"+e.replace("\\E","\\E\\\\E\\Q")+"\\E"},contains:function(e,t){return this._addCondition(e,"$regex",this._quote(t)),this},startsWith:function(e,t){return this._addCondition(e,"$regex","^"+this._quote(t)),this},endsWith:function(e,t){return this._addCondition(e,"$regex",this._quote(t)+"$"),this},ascending:function(e){return l(e,"undefined is not a valid key"),this._order=e,this},addAscending:function(e){return l(e,"undefined is not a valid key"),this._order?this._order+=","+e:this._order=e,this},descending:function(e){return l(e,"undefined is not a valid key"),this._order="-"+e,this},addDescending:function(e){return l(e,"undefined is not a valid key"),this._order?this._order+=",-"+e:this._order="-"+e,this},near:function(t,n){return n instanceof e.GeoPoint||(n=new e.GeoPoint(n)),this._addCondition(t,"$nearSphere",n),this},withinRadians:function(e,t,n){return this.near(e,t),this._addCondition(e,"$maxDistance",n),this},withinMiles:function(e,t,n){return this.withinRadians(e,t,n/3958.8)},withinKilometers:function(e,t,n){return this.withinRadians(e,t,n/6371)},withinGeoBox:function(t,n,r){return n instanceof e.GeoPoint||(n=new e.GeoPoint(n)),r instanceof e.GeoPoint||(r=new e.GeoPoint(r)), 4 | this._addCondition(t,"$within",{$box:[n,r]}),this},include:function(e){var t=this;return l(e,"undefined is not a valid key"),r(arguments).forEach(function(e){t._include=t._include.concat(c(e))}),this},select:function(e){var t=this;return l(e,"undefined is not a valid key"),r(arguments).forEach(function(e){t._select=t._select.concat(c(e))}),this},each:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this._order||this._skip||this._limit>=0){var i=new Error("Cannot iterate on a query with sort, skip, or limit.");return e.Promise.reject(i)}var o=new e.Query(this.objectClass);o._limit=n.batchSize||100,o._where=r.clone(this._where),o._include=r.clone(this._include),o.ascending("objectId");var s=!1;return e.Promise._continueWhile(function(){return!s},function(){return o.find(n).then(function(n){var i=e.Promise.resolve();return r.each(n,function(e){i=i.then(function(){return t(e)})}),i.then(function(){n.length>=o._limit?o.greaterThan("objectId",n[n.length-1].id):s=!0})})})}},e.FriendShipQuery=e.Query._extend({_objectClass:e.User,_newObject:function(){return new e.User},_processResult:function(e){if(e&&e[this._friendshipTag]){var t=e[this._friendshipTag];return"Pointer"===t.__type&&"_User"===t.className&&(delete t.__type,delete t.className),t}return null}})}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e){e.Relation=function(e,t){if(!r.isString(t))throw new TypeError("key must be a string");this.parent=e,this.key=t,this.targetClassName=null},e.Relation.reverseQuery=function(t,n,r){var i=new e.Query(t);return i.equalTo(n,r._toPointer()),i},e.Relation.prototype={_ensureParentAndKey:function(e,t){if(this.parent=this.parent||e,this.key=this.key||t,this.parent!==e)throw new Error("Internal Error. Relation retrieved from two different Objects.");if(this.key!==t)throw new Error("Internal Error. Relation retrieved from two different keys.")},add:function(t){r.isArray(t)||(t=[t]);var n=new e.Op.Relation(t,[]);this.parent.set(this.key,n),this.targetClassName=n._targetClassName},remove:function(t){r.isArray(t)||(t=[t]);var n=new e.Op.Relation([],t);this.parent.set(this.key,n),this.targetClassName=n._targetClassName},toJSON:function(){return{__type:"Relation",className:this.targetClassName}},query:function t(){var n,t;return this.targetClassName?(n=e.Object._getSubclass(this.targetClassName),t=new e.Query(n)):(n=e.Object._getSubclass(this.parent.className),t=new e.Query(n),t._extraOptions.redirectClassNameForKey=this.key),t._addCondition("$relatedTo","object",this.parent._toPointer()),t._addCondition("$relatedTo","key",this.key),t}}}},function(e,t,n){"use strict";var r=n(0),i=n(3);e.exports=function(e){e.Role=e.Object.extend("_Role",{constructor:function(t,n){if(r.isString(t)?(e.Object.prototype.constructor.call(this,null,null),this.setName(t)):e.Object.prototype.constructor.call(this,t,n),void 0===n){var i=new e.ACL;i.setPublicReadAccess(!0),this.getACL()||this.setACL(i)}else{if(!(n instanceof e.ACL))throw new TypeError("acl must be an instance of AV.ACL");this.setACL(n)}},getName:function(){return this.get("name")},setName:function(e,t){return this.set("name",e,t)},getUsers:function(){return this.relation("users")},getRoles:function(){return this.relation("roles")},validate:function(t,n){if("name"in t&&t.name!==this.getName()){var o=t.name;if(this.id&&this.id!==t.objectId)return new i(i.OTHER_CAUSE,"A role's name can only be set before it has been saved.");if(!r.isString(o))return new i(i.OTHER_CAUSE,"A role's name must be a String.");if(!/^[0-9a-zA-Z\-_ ]+$/.test(o))return new i(i.OTHER_CAUSE,"A role's name can only contain alphanumeric characters, _, -, and spaces.")}return!!e.Object.prototype.validate&&e.Object.prototype.validate.call(this,t,n)}})}},function(e,t,n){"use strict";var r=n(0),i=n(2).request;e.exports=function(e){e.SearchSortBuilder=function(){this._sortFields=[]},e.SearchSortBuilder.prototype={_addField:function(e,t,n,r){var i={};return i[e]={order:t||"asc",mode:n||"avg",missing:"_"+(r||"last")},this._sortFields.push(i),this},ascending:function(e,t,n){return this._addField(e,"asc",t,n)},descending:function(e,t,n){return this._addField(e,"desc",t,n)},whereNear:function(e,t,n){n=n||{};var r={},i={lat:t.latitude,lon:t.longitude},o={order:n.order||"asc",mode:n.mode||"avg",unit:n.unit||"km"};return o[e]=i,r._geo_distance=o,this._sortFields.push(r),this},build:function(){return JSON.stringify(e._encode(this._sortFields))}},e.SearchQuery=e.Query._extend({_sid:null,_hits:0,_queryString:null,_highlights:null,_sortBuilder:null,_createRequest:function(e,t){return i("search/select",null,null,"GET",e||this.toJSON(),t)},sid:function(e){return this._sid=e,this},queryString:function(e){return this._queryString=e,this},highlights:function(e){var t;return t=e&&r.isString(e)?arguments:e,this._highlights=t,this},sortBy:function(e){return this._sortBuilder=e,this},hits:function(){return this._hits||(this._hits=0),this._hits},_processResult:function(e){return delete e.className,delete e._app_url,delete e._deeplink,e},hasMore:function(){return!this._hitEnd},reset:function(){this._hitEnd=!1,this._sid=null,this._hits=0},find:function(){var e=this,t=this._createRequest();return t.then(function(t){return t.sid?(e._oldSid=e._sid,e._sid=t.sid):(e._sid=null,e._hitEnd=!0),e._hits=t.hits||0,r.map(t.results,function(n){n.className&&(t.className=n.className);var r=e._newObject(t);return r.appURL=n._app_url,r._finishFetch(e._processResult(n),!0),r})})},toJSON:function(){var t=e.SearchQuery.__super__.toJSON.call(this);if(delete t.where,this.className&&(t.clazz=this.className),this._sid&&(t.sid=this._sid),!this._queryString)throw new Error("Please set query string.");if(t.q=this._queryString,this._highlights&&(t.highlights=this._highlights.join(",")),this._sortBuilder&&t.order)throw new Error("sort and order can not be set at same time.");return this._sortBuilder&&(t.sort=this._sortBuilder.build()),t}})}},function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=n(0),o=n(2).request;e.exports=function(e){var t=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.User.currentAsync().then(function(n){return n||e.User._fetchUserBySessionToken(t.sessionToken)})},n=function(n){return t(n).then(function(t){return e.Object.createWithoutData("_User",t.id)._toPointer()})};e.Status=function(e,t){return this.data={},this.inboxType="default",this.query=null,e&&"object"===("undefined"==typeof e?"undefined":r(e))?this.data=e:(e&&(this.data.image=e),t&&(this.data.message=t)),this},e.Status.prototype={get:function(e){return this.data[e]},set:function(e,t){return this.data[e]=t,this},destroy:function(t){if(!this.id)return e.Promise.reject(new Error("The status id is not exists."));var n=o("statuses",null,this.id,"DELETE",t);return n},toObject:function(){return this.id?e.Object.createWithoutData("_Status",this.id):null},_getDataJSON:function(){var t=i.clone(this.data);return e._encode(t)},send:function(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!r.sessionToken&&!e.User.current())throw new Error("Please signin an user.");return this.query?n(r).then(function(e){var n=t.query.toJSON();n.className=t.query.className;var i={};return i.query=n,t.data=t.data||{},t.data.source=t.data.source||e,i.data=t._getDataJSON(),i.inboxType=t.inboxType||"default",o("statuses",null,null,"POST",i,r)}).then(function(n){return t.id=n.objectId,t.createdAt=e._parseDate(n.createdAt),t}):e.Status.sendStatusToFollowers(this,r)},_finishFetch:function(t){this.id=t.objectId,this.createdAt=e._parseDate(t.createdAt),this.updatedAt=e._parseDate(t.updatedAt),this.messageId=t.messageId,delete t.messageId,delete t.objectId,delete t.createdAt,delete t.updatedAt,this.data=e._decode(t)}},e.Status.sendStatusToFollowers=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!r.sessionToken&&!e.User.current())throw new Error("Please signin an user.");return n(r).then(function(n){var i={};i.className="_Follower",i.keys="follower",i.where={user:n};var s={};s.query=i,t.data=t.data||{},t.data.source=t.data.source||n,s.data=t._getDataJSON(),s.inboxType=t.inboxType||"default";var a=o("statuses",null,null,"POST",s,r);return a.then(function(n){return t.id=n.objectId,t.createdAt=e._parseDate(n.createdAt),t})})},e.Status.sendPrivateStatus=function(t,r){var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!s.sessionToken&&!e.User.current())throw new Error("Please signin an user.");if(!r)throw new Error("Invalid target user.");var a=i.isString(r)?r:r.id;if(!a)throw new Error("Invalid target user.");return n(s).then(function(n){var r={};r.className="_User",r.where={objectId:a};var i={};i.query=r,t.data=t.data||{},t.data.source=t.data.source||n,i.data=t._getDataJSON(),i.inboxType="private",t.inboxType="private";var u=o("statuses",null,null,"POST",i,s);return u.then(function(n){return t.id=n.objectId,t.createdAt=e._parseDate(n.createdAt),t})})},e.Status.countUnreadStatuses=function(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default",s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(i.isString(r)||(s=r),!s.sessionToken&&null==n&&!e.User.current())throw new Error("Please signin an user or pass the owner objectId.");return t(s).then(function(t){var n={};return n.inboxType=e._encode(r),n.owner=e._encode(t),o("subscribe/statuses/count",null,null,"GET",n,s)})},e.Status.resetUnreadCount=function(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default",s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(i.isString(r)||(s=r),!s.sessionToken&&null==n&&!e.User.current())throw new Error("Please signin an user or pass the owner objectId.");return t(s).then(function(t){var n={};return n.inboxType=e._encode(r),n.owner=e._encode(t),o("subscribe/statuses/resetUnreadCount",null,null,"POST",n,s)})},e.Status.statusQuery=function(t){var n=new e.Query("_Status");return t&&n.equalTo("source",t),n},e.InboxQuery=e.Query._extend({_objectClass:e.Status,_sinceId:0,_maxId:0,_inboxType:"default",_owner:null,_newObject:function(){return new e.Status},_createRequest:function(e,t){return o("subscribe/statuses",null,null,"GET",e||this.toJSON(),t)},sinceId:function(e){return this._sinceId=e,this},maxId:function(e){return this._maxId=e,this},owner:function(e){return this._owner=e,this},inboxType:function(e){return this._inboxType=e,this},toJSON:function(){var t=e.InboxQuery.__super__.toJSON.call(this);return t.owner=e._encode(this._owner),t.inboxType=e._encode(this._inboxType),t.sinceId=e._encode(this._sinceId),t.maxId=e._encode(this._maxId),t}}),e.Status.inboxQuery=function(t,n){var r=new e.InboxQuery(e.Status);return t&&(r._owner=t),n&&(r._inboxType=n),r}}},function(e,t,n){"use strict";e.exports=[]},function(e,t,n){"use strict";var r=n(18),i=["Weapp"].concat(n(40));e.exports="LeanCloud-JS-SDK/"+r+" ("+i.join("; ")+")"},function(e,t,n){"use strict";var r=n(7),i=n(5)("cos"),o=n(1);e.exports=function(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};n.attributes.url=e.url,n._bucket=e.bucket,n.id=e.objectId;var a=e.upload_url+"?sign="+encodeURIComponent(e.token);return new o(function(e,o){var u=r("POST",a).field("fileContent",t).field("op","upload");s.onprogress&&u.on("progress",s.onprogress),u.end(function(t,r){return r&&i(r.status,r.body,r.text),t?(r&&(t.statusCode=r.status,t.responseText=r.text,t.response=r.body),o(t)):void e(n)})})}},function(e,t,n){"use strict";var r=n(7),i=n(1),o=n(5)("qiniu");e.exports=function(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};n.attributes.url=e.url,n._bucket=e.bucket,n.id=e.objectId;var a=e.token;return new i(function(e,i){var u=r("POST","https://up.qbox.me").field("file",t).field("name",n.attributes.name).field("key",n._qiniu_key).field("token",a);s.onprogress&&u.on("progress",s.onprogress),u.end(function(t,r){return r&&o(r.status,r.body,r.text),t?(r&&(t.statusCode=r.status,t.responseText=r.text,t.response=r.body),i(t)):void e(n)})})}},function(e,t,n){"use strict";var r=n(7);n(1);e.exports=function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return n.attributes.url=e.url,n._bucket=e.bucket,n.id=e.objectId,new Promise(function(o,s){var a=r("PUT",e.upload_url).set("Content-Type",n.get("mime_type")).send(t);i.onprogress&&a.on("progress",i.onprogress),a.end(function(e,t){return e?(t&&(e.statusCode=t.status,e.responseText=t.text,e.response=t.body),s(e)):void o(n)})})}},function(e,t,n){"use strict";var r=n(0),i=n(3),o=n(2).request,s=n(1),a=function(){if("undefined"==typeof wx||"function"!=typeof wx.login)throw new Error("Weapp Login is only available in Weapp");return new s(function(e,t){wx.login({success:function(n){var r=n.code,i=n.errMsg;r?e(r):t(new Error(i))}})})};e.exports=function(e){e.User=e.Object.extend("_User",{_isCurrentUser:!1,_mergeMagicFields:function(t){t.sessionToken&&(this._sessionToken=t.sessionToken,delete t.sessionToken),e.User.__super__._mergeMagicFields.call(this,t)},_cleanupAuthData:function(){if(this.isCurrent()){var t=this.get("authData");t&&e._objectEach(this.get("authData"),function(e,n){t[n]||delete t[n]})}},_synchronizeAllAuthData:function(){var t=this.get("authData");if(t){var n=this;e._objectEach(this.get("authData"),function(e,t){n._synchronizeAuthData(t)})}},_synchronizeAuthData:function(t){if(this.isCurrent()){var n;r.isString(t)?(n=t,t=e.User._authProviders[n]):n=t.getAuthType();var i=this.get("authData");if(i&&t){var o=t.restoreAuthentication(i[n]);o||this._unlinkFrom(t)}}},_handleSaveResult:function(t){return t&&!e._config.disableCurrentUser&&(this._isCurrentUser=!0),this._cleanupAuthData(),this._synchronizeAllAuthData(),delete this._serverData.password,this._rebuildEstimatedDataForKey("password"),this._refreshCache(),!t&&!this.isCurrent()||e._config.disableCurrentUser?s.resolve():s.resolve(e.User._saveCurrentUser(this))},_linkWith:function(t,n){var i,o=this;if(r.isString(t)?(i=t,t=e.User._authProviders[t]):i=t.getAuthType(),n){var s=this.get("authData")||{};return s[i]=n,this.save({authData:s}).then(function(e){return e._handleSaveResult(!0).then(function(){return e})})}return t.authenticate().then(function(e){return o._linkWith(t,e)})},linkWithWeapp:function(){var e=this;return a().then(function(t){return e._linkWith("lc_weapp",{code:t})})},_unlinkFrom:function(t){var n=this;return r.isString(t)&&(t=e.User._authProviders[t]),this._linkWith(t,null).then(function(e){return n._synchronizeAuthData(t),e})},_isLinked:function(e){var t;t=r.isString(e)?e:e.getAuthType();var n=this.get("authData")||{};return!!n[t]},logOut:function(){this._logOutWithAll(),this._isCurrentUser=!1},_logOutWithAll:function(){var t=this.get("authData");if(t){var n=this;e._objectEach(this.get("authData"),function(e,t){n._logOutWith(t)})}},_logOutWith:function(t){this.isCurrent()&&(r.isString(t)&&(t=e.User._authProviders[t]),t&&t.deauthenticate&&t.deauthenticate())},signUp:function(e,t){var n,r=e&&e.username||this.get("username");if(!r||""===r)throw n=new i(i.OTHER_CAUSE,"Cannot sign up user with an empty name.");var o=e&&e.password||this.get("password");if(!o||""===o)throw n=new i(i.OTHER_CAUSE,"Cannot sign up user with an empty password.");return this.save(e,t).then(function(e){return e._handleSaveResult(!0).then(function(){return e})})},signUpOrlogInWithMobilePhone:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e&&e.mobilePhoneNumber||this.get("mobilePhoneNumber");if(!r||""===r)throw t=new i(i.OTHER_CAUSE,"Cannot sign up or login user by mobilePhoneNumber with an empty mobilePhoneNumber.");var s=e&&e.smsCode||this.get("smsCode");if(!s||""===s)throw t=new i(i.OTHER_CAUSE,"Cannot sign up or login user by mobilePhoneNumber with an empty smsCode.");return n._makeRequest=function(e,t,n,r,i){return o("usersByMobilePhone",null,null,"POST",i)},this.save(e,n).then(function(e){return delete e.attributes.smsCode,delete e._serverData.smsCode,e._handleSaveResult(!0).then(function(){return e})})},logIn:function(){var e=this,t=o("login",null,null,"POST",this.toJSON());return t.then(function(t){var n=e.parse(t);return e._finishFetch(n),e._handleSaveResult(!0).then(function(){return n.smsCode||delete e.attributes.smsCode,e})})},save:function(t,n,i){var o,s;return r.isObject(t)||r.isNull(t)||r.isUndefined(t)?(o=t,s=n):(o={},o[t]=n,s=i),s=s||{},e.Object.prototype.save.call(this,o,s).then(function(e){return e._handleSaveResult(!1).then(function(){return e})})},follow:function(e,t){if(!this.id)throw new Error("Please signin.");if(!e)throw new Error("Invalid target user.");var n=r.isString(e)?e:e.id;if(!n)throw new Error("Invalid target user.");var i="users/"+this.id+"/friendship/"+n,s=o(i,null,null,"POST",null,t);return s},unfollow:function(e,t){if(!this.id)throw new Error("Please signin.");if(!e)throw new Error("Invalid target user.");var n=r.isString(e)?e:e.id;if(!n)throw new Error("Invalid target user.");var i="users/"+this.id+"/friendship/"+n,s=o(i,null,null,"DELETE",null,t);return s},followerQuery:function(){return e.User.followerQuery(this.id)},followeeQuery:function(){return e.User.followeeQuery(this.id)},fetch:function(t,n){return e.Object.prototype.fetch.call(this,t,n).then(function(e){return e._handleSaveResult(!1).then(function(){return e})})},updatePassword:function(e,t,n){var r="users/"+this.id+"/updatePassword",i={old_password:e,new_password:t},s=o(r,null,null,"PUT",i,n);return s},isCurrent:function(){return this._isCurrentUser},getUsername:function(){return this.get("username")},getMobilePhoneNumber:function(){return this.get("mobilePhoneNumber")},setMobilePhoneNumber:function(e,t){return this.set("mobilePhoneNumber",e,t)},setUsername:function(e,t){return this.set("username",e,t)},setPassword:function(e,t){return this.set("password",e,t)},getEmail:function(){return this.get("email")},setEmail:function(e,t){return this.set("email",e,t)},authenticated:function(){return console.warn("DEPRECATED: 如果要判断当前用户的登录状态是否有效,请使用 currentUser.isAuthenticated().then(),如果要判断该用户是否是当前登录用户,请使用 user.id === currentUser.id。"),!!this._sessionToken&&!e._config.disableCurrentUser&&e.User.current()&&e.User.current().id===this.id},isAuthenticated:function(){var t=this;return s.resolve().then(function(){return!!t._sessionToken&&e.User._fetchUserBySessionToken(t._sessionToken).then(function(){return!0},function(e){if(211===e.code)return!1;throw e})})},getSessionToken:function(){return this._sessionToken},refreshSessionToken:function(e){var t=this;return o("users/"+this.id+"/refreshSessionToken",null,null,"PUT",null,e).then(function(e){return t._finishFetch(e),t})},getRoles:function(t){return e.Relation.reverseQuery("_Role","users",this).find(t)}},{_currentUser:null,_currentUserMatchesDisk:!1,_CURRENT_USER_KEY:"currentUser",_authProviders:{},signUp:function(t,n,r,i){r=r||{},r.username=t,r.password=n;var o=e.Object._create("_User");return o.signUp(r,i)},logIn:function(t,n,r){var i=e.Object._create("_User");return i._finishFetch({username:t,password:n}),i.logIn(r)},become:function(e){return this._fetchUserBySessionToken(e).then(function(e){return e._handleSaveResult(!0).then(function(){return e})})},_fetchUserBySessionToken:function(t){var n=e.Object._create("_User");return o("users","me",null,"GET",{session_token:t}).then(function(e){var t=n.parse(e);return n._finishFetch(t),n})},logInWithMobilePhoneSmsCode:function(t,n,r){var i=e.Object._create("_User");return i._finishFetch({mobilePhoneNumber:t,smsCode:n}),i.logIn(r)},signUpOrlogInWithMobilePhone:function(t,n,r,i){r=r||{},r.mobilePhoneNumber=t,r.smsCode=n;var o=e.Object._create("_User");return o.signUpOrlogInWithMobilePhone(r,i)},logInWithMobilePhone:function(t,n,r){var i=e.Object._create("_User");return i._finishFetch({mobilePhoneNumber:t,password:n}),i.logIn(r)},signUpOrlogInWithAuthData:function(t,n){return e.User._logInWith(n,t)},loginWithWeapp:function(){var e=this;return a().then(function(t){return e.signUpOrlogInWithAuthData({code:t},"lc_weapp")})},associateWithAuthData:function(e,t,n){return e._linkWith(t,n)},logOut:function(){return e._config.disableCurrentUser?(console.warn("AV.User.current() was disabled in multi-user environment, call logOut() from user object instead https://leancloud.cn/docs/leanengine-node-sdk-upgrade-1.html"),s.resolve(null)):(null!==e.User._currentUser&&(e.User._currentUser._logOutWithAll(),e.User._currentUser._isCurrentUser=!1),e.User._currentUserMatchesDisk=!0,e.User._currentUser=null,e.localStorage.removeItemAsync(e._getAVPath(e.User._CURRENT_USER_KEY)))},followerQuery:function(t){if(!t||!r.isString(t))throw new Error("Invalid user object id.");var n=new e.FriendShipQuery("_Follower");return n._friendshipTag="follower",n.equalTo("user",e.Object.createWithoutData("_User",t)),n},followeeQuery:function(t){if(!t||!r.isString(t))throw new Error("Invalid user object id.");var n=new e.FriendShipQuery("_Followee");return n._friendshipTag="followee",n.equalTo("user",e.Object.createWithoutData("_User",t)),n},requestPasswordReset:function(e){var t={email:e},n=o("requestPasswordReset",null,null,"POST",t);return n},requestEmailVerify:function(e){var t={email:e},n=o("requestEmailVerify",null,null,"POST",t);return n},requestMobilePhoneVerify:function(e){var t={mobilePhoneNumber:e},n=o("requestMobilePhoneVerify",null,null,"POST",t);return n},requestPasswordResetBySmsCode:function(e){var t={mobilePhoneNumber:e},n=o("requestPasswordResetBySmsCode",null,null,"POST",t);return n},resetPasswordBySmsCode:function(e,t){var n={password:t},r=o("resetPasswordBySmsCode",null,e,"PUT",n);return r},verifyMobilePhone:function(e){var t=o("verifyMobilePhone",null,e,"POST",null);return t},requestLoginSmsCode:function(e){var t={mobilePhoneNumber:e},n=o("requestLoginSmsCode",null,null,"POST",t);return n},currentAsync:function(){return e._config.disableCurrentUser?(console.warn("AV.User.currentAsync() was disabled in multi-user environment, access user from request instead https://leancloud.cn/docs/leanengine-node-sdk-upgrade-1.html"),s.resolve(null)):e.User._currentUser?s.resolve(e.User._currentUser):e.User._currentUserMatchesDisk?s.resolve(e.User._currentUser):e.localStorage.getItemAsync(e._getAVPath(e.User._CURRENT_USER_KEY)).then(function(t){if(!t)return null;e.User._currentUserMatchesDisk=!0,e.User._currentUser=e.Object._create("_User"),e.User._currentUser._isCurrentUser=!0;var n=JSON.parse(t);return e.User._currentUser.id=n._id,delete n._id,e.User._currentUser._sessionToken=n._sessionToken,delete n._sessionToken,e.User._currentUser._finishFetch(n),e.User._currentUser._synchronizeAllAuthData(),e.User._currentUser._refreshCache(),e.User._currentUser._opSetQueue=[{}],e.User._currentUser})},current:function(){if(e._config.disableCurrentUser)return console.warn("AV.User.current() was disabled in multi-user environment, access user from request instead https://leancloud.cn/docs/leanengine-node-sdk-upgrade-1.html"),null;if(e.User._currentUser)return e.User._currentUser;if(e.User._currentUserMatchesDisk)return e.User._currentUser;e.User._currentUserMatchesDisk=!0;var t=e.localStorage.getItem(e._getAVPath(e.User._CURRENT_USER_KEY));if(!t)return null;e.User._currentUser=e.Object._create("_User"),e.User._currentUser._isCurrentUser=!0;var n=JSON.parse(t);return e.User._currentUser.id=n._id,delete n._id,e.User._currentUser._sessionToken=n._sessionToken,delete n._sessionToken,e.User._currentUser._finishFetch(n),e.User._currentUser._synchronizeAllAuthData(),e.User._currentUser._refreshCache(),e.User._currentUser._opSetQueue=[{}],e.User._currentUser},_saveCurrentUser:function(t){var n;return n=e.User._currentUser!==t?e.User.logOut():s.resolve(),n.then(function(){t._isCurrentUser=!0,e.User._currentUser=t;var n=t.toJSON();return n._id=t.id,n._sessionToken=t._sessionToken,e.localStorage.setItemAsync(e._getAVPath(e.User._CURRENT_USER_KEY),JSON.stringify(n)).then(function(){e.User._currentUserMatchesDisk=!0})})},_registerAuthenticationProvider:function(t){e.User._authProviders[t.getAuthType()]=t,!e._config.disableCurrentUser&&e.User.current()&&e.User.current()._synchronizeAuthData(t.getAuthType())},_logInWith:function(t,n){var r=e.Object._create("_User");return r._linkWith(t,n)}})}},function(e,t,n){"use strict";(function(t){var r=n(0),i=(n(1),{}),o=["getItem","setItem","removeItem","clear"],s=t.localStorage;try{var a="__storejs__";if(s.setItem(a,a),s.getItem(a)!=a)throw new Error;s.removeItem(a)}catch(e){s=n(55)}r(o).each(function(e){i[e]=function(){return t.localStorage[e].apply(t.localStorage,arguments)}}),i.async=!1,e.exports=i}).call(t,n(8))},function(e,t,n){"use strict";var r=function(e,t){var n;e.indexOf("base64")<0?n=atob(e):e.split(",")[0].indexOf("base64")>=0?(t=t||e.split(",")[0].split(":")[1].split(";")[0],n=atob(e.split(",")[1])):n=unescape(e.split(",")[1]);for(var r=new Uint8Array(n.length),i=0;i>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],n=0,r=0;n>>5]|=e[n]<<24-r%32;return t},wordsToBytes:function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},bytesToHex:function(e){for(var t=[],n=0;n>>4).toString(16)),t.push((15&e[n]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],n=0;n>>6*(3-o)&63)):n.push("=");return n.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var n=[],r=0,i=0;r>>6-2*i);return n}};e.exports=n}()},function(e,t,n){function r(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}function i(e){function n(){if(n.enabled){var e=n,r=+new Date,i=r-(c||r);e.diff=i,e.prev=c,e.curr=r,c=r;for(var o=new Array(arguments.length),s=0;s>>24)|4278255360&(a[d]<<24|a[d]>>>8);a[u>>>5]|=128<>>9<<4)+14]=u;for(var p=s._ff,_=s._gg,v=s._hh,y=s._ii,d=0;d>>0,l=l+g>>>0,f=f+b>>>0,h=h+w>>>0}return t.endian([c,l,f,h])};s._ff=function(e,t,n,r,i,o,s){var a=e+(t&n|~t&r)+(i>>>0)+s;return(a<>>32-o)+t},s._gg=function(e,t,n,r,i,o,s){var a=e+(t&r|n&~r)+(i>>>0)+s;return(a<>>32-o)+t},s._hh=function(e,t,n,r,i,o,s){var a=e+(t^n^r)+(i>>>0)+s;return(a<>>32-o)+t},s._ii=function(e,t,n,r,i,o,s){var a=e+(n^(t|~r))+(i>>>0)+s;return(a<>>32-o)+t},s._blocksize=16,s._digestsize=16,e.exports=function(e,n){if(void 0===e||null===e)throw new Error("Illegal argument "+e);var r=t.wordsToBytes(s(e,n));return n&&n.asBytes?r:n&&n.asString?o.bytesToString(r):t.bytesToHex(r)}}()},function(e,t){function n(e){if(e=String(e),!(e.length>1e4)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*l;case"days":case"day":case"d":return n*c;case"hours":case"hour":case"hrs":case"hr":case"h":return n*u;case"minutes":case"minute":case"mins":case"min":case"m":return n*a;case"seconds":case"second":case"secs":case"sec":case"s":return n*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function r(e){return e>=c?Math.round(e/c)+"d":e>=u?Math.round(e/u)+"h":e>=a?Math.round(e/a)+"m":e>=s?Math.round(e/s)+"s":e+"ms"}function i(e){return o(e,c,"day")||o(e,u,"hour")||o(e,a,"minute")||o(e,s,"second")||e+" ms"}function o(e,t,n){if(!(e0)return n(e);if("number"===o&&isNaN(e)===!1)return t.long?i(e):r(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,n){function r(e){var t=i(e)?Object.prototype.toString.call(e):"";return"[object Function]"===t}var i=n(11);e.exports=r},function(e,t,n){function r(e){if(e)return i(e)}function i(e){for(var t in r.prototype)e[t]=r.prototype[t];return e}var o=n(11);e.exports=r,r.prototype.clearTimeout=function(){return this._timeout=0,this._responseTimeout=0,clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),this},r.prototype.parse=function(e){return this._parser=e,this},r.prototype.responseType=function(e){return this._responseType=e,this},r.prototype.serialize=function(e){return this._serializer=e,this},r.prototype.timeout=function(e){return e&&"object"==typeof e?("undefined"!=typeof e.deadline&&(this._timeout=e.deadline),"undefined"!=typeof e.response&&(this._responseTimeout=e.response),this):(this._timeout=e,this._responseTimeout=0,this)},r.prototype.then=function(e,t){if(!this._fullfilledPromise){var n=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(e,t){n.end(function(n,r){n?t(n):e(r)})})}return this._fullfilledPromise.then(e,t)},r.prototype.catch=function(e){return this.then(void 0,e)},r.prototype.use=function(e){return e(this),this},r.prototype.ok=function(e){if("function"!=typeof e)throw Error("Callback required");return this._okCallback=e,this},r.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},r.prototype.get=function(e){return this._header[e.toLowerCase()]},r.prototype.getHeader=r.prototype.get,r.prototype.set=function(e,t){if(o(e)){for(var n in e)this.set(n,e[n]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},r.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},r.prototype.field=function(e,t){if(null===e||void 0===e)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),o(e)){for(var n in e)this.field(n,e[n]);return this}if(Array.isArray(t)){for(var r in t)this.field(e,t[r]);return this}if(null===t||void 0===t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=""+t),this._getFormData().append(e,t),this},r.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},r.prototype.withCredentials=function(){return this._withCredentials=!0,this},r.prototype.redirects=function(e){return this._maxRedirects=e,this},r.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},r.prototype.send=function(e){var t=o(e),n=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(t&&o(this._data))for(var r in e)this._data[r]=e[r];else"string"==typeof e?(n||this.type("form"),n=this._header["content-type"],"application/x-www-form-urlencoded"==n?this._data=this._data?this._data+"&"+e:e:this._data=(this._data||"")+e):this._data=e;return!t||this._isHost(e)?this:(n||this.type("json"),this)},r.prototype.sortQuery=function(e){return this._sort="undefined"==typeof e||e,this},r.prototype._timeoutError=function(e,t){if(!this._aborted){var n=new Error(e+t+"ms exceeded");n.timeout=t,n.code="ECONNABORTED",this.timedout=!0,this.abort(),this.callback(n)}},r.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){e._timeoutError("Timeout of ",e._timeout)},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){e._timeoutError("Response timeout of ",e._responseTimeout)},this._responseTimeout))}},function(e,t,n){function r(e){if(e)return i(e)}function i(e){for(var t in r.prototype)e[t]=r.prototype[t];return e}var o=n(61);e.exports=r,r.prototype.get=function(e){return this.header[e.toLowerCase()]},r.prototype._setHeaderProperties=function(e){var t=e["content-type"]||"";this.type=o.type(t);var n=o.params(t);for(var r in n)this[r]=n[r];this.links={};try{e.link&&(this.links=o.parseLinks(e.link))}catch(e){}},r.prototype._setStatusProperties=function(e){var t=e/100|0;this.status=this.statusCode=e,this.statusType=t,this.info=1==t,this.ok=2==t,this.redirect=3==t,this.clientError=4==t,this.serverError=5==t,this.error=(4==t||5==t)&&this.toError(),this.accepted=202==e,this.noContent=204==e,this.badRequest=400==e,this.unauthorized=401==e,this.notAcceptable=406==e,this.forbidden=403==e,this.notFound=404==e}},function(e,t){t.type=function(e){return e.split(/ *; */).shift()},t.params=function(e){return e.split(/ *; */).reduce(function(e,t){var n=t.split(/ *= */),r=n.shift(),i=n.shift();return r&&i&&(e[r]=i),e},{})},t.parseLinks=function(e){return e.split(/ *, */).reduce(function(e,t){var n=t.split(/ *; */),r=n[0].slice(1,-1),i=n[1].split(/ *= */)[1].slice(1,-1);return e[i]=r,e},{})},t.cleanHeader=function(e,t){return delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&delete e.cookie,e}},function(e,t){},function(e,t,n){"use strict";n(22),e.exports=n(23)}])}); 6 | //# sourceMappingURL=av-weapp-min.js.map --------------------------------------------------------------------------------