├── pages ├── index │ ├── index.json │ ├── index.wxml │ ├── index.wxss │ └── index.js ├── login │ ├── login.json │ ├── login.wxml │ ├── login.wxss │ └── login.js ├── collect │ ├── collect.json │ ├── collect.wxml │ ├── collect.wxss │ └── collect.js ├── detail │ ├── detail.json │ ├── detail.wxml │ ├── detail.wxss │ └── detail.js ├── result │ ├── result.json │ ├── result.wxml │ ├── result.wxss │ └── result.js └── user │ ├── user.json │ ├── user.wxml │ ├── user.wxss │ └── user.js ├── .gitignore ├── images ├── tx.png ├── bookbox.png ├── connect.png ├── nobook.png ├── title.png ├── bookmodle.png ├── icon │ ├── icon-me.png │ ├── icon-book.png │ ├── icon-load.gif │ ├── icon-love.png │ ├── icon-collect.png │ ├── icon-me-cur.png │ ├── icon-book-cur.png │ ├── icon-love-cur.png │ └── icon-collect-cur.png ├── nobook-happy.png ├── search-fail.png └── avatar-default.png ├── utils ├── hotapp-conf.js ├── hotapp.js └── av-weapp-min.js ├── app.wxss ├── README.md ├── app.json └── app.js /pages/index/index.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea -------------------------------------------------------------------------------- /images/tx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ToadWoo/bookbox-wxapp/HEAD/images/tx.png -------------------------------------------------------------------------------- /images/bookbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ToadWoo/bookbox-wxapp/HEAD/images/bookbox.png -------------------------------------------------------------------------------- /images/connect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ToadWoo/bookbox-wxapp/HEAD/images/connect.png -------------------------------------------------------------------------------- /images/nobook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ToadWoo/bookbox-wxapp/HEAD/images/nobook.png -------------------------------------------------------------------------------- /images/title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ToadWoo/bookbox-wxapp/HEAD/images/title.png -------------------------------------------------------------------------------- /images/bookmodle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ToadWoo/bookbox-wxapp/HEAD/images/bookmodle.png -------------------------------------------------------------------------------- /images/icon/icon-me.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ToadWoo/bookbox-wxapp/HEAD/images/icon/icon-me.png -------------------------------------------------------------------------------- /images/nobook-happy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ToadWoo/bookbox-wxapp/HEAD/images/nobook-happy.png -------------------------------------------------------------------------------- /images/search-fail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ToadWoo/bookbox-wxapp/HEAD/images/search-fail.png -------------------------------------------------------------------------------- /images/avatar-default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ToadWoo/bookbox-wxapp/HEAD/images/avatar-default.png -------------------------------------------------------------------------------- /images/icon/icon-book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ToadWoo/bookbox-wxapp/HEAD/images/icon/icon-book.png -------------------------------------------------------------------------------- /images/icon/icon-load.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ToadWoo/bookbox-wxapp/HEAD/images/icon/icon-load.gif -------------------------------------------------------------------------------- /images/icon/icon-love.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ToadWoo/bookbox-wxapp/HEAD/images/icon/icon-love.png -------------------------------------------------------------------------------- /images/icon/icon-collect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ToadWoo/bookbox-wxapp/HEAD/images/icon/icon-collect.png -------------------------------------------------------------------------------- /images/icon/icon-me-cur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ToadWoo/bookbox-wxapp/HEAD/images/icon/icon-me-cur.png -------------------------------------------------------------------------------- /images/icon/icon-book-cur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ToadWoo/bookbox-wxapp/HEAD/images/icon/icon-book-cur.png -------------------------------------------------------------------------------- /images/icon/icon-love-cur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ToadWoo/bookbox-wxapp/HEAD/images/icon/icon-love-cur.png -------------------------------------------------------------------------------- /images/icon/icon-collect-cur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ToadWoo/bookbox-wxapp/HEAD/images/icon/icon-collect-cur.png -------------------------------------------------------------------------------- /utils/hotapp-conf.js: -------------------------------------------------------------------------------- 1 | exports.hotAppKey='hotapp100495290'; //小程序在hotapp平台注册的appKey 2 | exports.appVer='0.1.0'; //本地小程序的版本号,用来区分错误统计 3 | -------------------------------------------------------------------------------- /pages/login/login.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": " ", 3 | "navigationBarBackgroundColor": "#fff", 4 | "navigationBarTextStyle":"black" 5 | } -------------------------------------------------------------------------------- /pages/collect/collect.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "收藏", 3 | "navigationBarBackgroundColor": "#338FFC", 4 | "navigationBarTextStyle":"white", 5 | "backgroundColor": "#fff" 6 | } -------------------------------------------------------------------------------- /pages/detail/detail.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "图书盒子", 3 | "navigationBarBackgroundColor": "#338FFC", 4 | "navigationBarTextStyle":"white", 5 | "backgroundColor": "#fff" 6 | } -------------------------------------------------------------------------------- /pages/result/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "图书盒子", 3 | "navigationBarBackgroundColor": "#338FFC", 4 | "navigationBarTextStyle":"white", 5 | "backgroundColor": "#f9fbfe" 6 | } -------------------------------------------------------------------------------- /pages/user/user.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "图书盒子", 3 | "navigationBarBackgroundColor": "#338FFC", 4 | "navigationBarTextStyle":"white", 5 | "backgroundColor": "#f9fbfe" 6 | } -------------------------------------------------------------------------------- /app.wxss: -------------------------------------------------------------------------------- 1 | /**app.wxss**/ 2 | .container { 3 | height: 100%; 4 | display: flex; 5 | flex-direction: column; 6 | align-items: center; 7 | justify-content: space-between; 8 | padding: 200rpx 0; 9 | box-sizing: border-box; 10 | } 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bookbox-wxapp 2 | 图书盒子Pro[小程序]--集美大学图书馆的便捷工具 3 | 4 | 功能介绍及详情可查看:[图书盒子Pro小程序官网](http://bookbox.toadw.cn) 5 | 6 | 7 | 小程序截图:[截图](https://github.com/ToadWoo/bookbox-wxapp/wiki/%E7%95%8C%E9%9D%A2%E6%88%AA%E5%9B%BE) 8 | 9 | ###目前支持功能 10 | - [x] 集美大学图书馆馆藏书目查询 11 | - [x] 个人图书借阅情况查询 12 | - [x] 喜爱书籍收藏 13 | 14 | ###TODO功能 15 | - [ ] 书籍评论 16 | - [ ] 续借功能 17 | 18 | ### 版本更新记录 19 | 20 | - v0.1 搜索、个人借阅查询、收藏 21 | 22 | -------------------------------------------------------------------------------- /pages/login/login.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 10 |
11 |
-------------------------------------------------------------------------------- /pages/index/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | -------------------------------------------------------------------------------- /pages/login/login.wxss: -------------------------------------------------------------------------------- 1 | .logo{ 2 | display: block; 3 | width: 129rpx; 4 | height: 129rpx; 5 | margin: 80rpx auto 10px auto; 6 | } 7 | .title{ 8 | display: block; 9 | height: 40rpx; 10 | margin: 0 auto 90rpx auto; 11 | } 12 | .m-login{ 13 | width: 80%; 14 | margin: 0 auto; 15 | } 16 | .m-login .login-inp{ 17 | border-bottom: 1rpx solid #b2b2b2; 18 | margin-bottom:50rpx; 19 | line-height: 80rpx; 20 | height: 80rpx; 21 | padding: 0 10rpx; 22 | font-size: 36rpx; 23 | 24 | } 25 | .m-login .inp-place{ 26 | color: #b2b2b2; 27 | } 28 | .m-login .login-btn{ 29 | margin-top: 80rpx; 30 | background: #338FFC; 31 | border: none; 32 | height: 94rpx; 33 | line-height: 94rpx; 34 | font-size: 36rpx; 35 | border-radius: 10rpx; 36 | color: #fff; 37 | } -------------------------------------------------------------------------------- /pages/collect/collect.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{item.name}} 5 | {{item.author}} 6 | 7 | {{item.location}} 8 | {{item.callNumber}} 9 | 可借:{{item.available}} 10 | 11 | 12 | 13 | 14 | 15 | 16 | 您的收藏夹还是空的~ 17 | 18 | 19 | 查找书时点击爱心即可收藏 20 | 21 | 22 | -------------------------------------------------------------------------------- /pages/index/index.wxss: -------------------------------------------------------------------------------- 1 | 2 | .logo{ 3 | display: block; 4 | width: 129rpx; 5 | height: 129rpx; 6 | margin: 100rpx auto; 7 | } 8 | .m-search{ 9 | position: relative; 10 | width: 620rpx; 11 | margin: 0 auto; 12 | 13 | } 14 | .icon-search{ 15 | position: absolute; 16 | top: 36rpx; 17 | left: 25rpx; 18 | width: 38rpx; 19 | height: 38rpx; 20 | } 21 | .icon-cancel{ 22 | position: absolute; 23 | top: 7rpx; 24 | right: 105rpx; 25 | width: 38rpx; 26 | height: 38rpx; 27 | padding: 30rpx 20rpx 30rpx 10rpx; 28 | } 29 | .search-inp{ 30 | padding: 30rpx 170rpx 30rpx 70rpx; 31 | box-shadow: 0 0 20rpx #EBF5FF; 32 | border-radius: 15rpx; 33 | } 34 | .search-btn{ 35 | position: absolute; 36 | top: 0; 37 | right: 0; 38 | border: 0; 39 | background: #338FFC; 40 | color: #fff; 41 | border-radius: 0 15rpx 15rpx 0; 42 | padding: 30rpx 25rpx; 43 | line-height: 1.4rem; 44 | text-align: center; 45 | font-size: 30rpx; 46 | } 47 | .search-btn::after{ 48 | content: none; 49 | } -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages": [ 3 | 4 | "pages/index/index", 5 | "pages/user/user", 6 | "pages/collect/collect", 7 | "pages/login/login", 8 | "pages/detail/detail", 9 | "pages/result/result" 10 | ], 11 | "window": { 12 | "backgroundTextStyle": "light", 13 | "navigationBarBackgroundColor": "#fff", 14 | "navigationBarTitleText": "图书盒子", 15 | "navigationBarTextStyle": "black" 16 | }, 17 | "tabBar": { 18 | "color": "#bcc1cc", 19 | "backgroundColor": "#ffffff", 20 | "selectedColor": "#338ffc", 21 | "list": [ 22 | { 23 | "pagePath": "pages/index/index", 24 | "text": "找书", 25 | "iconPath": "images/icon/icon-book.png", 26 | "selectedIconPath": "images/icon/icon-book-cur.png" 27 | }, 28 | { 29 | "pagePath": "pages/collect/collect", 30 | "text": "搜藏", 31 | "iconPath": "images/icon/icon-collect.png", 32 | "selectedIconPath": "images/icon/icon-collect-cur.png" 33 | }, 34 | { 35 | "pagePath": "pages/user/user", 36 | "text": "我", 37 | "iconPath": "images/icon/icon-me.png", 38 | "selectedIconPath": "images/icon/icon-me-cur.png" 39 | } 40 | ] 41 | } 42 | } -------------------------------------------------------------------------------- /pages/collect/collect.wxss: -------------------------------------------------------------------------------- 1 | page{ 2 | background: "#338FFC"; 3 | } 4 | .collect-list{ 5 | padding: 0 30rpx; 6 | } 7 | .bookitem{ 8 | background: #338FFC; 9 | border-radius: 20rpx; 10 | margin: 30rpx 0; 11 | padding: 20rpx 40rpx; 12 | color: #fff; 13 | box-shadow: 0 0 20rpx #eee; 14 | text-align: center; 15 | } 16 | .bookitem .name{ 17 | font-size: 34rpx; 18 | padding-bottom: 10rpx; 19 | } 20 | .bookitem .author{ 21 | font-size: 28rpx; 22 | padding-bottom: 10rpx; 23 | } 24 | .bookitem .other-infos{ 25 | display: flex; 26 | flex-direction: row; 27 | justify-content: center; 28 | font-size: 22rpx; 29 | color: #fff; 30 | } 31 | .bookitem .other-infos .info-item{ 32 | margin: 0 10rpx; 33 | border: 1rpx solid #fff; 34 | padding: 0 10rpx; 35 | } 36 | .bookitem .other-infos .overflow{ 37 | max-width: 300rpx; 38 | overflow: hidden; 39 | text-overflow: ellipsis; 40 | display: -webkit-box; 41 | -webkit-line-clamp: 1; 42 | -webkit-box-orient: vertical; 43 | } 44 | 45 | 46 | .null-tip{ 47 | display: flex; 48 | flex-direction: column; 49 | justify-content: center; 50 | } 51 | .null-tip .img{ 52 | width: 150rpx; 53 | height: 150rpx; 54 | margin: 300rpx auto 30rpx auto; 55 | } 56 | .null-tip .txt{ 57 | font-size: 26rpx; 58 | color: #bcc1cc; 59 | text-align: center; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | //app.js 2 | var AV = require('utils/av-weapp-min.js'); 3 | var hotapp = require('utils/hotapp.js'); 4 | AV.init({ 5 | appId: 'gP7vju3g5dXbQyHXbLlKX4v5-gzGzoHsz', 6 | appKey: 'qgOtTnc2CD53LtFDiY2SL4JC', 7 | }); 8 | App({ 9 | onLaunch: function () { 10 | var that = this; 11 | const user = AV.User.current(); 12 | if (user) { 13 | // 已经登录 14 | } 15 | else { 16 | //currentUser 为空时,微信一键登录… 17 | AV.User.loginWithWeapp().then(user => { 18 | wx.getUserInfo({ 19 | success: ({userInfo}) => { 20 | // 更新当前用户的信息 21 | //头像存储到本地 22 | wx.setStorage({ 23 | key: "tshz_avatarUrl", 24 | data: userInfo.avatarUrl 25 | }) 26 | user.set(userInfo).save().then(user => { 27 | // 成功,此时可在控制台中看到更新后的用户信息 28 | that.globalData.user = user.toJSON(); 29 | }).catch(console.error); 30 | }, 31 | fail:()=>{ 32 | wx.setStorage({ 33 | key: "tshz_avatarUrl", 34 | data: "../../images/avatar-default.png" 35 | }) 36 | } 37 | }) 38 | }).catch(console.error); 39 | } 40 | }, 41 | onError: function (msg) { 42 | console.log(msg) 43 | console.log('onerror') 44 | }, 45 | globalData: { 46 | user: null, 47 | searchRsult: null 48 | } 49 | }) -------------------------------------------------------------------------------- /pages/collect/collect.js: -------------------------------------------------------------------------------- 1 | var app = getApp(); 2 | var AV = require('../../utils/av-weapp-min.js'); 3 | Page({ 4 | data: { 5 | 6 | }, 7 | onLoad: function () { 8 | 9 | }, 10 | //登录并获取收藏书目 11 | loginAndFetchCollection: function () { 12 | return AV.Promise.resolve(AV.User.current()).then(user => 13 | user ? (user.isAuthenticated().then(authed => authed ? user : null)) : null 14 | ).then(user => 15 | user ? user : AV.User.loginWithWeapp() 16 | ).then((user) => { 17 | console.log('uid', user.id); 18 | return new AV.Query('Collection') 19 | .equalTo('owner', AV.Object.createWithoutData('User', user.id)) 20 | .descending('createdAt') 21 | .find() 22 | .then(this.setCollection) 23 | }).catch(error => console.error(error.message)); 24 | }, 25 | onPullDownRefresh: function () { 26 | this.loginAndFetchCollection().then(wx.stopPullDownRefresh); 27 | }, 28 | 29 | //获得的书目储存到数据层 30 | setCollection: function (res) { 31 | var collectList = [] 32 | for (var i = 0; i < res.length; i++) { 33 | collectList.push(res[i].attributes) 34 | } 35 | this.setData({ 36 | collectList: collectList 37 | }) 38 | }, 39 | 40 | onShow: function () { 41 | this.loginAndFetchCollection() 42 | }, 43 | onShareAppMessage: function () { 44 | return { 45 | title: '图书盒子', 46 | path: '/pages/index/index' 47 | } 48 | } 49 | 50 | }) 51 | -------------------------------------------------------------------------------- /pages/result/result.wxml: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 | {{item.name}} 22 | {{item.author}} 23 | 24 | 出版社:{{item.publisher}} 25 | 索书号:{{item.callNumber}} 26 | 可借:{{item.available}} 27 | 28 | 29 | 30 | 31 | 32 | 加载中... 33 | 34 | 没有更多了 35 | 36 | 37 | 38 | 难过,没有找到您要的书... 39 | 40 | 41 | -------------------------------------------------------------------------------- /pages/detail/detail.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{name}} 5 | 作者:{{author}} 6 | 出版社:{{publisher}} 7 | ISBN:{{ISBN}} 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 详情 19 | 评论 20 | 21 | 22 | 详情 23 | 评论 24 | 25 | 26 | 27 | 28 | 29 | 30 | 馆藏情况: 31 | 32 | 33 | 索书号: 34 | {{infoes[0].callNumber}} 35 | 36 | 37 | {{infoes[0].location}}:共{{total}}本 可借{{available}}本 38 | 42 | 43 | 44 | 简介: 45 | 46 | {{intro}} 47 | 48 | 49 | 50 | 51 | 52 | 53 | Comming Soon... 54 | 55 | 56 | -------------------------------------------------------------------------------- /pages/detail/detail.wxss: -------------------------------------------------------------------------------- 1 | .header { 2 | display: flex; 3 | position: relative; 4 | flex-direction: row; 5 | justify-content: space-between; 6 | padding: 60rpx 40rpx 0 40rpx; 7 | height: 280rpx; 8 | background: #338ffc; 9 | overflow: hidden; 10 | } 11 | 12 | .header .book-img { 13 | width: 250rpx; 14 | /*margin-left: 50rpx;*//*height: 150rpx;*/ 15 | box-shadow: 0 0 20rpx #777; 16 | } 17 | 18 | .header .book-infos { 19 | display: flex; 20 | flex-direction: column; 21 | color: #fff; 22 | width: 380rpx; 23 | } 24 | 25 | .header .book-infos .name { 26 | width: 380rpx; 27 | font-size: 36rpx; 28 | font-weight: bold; 29 | overflow: hidden; 30 | text-overflow: ellipsis; 31 | display: -webkit-box; 32 | -webkit-line-clamp: 2; 33 | -webkit-box-orient: vertical; 34 | } 35 | 36 | .header .book-infos .item { 37 | font-size: 24rpx; 38 | padding-top: 5rpx; 39 | } 40 | 41 | .header .collect-btn{ 42 | width: 55rpx; 43 | height: 55rpx; 44 | position: absolute; 45 | bottom:30rpx; 46 | right: 40rpx; 47 | } 48 | 49 | .tab { 50 | display: flex; 51 | justify-content: space-around; 52 | height: 80rpx; 53 | border-bottom: solid 1rpx #ddd; 54 | } 55 | 56 | .tab .item { 57 | line-height: 80rpx; 58 | min-width: 140rpx; 59 | text-align: center; 60 | } 61 | 62 | .tab .cur { 63 | border-bottom: solid 5rpx #338ffc; 64 | color: #338ffc; 65 | } 66 | 67 | .swiper-content { 68 | background: #fff; 69 | } 70 | 71 | .swiper-content .mes .inner { 72 | padding: 40rpx 40rpx; 73 | font-size: 28rpx; 74 | } 75 | 76 | .swiper-content .mes .inner .label { 77 | font-weight: bold; 78 | margin: 10rpx 0; 79 | color: #555; 80 | } 81 | 82 | .swiper-content .mes .lib-info { 83 | color: #777; 84 | } 85 | 86 | .swiper-content .mes .num, .swiper-content .mes .lib { 87 | display: flex; 88 | padding: 10rpx 0; 89 | } 90 | 91 | .swiper-content .mes .lib .lib-item { 92 | width: 22rpx; 93 | height: 22rpx; 94 | background: #ccc; 95 | margin: auto 0 auto 20rpx; 96 | border-radius: 50%; 97 | } 98 | 99 | .swiper-content .mes .lib .available { 100 | background: #fdcc40; 101 | } 102 | 103 | .swiper-content .mes .intro { 104 | color: #777; 105 | } 106 | .doing{ 107 | color: #b2b2b2; 108 | text-align: center; 109 | line-height: 100rpx; 110 | font-size: 26rpx; 111 | } 112 | -------------------------------------------------------------------------------- /pages/result/result.wxss: -------------------------------------------------------------------------------- 1 | .search-content{ 2 | width: 100%; 3 | background: #338FFC; 4 | } 5 | .form-in{ 6 | display: flex; 7 | flex-direction: row; 8 | padding: 20rpx; 9 | } 10 | .m-search{ 11 | position: relative; 12 | } 13 | .icon-search{ 14 | position: absolute; 15 | top: 18rpx; 16 | left: 20rpx; 17 | 18 | } 19 | .icon-cancel{ 20 | position: absolute; 21 | top: 0rpx; 22 | right: 0rpx; 23 | 24 | padding: 15rpx 20rpx 15rpx 10rpx; 25 | } 26 | .search-inp{ 27 | background: #fff; 28 | width: 475rpx; 29 | padding: 10rpx 70rpx; 30 | border-radius:15rpx; 31 | height: 45rpx; 32 | line-height: 45rpx; 33 | min-height: 45rpx; 34 | } 35 | .input-placeholder{ 36 | color: #b2b2b2; 37 | } 38 | .search-btn{ 39 | border: 0; 40 | color: #fff; 41 | background: none; 42 | border-radius: 0 15rpx 15rpx 0; 43 | padding: 10rpx 10rpx 10rpx 25rpx; 44 | line-height: 45rpx; 45 | text-align: center; 46 | font-size: 30rpx; 47 | } 48 | .search-btn::after{ 49 | content: none; 50 | } 51 | 52 | .scroll-content{ 53 | background: #f9fbfe; 54 | } 55 | .list-content{ 56 | padding: 0 20rpx; 57 | } 58 | .bookitem{ 59 | background: #fff; 60 | border-radius: 20rpx; 61 | margin: 20rpx 0; 62 | padding: 20rpx 40rpx; 63 | color: #555; 64 | box-shadow: 0 0 20rpx #eee; 65 | } 66 | .bookitem .name{ 67 | font-size: 34rpx; 68 | padding-bottom: 10rpx; 69 | } 70 | .bookitem .author{ 71 | font-size: 28rpx; 72 | padding-bottom: 10rpx; 73 | } 74 | .bookitem .other-infos{ 75 | display: flex; 76 | flex-direction: row; 77 | font-size: 22rpx; 78 | color: #b2b2b2; 79 | } 80 | .bookitem .other-infos .info-item{ 81 | margin-right: 20rpx; 82 | 83 | } 84 | .bookitem .other-infos .overflow{ 85 | max-width: 300rpx; 86 | overflow: hidden; 87 | text-overflow: ellipsis; 88 | display: -webkit-box; 89 | -webkit-line-clamp: 1; 90 | -webkit-box-orient: vertical; 91 | } 92 | 93 | 94 | /*上拉加载*/ 95 | .load-tip{ 96 | display: flex; 97 | justify-content: center; 98 | align-content: center; 99 | font-size: 28rpx; 100 | color: #b2b2b2; 101 | padding-bottom: 20rpx; 102 | line-height: 45rpx; 103 | } 104 | .icon-load{ 105 | width: 45rpx; 106 | height: 45rpx; 107 | /*animation: spin 2s linear infinite;*/ 108 | } 109 | /*@-webkit-keyframes spin{ 110 | 0% { 111 | transform: rotate(0deg); 112 | } 113 | 100% { 114 | transform: rotate(360deg); 115 | } 116 | }*/ 117 | 118 | .search-fail{ 119 | display: flex; 120 | flex-direction: column; 121 | } 122 | .search-fail .fail-img{ 123 | width: 250rpx; 124 | height: 250rpx; 125 | margin: 200rpx auto 50rpx auto; 126 | } 127 | .search-fail .fail-txt{ 128 | font-size: 28rpx; 129 | color: #BCC1CC; 130 | text-align: center; 131 | } 132 | -------------------------------------------------------------------------------- /pages/index/index.js: -------------------------------------------------------------------------------- 1 | //index.js 2 | var hotapp = require('../../utils/hotapp.js'); 3 | //获取应用实例 4 | var app = getApp(); 5 | Page({ 6 | data: { 7 | cancel: false, 8 | inputValue: null, 9 | focus: false 10 | }, 11 | 12 | formSubmit: function (e) { 13 | var that = this; 14 | var keyword = null; 15 | if (e.detail.value.book) { 16 | keyword = e.detail.value.book; 17 | that.search(keyword); 18 | } else { 19 | wx.showToast({ 20 | title: '您没有输入哦', 21 | icon: 'success', 22 | duration: 10000 23 | }) 24 | setTimeout(function () { 25 | wx.hideToast() 26 | }, 1000) 27 | return false; 28 | } 29 | }, 30 | 31 | enterSubmit: function (e) { 32 | var that = this; 33 | var keyword = null; 34 | if (e.detail.value) { 35 | keyword = e.detail.value; 36 | that.search(keyword); 37 | } else { 38 | wx.showToast({ 39 | title: '您没有输入哦', 40 | icon: 'success', 41 | duration: 10000 42 | }) 43 | setTimeout(function () { 44 | wx.hideToast() 45 | }, 1000) 46 | return false; 47 | } 48 | }, 49 | 50 | search: function (keyword) { 51 | wx.showToast({ 52 | title: '搜索中', 53 | icon: 'loading', 54 | duration: 10000 55 | }) 56 | 57 | hotapp.request({ 58 | url: 'http://api.diviniti.cn/jmu/library/search/' + keyword + '/page/1/count/20', 59 | success: function (res) { 60 | wx.hideToast() 61 | app.globalData.searchResult = res.data; 62 | 63 | wx.navigateTo({ 64 | url: '../result/result?keyword=' + keyword 65 | }) 66 | }, 67 | fail: function () { 68 | wx.showToast({ 69 | title: '连接失败', 70 | icon: 'success', 71 | duration: 5000 72 | }) 73 | setTimeout(function () { 74 | wx.hideToast() 75 | }, 2000) 76 | }, 77 | complete: function () { 78 | 79 | } 80 | }) 81 | }, 82 | 83 | //input清除按钮显示 84 | typeIng: function (e) { 85 | var that = this; 86 | if (e.detail.value) { 87 | that.setData({ 88 | cancel: true 89 | }) 90 | } else { 91 | that.setData({ 92 | cancel: false 93 | }) 94 | } 95 | }, 96 | //清除输入框 97 | clearInput: function () { 98 | console.log(1) 99 | this.setData({ 100 | inputValue: null, 101 | cancel: false, 102 | focus: true 103 | }) 104 | }, 105 | onShareAppMessage: function () { 106 | return { 107 | title: '图书盒子', 108 | path: '/pages/index/index' 109 | } 110 | } 111 | 112 | 113 | }) 114 | -------------------------------------------------------------------------------- /pages/login/login.js: -------------------------------------------------------------------------------- 1 | var app = getApp(); 2 | var AV = require('../../utils/av-weapp-min.js'); 3 | var hotapp = require('../../utils/hotapp.js'); 4 | 5 | Page({ 6 | data: { 7 | load: false 8 | }, 9 | onLoad: function (options) { 10 | 11 | }, 12 | formSubmit: function (e) { 13 | 14 | var that = this; 15 | 16 | //todo 表单验证 17 | var user = e.detail.value.user; 18 | var pwd = e.detail.value.password; 19 | 20 | if (!user || !pwd) { 21 | wx.showModal({ 22 | title: '提示', 23 | content: '学号及密码不能为空哦!', 24 | showCancel: false, 25 | confirmColor: '#338FFC', 26 | success: function (res) { 27 | if (res.confirm) { 28 | console.log('用户点击确定') 29 | } 30 | } 31 | }) 32 | return false; 33 | } 34 | 35 | //更改绑定按钮loading状态 36 | that.setData({ 37 | load: true 38 | }) 39 | 40 | hotapp.request({ 41 | url: 'http://api.diviniti.cn/jmu/library/login', 42 | data: { 43 | user: user, 44 | pwd: pwd 45 | }, 46 | success: function (res) { 47 | var cookie = res.data.cookie; 48 | var studentUser = { 49 | cookie: cookie, 50 | user: user, 51 | pwd: pwd 52 | } 53 | //成功后储存cookie 54 | if (res.data.status == "success") { 55 | 56 | wx.setStorage({ 57 | key: "tshz_isbind", 58 | data: true 59 | }) 60 | wx.setStorage({ 61 | key: "tshz_cookie", 62 | data: cookie 63 | }) 64 | hotapp.request({ 65 | url: 'http://api.diviniti.cn/jmu/library/user/info', 66 | data: { cookie: cookie }, 67 | method: 'GET', 68 | success: function (res) { 69 | // success 70 | studentUser.infoes = res.data.infoes; 71 | const currentUser = AV.User.current(); 72 | currentUser.set(studentUser).save(); 73 | 74 | wx.setStorage({ 75 | key: 'tshz_studentInfoes', 76 | data: res.data, 77 | success: function () { 78 | wx.navigateBack({ 79 | delta: 1 80 | }) 81 | } 82 | }) 83 | }, 84 | complete: function () { 85 | 86 | } 87 | }) 88 | 89 | } else { 90 | wx.showToast({ 91 | title: '用户名或密码输入有误', 92 | icon: 'success', 93 | duration: 2000 94 | }) 95 | } 96 | }, 97 | fail: function () { 98 | wx.showToast({ 99 | title: '网络异常', 100 | icon: 'success', 101 | duration: 2000 102 | }) 103 | }, 104 | complete: function () { 105 | that.setData({ 106 | load: false 107 | }) 108 | } 109 | }) 110 | 111 | 112 | 113 | }, 114 | onShareAppMessage: function () { 115 | return { 116 | title: '图书盒子', 117 | path: '/pages/index/index' 118 | } 119 | } 120 | }); -------------------------------------------------------------------------------- /pages/user/user.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | {{studentInfoes.infoes.userName}} 11 | {{studentInfoes.infoes.userRemarks}} 12 | 13 | 14 | 15 | 16 | 17 | 18 | 22 | 26 | 27 | 28 | 32 | 36 | 37 | 38 | 39 | 40 | 41 | 绑定图书馆账号后查看借阅情况 42 | 前往绑定 43 | 44 | 45 | 46 | 47 | 48 | 49 | 您目前没有借书哦~ 50 | 51 | 52 | 53 | 54 | 55 | {{item.name}} 56 | 作者: {{item.author}} 57 | 58 | 借书时间:{{item.borrowedDate.rawValue}} 59 | 应还时间:{{item.expireDate.rawValue}} 60 | 可续借 61 | 不可续借 62 | 63 | 超期{{-item.tip}}天 64 | 剩余{{item.tip}}天 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 很棒,继续保持良好的借书习惯~ 74 | 75 | 76 | 77 | 78 | 79 | {{item.name}} 80 | 作者: {{item.author}} 81 | 82 | 还书地点:{{item.location}} 83 | 应还时间:{{item.expiredDate.rawValue}} 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /pages/user/user.wxss: -------------------------------------------------------------------------------- 1 | page{ 2 | background: #f9fbfe; 3 | } 4 | .header { 5 | background: #338ffc; 6 | display: flex; 7 | height: 200rpx; 8 | padding: 20rpx; 9 | } 10 | 11 | .header .avatar-cot { 12 | width: 120rpx; 13 | height: 120rpx; 14 | border-radius: 50%; 15 | box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.3); 16 | margin: 30rpx 30rpx 0 30rpx; 17 | } 18 | .header .unlogin-avatar{ 19 | margin: 30rpx auto; 20 | } 21 | 22 | .header .avatar { 23 | width: 120rpx; 24 | height: 120rpx; 25 | border-radius: 50%; 26 | } 27 | 28 | .header .user-infos { 29 | margin-top: 30rpx; 30 | color: #fff; 31 | font-size: 36rpx; 32 | width: 350rpx; 33 | } 34 | 35 | .header .user-infos .username{ 36 | padding-top: 10rpx; 37 | } 38 | .header .user-infos .remark{ 39 | font-size: 22rpx; 40 | padding-top: 8rpx; 41 | } 42 | .header .logout-btn { 43 | border: 1rpx solid #fff; 44 | color: #fff; 45 | width: 96rpx; 46 | height: 50rpx; 47 | padding: 0 20rpx; 48 | line-height: 50rpx; 49 | margin: 60rpx 0 0 60rpx; 50 | } 51 | .tab { 52 | display: flex; 53 | justify-content: space-around; 54 | height: 105rpx; 55 | border-bottom: solid 1rpx #ddd; 56 | background: #fff; 57 | } 58 | 59 | .tab .item { 60 | /*line-height: 80rpx;*/ 61 | min-width: 140rpx; 62 | text-align: center; 63 | border: none; 64 | border-radius:0; 65 | } 66 | .tab .item .num{ 67 | font-size: 50rpx; 68 | color: #338ffc; 69 | padding-top: 10rpx; 70 | line-height: 50rpx; 71 | font-weight:bolder; 72 | } 73 | .tab .item .danger{ 74 | color: #F7BA2A; 75 | } 76 | .tab .item .label{ 77 | font-size: 26rpx; 78 | color: #b2b2b2; 79 | line-height: 40rpx; 80 | padding-bottom:5rpx; 81 | } 82 | 83 | .tab .cur { 84 | border-bottom: solid 6rpx #338ffc; 85 | } 86 | 87 | .list-content{ 88 | padding: 0 20rpx; 89 | } 90 | .swiper-content{ 91 | background: #f9fbfe; 92 | } 93 | .bookitem{ 94 | position: relative; 95 | background: #fff; 96 | border-radius: 20rpx; 97 | margin: 20rpx 0; 98 | padding: 20rpx 40rpx; 99 | color: #555; 100 | box-shadow: 0 0 20rpx #eee; 101 | } 102 | .bookitem .name{ 103 | font-size: 34rpx; 104 | padding-bottom: 10rpx; 105 | } 106 | .bookitem .author{ 107 | font-size: 22rpx; 108 | color: #b2b2b2; 109 | padding-bottom: 10rpx; 110 | } 111 | .bookitem .other-infos{ 112 | display: flex; 113 | flex-direction: row; 114 | font-size: 22rpx; 115 | color: #b2b2b2; 116 | } 117 | .bookitem .other-infos .info-item{ 118 | margin-right: 20rpx; 119 | 120 | } 121 | .bookitem .other-infos .overflow{ 122 | max-width: 300rpx; 123 | overflow: hidden; 124 | text-overflow: ellipsis; 125 | display: -webkit-box; 126 | -webkit-line-clamp: 1; 127 | -webkit-box-orient: vertical; 128 | } 129 | .bookitem .tip{ 130 | position: absolute; 131 | background: #338ffc; 132 | width: 110rpx; 133 | height: 40rpx; 134 | line-height: 40rpx; 135 | text-align: center; 136 | font-size: 22rpx; 137 | color: #fff; 138 | top: 20rpx; 139 | right: 0; 140 | border-radius: 8rpx 0 0 8rpx; 141 | } 142 | 143 | .bookitem .tip.danger{ 144 | background: #FF4949; 145 | } 146 | 147 | .unlogin{ 148 | display: flex; 149 | flex-direction: column; 150 | justify-content: center; 151 | } 152 | 153 | .unlogin .img{ 154 | width: 120rpx; 155 | height: 120rpx; 156 | margin: 140rpx auto 0 auto; 157 | } 158 | .unlogin .tip{ 159 | font-size: 28rpx; 160 | text-align: center; 161 | margin-top: 20rpx; 162 | color: #555; 163 | } 164 | .unlogin .btn{ 165 | background: #13CE66; 166 | display: block; 167 | padding: 0 30rpx; 168 | height: 60rpx; 169 | width: 130rpx; 170 | margin: 20rpx auto; 171 | text-align: center; 172 | line-height: 60rpx; 173 | border-radius:10rpx; 174 | color: #fff; 175 | font-size: 26rpx; 176 | } 177 | 178 | .null-tip{ 179 | display: flex; 180 | flex-direction: column; 181 | justify-content: center; 182 | } 183 | .null-tip .img{ 184 | width: 150rpx; 185 | height: 150rpx; 186 | margin: 150rpx auto 30rpx auto; 187 | } 188 | .null-tip .txt{ 189 | font-size: 26rpx; 190 | color: #bcc1cc; 191 | text-align: center; 192 | } 193 | 194 | -------------------------------------------------------------------------------- /pages/result/result.js: -------------------------------------------------------------------------------- 1 | var hotapp = require('../../utils/hotapp.js'); 2 | var app = getApp(); 3 | // 注册当页全局变量,存放搜索结果以便更新到data中 4 | var curBooksList = []; 5 | Page({ 6 | data: { 7 | booksList: [], 8 | keyword: null, 9 | pageCurrent: null, 10 | pagesTotal: null, 11 | scrollHeight: null,//滚动区域高度 12 | cancel: true, //是否显示输入框清除按钮 13 | dropLoadFunc: "dropLoad" 14 | // animationData: {} 15 | }, 16 | 17 | // 页面初始化 18 | onLoad: function (param) { 19 | var that = this; 20 | wx.getSystemInfo({ 21 | success: function (res) { 22 | that.setData({ 23 | scrollHeight: res.windowHeight - (104 * res.windowWidth / 750),//窗口高度(px)-搜索模块高度(px) 24 | }) 25 | } 26 | }) 27 | that.setData({ 28 | keyword: param.keyword, 29 | }) 30 | var result = app.globalData.searchResult 31 | curBooksList = result.booksList 32 | // 有搜索结果 33 | if (result.status == "success") { 34 | // 更新数据 35 | that.setData({ 36 | status: "success", 37 | booksList: result.booksList, 38 | pageCurrent: result.pageCurrent, 39 | pagesTotal: result.pagesTotal 40 | }) 41 | } else { 42 | // 无搜索结果 43 | that.setData({ 44 | status: "fail", 45 | }) 46 | } 47 | 48 | }, 49 | //搜索按钮事件 50 | formSubmit: function (e) { 51 | var that = this; 52 | var keyword = null; 53 | if (e.detail.value.book) { 54 | keyword = e.detail.value.book; 55 | that.search(keyword); 56 | } else { 57 | wx.showToast({ 58 | title: '您没有输入哦', 59 | icon: 'success', 60 | duration: 10000 61 | }) 62 | setTimeout(function () { 63 | wx.hideToast() 64 | }, 1000) 65 | return false; 66 | } 67 | }, 68 | //回车事件 69 | enterSubmit: function (e) { 70 | var that = this; 71 | var keyword = null; 72 | if (e.detail.value) { 73 | keyword = e.detail.value; 74 | that.search(keyword); 75 | } else { 76 | wx.showToast({ 77 | title: '您没有输入哦', 78 | icon: 'success', 79 | duration: 10000 80 | }) 81 | setTimeout(function () { 82 | wx.hideToast() 83 | }, 1000) 84 | return false; 85 | } 86 | }, 87 | 88 | // 搜索 89 | search: function (keyword) { 90 | var that = this; 91 | //清空上次搜索的结果 92 | curBooksList = []; 93 | 94 | that.setData({ 95 | keyword: keyword, 96 | }) 97 | 98 | wx.showToast({ 99 | title: '加载中', 100 | icon: 'loading', 101 | duration: 10000 102 | }) 103 | 104 | hotapp.request({ 105 | url: 'http://api.diviniti.cn/jmu/library/search/' + keyword + '/page/1/count/20', 106 | success: function (res) { 107 | // 请求成功隐藏加载中的提示 108 | wx.hideToast() 109 | 110 | if (res.data.status == "success") { 111 | curBooksList = res.data.booksList; 112 | 113 | that.setData({ 114 | status: "success", 115 | booksList: res.data.booksList, 116 | pageCurrent: res.data.pageCurrent, 117 | pagesTotal: res.data.pagesTotal, 118 | scrollTop: "0" 119 | }) 120 | } else { 121 | // 无搜索结果 122 | that.setData({ 123 | status: "fail", 124 | }) 125 | } 126 | }, 127 | complete:function(){ 128 | 129 | } 130 | }) 131 | }, 132 | 133 | // 上拉加载 134 | dropLoad: function () { 135 | 136 | var that = this; 137 | if (this.data.pageCurrent < this.data.pagesTotal) { 138 | //锁定上拉加载 139 | that.setData({ 140 | dropLoadFunc: null 141 | }) 142 | that.loadMore(); 143 | 144 | } 145 | }, 146 | 147 | //加载更多 148 | loadMore: function () { 149 | 150 | var that = this; 151 | var page = parseInt(that.data.pageCurrent) + 1; 152 | 153 | hotapp.request({ 154 | url: 'http://api.diviniti.cn/jmu/library/search/' + that.data.keyword + '/page/' + page + '/count/20', 155 | success: function (res) { 156 | 157 | if (res.data.status == "success") { 158 | // 更新数据 159 | curBooksList = curBooksList.concat(res.data.booksList) 160 | that.setData({ 161 | booksList: curBooksList, 162 | pageCurrent: res.data.pageCurrent 163 | }) 164 | } else { 165 | // 无搜索结果 166 | console.log("没有结果") 167 | } 168 | }, 169 | complete:function(){ 170 | //启动上拉加载 171 | that.setData({ 172 | dropLoadFunc: "dropLoad" 173 | }) 174 | } 175 | }) 176 | }, 177 | //input清除按钮显示 178 | typeIng: function (e) { 179 | var that = this; 180 | if (e.detail.value) { 181 | that.setData({ 182 | cancel: true 183 | }) 184 | } else { 185 | that.setData({ 186 | cancel: false 187 | }) 188 | } 189 | }, 190 | //清除输入框 191 | clearInput: function () { 192 | this.setData({ 193 | keyword: null, 194 | cancel: false, 195 | focus: true 196 | }) 197 | }, 198 | // 分享搜索结果 199 | onShareAppMessage: function () { 200 | return { 201 | title: '图书盒子', 202 | path: '/pages/index/index' 203 | } 204 | } 205 | }) -------------------------------------------------------------------------------- /pages/detail/detail.js: -------------------------------------------------------------------------------- 1 | var hotapp = require('../../utils/hotapp.js'); 2 | var AV = require('../../utils/av-weapp-min.js'); 3 | var Collection = AV.Object.extend('Collection'); 4 | 5 | 6 | var app = getApp(); 7 | Page({ 8 | data: { 9 | current: 0,//swiper组件当前所在页面的 index 10 | image: "../../images/bookmodle.png"//默认封面 11 | // bookid: null, 12 | // name: null, 13 | // publishe: null, 14 | // total: null, 15 | // available: null, 16 | // author: null, 17 | // intro: null, 18 | // ISBN: null, 19 | // infoes: [] 20 | 21 | }, 22 | // 页面初始化 23 | onLoad: function (param) { 24 | this.setData({ 25 | bookid: param.bookid, 26 | publisher: param.publisher, 27 | total: param.total, 28 | available: param.available 29 | }) 30 | var that = this; 31 | 32 | //获取收藏状态 33 | that.isCollect(param.bookid) 34 | 35 | //获取图书信息 36 | hotapp.request({ 37 | useProxy: true, 38 | url: 'http://api.diviniti.cn/jmu/library/book/' + that.data.bookid, 39 | success: function (res) { 40 | if (res.data.status == "success") { 41 | that.setData({ 42 | name: res.data.name, 43 | author: res.data.author, 44 | intro: res.data.intro, 45 | ISBN: res.data.ISBN, 46 | infoes: res.data.infoes 47 | }) 48 | hotapp.request({ 49 | url: 'https://api.douban.com/v2/book/isbn/' + res.data.ISBN, 50 | success: function (res) { 51 | var bookDefault = "https://img3.doubanio.com/f/shire/5522dd1f5b742d1e1394a17f44d590646b63871d/pics/book-default-large.gif"; 52 | var bookImg = res.data.images.large; 53 | if (bookImg != bookDefault) { 54 | that.setData({ 55 | image: res.data.images.large 56 | }) 57 | } 58 | }, 59 | complete: function () { 60 | 61 | } 62 | }) 63 | } else { 64 | //TODO 无搜索结果 65 | console.log("没有结果") 66 | } 67 | }, 68 | complete: function () { 69 | 70 | } 71 | }) 72 | wx.getSystemInfo({ 73 | success: function (res) { 74 | that.setData({ 75 | swiperHeight: res.windowHeight - (422 * res.windowWidth / 750),//窗口高度(px)-搜索模块高度(px) 76 | }) 77 | } 78 | }) 79 | }, 80 | 81 | //获取是否收藏 82 | isCollect: function (bookid) { 83 | return AV.Promise.resolve(AV.User.current()).then(user => 84 | user ? (user.isAuthenticated().then(authed => authed ? user : null)) : null 85 | ).then(user => 86 | user ? user : AV.User.loginWithWeapp() 87 | ).then((user) => { 88 | console.log('uid', user.id); 89 | return new AV.Query('Collection') 90 | .equalTo('owner', AV.Object.createWithoutData('User', user.id)) 91 | .equalTo('bookid', bookid) 92 | .descending('createdAt') 93 | .find() 94 | .then(this.setIsCollect) 95 | }).catch(error => console.error(error.message)); 96 | }, 97 | 98 | //储存收藏状态 99 | setIsCollect: function (res) { 100 | var that = this; 101 | if (res.length) { 102 | that.setData({ 103 | isCollect: true 104 | }) 105 | } else { 106 | that.setData({ 107 | isCollect: false 108 | }) 109 | 110 | } 111 | }, 112 | 113 | //swiper滑动切换是触发的函数 114 | swiperChange: function (e) { 115 | this.setData({ 116 | current: e.detail.current 117 | }) 118 | 119 | }, 120 | //tab点击切换 121 | changeSwiperPage: function (e) { 122 | this.setData({ 123 | current: e.target.dataset.current 124 | }) 125 | }, 126 | 127 | //收藏事件 128 | collectBook: function () { 129 | var that = this; 130 | 131 | var currentUser = AV.User.current(); 132 | var collection = new Collection(); 133 | 134 | var item = { 135 | 'bookid': that.data.bookid, 136 | 'name': that.data.name, 137 | 'author': that.data.author, 138 | 'location': that.data.infoes[0].location, 139 | 'callNumber': that.data.infoes[0].callNumber, 140 | 'publisher': that.data.publisher, 141 | 'total': that.data.total, 142 | 'available': that.data.available, 143 | 'image': that.data.image, 144 | 'owner': currentUser 145 | 146 | } 147 | collection.set(item).save().then(function () { 148 | // 收藏成功 149 | that.setData({ 150 | isCollect: true 151 | }) 152 | 153 | wx.showToast({ 154 | title: '收藏成功', 155 | icon: 'success', 156 | duration: 1000 157 | }) 158 | }, function (error) { 159 | // 160 | }); 161 | }, 162 | //取消收藏 163 | cancelCollect: function () { 164 | var that = this; 165 | var currentUser = AV.User.current(); 166 | return new AV.Query('Collection') 167 | .equalTo('bookid', this.data.bookid) 168 | .equalTo('owner', AV.Object.createWithoutData('User', currentUser.id)) 169 | .find() 170 | .then(function (todos) { 171 | return AV.Object.destroyAll(todos); 172 | }).then(function (todos) { 173 | // 取消成功 174 | that.setData({ 175 | isCollect: false 176 | }) 177 | 178 | wx.showToast({ 179 | title: '取消收藏', 180 | icon: 'success', 181 | duration: 1000 182 | }) 183 | }, function (error) { 184 | // 异常处理 185 | }); 186 | 187 | }, 188 | onShareAppMessage: function () { 189 | return { 190 | title: this.data.name, 191 | path: '/pages/detail/detail?bookid='+this.data.bookid+'&publisher='+this.data.publisher+'&total='+this.data.total+'&available='+this.data.available 192 | } 193 | } 194 | 195 | 196 | }) -------------------------------------------------------------------------------- /pages/user/user.js: -------------------------------------------------------------------------------- 1 | var app = getApp(); 2 | var AV = require('../../utils/av-weapp-min.js'); 3 | var hotapp = require('../../utils/hotapp.js'); 4 | Page({ 5 | data: { 6 | avatarUrl: "../../images/avatar-default.png", 7 | isbind: false, 8 | booksTotal: "-", 9 | warnTotal: "-", 10 | current: 0 11 | }, 12 | 13 | //除次加载 14 | onLoad: function () { 15 | var that = this; 16 | const user = AV.User.current(); 17 | if (user) { 18 | // 已经登录 19 | } 20 | else { 21 | //currentUser 为空时,微信一键登录… 22 | AV.User.loginWithWeapp().then(user => { 23 | wx.getUserInfo({ 24 | success: ({userInfo}) => { 25 | // 更新当前用户的信息 26 | //头像存储到本地 27 | wx.setStorage({ 28 | key: "tshz_avatarUrl", 29 | data: userInfo.avatarUrl 30 | }); 31 | that.setData({ 32 | avatarUrl: userInfo.avatarUrl 33 | }) 34 | user.set(userInfo).save().then(user => { 35 | // 成功,此时可在控制台中看到更新后的用户信息 36 | app.globalData.user = user.toJSON(); 37 | }).catch(console.error); 38 | }, 39 | fail:()=>{ 40 | wx.setStorage({ 41 | key: "tshz_avatarUrl", 42 | data: "../../images/avatar-default.png" 43 | }) 44 | } 45 | }) 46 | }).catch(console.error); 47 | } 48 | }, 49 | 50 | //每一次界面显示 51 | onShow: function () { 52 | var that = this; 53 | that.setData({ 54 | avatarUrl: wx.getStorageSync('tshz_avatarUrl'), 55 | studentInfoes: wx.getStorageSync('tshz_studentInfoes') 56 | }) 57 | wx.getStorage({ 58 | key: "tshz_isbind", 59 | success: function (res) { 60 | that.setData({ 61 | isbind: res.data 62 | }) 63 | if (res.data) { 64 | var cookie = wx.getStorageSync('tshz_cookie') 65 | that.getBorrowData(cookie) 66 | that.getExpiredData(cookie) 67 | } 68 | } 69 | }) 70 | }, 71 | 72 | //获取借书信息 73 | getBorrowData: function (cookie) { 74 | var that = this; 75 | hotapp.request({ 76 | url: 'http://api.diviniti.cn/jmu/library/borrowed', 77 | data: { cookie: cookie }, 78 | method: 'GET', 79 | success: function (res) { 80 | // success 81 | if (res.data.status == "success") { 82 | 83 | var booksTotal=res.data.booksTotal; 84 | var booksList= res.data.booksList; 85 | 86 | for(var i=0;ir)return d("maxRequest ",r,"times achieved"),void o.call(this,e);var u=i[0],s=i[1],c=["getStorageSync:fail"];if(l.inArray(s.msg,c))return o.call(this,e);try{y.http(u,s,function(e,t){v.isObject(e)?d("send err log ok, err data: ",e,t):!1===e&&(d("err occurred",t),++a)})}catch(e){d("onError",e)}}return o.call(this,e)}return n.call(this,e,t),o.call(this,e)}}}var l=function(){function e(e,t){return!!p.isArray(t)&&t.indexOf(e)!==-1}function t(e,t){return t=t||{},p.shouldBe("object",e),p.shouldBe("object",t),i(t,function(t,n){e[t]=n}),e}function n(e){return p.isObject(e)?0===Object.getOwnPropertyNames(e).length:p.isArray(e)?0===e.length:!e}var o=Object.prototype.toString,r=Object.prototype.hasOwnProperty,a=Array.prototype.slice,p=function(){function t(t,o){var r=["function","object","array","string","number","boolean"];if(!e(t,r))throw Error("unknown type: "+t);var p=a.call(arguments),i="is"+t[0].toUpperCase()+t.substring(1);if(n[i]){if(!n[i].call(null,o))throw Error("argument#"+p.indexOf(o)+" should be "+t+", "+typeof o+" given");return!0}throw Error("Unregistered function: "+i)}var n={isFunction:function(e){return"[object Function]"===o.call(e)},isObject:function(e){return"[object Object]"===o.call(e)},isArray:function(e){return"[object Array]"===o.call(e)},isString:function(e){return"[object String]"===o.call(e)},isNumber:function(e){return"[object Number]"===o.call(e)},isBoolean:function(e){return"[object Boolean]"===o.call(e)}};return n.shouldBe=t,n}(),i=function(e,t){if(p.isObject(e))for(var n in e)r.call(e,n)&&t.call(null,n,e[n]);else if(p.isArray(e))for(var o=0,a=e.length;o0){d("app ttl, ",e);var t=o+"/data/wechat/time",r={time:e,hotAppKey:g.getHotAppKey(),hotAppUUID:g.getHotAppUUID(),openId:g.getOpenID()};d("send app ttl request ",r),y.http(t,r)}}),h(t,"onError",function(t){return e(t,g.get("appVer")||"0.1.0")}),m(t)};var w=Page;Page=function(e){h(e,"onReady",function(){}),h(e,"onLoad",function(){var e=arguments[0];c(this,e)}),h(e,"onUnload",function(){}),h(e,"onShow",function(){d("page show")}),h(e,"onHide",function(){d("page hide")}),"onShareAppMessage"in e&&h(e,"onShareAppMessage",function(e){var t=this.__route__;return d("page onShareAppMessage: "+t),e=e||{title:"ZM-title",desc:"ZM-desc",path:"/"===t[0]?t:"/"+t},f(this,e)}),w(e)},module.exports={init:r,onEvent:p,onError:e,onLoad:c,onShare:f,setEventUploadType:g.setEventUploadType,clearData:g.clearData,wxlogin:n,getFakeOpenID:g.getFakeOpenID,getOpenID:g.getOpenID,getPrefix:g.getPrefix,genPrimaryKey:g.genPrimaryKey,replaceOpenIdKey:g.replaceOpenIdKey,searchkey:i,get:y.get,post:y.post,del:y.del,request:y.request,getVersion:g.getVersion,setDebug:g.setDebug,feedback:u,uploadFeedbackImage:s,log:d}}(); -------------------------------------------------------------------------------- /utils/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 --------------------------------------------------------------------------------