diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..26d6131 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +/vendor +/node_modules diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..141fa11 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,99 @@ +module.exports = { + 'extends': [ + 'airbnb-base', + 'plugin:promise/recommended' + ], + 'parserOptions': { + 'ecmaVersion': 9, + 'ecmaFeatures': { + 'jsx': false + }, + 'sourceType': 'module' + }, + 'env': { + 'es6': true, + 'node': true, + 'jest': true + }, + 'plugins': [ + 'import', + 'node', + 'promise' + ], + 'rules': { + 'arrow-parens': 'off', + 'comma-dangle': [ + 'error', + 'only-multiline' + ], + 'complexity': ['error', 10], + 'func-names': 'off', + 'global-require': 'off', + 'handle-callback-err': [ + 'error', + '^(err|error)$' + ], + 'import/no-unresolved': [ + 'error', + { + 'caseSensitive': true, + 'commonjs': true, + 'ignore': ['^[^.]'] + } + ], + 'import/prefer-default-export': 'off', + 'linebreak-style': 'off', + 'no-catch-shadow': 'error', + 'no-continue': 'off', + 'no-div-regex': 'warn', + 'no-else-return': 'off', + 'no-param-reassign': 'off', + 'no-plusplus': 'off', + 'no-shadow': 'off', + // enable console for this project + 'no-console': 'off', + 'no-multi-assign': 'off', + 'no-underscore-dangle': 'off', + 'node/no-deprecated-api': 'error', + 'node/process-exit-as-throw': 'error', + 'object-curly-spacing': [ + 'error', + 'never' + ], + 'operator-linebreak': [ + 'error', + 'after', + { + 'overrides': { + ':': 'before', + '?': 'before' + } + } + ], + 'prefer-arrow-callback': 'off', + 'prefer-destructuring': 'off', + 'prefer-template': 'off', + 'quote-props': [ + 1, + 'as-needed', + { + 'unnecessary': true + } + ], + 'semi': [ + 'error', + 'never' + ] + }, + 'globals': { + 'window': true, + 'document': true, + 'App': true, + 'Page': true, + 'Component': true, + 'Behavior': true, + 'wx': true, + 'worker': true, + 'getApp': true + } +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b52f9a9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +*swp +.idea +.DS_Store +package-lock.json + +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +node_modules diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e78bcd8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 wechat-miniprogram + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..468a3bf --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +# 微信小程序示例 +微信小程序示例源码,欢迎扫描以下小程序码体验。 + +> 提示:请使用微信开发者工具或微信客户端 6.7.2 及以上版本运行。 + + + +## 使用 + +使用[微信开发者工具](https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html)打开该示例代码,云开发环境搭建请参考[云开发示例说明](https://github.com/wechat-miniprogram/miniprogram-demo/blob/master/miniprogram/page/cloud/README.md)。 + +## 贡献 + +如果你有 bug 反馈或其他任何建议,欢迎提 issue 给我们。 + +如果你愿意一起来完善小程序示例,欢迎通过 PR 的方式贡献代码。为了保证代码风格的统一,在编写代码之前,请在项目根目录运行以下命令安装依赖: + +``` +npm install +``` +同时,确保你的代码可以通过 Lint 检查: +``` +npm run lint +``` + +## 截图 + +![截图](https://developers.weixin.qq.com/miniprogram/dev/image/demo.png) diff --git a/cloudfunctions/getServerDataDemo/index.js b/cloudfunctions/getServerDataDemo/index.js new file mode 100644 index 0000000..065c9cd --- /dev/null +++ b/cloudfunctions/getServerDataDemo/index.js @@ -0,0 +1,13 @@ +// 云函数入口文件 +const cloud = require('wx-server-sdk') + +// 云函数入口函数 +exports.main = async () => { + cloud.init({ + env: process.env.TCB_ENV, + }) + const db = cloud.database() + return db.collection('perm4').where({ + _openid: 'server' + }).limit(1).get() +} diff --git a/cloudfunctions/getServerDataDemo/package.json b/cloudfunctions/getServerDataDemo/package.json new file mode 100644 index 0000000..d282a69 --- /dev/null +++ b/cloudfunctions/getServerDataDemo/package.json @@ -0,0 +1,14 @@ +{ + "name": "getServerDataDemo", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "wx-server-sdk": "latest" + } +} \ No newline at end of file diff --git a/cloudfunctions/getTempFileURL/index.js b/cloudfunctions/getTempFileURL/index.js new file mode 100644 index 0000000..ba007f8 --- /dev/null +++ b/cloudfunctions/getTempFileURL/index.js @@ -0,0 +1,14 @@ +// 云函数入口文件 +const cloud = require('wx-server-sdk') + +// 云函数入口函数 +exports.main = async (event) => { + cloud.init({ + env: process.env.TCB_ENV, + }) + const fileList = event.fileIdList + const result = await cloud.getTempFileURL({ + fileList, + }) + return result.fileList +} diff --git a/cloudfunctions/getTempFileURL/package.json b/cloudfunctions/getTempFileURL/package.json new file mode 100644 index 0000000..873cd0a --- /dev/null +++ b/cloudfunctions/getTempFileURL/package.json @@ -0,0 +1,14 @@ +{ + "name": "getTempFileURL", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "wx-server-sdk": "latest" + } +} \ No newline at end of file diff --git a/cloudfunctions/openapi/config.json b/cloudfunctions/openapi/config.json new file mode 100644 index 0000000..da17794 --- /dev/null +++ b/cloudfunctions/openapi/config.json @@ -0,0 +1,13 @@ +{ + "permissions": { + "openapi": [ + "wxacode.getUnlimited", + "templateMessage.send", + "templateMessage.addTemplate", + "templateMessage.deleteTemplate", + "templateMessage.getTemplateList", + "templateMessage.getTemplateLibraryById", + "templateMessage.getTemplateLibraryList" + ] + } +} \ No newline at end of file diff --git a/cloudfunctions/openapi/index.js b/cloudfunctions/openapi/index.js new file mode 100644 index 0000000..136dda9 --- /dev/null +++ b/cloudfunctions/openapi/index.js @@ -0,0 +1,65 @@ +// 云函数入口文件 +const cloud = require('wx-server-sdk') + +cloud.init({env : "asr-v3kua"}) + +async function sendTemplateMessage(event) { + const {OPENID} = cloud.getWXContext() + + // 接下来将新增模板、发送模板消息、然后删除模板 + // 注意:新增模板然后再删除并不是建议的做法,此处只是为了演示,模板 ID 应在添加后保存起来后续使用 + const addResult = await cloud.openapi.templateMessage.addTemplate({ + id: 'AT0002', + keywordIdList: [3, 4, 5] + }) + + const templateId = addResult.result.templateId + + const sendResult = await cloud.openapi.templateMessage.send({ + touser: OPENID, + templateId, + formId: event.formId, + page: 'page/cloud/pages/scf-openapi/scf-openapi', + data: { + keyword1: { + value: '未名咖啡屋', + }, + keyword2: { + value: '2019 年 1 月 1 日', + }, + keyword3: { + value: '拿铁', + }, + } + }) + + await cloud.openapi.templateMessage.deleteTemplate({ + templateId, + }) + + return sendResult +} + +async function getWXACode() { + const {result} = await cloud.openapi.wxacode.getUnlimited({ + scene: 'x=1', + }) + + // 此处返回 Base64 图片仅作为演示用,在实际开发中, + // 应上传图片至云文件存储,然后在小程序中通过云文件 ID 使用 + return `data:${result.contentType};base64,${result.buffer.toString('base64')}` +} + +// 云函数入口函数 +// eslint-disable-next-line +exports.main = async (event) => { + switch (event.action) { + case 'sendTemplateMessage': { + return sendTemplateMessage(event) + } + case 'getWXACode': { + return getWXACode(event) + } + default: break + } +} diff --git a/cloudfunctions/openapi/package.json b/cloudfunctions/openapi/package.json new file mode 100644 index 0000000..0a39461 --- /dev/null +++ b/cloudfunctions/openapi/package.json @@ -0,0 +1,14 @@ +{ + "name": "openapi", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "wx-server-sdk": "latest" + } +} diff --git a/cloudfunctions/wxContext/index.js b/cloudfunctions/wxContext/index.js new file mode 100644 index 0000000..7d7a863 --- /dev/null +++ b/cloudfunctions/wxContext/index.js @@ -0,0 +1,15 @@ +// 云函数入口文件 +const cloud = require('wx-server-sdk') + +cloud.init({env: "asr-v3kua"}) + +// 云函数入口函数 +exports.main = async () => { + const wxContext = cloud.getWXContext() + + return { + openid: wxContext.OPENID, + appid: wxContext.APPID, + unionid: wxContext.UNIONID, + } +} diff --git a/cloudfunctions/wxContext/package.json b/cloudfunctions/wxContext/package.json new file mode 100644 index 0000000..dc469ea --- /dev/null +++ b/cloudfunctions/wxContext/package.json @@ -0,0 +1,14 @@ +{ + "name": "wxContext", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "wx-server-sdk": "latest" + } +} \ No newline at end of file diff --git a/git.codesdream.com.txt b/git.codesdream.com.txt new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram/app.js b/miniprogram/app.js new file mode 100644 index 0000000..c9ceea4 --- /dev/null +++ b/miniprogram/app.js @@ -0,0 +1,87 @@ +//app.js +var config = require('./config') +var auth = require('./utils/auth') + +App({ + globalData:{ + token : null, + openid : null, + clientCode : '965cda1983f569b03abfb80dc9af8dd8', + hh:"\n", + loading: true, + registerListens: [], + }, + onLaunch: function () { + this.login(); + }, + + // 认证访问 + authRequest: function(object){ + var that = this; + var authObj = auth.authCodeGenerator; + authObj.updateTimestamp(); + wx.request({ + url: object.url, + header:{ + 'openid': that.globalData.openid, + 'X-Requested-With': '', + 'timestamp': authObj.timestamp, + 'signed': authObj.signed(that.globalData.openid, that.globalData.token) + }, + + data: object.data, + + success: object.success, + + fail:object.fail, + }); + }, + + listenLoading:function(method){ + if(this.globalData.loading == false) method(); + else this.globalData.registerListens.push(method) + }, + + login: function(){ + let that = this; + // 尝试登录 + wx.login({ + complete: (res) => { + console.log(res); + wx.request({ + url: config.loginUrl, + method: "GET", + data: { + code : res.code + }, + success: function(res){ + // 设置SessionKey + that.globalData.token = res.data.token; + that.globalData.openid = res.data.openid; + console.log("success",that.globalData); + console.log("sdaa",res) + that.globalData.loading = false; + for (const f of that.globalData.registerListens){ + f(); + } + that.globalData.registerListens = [] + + /* + that.authRequest({ + url : "https://compute.bktus.com", + success: function (res) { + console.log(res) + }, + fail: function (res) { + console.log(res) + } + });*/ + }, + fail: function(res){ + console.log(res) + } + }) + } + }); + } +}) \ No newline at end of file diff --git a/miniprogram/app.json b/miniprogram/app.json new file mode 100644 index 0000000..477434c --- /dev/null +++ b/miniprogram/app.json @@ -0,0 +1,59 @@ +{ + "pages": [ + "pages/index/index", + "pages/init/init", + "pages/databaseTest/databaseTest", + "pages/information/information", + "pages/information/about/about", + "pages/information/submit/submit", + "pages/list/list", + "pages/information/setting/setting", + "pages/information/graph/graph", + "pages/alloc/alloc", + "pages/information/help/help" + ], + "useExtendedLib": { + "kbone": true, + "weui": true + }, + "window": { + "backgroundColor": "#F6F6F6", + "backgroundTextStyle": "light", + "navigationBarBackgroundColor": "#F6F6F6", + "navigationBarTitleText": "\"措置有方\"", + "navigationBarTextStyle": "black" + }, + "sitemapLocation": "sitemap.json", + "tabBar": { + "color": "#8a8a8a", + "selectedColor": "#7644df", + "borderStyle": "black", + "backgroundColor": "white", + "list": [ + { + "pagePath": "pages/index/index", + "text": "近24小时", + "iconPath": "images/001.png", + "selectedIconPath": "images/001-2.png" + }, + { + "pagePath": "pages/list/list", + "text": "要做的事情", + "iconPath": "images/002.png", + "selectedIconPath": "images/002-2.png" + }, + { + "pagePath": "pages/alloc/alloc", + "text": "最优规划表", + "iconPath": "images/004-1.png", + "selectedIconPath": "images/004-2.png" + }, + { + "pagePath": "pages/information/information", + "text": "关于我自己", + "iconPath": "images/003.png", + "selectedIconPath": "images/003-2.png" + } + ] + } +} \ No newline at end of file diff --git a/miniprogram/app.wxss b/miniprogram/app.wxss new file mode 100644 index 0000000..4aba359 --- /dev/null +++ b/miniprogram/app.wxss @@ -0,0 +1,33 @@ +/**app.wxss**/ +.container { + display: flex; + flex-direction: column; + align-items: center; + box-sizing: border-box; +} +.btn,.sx,.ks{ + color: #8538ff; + top: 30px; + width: 90px; + margin-left:auto; + margin-right:auto; + margin-bottom: 40px; + } +.ipt,.picker1,.ipt-2{ + border-style: solid; + border-width: 4rpx; + margin-left: 20px; + height: 40px; + width: 80%; + margin-top:10px ; + border-radius: 15rpx; + margin-bottom: 15rpx; + border-color: #8538ff; + font-size: 40rpx; + text-align: center; + background-color: #ffffff; + text-align: left; + +} + + diff --git a/miniprogram/config.js b/miniprogram/config.js new file mode 100644 index 0000000..a1a238f --- /dev/null +++ b/miniprogram/config.js @@ -0,0 +1,16 @@ +/** + * 小程序配置文件 + */ + +var host = "https://asr.codesdream.com"; + +// var host = "http://localhost:8087"; + +var appID = "wx8d9d87cf93f3e918"; + +var config = { + loginUrl: host+'/wx/user/'+appID+'/login', + hostUrl: host +}; + +module.exports = config; diff --git a/miniprogram/dist/action-sheet/index.js b/miniprogram/dist/action-sheet/index.js new file mode 100644 index 0000000..2db31aa --- /dev/null +++ b/miniprogram/dist/action-sheet/index.js @@ -0,0 +1,47 @@ +Component({ + externalClasses: ['i-class', 'i-class-mask', 'i-class-header'], + + options: { + multipleSlots: true + }, + + properties: { + visible: { + type: Boolean, + value: false + }, + maskClosable: { + type: Boolean, + value: true + }, + showCancel: { + type: Boolean, + value: false + }, + cancelText: { + type: String, + value: '取消' + }, + actions: { + type: Array, + value: [] + } + }, + + methods: { + handleClickMask () { + if (!this.data.maskClosable) return; + this.handleClickCancel(); + }, + + handleClickItem ({ currentTarget = {} }) { + const dataset = currentTarget.dataset || {}; + const { index } = dataset; + this.triggerEvent('click', { index }); + }, + + handleClickCancel () { + this.triggerEvent('cancel'); + } + } +}); diff --git a/miniprogram/dist/action-sheet/index.json b/miniprogram/dist/action-sheet/index.json new file mode 100644 index 0000000..6b1e67d --- /dev/null +++ b/miniprogram/dist/action-sheet/index.json @@ -0,0 +1,8 @@ +{ + "component": true, + "usingComponents": + { + "i-button": "../button/index", + "i-icon": "../icon/index" + } +} diff --git a/miniprogram/dist/action-sheet/index.wxml b/miniprogram/dist/action-sheet/index.wxml new file mode 100644 index 0000000..332f393 --- /dev/null +++ b/miniprogram/dist/action-sheet/index.wxml @@ -0,0 +1,23 @@ + + + + + + + + + {{ item.name }} + + + + + {{ cancelText }} + + diff --git a/miniprogram/dist/action-sheet/index.wxss b/miniprogram/dist/action-sheet/index.wxss new file mode 100644 index 0000000..05c6f04 --- /dev/null +++ b/miniprogram/dist/action-sheet/index.wxss @@ -0,0 +1 @@ +.i-as{position:fixed;width:100%;box-sizing:border-box;left:0;right:0;bottom:0;background:#f7f7f7;transform:translate3d(0,100%,0);transform-origin:center;transition:all .2s ease-in-out;z-index:900;visibility:hidden}.i-as-show{transform:translate3d(0,0,0);visibility:visible}.i-as-mask{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,.7);z-index:900;transition:all .2s ease-in-out;opacity:0;visibility:hidden}.i-as-mask-show{opacity:1;visibility:visible}.i-as-action-item{position:relative}.i-as-action-item::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e9eaec;border-bottom-width:1px}.i-as-header{background:#fff;text-align:center;position:relative;font-size:12px;color:#80848f}.i-as-header::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e9eaec;border-bottom-width:1px}.i-as-cancel{margin-top:6px}.i-as-btn-loading{display:inline-block;vertical-align:middle;margin-right:10px;width:12px;height:12px;background:0 0;border-radius:50%;border:2px solid #e5e5e5;border-color:#666 #e5e5e5 #e5e5e5 #e5e5e5;animation:btn-spin .6s linear;animation-iteration-count:infinite}.i-as-btn-text{display:inline-block;vertical-align:middle}.i-as-btn-icon{font-size:14px!important;margin-right:4px}@keyframes btn-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}} \ No newline at end of file diff --git a/miniprogram/dist/alert/index.js b/miniprogram/dist/alert/index.js new file mode 100644 index 0000000..461b67d --- /dev/null +++ b/miniprogram/dist/alert/index.js @@ -0,0 +1,37 @@ +Component({ + externalClasses: ['i-class'], + options: { + multipleSlots: true + }, + properties: { + //info, success, warning, error + type: { + type: String, + value: 'info' + }, + closable: { + type: Boolean, + value: false + }, + showIcon: { + type: Boolean, + default: false + }, + desc: { + type: Boolean, + default: false + }, + }, + data: { + closed: false + }, + methods: { + handleTap() { + this.setData({ + closed: !this.data.closed, + }); + this.triggerEvent('close'); + }, + + } +}); diff --git a/miniprogram/dist/alert/index.json b/miniprogram/dist/alert/index.json new file mode 100644 index 0000000..db3afc0 --- /dev/null +++ b/miniprogram/dist/alert/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": + { + "i-icon": "../icon/index" + } +} diff --git a/miniprogram/dist/alert/index.wxml b/miniprogram/dist/alert/index.wxml new file mode 100644 index 0000000..eebabde --- /dev/null +++ b/miniprogram/dist/alert/index.wxml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/miniprogram/dist/alert/index.wxss b/miniprogram/dist/alert/index.wxss new file mode 100644 index 0000000..0e61fce --- /dev/null +++ b/miniprogram/dist/alert/index.wxss @@ -0,0 +1 @@ +.i-alert{position:relative;margin:10px;padding:8px 48px 8px 16px;font-size:14px;border-radius:2px;color:#fff;background:#f7f7f7;color:#495060}.i-alert.i-alert-with-icon{padding:8px 48px 8px 38px}.i-alert-info{color:#fff;background:#2db7f5}.i-alert-success{color:#fff;background:#19be6b}.i-alert-warning{color:#fff;background:#f90}.i-alert-error{color:#fff;background:#ed3f14}.i-alert-icon{position:absolute;top:9px;left:16px;font-size:14px}.i-alert-desc{font-size:12px}.i-alert-with-desc{padding:16px;position:relative}.i-alert-with-desc.i-alert-with-icon{padding:16px 16px 16px 69px}.i-alert-with-desc .i-alert-icon{top:50%;left:24px;margin-top:-21px;font-size:28px}.i-alert-close{font-size:12px;position:absolute;right:16px;top:8px;overflow:hidden;cursor:pointer} \ No newline at end of file diff --git a/miniprogram/dist/avatar/index.js b/miniprogram/dist/avatar/index.js new file mode 100644 index 0000000..fae9476 --- /dev/null +++ b/miniprogram/dist/avatar/index.js @@ -0,0 +1,20 @@ +Component({ + externalClasses: ['i-class'], + + properties: { + // circle || square + shape: { + type: String, + value: 'circle' + }, + // small || large || default + size: { + type: String, + value: 'default' + }, + src: { + type: String, + value: '' + } + } +}); diff --git a/miniprogram/dist/avatar/index.json b/miniprogram/dist/avatar/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/avatar/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/avatar/index.wxml b/miniprogram/dist/avatar/index.wxml new file mode 100644 index 0000000..11730c6 --- /dev/null +++ b/miniprogram/dist/avatar/index.wxml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/miniprogram/dist/avatar/index.wxss b/miniprogram/dist/avatar/index.wxss new file mode 100644 index 0000000..8f6e636 --- /dev/null +++ b/miniprogram/dist/avatar/index.wxss @@ -0,0 +1 @@ +.i-avatar{display:inline-block;text-align:center;background:#ccc;color:#fff;white-space:nowrap;position:relative;overflow:hidden;vertical-align:middle;width:32px;height:32px;line-height:32px;border-radius:16px;font-size:18px}.i-avatar .ivu-avatar-string{line-height:32px}.i-avatar-large{width:40px;height:40px;line-height:40px;border-radius:20px;font-size:24px}.i-avatar-large .ivu-avatar-string{line-height:40px}.i-avatar-small{width:24px;height:24px;line-height:24px;border-radius:12px;font-size:14px}.i-avatar-small .ivu-avatar-string{line-height:24px}.i-avatar-image{background:0 0}.i-avatar-square{border-radius:4px}.i-avatar>image{width:100%;height:100%} \ No newline at end of file diff --git a/miniprogram/dist/badge/index.js b/miniprogram/dist/badge/index.js new file mode 100644 index 0000000..2b9fb30 --- /dev/null +++ b/miniprogram/dist/badge/index.js @@ -0,0 +1,29 @@ +Component({ + externalClasses: ['i-class', 'i-class-alone'], + + properties: { + count: { + type: Number, + value: 0, + observer: 'finalCount' + }, + overflowCount: { + type: Number, + value: 99 + }, + dot: { + type: Boolean, + value: false + }, + }, + data: { + finalCount: 0 + }, + methods: { + finalCount() { + this.setData({ + finalCount: parseInt(this.data.count) >= parseInt(this.data.overflowCount) ? `${this.data.overflowCount}+` : this.data.count + }); + }, + } +}); diff --git a/miniprogram/dist/badge/index.json b/miniprogram/dist/badge/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/badge/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/badge/index.wxml b/miniprogram/dist/badge/index.wxml new file mode 100644 index 0000000..372fd7f --- /dev/null +++ b/miniprogram/dist/badge/index.wxml @@ -0,0 +1,5 @@ + + + + {{ finalCount }} + diff --git a/miniprogram/dist/badge/index.wxss b/miniprogram/dist/badge/index.wxss new file mode 100644 index 0000000..281658f --- /dev/null +++ b/miniprogram/dist/badge/index.wxss @@ -0,0 +1 @@ +.i-badge{position:relative;display:inline-block;line-height:1;vertical-align:middle}.i-badge-count{position:absolute;transform:translateX(50%);top:-6px;right:0;height:18px;border-radius:9px;min-width:18px;background:#ed3f14;border:1px solid transparent;color:#fff;line-height:18px;text-align:center;padding:0 5px;font-size:12px;white-space:nowrap;transform-origin:-10% center;z-index:10;box-shadow:0 0 0 1px #fff;box-sizing:border-box;text-rendering:optimizeLegibility}.i-badge-count-alone{top:auto;display:block;position:relative;transform:translateX(0)}.i-badge-dot{position:absolute;transform:translateX(-50%);transform-origin:0 center;top:-4px;right:-8px;height:8px;width:8px;border-radius:100%;background:#ed3f14;z-index:10;box-shadow:0 0 0 1px #fff} \ No newline at end of file diff --git a/miniprogram/dist/base/index.js b/miniprogram/dist/base/index.js new file mode 100644 index 0000000..6cb977f --- /dev/null +++ b/miniprogram/dist/base/index.js @@ -0,0 +1,37 @@ +function getCtx (selector) { + const pages = getCurrentPages(); + const ctx = pages[pages.length - 1]; + + const componentCtx = ctx.selectComponent(selector); + + if (!componentCtx) { + console.error('无法找到对应的组件,请按文档说明使用组件'); + return null; + } + return componentCtx; +} + +function Toast(options) { + const { selector = '#toast' } = options; + const ctx = getCtx(selector); + + ctx.handleShow(options); +} + +Toast.hide = function (selector = '#toast') { + const ctx = getCtx(selector); + + ctx.handleHide(); +}; + +function Message(options) { + const { selector = '#message' } = options; + const ctx = getCtx(selector); + + ctx.handleShow(options); +} + +module.exports = { + $Toast: Toast, + $Message: Message +}; \ No newline at end of file diff --git a/miniprogram/dist/button/index.js b/miniprogram/dist/button/index.js new file mode 100644 index 0000000..f0e9b3e --- /dev/null +++ b/miniprogram/dist/button/index.js @@ -0,0 +1,80 @@ +Component({ + externalClasses: ['i-class'], + + properties: { + // default, primary, ghost, info, success, warning, error + type: { + type: String, + value: '', + }, + inline: { + type: Boolean, + value: false + }, + // default, large, small + size: { + type: String, + value: '', + }, + // circle, square + shape: { + type: String, + value: 'square' + }, + disabled: { + type: Boolean, + value: false, + }, + loading: { + type: Boolean, + value: false, + }, + long: { + type: Boolean, + value: false + }, + openType: String, + appParameter: String, + hoverStopPropagation: Boolean, + hoverStartTime: { + type: Number, + value: 20 + }, + hoverStayTime: { + type: Number, + value: 70 + }, + lang: { + type: String, + value: 'en' + }, + sessionFrom: { + type: String, + value: '' + }, + sendMessageTitle: String, + sendMessagePath: String, + sendMessageImg: String, + showMessageCard: Boolean + }, + + methods: { + handleTap () { + if (this.data.disabled) return false; + + this.triggerEvent('click'); + }, + bindgetuserinfo({ detail = {} } = {}) { + this.triggerEvent('getuserinfo', detail); + }, + bindcontact({ detail = {} } = {}) { + this.triggerEvent('contact', detail); + }, + bindgetphonenumber({ detail = {} } = {}) { + this.triggerEvent('getphonenumber', detail); + }, + binderror({ detail = {} } = {}) { + this.triggerEvent('error', detail); + } + } +}); diff --git a/miniprogram/dist/button/index.json b/miniprogram/dist/button/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/button/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/button/index.wxml b/miniprogram/dist/button/index.wxml new file mode 100644 index 0000000..e154eee --- /dev/null +++ b/miniprogram/dist/button/index.wxml @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/miniprogram/dist/button/index.wxss b/miniprogram/dist/button/index.wxss new file mode 100644 index 0000000..550bc81 --- /dev/null +++ b/miniprogram/dist/button/index.wxss @@ -0,0 +1 @@ +.i-btn{text-align:center;vertical-align:middle;touch-action:manipulation;cursor:pointer;background-image:none;white-space:nowrap;user-select:none;font-size:14px;border-radius:2px;border:0!important;position:relative;text-decoration:none;height:44px;line-height:44px;box-shadow:inset 0 0 0 1px rgba(0,0,0,.1);color:#fff!important;background:#f7f7f7!important;color:#495060!important;margin:10px}.i-btn-hover{opacity:.9}.i-btn-long{border-radius:0;margin:0;box-shadow:none}.i-btn-large{height:48px;line-height:48px}.i-btn-small{height:40px;line-height:40px}.i-btn-primary{color:#fff!important;background:#2d8cf0!important}.i-btn-ghost{color:#fff!important;background:#fff!important;color:#495060!important}.i-btn-success{color:#fff!important;background:#19be6b!important}.i-btn-warning{color:#fff!important;background:#f90!important}.i-btn-error{color:#fff!important;background:#ed3f14!important}.i-btn-info{color:#fff!important;background:#2db7f5!important}.i-btn-circle{border-radius:44px}.i-btn-large.i-btn-circle{border-radius:48px}.i-btn-small.i-btn-circle{border-radius:40px}.i-btn-loading{opacity:.6}.i-btn-loading-inner{display:inline-block;margin-right:12px;vertical-align:middle;width:14px;height:14px;background:0 0;border-radius:50%;border:2px solid #fff;border-color:#fff #fff #fff transparent;animation:btn-spin .6s linear;animation-iteration-count:infinite}.i-btn-disabled{color:#bbbec4!important;background:#f7f7f7!important}.i-btn-inline{display:inline-block}@keyframes btn-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}} \ No newline at end of file diff --git a/miniprogram/dist/card/index.js b/miniprogram/dist/card/index.js new file mode 100644 index 0000000..20ad106 --- /dev/null +++ b/miniprogram/dist/card/index.js @@ -0,0 +1,26 @@ +Component({ + externalClasses: ['i-class'], + + options: { + multipleSlots: true + }, + + properties: { + full: { + type: Boolean, + value: false + }, + thumb: { + type: String, + value: '' + }, + title: { + type: String, + value: '' + }, + extra: { + type: String, + value: '' + } + } +}); diff --git a/miniprogram/dist/card/index.json b/miniprogram/dist/card/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/card/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/card/index.wxml b/miniprogram/dist/card/index.wxml new file mode 100644 index 0000000..4792293 --- /dev/null +++ b/miniprogram/dist/card/index.wxml @@ -0,0 +1,11 @@ + + + + + {{ title }} + + {{ extra }} + + + + diff --git a/miniprogram/dist/card/index.wxss b/miniprogram/dist/card/index.wxss new file mode 100644 index 0000000..fd8fad4 --- /dev/null +++ b/miniprogram/dist/card/index.wxss @@ -0,0 +1 @@ +.i-card{margin:0 16px;font-size:14px;overflow:hidden;position:relative;background:#fff;border:1rpx solid #dddee1;border-radius:5px}.i-card-full{margin:0;border-left:none;border-right:none;border-radius:0}.i-card-header{display:flex;padding:6px 16px;align-items:center}.i-card-header-content{flex:1;text-align:left}.i-card-header-thumb{display:inline-block;width:64px;height:64px;position:relative;margin-left:auto;margin-right:auto;overflow:hidden;background-size:cover;vertical-align:middle}.i-card-header-title{display:inline-block;vertical-align:middle;font-size:14px;color:#1c2438}.i-card-header-extra{flex:1;text-align:right;font-size:14px;color:#80848f}.i-card-body{position:relative;padding:6px 16px;color:#495060;font-size:14px}.i-card-body::before{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e9eaec;border-top-width:1px}.i-card-footer{position:relative;padding:6px 16px;color:#80848f;font-size:12px} \ No newline at end of file diff --git a/miniprogram/dist/cell-group/index.js b/miniprogram/dist/cell-group/index.js new file mode 100644 index 0000000..ad36baa --- /dev/null +++ b/miniprogram/dist/cell-group/index.js @@ -0,0 +1,33 @@ +Component({ + externalClasses: ['i-class'], + + relations: { + '../cell/index': { + type: 'child', + linked () { + this._updateIsLastCell(); + }, + linkChanged () { + this._updateIsLastCell(); + }, + unlinked () { + this._updateIsLastCell(); + } + } + }, + + methods: { + _updateIsLastCell() { + let cells = this.getRelationNodes('../cell/index'); + const len = cells.length; + + if (len > 0) { + let lastIndex = len - 1; + + cells.forEach((cell, index) => { + cell.updateIsLastCell(index === lastIndex); + }); + } + } + } +}); diff --git a/miniprogram/dist/cell-group/index.json b/miniprogram/dist/cell-group/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/cell-group/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/cell-group/index.wxml b/miniprogram/dist/cell-group/index.wxml new file mode 100644 index 0000000..1897919 --- /dev/null +++ b/miniprogram/dist/cell-group/index.wxml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/miniprogram/dist/cell/index.js b/miniprogram/dist/cell/index.js new file mode 100644 index 0000000..50e635c --- /dev/null +++ b/miniprogram/dist/cell/index.js @@ -0,0 +1,86 @@ +const warn = (msg, getValue) => { + console.warn(msg); + console.log('接受到的值为:', getValue); +}; + +Component({ + externalClasses: ['i-class'], + + options: { + multipleSlots: true + }, + + relations: { + '../cell-group/index': { + type: 'parent' + } + }, + + properties: { + // 左侧标题 + title: { + type: String + }, + // 标题下方的描述信息 + label: { + type: String + }, + // 右侧内容 + value: { + type: String + }, + // 只有点击 footer 区域才触发 tab 事件 + onlyTapFooter: { + type: Boolean + }, + // 是否展示右侧箭头并开启尝试以 url 跳转 + isLink: { + type: null, + value: '' + }, + // 链接类型,可选值为 navigateTo,redirectTo,switchTab,reLaunch + linkType: { + type: String, + value: 'navigateTo' + }, + url: { + type: String, + value: '' + } + }, + + data: { + isLastCell: true + }, + + methods: { + navigateTo () { + const { url } = this.data; + const type = typeof this.data.isLink; + + this.triggerEvent('click', {}); + + if (!this.data.isLink || !url || url === 'true' || url === 'false') return; + + if (type !== 'boolean' && type !== 'string') { + warn('isLink 属性值必须是一个字符串或布尔值', this.data.isLink); + return; + } + + if (['navigateTo', 'redirectTo', 'switchTab', 'reLaunch'].indexOf(this.data.linkType) === -1) { + warn('linkType 属性可选值为 navigateTo,redirectTo,switchTab,reLaunch', this.data.linkType); + return; + } + wx[this.data.linkType].call(wx, {url}); + }, + handleTap () { + if (!this.data.onlyTapFooter) { + this.navigateTo(); + } + }, + + updateIsLastCell (isLastCell) { + this.setData({ isLastCell }); + } + } +}); diff --git a/miniprogram/dist/cell/index.json b/miniprogram/dist/cell/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/cell/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/cell/index.wxml b/miniprogram/dist/cell/index.wxml new file mode 100644 index 0000000..c3683e3 --- /dev/null +++ b/miniprogram/dist/cell/index.wxml @@ -0,0 +1,16 @@ + + + + + + {{ title }} + {{ label }} + + + + {{ value }} + + + + + \ No newline at end of file diff --git a/miniprogram/dist/cell/index.wxss b/miniprogram/dist/cell/index.wxss new file mode 100644 index 0000000..e45ad75 --- /dev/null +++ b/miniprogram/dist/cell/index.wxss @@ -0,0 +1 @@ +.i-cell{position:relative;padding:12px 15px;display:flex;background:#fff;align-items:center;line-height:1.4;font-size:14px;overflow:hidden}.i-cell::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e9eaec;border-bottom-width:1px;left:15px;right:0}.i-cell-last::after{display:none}.i-cell-icon{margin-right:5px}.i-cell-icon:empty{display:none}.i-cell-bd{flex:1}.i-cell-text{line-height:24px;font-size:14px}.i-cell-desc{line-height:1.2;font-size:12px;color:#80848f}.i-cell-ft{position:relative;text-align:right;color:#495060}.i-cell-access .i-cell-ft{padding-right:13px}.i-cell-access .i-cell-ft::after{content:" ";display:inline-block;width:6px;height:6px;position:absolute;top:50%;right:2px;border-width:2px 2px 0 0;border-color:#dddee1;border-style:solid;transform:translateY(-50%) matrix(.71,.71,-.71,.71,0,0)} \ No newline at end of file diff --git a/miniprogram/dist/checkbox-group/index.js b/miniprogram/dist/checkbox-group/index.js new file mode 100644 index 0000000..6465450 --- /dev/null +++ b/miniprogram/dist/checkbox-group/index.js @@ -0,0 +1,38 @@ +Component({ + externalClasses: ['i-class'], + relations: { + '../checkbox/index': { + type: 'child', + linked() { + this.changeCurrent(); + }, + linkChanged() { + this.changeCurrent(); + }, + unlinked() { + this.changeCurrent(); + } + } + }, + properties: { + current: { + type: Array, + value: [], + observer: 'changeCurrent' + }, + }, + methods: { + changeCurrent(val = this.data.current) { + let items = this.getRelationNodes('../checkbox/index'); + const len = items.length; + if (len > 0) { + items.forEach(item => { + item.changeCurrent(val.indexOf(item.data.value) !== -1); + }); + } + }, + emitEvent(current) { + this.triggerEvent('change', current); + } + } +}); diff --git a/miniprogram/dist/checkbox-group/index.json b/miniprogram/dist/checkbox-group/index.json new file mode 100644 index 0000000..edf138d --- /dev/null +++ b/miniprogram/dist/checkbox-group/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": + { + "i-cell-group": "../cell-group/index" + } +} diff --git a/miniprogram/dist/checkbox-group/index.wxml b/miniprogram/dist/checkbox-group/index.wxml new file mode 100644 index 0000000..6940180 --- /dev/null +++ b/miniprogram/dist/checkbox-group/index.wxml @@ -0,0 +1,3 @@ + + + diff --git a/miniprogram/dist/checkbox-group/index.wxss b/miniprogram/dist/checkbox-group/index.wxss new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram/dist/checkbox/index.js b/miniprogram/dist/checkbox/index.js new file mode 100644 index 0000000..b383952 --- /dev/null +++ b/miniprogram/dist/checkbox/index.js @@ -0,0 +1,56 @@ +const prefixCls = 'i-checkbox'; + +Component({ + externalClasses: ['i-class'], + relations: { + '../checkbox-group/index': { + type: 'parent' + } + }, + properties: { + value: { + type: String, + value: '' + }, + checked: { + type: Boolean, + value: false + }, + disabled: { + type: Boolean, + value: false + }, + color: { + type: String, + value: '#2d8cf0' + }, + position: { + type: String, + value: 'left', //left right + observer: 'setPosition' + } + }, + data: { + checked: true, + positionCls: `${prefixCls}-checkbox-left`, + }, + attached() { + this.setPosition(); + }, + methods: { + changeCurrent(current) { + this.setData({ checked: current }); + }, + checkboxChange() { + if (this.data.disabled) return; + const item = { current: !this.data.checked, value: this.data.value }; + const parent = this.getRelationNodes('../checkbox-group/index')[0]; + parent ? parent.emitEvent(item) : this.triggerEvent('change', item); + }, + setPosition() { + this.setData({ + positionCls: this.data.position.indexOf('left') !== -1 ? `${prefixCls}-checkbox-left` : `${prefixCls}-checkbox-right`, + }); + } + } +}); diff --git a/miniprogram/dist/checkbox/index.json b/miniprogram/dist/checkbox/index.json new file mode 100644 index 0000000..e2ab49a --- /dev/null +++ b/miniprogram/dist/checkbox/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": + { + "i-cell": "../cell/index" + } +} diff --git a/miniprogram/dist/checkbox/index.wxml b/miniprogram/dist/checkbox/index.wxml new file mode 100644 index 0000000..214493f --- /dev/null +++ b/miniprogram/dist/checkbox/index.wxml @@ -0,0 +1,8 @@ + + + + + diff --git a/miniprogram/dist/checkbox/index.wxss b/miniprogram/dist/checkbox/index.wxss new file mode 100644 index 0000000..a07699f --- /dev/null +++ b/miniprogram/dist/checkbox/index.wxss @@ -0,0 +1 @@ +.i-checkbox-cell::after{display:block}.i-checkbox-checkbox-left{float:left}.i-checkbox-checkbox-right{float:right}.i-checkbox-radio{vertical-align:middle}.i-checkbox-title{display:inline-block;vertical-align:middle} \ No newline at end of file diff --git a/miniprogram/dist/circle-progress/index.js b/miniprogram/dist/circle-progress/index.js new file mode 100644 index 0000000..1b2aaa2 --- /dev/null +++ b/miniprogram/dist/circle-progress/index.js @@ -0,0 +1,47 @@ +Component({ + properties: { + currentProgress:{ + type: Number, + value: 0, + observer: '_progressDidChange', + }, + size:{ + type: Number, + value: 200 + }, + borderSize:{ + type: Number, + value: 20 + }, + borderColor:{ + type: String, + value: "green" + }, + normalColor:{ + type: String, + value: "gray" + } + }, + data: { + rightCircleRadius: 135, + leftCircleRadius: 135, + }, + methods: { + _progressDidChange: function(newVal,oldVal){ + var that = this; + var newLeftRadius = that.data.leftCircleRadius; + var newRightRadius = that.data.rightCircleRadius; + var radius = 360 * newVal; + if(newVal < 0.5 && newVal >= 0){ + //只需要旋转右边的值 + newLeftRadius = 135; + newRightRadius = 135 + radius; + }else if(newVal <= 1 && newVal >=0.5){ + //两边都需要旋转 + newLeftRadius = radius - 45; + newRightRadius = -45; + } + that.setData({rightCircleRadius:newRightRadius,leftCircleRadius:newLeftRadius}); + } + } +}) \ No newline at end of file diff --git a/miniprogram/dist/circle-progress/index.json b/miniprogram/dist/circle-progress/index.json new file mode 100644 index 0000000..e8cfaaf --- /dev/null +++ b/miniprogram/dist/circle-progress/index.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/miniprogram/dist/circle-progress/index.wxml b/miniprogram/dist/circle-progress/index.wxml new file mode 100644 index 0000000..00706e6 --- /dev/null +++ b/miniprogram/dist/circle-progress/index.wxml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/miniprogram/dist/circle-progress/index.wxss b/miniprogram/dist/circle-progress/index.wxss new file mode 100644 index 0000000..556aad6 --- /dev/null +++ b/miniprogram/dist/circle-progress/index.wxss @@ -0,0 +1,32 @@ +/* miniprogram/dist/circle-progress/circle-progress.wxss */ +.circle-progress-outter-circle{ + border-radius: 50%; + box-sizing: border-box; +} +.circle-progress-half-rect{ + position: absolute; + overflow: hidden; +} +.right-rect{ + top: 0; + right: 0; +} +.left-rect{ + top: 0; + left: 0; +} +.circle-progress-half-circle{ + border-radius: 50%; + box-sizing: border-box; + position: absolute; +} +.right-circle{ + top:0; + right: 0; + transform: rotate(-45deg); +} +.left-circle{ + top:0; + left: 0; + transform: rotate(-45deg); +} \ No newline at end of file diff --git a/miniprogram/dist/col/index.js b/miniprogram/dist/col/index.js new file mode 100644 index 0000000..9b2d65d --- /dev/null +++ b/miniprogram/dist/col/index.js @@ -0,0 +1,20 @@ +Component({ + externalClasses: ['i-class'], + + relations: { + '../row/index': { + type: 'parent' + } + }, + + properties: { + span: { + value: 0, + type: Number + }, + offset: { + value: 0, + type: Number + } + } +}); diff --git a/miniprogram/dist/col/index.json b/miniprogram/dist/col/index.json new file mode 100644 index 0000000..32640e0 --- /dev/null +++ b/miniprogram/dist/col/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/miniprogram/dist/col/index.wxml b/miniprogram/dist/col/index.wxml new file mode 100644 index 0000000..838a22b --- /dev/null +++ b/miniprogram/dist/col/index.wxml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/miniprogram/dist/col/index.wxss b/miniprogram/dist/col/index.wxss new file mode 100644 index 0000000..bdce125 --- /dev/null +++ b/miniprogram/dist/col/index.wxss @@ -0,0 +1 @@ +.i-col{float:left;box-sizing:border-box;width:0}.i-col-span-1{display:block;width:4.16666667%}.i-col-offset-1{margin-left:4.16666667%}.i-col-span-2{display:block;width:8.33333333%}.i-col-offset-2{margin-left:8.33333333%}.i-col-span-3{display:block;width:12.5%}.i-col-offset-3{margin-left:12.5%}.i-col-span-4{display:block;width:16.66666667%}.i-col-offset-4{margin-left:16.66666667%}.i-col-span-5{display:block;width:20.83333333%}.i-col-offset-5{margin-left:20.83333333%}.i-col-span-6{display:block;width:25%}.i-col-offset-6{margin-left:25%}.i-col-span-7{display:block;width:29.16666667%}.i-col-offset-7{margin-left:29.16666667%}.i-col-span-8{display:block;width:33.33333333%}.i-col-offset-8{margin-left:33.33333333%}.i-col-span-9{display:block;width:37.5%}.i-col-offset-9{margin-left:37.5%}.i-col-span-10{display:block;width:41.66666667%}.i-col-offset-10{margin-left:41.66666667%}.i-col-span-11{display:block;width:45.83333333%}.i-col-offset-11{margin-left:45.83333333%}.i-col-span-12{display:block;width:50%}.i-col-offset-12{margin-left:50%}.i-col-span-13{display:block;width:54.16666667%}.i-col-offset-13{margin-left:54.16666667%}.i-col-span-14{display:block;width:58.33333333%}.i-col-offset-14{margin-left:58.33333333%}.i-col-span-15{display:block;width:62.5%}.i-col-offset-15{margin-left:62.5%}.i-col-span-16{display:block;width:66.66666667%}.i-col-offset-16{margin-left:66.66666667%}.i-col-span-17{display:block;width:70.83333333%}.i-col-offset-17{margin-left:70.83333333%}.i-col-span-18{display:block;width:75%}.i-col-offset-18{margin-left:75%}.i-col-span-19{display:block;width:79.16666667%}.i-col-offset-19{margin-left:79.16666667%}.i-col-span-20{display:block;width:83.33333333%}.i-col-offset-20{margin-left:83.33333333%}.i-col-span-21{display:block;width:87.5%}.i-col-offset-21{margin-left:87.5%}.i-col-span-22{display:block;width:91.66666667%}.i-col-offset-22{margin-left:91.66666667%}.i-col-span-23{display:block;width:95.83333333%}.i-col-offset-23{margin-left:95.83333333%}.i-col-span-24{display:block;width:100%}.i-col-offset-24{margin-left:100%} \ No newline at end of file diff --git a/miniprogram/dist/collapse-item/index.js b/miniprogram/dist/collapse-item/index.js new file mode 100644 index 0000000..bc415c1 --- /dev/null +++ b/miniprogram/dist/collapse-item/index.js @@ -0,0 +1,46 @@ +Component({ + externalClasses: ['i-class-content', 'i-class-title', 'i-class'], + + relations: { + '../collapse/index': { + type: 'parent', + linked: function (target) { + const options = { + accordion: target.data.accordion + } + if (target.data.name === this.data.name) { + options.showContent = 'i-collapse-item-show-content'; + } + this.setData(options); + } + } + }, + + properties: { + title: String, + name: String + }, + + data: { + showContent: '', + accordion: false + }, + + options: { + multipleSlots: true + }, + + methods: { + trigger(e) { + const data = this.data; + if (data.accordion) { + this.triggerEvent('collapse', {name: data.name}, {composed: true, bubbles: true}); + } else { + this.setData({ + showContent: data.showContent ? '' : 'i-collapse-item-show-content' + }); + } + }, + } +}); + diff --git a/miniprogram/dist/collapse-item/index.json b/miniprogram/dist/collapse-item/index.json new file mode 100644 index 0000000..54575da --- /dev/null +++ b/miniprogram/dist/collapse-item/index.json @@ -0,0 +1,7 @@ + +{ + "component": true, + "usingComponents": { + "i-icon": "../icon/index" + } +} diff --git a/miniprogram/dist/collapse-item/index.wxml b/miniprogram/dist/collapse-item/index.wxml new file mode 100644 index 0000000..ba22b0a --- /dev/null +++ b/miniprogram/dist/collapse-item/index.wxml @@ -0,0 +1,9 @@ + + + + {{title}} + + + + + \ No newline at end of file diff --git a/miniprogram/dist/collapse-item/index.wxss b/miniprogram/dist/collapse-item/index.wxss new file mode 100644 index 0000000..d44c032 --- /dev/null +++ b/miniprogram/dist/collapse-item/index.wxss @@ -0,0 +1 @@ +.i-collapse-item{padding:2px 8px;border-top:1px solid #dddee1}.i-collapse-item-title{vertical-align:middle}.i-collapse-item-title-wrap{padding:2px 0 0}.i-collapse-item-content{padding:6px;display:none}.i-collapse-item-show-content{display:block}.i-collapse-item-arrow{transition:transform .2s ease-in-out}.i-collapse-item-arrow-show{transition:transform .2s ease-in-out;transform:rotate(90deg)} \ No newline at end of file diff --git a/miniprogram/dist/collapse/index.js b/miniprogram/dist/collapse/index.js new file mode 100644 index 0000000..acc1455 --- /dev/null +++ b/miniprogram/dist/collapse/index.js @@ -0,0 +1,31 @@ +Component({ + externalClasses: ['i-class'], + + relations: { + '../collapse-item/index': { + type: 'child' + } + }, + properties: { + name: String, + accordion: Boolean + }, + methods: { + clickfn(e) { + const params = e.detail; + const allList = this.getRelationNodes('../collapse-item/index'); + allList.forEach((item) => { + if (params.name === item.data.name) { + item.setData({ + showContent: 'i-collapse-item-show-content' + }); + } else { + item.setData({ + showContent: '' + }); + } + }); + }, + } +}); + diff --git a/miniprogram/dist/collapse/index.json b/miniprogram/dist/collapse/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/collapse/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/collapse/index.wxml b/miniprogram/dist/collapse/index.wxml new file mode 100644 index 0000000..0f379f7 --- /dev/null +++ b/miniprogram/dist/collapse/index.wxml @@ -0,0 +1,4 @@ + + + + diff --git a/miniprogram/dist/collapse/index.wxss b/miniprogram/dist/collapse/index.wxss new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram/dist/count-down/index.js b/miniprogram/dist/count-down/index.js new file mode 100644 index 0000000..f1da533 --- /dev/null +++ b/miniprogram/dist/count-down/index.js @@ -0,0 +1,90 @@ +Component({ + properties: { + target: Number, + showDay: Boolean, + callback: String, + format: Array, + clearTimer: Boolean + }, + externalClasses: ['countdown-class'], + data: { + time: '', + resultFormat: [], + changeFormat: false + }, + ready() { + this.getFormat(); + + }, + methods: { + getFormat() { + const data = this.data; + const len = data.format.length; + + if (!data.showDay) data.resultFormat.push(''); + + if (len >= 3) { + for (let i = 0; i < len; i++) { + if (data.resultFormat.length >= 4) break; + if (data.format[i]) { + data.resultFormat.push(data.format[i].toString()); + } + } + + if (data.resultFormat.length >= 4) data.changeFormat = true; + } + + this.getLastTime(); + }, + init() { + const self = this; + setTimeout(function () { + self.getLastTime.call(self); + }, 1000); + }, + getLastTime() { + const data = this.data; + const gapTime = Math.ceil((data.target - new Date().getTime()) / 1000); + let result = ''; + let time = '00:00:00'; + let day = '00'; + const format = data.resultFormat; + + if (gapTime > 0) { + day = this.formatNum(parseInt(gapTime / 86400)); + let lastTime = gapTime % 86400; + const hour = this.formatNum(parseInt(lastTime / 3600)); + lastTime = lastTime % 3600; + const minute = this.formatNum(parseInt(lastTime / 60)); + const second = this.formatNum(lastTime % 60); + + if (data.changeFormat) time = `${hour}${format[1]}${minute}${format[2]}${second}${format[3]}`; + else time = `${hour}:${minute}:${second}`; + + if (!data.clearTimer) this.init.call(this); + } else { + this.endfn(); + } + + if (data.showDay) { + if (data.changeFormat) { + result = `${day}${format[0]} ${time}`; + } else { + result = `${day}d ${time}`; + } + } else { + result = time; + } + this.setData({ + time: result + }); + + }, + formatNum(num) { + return num > 9 ? num : `0${num}`; + }, + endfn() { + this.triggerEvent('callback', {}); + } + } +}); diff --git a/miniprogram/dist/count-down/index.json b/miniprogram/dist/count-down/index.json new file mode 100644 index 0000000..74f1315 --- /dev/null +++ b/miniprogram/dist/count-down/index.json @@ -0,0 +1,4 @@ + +{ + "component": true +} diff --git a/miniprogram/dist/count-down/index.wxml b/miniprogram/dist/count-down/index.wxml new file mode 100644 index 0000000..e4bec57 --- /dev/null +++ b/miniprogram/dist/count-down/index.wxml @@ -0,0 +1,4 @@ + + {{time}} + + diff --git a/miniprogram/dist/count-down/index.wxss b/miniprogram/dist/count-down/index.wxss new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram/dist/divider/index.js b/miniprogram/dist/divider/index.js new file mode 100644 index 0000000..6b0e448 --- /dev/null +++ b/miniprogram/dist/divider/index.js @@ -0,0 +1,25 @@ +Component({ + externalClasses: ['i-class'], + properties: { + content: { + type: String, + value: '' + }, + height : { + type: Number, + value: 48 + }, + color : { + type : String, + value : '#80848f' + }, + lineColor : { + type : String, + value : '#e9eaec' + }, + size : { + type: String, + value: 12 + } + } +}); diff --git a/miniprogram/dist/divider/index.json b/miniprogram/dist/divider/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/divider/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/divider/index.wxml b/miniprogram/dist/divider/index.wxml new file mode 100644 index 0000000..b7111d3 --- /dev/null +++ b/miniprogram/dist/divider/index.wxml @@ -0,0 +1,19 @@ + + + {{content}} + + + + + + + + module.exports = { + getStyle : function(color,size,height){ + var color = 'color:' + color +';'; + var size = 'font-size:' + size + 'px;'; + var height = 'height:' + height+'px;' + return color + size + height; + } + } + diff --git a/miniprogram/dist/divider/index.wxss b/miniprogram/dist/divider/index.wxss new file mode 100644 index 0000000..98827ab --- /dev/null +++ b/miniprogram/dist/divider/index.wxss @@ -0,0 +1 @@ +.i-divider{width:100%;text-align:center;font-size:12px;position:relative;display:flex;align-items:center;justify-content:center}.i-divider-line{position:absolute;left:0;width:100%;height:1rpx;background-color:#f7f7f7;top:50%}.i-divider-content{background:#fff;position:relative;z-index:1;display:inline-block;padding:0 10px} \ No newline at end of file diff --git a/miniprogram/dist/drawer/index.js b/miniprogram/dist/drawer/index.js new file mode 100644 index 0000000..adb248a --- /dev/null +++ b/miniprogram/dist/drawer/index.js @@ -0,0 +1,33 @@ +Component({ + externalClasses: ['i-class'], + properties: { + visible: { + type: Boolean, + value: false + }, + + mask: { + type: Boolean, + value: true + }, + + maskClosable: { + type: Boolean, + value: true + }, + + mode: { + type: String, + value: 'left' // left right + } + }, + data: {}, + methods: { + handleMaskClick() { + if (!this.data.maskClosable) { + return; + } + this.triggerEvent('close', {}); + } + } +}); diff --git a/miniprogram/dist/drawer/index.json b/miniprogram/dist/drawer/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/drawer/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/drawer/index.wxml b/miniprogram/dist/drawer/index.wxml new file mode 100644 index 0000000..67380d9 --- /dev/null +++ b/miniprogram/dist/drawer/index.wxml @@ -0,0 +1,6 @@ + + + + + + diff --git a/miniprogram/dist/drawer/index.wxss b/miniprogram/dist/drawer/index.wxss new file mode 100644 index 0000000..2824713 --- /dev/null +++ b/miniprogram/dist/drawer/index.wxss @@ -0,0 +1 @@ +.i-drawer{visibility:hidden}.i-drawer-show{visibility:visible}.i-drawer-show .i-drawer-mask{display:block;opacity:1}.i-drawer-show .i-drawer-container{opacity:1}.i-drawer-show.i-drawer-left .i-drawer-container,.i-drawer-show.i-drawer-right .i-drawer-container{transform:translate3d(0,-50%,0)}.i-drawer-mask{opacity:0;position:fixed;top:0;left:0;right:0;bottom:0;z-index:6;background:rgba(0,0,0,.6);transition:all .3s ease-in-out}.i-drawer-container{position:fixed;left:50%;top:50%;transform:translate3d(-50%,-50%,0);transform-origin:center;transition:all .3s ease-in-out;z-index:7;opacity:0}.i-drawer-left .i-drawer-container{left:0;top:50%;transform:translate3d(-100%,-50%,0)}.i-drawer-right .i-drawer-container{right:0;top:50%;left:auto;transform:translate3d(100%,-50%,0)} \ No newline at end of file diff --git a/miniprogram/dist/grid-icon/index.js b/miniprogram/dist/grid-icon/index.js new file mode 100644 index 0000000..5315185 --- /dev/null +++ b/miniprogram/dist/grid-icon/index.js @@ -0,0 +1,10 @@ +Component({ + externalClasses: ['i-class'], + + relations: { + '../grid-item/index': { + type: 'parent' + } + }, + +}); diff --git a/miniprogram/dist/grid-icon/index.json b/miniprogram/dist/grid-icon/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/grid-icon/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/grid-icon/index.wxml b/miniprogram/dist/grid-icon/index.wxml new file mode 100644 index 0000000..b9f9025 --- /dev/null +++ b/miniprogram/dist/grid-icon/index.wxml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/miniprogram/dist/grid-icon/index.wxss b/miniprogram/dist/grid-icon/index.wxss new file mode 100644 index 0000000..88c58a7 --- /dev/null +++ b/miniprogram/dist/grid-icon/index.wxss @@ -0,0 +1 @@ +.i-grid-icon{display:block;width:28px;height:28px;margin:0 auto}.i-grid-icon image{width:100%;height:100%} \ No newline at end of file diff --git a/miniprogram/dist/grid-item/index.js b/miniprogram/dist/grid-item/index.js new file mode 100644 index 0000000..e492542 --- /dev/null +++ b/miniprogram/dist/grid-item/index.js @@ -0,0 +1,16 @@ +Component({ + externalClasses: ['i-class'], + + relations: { + '../grid/index': { + type: 'parent' + }, + '../grid-icon/index': { + type: 'child' + } + }, + + data: { + width: '33.33%' + } +}); diff --git a/miniprogram/dist/grid-item/index.json b/miniprogram/dist/grid-item/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/grid-item/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/grid-item/index.wxml b/miniprogram/dist/grid-item/index.wxml new file mode 100644 index 0000000..8e133cd --- /dev/null +++ b/miniprogram/dist/grid-item/index.wxml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/miniprogram/dist/grid-item/index.wxss b/miniprogram/dist/grid-item/index.wxss new file mode 100644 index 0000000..ed0f395 --- /dev/null +++ b/miniprogram/dist/grid-item/index.wxss @@ -0,0 +1 @@ +.i-grid-item{position:relative;float:left;padding:20px 10px;width:33.33333333%;box-sizing:border-box;border-right:1rpx solid #e9eaec;border-bottom:1rpx solid #e9eaec} \ No newline at end of file diff --git a/miniprogram/dist/grid-label/index.js b/miniprogram/dist/grid-label/index.js new file mode 100644 index 0000000..5315185 --- /dev/null +++ b/miniprogram/dist/grid-label/index.js @@ -0,0 +1,10 @@ +Component({ + externalClasses: ['i-class'], + + relations: { + '../grid-item/index': { + type: 'parent' + } + }, + +}); diff --git a/miniprogram/dist/grid-label/index.json b/miniprogram/dist/grid-label/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/grid-label/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/grid-label/index.wxml b/miniprogram/dist/grid-label/index.wxml new file mode 100644 index 0000000..7ab5a8a --- /dev/null +++ b/miniprogram/dist/grid-label/index.wxml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/miniprogram/dist/grid-label/index.wxss b/miniprogram/dist/grid-label/index.wxss new file mode 100644 index 0000000..d45a990 --- /dev/null +++ b/miniprogram/dist/grid-label/index.wxss @@ -0,0 +1 @@ +.i-grid-label{margin-top:5px;display:block;text-align:center;color:#1c2438;font-size:14px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden} \ No newline at end of file diff --git a/miniprogram/dist/grid/index.js b/miniprogram/dist/grid/index.js new file mode 100644 index 0000000..f9c9c40 --- /dev/null +++ b/miniprogram/dist/grid/index.js @@ -0,0 +1,50 @@ +Component({ + externalClasses: ['i-class'], + + relations: { + '../grid-item/index': { + type: 'child', + linked () { + this.setGridItemWidth(); + }, + linkChanged () { + this.setGridItemWidth(); + }, + unlinked () { + this.setGridItemWidth(); + } + } + }, + + methods: { + setGridItemWidth () { + const nodes = this.getRelationNodes('../grid-item/index'); + + // const len = nodes.length; + // if (len < 3) { + // nodes.forEach(item => { + // item.setData({ + // 'width': '33.33%' + // }); + // }); + // } else { + // const width = 100 / nodes.length; + // nodes.forEach(item => { + // item.setData({ + // 'width': width + '%' + // }); + // }); + // } + const width = 100 / nodes.length; + nodes.forEach(item => { + item.setData({ + 'width': width + '%' + }); + }); + } + }, + + ready () { + this.setGridItemWidth(); + } +}); diff --git a/miniprogram/dist/grid/index.json b/miniprogram/dist/grid/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/grid/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/grid/index.wxml b/miniprogram/dist/grid/index.wxml new file mode 100644 index 0000000..4c9143c --- /dev/null +++ b/miniprogram/dist/grid/index.wxml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/miniprogram/dist/grid/index.wxss b/miniprogram/dist/grid/index.wxss new file mode 100644 index 0000000..842fc98 --- /dev/null +++ b/miniprogram/dist/grid/index.wxss @@ -0,0 +1 @@ +.i-grid{border-top:1rpx solid #e9eaec;border-left:1rpx solid #e9eaec;overflow:hidden} \ No newline at end of file diff --git a/miniprogram/dist/icon/index.js b/miniprogram/dist/icon/index.js new file mode 100644 index 0000000..eb43ab9 --- /dev/null +++ b/miniprogram/dist/icon/index.js @@ -0,0 +1,22 @@ +Component({ + externalClasses: ['i-class'], + + properties: { + type: { + type: String, + value: '' + }, + custom: { + type: String, + value: '' + }, + size: { + type: Number, + value: 14 + }, + color: { + type: String, + value: '' + } + } +}); diff --git a/miniprogram/dist/icon/index.json b/miniprogram/dist/icon/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/icon/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/icon/index.wxml b/miniprogram/dist/icon/index.wxml new file mode 100644 index 0000000..d689bc5 --- /dev/null +++ b/miniprogram/dist/icon/index.wxml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/miniprogram/dist/icon/index.wxss b/miniprogram/dist/icon/index.wxss new file mode 100644 index 0000000..b18dcbb --- /dev/null +++ b/miniprogram/dist/icon/index.wxss @@ -0,0 +1 @@ +@font-face{font-family:iconfont;src:url('data:application/x-font-woff;charset=utf-8;base64,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') format('woff')}.i-icon{display:inline-block;font-family:iconfont;speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;text-rendering:auto;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;vertical-align:middle}.i-icon-accessory:before{content:"\e6dd"}.i-icon-activity:before{content:"\e6de"}.i-icon-activity_fill:before{content:"\e6df"}.i-icon-add:before{content:"\e6e0"}.i-icon-addressbook_fill:before{content:"\e6e2"}.i-icon-addressbook:before{content:"\e6e3"}.i-icon-barrage_fill:before{content:"\e6e4"}.i-icon-barrage:before{content:"\e6e5"}.i-icon-browse_fill:before{content:"\e6e6"}.i-icon-browse:before{content:"\e6e7"}.i-icon-brush:before{content:"\e6e8"}.i-icon-brush_fill:before{content:"\e6e9"}.i-icon-businesscard_fill:before{content:"\e6ea"}.i-icon-businesscard:before{content:"\e6eb"}.i-icon-camera_fill:before{content:"\e6ec"}.i-icon-camera:before{content:"\e6ed"}.i-icon-clock_fill:before{content:"\e6ee"}.i-icon-clock:before{content:"\e6ef"}.i-icon-close:before{content:"\e6f0"}.i-icon-collection_fill:before{content:"\e6f1"}.i-icon-collection:before{content:"\e6f2"}.i-icon-computer_fill:before{content:"\e6f3"}.i-icon-computer:before{content:"\e6f4"}.i-icon-coordinates_fill:before{content:"\e6f5"}.i-icon-coordinates:before{content:"\e6f6"}.i-icon-coupons_fill:before{content:"\e6f7"}.i-icon-coupons:before{content:"\e6f8"}.i-icon-createtask_fill:before{content:"\e6f9"}.i-icon-createtask:before{content:"\e6fa"}.i-icon-customerservice_fill:before{content:"\e6fb"}.i-icon-customerservice:before{content:"\e6fc"}.i-icon-delete_fill:before{content:"\e6fd"}.i-icon-delete:before{content:"\e6fe"}.i-icon-document:before{content:"\e6ff"}.i-icon-document_fill:before{content:"\e700"}.i-icon-dynamic_fill:before{content:"\e701"}.i-icon-dynamic:before{content:"\e702"}.i-icon-editor:before{content:"\e703"}.i-icon-eit:before{content:"\e704"}.i-icon-emoji_fill:before{content:"\e705"}.i-icon-emoji:before{content:"\e706"}.i-icon-enter:before{content:"\e707"}.i-icon-enterinto:before{content:"\e708"}.i-icon-enterinto_fill:before{content:"\e709"}.i-icon-feedback_fill:before{content:"\e70a"}.i-icon-feedback:before{content:"\e70b"}.i-icon-flag_fill:before{content:"\e70c"}.i-icon-flag:before{content:"\e70d"}.i-icon-flashlight:before{content:"\e70e"}.i-icon-flashlight_fill:before{content:"\e70f"}.i-icon-fullscreen:before{content:"\e710"}.i-icon-group:before{content:"\e711"}.i-icon-group_fill:before{content:"\e712"}.i-icon-homepage_fill:before{content:"\e713"}.i-icon-homepage:before{content:"\e714"}.i-icon-integral_fill:before{content:"\e715"}.i-icon-integral:before{content:"\e716"}.i-icon-interactive_fill:before{content:"\e717"}.i-icon-interactive:before{content:"\e718"}.i-icon-keyboard:before{content:"\e719"}.i-icon-label:before{content:"\e71a"}.i-icon-label_fill:before{content:"\e71b"}.i-icon-like_fill:before{content:"\e71c"}.i-icon-like:before{content:"\e71d"}.i-icon-live_fill:before{content:"\e71e"}.i-icon-live:before{content:"\e71f"}.i-icon-lock_fill:before{content:"\e720"}.i-icon-lock:before{content:"\e721"}.i-icon-mail:before{content:"\e722"}.i-icon-mail_fill:before{content:"\e723"}.i-icon-message:before{content:"\e724"}.i-icon-message_fill:before{content:"\e725"}.i-icon-mine:before{content:"\e726"}.i-icon-mine_fill:before{content:"\e727"}.i-icon-mobilephone_fill:before{content:"\e728"}.i-icon-mobilephone:before{content:"\e729"}.i-icon-more:before{content:"\e72a"}.i-icon-narrow:before{content:"\e72b"}.i-icon-offline_fill:before{content:"\e72c"}.i-icon-offline:before{content:"\e72d"}.i-icon-other:before{content:"\e72e"}.i-icon-picture_fill:before{content:"\e72f"}.i-icon-picture:before{content:"\e730"}.i-icon-play:before{content:"\e731"}.i-icon-play_fill:before{content:"\e732"}.i-icon-playon_fill:before{content:"\e733"}.i-icon-playon:before{content:"\e734"}.i-icon-praise_fill:before{content:"\e735"}.i-icon-praise:before{content:"\e736"}.i-icon-prompt_fill:before{content:"\e737"}.i-icon-prompt:before{content:"\e738"}.i-icon-redpacket_fill:before{content:"\e739"}.i-icon-redpacket:before{content:"\e73a"}.i-icon-refresh:before{content:"\e73b"}.i-icon-remind_fill:before{content:"\e73c"}.i-icon-remind:before{content:"\e73d"}.i-icon-return:before{content:"\e73e"}.i-icon-right:before{content:"\e73f"}.i-icon-scan:before{content:"\e740"}.i-icon-send:before{content:"\e741"}.i-icon-service_fill:before{content:"\e742"}.i-icon-service:before{content:"\e743"}.i-icon-setup_fill:before{content:"\e744"}.i-icon-setup:before{content:"\e745"}.i-icon-share_fill:before{content:"\e746"}.i-icon-share:before{content:"\e747"}.i-icon-success_fill:before{content:"\e748"}.i-icon-success:before{content:"\e749"}.i-icon-suspend:before{content:"\e74a"}.i-icon-switch:before{content:"\e74b"}.i-icon-systemprompt_fill:before{content:"\e74c"}.i-icon-systemprompt:before{content:"\e74d"}.i-icon-tailor:before{content:"\e74e"}.i-icon-task:before{content:"\e74f"}.i-icon-task_fill:before{content:"\e750"}.i-icon-tasklist_fill:before{content:"\e751"}.i-icon-tasklist:before{content:"\e752"}.i-icon-time_fill:before{content:"\e753"}.i-icon-time:before{content:"\e754"}.i-icon-translation_fill:before{content:"\e755"}.i-icon-translation:before{content:"\e756"}.i-icon-trash:before{content:"\e757"}.i-icon-trash_fill:before{content:"\e758"}.i-icon-undo:before{content:"\e759"}.i-icon-video:before{content:"\e75a"}.i-icon-video_fill:before{content:"\e75b"}.i-icon-warning_fill:before{content:"\e75c"}.i-icon-warning:before{content:"\e75d"}.i-icon-search:before{content:"\e75e"}.i-icon-searchfill:before{content:"\e75f"}.i-icon-publishgoods_fill:before{content:"\e760"}.i-icon-shop_fill:before{content:"\e761"}.i-icon-transaction_fill:before{content:"\e762"}.i-icon-packup:before{content:"\e763"}.i-icon-unfold:before{content:"\e764"}.i-icon-financial_fill:before{content:"\e765"}.i-icon-commodity:before{content:"\e766"} \ No newline at end of file diff --git a/miniprogram/dist/index-item/index.js b/miniprogram/dist/index-item/index.js new file mode 100644 index 0000000..ed818df --- /dev/null +++ b/miniprogram/dist/index-item/index.js @@ -0,0 +1,32 @@ +Component({ + externalClasses: ['i-class'], + properties : { + name : { + type : String, + value : '' + } + }, + relations : { + '../index/index' : { + type : 'parent' + } + }, + data : { + top : 0, + height : 0, + currentName : '' + }, + methods: { + updateDataChange() { + const className = '.i-index-item'; + const query = wx.createSelectorQuery().in(this); + query.select( className ).boundingClientRect((res)=>{ + this.setData({ + top : res.top, + height : res.height, + currentName : this.data.name + }) + }).exec() + } + } +}) \ No newline at end of file diff --git a/miniprogram/dist/index-item/index.json b/miniprogram/dist/index-item/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/index-item/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/index-item/index.wxml b/miniprogram/dist/index-item/index.wxml new file mode 100644 index 0000000..8986c8d --- /dev/null +++ b/miniprogram/dist/index-item/index.wxml @@ -0,0 +1,11 @@ + + {{name}} + + + + + + module.exports = { + + } + diff --git a/miniprogram/dist/index-item/index.wxss b/miniprogram/dist/index-item/index.wxss new file mode 100644 index 0000000..aeecf8d --- /dev/null +++ b/miniprogram/dist/index-item/index.wxss @@ -0,0 +1 @@ +.i-index-item-header{height:30px;line-height:30px;background:#eee;font-size:14px;padding-left:10px;width:100%;box-sizing:border-box}.i-index-item-content{font-size:14px} \ No newline at end of file diff --git a/miniprogram/dist/index/index.js b/miniprogram/dist/index/index.js new file mode 100644 index 0000000..c556f19 --- /dev/null +++ b/miniprogram/dist/index/index.js @@ -0,0 +1,158 @@ +Component({ + externalClasses: ['i-class'], + properties : { + height : { + type : String, + value : '300' + }, + itemHeight : { + type : Number, + value : 18 + } + }, + relations : { + '../index-item/index' : { + type : 'child', + linked(){ + this._updateDataChange(); + }, + linkChanged () { + this._updateDataChange(); + }, + unlinked () { + this._updateDataChange(); + } + } + }, + data : { + scrollTop : 0, + fixedData : [], + current : 0, + timer : null, + startTop : 0, + itemLength : 0, + currentName : '', + isTouches : false + }, + methods : { + loop(){}, + _updateDataChange( ){ + const indexItems = this.getRelationNodes('../index-item/index'); + const len = indexItems.length; + const fixedData = this.data.fixedData; + /* + * 使用函数节流限制重复去设置数组内容进而限制多次重复渲染 + * 暂时没有研究微信在渲染的时候是否会进行函数节流 + */ + if (len > 0) { + + if( this.data.timer ){ + clearTimeout( this.data.timer ) + this.setData({ + timer : null + }) + } + + this.data.timer = setTimeout(()=>{ + const data = []; + indexItems.forEach((item) => { + if( item.data.name && fixedData.indexOf( item.data.name ) === -1 ){ + data.push(item.data.name); + item.updateDataChange(); + } + }) + this.setData({ + fixedData : data, + itemLength : indexItems.length + }) + //组件加载完成之后重新设置顶部高度 + this.setTouchStartVal(); + },0); + this.setData({ + timer : this.data.timer + }) + + } + }, + handlerScroll(event){ + const detail = event.detail; + const scrollTop = detail.scrollTop; + const indexItems = this.getRelationNodes('../index-item/index'); + indexItems.forEach((item,index)=>{ + let data = item.data; + let offset = data.top + data.height; + if( scrollTop < offset && scrollTop >= data.top ){ + this.setData({ + current : index, + currentName : data.currentName + }) + } + }) + }, + getCurrentItem(index){ + const indexItems = this.getRelationNodes('../index-item/index'); + let result = {}; + result = indexItems[index].data; + result.total = indexItems.length; + return result; + }, + triggerCallback(options){ + this.triggerEvent('change',options) + }, + handlerFixedTap(event){ + const eindex = event.currentTarget.dataset.index; + const item = this.getCurrentItem(eindex); + this.setData({ + scrollTop : item.top, + currentName : item.currentName, + isTouches : true + }) + this.triggerCallback({ + index : eindex, + current : item.currentName + }) + }, + handlerTouchMove(event){ + const data = this.data; + const touches = event.touches[0] || {}; + const pageY = touches.pageY; + const rest = pageY - data.startTop; + let index = Math.ceil( rest/data.itemHeight ); + index = index >= data.itemLength ? data.itemLength -1 : index; + const movePosition = this.getCurrentItem(index); + + /* + * 当touch选中的元素和当前currentName不相等的时候才震动一下 + * 微信震动事件 + */ + if( movePosition.name !== this.data.currentName ){ + wx.vibrateShort(); + } + + this.setData({ + scrollTop : movePosition.top, + currentName : movePosition.name, + isTouches : true + }) + + this.triggerCallback({ + index : index, + current : movePosition.name + }) + }, + handlerTouchEnd(){ + this.setData({ + isTouches : false + }) + }, + setTouchStartVal(){ + const className = '.i-index-fixed'; + const query = wx.createSelectorQuery().in(this); + query.select( className ).boundingClientRect((res)=>{ + this.setData({ + startTop : res.top + }) + }).exec() + } + } +}) \ No newline at end of file diff --git a/miniprogram/dist/index/index.json b/miniprogram/dist/index/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/index/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/index/index.wxml b/miniprogram/dist/index/index.wxml new file mode 100644 index 0000000..f83d847 --- /dev/null +++ b/miniprogram/dist/index/index.wxml @@ -0,0 +1,38 @@ + + + + + + {{item}} + + + {{currentName}} + + + + module.exports = { + setScrollStyle : function(height){ + var units = ['%','px','rem','rpx','em','rem']; + var hasUnits = false; + for( var i = 0; i < units.length;i++ ){ + var u = units[i]; + if( height.indexOf( u ) > -1 ){ + hasUnits = true; + break; + } + } + return 'height:'+ ( hasUnits ? height : height+'px' ); + } + } + diff --git a/miniprogram/dist/index/index.wxss b/miniprogram/dist/index/index.wxss new file mode 100644 index 0000000..c0887c1 --- /dev/null +++ b/miniprogram/dist/index/index.wxss @@ -0,0 +1 @@ +.i-index{width:100%;height:100%}.i-index-line{position:absolute;left:0;width:100%;height:1rpx;background-color:#f7f7f7;top:50%}.i-index-content{background:#fff;position:relative;z-index:1;display:inline-block;padding:0 10px}.i-index-fixed{position:fixed;right:0;top:50%;z-index:10;padding-left:10px;transform:translateY(-50%)}.i-index-fixed-item{display:block;height:18px;line-height:18px;padding:0 5px;text-align:center;color:#2d8cf0;font-size:12px;border-radius:50%}.i-index-fixed-item-current{background:#2d8cf0;color:#fff}.i-index-tooltip{position:fixed;left:50%;top:50%;transform:translate3d(-50%,-50%,0);background:rgba(0,0,0,.7);color:#fff;font-size:24px;border-radius:50%;width:80px;height:80px;line-height:80px;text-align:center} \ No newline at end of file diff --git a/miniprogram/dist/input-number/index.js b/miniprogram/dist/input-number/index.js new file mode 100644 index 0000000..7a7d3f5 --- /dev/null +++ b/miniprogram/dist/input-number/index.js @@ -0,0 +1,101 @@ +function addNum (num1, num2) { + let sq1, sq2, m; + try { + sq1 = num1.toString().split('.')[1].length; + } + catch (e) { + sq1 = 0; + } + try { + sq2 = num2.toString().split('.')[1].length; + } + catch (e) { + sq2 = 0; + } + m = Math.pow(10, Math.max(sq1, sq2)); + return (Math.round(num1 * m) + Math.round(num2 * m)) / m; +} + +Component({ + externalClasses: ['i-class'], + + properties: { + // small || default || large + size: String, + value: { + type: Number, + value: 1 + }, + min: { + type: Number, + value: -Infinity + }, + max: { + type: Number, + value: Infinity + }, + step: { + type: Number, + value: 1 + } + }, + + + methods: { + handleChangeStep(e, type) { + const { dataset = {} } = e.currentTarget; + const { disabled } = dataset; + const { step } = this.data; + let { value } = this.data; + + if (disabled) return null; + + if (type === 'minus') { + value = addNum(value, -step); + } else if (type === 'plus') { + value = addNum(value, step); + } + + if (value < this.data.min || value > this.data.max) return null; + + this.handleEmit(value, type); + }, + + handleMinus(e) { + this.handleChangeStep(e, 'minus'); + }, + + handlePlus(e) { + this.handleChangeStep(e, 'plus'); + }, + + handleBlur(e) { + let { value } = e.detail; + const { min, max } = this.data; + + if (!value) { + setTimeout(() => { + this.handleEmit(value); + }, 16); + return; + } + + value = +value; + if (value > max) { + value = max; + } else if (value < min) { + value = min; + } + + this.handleEmit(value); + }, + handleEmit (value, type) { + const data = { + value: value + }; + if (type) data.type = type; + + this.triggerEvent('change', data); + } + } +}); diff --git a/miniprogram/dist/input-number/index.json b/miniprogram/dist/input-number/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/input-number/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/input-number/index.wxml b/miniprogram/dist/input-number/index.wxml new file mode 100644 index 0000000..b3503f4 --- /dev/null +++ b/miniprogram/dist/input-number/index.wxml @@ -0,0 +1,5 @@ + + - + + + + diff --git a/miniprogram/dist/input-number/index.wxss b/miniprogram/dist/input-number/index.wxss new file mode 100644 index 0000000..f696bb4 --- /dev/null +++ b/miniprogram/dist/input-number/index.wxss @@ -0,0 +1 @@ +.i-input-number{color:#495060}.i-input-number view{display:inline-block;line-height:20px;padding:5px 0;text-align:center;min-width:40px;box-sizing:border-box;vertical-align:middle;font-size:12px;border:1rpx solid #dddee1}.i-input-number-minus{border-right:none;border-radius:2px 0 0 2px}.i-input-number-plus{border-left:none;border-radius:0 2px 2px 0}.i-input-number-text{border:1rpx solid #dddee1;display:inline-block;text-align:center;vertical-align:middle;height:30px;width:40px;min-height:auto;font-size:12px;line-height:30px}.i-input-number-disabled{border-color:#dddee1;color:#bbbec4;background:#f7f7f7} \ No newline at end of file diff --git a/miniprogram/dist/input/index.js b/miniprogram/dist/input/index.js new file mode 100644 index 0000000..c9d4c41 --- /dev/null +++ b/miniprogram/dist/input/index.js @@ -0,0 +1,61 @@ +Component({ + behaviors: ['wx://form-field'], + + externalClasses: ['i-class'], + + properties: { + title: { + type: String + }, + // text || textarea || password || number + type: { + type: String, + value: 'text' + }, + disabled: { + type: Boolean, + value: false + }, + placeholder: { + type: String, + value: '' + }, + autofocus: { + type: Boolean, + value: false + }, + mode: { + type: String, + value: 'normal' + }, + right: { + type: Boolean, + value: false + }, + error: { + type: Boolean, + value: false + }, + maxlength: { + type: Number + } + }, + + methods: { + handleInputChange(event) { + const { detail = {} } = event; + const { value = '' } = detail; + this.setData({ value }); + + this.triggerEvent('change', event); + }, + + handleInputFocus(event) { + this.triggerEvent('focus', event); + }, + + handleInputBlur(event) { + this.triggerEvent('blur', event); + } + } +}); diff --git a/miniprogram/dist/input/index.json b/miniprogram/dist/input/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/input/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/input/index.wxml b/miniprogram/dist/input/index.wxml new file mode 100644 index 0000000..52b0ee3 --- /dev/null +++ b/miniprogram/dist/input/index.wxml @@ -0,0 +1,31 @@ + + {{ title }} + + + diff --git a/miniprogram/dist/input/index.wxss b/miniprogram/dist/input/index.wxss new file mode 100644 index 0000000..9e7e9c1 --- /dev/null +++ b/miniprogram/dist/input/index.wxss @@ -0,0 +1 @@ +.i-cell{position:relative;padding:12px 15px;display:flex;background:#fff;align-items:center;line-height:1.4;font-size:14px;overflow:hidden}.i-cell::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e9eaec;border-bottom-width:1px;left:15px;right:0}.i-cell-last::after{display:none}.i-cell-icon{margin-right:5px}.i-cell-icon:empty{display:none}.i-cell-bd{flex:1}.i-cell-text{line-height:24px;font-size:14px}.i-cell-desc{line-height:1.2;font-size:12px;color:#80848f}.i-cell-ft{position:relative;text-align:right;color:#495060}.i-cell-access .i-cell-ft{padding-right:13px}.i-cell-access .i-cell-ft::after{content:" ";display:inline-block;width:6px;height:6px;position:absolute;top:50%;right:2px;border-width:2px 2px 0 0;border-color:#dddee1;border-style:solid;transform:translateY(-50%) matrix(.71,.71,-.71,.71,0,0)}.i-input{padding:7px 15px;color:#495060}.i-input-wrapped{margin:10px 15px;background-color:#fff}.i-input-wrapped::after{left:0;border-width:1px;border-radius:4px}.i-input-error{color:#ed3f14}.i-input-title{color:#495060;min-width:65px;padding-right:10px}.i-input-input{flex:1;line-height:1.6;padding:4px 0;min-height:22px;height:auto;font-size:14px}.i-input-placeholder{font-size:14px}.i-input-input-right{text-align:right}.i-input.i-input-wrapped::after{display:block}.i-input-wrapped.i-input-error::after{border-color:#ed3f14} \ No newline at end of file diff --git a/miniprogram/dist/load-more/index.js b/miniprogram/dist/load-more/index.js new file mode 100644 index 0000000..d0cd46c --- /dev/null +++ b/miniprogram/dist/load-more/index.js @@ -0,0 +1,14 @@ +Component({ + externalClasses: ['i-class'], + + properties: { + loading: { + type: Boolean, + value: true + }, + tip: { + type: String, + value: '' + } + }, +}); diff --git a/miniprogram/dist/load-more/index.json b/miniprogram/dist/load-more/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/load-more/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/load-more/index.wxml b/miniprogram/dist/load-more/index.wxml new file mode 100644 index 0000000..66571af --- /dev/null +++ b/miniprogram/dist/load-more/index.wxml @@ -0,0 +1,8 @@ + + + + {{ tip }} + 正在加载 + + + \ No newline at end of file diff --git a/miniprogram/dist/load-more/index.wxss b/miniprogram/dist/load-more/index.wxss new file mode 100644 index 0000000..ffe4026 --- /dev/null +++ b/miniprogram/dist/load-more/index.wxss @@ -0,0 +1 @@ +.i-load-more{width:65%;margin:1.5em auto;line-height:1.6em;font-size:14px;text-align:center}.i-load-more-loading{display:inline-block;margin-right:12px;vertical-align:middle;width:14px;height:14px;background:0 0;border-radius:50%;border:2px solid #e9eaec;border-color:#e9eaec #e9eaec #e9eaec #2d8cf0;animation:btn-spin .6s linear;animation-iteration-count:infinite}.i-load-more-tip{display:inline-block;vertical-align:middle;color:#495060}.i-load-more-line{border-top:1px solid #dddee1;display:flex;border-top:0}.i-load-more-line::before{position:relative;top:-1px;-webkit-box-flex:1;-webkit-flex:1;flex:1;content:'';border-top:1px solid #dddee1}.i-load-more-line::after{position:relative;top:-1px;-webkit-box-flex:1;-webkit-flex:1;flex:1;content:'';border-top:1px solid #dddee1}.i-load-more-line .i-load-more-tip{position:relative;top:-.9em;padding:0 .55em}.i-load-more-empty{width:4px;height:4px;border-radius:50%;background-color:#e5e5e5;display:inline-block;position:relative;vertical-align:0;top:-.16em}@keyframes btn-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}} \ No newline at end of file diff --git a/miniprogram/dist/message/index.js b/miniprogram/dist/message/index.js new file mode 100644 index 0000000..21a6d68 --- /dev/null +++ b/miniprogram/dist/message/index.js @@ -0,0 +1,45 @@ +const default_data = { + visible: false, + content: '', + duration: 2, + type: 'default', // default || success || warning || error +}; + +let timmer = null; + +Component({ + externalClasses: ['i-class'], + + data: { + ...default_data + }, + + methods: { + handleShow (options) { + const { type = 'default', duration = 2 } = options; + + this.setData({ + ...options, + type, + duration, + visible: true + }); + + const d = this.data.duration * 1000; + + if (timmer) clearTimeout(timmer); + if (d !== 0) { + timmer = setTimeout(() => { + this.handleHide(); + timmer = null; + }, d); + } + }, + + handleHide () { + this.setData({ + ...default_data + }); + } + } +}); \ No newline at end of file diff --git a/miniprogram/dist/message/index.json b/miniprogram/dist/message/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/message/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/message/index.wxml b/miniprogram/dist/message/index.wxml new file mode 100644 index 0000000..aecaad9 --- /dev/null +++ b/miniprogram/dist/message/index.wxml @@ -0,0 +1,3 @@ + + {{ content }} + \ No newline at end of file diff --git a/miniprogram/dist/message/index.wxss b/miniprogram/dist/message/index.wxss new file mode 100644 index 0000000..e6a79a6 --- /dev/null +++ b/miniprogram/dist/message/index.wxss @@ -0,0 +1 @@ +.i-message{display:block;width:100%;min-height:32px;line-height:2.3;position:fixed;top:0;left:0;right:0;background:#2d8cf0;color:#fff;text-align:center;font-size:14px;z-index:1010;opacity:0;-webkit-transform:translateZ(0) translateY(-100%);transition:all .4s ease-in-out}.i-message-show{-webkit-transform:translateZ(0) translateY(0);opacity:1}.i-message-default{background:#2d8cf0}.i-message-success{background:#19be6b}.i-message-warning{background:#f90}.i-message-error{background:#ed3f14} \ No newline at end of file diff --git a/miniprogram/dist/modal/index.js b/miniprogram/dist/modal/index.js new file mode 100644 index 0000000..ae178e5 --- /dev/null +++ b/miniprogram/dist/modal/index.js @@ -0,0 +1,54 @@ +Component({ + externalClasses: ['i-class', 'i-class-mask'], + + properties: { + visible: { + type: Boolean, + value: false + }, + title: { + type: String, + value: '' + }, + showOk: { + type: Boolean, + value: true + }, + showCancel: { + type: Boolean, + value: true + }, + okText: { + type: String, + value: '确定' + }, + cancelText: { + type: String, + value: '取消' + }, + // 按钮组,有此值时,不显示 ok 和 cancel 按钮 + actions: { + type: Array, + value: [] + }, + // horizontal || vertical + actionMode: { + type: String, + value: 'horizontal' + } + }, + + methods: { + handleClickItem ({ currentTarget = {} }) { + const dataset = currentTarget.dataset || {}; + const { index } = dataset; + this.triggerEvent('click', { index }); + }, + handleClickOk () { + this.triggerEvent('ok'); + }, + handleClickCancel () { + this.triggerEvent('cancel'); + } + } +}); diff --git a/miniprogram/dist/modal/index.json b/miniprogram/dist/modal/index.json new file mode 100644 index 0000000..50d034a --- /dev/null +++ b/miniprogram/dist/modal/index.json @@ -0,0 +1,9 @@ +{ + "component": true, + "usingComponents": { + "i-grid": "../grid/index", + "i-grid-item": "../grid-item/index", + "i-button": "../button/index", + "i-icon": "../icon/index" + } +} diff --git a/miniprogram/dist/modal/index.wxml b/miniprogram/dist/modal/index.wxml new file mode 100644 index 0000000..11bcbd4 --- /dev/null +++ b/miniprogram/dist/modal/index.wxml @@ -0,0 +1,40 @@ + + + + + {{ title }} + + + + + + + + + + + + + + + + + + + {{ cancelText }} + + + {{ okText }} + + + + + + + \ No newline at end of file diff --git a/miniprogram/dist/modal/index.wxss b/miniprogram/dist/modal/index.wxss new file mode 100644 index 0000000..d1c42fc --- /dev/null +++ b/miniprogram/dist/modal/index.wxss @@ -0,0 +1 @@ +.i-modal{position:fixed;overflow:auto;top:0;right:0;bottom:0;left:0;height:100%;z-index:1000;display:flex;outline:0;-webkit-box-align:center;align-items:center;-webkit-box-pack:center;justify-content:center;transform:translateZ(1px);opacity:0;visibility:hidden}.i-modal-show{visibility:visible;opacity:1}.i-modal-mask{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,.7);z-index:1000;transition:all .2s ease-in-out;opacity:0;visibility:hidden}.i-modal-mask-show{opacity:1;visibility:visible}.i-modal-main{width:270px;position:relative}.i-modal-content{border-radius:7px;padding-top:15px;position:relative;background-color:#fff;border:0;background-clip:padding-box;text-align:center;height:100%;overflow:hidden}.i-modal-body{max-height:100px;margin-bottom:15px;font-size:14px;color:#80848f;height:100%;line-height:1.5;overflow:auto}.i-modal-title{padding:6px 15px 15px;margin:0;font-size:18px;line-height:1;color:#1c2438;text-align:center}.i-modal-actions{margin:0 1px}.i-modal-action-vertical{position:relative}.i-modal-action-vertical:after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e9eaec;border-top-width:1px}.i-modal-grid{border-radius:0 0 7px 7px;border-left:none}.i-modal-grid-item,.i-modal-grid-item-last{padding:0;border-bottom:none}.i-modal-grid-item-last{border-right:none}.i-modal-btn-ok{color:#2d8cf0!important}.i-modal-btn-loading{display:inline-block;vertical-align:middle;margin-right:10px;width:12px;height:12px;background:0 0;border-radius:50%;border:2px solid #e5e5e5;border-color:#666 #e5e5e5 #e5e5e5 #e5e5e5;animation:btn-spin .6s linear;animation-iteration-count:infinite}.i-modal-btn-text{display:inline-block;vertical-align:middle}.i-modal-btn-icon{font-size:14px!important;margin-right:4px}@keyframes btn-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}} \ No newline at end of file diff --git a/miniprogram/dist/notice-bar/index.js b/miniprogram/dist/notice-bar/index.js new file mode 100644 index 0000000..7043dbd --- /dev/null +++ b/miniprogram/dist/notice-bar/index.js @@ -0,0 +1,112 @@ +const VALID_MODE = ['closeable']; +const FONT_COLOR = '#f60'; +const BG_COLOR = '#fff7cc'; + +Component({ + externalClasses: ['i-class'], + + properties: { + closable: { + type: Boolean, + value: false + }, + icon: { + type: String, + value: '' + }, + loop: { + type: Boolean, + value: false + }, + // 背景颜色 + backgroundcolor: { + type: String, + value: '#fefcec' + }, + // 字体及图标颜色 + color: { + type: String, + value: '#f76a24' + }, + // 滚动速度 + speed: { + type: Number, + value: 1000 + } + }, + + data: { + show: true, + wrapWidth: 0, + width: 0, + duration: 0, + animation: null, + timer: null, + }, + detached() { + this.destroyTimer(); + }, + ready() { + if (this.data.loop) { + this.initAnimation(); + } + }, + + methods: { + initAnimation() { + wx.createSelectorQuery().in(this).select('.i-noticebar-content-wrap').boundingClientRect((wrapRect) => { + wx.createSelectorQuery().in(this).select('.i-noticebar-content').boundingClientRect((rect) => { + const duration = rect.width / 40 * this.data.speed; + const animation = wx.createAnimation({ + duration: duration, + timingFunction: "linear", + }); + this.setData({ + wrapWidth: wrapRect.width, + width: rect.width, + duration: duration, + animation: animation + }, () => { + this.startAnimation(); + }); + }).exec(); + + }).exec(); + }, + startAnimation() { + //reset + if (this.data.animation.option.transition.duration !== 0) { + this.data.animation.option.transition.duration = 0; + const resetAnimation = this.data.animation.translateX(this.data.wrapWidth).step(); + this.setData({ + animationData: resetAnimation.export() + }); + } + this.data.animation.option.transition.duration = this.data.duration; + const animationData = this.data.animation.translateX(-this.data.width).step(); + setTimeout(() => { + this.setData({ + animationData: animationData.export() + }); + }, 100); + const timer = setTimeout(() => { + this.startAnimation(); + }, this.data.duration); + this.setData({ + timer, + }); + }, + destroyTimer() { + if (this.data.timer) { + clearTimeout(this.data.timer); + } + }, + handleClose() { + this.destroyTimer(); + this.setData({ + show: false, + timer: null + }); + } + } +}); diff --git a/miniprogram/dist/notice-bar/index.json b/miniprogram/dist/notice-bar/index.json new file mode 100644 index 0000000..db3afc0 --- /dev/null +++ b/miniprogram/dist/notice-bar/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": + { + "i-icon": "../icon/index" + } +} diff --git a/miniprogram/dist/notice-bar/index.wxml b/miniprogram/dist/notice-bar/index.wxml new file mode 100644 index 0000000..5de1e11 --- /dev/null +++ b/miniprogram/dist/notice-bar/index.wxml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/miniprogram/dist/notice-bar/index.wxss b/miniprogram/dist/notice-bar/index.wxss new file mode 100644 index 0000000..9ea2aa7 --- /dev/null +++ b/miniprogram/dist/notice-bar/index.wxss @@ -0,0 +1 @@ +.i-noticebar{display:flex;height:72rpx;line-height:72rpx;font-size:14px;color:#f76a24;background-color:#fefcec;overflow:hidden}.i-noticebar-icon{display:flex;margin-left:30rpx;align-items:center}.i-noticebar-icon+view{margin-left:10rpx}.i-noticebar-operation{display:flex;margin-right:16rpx;align-items:center}.i-noticebar-content-wrap{position:relative;flex:1;margin:0 30rpx;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.i-noticebar-content-wrap .i-noticebar-content{position:absolute;transition-duration:20s} \ No newline at end of file diff --git a/miniprogram/dist/page/index.js b/miniprogram/dist/page/index.js new file mode 100644 index 0000000..e0f44c5 --- /dev/null +++ b/miniprogram/dist/page/index.js @@ -0,0 +1,42 @@ +Component({ + externalClasses: ['i-class'], + + options: { + multipleSlots: true + }, + + properties: { + // button || number || pointer + mode: { + type: String, + value: 'button' + }, + current: { + type: Number, + value: 1 + }, + total: { + type: Number, + value: 0 + }, + // 是否隐藏数值 + simple: { + type: Boolean, + value: false + } + }, + + methods: { + handleChange (type) { + this.triggerEvent('change', { + type: type + }); + }, + handlePrev () { + this.handleChange('prev'); + }, + handleNext () { + this.handleChange('next'); + } + } +}); diff --git a/miniprogram/dist/page/index.json b/miniprogram/dist/page/index.json new file mode 100644 index 0000000..7b1a128 --- /dev/null +++ b/miniprogram/dist/page/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": + { + "i-button": "../button/index" + } +} diff --git a/miniprogram/dist/page/index.wxml b/miniprogram/dist/page/index.wxml new file mode 100644 index 0000000..a84d47b --- /dev/null +++ b/miniprogram/dist/page/index.wxml @@ -0,0 +1,14 @@ + + + + + + {{ current }}/{{total}} + + + + + + + + diff --git a/miniprogram/dist/page/index.wxss b/miniprogram/dist/page/index.wxss new file mode 100644 index 0000000..06c5c3b --- /dev/null +++ b/miniprogram/dist/page/index.wxss @@ -0,0 +1 @@ +.i-page{display:block;width:100%;height:44px;overflow:hidden;box-sizing:border-box;position:relative}.i-page-prev{position:absolute;left:10px;top:0}.i-page-next{position:absolute;right:10px;top:0}.i-page-number{width:100%;height:44px;line-height:44px;margin:0 auto;text-align:center}.i-page-number-current{display:inline;color:#2d8cf0}.i-page-pointer{width:100%;height:44px;line-height:44px;margin:0 auto;text-align:center}.i-page-pointer-dot{display:inline-block;width:8px;height:8px;margin:0 2px;border-radius:50%;background:#bbbec4}.i-page-pointer-dot.current{background:#80848f}.i-page-button{display:inline-block;margin:0} \ No newline at end of file diff --git a/miniprogram/dist/panel/index.js b/miniprogram/dist/panel/index.js new file mode 100644 index 0000000..b572da5 --- /dev/null +++ b/miniprogram/dist/panel/index.js @@ -0,0 +1,19 @@ +Component({ + externalClasses: ['i-class'], + + properties: { + title: { + type: String, + value: '' + }, + // 标题顶部距离 + hideTop: { + type: Boolean, + value: false + }, + hideBorder: { + type: Boolean, + value: false + } + } +}); diff --git a/miniprogram/dist/panel/index.json b/miniprogram/dist/panel/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/panel/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/panel/index.wxml b/miniprogram/dist/panel/index.wxml new file mode 100644 index 0000000..aa91c20 --- /dev/null +++ b/miniprogram/dist/panel/index.wxml @@ -0,0 +1,4 @@ + + {{ title }} + + diff --git a/miniprogram/dist/panel/index.wxss b/miniprogram/dist/panel/index.wxss new file mode 100644 index 0000000..edee3b8 --- /dev/null +++ b/miniprogram/dist/panel/index.wxss @@ -0,0 +1 @@ +.i-panel{position:relative;overflow:hidden}.i-panel-title{font-size:14px;line-height:1;color:#1c2438;padding:20px 16px 10px}.i-panel-title-hide-top{padding-top:0}.i-panel-content{position:relative;background:#fff;overflow:hidden}.i-panel-content::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e9eaec;border-top-width:1px;border-bottom-width:1px}.i-panel-without-border::after{border:0 none} \ No newline at end of file diff --git a/miniprogram/dist/progress/index.js b/miniprogram/dist/progress/index.js new file mode 100644 index 0000000..b87b962 --- /dev/null +++ b/miniprogram/dist/progress/index.js @@ -0,0 +1,23 @@ +Component({ + externalClasses: ['i-class'], + + properties: { + percent: { + type: Number, + value: 0 + }, + // normal || active || wrong || success + status: { + type: String, + value: 'normal' + }, + strokeWidth: { + type: Number, + value: 10 + }, + hideInfo: { + type: Boolean, + value: false + } + } +}); diff --git a/miniprogram/dist/progress/index.json b/miniprogram/dist/progress/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/progress/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/progress/index.wxml b/miniprogram/dist/progress/index.wxml new file mode 100644 index 0000000..09b5abc --- /dev/null +++ b/miniprogram/dist/progress/index.wxml @@ -0,0 +1,10 @@ + + + + + + + + {{ percent }}% + + \ No newline at end of file diff --git a/miniprogram/dist/progress/index.wxss b/miniprogram/dist/progress/index.wxss new file mode 100644 index 0000000..21b9d9c --- /dev/null +++ b/miniprogram/dist/progress/index.wxss @@ -0,0 +1 @@ +.i-progress{display:inline-block;width:100%;font-size:12px;position:relative}.i-progress-outer{display:inline-block;width:100%;margin-right:0;padding-right:0;box-sizing:border-box}.i-progress-show-info .i-progress-outer{padding-right:55px;margin-right:-55px}.i-progress-inner{display:inline-block;width:100%;background-color:#f3f3f3;border-radius:100px;vertical-align:middle}.i-progress-bg{border-radius:100px;background-color:#2db7f5;transition:all .2s linear;position:relative}.i-progress-text{display:inline-block;margin-left:5px;text-align:left;font-size:1em;vertical-align:middle}.i-progress-active .i-progress-bg:before{content:'';opacity:0;position:absolute;top:0;left:0;right:0;bottom:0;background:#fff;border-radius:10px;animation:i-progress-active 2s ease-in-out infinite}.i-progress-wrong .i-progress-bg{background-color:#ed3f14}.i-progress-wrong .i-progress-text{color:#ed3f14}.i-progress-success .i-progress-bg{background-color:#19be6b}.i-progress-success .i-progress-text{color:#19be6b}@keyframes i-progress-active{0%{opacity:.3;width:0}100%{opacity:0;width:100%}} \ No newline at end of file diff --git a/miniprogram/dist/radio-group/index.js b/miniprogram/dist/radio-group/index.js new file mode 100644 index 0000000..db76e41 --- /dev/null +++ b/miniprogram/dist/radio-group/index.js @@ -0,0 +1,38 @@ +Component({ + externalClasses: ['i-class'], + relations: { + '../radio/index': { + type: 'child', + linked() { + this.changeCurrent(); + }, + linkChanged() { + this.changeCurrent(); + }, + unlinked() { + this.changeCurrent(); + } + } + }, + properties: { + current: { + type: String, + value: '', + observer: 'changeCurrent' + }, + }, + methods: { + changeCurrent(val = this.data.current) { + let items = this.getRelationNodes('../radio/index'); + const len = items.length; + if (len > 0) { + items.forEach(item => { + item.changeCurrent(val === item.data.value); + }); + } + }, + emitEvent(current) { + this.triggerEvent('change', current); + } + } +}); diff --git a/miniprogram/dist/radio-group/index.json b/miniprogram/dist/radio-group/index.json new file mode 100644 index 0000000..edf138d --- /dev/null +++ b/miniprogram/dist/radio-group/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": + { + "i-cell-group": "../cell-group/index" + } +} diff --git a/miniprogram/dist/radio-group/index.wxml b/miniprogram/dist/radio-group/index.wxml new file mode 100644 index 0000000..6940180 --- /dev/null +++ b/miniprogram/dist/radio-group/index.wxml @@ -0,0 +1,3 @@ + + + diff --git a/miniprogram/dist/radio-group/index.wxss b/miniprogram/dist/radio-group/index.wxss new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram/dist/radio/index.js b/miniprogram/dist/radio/index.js new file mode 100644 index 0000000..cb73db5 --- /dev/null +++ b/miniprogram/dist/radio/index.js @@ -0,0 +1,56 @@ +const prefixCls = 'i-radio'; + +Component({ + externalClasses: ['i-class'], + relations: { + '../radio-group/index': { + type: 'parent' + } + }, + properties: { + value: { + type: String, + value: '' + }, + checked: { + type: Boolean, + value: false + }, + disabled: { + type: Boolean, + value: false + }, + color: { + type: String, + value: '#2d8cf0' + }, + position: { + type: String, + value: 'left', //left right + observer: 'setPosition' + } + }, + data: { + checked: true, + positionCls: `${prefixCls}-radio-left`, + }, + attached() { + this.setPosition(); + }, + methods: { + changeCurrent(current) { + this.setData({ checked: current }); + }, + radioChange() { + if (this.data.disabled) return; + const item = { current: !this.data.checked, value: this.data.value }; + const parent = this.getRelationNodes('../radio-group/index')[0]; + parent ? parent.emitEvent(item) : this.triggerEvent('change', item); + }, + setPosition() { + this.setData({ + positionCls: this.data.position.indexOf('left') !== -1 ? `${prefixCls}-radio-left` : `${prefixCls}-radio-right`, + }); + } + } +}); diff --git a/miniprogram/dist/radio/index.json b/miniprogram/dist/radio/index.json new file mode 100644 index 0000000..e2ab49a --- /dev/null +++ b/miniprogram/dist/radio/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": + { + "i-cell": "../cell/index" + } +} diff --git a/miniprogram/dist/radio/index.wxml b/miniprogram/dist/radio/index.wxml new file mode 100644 index 0000000..1e20b79 --- /dev/null +++ b/miniprogram/dist/radio/index.wxml @@ -0,0 +1,8 @@ + + + + + diff --git a/miniprogram/dist/radio/index.wxss b/miniprogram/dist/radio/index.wxss new file mode 100644 index 0000000..c52b211 --- /dev/null +++ b/miniprogram/dist/radio/index.wxss @@ -0,0 +1 @@ +.i-radio-cell::after{display:block}.i-radio-radio-left{float:left}.i-radio-radio-right{float:right}.i-radio-radio{vertical-align:middle}.i-radio-title{display:inline-block;vertical-align:middle} \ No newline at end of file diff --git a/miniprogram/dist/rate/index.js b/miniprogram/dist/rate/index.js new file mode 100644 index 0000000..a7e374a --- /dev/null +++ b/miniprogram/dist/rate/index.js @@ -0,0 +1,69 @@ +Component({ + externalClasses: ['i-class'], + properties : { + count : { + type : Number, + value : 5 + }, + value : { + type : Number, + value : 0 + }, + disabled : { + type : Boolean, + value : false + }, + size : { + type : Number, + value : 20 + }, + name : { + type : String, + value : '' + } + }, + data : { + touchesStart : { + pageX : 0 + } + }, + methods : { + handleClick(e){ + const data = this.data; + if( data.disabled ){ + return; + } + const index = e.currentTarget.dataset.index; + this.triggerEvent('change',{ + index : index + 1 + }) + }, + handleTouchMove(e){ + const data = this.data; + if( data.disabled ){ + return; + } + if( !e.changedTouches[0] ){ + return; + } + const movePageX = e.changedTouches[0].pageX; + const space = movePageX - data.touchesStart.pageX; + + if( space <= 0 ){ + return; + } + let setIndex = Math.ceil( space/data.size ); + setIndex = setIndex > data.count ? data.count : setIndex ; + this.triggerEvent('change',{ + index : setIndex + }) + } + }, + ready(){ + const className = '.i-rate'; + var query = wx.createSelectorQuery().in(this) + query.select( className ).boundingClientRect((res)=>{ + this.data.touchesStart.pageX = res.left || 0; + }).exec() + } +}); diff --git a/miniprogram/dist/rate/index.json b/miniprogram/dist/rate/index.json new file mode 100644 index 0000000..687543c --- /dev/null +++ b/miniprogram/dist/rate/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents":{ + "i-icon": "../icon/index" + } +} diff --git a/miniprogram/dist/rate/index.wxml b/miniprogram/dist/rate/index.wxml new file mode 100644 index 0000000..d600660 --- /dev/null +++ b/miniprogram/dist/rate/index.wxml @@ -0,0 +1,23 @@ + + + + + + + + +var prefixCls = 'i-rate'; +module.exports = { + getCurrent : function( value,index ){ + if( index < value ){ + return prefixCls + '-current' + } + } +} + diff --git a/miniprogram/dist/rate/index.wxss b/miniprogram/dist/rate/index.wxss new file mode 100644 index 0000000..e889107 --- /dev/null +++ b/miniprogram/dist/rate/index.wxss @@ -0,0 +1 @@ +.i-rate{margin:0;padding:0;font-size:20px;display:inline-block;vertical-align:middle;font-weight:400;font-style:normal}.i-rate-hide-input{display:none}.i-rate-star{display:inline-block;color:#e9e9e9}.i-rate-current{color:#f5a623}.i-rate-text{display:inline-block;vertical-align:middle;margin-left:6px;font-size:14px} \ No newline at end of file diff --git a/miniprogram/dist/row/index.js b/miniprogram/dist/row/index.js new file mode 100644 index 0000000..3428387 --- /dev/null +++ b/miniprogram/dist/row/index.js @@ -0,0 +1,9 @@ +Component({ + externalClasses: ['i-class'], + + relations: { + '../col/index': { + type: 'child' + } + } +}); diff --git a/miniprogram/dist/row/index.json b/miniprogram/dist/row/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/row/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/row/index.wxml b/miniprogram/dist/row/index.wxml new file mode 100644 index 0000000..fe8159e --- /dev/null +++ b/miniprogram/dist/row/index.wxml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/miniprogram/dist/row/index.wxss b/miniprogram/dist/row/index.wxss new file mode 100644 index 0000000..3b8b432 --- /dev/null +++ b/miniprogram/dist/row/index.wxss @@ -0,0 +1 @@ +.i-row:after{content:"";display:table;clear:both} \ No newline at end of file diff --git a/miniprogram/dist/slide/index.js b/miniprogram/dist/slide/index.js new file mode 100644 index 0000000..a397f4f --- /dev/null +++ b/miniprogram/dist/slide/index.js @@ -0,0 +1,15 @@ +Component({ + externalClasses: ['i-class'], + options: { + // 在组件定义时的选项中启用多slot支持 + multipleSlots: true + }, + methods : { + handleTap2(){ + console.log(event,1111111) + }, + handleTap3(){ + + } + } +}); diff --git a/miniprogram/dist/slide/index.json b/miniprogram/dist/slide/index.json new file mode 100644 index 0000000..6b1e67d --- /dev/null +++ b/miniprogram/dist/slide/index.json @@ -0,0 +1,8 @@ +{ + "component": true, + "usingComponents": + { + "i-button": "../button/index", + "i-icon": "../icon/index" + } +} diff --git a/miniprogram/dist/slide/index.wxml b/miniprogram/dist/slide/index.wxml new file mode 100644 index 0000000..a13c673 --- /dev/null +++ b/miniprogram/dist/slide/index.wxml @@ -0,0 +1,4 @@ + + 1111 + + \ No newline at end of file diff --git a/miniprogram/dist/slide/index.wxss b/miniprogram/dist/slide/index.wxss new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram/dist/spin/index.js b/miniprogram/dist/spin/index.js new file mode 100644 index 0000000..3297f81 --- /dev/null +++ b/miniprogram/dist/spin/index.js @@ -0,0 +1,23 @@ +Component({ + externalClasses: ['i-class'], + + properties: { + // small || default || large + size: { + type: String, + value: 'default' + }, + fix: { + type: Boolean, + value: false + }, + fullscreen: { + type: Boolean, + value: false + }, + custom: { + type: Boolean, + value: false + } + } +}); diff --git a/miniprogram/dist/spin/index.json b/miniprogram/dist/spin/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/spin/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/spin/index.wxml b/miniprogram/dist/spin/index.wxml new file mode 100644 index 0000000..8c25439 --- /dev/null +++ b/miniprogram/dist/spin/index.wxml @@ -0,0 +1,6 @@ + +
+ +
+
+
diff --git a/miniprogram/dist/spin/index.wxss b/miniprogram/dist/spin/index.wxss new file mode 100644 index 0000000..8ed714a --- /dev/null +++ b/miniprogram/dist/spin/index.wxss @@ -0,0 +1 @@ +.i-spin{color:#2d8cf0;vertical-align:middle;text-align:center}.i-spin-dot{position:relative;display:block;border-radius:50%;background-color:#2d8cf0;width:20px;height:20px;animation:ani-spin-bounce 1s 0s ease-in-out infinite}.i-spin-large .i-spin-dot{width:32px;height:32px}.i-spin-small .i-spin-dot{width:12px;height:12px}.i-spin-fix{position:absolute;top:0;left:0;z-index:8;width:100%;height:100%;background-color:rgba(255,255,255,.9)}.i-spin-fullscreen{z-index:2010}.i-spin-fullscreen-wrapper{position:fixed;top:0;right:0;bottom:0;left:0}.i-spin-fix .i-spin-main{position:absolute;top:50%;left:50%;-ms-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.i-spin-fix .i-spin-dot{display:inline-block}.i-spin-show-text .i-spin-dot,.i-spin-text{display:none}.i-spin-show-text .i-spin-text{display:block;font-size:14px}@keyframes ani-spin-bounce{0%{transform:scale(0)}100%{transform:scale(1);opacity:0}} \ No newline at end of file diff --git a/miniprogram/dist/step/index.js b/miniprogram/dist/step/index.js new file mode 100644 index 0000000..06a81a2 --- /dev/null +++ b/miniprogram/dist/step/index.js @@ -0,0 +1,52 @@ +Component({ + externalClasses: ['i-class'], + properties : { + status : { + type : String, + //wait、process、finish、error + value : '' + }, + title : { + type : String, + value : '' + }, + content : { + type : String, + value : '' + }, + icon : { + type : String, + value : '' + } + }, + options: { + // 在组件定义时的选项中启用多slot支持 + multipleSlots: true + }, + relations : { + '../steps/index' : { + type : 'parent' + } + }, + data : { + //step length + len : 1, + //current in step index + index : 0, + //parent component select current index + current : 0, + //css direction + direction : 'horizontal' + }, + methods : { + updateDataChange( options ){ + this.setData({ + len : options.len, + index : options.index, + current : options.current, + direction : options.direction + }) + } + } + +}) \ No newline at end of file diff --git a/miniprogram/dist/step/index.json b/miniprogram/dist/step/index.json new file mode 100644 index 0000000..ffb5dee --- /dev/null +++ b/miniprogram/dist/step/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": + { + "i-icon": "../icon/index" + } +} diff --git a/miniprogram/dist/step/index.wxml b/miniprogram/dist/step/index.wxml new file mode 100644 index 0000000..63549dc --- /dev/null +++ b/miniprogram/dist/step/index.wxml @@ -0,0 +1,70 @@ + + + {{ index+1 }} + + + + + + + + {{title}} + + + + + + {{content}} + + + + + + + +var allStatus = ['wait','process','finish','error']; +module.exports = { + noIco : function( status,current,index,icon ){ + var aindex = allStatus.indexOf(status); + var noIcon = true; + if( index < current || icon !== '' ){ + noIcon = false; + } + return noIcon; + }, + getIcoClass : function( status,ico ){ + var class = ''; + if( status === 'error' ){ + class = 'close'; + }else{ + class = 'right'; + } + if( ico !== '' ){ + class = ico; + } + return class; + }, + getItemStyle : function(len,direction){ + if( direction === 'horizontal' ){ + return 'width :'+100/len + '%'; + }else{ + return 'width : 100%;'; + } + }, + getClass : function( status,current,index ) { + //wait、process、finish、error + var startClass = 'i-step-' + var classes = ''; + var cindex = allStatus.indexOf( status ); + if( cindex !== -1 ){ + classes = startClass + allStatus[cindex]; + } + if( index < current ){ + classes = startClass + 'finish'; + }else if( index === current ){ + classes = startClass + 'process'; + } + return classes; + } +} + \ No newline at end of file diff --git a/miniprogram/dist/step/index.wxss b/miniprogram/dist/step/index.wxss new file mode 100644 index 0000000..284b42a --- /dev/null +++ b/miniprogram/dist/step/index.wxss @@ -0,0 +1 @@ +.i-step-ico{width:24px;height:100%;border-radius:100%;background:#fff;position:relative;z-index:2;margin:0 auto;border:#dddee1 solid 1px}.i-step-ico-in{vertical-align:baseline}.i-step-line{position:absolute;left:50%;top:12px;width:100%;height:1px;background:#dddee1}.i-step-horizontal .i-step-ico::after{position:absolute;top:11px;left:23px;z-index:1;content:'';height:1px;background:#fff;width:10px}.i-step-horizontal .i-step-item-main{text-align:center}.i-step-horizontal .i-step-ico::before{position:absolute;top:11px;left:-11px;z-index:1;content:'';height:1px;background:#fff;width:10px}.i-step-ico{box-sizing:border-box;font-size:12px}.i-step-process .i-step-ico{border:#2d8cf0 solid 1px;color:#fff;background:#2d8cf0}.i-step-wait .i-step-ico{border:#e9eaec solid 1px;color:#e9eaec}.i-step-wait .i-step-line{background:#2d8cf0}.i-step-finish .i-step-ico{border:#2d8cf0 solid 1px;color:#2d8cf0}.i-step-finish .i-step-line{background:#2d8cf0}.i-step-error .i-step-ico{border:#ed3f14 solid 1px;color:#ed3f14}.i-step-error .i-step-line{background:#ed3f14}.i-step-item{font-size:12px;position:relative;display:inline-block;box-sizing:border-box;padding-left:10px;vertical-align:top}.i-step-item-ico{width:100%;height:24px;line-height:24px;text-align:center}.i-step-item-main{margin-top:10px;clear:both}.i-step-item-title{font-size:14px;font-weight:700;color:#1c2438}.i-step-item-content{font-size:12px;font-weight:700;margin-top:2px;color:#80848f}.i-step-vertical{padding-bottom:30px}.i-step-vertical .i-step-item-ico{width:24px;float:left}.i-step-vertical .i-step-item-main{margin-left:40px;margin-top:0;clear:inherit}.i-step-vertical .i-step-line{position:absolute;height:100%;top:0;left:10px;margin:0 0 0 12px;width:1px} \ No newline at end of file diff --git a/miniprogram/dist/steps/index.js b/miniprogram/dist/steps/index.js new file mode 100644 index 0000000..06bed88 --- /dev/null +++ b/miniprogram/dist/steps/index.js @@ -0,0 +1,50 @@ +Component({ + externalClasses: ['i-class'], + properties : { + current : { + type : Number, + value : -1, + observer : '_updateDataChange' + }, + status : { + type : String, + //wait、process、finish、error + value : '' + }, + direction : { + type : String, + //value has horizontal or vertical + value : 'horizontal' + } + }, + relations : { + '../step/index' : { + type : 'child', + linked(){ + this._updateDataChange(); + }, + linkChanged () { + this._updateDataChange(); + }, + unlinked () { + this._updateDataChange(); + } + } + }, + methods: { + _updateDataChange() { + let steps = this.getRelationNodes('../step/index'); + const len = steps.length; + if (len > 0) { + steps.forEach((step, index) => { + step.updateDataChange({ + len : len, + index : index, + current : this.data.current, + direction : this.data.direction + }); + }); + } + } + } +}) \ No newline at end of file diff --git a/miniprogram/dist/steps/index.json b/miniprogram/dist/steps/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/steps/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/steps/index.wxml b/miniprogram/dist/steps/index.wxml new file mode 100644 index 0000000..d9c7942 --- /dev/null +++ b/miniprogram/dist/steps/index.wxml @@ -0,0 +1,3 @@ + + + diff --git a/miniprogram/dist/steps/index.wxss b/miniprogram/dist/steps/index.wxss new file mode 100644 index 0000000..616ed04 --- /dev/null +++ b/miniprogram/dist/steps/index.wxss @@ -0,0 +1 @@ +.i-steps{width:100%} \ No newline at end of file diff --git a/miniprogram/dist/sticky-item/index.js b/miniprogram/dist/sticky-item/index.js new file mode 100644 index 0000000..4fc3dbe --- /dev/null +++ b/miniprogram/dist/sticky-item/index.js @@ -0,0 +1,40 @@ +Component({ + externalClasses: ['i-class'], + options: { + multipleSlots: true + }, + relations : { + '../sticky/index' : { + type : 'parent' + } + }, + data : { + top : 0, + height : 0, + isFixed : false, + index : -1, + }, + methods: { + updateScrollTopChange(scrollTop){ + const data = this.data; + const top = data.top; + const height = data.height; + this.setData({ + isFixed : ( scrollTop >= top && scrollTop < top + height ) ? true : false + }) + }, + updateDataChange(index) { + const className = '.i-sticky-item'; + const query = wx.createSelectorQuery().in(this); + query.select( className ).boundingClientRect((res)=>{ + if( res ){ + this.setData({ + top : res.top, + height : res.height, + index : index + }) + } + }).exec() + } + } +}) \ No newline at end of file diff --git a/miniprogram/dist/sticky-item/index.json b/miniprogram/dist/sticky-item/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/sticky-item/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/sticky-item/index.wxml b/miniprogram/dist/sticky-item/index.wxml new file mode 100644 index 0000000..613a5c0 --- /dev/null +++ b/miniprogram/dist/sticky-item/index.wxml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/miniprogram/dist/sticky-item/index.wxss b/miniprogram/dist/sticky-item/index.wxss new file mode 100644 index 0000000..7328f0f --- /dev/null +++ b/miniprogram/dist/sticky-item/index.wxss @@ -0,0 +1 @@ +.i-sticky-item-header{background:#eee;font-size:14px;width:100%;height:32px;line-height:32px}.i-sticky-item-content{font-size:14px}.i-sticky-title{width:100%;padding:0 15px;box-sizing:border-box;background:#eee}.i-sticky-fixed .i-sticky-title{position:fixed;top:0} \ No newline at end of file diff --git a/miniprogram/dist/sticky/index.js b/miniprogram/dist/sticky/index.js new file mode 100644 index 0000000..546aa4c --- /dev/null +++ b/miniprogram/dist/sticky/index.js @@ -0,0 +1,63 @@ +Component({ + externalClasses: ['i-class'], + properties : { + scrollTop : { + type : Number, + observer(val){ + this._updateScrollTopChange(); + } + } + }, + relations : { + '../sticky-item/index' : { + type : 'child', + linked(){ + this._updateDataChange(); + }, + linkChanged () { + this._updateDataChange(); + }, + unlinked () { + this._updateDataChange(); + } + } + }, + data : { + timer : null, + itemLength : 0, + }, + methods : { + _updateScrollTopChange(){ + const stickies = this.getRelationNodes('../sticky-item/index'); + if( stickies.length > 0 ){ + stickies.forEach((item) => { + if( item ){ + item.updateScrollTopChange( this.data.scrollTop ); + } + }) + } + }, + _updateDataChange( ){ + const stickies = this.getRelationNodes('../sticky-item/index'); + if( stickies.length > 0 ){ + if( this.data.timer ){ + clearTimeout( this.data.timer ) + this.setData({ + timer : null + }) + } + this.data.timer = setTimeout(()=>{ + stickies.forEach((item,index) => { + if( item ){ + item.updateDataChange(index); + } + }) + },0) + this.setData({ + timer : this.data.timer + }) + } + } + } + +}) \ No newline at end of file diff --git a/miniprogram/dist/sticky/index.json b/miniprogram/dist/sticky/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/sticky/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/sticky/index.wxml b/miniprogram/dist/sticky/index.wxml new file mode 100644 index 0000000..aee0c63 --- /dev/null +++ b/miniprogram/dist/sticky/index.wxml @@ -0,0 +1,3 @@ + + + diff --git a/miniprogram/dist/sticky/index.wxss b/miniprogram/dist/sticky/index.wxss new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram/dist/swipeout/index.js b/miniprogram/dist/swipeout/index.js new file mode 100644 index 0000000..b23748c --- /dev/null +++ b/miniprogram/dist/swipeout/index.js @@ -0,0 +1,161 @@ + /* +* touch事件判断方式 +* https://github.com/madrobby/zepto/blob/master/src/touch.js#files +*/ +function swipeDirection(x1, x2, y1, y2) { + return Math.abs(x1 - x2) >= + Math.abs(y1 - y2) ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down') +} + +Component({ + externalClasses: ['i-class'], + properties: { + actions: { + value: [], + type: Array, + observer : '_updateButtonSize' + }, + unclosable : { + value : false, + type : Boolean + }, + toggle : { + value : false, + type : Boolean, + observer : 'closeButtonGroup' + }, + operateWidth : { + type : Number, + value : 160 + } + }, + options: { + // 在组件定义时的选项中启用多slot支持 + multipleSlots: true + }, + data : { + //touch start position + tStart : { + pageX : 0, + pageY : 0 + }, + //限制滑动距离 + limitMove : 0, + //element move position + position : { + pageX : 0, + pageY : 0 + } + }, + methods : { + //阻止事件冒泡 + loop(){}, + _updateButtonSize(){ + const actions = this.data.actions; + if( actions.length > 0 ){ + const query = wx.createSelectorQuery().in(this); + let limitMovePosition = 0; + actions.forEach(item => { + limitMovePosition += item.width || 0; + }); + this.data.limitMove = limitMovePosition; + /* + * 动态获取每个传进值的按钮尺寸不能正确获取,在安卓上少了6px + * 暂时实现需要在actions里面传递宽度 + * 需要后期调研 + */ + //query.selectAll('.i-swipeout-button-right-item').boundingClientRect((rects)=>{ + // if( rects ){ + // console.log(rects,1111111) + // rects.forEach(item => { + // limitMovePosition += item.width; + // }); + // this.data.limitMove = limitMovePosition; + // console.log(limitMovePosition,111111111) + // } + // }).exec() + }else{ + this.data.limitMove = this.data.operateWidth; + + } + }, + handlerTouchstart(event){ + const touches = event.touches ? event.touches[0] : {}; + const tStart = this.data.tStart; + if( touches ){ + for( let i in tStart ){ + if( touches[i] ){ + tStart[i] = touches[i]; + } + } + } + }, + swipper(touches){ + const data = this.data; + const start = data.tStart; + const spacing = { + pageX : touches.pageX - start.pageX, + pageY : touches.pageY - start.pageY + } + if( data.limitMove < Math.abs( spacing.pageX ) ){ + spacing.pageX = -data.limitMove; + + } + this.setData({ + 'position' : spacing + }) + }, + handlerTouchmove(event){ + const start = this.data.tStart; + const touches = event.touches ? event.touches[0] : {}; + if( touches ){ + const direction = swipeDirection( start.pageX,touches.pageX,start.pageY,touches.pageY ); + if( direction === 'Left' ){ + this.swipper( touches ); + } + } + }, + handlerTouchend(event){ + const start = this.data.tStart; + const touches = event.changedTouches ? event.changedTouches[0] : {}; + if( touches ){ + const direction = swipeDirection( start.pageX,touches.pageX,start.pageY,touches.pageY ); + const spacing = { + pageX : touches.pageX - start.pageX, + pageY : touches.pageY - start.pageY + } + if( Math.abs( spacing.pageX ) >= 40 && direction === "Left" ){ + spacing.pageX = spacing.pageX < 0 ? - this.data.limitMove : this.data.limitMove; + }else{ + spacing.pageX = 0; + } + this.setData({ + 'position' : spacing + }) + } + }, + handlerButton(event){ + if( !this.data.unclosable ){ + this.closeButtonGroup(); + } + const dataset = event.currentTarget.dataset; + this.triggerEvent('change',{ + index : dataset.index + }) + }, + closeButtonGroup(){ + this.setData({ + 'position' : {pageX : 0,pageY : 0} + }) + }, + //控制自定义组件 + handlerParentButton(event){ + if( !this.data.unclosable ){ + this.closeButtonGroup(); + } + } + }, + ready(){ + this._updateButtonSize(); + } +}); diff --git a/miniprogram/dist/swipeout/index.json b/miniprogram/dist/swipeout/index.json new file mode 100644 index 0000000..c63f9a6 --- /dev/null +++ b/miniprogram/dist/swipeout/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "i-cell": "../cell/index", + "i-icon": "../icon/index" + } +} \ No newline at end of file diff --git a/miniprogram/dist/swipeout/index.wxml b/miniprogram/dist/swipeout/index.wxml new file mode 100644 index 0000000..96edef8 --- /dev/null +++ b/miniprogram/dist/swipeout/index.wxml @@ -0,0 +1,38 @@ + + + + + + + + + + {{item.name}} + + + + + + + + + module.exports = { + setStyle : function( item ){ + var defaults = '#f7f7f7'; + return 'background:' + ( item.background ? item.background : defaults ) +';' + 'color:'+ item.color; + }, + setPosition : function( position ){ + return 'transform:translate(' + position.pageX + 'px,0);'; + } + } + \ No newline at end of file diff --git a/miniprogram/dist/swipeout/index.wxss b/miniprogram/dist/swipeout/index.wxss new file mode 100644 index 0000000..597cffc --- /dev/null +++ b/miniprogram/dist/swipeout/index.wxss @@ -0,0 +1 @@ +.i-swipeout-wrap{border-bottom:#dddee1 solid 1px;background:#fff;position:relative;overflow:hidden}.i-swipeout-item{width:100%;padding:15px 20px;box-sizing:border-box;transition:transform .2s ease;font-size:14px}.i-swipeout-content{white-space:nowrap;overflow:hidden}.i-swipeout-button-right-group{position:absolute;right:-100%;top:0;height:100%;z-index:1;width:100%}.i-swipeout-button-right-item{height:100%;float:left;white-space:nowrap;box-sizing:border-box;display:flex;align-items:center;justify-content:center} \ No newline at end of file diff --git a/miniprogram/dist/switch/index.js b/miniprogram/dist/switch/index.js new file mode 100644 index 0000000..5ebccfa --- /dev/null +++ b/miniprogram/dist/switch/index.js @@ -0,0 +1,38 @@ +Component({ + externalClasses: ['i-class'], + properties : { + value : { + type : Boolean, + value : false + }, + //large small default + size : { + type : String, + value : 'default' + }, + // is or not disable + disabled : { + type : Boolean, + value : false + }, + // hidden inut name + name : { + type : String, + value : '' + } + }, + options: { + // 在组件定义时的选项中启用多slot支持 + multipleSlots: true + }, + methods : { + toggle(){ + if( this.data.disabled ) return; + const data = this.data; + const value = data.value ? false : true; + this.triggerEvent('change',{ + value : value + }) + } + } +}); diff --git a/miniprogram/dist/switch/index.json b/miniprogram/dist/switch/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/switch/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/switch/index.wxml b/miniprogram/dist/switch/index.wxml new file mode 100644 index 0000000..a180254 --- /dev/null +++ b/miniprogram/dist/switch/index.wxml @@ -0,0 +1,26 @@ + + + + + + + + + + +var sizes = ['large', 'default']; +var prefixCls = 'i-switch'; +module.exports = { + setSize : function( size ){ + var index = sizes.indexOf( size ); + return prefixCls + ( index > -1 ? ( '-'+size ) : 'default' ) + }, + setCurrent : function( value,disabled ){ + var className = value && !disabled ? prefixCls + '-checked' : ''; + if( disabled ){ + className += ' ' + prefixCls + '-disabled'; + } + return className; + } +} + \ No newline at end of file diff --git a/miniprogram/dist/switch/index.wxss b/miniprogram/dist/switch/index.wxss new file mode 100644 index 0000000..128fea6 --- /dev/null +++ b/miniprogram/dist/switch/index.wxss @@ -0,0 +1 @@ +.i-switch{display:inline-block;width:48px;height:24px;line-height:24px;border-radius:24px;vertical-align:middle;border:1px solid #ccc;background-color:#ccc;position:relative;cursor:pointer;-webkit-tap-highlight-color:transparent;transition:all .2s ease-in-out}.i-switch-hide-input{display:none;opacity:0}.i-switch-inner{color:#fff;font-size:12px;position:absolute;left:25px;vertical-align:middle}.i-switch-inner .i-icon{width:12px;height:12px;text-align:center;vertical-align:middle}.i-switch:after{content:'';width:22px;height:22px;border-radius:22px;background-color:#fff;position:absolute;left:1px;top:1px;cursor:pointer;transition:left .2s ease-in-out,width .2s ease-in-out}.i-switch-checked:after{left:8px}.i-switch-large{width:60px}.i-switch-large.i-switch-checked:after{left:37px}.i-switch-checked:after{left:25px}.i-switch-checked{border-color:#2d8cf0;background-color:#2d8cf0}.i-switch-checked .i-switch-inner{left:8px}.i-switch-checked:after{left:25px}.i-switch-disabled{background:#f3f3f3;border-color:#f3f3f3}.i-switch-disabled:after{background:#ccc;cursor:not-allowed}.i-switch-disabled .i-switch-inner{color:#ccc} \ No newline at end of file diff --git a/miniprogram/dist/tab-bar-item/index.js b/miniprogram/dist/tab-bar-item/index.js new file mode 100644 index 0000000..0c24c1a --- /dev/null +++ b/miniprogram/dist/tab-bar-item/index.js @@ -0,0 +1,62 @@ +Component({ + externalClasses: ['i-class'], + + relations: { + '../tab-bar/index': { + type: 'parent' + } + }, + + properties: { + icon: { + type: String, + value: '' + }, + currentIcon: { + type: String, + value: '' + }, + img: { + type: String, + value: '' + }, + currentImg: { + type: String, + value: '' + }, + key: { + type: String, + value: '' + }, + title: { + type: String, + value: '' + }, + dot: { + type: Boolean, + value: false + }, + count: { + type: Number, + value: 0 + } + }, + + data: { + current: false, + currentColor: '' + }, + + methods: { + changeCurrent (current) { + this.setData({ current }); + }, + changeCurrentColor (currentColor) { + this.setData({ currentColor }); + }, + handleClickItem () { + const parent = this.getRelationNodes('../tab-bar/index')[0]; + parent.emitEvent(this.data.key); + } + } +}); diff --git a/miniprogram/dist/tab-bar-item/index.json b/miniprogram/dist/tab-bar-item/index.json new file mode 100644 index 0000000..918aaf8 --- /dev/null +++ b/miniprogram/dist/tab-bar-item/index.json @@ -0,0 +1,8 @@ +{ + "component": true, + "usingComponents": + { + "i-badge": "../badge/index", + "i-icon": "../icon/index" + } +} diff --git a/miniprogram/dist/tab-bar-item/index.wxml b/miniprogram/dist/tab-bar-item/index.wxml new file mode 100644 index 0000000..7153909 --- /dev/null +++ b/miniprogram/dist/tab-bar-item/index.wxml @@ -0,0 +1,10 @@ + + + + + + {{ title }} + {{ title }} + + + \ No newline at end of file diff --git a/miniprogram/dist/tab-bar-item/index.wxss b/miniprogram/dist/tab-bar-item/index.wxss new file mode 100644 index 0000000..0f8a9c8 --- /dev/null +++ b/miniprogram/dist/tab-bar-item/index.wxss @@ -0,0 +1 @@ +.i-tab-bar-item{flex:1;display:flex;width:100%;-webkit-box-pack:center;justify-content:center;-webkit-box-align:center;align-items:center;-webkit-box-orient:vertical;-webkit-box-direction:normal;flex-direction:column;text-align:center}.i-tab-bar-item-icon{display:flex;-webkit-box-pack:center;justify-content:center;box-sizing:border-box;color:#80848f}.i-tab-bar-item-icon-current{color:#2d8cf0}.i-tab-bar-item-img{display:flex;-webkit-box-pack:center;justify-content:center;box-sizing:border-box;width:22px;height:22px}.i-tab-bar-item-title{font-size:10px;margin:3px 0 0;line-height:1;text-align:center;box-sizing:border-box;color:#80848f}.i-tab-bar-item-title-current{color:#2d8cf0}.i-tab-bar-item-img{display:flex;-webkit-box-pack:center;justify-content:center;box-sizing:border-box;color:#80848f} \ No newline at end of file diff --git a/miniprogram/dist/tab-bar/index.js b/miniprogram/dist/tab-bar/index.js new file mode 100644 index 0000000..ca02fe4 --- /dev/null +++ b/miniprogram/dist/tab-bar/index.js @@ -0,0 +1,66 @@ +Component({ + externalClasses: ['i-class'], + + relations: { + '../tab-bar-item/index': { + type: 'child', + linked () { + this.changeCurrent(); + }, + linkChanged () { + this.changeCurrent(); + }, + unlinked () { + this.changeCurrent(); + } + } + }, + + properties: { + current: { + type: String, + value: '', + observer: 'changeCurrent' + }, + color: { + type: String, + value: '' + }, + fixed: { + type: Boolean, + value: false + } + }, + + data: { + list: [] + }, + + methods: { + changeCurrent (val = this.data.current) { + let items = this.getRelationNodes('../tab-bar-item/index'); + const len = items.length; + + if (len > 0) { + const list = []; + items.forEach(item => { + item.changeCurrent(item.data.key === val); + item.changeCurrentColor(this.data.color); + list.push({ + key: item.data.key + }); + }); + this.setData({ + list: list + }); + } + }, + emitEvent (key) { + this.triggerEvent('change', { key }); + }, + handleClickItem (e) { + const key = e.currentTarget.dataset.key; + this.emitEvent(key); + } + } +}); diff --git a/miniprogram/dist/tab-bar/index.json b/miniprogram/dist/tab-bar/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/tab-bar/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/tab-bar/index.wxml b/miniprogram/dist/tab-bar/index.wxml new file mode 100644 index 0000000..9dbfbea --- /dev/null +++ b/miniprogram/dist/tab-bar/index.wxml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/miniprogram/dist/tab-bar/index.wxss b/miniprogram/dist/tab-bar/index.wxss new file mode 100644 index 0000000..5c6fd9c --- /dev/null +++ b/miniprogram/dist/tab-bar/index.wxss @@ -0,0 +1 @@ +.i-tab-bar{display:flex;width:100%;height:50px;box-sizing:border-box;position:relative;justify-content:space-around;align-items:center;-webkit-box-align:center;background:#fff}.i-tab-bar::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e9eaec;border-top-width:1px}.i-tab-bar-fixed{position:fixed;bottom:0;z-index:2}.i-tab-bar-list{position:absolute;top:0;bottom:0;left:0;right:0}.i-tab-bar-layer{display:block;float:left;height:100%} \ No newline at end of file diff --git a/miniprogram/dist/tab/index.js b/miniprogram/dist/tab/index.js new file mode 100644 index 0000000..c8d3079 --- /dev/null +++ b/miniprogram/dist/tab/index.js @@ -0,0 +1,50 @@ +Component({ + externalClasses: ['i-class'], + + relations: { + '../tabs/index': { + type: 'parent' + } + }, + + properties: { + key: { + type: String, + value: '' + }, + title: { + type: String, + value: '' + }, + dot: { + type: Boolean, + value: false + }, + count: { + type: Number, + value: 0 + } + }, + + data: { + current: false, + currentColor: '', + scroll: false + }, + + methods: { + changeCurrent (current) { + this.setData({ current }); + }, + changeCurrentColor (currentColor) { + this.setData({ currentColor }); + }, + changeScroll (scroll) { + this.setData({ scroll }); + }, + handleClickItem () { + const parent = this.getRelationNodes('../tabs/index')[0]; + parent.emitEvent(this.data.key); + } + } +}); diff --git a/miniprogram/dist/tab/index.json b/miniprogram/dist/tab/index.json new file mode 100644 index 0000000..eb6877d --- /dev/null +++ b/miniprogram/dist/tab/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": + { + "i-badge": "../badge/index" + } +} diff --git a/miniprogram/dist/tab/index.wxml b/miniprogram/dist/tab/index.wxml new file mode 100644 index 0000000..29d3955 --- /dev/null +++ b/miniprogram/dist/tab/index.wxml @@ -0,0 +1,9 @@ + + + + {{ title }} + {{ title }} + + + + \ No newline at end of file diff --git a/miniprogram/dist/tab/index.wxss b/miniprogram/dist/tab/index.wxss new file mode 100644 index 0000000..135637b --- /dev/null +++ b/miniprogram/dist/tab/index.wxss @@ -0,0 +1 @@ +.i-tabs-tab{flex:1;display:flex;width:100%;-webkit-box-pack:center;justify-content:center;-webkit-box-align:center;align-items:center;-webkit-box-orient:vertical;-webkit-box-direction:normal;flex-direction:column;text-align:center;position:relative}.i-tabs-tab-bar{display:block;width:100%;height:2px;background:0 0;position:absolute;bottom:0;left:0;background:#2d8cf0}.i-tabs-tab-title{font-size:14px;text-align:center;box-sizing:border-box;color:#80848f}.i-tabs-tab-title-current{color:#2d8cf0}.i-tabs-tab-scroll{display:inline-block;width:60px} \ No newline at end of file diff --git a/miniprogram/dist/tabs/index.js b/miniprogram/dist/tabs/index.js new file mode 100644 index 0000000..b9d0326 --- /dev/null +++ b/miniprogram/dist/tabs/index.js @@ -0,0 +1,56 @@ +Component({ + externalClasses: ['i-class'], + + relations: { + '../tab/index': { + type: 'child', + linked () { + this.changeCurrent(); + }, + linkChanged () { + this.changeCurrent(); + }, + unlinked () { + this.changeCurrent(); + } + } + }, + + properties: { + current: { + type: String, + value: '', + observer: 'changeCurrent' + }, + color: { + type: String, + value: '' + }, + scroll: { + type: Boolean, + value: false + }, + fixed: { + type: Boolean, + value: false + } + }, + + methods: { + changeCurrent (val = this.data.current) { + let items = this.getRelationNodes('../tab/index'); + const len = items.length; + + if (len > 0) { + items.forEach(item => { + item.changeScroll(this.data.scroll); + item.changeCurrent(item.data.key === val); + item.changeCurrentColor(this.data.color); + }); + } + }, + emitEvent (key) { + this.triggerEvent('change', { key }); + } + } +}); diff --git a/miniprogram/dist/tabs/index.json b/miniprogram/dist/tabs/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram/dist/tabs/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram/dist/tabs/index.wxml b/miniprogram/dist/tabs/index.wxml new file mode 100644 index 0000000..b61d51b --- /dev/null +++ b/miniprogram/dist/tabs/index.wxml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/miniprogram/dist/tabs/index.wxss b/miniprogram/dist/tabs/index.wxss new file mode 100644 index 0000000..985fb18 --- /dev/null +++ b/miniprogram/dist/tabs/index.wxss @@ -0,0 +1 @@ +.i-tabs{display:flex;width:100%;height:42px;line-height:42px;box-sizing:border-box;position:relative;justify-content:space-around;align-items:center;-webkit-box-align:center;background:#fff}.i-tabs::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e9eaec;border-bottom-width:1px}.i-tabs-scroll{display:block;overflow-x:auto;white-space:nowrap}.i-tabs-fixed{position:fixed;top:0;z-index:2} \ No newline at end of file diff --git a/miniprogram/dist/tag/index.js b/miniprogram/dist/tag/index.js new file mode 100644 index 0000000..338440a --- /dev/null +++ b/miniprogram/dist/tag/index.js @@ -0,0 +1,42 @@ +Component({ + externalClasses: ['i-class'], + properties : { + //slot name + name : { + type : String, + value : '' + }, + //can click or not click + checkable : { + type : Boolean, + value : false + }, + //is current choose + checked : { + type : Boolean, + value : true + }, + //background and color setting + color : { + type : String, + value : 'default' + }, + //control fill or not + type : { + type : String, + value : 'dot' + } + }, + methods : { + tapTag(){ + const data = this.data; + if( data.checkable ){ + const checked = data.checked ? false : true; + this.triggerEvent('change',{ + name : data.name || '', + checked : checked + }); + } + } + } +}) \ No newline at end of file diff --git a/miniprogram/dist/tag/index.json b/miniprogram/dist/tag/index.json new file mode 100644 index 0000000..1dd6c7f --- /dev/null +++ b/miniprogram/dist/tag/index.json @@ -0,0 +1,3 @@ +{ + "component" : true +} \ No newline at end of file diff --git a/miniprogram/dist/tag/index.wxml b/miniprogram/dist/tag/index.wxml new file mode 100644 index 0000000..ed2c675 --- /dev/null +++ b/miniprogram/dist/tag/index.wxml @@ -0,0 +1,27 @@ + + + + +module.exports = { + getClass : function(color,type,checked,checkable) { + var initColorList = ['blue', 'green', 'red', 'yellow', 'default']; + var theme = ''; + var className = 'i-tag-'; + if( initColorList.indexOf( color ) > -1 ){ + theme = className + color; + } + if( type === 'border' ){ + theme = className+color+'-border'; + } + if( checkable && checked ){ + theme = className+color+'-checked'; + }else if( checkable && !checked ){ + theme = ( type === 'border' ? className + color +'-border' : className+'none' ); + } + + return theme; + } +} + \ No newline at end of file diff --git a/miniprogram/dist/tag/index.wxss b/miniprogram/dist/tag/index.wxss new file mode 100644 index 0000000..e19f976 --- /dev/null +++ b/miniprogram/dist/tag/index.wxss @@ -0,0 +1 @@ +.i-tag{display:inline-block;height:18px;line-height:18px;padding:0 4px;border-radius:2px;background:#fff;font-size:11px;vertical-align:middle;border:1rpx solid #dddee1}.i-tag-none{border-color:#fff}.i-tag-default{border-color:#dddee1;background:#e9eaec}.i-tag-red{background:#ed3f14;color:#fff}.i-tag-red-border{color:#ed3f14;background:#fff;border-color:#ed3f14}.i-tag-red-checked{background:#ed3f14;color:#fff;border-color:#ed3f14}.i-tag-green{background:#19be6b;color:#fff;border-color:#19be6b}.i-tag-green-border{color:#19be6b;background:#fff;border-color:#19be6b}.i-tag-green-checked{background:#19be6b;color:#fff;border-color:#19be6b}.i-tag-blue{background:#2d8cf0;color:#fff;border-color:#2d8cf0}.i-tag-blue-border{color:#2d8cf0;background:#fff;border-color:#2d8cf0}.i-tag-blue-checked{background:#2d8cf0;color:#fff;border-color:#2d8cf0}.i-tag-yellow{background:#f90;color:#fff;border-color:#f90}.i-tag-yellow-border{color:#f90;background:#fff;border-color:#f90}.i-tag-yellow-checked{background:#f90;color:#fff;border-color:#f90}.i-tag-default-checked{background:#e9eaec;color:#495060;border-color:#e9eaec} \ No newline at end of file diff --git a/miniprogram/dist/toast/index.js b/miniprogram/dist/toast/index.js new file mode 100644 index 0000000..6493111 --- /dev/null +++ b/miniprogram/dist/toast/index.js @@ -0,0 +1,48 @@ +const default_data = { + visible: false, + content: '', + icon: '', + image: '', + duration: 2, + mask: true, + type: 'default', // default || success || warning || error || loading +}; + +let timmer = null; + +Component({ + externalClasses: ['i-class'], + + data: { + ...default_data + }, + + methods: { + handleShow (options) { + const { type = 'default', duration = 2 } = options; + + this.setData({ + ...options, + type, + duration, + visible: true + }); + + const d = this.data.duration * 1000; + + if (timmer) clearTimeout(timmer); + if (d !== 0) { + timmer = setTimeout(() => { + this.handleHide(); + timmer = null; + }, d); + } + }, + + handleHide () { + this.setData({ + ...default_data + }); + } + } +}); diff --git a/miniprogram/dist/toast/index.json b/miniprogram/dist/toast/index.json new file mode 100644 index 0000000..31309b1 --- /dev/null +++ b/miniprogram/dist/toast/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": + { + "i-icon": "../icon/index" + } +} diff --git a/miniprogram/dist/toast/index.wxml b/miniprogram/dist/toast/index.wxml new file mode 100644 index 0000000..ca5f732 --- /dev/null +++ b/miniprogram/dist/toast/index.wxml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + {{ content }} + \ No newline at end of file diff --git a/miniprogram/dist/toast/index.wxss b/miniprogram/dist/toast/index.wxss new file mode 100644 index 0000000..5b3bd7f --- /dev/null +++ b/miniprogram/dist/toast/index.wxss @@ -0,0 +1 @@ +.i-toast{position:fixed;top:35%;left:50%;transform:translate3d(-50%,-50%,0);background:rgba(0,0,0,.7);color:#fff;font-size:14px;line-height:1.5em;margin:0 auto;box-sizing:border-box;padding:10px 18px;text-align:center;border-radius:4px;z-index:1010}.i-toast-mask{position:fixed;top:0;bottom:0;left:0;right:0;z-index:1010}.i-toast-icon{font-size:38px!important;margin-bottom:6px}.i-toast-image{max-width:100px;max-height:100px}.i-toast-loading{display:inline-block;vertical-align:middle;width:28px;height:28px;background:0 0;border-radius:50%;border:2px solid #fff;border-color:#fff #fff #fff #2d8cf0;animation:btn-spin .8s linear;animation-iteration-count:infinite}@keyframes btn-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}} \ No newline at end of file diff --git a/miniprogram/images/001-2.png b/miniprogram/images/001-2.png new file mode 100644 index 0000000..6158e49 Binary files /dev/null and b/miniprogram/images/001-2.png differ diff --git a/miniprogram/images/001.png b/miniprogram/images/001.png new file mode 100644 index 0000000..0a75b51 Binary files /dev/null and b/miniprogram/images/001.png differ diff --git a/miniprogram/images/002-2.png b/miniprogram/images/002-2.png new file mode 100644 index 0000000..f1bcea2 Binary files /dev/null and b/miniprogram/images/002-2.png differ diff --git a/miniprogram/images/002.png b/miniprogram/images/002.png new file mode 100644 index 0000000..5faec67 Binary files /dev/null and b/miniprogram/images/002.png differ diff --git a/miniprogram/images/003-2.png b/miniprogram/images/003-2.png new file mode 100644 index 0000000..4b27a05 Binary files /dev/null and b/miniprogram/images/003-2.png differ diff --git a/miniprogram/images/003.png b/miniprogram/images/003.png new file mode 100644 index 0000000..36b723d Binary files /dev/null and b/miniprogram/images/003.png differ diff --git a/miniprogram/images/004-1.png b/miniprogram/images/004-1.png new file mode 100644 index 0000000..1108c58 Binary files /dev/null and b/miniprogram/images/004-1.png differ diff --git a/miniprogram/images/004-2.png b/miniprogram/images/004-2.png new file mode 100644 index 0000000..d9f6a5f Binary files /dev/null and b/miniprogram/images/004-2.png differ diff --git a/miniprogram/images/bt.png b/miniprogram/images/bt.png new file mode 100644 index 0000000..a4c0358 Binary files /dev/null and b/miniprogram/images/bt.png differ diff --git a/miniprogram/images/bt0-1.png b/miniprogram/images/bt0-1.png new file mode 100644 index 0000000..d1661c3 Binary files /dev/null and b/miniprogram/images/bt0-1.png differ diff --git a/miniprogram/images/bt0.png b/miniprogram/images/bt0.png new file mode 100644 index 0000000..024e4b8 Binary files /dev/null and b/miniprogram/images/bt0.png differ diff --git a/miniprogram/images/bt2.png b/miniprogram/images/bt2.png new file mode 100644 index 0000000..2e5594b Binary files /dev/null and b/miniprogram/images/bt2.png differ diff --git a/miniprogram/images/team-bak.png b/miniprogram/images/team-bak.png new file mode 100644 index 0000000..89da898 Binary files /dev/null and b/miniprogram/images/team-bak.png differ diff --git a/miniprogram/images/user-unlogin.png b/miniprogram/images/user-unlogin.png new file mode 100644 index 0000000..95b27e4 Binary files /dev/null and b/miniprogram/images/user-unlogin.png differ diff --git a/miniprogram/pages/alloc/alloc.js b/miniprogram/pages/alloc/alloc.js new file mode 100644 index 0000000..3f8a44b --- /dev/null +++ b/miniprogram/pages/alloc/alloc.js @@ -0,0 +1,239 @@ +// pages/list/list.js +var authGET = require('../../utils/authGET') +var authRESULT = require('../../utils/authRESULT') +const { $Message } = require('../../dist/base/index'); + +const app = getApp() +function formatNumber(n) { + n = n.toString() + return n[1] ? n : '0' + n +} +Page({ + data: { + taskid:new Array,taskidstring:'', + taskddllist:new Array, taskbeginlist:new Array, + planid:new Array,planidstring:'', + planddllist:new Array, planbeginlist:new Array, + taskNULL:false, + current: 'tab1',current_scroll: 'tab1', + visible2: false,toggle : false,toggle2 : false, + actions : [ + { + name : '删除', + width : 100, + color : '#fff', + fontsize : '20', + icon : 'trash', + background : '#ed3f14' + }, + + ], + press : false, + loading: true + }, + + listenPress: function (res) { + this.setData({ + press: true, + }) + let that = this; + setTimeout(function(){ + that.setData({ + press: false, + }) + },15) + }, + + + onLoad: function (e) { + + }, + onReady: function () { + + }, + onShow:function(){ + let that = this; + app.listenLoading(function (res) { + that.Query() + }) + }, + onPullDownRefresh: function () { + let that = this; + app.listenLoading(function (res) { + that.Query() + }) + + }, + stopPullDownRefresh(){ + wx.stopPullDownRefresh() + $Message({ + content: '拉取数据成功', + type: 'success' + }); + }, + + Query:function(){ + this.onRESULTS() + }, + onRESULTS: function () { + var that = this + authRESULT.authRESULTS({ + url : "task", + success: function (res) { + console.log("results",res) + if(res.data!=""){ + var _taskid=[] + var _taskddlist = [] + var _taskbeginlist = [] + for(var i = 0;i + + + + + + + + + + + + + + + + + + + + + + + + + + 开始时间:{{taskbeginlist[index]}} + + + 截止时间:{{taskddlist[index]}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 开始时间:{{planbeginlist[index]}} + + + 截止时间:{{planddlist[index]}} + + + + + + + + + \ No newline at end of file diff --git a/miniprogram/pages/alloc/alloc.wxss b/miniprogram/pages/alloc/alloc.wxss new file mode 100644 index 0000000..bd438c2 --- /dev/null +++ b/miniprogram/pages/alloc/alloc.wxss @@ -0,0 +1,155 @@ +/* pages/list/list.wxss */ +.row,.row2{ + margin-top: 2px; + height :50px; + width: 95%; + margin-left:auto; + margin-right:auto; + background-color:white +} +page { + background: #F6F6F6; + display: flex; + flex-direction: column; + justify-content: flex-start; + background: url("http://static.codesdream.com/bk.png") no-repeat; + width: 100%; + background-size: 100% 100%; + background-attachment:fixed; +} + +.itm{ + margin-left: 20px; + color: rgb(99, 98, 101); + font-style: initial; + +} +.row2{ + background-color:rgb(221, 206, 255); +} + +.blk0,.blk1{ + border: 1px solid rgb(178, 139, 255); + width: 72px; + height:30px; + margin-left: 5px; + border-radius: 10px; + color: rgb(178, 139, 255); + text-align: center; +} +.blk1{ + border: 1px solid rgb(178, 139, 255); + background-color: rgb(178, 139, 255); + color: white; + border-radius: 10px; + +} +.row3{ + display: flex; + flex-direction: row; + margin-top: 5px; +} +.i-cell-padding{ + height: 28px; +} + +.i-row-class{ + margin-bottom:5px; +} + +.circle-button{ + font-size: 60rpx; + color: white; + text-align: center; + border-radius: 100%; +} + +/* .circle-view1{ + height: 120rpx; + width: 120rpx; + background-color: #19be6b; + border-radius: 100%; + position: fixed; + bottom: 100rpx; + right: 40rpx; + display: flex; + align-items: center; + justify-content: center; + z-index: 9; + border: 0 solid #ffffff; + box-shadow: 4px 1px 1px #cccccc; +} */ + +.circle-view1{ + position: fixed; + bottom: 100rpx; + right: 40rpx; + /* display: flex; + align-items: center; + justify-content: center; */ +} + +.button-img{ + height: 60px; + width: 60px; +} + +.circle-view2{ + height: 120rpx; + width: 120rpx; + background-color: #1ea4ed; + border-radius: 100%; + position: fixed; + bottom: 100rpx; + right: 40rpx; + display: flex; + align-items: center; + justify-content: center; + z-index: 9; + border: 0 solid #ffffff; + box-shadow: 4px 1px 1px #cccccc; +} + +.progress-cell{ + height: 18px; +} + +.i-cell-padding{ + height: 20px; +} + +.item-row{ + height: 45px; +} + +.empty-img{ + height: 240px; + width: 150px; + +} + +.empty-view{ + display:flex; + justify-content: center; + margin-top: 80px; + margin-left: 15px; +} + +.desc-row{ + font-size: smaller; + color: #80848f; +} + +.last-desc-row{ + margin-bottom: 5px; +} +.panel-row{ + margin-bottom: 0px; + border-bottom: solid 1px; + border-color: #dddee1; + +} + +.i-row-class-top{ + margin-top: 20px; +} \ No newline at end of file diff --git a/miniprogram/pages/databaseTest/databaseTest.js b/miniprogram/pages/databaseTest/databaseTest.js new file mode 100644 index 0000000..1baad37 --- /dev/null +++ b/miniprogram/pages/databaseTest/databaseTest.js @@ -0,0 +1,191 @@ +const app = getApp() +var authPOST = require('../../utils/authPOST') +var authGET = require('../../utils/authGET') +var authPATCH = require('../../utils/authPATCH') +var authDELETE = require('../../utils/authDELETE') +var authRESULT = require('../../utils/authRESULT') +var util = require('../../utils/util.js') + +var USERPREF = { + availableTime:Array(), + forbiddenTime:Array(), + preferTime:0,//上午下午晚上 + remindAdvance:5,//提前几分钟提醒 +}; +var USERPLAN = { + planlist:Array(), + AssignedPlanlist:Array(), + UnassignedPlanlist:Array(), +} +var USERTASK = { + tasklist:Array(), + AssignedTasklist:Array(), + UnassignedTasklist:Array(), +} +function PLAN(){ + this.description=Array(); + this.toDoDays=-1; + this.doneDays=-1; + this.eachTimeConsume=-1; + this.totalTimeConsume=-1; + this.completeProgress=-1;//完成进度 + this.bookingTime=Array(); +} +function TASK(){ + this.description=Array(); + this.deadLine=-1; + this.expectTimeConsume=-1;//剩余需分配时间 + this.iscompleted=0;//完成进度 + this.importantDegree=-1;//重要程度 + this.bookingTime=Array(); + this.preference=0;//偏好 +} + +Page({ + data: { + queryResult:[],//数据库记录查询存储 + userpref:USERPREF, + userplan:USERPLAN, + usertask:USERTASK, + }, + + onLoad: function () {//当加载页面时执行的程序,执行用户信息获取,数据库查找 + this.onQuery();//数据库查找是否已经有过创建记录 + }, + onReady:function(){ + var timestamp = Date.parse(new Date()); + timestamp = timestamp / 1000; + //获取当前时间 + var n = timestamp * 1000; + var date = new Date(n); + //年 + var Y = date.getFullYear(); + //月 + var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1); + //日 + var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate(); + //时 + var h = date.getHours(); + //分 + var m = date.getMinutes(); + //秒 + var s = date.getSeconds(); + console.log(Y+M+D+h+m+s) + }, + onQuery: function () { + console.log(new Date('2018-09-04 15:46:13'.replace(/-/g,"/")).getTime()) + }, + onPOST: function () { + let that = this; + authPOST.authPOST({ + url : "plan", + data: { + "description":["模电作业"], + "deadline":1536047173000, + "importantDegree":1.0, + "preference":0, + "singleMin":0, + "singleMax":2, + "duration":1, + "mutexPeriod":1, + }, + success: function (res) { + console.log(res) + }, + fail: function (res) { + console.log(res) + } + }) + }, + onGET: function () { + authGET.authGET({ + url : "plan", + data: { + "id":88, + }, + success: function (res) { + console.log(res) + }, + fail: function (res) { + console.log(res) + } + }) + }, + onGETALL: function () { + authGET.authGETALL({ + url : "plan", + data: { + }, + success: function (res) { + console.log(res) + }, + fail: function (res) { + console.log(res) + } + }) + }, + onPATCH: function () { + authPATCH.authPATCH({ + url:"plan", + data:{ + 'id':88, + 'patch':[ + {"op": "replace", "path": "/importantDegree", "value": 55 }, + {"op": "replace", "path": "/singleMax", "value": 7 }, + ], + }, + success: function (res) { + console.log(res) + }, + fail: function (res) { + console.log(res) + } + + }) + }, + onDELETE: function () { + authDELETE.authDELETE({ + url:"plan", + data:{ + "id":[89], + }, + success: function (res) { + console.log(res) + }, + fail: function (res) { + console.log(res) + } + + }) + }, + onTODAY: function () { + authRESULT.authTODAY({ + url : "task", + success: function (res) { + console.log(res) + }, + fail: function (res) { + console.log(res) + } + }) + }, + buttonPOST:function(){ + this.onPOST() + }, + buttonGET:function(){ + this.onGET() + }, + buttonGETALL:function(){ + this.onGETALL() + }, + buttonPATCH:function(){ + this.onPATCH() + }, + buttonDELETE:function(){ + this.onDELETE() + }, + buttonTODAY:function(){ + this.onTODAY() + }, + +}) \ No newline at end of file diff --git a/miniprogram/pages/databaseTest/databaseTest.json b/miniprogram/pages/databaseTest/databaseTest.json new file mode 100644 index 0000000..fc342d0 --- /dev/null +++ b/miniprogram/pages/databaseTest/databaseTest.json @@ -0,0 +1,11 @@ +{ + "component": true, + "usingComponents": { + "i-tabs": "../../dist/tabs/index", + "i-tab": "../../dist/tab/index", + "i-swipeout": "../../dist/swipeout/index", + "i-cell": "../../dist/cell/index", + "i-divider": "../../dist/divider/index", + "i-icon": "../../dist/icon/index" + } +} \ No newline at end of file diff --git a/miniprogram/pages/databaseTest/databaseTest.wxml b/miniprogram/pages/databaseTest/databaseTest.wxml new file mode 100644 index 0000000..b19d649 --- /dev/null +++ b/miniprogram/pages/databaseTest/databaseTest.wxml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/miniprogram/pages/databaseTest/databaseTest.wxss b/miniprogram/pages/databaseTest/databaseTest.wxss new file mode 100644 index 0000000..ec9776b --- /dev/null +++ b/miniprogram/pages/databaseTest/databaseTest.wxss @@ -0,0 +1,101 @@ +.button{ + width: 40%; + margin-top: 35rpx; + color: red; + border-radius: 60rpx; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} +/* pages/list/list.wxss */ +.row,.row2{ + margin-top: 2px; + height :50px; + width: 95%; + margin-left:auto; + margin-right:auto; + background-color:white +} +page { + background: #F6F6F6; + display: flex; + flex-direction: column; + justify-content: flex-start; +} +.itm{ + margin-left: 20px; + color: rgb(99, 98, 101); + font-style: initial; + +} +.row2{ + background-color:rgb(221, 206, 255); +} + +.blk0,.blk1{ + border: 1px solid rgb(178, 139, 255); + width: 72px; + height:30px; + margin-left: 5px; + border-radius: 10px; + color: rgb(178, 139, 255); + text-align: center; +} +.blk1{ + border: 1px solid rgb(178, 139, 255); + background-color: rgb(178, 139, 255); + color: white; + border-radius: 10px; + +} +.row3{ + display: flex; + flex-direction: row; + margin-top: 5px; +} +.i-cell-padding{ + height: 28px; +} + +.i-row-class{ + margin-bottom:20px; +} + +.circle-button{ + font-size: 60rpx; + color: white; + text-align: center; + border-radius: 100%; +} + +.circle-view1{ + height: 120rpx; + width: 120rpx; + background-color: #19be6b; + border-radius: 100%; + position: fixed; + bottom: 100rpx; + right: 40rpx; + display: flex; + align-items: center; + justify-content: center; + z-index: 9; + border: 0 solid #ffffff; + box-shadow: 4px 1px 1px #cccccc; +} +.circle-view2{ + height: 120rpx; + width: 120rpx; + background-color: #1ea4ed; + border-radius: 100%; + position: fixed; + bottom: 100rpx; + right: 40rpx; + display: flex; + align-items: center; + justify-content: center; + z-index: 9; + border: 0 solid #ffffff; + box-shadow: 4px 1px 1px #cccccc; +} \ No newline at end of file diff --git a/miniprogram/pages/index/index.js b/miniprogram/pages/index/index.js new file mode 100644 index 0000000..3ca2b17 --- /dev/null +++ b/miniprogram/pages/index/index.js @@ -0,0 +1,605 @@ +//index.js +var config = require('../../config') +var util = require('../../utils/util.js') +var authRESULT = require('../../utils/authRESULT') +var authGET = require('../../utils/authGET') +var authTIME = require('../../utils/authTIME') +const { $Message } = require('../../dist/base/index'); + +var app = getApp(); +function formatNumber(n) { + n = n.toString() + return n[1] ? n : '0' + n +} +Page({ + data: { + userInfo: {}, + logged: false,taskNULL:false,todayNULL:false,todayPNULL:false, + takeSession: false, + requestResult: '',button:"success", + loading: true,clearTimer: false,taskidstring:'', + nowTimestamp:0,deadline:[],beginline:[],deadline_P:[],beginline_P:[], + taskToday:{ + id:[], + beginTimestamp:[], + endTimestamp:[], + Detail:new Array, + }, + planToday:{ + id:0, + beginTimestamp:0, + endTimestamp:0, + Detail:new Array, + }, + importance: ['重要','一般','次要'], + }, + + onLoad: function(){ + wx.getSetting({ + success: function(res) { + console.log(res) + if(res.authSetting["scope.userInfo"] != true) + wx.reLaunch({ + url: '../init/init', + }) + } + }) + let that = this + app.listenLoading(function (res) { + console.log("cadsfaa",app.globalData.token) + that.setData({ + loading: false, + }) + if(app.globalData.token == null){ + $Message({ + content: '服务器维护中', + type: 'error' + }); + } + + }) + }, + onReady:function(){ + this.setData({ + nowTimestamp:new Date().getTime() + }); + console.log("now",this.data.nowTimestamp) + }, + onPullDownRefresh: function () { + let that = this; + app.listenLoading(function (res) { + that.onTODAY() + }) + + }, + stopPullDownRefresh(){ + wx.stopPullDownRefresh() + }, + onShow:function(){ + var that = this + app.listenLoading(function (res) { + that.onTODAY() + //that.onRESULTS() + that.onPOST() + }) + }, + onPOST:function(){ + var that = this + authTIME.authGET({ + url : "", + data: { + "dow":1, + }, + success: function (res) { + //console.log("get",res) + if(res.data.periods.length<=0){ + for(var i =1;i<8;i++){ + authTIME.authPOST({ + data: { + "dayOfWeek": i, + "periods": [{startScale: 2, endScale: 10}] + }, + success: function (res) { + console.log("post",res) + }, + fail: function (res) { + console.log(res) + } + }) + } + } + }, + fail: function (res) { + console.log(res) + } + }) + + }, + onTODAY: function () { + var that = this + authRESULT.authTODAY({ + url : "task", + success: function (res) { + var _taskid=[],_beginline=[],_endline=[],_begin_wxml=[],_dead_wxml=[] + if(res.statusCode <300 && res.data.length>0){ + for(var i =0;i < res.data.length;i++){ + var datee = res.data[i].end; + datee = new Date(datee.replace(/-/g, '/')) + var y = datee.getFullYear(); + var m = datee.getMonth()+1; + var d = datee.getDate(); + var h = datee.getHours(); + var mn= datee.getMinutes(); + var dateb = res.data[i].begin; + dateb = new Date(dateb.replace(/-/g, '/')) + var yy = dateb.getFullYear(); + var mm = dateb.getMonth()+1; + var dd = dateb.getDate(); + var hh = dateb.getHours(); + var mmnn= dateb.getMinutes(); + if(dd == new Date(that.data.nowTimestamp).getDate()){ + var ddl1 = '今天'+formatNumber(hh)+':'+formatNumber(mmnn) + } + else{ + var ddl1 = '明天'+formatNumber(hh)+':'+formatNumber(mmnn) + } + if(d == new Date(that.data.nowTimestamp).getDate()){ + var ddl = '今天 '+formatNumber(h)+':'+formatNumber(mn) + } + else{ + var ddl = '明天 '+formatNumber(h)+':'+formatNumber(mn) + } + _beginline.push(new Date(res.data[i].begin.replace(/-/g, '/')).getTime()) + _endline.push(new Date(res.data[i].end.replace(/-/g, '/')).getTime()) + _taskid.push(res.data[i].taskId) + _begin_wxml.push(ddl1) + _dead_wxml.push(ddl) + } + that.setData({ + 'taskToday.id':_taskid, + taskidstring:_taskid.join(','), + 'taskToday.beginTimestamp': _beginline, + 'taskToday.endTimestamp':_endline, + deadline:_dead_wxml, + beginline:_begin_wxml, + }) + //console.log("beginT",that.data.taskToday.beginTimestamp) + //console.log("end",that.data.taskToday.endTimestamp) + console.log('todayTask',that.data.taskToday) + that.onGETDETAIL() + } + else{ + that.setData({ + todayNULL:true, + 'taskToday.id':'', + 'taskToday.beginTimestamp': [], + 'taskToday.endTimestamp':[], + deadline:0, + beginline:0, + }) + console.log("NULL") + } + }, + fail: function (res) { + console.log(res) + } + }) + authRESULT.authTODAY({ + url : "plan", + success: function (res) { + var _planid=[],_beginline=[],_endline=[],_begin_wxml=[],_dead_wxml=[] + if(res.statusCode <300 && res.data.length>0){ + for(var i =0;i < res.data.length;i++){ + var datee =res.data[i].end; + datee = new Date(datee.replace(/-/g, '/')) + var y = datee.getFullYear(); + var m = datee.getMonth()+1; + var d = datee.getDate(); + var h = datee.getHours(); + var mn= datee.getMinutes(); + var dateb = res.data[i].begin; + dateb = new Date(dateb.replace(/-/g, '/')) + var yy = dateb.getFullYear(); + var mm = dateb.getMonth()+1; + var dd = dateb.getDate(); + var hh = dateb.getHours(); + var mmnn= dateb.getMinutes(); + if(dd == new Date(that.data.nowTimestamp).getDate()){ + var ddl1 = '今天'+formatNumber(hh)+':'+formatNumber(mmnn) + } + else{ + var ddl1 = '明天'+formatNumber(hh)+':'+formatNumber(mmnn) + } + if(d == new Date(that.data.nowTimestamp).getDate()){ + var ddl = '今天 '+formatNumber(h)+':'+formatNumber(mn) + } + else{ + var ddl = '明天 '+formatNumber(h)+':'+formatNumber(mn) + } + _beginline.push(new Date(res.data[i].begin.replace(/-/g, '/')).getTime()) + _endline.push(new Date(res.data[i].end.replace(/-/g, '/')).getTime()) + _planid.push(res.data[i].taskId) + _begin_wxml.push(ddl1) + _dead_wxml.push(ddl) + } + that.setData({ + 'planToday.id':_planid, + planidstring:_planid.join(','), + 'planToday.beginTimestamp':_beginline, + 'planToday.endTimestamp':_endline, + deadline_P:_dead_wxml, + beginline_P:_begin_wxml, + }) + //console.log("beginP",that.data.planToday.beginTimestamp) + //console.log("end",that.data.planToday.endTimestamp) + //console.log("开始",new Date(res.data[0].begin).getHours(), new Date(res.data[0].begin).getMinutes()) + console.log('todayPlan',that.data.planToday) + that.onGETDETAILP() + } + else{ + that.setData({ + todayPNULL:true, + 'planToday.id':'', + 'planToday.beginTimestamp': 0, + 'planToday.endTimestamp':0, + deadline_P:[], + beginline_P:[], + }) + console.log("PNULL") + } + }, + fail: function (res) { + console.log(res) + } + }) + }, + /* + onRESULTS: function () { + var that = this + authRESULT.authRESULTS({ + url : "task", + success: function (res) { + console.log("results",res) + var _taskid=[],_beginline_R=[] + if(res.data != "" ){ + for(var i = 0;i { + util.showSuccess('信道已连接') + console.log('WebSocket 信道已连接') + this.setData({ tunnelStatus: 'connected' }) + }) + + tunnel.on('close', () => { + util.showSuccess('信道已断开') + console.log('WebSocket 信道已断开') + this.setData({ tunnelStatus: 'closed' }) + }) + + tunnel.on('reconnecting', () => { + console.log('WebSocket 信道正在重连...') + util.showBusy('正在重连') + }) + + tunnel.on('reconnect', () => { + console.log('WebSocket 信道重连成功') + util.showSuccess('重连成功') + }) + + tunnel.on('error', error => { + util.showModel('信道发生错误', error) + console.error('信道发生错误:', error) + }) + + // 监听自定义消息(服务器进行推送) + tunnel.on('speak', speak => { + util.showModel('信道消息', speak) + console.log('收到说话消息:', speak) + }) + + // 打开信道 + tunnel.open() + + this.setData({ tunnelStatus: 'connecting' }) + }, + + + //点击「发送消息」按钮,测试使用信道发送消息 + + sendMessage() { + if (!this.data.tunnelStatus || !this.data.tunnelStatus === 'connected') return + // 使用 tunnel.isActive() 来检测当前信道是否处于可用状态 + if (this.tunnel && this.tunnel.isActive()) { + // 使用信道给服务器推送「speak」消息 + this.tunnel.emit('speak', { + 'word': 'I say something at ' + new Date(), + }); + } + }, + + + //点击「关闭信道」按钮,关闭已经打开的信道 + + closeTunnel() { + if (this.tunnel) { + this.tunnel.close(); + } + util.showBusy('信道连接中...') + this.setData({ tunnelStatus: 'closed' }) + }*/ diff --git a/miniprogram/pages/index/index.json b/miniprogram/pages/index/index.json new file mode 100644 index 0000000..e4f67b5 --- /dev/null +++ b/miniprogram/pages/index/index.json @@ -0,0 +1,22 @@ +{ + "component": true, + "enablePullDownRefresh": true, + "backgroundTextStyle": "dark", + "usingComponents": { + "i-row": "../../dist/row/index", + "i-col": "../../dist/col/index", + "i-card": "../../dist/card/index", + "i-progress": "../../dist/progress/index", + "i-grid": "../../dist/grid/index", + "i-grid-item": "../../dist/grid-item/index", + "i-grid-icon": "../../dist/grid-icon/index", + "i-grid-label": "../../dist/grid-label/index", + "i-count-down": "../../dist/count-down/index", + "i-button": "../../dist/button/index", + "i-icon": "../../dist/icon/index", + "i-message": "../../dist/message/index", + "i-load-more": "../../dist/load-more/index", + "i-divider": "../../dist/divider/index", + "i-spin": "../../dist/spin/index" + } +} \ No newline at end of file diff --git a/miniprogram/pages/index/index.wxml b/miniprogram/pages/index/index.wxml new file mode 100644 index 0000000..8fa5be0 --- /dev/null +++ b/miniprogram/pages/index/index.wxml @@ -0,0 +1,356 @@ + + + + + + + + + 时间块进度 + + + + + + + 类型 + + + + 任务 + + + + + 重要性 + + + + + + + + + + + + {{importance[taskToday.Detail[0].importantDegree-1]}} + + + + + + 任务标题 + + + {{taskToday.Detail[[0]].description}} + + + + + + + + 截止时间 + {{deadline[0]}} + + + + + + + + + + 当前 + + + + + + 时间块进度 + + + + + + + 类型 + + + + 计划 + + + + + 重要性 + + + + + + + + + + + + {{importance[planToday.Detail[0].importantDegree-1]}} + + + + + + 计划标题 + + + {{planToday.Detail.description}} + + + + + + + + 截止时间 + {{deadline_P}} + + + + + + + + + + 当前 + + + + + + + + + + + + 当前时间块无任务安排 + + + + + + + + + + + + + + + + + + + + + + 类型 + + + + 任务 + + + + + 重要性 + + + + + + + + + + + + {{importance[taskToday.Detail[index].importantDegree-1]}} + + + + + + 任务标题 + + + {{taskToday.Detail[index].description}} + + + + + 开始时间 {{beginline[index]}} + + + + + + + + + + + + + + + 类型 + + + + 计划 + + + + + 重要性 + + + + + + + + + + + + {{importance[planToday.Detail[index].importantDegree-1]}} + + + + + + 计划标题 + + + {{planToday.Detail[index].description}} + + + + + 开始时间 {{beginline_P[index]}} + + + + + + + + + + + + \ No newline at end of file diff --git a/miniprogram/pages/index/index.wxss b/miniprogram/pages/index/index.wxss new file mode 100644 index 0000000..e5a0515 --- /dev/null +++ b/miniprogram/pages/index/index.wxss @@ -0,0 +1,244 @@ +/**index.wxss**/ +page { + display: flex; + flex-direction: column; + justify-content: flex-start; + background: #F6F6F6; + background: url("http://static.codesdream.com/bk.png") no-repeat; + width: 100%; + background-size: 100% 100%; + background-attachment:fixed; +} + +.userinfo, .uploader, .tunnel,.row ,.row-small{ + margin-top: 40rpx; + height: 140rpx; + width: 100%; + background: #FFF; + border: 1px solid rgba(0, 0, 0, .1); + border-left: none; + border-right: none; + display: flex; + flex-direction: row; + align-items: center; + transition: all 300ms ease; +} + +.userinfo-avatar { + width: 100rpx; + height: 100rpx; + margin: 20rpx; + border-radius: 50%; +} + +.userinfo-nickname { + font-size: 32rpx; + color: #007AFF; + background-color: white; +} + +.userinfo-nickname::after { + border: none; +} + +.uploader, .tunnel { + height: auto; + padding: 0 0 0 40rpx; + flex-direction: column; + align-items: flex-start; + box-sizing: border-box; +} + +.uploader-text, .tunnel-text { + width: 100%; + line-height: 52px; + font-size: 34rpx; + color: #007AFF; +} + +.uploader-container { + width: 100%; + height: 400rpx; + padding: 20rpx 20rpx 20rpx 0; + display: flex; + align-content: center; + justify-content: center; + box-sizing: border-box; + border-top: 1px solid rgba(0, 0, 0, .1); +} + +.uploader-image { + width: 100%; + height: 360rpx; +} + +.tunnel { + padding: 0 0 0 40rpx; +} + +.tunnel-text { + position: relative; + color: #222; + display: flex; + flex-direction: row; + align-content: center; + justify-content: space-between; + box-sizing: border-box; + border-top: 1px solid rgba(0, 0, 0, .1); +} + +.tunnel-text:first-child { + border-top: none; +} + +.tunnel-switch { + position: absolute; + right: 20rpx; + top: -2rpx; +} + +.disable { + color: #888; +} + +.service { + position: fixed; + right: 40rpx; + bottom: 40rpx; + width: 140rpx; + height: 140rpx; + border-radius: 50%; + background: linear-gradient(#007AFF, #0063ce); + box-shadow: 0 5px 10px rgba(0, 0, 0, .3); + display: flex; + align-content: center; + justify-content: center; + transition: all 300ms ease; +} + +.service-button { + position: absolute; + top: 40rpx; +} + +.service:active { + box-shadow: none; +} + +.request-text { + padding: 20rpx 0; + font-size: 24rpx; + line-height: 36rpx; + word-break: break-all; +} + +.area3{ + margin-top: 15rpx; + display:flex; + /*row 横向 column 列表 */ + flex-direction: row; + background-color: #f9f7f7; + border-radius: 15rpx; + margin-left:15rpx; + margin-right:15rpx; + + } + .start{ + top: 20px; + position: relative; + } + .t1{ + position:relative; + margin-left: auto; + margin-right: auto; + } + .t2{ + position:relative; + margin-left: auto; + margin-right: auto; +} +.t3{ + margin-left: auto; + margin-right: auto; +} +.row,.row-small{ + width: auto; + margin-top: 0px; + left: 10px; + right: 10px; + width: 90%; + border: 0px; + +} +.btn,.sx,.sx2,.ks,.ks2{ + margin-left: auto; + margin-right: auto; + height: 40px; + background-color: lightslategrey; + color: white; + text-align: center; + +} +.sx2{ + background-color:rgb(65, 65, 65) ; +} +.progress-box{ + height: 30px; + width: 250px; + margin-left: 20px; +} +.pro{ + color: rgb(140, 141, 147); +} +.ks{ + background-color: #9553ff; +} +.ks2{ + background-color: #574279; +} +.btn{ + margin-left:20px ; +} + +.row-class{ + margin-bottom:20px; +} + +.row-class-near{ + margin-bottom:5px; +} + +.count-down{ + font-size: 20px; + height: 20px; + line-height: 1; +} + +.tp-title{ + text-align: center; + font-size: 18px; + color: #495060; +} + +.divLine{ + background: #E0E3DA; + width: 100%; + height: 3rpx; +} + +.row-card{ + margin-top: 10px; + margin-bottom: 10px; +} + +.no-alloc-desc{ + margin-top: 15px; +} + +.load-more{ + color: #ff9900; +} + +.no-alloc-row{ + height: 250px; +} \ No newline at end of file diff --git a/miniprogram/pages/information/about/about.js b/miniprogram/pages/information/about/about.js new file mode 100644 index 0000000..990b39f --- /dev/null +++ b/miniprogram/pages/information/about/about.js @@ -0,0 +1,72 @@ +// miniprogram/pages/information/about/about.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + loading : true + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + imgLoad(res) { + this.setData({ + loading:false, + }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/miniprogram/pages/information/about/about.json b/miniprogram/pages/information/about/about.json new file mode 100644 index 0000000..d802632 --- /dev/null +++ b/miniprogram/pages/information/about/about.json @@ -0,0 +1,11 @@ +{ + "usingComponents": { + "i-row": "../../../dist/row/index", + "i-col": "../../../dist/col/index", + "i-input": "../../../dist/input/index", + "i-panel": "../../../dist/panel/index", + "i-radio-group": "../../../dist/radio-group/index", + "i-radio": "../../../dist/radio/index", + "i-spin": "../../../dist/spin/index" + } +} \ No newline at end of file diff --git a/miniprogram/pages/information/about/about.wxml b/miniprogram/pages/information/about/about.wxml new file mode 100644 index 0000000..503e84f --- /dev/null +++ b/miniprogram/pages/information/about/about.wxml @@ -0,0 +1,29 @@ + + + + + + + + + + 码梦工坊 + + + + + 自动日程规划 + + + + + Version + 1.2.1 + + + + + + Copyright © 2020 码梦工坊. All rights reserved. + + \ No newline at end of file diff --git a/miniprogram/pages/information/about/about.wxss b/miniprogram/pages/information/about/about.wxss new file mode 100644 index 0000000..76873aa --- /dev/null +++ b/miniprogram/pages/information/about/about.wxss @@ -0,0 +1,54 @@ +/* miniprogram/pages/information/about/about.wxss */ + +page { + background: #F6F6F6; + display: flex; + flex-direction: column; + justify-content: flex-start; + background: url("http://static.codesdream.com/bk.png") no-repeat; + width: 100%; + background-size: 100% 100%; + background-attachment:fixed; +} + +.icon-row{ + margin-top: 40%; +} + +.title-row{ + margin-top: 5px; + font-size: 26px; + font-weight: bold; + text-align: center; +} + +.text-row{ + margin-top: 8px; + font-size: 17px; + text-decoration: underline; +} +.version-row{ + margin-top: 8px; + font-size: 17px; + font-weight: bold; +} + +.copyright-row{ + position: fixed; + width: 100%; + height: 50rpx; + bottom:0px; + z-index: -1; +} + +.copyright-text{ + color: #80848f; + font-size: smaller; +} + +.center-view{ + margin-top: 0px; + text-align: center; + display: flex; + justify-content: center; +} \ No newline at end of file diff --git a/miniprogram/pages/information/graph/graph.js b/miniprogram/pages/information/graph/graph.js new file mode 100644 index 0000000..9f06e9d --- /dev/null +++ b/miniprogram/pages/information/graph/graph.js @@ -0,0 +1,245 @@ +// miniprogram/pages/information/graph/graph.js +var uCharts = require('../../../utils/ucharts/u-charts'); +var authCOMP = require('../../../utils/authCOMP') +Page({ + + /** + * 页面的初始数据 + */ + data: { + allFinishRate: 0.00, + taskFinishRate: 0.00, + planFinishRate: 0.00 + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + let that = this + this.showFinishedRate("canvasAllFinishedRate", + { + series: [{ + name: '总完成度', + data: this.data.allFinishRate, + color: '#19be6b' + }] + }); + + this.showFinishedRate("canvasTaskFinishedRate", + { + series: [{ + name: '任务完成度', + data: this.data.taskFinishRate, + color: '#2d8cf0' + }] + }); + + this.showFinishedRate("canvasPlanFinishedRate", + { + series: [{ + name: '计划完成度', + data: this.data.planFinishRate, + color: '#ff9900' + }] + }); + + this.showFunnel("funnelFinished", + { + "series": [{ + "name": "90%-100%", + "data": 0 + }, { + "name": "80%-90%", + "data": 0 + }, { + "name": "70%-80%", + "data": 0 + }, { + "name": "60%-70%", + "data": 0 + }, { + "name": "<60%", + "data": 0 + }] + }); + this.showColumn("columnNumbered", + { + "categories": ["周一", "周二", "周三", "周四", "周五", "周六", "周日"], + "series": [{ + "name": "已完成", + "data": [0, {"value": 0,"color": "#f04864"}, 0, 0, 0, 0] + }, { + "name": "未完成", + "data": [0, {"value": 0,"color": "#facc14"}, 0, 0, 0, 0] + }] + }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + this.onQuery() + }, + onQuery:function(){ + authCOMP.authCOMP({ + url : "total", + data: { + + }, + success: function (res) { + console.log("get",res) + + }, + fail: function (res) { + console.log(res) + } + }) + }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + + showFunnel: function(canvasId, chartData){ + canvaFunnel=new uCharts({ + $this:this, + canvasId: canvasId, + type: 'funnel', + fontSize:11, + padding:[15,15,0,15], + legend:{ + show:true, + padding:5, + lineHeight:11, + margin:0, + }, + background:'#FFFFFF', + pixelRatio:this.pixelRatio, + series: chartData.series, + animation: true, + width: 300, + height: 200, + dataLabel: true, + extra: { + funnel: { + border:true, + borderWidth:2, + borderColor:'#FFFFFF' + } + }, + }) + }, + + showFinishedRate: function(canvasId, chartData){ + canvasFinishedRate = new uCharts({ + $this:this, + canvasId: canvasId, + type: 'arcbar', + fontSize:11, + legend:{show:false}, + background:'#FFFFFF', + pixelRatio:1, + series: chartData.series, + animation: true, + width: 120, + height: 120, + dataLabel: true, + title: { + name: Math.round(chartData.series[0].data*100)+'%', + color: chartData.series[0].color, + fontSize: 25 + }, + subtitle: { + name: chartData.series[0].name, + color: '#666666', + fontSize: 15 + }, + extra: { + arcbar:{ + type:'default', + width:10 + } + } + }); + }, + + showColumn : function(canvasId, chartData) { + canvaColumn=new uCharts({ + $this:this, + canvasId: canvasId, + type: 'column', + legend:{show:true}, + fontSize:11, + background:'#FFFFFF', + pixelRatio:1, + animation: true, + categories: chartData.categories, + series: chartData.series, + xAxis: { + disableGrid:true, + }, + yAxis: { + //disabled:true + }, + dataLabel: true, + width: 300, + height: 210, + extra: { + column: { + type:'group', + width: 20 + } + } + }); + }, + touchColumn(e) { + canvaColumn.showToolTip(e, { + format: function (item, category) { + if (typeof item.data === 'object') { + return category + ' ' + item.name + ':' + item.data.value + } else { + return category + ' ' + item.name + ':' + item.data + } + } + }); + }, +}) \ No newline at end of file diff --git a/miniprogram/pages/information/graph/graph.json b/miniprogram/pages/information/graph/graph.json new file mode 100644 index 0000000..617d8fb --- /dev/null +++ b/miniprogram/pages/information/graph/graph.json @@ -0,0 +1,7 @@ +{ + "usingComponents": { + "i-row": "../../../dist/row/index", + "i-col": "../../../dist/col/index", + "i-panel": "../../../dist/panel/index" + } +} \ No newline at end of file diff --git a/miniprogram/pages/information/graph/graph.wxml b/miniprogram/pages/information/graph/graph.wxml new file mode 100644 index 0000000..d5523b9 --- /dev/null +++ b/miniprogram/pages/information/graph/graph.wxml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/miniprogram/pages/information/graph/graph.wxss b/miniprogram/pages/information/graph/graph.wxss new file mode 100644 index 0000000..0c1f73a --- /dev/null +++ b/miniprogram/pages/information/graph/graph.wxss @@ -0,0 +1,32 @@ +/* miniprogram/pages/information/graph/graph.wxss */ + +page{ + background-color: #F6F6F6; + background: url("http://static.codesdream.com/bk.png") no-repeat; + width: 100%; + background-size: 100% 100%; + background-attachment:fixed; +} + +.center-view{ + text-align: center; + justify-content: center; + +} + +.finished-row{ + height: 160px; +} + +.numbered-row{ + height: 300px; +} + +.row-view{ + +} + +.charts{ + height: 200px; + width: 100%; +} \ No newline at end of file diff --git a/miniprogram/pages/information/help/help.js b/miniprogram/pages/information/help/help.js new file mode 100644 index 0000000..54e9f7d --- /dev/null +++ b/miniprogram/pages/information/help/help.js @@ -0,0 +1,66 @@ +// miniprogram/pages/information/help/help.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/miniprogram/pages/information/help/help.json b/miniprogram/pages/information/help/help.json new file mode 100644 index 0000000..42caa53 --- /dev/null +++ b/miniprogram/pages/information/help/help.json @@ -0,0 +1,7 @@ +{ + "usingComponents": { + "i-panel": "../../../dist/panel/index", + "i-cell-group": "../../../dist/cell-group/index", + "i-cell": "../../../dist/cell/index" + } +} \ No newline at end of file diff --git a/miniprogram/pages/information/help/help.wxml b/miniprogram/pages/information/help/help.wxml new file mode 100644 index 0000000..af4107f --- /dev/null +++ b/miniprogram/pages/information/help/help.wxml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/miniprogram/pages/information/help/help.wxss b/miniprogram/pages/information/help/help.wxss new file mode 100644 index 0000000..628dbff --- /dev/null +++ b/miniprogram/pages/information/help/help.wxss @@ -0,0 +1 @@ +/* miniprogram/pages/information/help/help.wxss */ \ No newline at end of file diff --git a/miniprogram/pages/information/information.js b/miniprogram/pages/information/information.js new file mode 100644 index 0000000..271ee50 --- /dev/null +++ b/miniprogram/pages/information/information.js @@ -0,0 +1,87 @@ +// pages/information/information.js +var authGET = require('../../utils/authGET') +const app = getApp() +Page({ + + data: { + avatarUrl: '../../images/user-unlogin.png', + userInfo: {}, + loading: true, + }, + onLoad:function(){ + var that = this; + wx.getSetting({ + success: res => { + if (res.authSetting['scope.userInfo']) { + // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 + wx.getUserInfo({ + success: res => { + that.setData({ + avatarUrl: res.userInfo.avatarUrl, + userInfo: res.userInfo, + loading: false, + + }) + app.globalData.userInfo=this.data.userInfo + console.log(app.globalData.userInfo); + let that1 = that; + authGET.authGET({ + url : "user/star", + data: { + }, + success: function (res) { + console.log(res) + that1.setData({ + star : res.data.starNum, + starDescription : res.data.description, + loading: false + }) + }, + fail: function (res) { + console.log(res) + that1.setData({ + star : 0, + starDescription : "暂无执行力评价", + loading: false + }) + } + }) + } + }) + } + else{ + wx.showToast({ + title: '未登录', + icon:'none', + duration:2000, + }) + } + } + }); + }, + goSetting :function(){ + wx.navigateTo({ + url: 'setting/setting', + }) + }, + goHelp :function(){ + wx.navigateTo({ + url: 'help/help', + }) +}, + goGraph :function(){ + wx.navigateTo({ + url: 'graph/graph', + }) +}, + goSubmit :function(){ + wx.navigateTo({ + url: 'submit/submit', + }) + }, + goAbout :function(){ + wx.navigateTo({ + url: 'about/about', + }) + } +}) diff --git a/miniprogram/pages/information/information.json b/miniprogram/pages/information/information.json new file mode 100644 index 0000000..7322aed --- /dev/null +++ b/miniprogram/pages/information/information.json @@ -0,0 +1,25 @@ +{ + "component": true, + "usingComponents": { + "i-row": "../../dist/row/index", + "i-col": "../../dist/col/index", + "i-card": "../../dist/card/index", + "i-progress": "../../dist/progress/index", + "i-grid": "../../dist/grid/index", + "i-grid-item": "../../dist/grid-item/index", + "i-grid-icon": "../../dist/grid-icon/index", + "i-grid-label": "../../dist/grid-label/index", + "i-count-down": "../../dist/count-down/index", + "i-icon": "../../dist/icon/index", + "i-avatar": "../../dist/avatar/index", + "i-button": "../../dist/button/index", + "i-cell-group": "../../dist/cell-group/index", + "i-cell": "../../dist/cell/index", + "i-rate": "../../dist/rate/index", + "i-spin": "../../dist/spin/index", + "mp-cells": "weui-miniprogram/cells/cells", + "mp-cell": "weui-miniprogram/cell/cell", + "mp-slideview": "weui-miniprogram/slideview/slideview", + "mp-icon": "weui-miniprogram/icon/icon" +} +} \ No newline at end of file diff --git a/miniprogram/pages/information/information.wxml b/miniprogram/pages/information/information.wxml new file mode 100644 index 0000000..75a8baf --- /dev/null +++ b/miniprogram/pages/information/information.wxml @@ -0,0 +1,48 @@ + + + + + + + + + {{userInfo.nickName}} + + + + + + {{starDescription}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/miniprogram/pages/information/information.wxss b/miniprogram/pages/information/information.wxss new file mode 100644 index 0000000..e81157a --- /dev/null +++ b/miniprogram/pages/information/information.wxss @@ -0,0 +1,93 @@ +/* pages/information/information.wxss */ + +page { + background: #F6F6F6; + display: flex; + flex-direction: column; + justify-content: flex-start; + background: url("http://static.codesdream.com/bk.png") no-repeat; + width: 100%; + background-size: 100% 100%; + background-attachment:fixed; +} +.row,.row0,.row2{ + margin-top: 2px; + height :50px; + width: 95%; + margin-left:auto; + margin-right:auto; + background-color:white +} +.row0{ + height: 100px; + display: flex; + flex-direction: row; +} +.row2{ +margin-top: 0; +} +.tou{ + width: 70px; + height: 70px; + margin-top: 36px; + margin-left: 30px; + border: 1px solid #80848f; + border-radius: 100%; + background-color: #f6f9ff; +} +.shu{ + left: 20px; + top: 10px; + position: relative; +} + +.set,.set2{ + width: 110px; + height: 30px; + font-size: 13px; + color: rgb(133, 112, 182); + background-color: rgb(255, 255, 255); + margin-top:10px ; + margin-left: 0; + border: 1px solid rgb(133, 112, 182); +} + +.set2{ + background-color: rgb(184, 160, 255); +} + +.info-name{ + font-size: 18px; + font-weight: bold; +} +.info-title{ + font-size: 13px; + font-weight: bold; +} + +.row-class{ + margin-bottom: 10px; +} + +.divLine{ + background: #E0E3DA; + width: 100%; + height: 3rpx; + margin-top: 5px; +} + +.name-row{ + margin-top: 15px; +} + +.rate-class{ + margin-left: 10px; +} + +.info-row-class{ + background-color: white; +} + +.menu{ + font-size: smaller; +} diff --git a/miniprogram/pages/information/setting/setting.js b/miniprogram/pages/information/setting/setting.js new file mode 100644 index 0000000..0ea30ef --- /dev/null +++ b/miniprogram/pages/information/setting/setting.js @@ -0,0 +1,136 @@ +// pages/information/setting/setting.js +var app = getApp(); +var authTIME = require('../../../utils/authTIME') +function formatNumber(n) { + n = n.toString() + return n[1] ? n : '0' + n +} +Page({ + data: { + hiddenmodalput: true, + current: 'tab1', + hour:['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23'],beginhour_index:0,endhour_index:0, + minute:["00","30"],beginmin_index:0,endmin_index:0, + week:["","周一","周二","周三","周四","周五","周六","周日"], + week_index:1, + FBTimeList:[[{startScale: 0, endScale: 12}],[{startScale: 0, endScale: 12}],[{startScale: 0, endScale: 12}],[{startScale: 0, endScale: 12}],[{startScale: 0, endScale: 12}],[{startScale: 0, endScale: 12}],[{startScale: 0, endScale: 12}],[{startScale: 0, endScale: 12}]], + actions : [{ + name : '删除', + width : 100, + color : '#fff', + fontsize : '20', + icon : 'trash', + background : '#ed3f14' + }] + }, + onLoad:function(){ + this.onGET() + }, + onGET:function(){ + var that = this + authTIME.authGET({ + url : "", + data: { + "dow":this.data.week_index, + }, + success: function (res) { + console.log("get",res) + var FBTL =that.data.FBTimeList + FBTL.splice(res.data.dayOfWeek,1,res.data.periods) + that.setData({ + FBTimeList:FBTL + }) + console.log("FB",that.data.FBTimeList) + }, + fail: function (res) { + console.log(res) + } + }) + }, + onPOST:function(){ + var that = this + authTIME.authPOST({ + data: { + "dayOfWeek": this.data.week_index, + "periods": this.data.FBTimeList[this.data.week_index] + }, + success: function (res) { + console.log("post",res) + that.onGET() + }, + fail: function (res) { + console.log(res) + } + }) + }, + handleChange ({ detail }) { + this.setData({ + current: detail.key, + week_index:detail.key.substr(-1), + }); + this.onGET() + }, + modalinput:function(){ + this.setData({ + hiddenmodalput: !this.data.hiddenmodalput + }) + }, + cancel: function(){ + this.setData({ + hiddenmodalput: true, + }); + }, + confirm: function(){ //确认 + this.setData({ + hiddenmodalput: true, + }) + this.goCreateFBtime() + }, + bindBeginhourChange:function(e){ + this.setData({ + beginhour_index:e.detail.value + }) + console.log('beginhour值为', this.data.beginhour_index) + }, + bindEndhourChange:function(e){ + this.setData({ + endhour_index:e.detail.value + }) + console.log('endhour值为', this.data.endhour_index) + }, + bindBeginminChange:function(e){ + this.setData({ + beginmin_index:e.detail.value + }) + console.log('beginmin值为', this.data.beginmin_index) + }, + bindEndminChange:function(e){ + this.setData({ + endmin_index:e.detail.value + }) + console.log('endmin值为', this.data.endmin_index) + }, + goCreateFBtime(e){ + var dayFBTime=this.data.FBTimeList + var a={ + "startScale":this.data.beginhour_index*2+this.data.beginmin_index*1, + "endScale":this.data.endhour_index*2+this.data.endmin_index*1, + } + dayFBTime[this.data.week_index].push(a) + this.setData({ + FBTimeList:dayFBTime, + }) + console.log("FBTimeList",this.data.FBTimeList) + this.onPOST() + }, + deleteTime:function(e){ + console.log(e.currentTarget.dataset.value) + var dayFBTime=this.data.FBTimeList + dayFBTime[this.data.week_index].splice(e.currentTarget.dataset.value,1) + this.setData({ + FBTimeList:dayFBTime + }) + this.onPOST() + } + +}) diff --git a/miniprogram/pages/information/setting/setting.json b/miniprogram/pages/information/setting/setting.json new file mode 100644 index 0000000..4f6b9f7 --- /dev/null +++ b/miniprogram/pages/information/setting/setting.json @@ -0,0 +1,20 @@ +{ + "component": true, + "usingComponents": { + "i-row": "../../../dist/row/index", + "i-col": "../../../dist/col/index", + "i-card": "../../../dist/card/index", + "i-progress": "../../../dist/progress/index", + "i-grid": "../../../dist/grid/index", + "i-grid-item": "../../../dist/grid-item/index", + "i-grid-icon": "../../../dist/grid-icon/index", + "i-grid-label": "../../../dist/grid-label/index", + "i-count-down": "../../../dist/count-down/index", + "i-button": "../../../dist/button/index", + "i-icon": "../../../dist/icon/index", + "i-avatar": "../../../dist/avatar/index", + "i-tabs": "../../../dist/tabs/index", + "i-tab": "../../../dist/tab/index", + "i-swipeout": "../../../dist/swipeout/index" + } +} \ No newline at end of file diff --git a/miniprogram/pages/information/setting/setting.wxml b/miniprogram/pages/information/setting/setting.wxml new file mode 100644 index 0000000..812f539 --- /dev/null +++ b/miniprogram/pages/information/setting/setting.wxml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 开始:{{(FBTimeList[week_index][index].startScale/2)|Int}}时{{(FBTimeList[week_index][index].startScale%2)*30}}分 + + + + 结束:{{(FBTimeList[week_index][index].endScale/2)|Int}}时{{(FBTimeList[week_index][index].endScale%2*30)}}分 + + + + + + + \ No newline at end of file diff --git a/miniprogram/pages/information/setting/setting.wxss b/miniprogram/pages/information/setting/setting.wxss new file mode 100644 index 0000000..b1a0510 --- /dev/null +++ b/miniprogram/pages/information/setting/setting.wxss @@ -0,0 +1,91 @@ +/* pages/information/setting/setting.wxss */ +.btn{ + width:200px; +} +.btn-area{ + display: flex; + flex-direction: row; +} +.box{ + display: flex; + flex-direction: row; + width:100%; + height: auto; +} +.t2{ + font-size: 10px; +} +.page-section{ + margin-top:10px; +} +.page-section3{ + margin-top:40px; +} +.c1{ + + background-color: rgb(80, 80, 80); +} + +.blk0,.blk1{ + border: 1px solid rgb(127, 63, 255); + width: 72px; + height:40px; + margin-left: 5px; + border-radius: 10px; + color: rgb(127, 63, 255); + text-align: center; +} +.blk1{ + border: 1px solid rgb(127, 63, 255); + background-color: rgb(127, 63, 255); + color: white; + border-radius: 10px; + +} +.row3{ + display: flex; + flex-direction: row; + margin-top: 5px; +} +page{ + background-color: #F6F6F6; + background: url("http://static.codesdream.com/bk.png") no-repeat; + width: 100%; + background-size: 100% 100%; + background-attachment:fixed; +} + +input[type=checkbox] { + zoom: 50%; +} + +.circle-view1{ + height: 120rpx; + width: 120rpx; + background-color: #19be6b; + border-radius: 100%; + position: fixed; + bottom: 100rpx; + right: 40rpx; + display: flex; + align-items: center; + justify-content: center; + z-index: 9; + border: 0 solid #ffffff; + box-shadow: 4px 1px 1px #cccccc; +} + +.item-row{ + height: 12px; +} + +.item{ + height: 56px; +} + +.center-view{ + margin-top: 0px; + text-align: center; + display: flex; + justify-content: center; +} \ No newline at end of file diff --git a/miniprogram/pages/information/submit/submit.js b/miniprogram/pages/information/submit/submit.js new file mode 100644 index 0000000..6a1cbc1 --- /dev/null +++ b/miniprogram/pages/information/submit/submit.js @@ -0,0 +1,155 @@ +// miniprogram/pages/information/submit/submit.js +var authPOST = require('../../../utils/authPOST') +let app = getApp(); + +Page({ + + /** + * 页面的初始数据 + */ + data: { + userInfo: {}, + complain: [{id: 1,name: '漏洞反馈',}, {id: 2,name: '功能建议'}], + current: '漏洞反馈', + type: 0, + nickname:'', + emali:'', + text:'', + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + wx.getSetting({ + success: res => { + if (res.authSetting['scope.userInfo']) { + // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 + wx.getUserInfo({ + success: res => { + this.setData({ + avatarUrl: res.userInfo.avatarUrl, + userInfo: res.userInfo, + }) + app.globalData.userInfo=this.data.userInfo + console.log(app.globalData.userInfo); + + } + }) + } + else{ + wx.showToast({ + title: '未登录', + icon:'none', + duration:2000, + }) + } + } + }); + }, + + handleComplainChange: function({ detail = {} }) { + var index=0 + if(detail.value == "漏洞反馈") index=0 + else if (detail.value == "功能建议") index=1 + this.setData({ + type: index, + current:detail.value, + }); + console.log('chang_type', this.data.type) + }, + + bindNickNameBlur(e) { + console.log('nickname发生改变,携带值为', e.detail.detail.value) + this.setData({ + nickname: e.detail.detail.value + }) + console.log('nickname值为', this.data.nickname) + }, + bindEmailBlur(e) { + console.log('email发生改变,携带值为', e.detail.detail.value) + this.setData({ + emali: e.detail.detail.value + }) + console.log('email值为', this.data.emali) + }, + bindTextBlur(e) { + console.log('text发生改变,携带值为', e.detail.detail.value) + this.setData({ + text: e.detail.detail.value + }) + console.log('text值为', this.data.text) + }, + handleSubmit() { + authPOST.authPOST({ + url : "user/submit", + data: { + "type":this.data.type, + "text":this.data.text + }, + success: function (res) { + console.log(res) + wx.reLaunch({ + url: '../information', + }) + wx.showToast({ + title: '创建成功', + icon:"success", + duration: 2000 + }) + }, + fail: function (res) { + console.log(res) + } + }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/miniprogram/pages/information/submit/submit.json b/miniprogram/pages/information/submit/submit.json new file mode 100644 index 0000000..499b04a --- /dev/null +++ b/miniprogram/pages/information/submit/submit.json @@ -0,0 +1,12 @@ +{ + "usingComponents": { + "i-row": "../../../dist/row/index", + "i-col": "../../../dist/col/index", + "i-input": "../../../dist/input/index", + "i-panel": "../../../dist/panel/index", + "i-radio-group": "../../../dist/radio-group/index", + "i-radio": "../../../dist/radio/index", + "i-button": "../../../dist/button/index", + "i-toast": "../../../dist/toast/index" + } +} \ No newline at end of file diff --git a/miniprogram/pages/information/submit/submit.wxml b/miniprogram/pages/information/submit/submit.wxml new file mode 100644 index 0000000..a2796ec --- /dev/null +++ b/miniprogram/pages/information/submit/submit.wxml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + +提交反馈 \ No newline at end of file diff --git a/miniprogram/pages/information/submit/submit.wxss b/miniprogram/pages/information/submit/submit.wxss new file mode 100644 index 0000000..669e9dc --- /dev/null +++ b/miniprogram/pages/information/submit/submit.wxss @@ -0,0 +1,12 @@ +/* miniprogram/pages/information/submit/submit.wxss */ + +page { + background: #F6F6F6; + display: flex; + flex-direction: column; + justify-content: flex-start; +} + +.button-row{ + margin-top: 40px; +} \ No newline at end of file diff --git a/miniprogram/pages/init/down.png b/miniprogram/pages/init/down.png new file mode 100644 index 0000000..a19ab40 Binary files /dev/null and b/miniprogram/pages/init/down.png differ diff --git a/miniprogram/pages/init/init.js b/miniprogram/pages/init/init.js new file mode 100644 index 0000000..2df4a15 --- /dev/null +++ b/miniprogram/pages/init/init.js @@ -0,0 +1,94 @@ +// miniprogram/pages/init/init.js +let app = getApp() +Page({ + + /** + * 页面的初始数据 + */ + data: { + loading: true, + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + imgLoad1(res) { + this.setData({ + loading:false, + }) + }, + + /*微信授权登陆 */ + getuserinfo:function(e){ + if(e.detail.userInfo){ + console.log('授权通过') + app.globalData.userInfo = e.detail.userInfo + console.log( app.globalData.userInfo) + wx.reLaunch({ + url: '../index/index', + }) + }else{ + console.log('拒绝授权') + wx.showModal({ + title: '真香警告!' + }) + } + }, + + noneLoading(res){ + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/miniprogram/pages/init/init.json b/miniprogram/pages/init/init.json new file mode 100644 index 0000000..d219d00 --- /dev/null +++ b/miniprogram/pages/init/init.json @@ -0,0 +1,18 @@ +{ + "usingComponents": { + "i-row": "../../dist/row/index", + "i-col": "../../dist/col/index", + "i-card": "../../dist/card/index", + "i-progress": "../../dist/progress/index", + "i-grid": "../../dist/grid/index", + "i-grid-item": "../../dist/grid-item/index", + "i-grid-icon": "../../dist/grid-icon/index", + "i-grid-label": "../../dist/grid-label/index", + "i-count-down": "../../dist/count-down/index", + "i-button": "../../dist/button/index", + "i-icon": "../../dist/icon/index", + "i-load-more": "../../dist/load-more/index", + "i-divider": "../../dist/divider/index", + "i-spin": "../../dist/spin/index" + } +} \ No newline at end of file diff --git a/miniprogram/pages/init/init.wxml b/miniprogram/pages/init/init.wxml new file mode 100644 index 0000000..548f9d9 --- /dev/null +++ b/miniprogram/pages/init/init.wxml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/miniprogram/pages/init/init.wxss b/miniprogram/pages/init/init.wxss new file mode 100644 index 0000000..0519abf --- /dev/null +++ b/miniprogram/pages/init/init.wxss @@ -0,0 +1,27 @@ +/* miniprogram/pages/init/init.wxss */ +.btn{ + position: absolute; + top: 500px; + right :20px; + width: 50px; + height: 30px; + background-color: white; +} + +.down-img{ + width: 20px; + height: 30px; +} + +.down-row{ + position: fixed; + bottom: 20px; + width: 100%; +} + +.auth-button{ + width: 70%; + margin-top: 20px; + margin-bottom: 50px; + background-color: #19be6b; +} \ No newline at end of file diff --git a/miniprogram/pages/list/createPlan/createPlan.js b/miniprogram/pages/list/createPlan/createPlan.js new file mode 100644 index 0000000..a845795 --- /dev/null +++ b/miniprogram/pages/list/createPlan/createPlan.js @@ -0,0 +1,310 @@ +// pages/create/create.js +const app = getApp() +var authPOST = require('../../../utils/authPOST') +var authGET = require('../../../utils/authGET') +var authPATCH = require('../../../utils/authPATCH') +var util = require('../../../utils/util.js') +const date = new Date(); +const years = []; +const months = []; +const days = []; +const hours = []; +const minitue = ['00分','30分']; +//获取年 +for (let i = date.getFullYear(); i <= date.getFullYear() + 1; i++) { + years.push("" + i+'年'); + } +for (let i = 1; i <= 12; i++) { + if (i < 10) { + i = "0" + i; + } + months.push("" + i+'月'); +} +for (let i = 1; i <= 31; i++) { + if (i < 10) { + i = "0" + i; + } + days.push("" + i+'日'); +} +for (let i = 0; i < 24; i++) { + if (i < 10) { + i = "0" + i; + } + hours.push("" + i+'时'); +} +function formatNumber(n) { + n = n.toString() + return n[1] ? n : '0' + n +} +Page({ + data: { + multiArray: [years, months,days, hours, minitue], + multiIndex: [0, 9, 16, 10, 17], + choose_year: '', + hh:"\n", + description:new Array, + dscp:'', + + ddl_time:'', + deadline:0, + importance: [{id: 1,name: '重要',}, {id: 2,name: '一般'}, {id: 3,name: '次要'}], + current: '一般',importantDegree:1, + prefer_time: [{id: 0,name: '任意'},{id: 1,name: '早上',}, {id: 2,name: '中午'}, {id: 3,name: '晚上'}], + pt_current: '任意',pref_index:-1, + + singleMin:0, + dd:0,duration:0,//所需时间块 + mutexPeriod:0, + + position: 'left', + checked: false, + disabled: false, + error: '', + + }, + onLoad: function(options) { + //设置默认的年份 + this.setData({ + choose_year: this.data.multiArray[0][0] + }) + }, + onReady:function(){ + var timestamp = Date.parse(new Date()); + timestamp = timestamp / 1000; + var n = timestamp * 1000; + var date = new Date(n); + this.setData({ + multiIndex:[date.getFullYear(),date.getMonth(),date.getDate(),date.getHours()+1, 0], + ddl_time:[date.getFullYear(),date.getMonth()+1,date.getDate()].map(formatNumber).join('-')+' '+[date.getHours()+1, 00].map(formatNumber).join(':'), + }) + console.log(this.data.ddl_time) + }, + bindDescriptionBlur(e) { + console.log('description发送改变,携带值为', e.detail.detail.value) + let dscptn = new Array + dscptn.push(e.detail.detail.value) + this.setData({ + description: dscptn + }) + console.log('description值为', this.data.description) + }, + bindMultiPickerChange: function(e) { + console.log('picker发送选择改变,携带值为', e.detail.value) + this.setData({ + multiIndex: e.detail.value + }) + const index = this.data.multiIndex; + const year = this.data.multiArray[0][index[0]].slice(0,4); + const month = this.data.multiArray[1][index[1]].slice(0,2); + const day = this.data.multiArray[2][index[2]].slice(0,2); + const hour = this.data.multiArray[3][index[3]].slice(0,2); + const minute = this.data.multiArray[4][index[4]].slice(0,2); + //console.log(`${year}-${month}-${day} ${hour}:${minute}`); + this.setData({ + ddl_time: year + '-' + month + '-' + day + ' ' + hour + ':' + minute + }) + console.log(this.data.ddl_time); + }, + + bindMultiPickerColumnChange: function(e) { + //获取年份 + if (e.detail.column == 0) { + let choose_year = this.data.multiArray[e.detail.column][e.detail.value]; + console.log(choose_year); + this.setData({ + choose_year + }) + } + console.log('修改的列为', e.detail.column, ',值为', e.detail.value); + if (e.detail.column == 1) { + let num = parseInt(this.data.multiArray[e.detail.column][e.detail.value]); + let temp = []; + if (num == 1 || num == 3 || num == 5 || num == 7 || num == 8 || num == 10 || num == 12) { //判断31天的月份 + for (let i = 1; i <= 31; i++) { + if (i < 10) { + i = "0" + i; + } + temp.push("" + i+'日'); + } + this.setData({ + ['multiArray[2]']: temp + }); + } else if (num == 4 || num == 6 || num == 9 || num == 11) { //判断30天的月份 + for (let i = 1; i <= 30; i++) { + if (i < 10) { + i = "0" + i; + } + temp.push("" + i+'日'); + } + this.setData({ + ['multiArray[2]']: temp + }); + } else if (num == 2) { //判断2月份天数 + let year = parseInt(this.data.choose_year); + console.log(year); + if (((year % 400 == 0) || (year % 100 != 0)) && (year % 4 == 0)) { + for (let i = 1; i <= 29; i++) { + if (i < 10) { + i = "0" + i; + } + temp.push("" + i+'日'); + } + this.setData({ + ['multiArray[2]']: temp + }); + } else { + for (let i = 1; i <= 28; i++) { + if (i < 10) { + i = "0" + i; + } + temp.push("" + i+'日'); + } + this.setData({ + ['multiArray[2]']: temp + }); + } + } + //console.log(this.data.multiArray[2]); + } + var data = { + multiArray: this.data.multiArray, + multiIndex: this.data.multiIndex + }; + data.multiIndex[e.detail.column] = e.detail.value; + this.setData(data); + }, + + handleImportantChange({ detail = {} }) { + var imptdg=0 + if(detail.value == "重要") imptdg=0 + else if (detail.value == "一般") imptdg=1 + else imptdg=2 + this.setData({ + current: detail.value, + importantDegree:imptdg, + }); + console.log('importantDegree', this.data.importantDegree) + }, + + handlePrefChange({ detail = {} }) { + var pref=-1 + if(detail.value == "任意") pref=-1 + else if (detail.value == "早上") pref=0 + else if (detail.value == "中午") pref=1 + else pref=2 + this.setData({ + pt_current: detail.value, + pref_index:pref, + }); + console.log('pref_index', this.data.pref_index) + }, + + bindDurationBlur(e){ + console.log('pref发送改变,携带值为', e.detail.detail.value) + if(Number.isInteger(e.detail.detail.value*1)){ + this.setData({ + dd: e.detail.detail.value + }) + console.log('dd值为', this.data.dd) + } + else{ + this.setData({ + error: '输入必须为整数', + }) + } + }, + bindSingleMinBlur(e){ + console.log('singleMin发送改变,携带值为', e.detail.detail.value) + if(Number.isInteger(e.detail.detail.value*2)){ + if (e.detail.detail.value>0){ + this.setData({ + singleMin: e.detail.detail.value*2 + }) + console.log('singleMin值为', this.data.singleMin) + } + } + else{ + this.setData({ + error: '输入必须为0.5的倍数', + }) + } + + }, + bindMutexPeriodBlur(e){ + console.log('mutexPeriod发送改变,携带值为', e.detail.detail.value) + if(Number.isInteger(e.detail.detail.value*48)){ + if (e.detail.detail.value>0){ + this.setData({ + mutexPeriod: e.detail.detail.value*48 + }) + console.log('mutexPeriod值为', this.data.mutexPeriod) + } + } + else{ + this.setData({ + error: '输入必须为0.5的倍数', + }) + } + }, + onPOST: function () { + let that = this + authPOST.authPOST({ + url : "plan", + data: { + "description":this.data.description, + "deadline":this.data.deadline, + "importantDegree":this.data.importantDegree+1, + "preference":this.data.pref_index, + "singleMin":this.data.singleMin, + "duration":this.data.duration, + "mutexPeriod":this.data.mutexPeriod, + }, + success: function (res) { + console.log(res) + }, + fail: function (res) { + console.log(res) + } + }) + }, + surebutton :function (options) { + var timestamp = Date.parse(new Date()); + this.setData({ + duration:this.data.dd*this.data.singleMin, + deadline:new Date(this.data.ddl_time.replace(/-/g,"/")).getTime(), + }) + if(this.data.duration<=0 || this.data.mutexPeriod <= 0){ + this.setData({ + error: '请完善计划信息!', + }) + } + else if((this.data.deadline-timestamp)<31536000000){ + var that = this + wx.showModal({//弹窗提示二次确认 + title: '提示', + content: '确定创建吗', + success: function (res) { + if (res.confirm) { + that.onPOST() + wx.reLaunch({ + url: '../list', + }) + wx.showToast({ + title: '创建成功', + icon:"success", + duration: 2000 + }) + } + else { + console.log('弹框后点取消') + } + } + }) + } + else{ + this.setData({ + error: '时间跨度需小于一年', + }) + } + } +}) diff --git a/miniprogram/pages/list/createPlan/createPlan.json b/miniprogram/pages/list/createPlan/createPlan.json new file mode 100644 index 0000000..dcad566 --- /dev/null +++ b/miniprogram/pages/list/createPlan/createPlan.json @@ -0,0 +1,16 @@ +{ + "component": true, + "usingComponents": { + "i-input": "../../../dist/input/index", + "i-panel": "../../../dist/panel/index", + "i-radio-group": "../../../dist/radio-group/index", + "i-radio": "../../../dist/radio/index", + "i-row": "../../../dist/row/index", + "i-col": "../../../dist/col/index", + "i-cell-group": "../../../dist/cell-group/index", + "i-cell": "../../../dist/cell/index", + "i-button": "../../../dist/button/index", + "mp-toptips": "weui-miniprogram/toptips/toptips" + + } +} \ No newline at end of file diff --git a/miniprogram/pages/list/createPlan/createPlan.wxml b/miniprogram/pages/list/createPlan/createPlan.wxml new file mode 100644 index 0000000..9624073 --- /dev/null +++ b/miniprogram/pages/list/createPlan/createPlan.wxml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +创建并自动安排 diff --git a/miniprogram/pages/list/createPlan/createPlan.wxss b/miniprogram/pages/list/createPlan/createPlan.wxss new file mode 100644 index 0000000..ddbfbd2 --- /dev/null +++ b/miniprogram/pages/list/createPlan/createPlan.wxss @@ -0,0 +1,114 @@ +/* pages/create/create.wxss */ +page { + background: #F6F6F6; + display: flex; + flex-direction: column; + justify-content: flex-start; +} +.head{ + width: 100px; + height: 100px; + left: 50px; + top:20px; +} +.row,.row-2{ + margin-top: 0px; + width: 95%; + margin-left:auto; + margin-right:auto; + background-color:white; +} +.row-2{ + left: 0; + margin-left: 0; + display: flex; +} +.ipt,.picker1,.ipt-2{ + border-style: solid; + border-width: 1px; + margin-left: 20px; + height: 40px; + width: 80%; + margin-top:10px ; + border-radius: 15rpx; + margin-bottom: 15rpx; + border-color: #d7cee6; + font-size: 35rpx; + text-align: center; + background-color: #ffffff; + text-align: left; + + +} +.picker2{ + border-style: solid; + border-width: 1px; + margin-left: 10px; + height: 30px; + width: 100rpx; + margin-top:10px ; + border-radius: 15rpx; + margin-bottom: 15rpx; + border-color: #d7cee6; + font-size: 35rpx; + text-align: center; + background-color: #ffffff; + text-align: center; +} +.ipt-2{ + height: 150px; + +} +.t1{ + margin-left: 20px; + margin-top:10px ; +} +.text2{ + margin-left: 10px; + margin-top:10px ; + margin-right:0px; + font-size: 10px; + color: rgb(164, 166, 169); +} +.t3{ + margin-left: 10px; + left:20px; + bottom: 10px; + position: relative; +} +.btn{ +color: #8538ff; +top: 30px; +width: 90px; +margin-left:auto; +margin-right:auto; +margin-bottom: 100px; +} +.t1{ + font-size: 15px; + color: rgb(76, 74, 77); + +} +.t2{ + top: auto; + margin-top: auto; + margin-left: 30px; + font-size: 13px; + color: rgb(71, 69, 72); +} +.pla{ + +margin-left:10px; +color: rgb(199, 199, 199); + +} +.sld{ + border-block-color: #8234ff; +} +.t4{ + font-size: 10px; + margin-left: 10px; + margin-top: 20px; + color: #c1c1c1; + +} diff --git a/miniprogram/pages/list/createTask/createTask.js b/miniprogram/pages/list/createTask/createTask.js new file mode 100644 index 0000000..b41b8e5 --- /dev/null +++ b/miniprogram/pages/list/createTask/createTask.js @@ -0,0 +1,340 @@ +// pages/create/create.js +const app = getApp() +var authPOST = require('../../../utils/authPOST') +const date = new Date(); +const years = []; +const months = []; +const days = []; +const hours = []; +const minitue = ['00分','30分']; +//获取年 +for (let i = date.getFullYear(); i <= date.getFullYear() + 1; i++) { + years.push("" + i+'年'); + } +for (let i = 1; i <= 12; i++) { + if (i < 10) { + i = "0" + i; + } + months.push("" + i+'月'); +} +for (let i = 1; i <= 31; i++) { + if (i < 10) { + i = "0" + i; + } + days.push("" + i+'日'); +} +for (let i = 0; i < 24; i++) { + if (i < 10) { + i = "0" + i; + } + hours.push("" + i+'时'); +} +function formatNumber(n) { + n = n.toString() + return n[1] ? n : '0' + n +} +Page({ + data: { + multiArray: [years, months,days, hours, minitue], + multiIndex: new Array, + choose_year: '', + hh:"\n", + description:new Array, + + ddl_time:'', + deadline:0, + importance: [{id: 1,name: '重要',}, {id: 2,name: '一般'}, {id: 3,name: '次要'}], + current: '一般',importantDegree:1, + prefer_time: [{id: 0,name: '任意'},{id: 1,name: '早上',}, {id: 2,name: '中午'}, {id: 3,name: '晚上'}], + pt_current: '任意',pref_index:0, + + singleMin:0,singleMax:0, + duration:0,//所需时间块 + + position: 'left', + checked: false, + disabled: false, + error: '', + + }, + onLoad: function(options) { + //设置默认的年份 + this.setData({ + choose_year: this.data.multiArray[0][0] + }) + }, + onReady:function(){ + var timestamp = Date.parse(new Date()); + timestamp = timestamp / 1000; + var n = timestamp * 1000; + var date = new Date(n); + this.setData({ + multiIndex:[date.getFullYear(),date.getMonth(),date.getDate()-1,date.getHours()+1, 0], + ddl_time:[date.getFullYear(),date.getMonth()+1,date.getDate()].map(formatNumber).join('-')+' '+[date.getHours()+1, 00].map(formatNumber).join(':'), + }) + console.log('multiIndex',this.data.multiIndex) + }, + + + bindDescriptionBlur(e) { + console.log('description发送改变,携带值为', e.detail.detail.value) + let dscptn = new Array + dscptn.push(e.detail.detail.value) + this.setData({ + description: dscptn + }) + console.log('description值为', this.data.description) + }, + + bindMultiPickerChange: function(e) { + console.log('picker发送选择改变,携带值为', e.detail.value) + this.setData({ + multiIndex: e.detail.value + }) + const index = this.data.multiIndex; + const year = this.data.multiArray[0][index[0]].slice(0,4); + const month = this.data.multiArray[1][index[1]].slice(0,2); + const day = this.data.multiArray[2][index[2]].slice(0,2); + const hour = this.data.multiArray[3][index[3]].slice(0,2); + const minute = this.data.multiArray[4][index[4]].slice(0,2); + //console.log(`${year}-${month}-${day} ${hour}:${minute}`); + this.setData({ + ddl_time: year + '-' + month + '-' + day + ' ' + hour + ':' + minute + }) + console.log(this.data.ddl_time); + }, + + bindMultiPickerColumnChange: function(e) { + //获取年份 + if (e.detail.column == 0) { + let choose_year = this.data.multiArray[e.detail.column][e.detail.value]; + console.log(choose_year); + this.setData({ + choose_year + }) + } + console.log('修改的列为', e.detail.column, ',值为', e.detail.value); + if (e.detail.column == 1) { + let num = parseInt(this.data.multiArray[e.detail.column][e.detail.value]); + let temp = []; + if (num == 1 || num == 3 || num == 5 || num == 7 || num == 8 || num == 10 || num == 12) { //判断31天的月份 + for (let i = 1; i <= 31; i++) { + if (i < 10) { + i = "0" + i; + } + temp.push("" + i+'日'); + } + this.setData({ + ['multiArray[2]']: temp + }); + } else if (num == 4 || num == 6 || num == 9 || num == 11) { //判断30天的月份 + for (let i = 1; i <= 30; i++) { + if (i < 10) { + i = "0" + i; + } + temp.push("" + i+'日'); + } + this.setData({ + ['multiArray[2]']: temp + }); + } else if (num == 2) { //判断2月份天数 + let year = parseInt(this.data.choose_year); + console.log(year); + if (((year % 400 == 0) || (year % 100 != 0)) && (year % 4 == 0)) { + for (let i = 1; i <= 29; i++) { + if (i < 10) { + i = "0" + i; + } + temp.push("" + i+'日'); + } + this.setData({ + ['multiArray[2]']: temp + }); + } else { + for (let i = 1; i <= 28; i++) { + if (i < 10) { + i = "0" + i; + } + temp.push("" + i+'日'); + } + this.setData({ + ['multiArray[2]']: temp + }); + } + } + //console.log(this.data.multiArray[2]); + } + var data = { + multiArray: this.data.multiArray, + multiIndex: this.data.multiIndex + }; + data.multiIndex[e.detail.column] = e.detail.value; + this.setData(data); + }, + handleImportantChange({ detail = {} }) { + var imptdg=0 + if(detail.value == "重要") imptdg=0 + else if (detail.value == "一般") imptdg=1 + else imptdg=2 + this.setData({ + current: detail.value, + importantDegree:imptdg, + }); + console.log('importantDegree', this.data.importantDegree) + }, + handlePrefChange({ detail = {} }) { + var pref=-1 + if(detail.value == "任意") pref=-1 + else if (detail.value == "早上") pref=0 + else if (detail.value == "中午") pref=1 + else pref=2 + this.setData({ + pt_current: detail.value, + pref_index:pref, + }); + console.log('pref_index', this.data.pref_index) + }, + bindDurationBlur(e){ + console.log('pref发送改变,携带值为', e.detail.detail.value) + if(Number.isInteger(e.detail.detail.value*2)){ + this.setData({ + duration: e.detail.detail.value*2 + }) + console.log('duration值为', this.data.duration) + } + else{ + this.setData({ + error: '输入必须为0.5的倍数' + }) + } + }, + bindSingleMinBlur(e){ + console.log('singleMin发送改变,携带值为', e.detail.detail.value) + if(Number.isInteger(e.detail.detail.value*2)){ + if (e.detail.detail.value>0){ + this.setData({ + singleMin: e.detail.detail.value*2 + }) + console.log('singleMin值为', this.data.singleMin) + } + else{ + this.setData({ + error: '请输入大于0的数' + }) + } + } + else{ + this.setData({ + error: '输入必须为0.5的倍数' + }) + } + + }, + bindSingleMaxBlur(e){ + console.log('singleMax发送改变,携带值为', e.detail.detail.value) + if(Number.isInteger(e.detail.detail.value*2)){ + if (e.detail.detail.value>0){ + this.setData({ + singleMax: e.detail.detail.value*2 + }) + console.log('singleMax值为', this.data.singleMax) + } + else{ + this.setData({ + error: '请输入大于0的数' + }) + } + } + else{ + this.setData({ + error: '输入必须为0.5的倍数' + }) + } + }, + onPOST: function () { + authPOST.authPOST({ + url : "task", + data: { + "description":this.data.description, + "deadline":this.data.deadline, + "importantDegree":this.data.importantDegree+1, + "preference":this.data.pref_index, + "singleMin":this.data.singleMin, + "singleMax":this.data.singleMax, + "duration":this.data.duration, + "urgencyPreference":8.0, + }, + success: function (res) { + console.log(res) + }, + fail: function (res) { + console.log(res) + } + }) + }, + surebutton :function (options) { + var timestamp = Date.parse(new Date()); + this.setData({ + deadline:new Date((this.data.ddl_time).replace(/-/g,"/")).getTime()-1800000, + }) + if(this.data.duration<=0){ + this.setData({ + error: '时长不能小于等于0' + }) + } + else if(this.data.singleMin>this.data.singleMax){ + this.setData({ + error: '最小时长不能大于最大时长' + }) + } + else if (this.data.duration>64){ + this.setData({ + error: '计划时长不能大于32小时' + }) + } + else if(this.data.singleMin <0.1||this.data.singleMax <0.1){ + this.setData({ + error: '请输入正确的单次最短/最长时间' + }) + } + else if(this.data.singleMin > this.data.duration){ + this.setData({ + error: '单次最短不能大于总花费时间' + }) + } + else if((this.data.deadline-timestamp)<(this.data.duration+1)*30*60*1000){ + this.setData({ + error: '那么紧急的事情请马上去做吧' + }) + } + else if((this.data.deadline-timestamp)<31536000000){ + console.log(this.data.deadline); + var that = this + wx.showModal({//弹窗提示二次确认 + title: '提示', + content: '确定创建吗', + success: function (res) { + if (res.confirm) { + that.onPOST() + wx.reLaunch({ + url: '../list', + }) + wx.showToast({ + title: '创建成功', + icon:"success", + duration: 2000 + }) + } + else { + console.log('弹框后点取消') + } + } + }) + } + else{ + this.setData({ + error: '时间跨度需小于一年' + }) + } + } +}) diff --git a/miniprogram/pages/list/createTask/createTask.json b/miniprogram/pages/list/createTask/createTask.json new file mode 100644 index 0000000..6417d36 --- /dev/null +++ b/miniprogram/pages/list/createTask/createTask.json @@ -0,0 +1,15 @@ +{ + "component": true, + "usingComponents": { + "i-input": "../../../dist/input/index", + "i-panel": "../../../dist/panel/index", + "i-radio-group": "../../../dist/radio-group/index", + "i-radio": "../../../dist/radio/index", + "i-row": "../../../dist/row/index", + "i-col": "../../../dist/col/index", + "i-cell-group": "../../../dist/cell-group/index", + "i-cell": "../../../dist/cell/index", + "i-button": "../../../dist/button/index", + "mp-toptips": "weui-miniprogram/toptips/toptips" + } +} \ No newline at end of file diff --git a/miniprogram/pages/list/createTask/createTask.wxml b/miniprogram/pages/list/createTask/createTask.wxml new file mode 100644 index 0000000..3a49f05 --- /dev/null +++ b/miniprogram/pages/list/createTask/createTask.wxml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +创建并自动安排 + + + + + diff --git a/miniprogram/pages/list/createTask/createTask.wxss b/miniprogram/pages/list/createTask/createTask.wxss new file mode 100644 index 0000000..ecaec20 --- /dev/null +++ b/miniprogram/pages/list/createTask/createTask.wxss @@ -0,0 +1,117 @@ +/* pages/create/create.wxss */ +page { + background: #F6F6F6; + display: flex; + flex-direction: column; + justify-content: flex-start; + +} +.head{ + width: 100px; + height: 100px; + left: 50px; + top:20px; +} +.row,.row-2{ + margin-top: 0px; + width: 95%; + margin-left:auto; + margin-right:auto; + background-color:white; +} +.row-2{ + left: 0; + margin-left: 0; + display: flex; +} +.ipt,.picker1,.ipt-2{ + border-style: solid; + border-width: 1px; + margin-left: 20px; + height: 40px; + width: 80%; + margin-top:10px ; + border-radius: 15rpx; + margin-bottom: 15rpx; + border-color: #d7cee6; + font-size: 35rpx; + text-align: center; + background-color: #ffffff; + text-align: left; + + +} +.picker2{ + border-style: solid; + border-width: 1px; + margin-left: 10px; + height: 30px; + width: 100rpx; + margin-top:10px ; + border-radius: 15rpx; + margin-bottom: 15rpx; + border-color: #d7cee6; + font-size: 35rpx; + text-align: center; + background-color: #ffffff; + text-align: center; +} +.ipt-2{ + height: 150px; + +} +.t1{ + margin-left: 20px; + margin-top:10px ; +} +.text2{ + margin-left: 10px; + margin-top:10px ; + margin-right:0px; + font-size: 10px; + color: rgb(164, 166, 169); +} +.t3{ + margin-left: 10px; + left:20px; + bottom: 10px; + position: relative; +} +.btn{ +color: #8538ff; +top: 30px; +width: 90px; +margin-left:auto; +margin-right:auto; +margin-bottom: 100px; +} +.t1{ + font-size: 15px; + color: rgb(76, 74, 77); + +} +.t2{ + top: auto; + margin-top: auto; + margin-left: 30px; + font-size: 13px; + color: rgb(71, 69, 72); +} +.pla{ + +margin-left:10px; +color: rgb(199, 199, 199); + +} +.sld{ + border-block-color: #8234ff; +} + +.picker{ + background-color: #ffffff; + height: 48px; + font-size: 15px; + display: flex; + justify-content: left; + align-items: center; +} diff --git a/miniprogram/pages/list/list.js b/miniprogram/pages/list/list.js new file mode 100644 index 0000000..1a3de1a --- /dev/null +++ b/miniprogram/pages/list/list.js @@ -0,0 +1,355 @@ +// pages/list/list.js +var authGET = require('../../utils/authGET') +var authDELETE = require('../../utils/authDELETE') +var authRESULT = require('../../utils/authRESULT') +const { $Message } = require('../../dist/base/index'); +const app = getApp() +function formatNumber(n) { + n = n.toString() + return n[1] ? n : '0' + n +} +Page({ + data: { + taskid:new Array,taskidstring:'', + taskDetail:new Array,taskddlist:new Array, + planid:new Array,planidstring:'', + planDetail:new Array,planddllist:new Array, + failids:[],failplanids:[],allocstatus:[],Pallocstatus:[], + current: 'tab1',current_scroll: 'tab1', + visible2: false,toggle : false,toggle2 : false, + actions : [ + { + name : '删除', + width : 100, + color : '#fff', + fontsize : '20', + icon : 'trash', + background : '#ed3f14' + }, + ], + press : false, + loading: true, + }, + + listenPress: function (res) { + this.setData({ + press: true, + }) + let that = this; + setTimeout(function(){ + that.setData({ + press: false, + }) + },15) + }, + + + onLoad: function (e) { + + }, + onReady: function () { + let that = this; + + }, + onShow:function(){ + let that = this; + + app.listenLoading(function (res) { + that.Query() + }) + }, + onPullDownRefresh: function () { + let that = this; + app.listenLoading(function (res) { + that.Query() + }) + + }, + stopPullDownRefresh(){ + wx.stopPullDownRefresh() + $Message({ + content: '拉取数据成功', + type: 'success' + }); + }, + + Query:function(){ + this.onRESULTS() + this.onGETALL() + + }, + onRESULTS: function () { + var that = this + authRESULT.authRESULTS({ + url : "task", + success: function (res) { + that.setData({ + failids:res.data.failedIds, + }) + console.log("failid",that.data.failids) + }, + fail: function (res) { + console.log(res) + } + }) + authRESULT.authRESULTS({ + url : "plan", + success: function (res) { + that.setData({ + failplanids:res.data.failedIds, + }) + console.log("failplanid",that.data.failplanids) + }, + fail: function (res) { + console.log(res) + } + }) +}, + onGETALL:function () { + var that = this + authGET.authGETALL({ + url : "task", + data: { + }, + success: function (res) { + console.log("返回t",res.data) + if(res.data.length>0){ + that.setData({ + loading: false, + taskid:res.data, + taskidstring:res.data.join(',') + }) + that.onGETDETAIL(); + } + else{ + that.setData({ + loading: false, + taskid:res.data, + taskidstring:"" + }) + } + }, + fail: function (res) { + console.log(res) + } + }), + authGET.authGETALL({ + url : "plan", + data: { + }, + success: function (res) { + console.log("返回p",res.data) + if(res.data.length>0){ + that.setData({ + loading:false, + planid:res.data, + planidstring:res.data.join(',') + }) + that.onGETDETAIL(); + } + else{ + that.setData({ + loading:false, + planid:res.data, + planidstring:"" + }) + } + }, + fail: function (res) { + console.log(res) + } + }) + }, + onGETDETAIL:function(){ + var that = this + authGET.authGETDETAIL({ + url : "task", + data:{ + "ids":this.data.taskidstring, + }, + success: function (res) { + console.log("taskDetail",res.data) + var ddllist = new Array + var _alloc =[] + for(var i = 0;i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 时间已规划 + + + + + + 规划中 + + + + + + + + + + + + + + + + + + + + + + + + + 时间已规划 + + + + + + 规划中 + + + + + + + + + \ No newline at end of file diff --git a/miniprogram/pages/list/list.wxss b/miniprogram/pages/list/list.wxss new file mode 100644 index 0000000..e42739c --- /dev/null +++ b/miniprogram/pages/list/list.wxss @@ -0,0 +1,140 @@ +/* pages/list/list.wxss */ +.row,.row2{ + margin-top: 2px; + height :50px; + width: 95%; + margin-left:auto; + margin-right:auto; + background-color:white +} +page { + background: #F6F6F6; + display: flex; + flex-direction: column; + justify-content: flex-start; + background: url("http://static.codesdream.com/bk.png") no-repeat; + width: 100%; + background-size: 100% 100%; + background-attachment:fixed; +} + +.itm{ + margin-left: 20px; + color: rgb(99, 98, 101); + font-style: initial; + +} +.row2{ + background-color:rgb(221, 206, 255); +} + +.blk0,.blk1{ + border: 1px solid rgb(178, 139, 255); + width: 72px; + height:30px; + margin-left: 5px; + border-radius: 10px; + color: rgb(178, 139, 255); + text-align: center; +} +.blk1{ + border: 1px solid rgb(178, 139, 255); + background-color: rgb(178, 139, 255); + color: white; + border-radius: 10px; + +} +.row3{ + display: flex; + flex-direction: row; + margin-top: 5px; +} +.i-cell-padding{ + height: 28px; +} + +.i-row-class{ + margin-bottom:5px; +} + +.circle-button{ + font-size: 60rpx; + color: white; + text-align: center; + border-radius: 100%; +} + +/* .circle-view1{ + height: 120rpx; + width: 120rpx; + background-color: #19be6b; + border-radius: 100%; + position: fixed; + bottom: 100rpx; + right: 40rpx; + display: flex; + align-items: center; + justify-content: center; + z-index: 9; + border: 0 solid #ffffff; + box-shadow: 4px 1px 1px #cccccc; +} */ + +.circle-view1{ + position: fixed; + bottom: 100rpx; + right: 40rpx; + /* display: flex; + align-items: center; + justify-content: center; */ +} + +.button-img{ + height: 60px; + width: 60px; +} + +.circle-view2{ + height: 120rpx; + width: 120rpx; + background-color: #1ea4ed; + border-radius: 100%; + position: fixed; + bottom: 100rpx; + right: 40rpx; + display: flex; + align-items: center; + justify-content: center; + z-index: 9; + border: 0 solid #ffffff; + box-shadow: 4px 1px 1px #cccccc; +} + +.progress-cell{ + height: 18px; +} + +.i-cell-padding{ + height: 20px; +} + +.item-row{ + height: 45px; +} + +.empty-img{ + height: 240px; + width: 150px; + +} + +.empty-view{ + display:flex; + justify-content: center; + margin-top: 80px; + margin-left: 15px; +} + +.i-row-class-top{ + margin-top: 20px; +} \ No newline at end of file diff --git a/miniprogram/pages/list/plan/plan.js b/miniprogram/pages/list/plan/plan.js new file mode 100644 index 0000000..ea6f81a --- /dev/null +++ b/miniprogram/pages/list/plan/plan.js @@ -0,0 +1,344 @@ +// pages/plan/plan.js +var authGET = require('../../../utils/authGET') +var authPATCH = require('../../../utils/authPATCH') +var authDELETE = require('../../../utils/authDELETE') +const app = getApp() +Page({ + data: { + changed:false, + hiddenmodalput1:true, + hiddenmodalput2:true, + hiddenmodalput3:true, + hiddenmodalput4:true, + hiddenmodalput5: true, + planid:0, + description:new Array, + year:[2020,2021], + month:['01','02','03','04','05','06','07','08','09','10','11','12'], + day:['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31'], + hour:['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23'], + mniute:['00','30'], + y:0,m:0,d:0,h:0,mn:0, + deadline:'', + importance: ['重要','一般','次要'], + importantDegree:1, + preference:['任意','早上','下午','晚上'], + pref_index:0, + singleMin:0, + dd:0,duration:0,//所需时间块 + mutexPeriod:0, + nowTimestamp:0, + error: '' + }, + onLoad: function (e) { + console.log(e); + this.setData({ + planid:e.planid + }) + }, + onReady: function () { + this.setData({ + nowTimestamp:new Date().getTime() + }); + + this.onGET() + }, + onGET: function () { + var that = this; + authGET.authGET({ + url : "plan", + data: { + "id":this.data.planid, + }, + success: function (res) { + console.log(res.data) + that.setData({ + description:res.data.description, + y:new Date(res.data.deadline.replace(/-/g, '/')).getFullYear()-2020, + m:new Date(res.data.deadline.replace(/-/g, '/')).getMonth(), + d:new Date(res.data.deadline.replace(/-/g, '/')).getDate()-1, + h:(new Date(res.data.deadline.replace(/-/g, '/')).getHours()+new Date(res.data.deadline.replace(/-/g, '/')).getMinutes()/30)%24, + mn:(new Date(res.data.deadline.replace(/-/g, '/')).getMinutes()/30+1)%2, + importantDegree:res.data.importantDegree-1, + pref_index:res.data.preference+1, + singleMin:res.data.singleMin/2, + duration:res.data.duration/2, + mutexPeriod:res.data.mutexPeriod/48, + dd:res.data.duration/res.data.singleMin + }) + }, + fail: function (res) { + console.log(res) + } + }) + }, + onPATCH: function () { + authPATCH.authPATCH({ + url:"plan", + data:{ + 'id':parseInt(this.data.planid), + 'patch':[ + {"op": "replace", "path": "/description", "value": this.data.description }, + {"op": "replace", "path": "/deadline", "value":this.data.deadline }, + {"op": "replace", "path": "/importantDegree", "value": 1+1*this.data.importantDegree }, + {"op": "replace", "path": "/preference", "value": this.data.pref_index-1 }, + {"op": "replace", "path": "/mutexPeriod", "value": this.data.mutexPeriod*48 }, + {"op": "replace", "path": "/singleMin", "value": this.data.singleMin*2 }, + {"op": "replace", "path": "/duration", "value": this.data.duration*2 }, + ], + }, + success: function (res) { + console.log(res) + }, + fail: function (res) { + console.log(res) + } + + }) + }, + onDELETE: function () { + authDELETE.authDELETE({ + url:"plan", + data:{ + "id":[parseInt(this.data.planid)], + }, + success: function (res) { + console.log(res) + }, + fail: function (res) { + console.log(res) + } + + }) + }, + modalinput1:function(){ + this.setData({ + hiddenmodalput1: !this.data.hiddenmodalput1 + }) + }, + modalinput2:function(){ + this.setData({ + hiddenmodalput2: !this.data.hiddenmodalput2 + }) + }, + modalinput3:function(){ + this.setData({ + hiddenmodalput3: !this.data.hiddenmodalput3 + }) + }, + modalinput4:function(){ + this.setData({ + hiddenmodalput4: !this.data.hiddenmodalput4 + }) + }, + modalinput5:function(){ + this.setData({ + hiddenmodalput5: !this.data.hiddenmodalput5 + }) + }, + cancel: function(){ + this.setData({ + hiddenmodalput1: true, + hiddenmodalput2: true, + hiddenmodalput3: true, + hiddenmodalput4: true, + hiddenmodalput5: true, + }); +}, +confirm: function(){ //确认 + this.setData({ + hiddenmodalput1: true, + hiddenmodalput2: true, + hiddenmodalput3: true, + hiddenmodalput4: true, + hiddenmodalput5: true, + }) +}, +bindDescriptionBlur(e) { + console.log('description发送改变,携带值为', e.detail.detail.value) + if(e.detail.value != ''){ + let dscptn = new Array + dscptn.push(e.detail.detail.value) + this.setData({ + changed:true, + description: dscptn, + }) + console.log('description值为', this.data.description) + } +}, +bindYearBlur(e){ + console.log('y发送改变,携带值为', e.detail.value) + this.setData({ + changed:true, + y: e.detail.value + }) + console.log('year值为', this.data.year[this.data.y]) +}, +bindMonthBlur(e){ + console.log('m发送改变,携带值为', e.detail.value) + this.setData({ + changed:true, + m: e.detail.value + }) + console.log('month值为', this.data.month[this.data.m]) +}, +bindDayBlur(e){ + console.log('d发送改变,携带值为', e.detail.value) + this.setData({ + changed:true, + d: e.detail.value + }) + console.log('day值为', this.data.day[this.data.d]) +}, +bindHourBlur(e){ + console.log('h发送改变,携带值为', e.detail.value) + this.setData({ + changed:true, + h: e.detail.value + }) + console.log('hour值为', this.data.hour[this.data.h]) +}, +bindMniuteBlur(e){ + console.log('mn发送改变,携带值为', e.detail.value) + this.setData({ + changed:true, + mn: e.detail.value + }) + console.log('hour值为', this.data.mniute[this.data.mn]) +}, +bindImptChange(e){ + console.log('impt发送选择改变,携带值为', e.detail.value) + this.setData({ + changed:true, + importantDegree: e.detail.value + }) + console.log('importantDegree', this.data.importantDegree) +}, +bindPrefChange(e){ + console.log('pref发送改变,携带值为', e.detail.value) + this.setData({ + changed:true, + pref_index: e.detail.value + }) + console.log('preference值为', this.data.pref_index) +}, +bindDurationBlur(e){ + if(e.detail.detail.value != ''){ + if(Number.isInteger(e.detail.detail.value*2)){ + this.setData({ + changed:true, + duration: e.detail.detail.value + }) + console.log('duration值为', this.data.duration) + } + else{ + this.setData({ + error: '输入必须为0.5的倍数', + + }) + } + } +}, +bindSingleMinBlur(e){ + console.log('singleMin发送改变,携带值为', e.detail.value) + if(e.detail.detail.value != ''){ + if(Number.isInteger(e.detail.detail.value*2)){ + if(e.detail.detail.value>0){ + this.setData({ + changed:true, + singleMin: e.detail.detail.value + }) + console.log('singleMin值为', this.data.singleMin) + } + else{ + this.setData({ + changed:true, + singleMin:0.5 + }) + console.log('singleMin值为', this.data.singleMin) + } + } + else{ + this.setData({ + error: '输入必须为0.5的倍数', + }) + } + } +}, +bindMutexPeriodBlur(e){ + console.log('mutexPeriod发送改变,携带值为', e.detail.detail.value) + if(Number.isInteger(e.detail.detail.value*2)){ + if (e.detail.detail.value>0){ + this.setData({ + changed:true, + mutexPeriod: e.detail.detail.value + }) + console.log('mutexPeriod值为', this.data.mutexPeriod) + } + } + else{ + this.setData({ + error: '输入必须为0.5的倍数', + }) + } +}, + +deletebutton :function (options) { + var that = this + wx.showModal({//弹窗提示二次确认 + title: '提示', + content: '确定删除吗', + success: function (res) { + if (res.confirm) { + that.onDELETE() + wx.reLaunch({ + url: '../list', + }) + wx.showToast({ + title: '删除成功', + icon:"success", + duration: 2000 + }) + } + else { + console.log('弹框后点取消') + } + } + }) +}, +surebutton :function (options) { + var ddl =this.data.year[this.data.y]+'-'+this.data.month[this.data.m]+'-'+this.data.day[this.data.d]+' '+this.data.hour[this.data.h-(parseInt(this.data.mn)+1)%2]+':'+this.data.mniute[(parseInt(this.data.mn)+1)%2] + this.setData({ + "deadline":new Date(ddl.replace(/-/g,"/")).getTime(), + }) + if((this.data.deadline-this.data.nowTimestamp)<31536000000){ + var that = this + wx.showModal({//弹窗提示二次确认 + title: '提示', + content: '确定修改吗', + success: function (res) { + if (res.confirm) { + that.onPATCH() + wx.reLaunch({ + url: '../list', + }) + wx.showToast({ + title: '修改成功', + icon:"success", + duration: 2000 + }) + } + else { + console.log('弹框后点取消') + } + } + }) + } + else{ + this.setData({ + error: '时间跨度需小于一年', + }) + } +} + +}) diff --git a/miniprogram/pages/list/plan/plan.json b/miniprogram/pages/list/plan/plan.json new file mode 100644 index 0000000..1d0ee16 --- /dev/null +++ b/miniprogram/pages/list/plan/plan.json @@ -0,0 +1,20 @@ +{ + "component": true, + "usingComponents": { + "i-cell-group": "../../../dist/cell-group/index", + "i-cell": "../../../dist/cell/index", + "i-row": "../../../dist/row/index", + "i-col": "../../../dist/col/index", + "i-card": "../../../dist/card/index", + "i-panel": "../../../dist/panel/index", + "i-grid": "../../../dist/grid/index", + "i-grid-item": "../../../dist/grid-item/index", + "i-grid-icon": "../../../dist/grid-icon/index", + "i-grid-label": "../../../dist/grid-label/index", + "i-icon": "../../../dist/icon/index", + "i-button": "../../../dist/button/index", + "i-input": "../../../dist/input/index", + "mp-toptips": "weui-miniprogram/toptips/toptips" + + } +} \ No newline at end of file diff --git a/miniprogram/pages/list/plan/plan.wxml b/miniprogram/pages/list/plan/plan.wxml new file mode 100644 index 0000000..e08e269 --- /dev/null +++ b/miniprogram/pages/list/plan/plan.wxml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{importance[importantDegree]}} + + + + + + {{preference[pref_index]}} + + + + + + + 确认修改 + +删除 + diff --git a/miniprogram/pages/list/plan/plan.wxss b/miniprogram/pages/list/plan/plan.wxss new file mode 100644 index 0000000..a507648 --- /dev/null +++ b/miniprogram/pages/list/plan/plan.wxss @@ -0,0 +1,188 @@ +/**index.wxss**/ +page { + background: #F6F6F6; + display: flex; + flex-direction: column; + justify-content: flex-start; +} + +.userinfo, .uploader, .tunnel,.row{ + margin-top: 40rpx; + height: 140rpx; + width: 100%; + background: #FFF; + border: 1px solid rgba(0, 0, 0, .1); + border-left: none; + border-right: none; + display: flex; + flex-direction: row; + align-items: center; + transition: all 300ms ease; +} + +.userinfo-avatar { + width: 100rpx; + height: 100rpx; + margin: 20rpx; + border-radius: 50%; +} + +.userinfo-nickname { + font-size: 32rpx; + color: #007AFF; + background-color: white; +} + +.userinfo-nickname::after { +border: none; +} + +.uploader, .tunnel { + height: auto; + padding: 0 0 0 40rpx; + flex-direction: column; + align-items: flex-start; + box-sizing: border-box; +} + +.uploader-text, .tunnel-text { + width: 100%; + line-height: 52px; + font-size: 34rpx; + color: #007AFF; +} + +.uploader-container { + width: 100%; + height: 400rpx; + padding: 20rpx 20rpx 20rpx 0; + display: flex; + align-content: center; + justify-content: center; + box-sizing: border-box; + border-top: 1px solid rgba(0, 0, 0, .1); +} + +.uploader-image { + width: 100%; + height: 360rpx; +} + +.tunnel { + padding: 0 0 0 40rpx; +} + +.tunnel-text { + position: relative; + color: #222; + display: flex; + flex-direction: row; + align-content: center; + justify-content: space-between; + box-sizing: border-box; + border-top: 1px solid rgba(0, 0, 0, .1); +} + +.tunnel-text:first-child { + border-top: none; +} + +.tunnel-switch { + position: absolute; + right: 20rpx; + top: -2rpx; +} + +.disable { + color: #888; +} + +.service { + position: fixed; + right: 40rpx; + bottom: 40rpx; + width: 140rpx; + height: 140rpx; + border-radius: 50%; + background: linear-gradient(#007AFF, #0063ce); + box-shadow: 0 5px 10px rgba(0, 0, 0, .3); + display: flex; + align-content: center; + justify-content: center; + transition: all 300ms ease; +} + +.service-button { + position: absolute; + top: 40rpx; +} + +.service:active { + box-shadow: none; +} + +.request-text { + padding: 20rpx 0; + font-size: 24rpx; + line-height: 36rpx; + word-break: break-all; +} +.btn{ + margin-left: 30px; + margin-right: 0; + left: 0; + right: 0; +} +.area3{ + margin-top: 15rpx; + display:flex; + /*row 横向 column 列表 */ + flex-direction: row; + background-color: #f9f7f7; + border-radius: 15rpx; + margin-left:15rpx; + margin-right:15rpx; +} +.start{ + top: 20px; + position: relative; +} +.t1{ + position:relative; + margin-left: auto; + margin-right: auto; +} +.t2{ + position:relative; + margin-left: auto; +margin-right: auto; +} +.t3{ + margin-left: auto; + margin-right: auto; +} +.userinfo,.row{ + margin-top: 1px; + left: 10px; + right: 10px; + width: 90%; + +} +.row{ + background-color: white; + margin-top: 0px; + height: 100px; +} +.l4{ + display: flex; + flex-direction: column; + margin-left: 10px; + font-size: 15px; +} + +.center-view{ + margin-top: 0px; + text-align: center; + display: flex; + justify-content: center; +} \ No newline at end of file diff --git a/miniprogram/pages/list/task/task.js b/miniprogram/pages/list/task/task.js new file mode 100644 index 0000000..725c85f --- /dev/null +++ b/miniprogram/pages/list/task/task.js @@ -0,0 +1,362 @@ +// pages/plan/plan.js +const app = getApp() +var authGET = require('../../../utils/authGET') +var authPATCH = require('../../../utils/authPATCH') +var authDELETE = require('../../../utils/authDELETE') + +Page({ + data: { + changed:false, + hiddenmodalput1:true, + hiddenmodalput2:true, + hiddenmodalput3:true, + hiddenmodalput4:true, + hiddenmodalput5:true, + taskid:0, + hh:"\n", + description:new Array, + ddl_time:'', + year:[2020,2021], + month:['01','02','03','04','05','06','07','08','09','10','11','12'], + day:['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31'], + hour:['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23'], + mniute:['00','30'], + y:0,m:0,d:0,h:0,mn:0, + deadline:0, + importance: ['重要','一般','次要'], + importantDegree:1, + preference:['任意','早上','下午','晚上'], + pref_index:0, + singleMin:0,singleMax:0x7fffffff, + duration:0,//所需时间块 + error: '' + + }, + onLoad: function (e) { + console.log(e); + this.setData({ + taskid:e.taskid + }) + }, + onReady: function () { + this.setData({ + nowTimestamp:new Date().getTime() + }); + this.onGET() + }, + onGET: function () { + var that = this; + authGET.authGET({ + url : "task", + data: { + "id":this.data.taskid, + }, + success: function (res) { + console.log(res) + that.setData({ + description:res.data.description, + + y:new Date(res.data.deadline.replace(/-/g, '/')).getFullYear()-2020, + m:new Date(res.data.deadline.replace(/-/g, '/')).getMonth(), + d:new Date(res.data.deadline.replace(/-/g, '/')).getDate()-1, + h:(new Date(res.data.deadline.replace(/-/g, '/')).getHours()+new Date(res.data.deadline.replace(/-/g, '/')).getMinutes()/30)%24, + mn:(new Date(res.data.deadline.replace(/-/g, '/')).getMinutes()/30+1)%2, + importantDegree:res.data.importantDegree-1, + pref_index:res.data.preference+1, + singleMin:res.data.singleMin/2, + singleMax:res.data.singleMax/2, + duration:res.data.duration/2, + }) + console.log("h",that.data.h,"mn",that.data.mn); + }, + fail: function (res) { + console.log(res) + } + }) + }, + onPATCH: function () { + authPATCH.authPATCH({ + url:"task", + data:{ + 'id':parseInt(this.data.taskid), + 'patch':[ + {"op": "replace", "path": "/description", "value": this.data.description }, + {"op": "replace", "path": "/deadline", "value":this.data.deadline }, + {"op": "replace", "path": "/importantDegree", "value": 1*this.data.importantDegree+1 }, + {"op": "replace", "path": "/preference", "value": this.data.pref_index-1 }, + {"op": "replace", "path": "/singleMax", "value": this.data.singleMax*2 }, + {"op": "replace", "path": "/singleMin", "value": this.data.singleMin*2 }, + {"op": "replace", "path": "/duration", "value": this.data.duration*2 }, + ], + }, + success: function (res) { + console.log(res) + }, + fail: function (res) { + console.log(res) + } + + }) + }, + onDELETE: function () { + authDELETE.authDELETE({ + url:"task", + data:{ + "id":[parseInt(this.data.taskid)], + }, + success: function (res) { + console.log(res) + }, + fail: function (res) { + console.log(res) + } + + }) + }, + modalinput1:function(){ + this.setData({ + hiddenmodalput1: !this.data.hiddenmodalput1 + }) + }, + modalinput2:function(){ + this.setData({ + hiddenmodalput2: !this.data.hiddenmodalput2 + }) + }, + modalinput3:function(){ + this.setData({ + hiddenmodalput3: !this.data.hiddenmodalput3 + }) + }, + modalinput4:function(){ + this.setData({ + hiddenmodalput4: !this.data.hiddenmodalput4 + }) + }, + modalinput5:function(){ + this.setData({ + hiddenmodalput5: !this.data.hiddenmodalput5 + }) + }, + + cancel: function(){ + this.setData({ + hiddenmodalput1: true, + hiddenmodalput2: true, + hiddenmodalput3: true, + hiddenmodalput4: true, + hiddenmodalput5: true, + }); + }, + confirm: function(){ //确认 + this.setData({ + hiddenmodalput1: true, + hiddenmodalput2: true, + hiddenmodalput3: true, + hiddenmodalput4: true, + hiddenmodalput5: true, + + }) + }, + bindDescriptionBlur(e) { + console.log('description发送改变,携带值为', e.detail.detail.value) + if(e.detail.detail.value != ''){ + let dscptn = new Array + dscptn.push(e.detail.detail.value) + this.setData({ + changed:true, + description: dscptn, + }) + console.log('description值为', this.data.description) + } + }, + + bindYearBlur(e){ + console.log('y发送改变,携带值为', e.detail.value) + this.setData({ + changed:true, + y: e.detail.value + }) + console.log('year值为', this.data.year[this.data.y]) + }, + bindMonthBlur(e){ + console.log('m发送改变,携带值为', e.detail.value) + this.setData({ + changed:true, + m: e.detail.value + }) + console.log('month值为', this.data.month[this.data.m]) + }, + bindDayBlur(e){ + console.log('d发送改变,携带值为', e.detail.value) + this.setData({ + changed:true, + d: e.detail.value + }) + console.log('day值为', this.data.day[this.data.d]) + }, + bindHourBlur(e){ + console.log('h发送改变,携带值为', e.detail.value) + this.setData({ + changed:true, + h: e.detail.value + }) + console.log('hour值为', this.data.hour[this.data.h]) + }, + bindMniuteBlur(e){ + console.log('mn发送改变,携带值为', e.detail.value) + this.setData({ + changed:true, + mn: e.detail.value + }) + console.log('hour值为', this.data.mniute[this.data.mn]) + }, + + + +bindImptChange(e){ + console.log('impt发送选择改变,携带值为', e.detail.value) + this.setData({ + changed:true, + importantDegree: e.detail.value + }) + console.log('importantDegree', this.data.importantDegree) + }, +bindPrefChange(e){ + console.log('pref发送改变,携带值为', e.detail.value) + this.setData({ + changed:true, + pref_index: e.detail.value + }) + console.log('preference值为', this.data.pref_index) +}, +bindDurationBlur(e){ + if(e.detail.detail.value != ''){ + if(Number.isInteger(e.detail.detail.value*2)){ + this.setData({ + changed:true, + duration: e.detail.detail.value + }) + console.log('duration值为', this.data.duration) + } + else{ + this.setData({ + error: '输入必须为0.5的倍数', + }) + } + } +}, +bindSingleMinBlur(e){ + console.log('singleMin发送改变,携带值为', e.detail.detail.value) + if(e.detail.detail.value != ''){ + if(Number.isInteger(e.detail.detail.value*2)){ + + if(e.detail.detail.value>0){ + this.setData({ + changed:true, + singleMin: e.detail.detail.value + }) + console.log('singleMin值为', this.data.singleMin) + } + else{ + this.setData({ + changed:true, + singleMin:0 + }) + console.log('singleMin值为', this.data.singleMin) + } + } + else{ + this.setData({ + error: '输入必须为0.5的倍数', + }) + } + } +}, +bindSingleMaxBlur(e){ + console.log('singleMax发送改变,携带值为', e.detail.detail.value) + if(e.detail.detail.value != ''){ + if(Number.isInteger(e.detail.detail.value*2)){ + if (e.detail.detail.value>0){ + this.setData({ + changed:true, + singleMax: e.detail.detail.value + }) + console.log('singleMax值为', this.data.singleMax) + } + else if(e.detail.detail.value == 0 || e.detail.detail.value >9999) { + this.setData({ + changed:true, + singleMax: 0x7fffffff + }) + console.log('singleMax值为', this.data.singleMax) + } + } + else{ + this.setData({ + error: '输入必须为0.5的倍数', + }) + } + } +}, + +deletebutton :function (options) { + var that = this + wx.showModal({//弹窗提示二次确认 + title: '提示', + content: '确定删除吗', + success: function (res) { + if (res.confirm) { + that.onDELETE() + wx.reLaunch({ + url: '../list', + }) + wx.showToast({ + title: '删除成功', + icon:"success", + duration: 2000 + }) + } + else { + console.log('弹框后点取消') + } + } + }) +}, +surebutton :function (options) { + var timestamp = new Date().getTime(); + var ddl =this.data.year[this.data.y]+'-'+this.data.month[this.data.m]+'-'+this.data.day[this.data.d]+' '+this.data.hour[this.data.h-(parseInt(this.data.mn)+1)%2]+':'+this.data.mniute[(parseInt(this.data.mn)+1)%2] + this.setData({ + "deadline":new Date(ddl.replace(/-/g,"/")).getTime(), + }) + if((this.data.deadline-this.data.nowTimestamp)<31536000000){ + var that = this + wx.showModal({//弹窗提示二次确认 + title: '提示', + content: '确定修改吗', + success: function (res) { + if (res.confirm) { + that.onPATCH() + wx.reLaunch({ + url: '../list', + }) + wx.showToast({ + title: '修改成功', + icon:"success", + duration: 2000 + }) + } + else { + console.log('弹框后点取消') + } + } + }) + } + else{ + this.setData({ + error: '时间跨度需小于一年', + }) + } +} + +}) diff --git a/miniprogram/pages/list/task/task.json b/miniprogram/pages/list/task/task.json new file mode 100644 index 0000000..1d0ee16 --- /dev/null +++ b/miniprogram/pages/list/task/task.json @@ -0,0 +1,20 @@ +{ + "component": true, + "usingComponents": { + "i-cell-group": "../../../dist/cell-group/index", + "i-cell": "../../../dist/cell/index", + "i-row": "../../../dist/row/index", + "i-col": "../../../dist/col/index", + "i-card": "../../../dist/card/index", + "i-panel": "../../../dist/panel/index", + "i-grid": "../../../dist/grid/index", + "i-grid-item": "../../../dist/grid-item/index", + "i-grid-icon": "../../../dist/grid-icon/index", + "i-grid-label": "../../../dist/grid-label/index", + "i-icon": "../../../dist/icon/index", + "i-button": "../../../dist/button/index", + "i-input": "../../../dist/input/index", + "mp-toptips": "weui-miniprogram/toptips/toptips" + + } +} \ No newline at end of file diff --git a/miniprogram/pages/list/task/task.wxml b/miniprogram/pages/list/task/task.wxml new file mode 100644 index 0000000..4b5b681 --- /dev/null +++ b/miniprogram/pages/list/task/task.wxml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{importance[importantDegree]}} + + + + + + {{preference[pref_index]}} + + + + + + +确认修改 + +删除 + + diff --git a/miniprogram/pages/list/task/task.wxss b/miniprogram/pages/list/task/task.wxss new file mode 100644 index 0000000..82fafab --- /dev/null +++ b/miniprogram/pages/list/task/task.wxss @@ -0,0 +1,188 @@ +/**index.wxss**/ +page { + background: #F6F6F6; + display: flex; + flex-direction: column; + justify-content: flex-start; +} + +.userinfo, .uploader, .tunnel,.row{ + margin-top: 40rpx; + height: 140rpx; + width: 100%; + background: #FFF; + border: 1px solid rgba(0, 0, 0, .1); + border-left: none; + border-right: none; + display: flex; + flex-direction: row; + align-items: center; + transition: all 300ms ease; +} + +.userinfo-avatar { + width: 100rpx; + height: 100rpx; + margin: 20rpx; + border-radius: 50%; +} + +.userinfo-nickname { + font-size: 32rpx; + color: #007AFF; + background-color: white; +} + +.userinfo-nickname::after { +border: none; +} + +.uploader, .tunnel { + height: auto; + padding: 0 0 0 40rpx; + flex-direction: column; + align-items: flex-start; + box-sizing: border-box; +} + +.uploader-text, .tunnel-text { + width: 100%; + line-height: 52px; + font-size: 34rpx; + color: #007AFF; +} + +.uploader-container { + width: 100%; + height: 400rpx; + padding: 20rpx 20rpx 20rpx 0; + display: flex; + align-content: center; + justify-content: center; + box-sizing: border-box; + border-top: 1px solid rgba(0, 0, 0, .1); +} + +.uploader-image { + width: 100%; + height: 360rpx; +} + +.tunnel { + padding: 0 0 0 40rpx; +} + +.tunnel-text { + position: relative; + color: #222; + display: flex; + flex-direction: row; + align-content: center; + justify-content: space-between; + box-sizing: border-box; + border-top: 1px solid rgba(0, 0, 0, .1); +} + +.tunnel-text:first-child { + border-top: none; +} + +.tunnel-switch { + position: absolute; + right: 20rpx; + top: -2rpx; +} + +.disable { + color: #888; +} + +.service { + position: fixed; + right: 40rpx; + bottom: 40rpx; + width: 140rpx; + height: 140rpx; + border-radius: 50%; + background: linear-gradient(#007AFF, #0063ce); + box-shadow: 0 5px 10px rgba(0, 0, 0, .3); + display: flex; + align-content: center; + justify-content: center; + transition: all 300ms ease; +} + +.service-button { + position: absolute; + top: 40rpx; +} + +.service:active { + box-shadow: none; +} + +.request-text { + padding: 20rpx 0; + font-size: 24rpx; + line-height: 36rpx; + word-break: break-all; +} +.btn{ + margin-left: 30px; + margin-right: 0; + left: 0; + right: 0; +} +.area3{ + margin-top: 15rpx; + display:flex; + /*row 横向 column 列表 */ + flex-direction: row; + background-color: #f9f7f7; + border-radius: 15rpx; + margin-left:15rpx; + margin-right:15rpx; +} +.start{ + top: 20px; + position: relative; +} +.t1{ + position:relative; + margin-left: auto; + margin-right: auto; +} +.t2{ + position:relative; + margin-left: auto; +margin-right: auto; +} +.t3{ + margin-left: auto; + margin-right: auto; +} +.userinfo,.row{ + margin-top: 1px; + left: 10px; + right: 10px; + width: 90%; + +} +.row{ + background-color: white; + margin-top: 0px; + height: 100px; +} +.l4{ + display: flex; + flex-direction: column; + margin-left: 10px; + font-size: 15px; +} + +.center-view{ + margin-top: 0px; + text-align: center; + display: flex; + justify-content: center; +} diff --git a/miniprogram/sitemap.json b/miniprogram/sitemap.json new file mode 100644 index 0000000..ca02add --- /dev/null +++ b/miniprogram/sitemap.json @@ -0,0 +1,7 @@ +{ + "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", + "rules": [{ + "action": "allow", + "page": "*" + }] +} \ No newline at end of file diff --git a/miniprogram/utils/auth.js b/miniprogram/utils/auth.js new file mode 100644 index 0000000..4e48504 --- /dev/null +++ b/miniprogram/utils/auth.js @@ -0,0 +1,22 @@ +var sha1 = require('./sha1') + +var authCodeGenerator = { + clientCode: '965cda1983f569b03abfb80dc9af8dd8', + timestamp: Date.parse(new Date()), + updateTimestamp: function () { + this.timestamp = Date.parse(new Date()); + return this.timestamp; + }, + + randomCode: function (openid) { + this.timestamp = Date.parse(new Date()); + console.log(sha1("RandomCode ["+openid+"]["+this.timestamp+"]["+this.clientCode+"]")) + return sha1("RandomCode ["+openid+"]["+this.timestamp+"]["+this.clientCode+"]"); + }, + + signed: function (openid, token) { + return sha1("SIGN ["+openid+"]["+this.randomCode(openid)+"]["+token+"]") + } +} + +module.exports = {authCodeGenerator} \ No newline at end of file diff --git a/miniprogram/utils/authCOMP.js b/miniprogram/utils/authCOMP.js new file mode 100644 index 0000000..ef7128b --- /dev/null +++ b/miniprogram/utils/authCOMP.js @@ -0,0 +1,23 @@ +const app = getApp() +var auth = require('./auth') +var config = require('../config') + +async function authCOMP(object){ + var that = this; + var authObj = auth.authCodeGenerator; + authObj.updateTimestamp(); + wx.request({ + method: "GET", + url: config.hostUrl+"/completion/"+object.url, + data: object.data, + header:{ + 'openid': app.globalData.openid, + 'X-Requested-With': '', + 'timestamp': authObj.timestamp, + 'signed': authObj.signed(app.globalData.openid, app.globalData.token) + }, + success: object.success, + fail:object.fail, + }); +} +module.exports = {authCOMP} \ No newline at end of file diff --git a/miniprogram/utils/authDELETE.js b/miniprogram/utils/authDELETE.js new file mode 100644 index 0000000..597b62d --- /dev/null +++ b/miniprogram/utils/authDELETE.js @@ -0,0 +1,23 @@ +const app = getApp() +var auth = require('./auth') +var config = require('../config') + +async function authDELETE(object){ + var that = this; + var authObj = auth.authCodeGenerator; + authObj.updateTimestamp(); + wx.request({ + method: "POST", + url: config.hostUrl+"/"+object.url+"/delete", + data: object.data, + header:{ + 'openid': app.globalData.openid, + 'X-Requested-With': '', + 'timestamp': authObj.timestamp, + 'signed': authObj.signed(app.globalData.openid, app.globalData.token) + }, + success: object.success, + fail:object.fail, + }); +} +module.exports = {authDELETE} \ No newline at end of file diff --git a/miniprogram/utils/authGET.js b/miniprogram/utils/authGET.js new file mode 100644 index 0000000..dbddaa1 --- /dev/null +++ b/miniprogram/utils/authGET.js @@ -0,0 +1,63 @@ +const app = getApp() +var auth = require('./auth') +var config = require('../config') + +function authGET(object){ + var that = this; + var authObj = auth.authCodeGenerator; + authObj.updateTimestamp(); + wx.request({ + method: "GET", + url: config.hostUrl+"/"+object.url, + data: object.data, + header:{ + 'openid': app.globalData.openid, + 'X-Requested-With': '', + 'timestamp': authObj.timestamp, + 'signed': authObj.signed(app.globalData.openid, app.globalData.token) + }, + success: object.success, + fail:object.fail, + }); +} +async function authGETALL(object){ + var that = this; + var authObj = auth.authCodeGenerator; + authObj.updateTimestamp(); + wx.request({ + method: "GET", + url: config.hostUrl+"/"+object.url+'/ids', + data: object.data, + header:{ + 'openid': app.globalData.openid, + 'X-Requested-With': '', + 'timestamp': authObj.timestamp, + 'signed': authObj.signed(app.globalData.openid, app.globalData.token) + }, + success: object.success, + fail:object.fail, + }); +} +async function authGETDETAIL(object){ + var that = this; + var authObj = auth.authCodeGenerator; + authObj.updateTimestamp(); + wx.request({ + method: "GET", + url: config.hostUrl+"/"+object.url+'/details', + data: object.data, + header:{ + 'openid': app.globalData.openid, + 'X-Requested-With': '', + 'timestamp': authObj.timestamp, + 'signed': authObj.signed(app.globalData.openid, app.globalData.token) + }, + success: object.success, + fail:object.fail, + }); +} +module.exports = { + authGET, + authGETALL, + authGETDETAIL, +} \ No newline at end of file diff --git a/miniprogram/utils/authPATCH.js b/miniprogram/utils/authPATCH.js new file mode 100644 index 0000000..8711df2 --- /dev/null +++ b/miniprogram/utils/authPATCH.js @@ -0,0 +1,23 @@ +const app = getApp() +var auth = require('./auth') +var config = require('../config') + +async function authPATCH(object){ + var that = this; + var authObj = auth.authCodeGenerator; + authObj.updateTimestamp(); + wx.request({ + method: "POST", + url: config.hostUrl+"/"+object.url+"/update", + data: object.data, + header:{ + 'openid': app.globalData.openid, + 'X-Requested-With': '', + 'timestamp': authObj.timestamp, + 'signed': authObj.signed(app.globalData.openid, app.globalData.token) + }, + success: object.success, + fail:object.fail, + }); +} +module.exports = {authPATCH} \ No newline at end of file diff --git a/miniprogram/utils/authPOST.js b/miniprogram/utils/authPOST.js new file mode 100644 index 0000000..a2c0cda --- /dev/null +++ b/miniprogram/utils/authPOST.js @@ -0,0 +1,23 @@ +const app = getApp() +var auth = require('./auth') +var config = require('../config') + +async function authPOST(object){ + var that = this; + var authObj = auth.authCodeGenerator; + authObj.updateTimestamp(); + wx.request({ + method: "POST", + url: config.hostUrl+"/"+object.url, + data: object.data, + header:{ + 'openid': app.globalData.openid, + 'X-Requested-With': '', + 'timestamp': authObj.timestamp, + 'signed': authObj.signed(app.globalData.openid, app.globalData.token) + }, + success: object.success, + fail:object.fail, + }); +} +module.exports = {authPOST} \ No newline at end of file diff --git a/miniprogram/utils/authRESULT.js b/miniprogram/utils/authRESULT.js new file mode 100644 index 0000000..04349c5 --- /dev/null +++ b/miniprogram/utils/authRESULT.js @@ -0,0 +1,64 @@ +const app = getApp() +var auth = require('./auth') +var config = require('../config') + +function authTODAY(object){ + var that = this; + var authObj = auth.authCodeGenerator; + authObj.updateTimestamp(); + wx.request({ + method: "GET", + url: config.hostUrl+'/'+object.url+"/today", + data: object.data, + header:{ + 'openid': app.globalData.openid, + 'X-Requested-With': '', + 'timestamp': authObj.timestamp, + 'signed': authObj.signed(app.globalData.openid, app.globalData.token) + }, + success: object.success, + fail:object.fail, + }); +} +async function authRESULTS(object){ + var that = this; + var authObj = auth.authCodeGenerator; + authObj.updateTimestamp(); + wx.request({ + method: "GET", + url: config.hostUrl+'/'+object.url+"/results", + data: object.data, + header:{ + 'openid': app.globalData.openid, + 'X-Requested-With': '', + 'timestamp': authObj.timestamp, + 'signed': authObj.signed(app.globalData.openid, app.globalData.token) + }, + success: object.success, + fail:object.fail, + }); +} +async function authMARK(object){ + var that = this; + var authObj = auth.authCodeGenerator; + authObj.updateTimestamp(); + wx.request({ + method: "POST", + url: config.hostUrl+'/'+object.url+"/mark", + data: object.data, + header:{ + 'openid': app.globalData.openid, + 'X-Requested-With': '', + 'timestamp': authObj.timestamp, + 'signed': authObj.signed(app.globalData.openid, app.globalData.token) + }, + success: object.success, + fail:object.fail, + }); +} +module.exports = { + authTODAY, + authRESULTS, + authMARK, + +} \ No newline at end of file diff --git a/miniprogram/utils/authTIME.js b/miniprogram/utils/authTIME.js new file mode 100644 index 0000000..ae1cb29 --- /dev/null +++ b/miniprogram/utils/authTIME.js @@ -0,0 +1,45 @@ +const app = getApp() +var auth = require('./auth') +var config = require('../config') + +function authGET(object){ + var that = this; + var authObj = auth.authCodeGenerator; + authObj.updateTimestamp(); + wx.request({ + method: "GET", + url: config.hostUrl+"/time/disabled/list", + data: object.data, + header:{ + 'openid': app.globalData.openid, + 'X-Requested-With': '', + 'timestamp': authObj.timestamp, + 'signed': authObj.signed(app.globalData.openid, app.globalData.token) + }, + success: object.success, + fail:object.fail, + }); +} +async function authPOST(object){ + var that = this; + var authObj = auth.authCodeGenerator; + authObj.updateTimestamp(); + wx.request({ + method: "POST", + url: config.hostUrl+"/time/disabled/set", + data: object.data, + header:{ + 'openid': app.globalData.openid, + 'X-Requested-With': '', + 'timestamp': authObj.timestamp, + 'signed': authObj.signed(app.globalData.openid, app.globalData.token) + }, + success: object.success, + fail:object.fail, + }); +} + +module.exports = { + authGET, + authPOST, +} \ No newline at end of file diff --git a/miniprogram/utils/sha1.js b/miniprogram/utils/sha1.js new file mode 100644 index 0000000..c6b4eae --- /dev/null +++ b/miniprogram/utils/sha1.js @@ -0,0 +1,371 @@ +/* + * [js-sha1]{@link https://github.com/emn178/js-sha1} + * + * @version 0.6.0 + * @author Chen, Yi-Cyuan [emn178@gmail.com] + * @copyright Chen, Yi-Cyuan 2014-2017 + * @license MIT + */ +/*jslint bitwise: true */ +(function() { + 'use strict'; + + var root = typeof window === 'object' ? window : {}; + var NODE_JS = !root.JS_SHA1_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; + if (NODE_JS) { + root = global; + } + var COMMON_JS = !root.JS_SHA1_NO_COMMON_JS && typeof module === 'object' && module.exports; + var AMD = typeof define === 'function' && define.amd; + var HEX_CHARS = '0123456789abcdef'.split(''); + var EXTRA = [-2147483648, 8388608, 32768, 128]; + var SHIFT = [24, 16, 8, 0]; + var OUTPUT_TYPES = ['hex', 'array', 'digest', 'arrayBuffer']; + + var blocks = []; + + var createOutputMethod = function (outputType) { + return function (message) { + return new Sha1(true).update(message)[outputType](); + }; + }; + + var createMethod = function () { + var method = createOutputMethod('hex'); + if (NODE_JS) { + method = nodeWrap(method); + } + method.create = function () { + return new Sha1(); + }; + method.update = function (message) { + return method.create().update(message); + }; + for (var i = 0; i < OUTPUT_TYPES.length; ++i) { + var type = OUTPUT_TYPES[i]; + method[type] = createOutputMethod(type); + } + return method; + }; + + var nodeWrap = function (method) { + var crypto = eval("require('crypto')"); + var Buffer = eval("require('buffer').Buffer"); + var nodeMethod = function (message) { + if (typeof message === 'string') { + return crypto.createHash('sha1').update(message, 'utf8').digest('hex'); + } else if (message.constructor === ArrayBuffer) { + message = new Uint8Array(message); + } else if (message.length === undefined) { + return method(message); + } + return crypto.createHash('sha1').update(new Buffer(message)).digest('hex'); + }; + return nodeMethod; + }; + + function Sha1(sharedMemory) { + if (sharedMemory) { + blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] = + blocks[4] = blocks[5] = blocks[6] = blocks[7] = + blocks[8] = blocks[9] = blocks[10] = blocks[11] = + blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; + this.blocks = blocks; + } else { + this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; + } + + this.h0 = 0x67452301; + this.h1 = 0xEFCDAB89; + this.h2 = 0x98BADCFE; + this.h3 = 0x10325476; + this.h4 = 0xC3D2E1F0; + + this.block = this.start = this.bytes = this.hBytes = 0; + this.finalized = this.hashed = false; + this.first = true; + } + + Sha1.prototype.update = function (message) { + if (this.finalized) { + return; + } + var notString = typeof(message) !== 'string'; + if (notString && message.constructor === root.ArrayBuffer) { + message = new Uint8Array(message); + } + var code, index = 0, i, length = message.length || 0, blocks = this.blocks; + + while (index < length) { + if (this.hashed) { + this.hashed = false; + blocks[0] = this.block; + blocks[16] = blocks[1] = blocks[2] = blocks[3] = + blocks[4] = blocks[5] = blocks[6] = blocks[7] = + blocks[8] = blocks[9] = blocks[10] = blocks[11] = + blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; + } + + if(notString) { + for (i = this.start; index < length && i < 64; ++index) { + blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; + } + } else { + for (i = this.start; index < length && i < 64; ++index) { + code = message.charCodeAt(index); + if (code < 0x80) { + blocks[i >> 2] |= code << SHIFT[i++ & 3]; + } else if (code < 0x800) { + blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else if (code < 0xd800 || code >= 0xe000) { + blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } + } + } + + this.lastByteIndex = i; + this.bytes += i - this.start; + if (i >= 64) { + this.block = blocks[16]; + this.start = i - 64; + this.hash(); + this.hashed = true; + } else { + this.start = i; + } + } + if (this.bytes > 4294967295) { + this.hBytes += this.bytes / 4294967296 << 0; + this.bytes = this.bytes % 4294967296; + } + return this; + }; + + Sha1.prototype.finalize = function () { + if (this.finalized) { + return; + } + this.finalized = true; + var blocks = this.blocks, i = this.lastByteIndex; + blocks[16] = this.block; + blocks[i >> 2] |= EXTRA[i & 3]; + this.block = blocks[16]; + if (i >= 56) { + if (!this.hashed) { + this.hash(); + } + blocks[0] = this.block; + blocks[16] = blocks[1] = blocks[2] = blocks[3] = + blocks[4] = blocks[5] = blocks[6] = blocks[7] = + blocks[8] = blocks[9] = blocks[10] = blocks[11] = + blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; + } + blocks[14] = this.hBytes << 3 | this.bytes >>> 29; + blocks[15] = this.bytes << 3; + this.hash(); + }; + + Sha1.prototype.hash = function () { + var a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4; + var f, j, t, blocks = this.blocks; + + for(j = 16; j < 80; ++j) { + t = blocks[j - 3] ^ blocks[j - 8] ^ blocks[j - 14] ^ blocks[j - 16]; + blocks[j] = (t << 1) | (t >>> 31); + } + + for(j = 0; j < 20; j += 5) { + f = (b & c) | ((~b) & d); + t = (a << 5) | (a >>> 27); + e = t + f + e + 1518500249 + blocks[j] << 0; + b = (b << 30) | (b >>> 2); + + f = (a & b) | ((~a) & c); + t = (e << 5) | (e >>> 27); + d = t + f + d + 1518500249 + blocks[j + 1] << 0; + a = (a << 30) | (a >>> 2); + + f = (e & a) | ((~e) & b); + t = (d << 5) | (d >>> 27); + c = t + f + c + 1518500249 + blocks[j + 2] << 0; + e = (e << 30) | (e >>> 2); + + f = (d & e) | ((~d) & a); + t = (c << 5) | (c >>> 27); + b = t + f + b + 1518500249 + blocks[j + 3] << 0; + d = (d << 30) | (d >>> 2); + + f = (c & d) | ((~c) & e); + t = (b << 5) | (b >>> 27); + a = t + f + a + 1518500249 + blocks[j + 4] << 0; + c = (c << 30) | (c >>> 2); + } + + for(; j < 40; j += 5) { + f = b ^ c ^ d; + t = (a << 5) | (a >>> 27); + e = t + f + e + 1859775393 + blocks[j] << 0; + b = (b << 30) | (b >>> 2); + + f = a ^ b ^ c; + t = (e << 5) | (e >>> 27); + d = t + f + d + 1859775393 + blocks[j + 1] << 0; + a = (a << 30) | (a >>> 2); + + f = e ^ a ^ b; + t = (d << 5) | (d >>> 27); + c = t + f + c + 1859775393 + blocks[j + 2] << 0; + e = (e << 30) | (e >>> 2); + + f = d ^ e ^ a; + t = (c << 5) | (c >>> 27); + b = t + f + b + 1859775393 + blocks[j + 3] << 0; + d = (d << 30) | (d >>> 2); + + f = c ^ d ^ e; + t = (b << 5) | (b >>> 27); + a = t + f + a + 1859775393 + blocks[j + 4] << 0; + c = (c << 30) | (c >>> 2); + } + + for(; j < 60; j += 5) { + f = (b & c) | (b & d) | (c & d); + t = (a << 5) | (a >>> 27); + e = t + f + e - 1894007588 + blocks[j] << 0; + b = (b << 30) | (b >>> 2); + + f = (a & b) | (a & c) | (b & c); + t = (e << 5) | (e >>> 27); + d = t + f + d - 1894007588 + blocks[j + 1] << 0; + a = (a << 30) | (a >>> 2); + + f = (e & a) | (e & b) | (a & b); + t = (d << 5) | (d >>> 27); + c = t + f + c - 1894007588 + blocks[j + 2] << 0; + e = (e << 30) | (e >>> 2); + + f = (d & e) | (d & a) | (e & a); + t = (c << 5) | (c >>> 27); + b = t + f + b - 1894007588 + blocks[j + 3] << 0; + d = (d << 30) | (d >>> 2); + + f = (c & d) | (c & e) | (d & e); + t = (b << 5) | (b >>> 27); + a = t + f + a - 1894007588 + blocks[j + 4] << 0; + c = (c << 30) | (c >>> 2); + } + + for(; j < 80; j += 5) { + f = b ^ c ^ d; + t = (a << 5) | (a >>> 27); + e = t + f + e - 899497514 + blocks[j] << 0; + b = (b << 30) | (b >>> 2); + + f = a ^ b ^ c; + t = (e << 5) | (e >>> 27); + d = t + f + d - 899497514 + blocks[j + 1] << 0; + a = (a << 30) | (a >>> 2); + + f = e ^ a ^ b; + t = (d << 5) | (d >>> 27); + c = t + f + c - 899497514 + blocks[j + 2] << 0; + e = (e << 30) | (e >>> 2); + + f = d ^ e ^ a; + t = (c << 5) | (c >>> 27); + b = t + f + b - 899497514 + blocks[j + 3] << 0; + d = (d << 30) | (d >>> 2); + + f = c ^ d ^ e; + t = (b << 5) | (b >>> 27); + a = t + f + a - 899497514 + blocks[j + 4] << 0; + c = (c << 30) | (c >>> 2); + } + + this.h0 = this.h0 + a << 0; + this.h1 = this.h1 + b << 0; + this.h2 = this.h2 + c << 0; + this.h3 = this.h3 + d << 0; + this.h4 = this.h4 + e << 0; + }; + + Sha1.prototype.hex = function () { + this.finalize(); + + var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4; + + return HEX_CHARS[(h0 >> 28) & 0x0F] + HEX_CHARS[(h0 >> 24) & 0x0F] + + HEX_CHARS[(h0 >> 20) & 0x0F] + HEX_CHARS[(h0 >> 16) & 0x0F] + + HEX_CHARS[(h0 >> 12) & 0x0F] + HEX_CHARS[(h0 >> 8) & 0x0F] + + HEX_CHARS[(h0 >> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] + + HEX_CHARS[(h1 >> 28) & 0x0F] + HEX_CHARS[(h1 >> 24) & 0x0F] + + HEX_CHARS[(h1 >> 20) & 0x0F] + HEX_CHARS[(h1 >> 16) & 0x0F] + + HEX_CHARS[(h1 >> 12) & 0x0F] + HEX_CHARS[(h1 >> 8) & 0x0F] + + HEX_CHARS[(h1 >> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] + + HEX_CHARS[(h2 >> 28) & 0x0F] + HEX_CHARS[(h2 >> 24) & 0x0F] + + HEX_CHARS[(h2 >> 20) & 0x0F] + HEX_CHARS[(h2 >> 16) & 0x0F] + + HEX_CHARS[(h2 >> 12) & 0x0F] + HEX_CHARS[(h2 >> 8) & 0x0F] + + HEX_CHARS[(h2 >> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] + + HEX_CHARS[(h3 >> 28) & 0x0F] + HEX_CHARS[(h3 >> 24) & 0x0F] + + HEX_CHARS[(h3 >> 20) & 0x0F] + HEX_CHARS[(h3 >> 16) & 0x0F] + + HEX_CHARS[(h3 >> 12) & 0x0F] + HEX_CHARS[(h3 >> 8) & 0x0F] + + HEX_CHARS[(h3 >> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] + + HEX_CHARS[(h4 >> 28) & 0x0F] + HEX_CHARS[(h4 >> 24) & 0x0F] + + HEX_CHARS[(h4 >> 20) & 0x0F] + HEX_CHARS[(h4 >> 16) & 0x0F] + + HEX_CHARS[(h4 >> 12) & 0x0F] + HEX_CHARS[(h4 >> 8) & 0x0F] + + HEX_CHARS[(h4 >> 4) & 0x0F] + HEX_CHARS[h4 & 0x0F]; + }; + + Sha1.prototype.toString = Sha1.prototype.hex; + + Sha1.prototype.digest = function () { + this.finalize(); + + var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4; + + return [ + (h0 >> 24) & 0xFF, (h0 >> 16) & 0xFF, (h0 >> 8) & 0xFF, h0 & 0xFF, + (h1 >> 24) & 0xFF, (h1 >> 16) & 0xFF, (h1 >> 8) & 0xFF, h1 & 0xFF, + (h2 >> 24) & 0xFF, (h2 >> 16) & 0xFF, (h2 >> 8) & 0xFF, h2 & 0xFF, + (h3 >> 24) & 0xFF, (h3 >> 16) & 0xFF, (h3 >> 8) & 0xFF, h3 & 0xFF, + (h4 >> 24) & 0xFF, (h4 >> 16) & 0xFF, (h4 >> 8) & 0xFF, h4 & 0xFF + ]; + }; + + Sha1.prototype.array = Sha1.prototype.digest; + + Sha1.prototype.arrayBuffer = function () { + this.finalize(); + + var buffer = new ArrayBuffer(20); + var dataView = new DataView(buffer); + dataView.setUint32(0, this.h0); + dataView.setUint32(4, this.h1); + dataView.setUint32(8, this.h2); + dataView.setUint32(12, this.h3); + dataView.setUint32(16, this.h4); + return buffer; + }; + + var exports = createMethod(); + + if (COMMON_JS) { + module.exports = exports; + } else { + root.sha1 = exports; + if (AMD) { + define(function () { + return exports; + }); + } + } +})(); \ No newline at end of file diff --git a/miniprogram/utils/sha256.js b/miniprogram/utils/sha256.js new file mode 100644 index 0000000..b621650 --- /dev/null +++ b/miniprogram/utils/sha256.js @@ -0,0 +1,250 @@ +/* +* A JavaScript implementation of the SHA256 hash function. +* +* FILE: sha256.js +* VERSION: 0.8 +* AUTHOR: Christoph Bichlmeier +* +* NOTE: This version is not tested thoroughly! +* +* Copyright (c) 2003, Christoph Bichlmeier +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* 3. Neither the name of the copyright holder nor the names of contributors +* may be used to endorse or promote products derived from this software +* without specific prior written permission. +* +* ====================================================================== +* +* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS +* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE +* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* SHA256 logical functions */ +function rotateRight(n,x) { + return ((x >>> n) | (x << (32 - n))); +} +function choice(x,y,z) { + return ((x & y) ^ (~x & z)); +} +function majority(x,y,z) { + return ((x & y) ^ (x & z) ^ (y & z)); +} +function sha256_Sigma0(x) { + return (rotateRight(2, x) ^ rotateRight(13, x) ^ rotateRight(22, x)); +} +function sha256_Sigma1(x) { + return (rotateRight(6, x) ^ rotateRight(11, x) ^ rotateRight(25, x)); +} +function sha256_sigma0(x) { + return (rotateRight(7, x) ^ rotateRight(18, x) ^ (x >>> 3)); +} +function sha256_sigma1(x) { + return (rotateRight(17, x) ^ rotateRight(19, x) ^ (x >>> 10)); +} +function sha256_expand(W, j) { + return (W[j&0x0f] += sha256_sigma1(W[(j+14)&0x0f]) + W[(j+9)&0x0f] + +sha256_sigma0(W[(j+1)&0x0f])); +} + +/* Hash constant words K: */ +var K256 = new Array( + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, + 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, + 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, + 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, + 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +); + +/* global arrays */ +var ihash, count, buffer; +var sha256_hex_digits = "0123456789abcdef"; + +/* Add 32-bit integers with 16-bit operations (bug in some JS-interpreters: +overflow) */ +function safe_add(x, y) +{ + var lsw = (x & 0xffff) + (y & 0xffff); + var msw = (x >> 16) + (y >> 16) + (lsw >> 16); + return (msw << 16) | (lsw & 0xffff); +} + +/* Initialise the SHA256 computation */ +function sha256_init() { + ihash = new Array(8); + count = new Array(2); + buffer = new Array(64); + count[0] = count[1] = 0; + ihash[0] = 0x6a09e667; + ihash[1] = 0xbb67ae85; + ihash[2] = 0x3c6ef372; + ihash[3] = 0xa54ff53a; + ihash[4] = 0x510e527f; + ihash[5] = 0x9b05688c; + ihash[6] = 0x1f83d9ab; + ihash[7] = 0x5be0cd19; +} + +/* Transform a 512-bit message block */ +function sha256_transform() { + var a, b, c, d, e, f, g, h, T1, T2; + var W = new Array(16); + + /* Initialize registers with the previous intermediate value */ + a = ihash[0]; + b = ihash[1]; + c = ihash[2]; + d = ihash[3]; + e = ihash[4]; + f = ihash[5]; + g = ihash[6]; + h = ihash[7]; + + /* make 32-bit words */ + for(var i=0; i<16; i++) + W[i] = ((buffer[(i<<2)+3]) | (buffer[(i<<2)+2] << 8) | (buffer[(i<<2)+1] +<< 16) | (buffer[i<<2] << 24)); + + for(var j=0; j<64; j++) { + T1 = h + sha256_Sigma1(e) + choice(e, f, g) + K256[j]; + if(j < 16) T1 += W[j]; + else T1 += sha256_expand(W, j); + T2 = sha256_Sigma0(a) + majority(a, b, c); + h = g; + g = f; + f = e; + e = safe_add(d, T1); + d = c; + c = b; + b = a; + a = safe_add(T1, T2); + } + + /* Compute the current intermediate hash value */ + ihash[0] += a; + ihash[1] += b; + ihash[2] += c; + ihash[3] += d; + ihash[4] += e; + ihash[5] += f; + ihash[6] += g; + ihash[7] += h; +} + +/* Read the next chunk of data and update the SHA256 computation */ +function sha256_update(data, inputLen) { + var i, index, curpos = 0; + /* Compute number of bytes mod 64 */ + index = ((count[0] >> 3) & 0x3f); + var remainder = (inputLen & 0x3f); + + /* Update number of bits */ + if ((count[0] += (inputLen << 3)) < (inputLen << 3)) count[1]++; + count[1] += (inputLen >> 29); + + /* Transform as many times as possible */ + for(i=0; i+63> 3) & 0x3f); + buffer[index++] = 0x80; + if(index <= 56) { + for(var i=index; i<56; i++) + buffer[i] = 0; + } else { + for(var i=index; i<64; i++) + buffer[i] = 0; + sha256_transform(); + for(var i=0; i<56; i++) + buffer[i] = 0; + } + buffer[56] = (count[1] >>> 24) & 0xff; + buffer[57] = (count[1] >>> 16) & 0xff; + buffer[58] = (count[1] >>> 8) & 0xff; + buffer[59] = count[1] & 0xff; + buffer[60] = (count[0] >>> 24) & 0xff; + buffer[61] = (count[0] >>> 16) & 0xff; + buffer[62] = (count[0] >>> 8) & 0xff; + buffer[63] = count[0] & 0xff; + sha256_transform(); +} + +/* Split the internal hash values into an array of bytes */ +function sha256_encode_bytes() { + var j=0; + var output = new Array(32); + for(var i=0; i<8; i++) { + output[j++] = ((ihash[i] >>> 24) & 0xff); + output[j++] = ((ihash[i] >>> 16) & 0xff); + output[j++] = ((ihash[i] >>> 8) & 0xff); + output[j++] = (ihash[i] & 0xff); + } + return output; +} + +/* Get the internal hash as a hex string */ +function sha256_encode_hex() { + var output = new String(); + for(var i=0; i<8; i++) { + for(var j=28; j>=0; j-=4) + output += sha256_hex_digits.charAt((ihash[i] >>> j) & 0x0f); + } + return output; +} + +/* Main function: returns a hex string representing the SHA256 value of the +given data */ +function sha256_digest(data) { + sha256_init(); + sha256_update(data, data.length); + sha256_final(); + return sha256_encode_hex(); +} + +/* test if the JS-interpreter is working properly */ +function sha256_self_test() +{ + return sha256_digest("message digest") == +"f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650"; +} + +module.exports = {sha256_digest} \ No newline at end of file diff --git a/miniprogram/utils/ucharts/u-charts.js b/miniprogram/utils/ucharts/u-charts.js new file mode 100644 index 0000000..602dd99 --- /dev/null +++ b/miniprogram/utils/ucharts/u-charts.js @@ -0,0 +1,5658 @@ +/* + * uCharts v1.9.4.20200331 + * uni-app平台高性能跨全端图表,支持H5、APP、小程序(微信/支付宝/百度/头条/QQ/360) + * Copyright (c) 2019 QIUN秋云 https://www.ucharts.cn All rights reserved. + * Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) + * + * uCharts官方网站 + * https://www.uCharts.cn + * + * 开源地址: + * https://gitee.com/uCharts/uCharts + * + * uni-app插件市场地址: + * http://ext.dcloud.net.cn/plugin?id=271 + * + */ + +'use strict'; + +var config = { + yAxisWidth: 15, + yAxisSplit: 5, + xAxisHeight: 15, + xAxisLineHeight: 15, + legendHeight: 15, + yAxisTitleWidth: 15, + padding: [10, 10, 10, 10], + pixelRatio: 1, + rotate: false, + columePadding: 3, + fontSize: 13, + //dataPointShape: ['diamond', 'circle', 'triangle', 'rect'], + dataPointShape: ['circle', 'circle', 'circle', 'circle'], + colors: ['#1890ff', '#2fc25b', '#facc14', '#f04864', '#8543e0', '#90ed7d'], + pieChartLinePadding: 15, + pieChartTextPadding: 5, + xAxisTextPadding: 3, + titleColor: '#333333', + titleFontSize: 20, + subtitleColor: '#999999', + subtitleFontSize: 15, + toolTipPadding: 3, + toolTipBackground: '#000000', + toolTipOpacity: 0.7, + toolTipLineHeight: 20, + radarLabelTextMargin: 15, + gaugeLabelTextMargin: 15 +}; + +let assign = function (target, ...varArgs) { + if (target == null) { + throw new TypeError('Cannot convert undefined or null to object'); + } + if (!varArgs || varArgs.length <= 0) { + return target; + } + // 深度合并对象 + function deepAssign(obj1, obj2) { + for (let key in obj2) { + obj1[key] = obj1[key] && obj1[key].toString() === "[object Object]" ? + deepAssign(obj1[key], obj2[key]) : obj1[key] = obj2[key]; + } + return obj1; + } + + varArgs.forEach(val => { + target = deepAssign(target, val); + }); + return target; +}; + +var util = { + toFixed: function toFixed(num, limit) { + limit = limit || 2; + if (this.isFloat(num)) { + num = num.toFixed(limit); + } + return num; + }, + isFloat: function isFloat(num) { + return num % 1 !== 0; + }, + approximatelyEqual: function approximatelyEqual(num1, num2) { + return Math.abs(num1 - num2) < 1e-10; + }, + isSameSign: function isSameSign(num1, num2) { + return Math.abs(num1) === num1 && Math.abs(num2) === num2 || Math.abs(num1) !== num1 && Math.abs(num2) !== num2; + }, + isSameXCoordinateArea: function isSameXCoordinateArea(p1, p2) { + return this.isSameSign(p1.x, p2.x); + }, + isCollision: function isCollision(obj1, obj2) { + obj1.end = {}; + obj1.end.x = obj1.start.x + obj1.width; + obj1.end.y = obj1.start.y - obj1.height; + obj2.end = {}; + obj2.end.x = obj2.start.x + obj2.width; + obj2.end.y = obj2.start.y - obj2.height; + var flag = obj2.start.x > obj1.end.x || obj2.end.x < obj1.start.x || obj2.end.y > obj1.start.y || obj2.start.y < obj1.end.y; + return !flag; + } +}; + +//兼容H5点击事件 +function getH5Offset(e) { + e.mp = { + changedTouches: [] + }; + e.mp.changedTouches.push({ + x: e.offsetX, + y: e.offsetY + }); + return e; +} + +// hex 转 rgba +function hexToRgb(hexValue, opc) { + var rgx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i; + var hex = hexValue.replace(rgx, function(m, r, g, b) { + return r + r + g + g + b + b; + }); + var rgb = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); + var r = parseInt(rgb[1], 16); + var g = parseInt(rgb[2], 16); + var b = parseInt(rgb[3], 16); + return 'rgba(' + r + ',' + g + ',' + b + ',' + opc + ')'; +} + +function findRange(num, type, limit) { + if (isNaN(num)) { + throw new Error('[uCharts] unvalid series data!'); + } + limit = limit || 10; + type = type ? type : 'upper'; + var multiple = 1; + while (limit < 1) { + limit *= 10; + multiple *= 10; + } + if (type === 'upper') { + num = Math.ceil(num * multiple); + } else { + num = Math.floor(num * multiple); + } + while (num % limit !== 0) { + if (type === 'upper') { + num++; + } else { + num--; + } + } + return num / multiple; +} + +function calCandleMA(dayArr, nameArr, colorArr, kdata) { + let seriesTemp = []; + for (let k = 0; k < dayArr.length; k++) { + let seriesItem = { + data: [], + name: nameArr[k], + color: colorArr[k] + }; + for (let i = 0, len = kdata.length; i < len; i++) { + if (i < dayArr[k]) { + seriesItem.data.push(null); + continue; + } + let sum = 0; + for (let j = 0; j < dayArr[k]; j++) { + sum += kdata[i - j][1]; + } + seriesItem.data.push(+(sum / dayArr[k]).toFixed(3)); + } + seriesTemp.push(seriesItem); + } + return seriesTemp; +} + +function calValidDistance(self,distance, chartData, config, opts) { + var dataChartAreaWidth = opts.width - opts.area[1] - opts.area[3]; + var dataChartWidth = chartData.eachSpacing * (opts.chartData.xAxisData.xAxisPoints.length-1); + var validDistance = distance; + if (distance >= 0) { + validDistance = 0; + self.event.trigger('scrollLeft'); + } else if (Math.abs(distance) >= dataChartWidth - dataChartAreaWidth) { + validDistance = dataChartAreaWidth - dataChartWidth; + self.event.trigger('scrollRight'); + } + return validDistance; +} + +function isInAngleRange(angle, startAngle, endAngle) { + function adjust(angle) { + while (angle < 0) { + angle += 2 * Math.PI; + } + while (angle > 2 * Math.PI) { + angle -= 2 * Math.PI; + } + return angle; + } + angle = adjust(angle); + startAngle = adjust(startAngle); + endAngle = adjust(endAngle); + if (startAngle > endAngle) { + endAngle += 2 * Math.PI; + if (angle < startAngle) { + angle += 2 * Math.PI; + } + } + return angle >= startAngle && angle <= endAngle; +} + +function calRotateTranslate(x, y, h) { + var xv = x; + var yv = h - y; + var transX = xv + (h - yv - xv) / Math.sqrt(2); + transX *= -1; + var transY = (h - yv) * (Math.sqrt(2) - 1) - (h - yv - xv) / Math.sqrt(2); + return { + transX: transX, + transY: transY + }; +} + +function createCurveControlPoints(points, i) { + + function isNotMiddlePoint(points, i) { + if (points[i - 1] && points[i + 1]) { + return points[i].y >= Math.max(points[i - 1].y, points[i + 1].y) || points[i].y <= Math.min(points[i - 1].y,points[i + 1].y); + } else { + return false; + } + } + function isNotMiddlePointX(points, i) { + if (points[i - 1] && points[i + 1]) { + return points[i].x >= Math.max(points[i - 1].x, points[i + 1].x) || points[i].x <= Math.min(points[i - 1].x,points[i + 1].x); + } else { + return false; + } + } + var a = 0.2; + var b = 0.2; + var pAx = null; + var pAy = null; + var pBx = null; + var pBy = null; + if (i < 1) { + pAx = points[0].x + (points[1].x - points[0].x) * a; + pAy = points[0].y + (points[1].y - points[0].y) * a; + } else { + pAx = points[i].x + (points[i + 1].x - points[i - 1].x) * a; + pAy = points[i].y + (points[i + 1].y - points[i - 1].y) * a; + } + + if (i > points.length - 3) { + var last = points.length - 1; + pBx = points[last].x - (points[last].x - points[last - 1].x) * b; + pBy = points[last].y - (points[last].y - points[last - 1].y) * b; + } else { + pBx = points[i + 1].x - (points[i + 2].x - points[i].x) * b; + pBy = points[i + 1].y - (points[i + 2].y - points[i].y) * b; + } + if (isNotMiddlePoint(points, i + 1)) { + pBy = points[i + 1].y; + } + if (isNotMiddlePoint(points, i)) { + pAy = points[i].y; + } + if (isNotMiddlePointX(points, i + 1)) { + pBx = points[i + 1].x; + } + if (isNotMiddlePointX(points, i)) { + pAx = points[i].x; + } + if (pAy >= Math.max(points[i].y, points[i + 1].y) || pAy <= Math.min(points[i].y, points[i + 1].y)) { + pAy = points[i].y; + } + if (pBy >= Math.max(points[i].y, points[i + 1].y) || pBy <= Math.min(points[i].y, points[i + 1].y)) { + pBy = points[i + 1].y; + } + if (pAx >= Math.max(points[i].x, points[i + 1].x) || pAx <= Math.min(points[i].x, points[i + 1].x)) { + pAx = points[i].x; + } + if (pBx >= Math.max(points[i].x, points[i + 1].x) || pBx <= Math.min(points[i].x, points[i + 1].x)) { + pBx = points[i + 1].x; + } + return { + ctrA: { + x: pAx, + y: pAy + }, + ctrB: { + x: pBx, + y: pBy + } + }; +} + +function convertCoordinateOrigin(x, y, center) { + return { + x: center.x + x, + y: center.y - y + }; +} + +function avoidCollision(obj, target) { + if (target) { + // is collision test + while (util.isCollision(obj, target)) { + if (obj.start.x > 0) { + obj.start.y--; + } else if (obj.start.x < 0) { + obj.start.y++; + } else { + if (obj.start.y > 0) { + obj.start.y++; + } else { + obj.start.y--; + } + } + } + } + return obj; +} + +function fillSeries(series, opts, config) { + var index = 0; + return series.map(function(item) { + if (!item.color) { + item.color = config.colors[index]; + index = (index + 1) % config.colors.length; + } + if (!item.index) { + item.index = 0; + } + if (!item.type) { + item.type = opts.type; + } + if (typeof item.show == "undefined") { + item.show = true; + } + if (!item.type) { + item.type = opts.type; + } + if (!item.pointShape) { + item.pointShape = "circle"; + } + if (!item.legendShape) { + switch (item.type) { + case 'line': + item.legendShape = "line"; + break; + case 'column': + item.legendShape = "rect"; + break; + case 'area': + item.legendShape = "triangle"; + break; + default: + item.legendShape = "circle"; + } + } + return item; + }); +} + +function getDataRange(minData, maxData) { + var limit = 0; + var range = maxData - minData; + if (range >= 10000) { + limit = 1000; + } else if (range >= 1000) { + limit = 100; + } else if (range >= 100) { + limit = 10; + } else if (range >= 10) { + limit = 5; + } else if (range >= 1) { + limit = 1; + } else if (range >= 0.1) { + limit = 0.1; + } else if (range >= 0.01) { + limit = 0.01; + } else if (range >= 0.001) { + limit = 0.001; + } else if (range >= 0.0001) { + limit = 0.0001; + } else if (range >= 0.00001) { + limit = 0.00001; + } else { + limit = 0.000001; + } + return { + minRange: findRange(minData, 'lower', limit), + maxRange: findRange(maxData, 'upper', limit) + }; +} + +function measureText(text) { + var fontSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : config.fontSize; + text = String(text); + var text = text.split(''); + var width = 0; + for (let i = 0; i < text.length; i++) { + let item = text[i]; + if (/[a-zA-Z]/.test(item)) { + width += 7; + } else if (/[0-9]/.test(item)) { + width += 5.5; + } else if (/\./.test(item)) { + width += 2.7; + } else if (/-/.test(item)) { + width += 3.25; + } else if (/[\u4e00-\u9fa5]/.test(item)) { + width += 10; + } else if (/\(|\)/.test(item)) { + width += 3.73; + } else if (/\s/.test(item)) { + width += 2.5; + } else if (/%/.test(item)) { + width += 8; + } else { + width += 10; + } + } + return width * fontSize / 10; +} + +function dataCombine(series) { + return series.reduce(function(a, b) { + return (a.data ? a.data : a).concat(b.data); + }, []); +} + +function dataCombineStack(series, len) { + var sum = new Array(len); + for (var j = 0; j < sum.length; j++) { + sum[j] = 0; + } + for (var i = 0; i < series.length; i++) { + for (var j = 0; j < sum.length; j++) { + sum[j] += series[i].data[j]; + } + } + return series.reduce(function(a, b) { + return (a.data ? a.data : a).concat(b.data).concat(sum); + }, []); +} + +function getTouches(touches, opts, e) { + let x, y; + if (touches.clientX) { + if (opts.rotate) { + y = opts.height - touches.clientX * opts.pixelRatio; + x = (touches.pageY - e.currentTarget.offsetTop - (opts.height / opts.pixelRatio / 2) * (opts.pixelRatio - 1)) * + opts.pixelRatio; + } else { + x = touches.clientX * opts.pixelRatio; + y = (touches.pageY - e.currentTarget.offsetTop - (opts.height / opts.pixelRatio / 2) * (opts.pixelRatio - 1)) * + opts.pixelRatio; + } + } else { + if (opts.rotate) { + y = opts.height - touches.x * opts.pixelRatio; + x = touches.y * opts.pixelRatio; + } else { + x = touches.x * opts.pixelRatio; + y = touches.y * opts.pixelRatio; + } + } + return { + x: x, + y: y + } +} + +function getSeriesDataItem(series, index) { + var data = []; + for (let i = 0; i < series.length; i++) { + let item = series[i]; + if (item.data[index] !== null && typeof item.data[index] !== 'undefined' && item.show) { + let seriesItem = {}; + seriesItem.color = item.color; + seriesItem.type = item.type; + seriesItem.style = item.style; + seriesItem.pointShape = item.pointShape; + seriesItem.disableLegend = item.disableLegend; + seriesItem.name = item.name; + seriesItem.show = item.show; + seriesItem.data = item.format ? item.format(item.data[index]) : item.data[index]; + data.push(seriesItem); + } + } + return data; +} + +function getMaxTextListLength(list) { + var lengthList = list.map(function(item) { + return measureText(item); + }); + return Math.max.apply(null, lengthList); +} + +function getRadarCoordinateSeries(length) { + var eachAngle = 2 * Math.PI / length; + var CoordinateSeries = []; + for (var i = 0; i < length; i++) { + CoordinateSeries.push(eachAngle * i); + } + + return CoordinateSeries.map(function(item) { + return -1 * item + Math.PI / 2; + }); +} + +function getToolTipData(seriesData, calPoints, index, categories) { + var option = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {}; + + var textList = seriesData.map(function(item) { + let titleText=[]; + if(categories){ + titleText=categories; + }else{ + titleText=item.data; + } + return { + text: option.format ? option.format(item, titleText[index]) : item.name + ': ' + item.data, + color: item.color + }; + }); + var validCalPoints = []; + var offset = { + x: 0, + y: 0 + }; + for (let i = 0; i < calPoints.length; i++) { + let points = calPoints[i]; + if (typeof points[index] !== 'undefined' && points[index] !== null) { + validCalPoints.push(points[index]); + } + } + for (let i = 0; i < validCalPoints.length; i++) { + let item = validCalPoints[i]; + offset.x = Math.round(item.x); + offset.y += item.y; + } + offset.y /= validCalPoints.length; + return { + textList: textList, + offset: offset + }; +} + +function getMixToolTipData(seriesData, calPoints, index, categories) { + var option = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {}; + var textList = seriesData.map(function(item) { + return { + text: option.format ? option.format(item, categories[index]) : item.name + ': ' + item.data, + color: item.color, + disableLegend: item.disableLegend ? true : false + }; + }); + textList = textList.filter(function(item) { + if (item.disableLegend !== true) { + return item; + } + }); + var validCalPoints = []; + var offset = { + x: 0, + y: 0 + }; + for (let i = 0; i < calPoints.length; i++) { + let points = calPoints[i]; + if (typeof points[index] !== 'undefined' && points[index] !== null) { + validCalPoints.push(points[index]); + } + } + for (let i = 0; i < validCalPoints.length; i++) { + let item = validCalPoints[i]; + offset.x = Math.round(item.x); + offset.y += item.y; + } + offset.y /= validCalPoints.length; + return { + textList: textList, + offset: offset + }; +} + +function getCandleToolTipData(series, seriesData, calPoints, index, categories, extra) { + var option = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : {}; + let upColor = extra.color.upFill; + let downColor = extra.color.downFill; + //颜色顺序为开盘,收盘,最低,最高 + let color = [upColor, upColor, downColor, upColor]; + var textList = []; + let text0 = { + text: categories[index], + color: null + }; + textList.push(text0); + seriesData.map(function(item) { + if (index == 0 && item.data[1] - item.data[0] < 0) { + color[1] = downColor; + } else { + if (item.data[0] < series[index - 1][1]) { + color[0] = downColor; + } + if (item.data[1] < item.data[0]) { + color[1] = downColor; + } + if (item.data[2] > series[index - 1][1]) { + color[2] = upColor; + } + if (item.data[3] < series[index - 1][1]) { + color[3] = downColor; + } + } + let text1 = { + text: '开盘:' + item.data[0], + color: color[0] + }; + let text2 = { + text: '收盘:' + item.data[1], + color: color[1] + }; + let text3 = { + text: '最低:' + item.data[2], + color: color[2] + }; + let text4 = { + text: '最高:' + item.data[3], + color: color[3] + }; + textList.push(text1, text2, text3, text4); + }); + var validCalPoints = []; + var offset = { + x: 0, + y: 0 + }; + for (let i = 0; i < calPoints.length; i++) { + let points = calPoints[i]; + if (typeof points[index] !== 'undefined' && points[index] !== null) { + validCalPoints.push(points[index]); + } + } + offset.x = Math.round(validCalPoints[0][0].x); + return { + textList: textList, + offset: offset + }; +} + +function filterSeries(series) { + let tempSeries = []; + for (let i = 0; i < series.length; i++) { + if (series[i].show == true) { + tempSeries.push(series[i]) + } + } + return tempSeries; +} + +function findCurrentIndex(currentPoints, calPoints, opts, config) { + var offset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0; + var currentIndex = -1; + var spacing = opts.chartData.eachSpacing/2; + let xAxisPoints=[]; + if(calPoints.length>0){ + if(opts.type=='candle'){ + for(let i=0;i item) { + currentIndex = index; + } + }); + } + } + return currentIndex; +} + +function findLegendIndex(currentPoints, legendData, opts) { + let currentIndex = -1; + if (isInExactLegendArea(currentPoints, legendData.area)) { + let points = legendData.points; + let index = -1; + for (let i = 0, len = points.length; i < len; i++) { + let item = points[i]; + for (let j = 0; j < item.length; j++) { + index += 1; + let area = item[j]['area']; + if (currentPoints.x > area[0] && currentPoints.x < area[2] && currentPoints.y > area[1] && currentPoints.y < area[3]) { + currentIndex = index; + break; + } + } + } + return currentIndex; + } + return currentIndex; +} + +function isInExactLegendArea(currentPoints, area) { + return currentPoints.x > area.start.x && currentPoints.x < area.end.x && currentPoints.y > area.start.y && + currentPoints.y < area.end.y; +} + +function isInExactChartArea(currentPoints, opts, config) { + return currentPoints.x <= opts.width - opts.area[1] + 10 && currentPoints.x >= opts.area[3] -10 && currentPoints.y >= opts.area[0] && currentPoints.y <= opts.height - opts.area[2]; +} + +function findRadarChartCurrentIndex(currentPoints, radarData, count) { + var eachAngleArea = 2 * Math.PI / count; + var currentIndex = -1; + if (isInExactPieChartArea(currentPoints, radarData.center, radarData.radius)) { + var fixAngle = function fixAngle(angle) { + if (angle < 0) { + angle += 2 * Math.PI; + } + if (angle > 2 * Math.PI) { + angle -= 2 * Math.PI; + } + return angle; + }; + + var angle = Math.atan2(radarData.center.y - currentPoints.y, currentPoints.x - radarData.center.x); + angle = -1 * angle; + if (angle < 0) { + angle += 2 * Math.PI; + } + + var angleList = radarData.angleList.map(function(item) { + item = fixAngle(-1 * item); + + return item; + }); + + angleList.forEach(function(item, index) { + var rangeStart = fixAngle(item - eachAngleArea / 2); + var rangeEnd = fixAngle(item + eachAngleArea / 2); + if (rangeEnd < rangeStart) { + rangeEnd += 2 * Math.PI; + } + if (angle >= rangeStart && angle <= rangeEnd || angle + 2 * Math.PI >= rangeStart && angle + 2 * Math.PI <= + rangeEnd) { + currentIndex = index; + } + }); + } + + return currentIndex; +} + +function findFunnelChartCurrentIndex(currentPoints, funnelData) { + var currentIndex = -1; + for (var i = 0, len = funnelData.series.length; i < len; i++) { + var item = funnelData.series[i]; + if (currentPoints.x > item.funnelArea[0] && currentPoints.x < item.funnelArea[2] && currentPoints.y > item.funnelArea[1] && currentPoints.y < item.funnelArea[3]) { + currentIndex = i; + break; + } + } + return currentIndex; +} + +function findWordChartCurrentIndex(currentPoints, wordData) { + var currentIndex = -1; + for (var i = 0, len = wordData.length; i < len; i++) { + var item = wordData[i]; + if (currentPoints.x > item.area[0] && currentPoints.x < item.area[2] && currentPoints.y > item.area[1] && currentPoints.y < item.area[3]) { + currentIndex = i; + break; + } + } + return currentIndex; +} + +function findMapChartCurrentIndex(currentPoints, opts) { + var currentIndex = -1; + var cData=opts.chartData.mapData; + var data=opts.series; + var tmp=pointToCoordinate(currentPoints.y, currentPoints.x,cData.bounds,cData.scale,cData.xoffset,cData.yoffset); + var poi=[tmp.x, tmp.y]; + for (var i = 0, len = data.length; i < len; i++) { + var item = data[i].geometry.coordinates; + if(isPoiWithinPoly(poi,item)){ + currentIndex = i; + break; + } + } + return currentIndex; +} + +function findPieChartCurrentIndex(currentPoints, pieData) { + var currentIndex = -1; + if (isInExactPieChartArea(currentPoints, pieData.center, pieData.radius)) { + var angle = Math.atan2(pieData.center.y - currentPoints.y, currentPoints.x - pieData.center.x); + angle = -angle; + for (var i = 0, len = pieData.series.length; i < len; i++) { + var item = pieData.series[i]; + if (isInAngleRange(angle, item._start_, item._start_ + item._proportion_ * 2 * Math.PI)) { + currentIndex = i; + break; + } + } + } + + return currentIndex; +} + +function isInExactPieChartArea(currentPoints, center, radius) { + return Math.pow(currentPoints.x - center.x, 2) + Math.pow(currentPoints.y - center.y, 2) <= Math.pow(radius, 2); +} + +function splitPoints(points) { + var newPoints = []; + var items = []; + points.forEach(function(item, index) { + if (item !== null) { + items.push(item); + } else { + if (items.length) { + newPoints.push(items); + } + items = []; + } + }); + if (items.length) { + newPoints.push(items); + } + + return newPoints; +} + +function calLegendData(series, opts, config, chartData) { + let legendData = { + area: { + start: { + x: 0, + y: 0 + }, + end: { + x: 0, + y: 0 + }, + width: 0, + height: 0, + wholeWidth: 0, + wholeHeight: 0 + }, + points: [], + widthArr: [], + heightArr: [] + }; + if (opts.legend.show === false) { + chartData.legendData = legendData; + return legendData; + } + + let padding = opts.legend.padding; + let margin = opts.legend.margin; + let fontSize = opts.legend.fontSize; + let shapeWidth = 15 * opts.pixelRatio; + let shapeRight = 5 * opts.pixelRatio; + let lineHeight = Math.max(opts.legend.lineHeight * opts.pixelRatio, fontSize); + if (opts.legend.position == 'top' || opts.legend.position == 'bottom') { + let legendList = []; + let widthCount = 0; + let widthCountArr = []; + let currentRow = []; + for (let i = 0; i < series.length; i++) { + let item = series[i]; + let itemWidth = shapeWidth + shapeRight + measureText(item.name || 'undefined', fontSize) + opts.legend.itemGap; + if (widthCount + itemWidth > opts.width - opts.padding[1] - opts.padding[3]) { + legendList.push(currentRow); + widthCountArr.push(widthCount - opts.legend.itemGap); + widthCount = itemWidth; + currentRow = [item]; + } else { + widthCount += itemWidth; + currentRow.push(item); + } + } + if (currentRow.length) { + legendList.push(currentRow); + widthCountArr.push(widthCount - opts.legend.itemGap); + legendData.widthArr = widthCountArr; + let legendWidth = Math.max.apply(null, widthCountArr); + switch (opts.legend.float) { + case 'left': + legendData.area.start.x = opts.padding[3]; + legendData.area.end.x = opts.padding[3] + 2 * padding; + break; + case 'right': + legendData.area.start.x = opts.width - opts.padding[1] - legendWidth - 2 * padding; + legendData.area.end.x = opts.width - opts.padding[1]; + break; + default: + legendData.area.start.x = (opts.width - legendWidth) / 2 - padding; + legendData.area.end.x = (opts.width + legendWidth) / 2 + padding; + } + legendData.area.width = legendWidth + 2 * padding; + legendData.area.wholeWidth = legendWidth + 2 * padding; + legendData.area.height = legendList.length * lineHeight + 2 * padding; + legendData.area.wholeHeight = legendList.length * lineHeight + 2 * padding + 2 * margin; + legendData.points = legendList; + } + } else { + let len = series.length; + let maxHeight = opts.height - opts.padding[0] - opts.padding[2] - 2 * margin - 2 * padding; + let maxLength = Math.min(Math.floor(maxHeight / lineHeight), len); + legendData.area.height = maxLength * lineHeight + padding * 2; + legendData.area.wholeHeight = maxLength * lineHeight + padding * 2; + switch (opts.legend.float) { + case 'top': + legendData.area.start.y = opts.padding[0] + margin; + legendData.area.end.y = opts.padding[0] + margin + legendData.area.height; + break; + case 'bottom': + legendData.area.start.y = opts.height - opts.padding[2] - margin - legendData.area.height; + legendData.area.end.y = opts.height - opts.padding[2] - margin; + break; + default: + legendData.area.start.y = (opts.height - legendData.area.height) / 2; + legendData.area.end.y = (opts.height + legendData.area.height) / 2; + } + let lineNum = len % maxLength === 0 ? len / maxLength : Math.floor((len / maxLength) + 1); + let currentRow = []; + for (let i = 0; i < lineNum; i++) { + let temp = series.slice(i * maxLength, i * maxLength + maxLength); + currentRow.push(temp); + } + + legendData.points = currentRow; + + if (currentRow.length) { + for (let i = 0; i < currentRow.length; i++) { + let item = currentRow[i]; + let maxWidth = 0; + for (let j = 0; j < item.length; j++) { + let itemWidth = shapeWidth + shapeRight + measureText(item[j].name || 'undefined', fontSize) + opts.legend.itemGap; + if (itemWidth > maxWidth) { + maxWidth = itemWidth; + } + } + legendData.widthArr.push(maxWidth); + legendData.heightArr.push(item.length * lineHeight + padding * 2); + } + let legendWidth = 0 + for (let i = 0; i < legendData.widthArr.length; i++) { + legendWidth += legendData.widthArr[i]; + } + legendData.area.width = legendWidth - opts.legend.itemGap + 2 * padding; + legendData.area.wholeWidth = legendData.area.width + padding; + } + } + + switch (opts.legend.position) { + case 'top': + legendData.area.start.y = opts.padding[0] + margin; + legendData.area.end.y = opts.padding[0] + margin + legendData.area.height; + break; + case 'bottom': + legendData.area.start.y = opts.height - opts.padding[2] - legendData.area.height - margin; + legendData.area.end.y = opts.height - opts.padding[2] - margin; + break; + case 'left': + legendData.area.start.x = opts.padding[3]; + legendData.area.end.x = opts.padding[3] + legendData.area.width; + break; + case 'right': + legendData.area.start.x = opts.width - opts.padding[1] - legendData.area.width; + legendData.area.end.x = opts.width - opts.padding[1]; + break; + } + chartData.legendData = legendData; + return legendData; +} + +function calCategoriesData(categories, opts, config, eachSpacing) { + var result = { + angle: 0, + xAxisHeight: config.xAxisHeight + }; + var categoriesTextLenth = categories.map(function(item) { + return measureText(item,opts.xAxis.fontSize||config.fontSize); + }); + var maxTextLength = Math.max.apply(this, categoriesTextLenth); + + if (opts.xAxis.rotateLabel == true && maxTextLength + 2 * config.xAxisTextPadding > eachSpacing) { + result.angle = 45 * Math.PI / 180; + result.xAxisHeight = 2 * config.xAxisTextPadding + maxTextLength * Math.sin(result.angle); + } + return result; +} + +function getXAxisTextList(series, opts, config) { + var index = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : -1; + var data = dataCombine(series); + var sorted = []; + // remove null from data + data = data.filter(function(item) { + //return item !== null; + if (typeof item === 'object' && item !== null) { + if (item.constructor == Array) { + return item !== null; + } else { + return item.value !== null; + } + } else { + return item !== null; + } + }); + data.map(function(item) { + if (typeof item === 'object') { + if (item.constructor == Array) { + if(opts.type=='candle'){ + item.map(function(subitem) { + sorted.push(subitem); + }) + }else{ + sorted.push(item[0]); + } + } else { + sorted.push(item.value); + } + } else { + sorted.push(item); + } + }) + + var minData = 0; + var maxData = 0; + if (sorted.length > 0) { + minData = Math.min.apply(this, sorted); + maxData = Math.max.apply(this, sorted); + } + //为了兼容v1.9.0之前的项目 + if(index>-1){ + if (typeof opts.xAxis.data[index].min === 'number') { + minData = Math.min(opts.xAxis.data[index].min, minData); + } + if (typeof opts.xAxis.data[index].max === 'number') { + maxData = Math.max(opts.xAxis.data[index].max, maxData); + } + }else{ + if (typeof opts.xAxis.min === 'number') { + minData = Math.min(opts.xAxis.min, minData); + } + if (typeof opts.xAxis.max === 'number') { + maxData = Math.max(opts.xAxis.max, maxData); + } + } + + + if (minData === maxData) { + var rangeSpan = maxData || 10; + maxData += rangeSpan; + } + + //var dataRange = getDataRange(minData, maxData); + var minRange = minData; + var maxRange = maxData; + + var range = []; + var eachRange = (maxRange - minRange) / opts.xAxis.splitNumber; + + for (var i = 0; i <= opts.xAxis.splitNumber; i++) { + range.push(minRange + eachRange * i); + } + return range; +} + +function calXAxisData(series, opts, config){ + var result = { + angle: 0, + xAxisHeight: config.xAxisHeight + }; + + result.ranges = getXAxisTextList(series, opts, config); + result.rangesFormat = result.ranges.map(function(item){ + item = opts.xAxis.format? opts.xAxis.format(item):util.toFixed(item, 2); + return item; + }); + + var xAxisScaleValues = result.ranges.map(function (item) { + // 如果刻度值是浮点数,则保留两位小数 + item = util.toFixed(item, 2); + // 若有自定义格式则调用自定义的格式化函数 + item = opts.xAxis.format ? opts.xAxis.format(Number(item)) : item; + return item; + }); + + result = Object.assign(result,getXAxisPoints(xAxisScaleValues, opts, config)); + // 计算X轴刻度的属性譬如每个刻度的间隔,刻度的起始点\结束点以及总长 + var eachSpacing = result.eachSpacing; + + var textLength = xAxisScaleValues.map(function (item) { + return measureText(item); + }); + + // get max length of categories text + var maxTextLength = Math.max.apply(this, textLength); + + // 如果刻度值文本内容过长,则将其逆时针旋转45° + if (maxTextLength + 2 * config.xAxisTextPadding > eachSpacing) { + result.angle = 45 * Math.PI / 180; + result.xAxisHeight = 2 * config.xAxisTextPadding + maxTextLength * Math.sin(result.angle); + } + + if (opts.xAxis.disabled === true) { + result.xAxisHeight = 0; + } + + return result; +} + +function getRadarDataPoints(angleList, center, radius, series, opts) { + var process = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 1; + + var radarOption = opts.extra.radar || {}; + radarOption.max = radarOption.max || 0; + var maxData = Math.max(radarOption.max, Math.max.apply(null, dataCombine(series))); + + var data = []; + for (let i = 0; i < series.length; i++) { + let each = series[i]; + let listItem = {}; + listItem.color = each.color; + listItem.legendShape = each.legendShape; + listItem.pointShape = each.pointShape; + listItem.data = []; + each.data.forEach(function(item, index) { + let tmp = {}; + tmp.angle = angleList[index]; + + tmp.proportion = item / maxData; + tmp.position = convertCoordinateOrigin(radius * tmp.proportion * process * Math.cos(tmp.angle), radius * tmp.proportion * + process * Math.sin(tmp.angle), center); + listItem.data.push(tmp); + }); + + data.push(listItem); + } + + return data; +} + +function getPieDataPoints(series, radius) { + var process = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; + + var count = 0; + var _start_ = 0; + for (let i = 0; i < series.length; i++) { + let item = series[i]; + item.data = item.data === null ? 0 : item.data; + count += item.data; + } + for (let i = 0; i < series.length; i++) { + let item = series[i]; + item.data = item.data === null ? 0 : item.data; + if (count === 0) { + item._proportion_ = 1 / series.length * process; + } else { + item._proportion_ = item.data / count * process; + } + item._radius_ = radius; + } + for (let i = 0; i < series.length; i++) { + let item = series[i]; + item._start_ = _start_; + _start_ += 2 * item._proportion_ * Math.PI; + } + + return series; +} + +function getFunnelDataPoints(series, radius) { + var process = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; + series = series.sort(function(a,b){return parseInt(b.data)-parseInt(a.data);}); + for (let i = 0; i < series.length; i++) { + series[i].radius = series[i].data/series[0].data*radius*process; + series[i]._proportion_ = series[i].data/series[0].data; + } + return series.reverse(); +} + +function getRoseDataPoints(series, type, minRadius, radius) { + var process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1; + var count = 0; + var _start_ = 0; + + var dataArr = []; + for (let i = 0; i < series.length; i++) { + let item = series[i]; + item.data = item.data === null ? 0 : item.data; + count += item.data; + dataArr.push(item.data); + } + + var minData = Math.min.apply(null, dataArr); + var maxData = Math.max.apply(null, dataArr); + var radiusLength = radius - minRadius; + + for (let i = 0; i < series.length; i++) { + let item = series[i]; + item.data = item.data === null ? 0 : item.data; + if (count === 0 || type == 'area') { + item._proportion_ = item.data / count * process; + item._rose_proportion_ = 1 / series.length * process; + } else { + item._proportion_ = item.data / count * process; + item._rose_proportion_ = item.data / count * process; + } + item._radius_ = minRadius + radiusLength * ((item.data - minData) / (maxData - minData)); + } + for (let i = 0; i < series.length; i++) { + let item = series[i]; + item._start_ = _start_; + _start_ += 2 * item._rose_proportion_ * Math.PI; + } + + return series; +} + +function getArcbarDataPoints(series, arcbarOption) { + var process = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; + if (process == 1) { + process = 0.999999; + } + for (let i = 0; i < series.length; i++) { + let item = series[i]; + item.data = item.data === null ? 0 : item.data; + let totalAngle; + if (arcbarOption.type == 'circle') { + totalAngle = 2; + } else { + if (arcbarOption.endAngle < arcbarOption.startAngle) { + totalAngle = 2 + arcbarOption.endAngle - arcbarOption.startAngle; + } else{ + totalAngle = arcbarOption.startAngle - arcbarOption.endAngle; + } + } + item._proportion_ = totalAngle * item.data * process + arcbarOption.startAngle; + if (item._proportion_ >= 2) { + item._proportion_ = item._proportion_ % 2; + } + } + return series; +} + +function getGaugeAxisPoints(categories, startAngle, endAngle) { + let totalAngle = startAngle - endAngle + 1; + let tempStartAngle = startAngle; + for (let i = 0; i < categories.length; i++) { + categories[i].value = categories[i].value === null ? 0 : categories[i].value; + categories[i]._startAngle_ = tempStartAngle; + categories[i]._endAngle_ = totalAngle * categories[i].value + startAngle; + if (categories[i]._endAngle_ >= 2) { + categories[i]._endAngle_ = categories[i]._endAngle_ % 2; + } + tempStartAngle = categories[i]._endAngle_; + } + return categories; +} + +function getGaugeDataPoints(series, categories, gaugeOption) { + let process = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1; + for (let i = 0; i < series.length; i++) { + let item = series[i]; + item.data = item.data === null ? 0 : item.data; + if (gaugeOption.pointer.color == 'auto') { + for (let i = 0; i < categories.length; i++) { + if (item.data <= categories[i].value) { + item.color = categories[i].color; + break; + } + } + } else { + item.color = gaugeOption.pointer.color; + } + let totalAngle = gaugeOption.startAngle - gaugeOption.endAngle + 1; + item._endAngle_ = totalAngle * item.data + gaugeOption.startAngle; + item._oldAngle_ = gaugeOption.oldAngle; + if (gaugeOption.oldAngle < gaugeOption.endAngle) { + item._oldAngle_ += 2; + } + if (item.data >= gaugeOption.oldData) { + item._proportion_ = (item._endAngle_ - item._oldAngle_) * process + gaugeOption.oldAngle; + } else { + item._proportion_ = item._oldAngle_ - (item._oldAngle_ - item._endAngle_) * process; + } + if (item._proportion_ >= 2) { + item._proportion_ = item._proportion_ % 2; + } + } + return series; +} + +function getPieTextMaxLength(series) { + series = getPieDataPoints(series); + let maxLength = 0; + for (let i = 0; i < series.length; i++) { + let item = series[i]; + let text = item.format ? item.format(+item._proportion_.toFixed(2)) : util.toFixed(item._proportion_ * 100) + '%'; + maxLength = Math.max(maxLength, measureText(text)); + } + + return maxLength; +} + +function fixColumeData(points, eachSpacing, columnLen, index, config, opts) { + return points.map(function(item) { + if (item === null) { + return null; + } + item.width = Math.ceil((eachSpacing - 2 * config.columePadding) / columnLen); + + if (opts.extra.column && opts.extra.column.width && +opts.extra.column.width > 0) { + item.width = Math.min(item.width, +opts.extra.column.width); + } + if (item.width <= 0) { + item.width = 1; + } + item.x += (index + 0.5 - columnLen / 2) * item.width; + return item; + }); +} + +function fixColumeMeterData(points, eachSpacing, columnLen, index, config, opts, border) { + return points.map(function(item) { + if (item === null) { + return null; + } + item.width = Math.ceil((eachSpacing - 2 * config.columePadding) / 2); + + if (opts.extra.column && opts.extra.column.width && +opts.extra.column.width > 0) { + item.width = Math.min(item.width, +opts.extra.column.width); + } + + if (index > 0) { + item.width -= 2 * border; + } + return item; + }); +} + +function fixColumeStackData(points, eachSpacing, columnLen, index, config, opts, series) { + + return points.map(function(item, indexn) { + + if (item === null) { + return null; + } + item.width = Math.ceil((eachSpacing - 2 * config.columePadding) / 2); + + if (opts.extra.column && opts.extra.column.width && +opts.extra.column.width > 0) { + item.width = Math.min(item.width, +opts.extra.column.width); + } + return item; + }); +} + +function getXAxisPoints(categories, opts, config) { + var spacingValid = opts.width - opts.area[1] - opts.area[3]; + var dataCount = opts.enableScroll ? Math.min(opts.xAxis.itemCount, categories.length) : categories.length; + if((opts.type=='line' || opts.type=='area') && dataCount>1 && opts.xAxis.boundaryGap=='justify'){ + dataCount -=1; + } + var eachSpacing = spacingValid / dataCount; + + var xAxisPoints = []; + var startX = opts.area[3]; + var endX = opts.width - opts.area[1]; + categories.forEach(function(item, index) { + xAxisPoints.push(startX + index * eachSpacing); + }); + if(opts.xAxis.boundaryGap !=='justify'){ + if (opts.enableScroll === true) { + xAxisPoints.push(startX + categories.length * eachSpacing); + } else { + xAxisPoints.push(endX); + } + } + return { + xAxisPoints: xAxisPoints, + startX: startX, + endX: endX, + eachSpacing: eachSpacing + }; +} + +function getCandleDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config) { + var process = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 1; + var points = []; + var validHeight = opts.height - opts.area[0] - opts.area[2]; + data.forEach(function(item, index) { + if (item === null) { + points.push(null); + } else { + var cPoints = []; + item.forEach(function(items, indexs) { + var point = {}; + point.x = xAxisPoints[index] + Math.round(eachSpacing / 2); + var value = items.value || items; + var height = validHeight * (value - minRange) / (maxRange - minRange); + height *= process; + point.y = opts.height - Math.round(height) - opts.area[2]; + cPoints.push(point); + }); + points.push(cPoints); + } + }); + + return points; +} + +function getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config) { + var process = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 1; + var boundaryGap='center'; + if (opts.type == 'line'||opts.type == 'area'){ + boundaryGap=opts.xAxis.boundaryGap; + } + var points = []; + var validHeight = opts.height - opts.area[0] - opts.area[2]; + var validWidth = opts.width - opts.area[1] - opts.area[3]; + data.forEach(function(item, index) { + if (item === null) { + points.push(null); + } else { + var point = {}; + point.color = item.color; + point.x = xAxisPoints[index]; + var value = item; + if (typeof item === 'object' && item !== null) { + if (item.constructor == Array) { + let xranges,xminRange,xmaxRange; + xranges = [].concat(opts.chartData.xAxisData.ranges); + xminRange = xranges.shift(); + xmaxRange = xranges.pop(); + value = item[1]; + point.x = opts.area[3]+ validWidth * (item[0] - xminRange) / (xmaxRange - xminRange); + } else { + value = item.value; + } + } + if(boundaryGap=='center'){ + point.x += Math.round(eachSpacing / 2); + } + var height = validHeight * (value - minRange) / (maxRange - minRange); + height *= process; + point.y = opts.height - Math.round(height) - opts.area[2]; + points.push(point); + } + }); + + return points; +} + +function getStackDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, seriesIndex, stackSeries) { + var process = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : 1; + var points = []; + var validHeight = opts.height - opts.area[0] - opts.area[2]; + + data.forEach(function(item, index) { + if (item === null) { + points.push(null); + } else { + var point = {}; + point.color = item.color; + point.x = xAxisPoints[index] + Math.round(eachSpacing / 2); + + if (seriesIndex > 0) { + var value = 0; + for (let i = 0; i <= seriesIndex; i++) { + value += stackSeries[i].data[index]; + } + var value0 = value - item; + var height = validHeight * (value - minRange) / (maxRange - minRange); + var height0 = validHeight * (value0 - minRange) / (maxRange - minRange); + } else { + var value = item; + var height = validHeight * (value - minRange) / (maxRange - minRange); + var height0 = 0; + } + var heightc = height0; + height *= process; + heightc *= process; + point.y = opts.height - Math.round(height) - opts.area[2]; + point.y0 = opts.height - Math.round(heightc) - opts.area[2]; + points.push(point); + } + }); + + return points; +} + +function getYAxisTextList(series, opts, config, stack) { + var index = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : -1; + var data; + if (stack == 'stack') { + data = dataCombineStack(series, opts.categories.length); + } else { + data = dataCombine(series); + } + var sorted = []; + // remove null from data + data = data.filter(function(item) { + //return item !== null; + if (typeof item === 'object' && item !== null) { + if (item.constructor == Array) { + return item !== null; + } else { + return item.value !== null; + } + } else { + return item !== null; + } + }); + data.map(function(item) { + if (typeof item === 'object') { + if (item.constructor == Array) { + if(opts.type=='candle'){ + item.map(function(subitem) { + sorted.push(subitem); + }) + }else{ + sorted.push(item[1]); + } + } else { + sorted.push(item.value); + } + } else { + sorted.push(item); + } + }) + + var minData = 0; + var maxData = 0; + if (sorted.length > 0) { + minData = Math.min.apply(this, sorted); + maxData = Math.max.apply(this, sorted); + } + //为了兼容v1.9.0之前的项目 + if(index>-1){ + if (typeof opts.yAxis.data[index].min === 'number') { + minData = Math.min(opts.yAxis.data[index].min, minData); + } + if (typeof opts.yAxis.data[index].max === 'number') { + maxData = Math.max(opts.yAxis.data[index].max, maxData); + } + }else{ + if (typeof opts.yAxis.min === 'number') { + minData = Math.min(opts.yAxis.min, minData); + } + if (typeof opts.yAxis.max === 'number') { + maxData = Math.max(opts.yAxis.max, maxData); + } + } + + + if (minData === maxData) { + var rangeSpan = maxData || 10; + maxData += rangeSpan; + } + + var dataRange = getDataRange(minData, maxData); + var minRange = dataRange.minRange; + var maxRange = dataRange.maxRange; + + var range = []; + var eachRange = (maxRange - minRange) / opts.yAxis.splitNumber; + + for (var i = 0; i <= opts.yAxis.splitNumber; i++) { + range.push(minRange + eachRange * i); + } + return range.reverse(); +} + +function calYAxisData(series, opts, config) { + //堆叠图重算Y轴 + var columnstyle = assign({}, { + type: "" + }, opts.extra.column); + //如果是多Y轴,重新计算 + var YLength = opts.yAxis.data.length; + var newSeries=new Array(YLength); + if(YLength>0){ + for(let i=0;i= 2) { + nowAngle = nowAngle % 2; + } + nowNumber += splitNumber; + } + +} + +function drawRadarLabel(angleList, radius, centerPosition, opts, config, context) { + var radarOption = opts.extra.radar || {}; + radius += config.radarLabelTextMargin; + + angleList.forEach(function(angle, index) { + var pos = { + x: radius * Math.cos(angle), + y: radius * Math.sin(angle) + }; + var posRelativeCanvas = convertCoordinateOrigin(pos.x, pos.y, centerPosition); + var startX = posRelativeCanvas.x; + var startY = posRelativeCanvas.y; + if (util.approximatelyEqual(pos.x, 0)) { + startX -= measureText(opts.categories[index] || '') / 2; + } else if (pos.x < 0) { + startX -= measureText(opts.categories[index] || ''); + } + context.beginPath(); + context.setFontSize(config.fontSize); + context.setFillStyle(radarOption.labelColor || '#666666'); + context.fillText(opts.categories[index] || '', startX, startY + config.fontSize / 2); + context.closePath(); + context.stroke(); + }); + +} + +function drawPieText(series, opts, config, context, radius, center) { + var lineRadius = config.pieChartLinePadding; + var textObjectCollection = []; + var lastTextObject = null; + + var seriesConvert = series.map(function(item) { + var text = item.format ? item.format(+item._proportion_.toFixed(2)) : util.toFixed(item._proportion_.toFixed(4) * 100) +'%'; + if(item._rose_proportion_) item._proportion_=item._rose_proportion_; + var arc = 2 * Math.PI - (item._start_ + 2 * Math.PI * item._proportion_ / 2); + var color = item.color; + var radius = item._radius_; + return { + arc: arc, + text: text, + color: color, + radius: radius, + textColor: item.textColor, + textSize: item.textSize, + }; + }); + for (let i = 0; i < seriesConvert.length; i++) { + let item = seriesConvert[i]; + // line end + let orginX1 = Math.cos(item.arc) * (item.radius + lineRadius); + let orginY1 = Math.sin(item.arc) * (item.radius + lineRadius); + + // line start + let orginX2 = Math.cos(item.arc) * item.radius; + let orginY2 = Math.sin(item.arc) * item.radius; + + // text start + let orginX3 = orginX1 >= 0 ? orginX1 + config.pieChartTextPadding : orginX1 - config.pieChartTextPadding; + let orginY3 = orginY1; + let textWidth = measureText(item.text,item.textSize||config.fontSize); + let startY = orginY3; + + if (lastTextObject && util.isSameXCoordinateArea(lastTextObject.start, { + x: orginX3 + })) { + if (orginX3 > 0) { + startY = Math.min(orginY3, lastTextObject.start.y); + } else if (orginX1 < 0) { + startY = Math.max(orginY3, lastTextObject.start.y); + } else { + if (orginY3 > 0) { + startY = Math.max(orginY3, lastTextObject.start.y); + } else { + startY = Math.min(orginY3, lastTextObject.start.y); + } + } + } + if (orginX3 < 0) { + orginX3 -= textWidth; + } + + let textObject = { + lineStart: { + x: orginX2, + y: orginY2 + }, + lineEnd: { + x: orginX1, + y: orginY1 + }, + start: { + x: orginX3, + y: startY + }, + width: textWidth, + height: config.fontSize, + text: item.text, + color: item.color, + textColor: item.textColor, + textSize: item.textSize + }; + lastTextObject = avoidCollision(textObject, lastTextObject); + textObjectCollection.push(lastTextObject); + } + + for (let i = 0; i < textObjectCollection.length; i++) { + let item = textObjectCollection[i]; + let lineStartPoistion = convertCoordinateOrigin(item.lineStart.x, item.lineStart.y, center); + let lineEndPoistion = convertCoordinateOrigin(item.lineEnd.x, item.lineEnd.y, center); + let textPosition = convertCoordinateOrigin(item.start.x, item.start.y, center); + context.setLineWidth(1 * opts.pixelRatio); + context.setFontSize(config.fontSize); + context.beginPath(); + context.setStrokeStyle(item.color); + context.setFillStyle(item.color); + context.moveTo(lineStartPoistion.x, lineStartPoistion.y); + let curveStartX = item.start.x < 0 ? textPosition.x + item.width : textPosition.x; + let textStartX = item.start.x < 0 ? textPosition.x - 5 : textPosition.x + 5; + context.quadraticCurveTo(lineEndPoistion.x, lineEndPoistion.y, curveStartX, textPosition.y); + context.moveTo(lineStartPoistion.x, lineStartPoistion.y); + context.stroke(); + context.closePath(); + context.beginPath(); + context.moveTo(textPosition.x + item.width, textPosition.y); + context.arc(curveStartX, textPosition.y, 2, 0, 2 * Math.PI); + context.closePath(); + context.fill(); + context.beginPath(); + context.setFontSize(item.textSize || config.fontSize); + context.setFillStyle(item.textColor || '#666666'); + context.fillText(item.text, textStartX, textPosition.y + 3); + context.closePath(); + context.stroke(); + context.closePath(); + } +} + +function drawToolTipSplitLine(offsetX, opts, config, context) { + var toolTipOption = opts.extra.tooltip || {}; + toolTipOption.gridType = toolTipOption.gridType == undefined ? 'solid' : toolTipOption.gridType; + toolTipOption.dashLength = toolTipOption.dashLength == undefined ? 4 : toolTipOption.dashLength; + var startY = opts.area[0]; + var endY = opts.height - opts.area[2]; + + if (toolTipOption.gridType == 'dash') { + context.setLineDash([toolTipOption.dashLength, toolTipOption.dashLength]); + } + context.setStrokeStyle(toolTipOption.gridColor || '#cccccc'); + context.setLineWidth(1 * opts.pixelRatio); + context.beginPath(); + context.moveTo(offsetX, startY); + context.lineTo(offsetX, endY); + context.stroke(); + context.setLineDash([]); + + if (toolTipOption.xAxisLabel) { + let labelText = opts.categories[opts.tooltip.index]; + context.setFontSize(config.fontSize); + let textWidth = measureText(labelText, config.fontSize); + + let textX = offsetX - 0.5 * textWidth; + let textY = endY; + context.beginPath(); + context.setFillStyle(hexToRgb(toolTipOption.labelBgColor || config.toolTipBackground, toolTipOption.labelBgOpacity || config.toolTipOpacity)); + context.setStrokeStyle(toolTipOption.labelBgColor || config.toolTipBackground); + context.setLineWidth(1 * opts.pixelRatio); + context.rect(textX - config.toolTipPadding, textY, textWidth + 2 * config.toolTipPadding, config.fontSize + 2 * config.toolTipPadding); + context.closePath(); + context.stroke(); + context.fill(); + + context.beginPath(); + context.setFontSize(config.fontSize); + context.setFillStyle(toolTipOption.labelFontColor || config.fontColor); + context.fillText(String(labelText), textX, textY + config.toolTipPadding + config.fontSize); + context.closePath(); + context.stroke(); + } +} + +function drawMarkLine(opts, config, context) { + let markLineOption = assign({}, { + type: 'solid', + dashLength: 4, + data: [] + }, opts.extra.markLine); + let startX = opts.area[3]; + let endX = opts.width - opts.area[1]; + let points = calMarkLineData(markLineOption.data, opts); + + for (let i = 0; i < points.length; i++) { + let item = assign({}, { + lineColor: '#DE4A42', + showLabel: false, + labelFontColor: '#666666', + labelBgColor: '#DFE8FF', + labelBgOpacity: 0.8, + yAxisIndex: 0 + }, points[i]); + + if (markLineOption.type == 'dash') { + context.setLineDash([markLineOption.dashLength, markLineOption.dashLength]); + } + context.setStrokeStyle(item.lineColor); + context.setLineWidth(1 * opts.pixelRatio); + context.beginPath(); + context.moveTo(startX, item.y); + context.lineTo(endX, item.y); + context.stroke(); + context.setLineDash([]); + if (item.showLabel) { + let labelText = opts.yAxis.format ? opts.yAxis.format(Number(item.value)) : item.value; + context.setFontSize(config.fontSize); + let textWidth = measureText(labelText, config.fontSize); + let bgStartX = opts.padding[3] + config.yAxisTitleWidth - config.toolTipPadding; + let bgEndX = Math.max(opts.area[3], textWidth + config.toolTipPadding * 2); + let bgWidth = bgEndX - bgStartX; + + let textX = bgStartX + (bgWidth - textWidth) / 2; + let textY = item.y; + context.setFillStyle(hexToRgb(item.labelBgColor, item.labelBgOpacity)); + context.setStrokeStyle(item.labelBgColor); + context.setLineWidth(1 * opts.pixelRatio); + context.beginPath(); + context.rect(bgStartX, textY - 0.5 * config.fontSize - config.toolTipPadding, bgWidth, config.fontSize + 2 * config.toolTipPadding); + context.closePath(); + context.stroke(); + context.fill(); + + context.beginPath(); + context.setFontSize(config.fontSize); + context.setFillStyle(item.labelFontColor); + context.fillText(String(labelText), textX, textY + 0.5 * config.fontSize); + context.stroke(); + } + } +} + +function drawToolTipHorizentalLine(opts, config, context, eachSpacing, xAxisPoints) { + var toolTipOption = assign({}, { + gridType: 'solid', + dashLength: 4 + }, opts.extra.tooltip); + + var startX = opts.area[3]; + var endX = opts.width - opts.area[1]; + + if (toolTipOption.gridType == 'dash') { + context.setLineDash([toolTipOption.dashLength, toolTipOption.dashLength]); + } + context.setStrokeStyle(toolTipOption.gridColor || '#cccccc'); + context.setLineWidth(1 * opts.pixelRatio); + context.beginPath(); + context.moveTo(startX, opts.tooltip.offset.y); + context.lineTo(endX, opts.tooltip.offset.y); + context.stroke(); + context.setLineDash([]); + + if (toolTipOption.yAxisLabel) { + let labelText = calTooltipYAxisData(opts.tooltip.offset.y, opts.series, opts, config, eachSpacing); + let widthArr = opts.chartData.yAxisData.yAxisWidth; + let tStartLeft=opts.area[3]; + let tStartRight=opts.width-opts.area[1]; + for(let i=0;i opts.width) { + isOverRightBorder = true; + } + if (toolTipHeight + offset.y > opts.height) { + offset.y = opts.height - toolTipHeight; + } + // draw background rect + context.beginPath(); + context.setFillStyle(hexToRgb(toolTipOption.bgColor || config.toolTipBackground, toolTipOption.bgOpacity || config.toolTipOpacity)); + if (isOverRightBorder) { + context.moveTo(offset.x, offset.y + 10 * opts.pixelRatio); + context.lineTo(offset.x - arrowWidth, offset.y + 10 * opts.pixelRatio - 5 * opts.pixelRatio); + context.lineTo(offset.x - arrowWidth, offset.y); + context.lineTo(offset.x - arrowWidth - Math.round(toolTipWidth), offset.y); + context.lineTo(offset.x - arrowWidth - Math.round(toolTipWidth), offset.y + toolTipHeight); + context.lineTo(offset.x - arrowWidth, offset.y + toolTipHeight); + context.lineTo(offset.x - arrowWidth, offset.y + 10 * opts.pixelRatio + 5 * opts.pixelRatio); + context.lineTo(offset.x, offset.y + 10 * opts.pixelRatio); + } else { + context.moveTo(offset.x, offset.y + 10 * opts.pixelRatio); + context.lineTo(offset.x + arrowWidth, offset.y + 10 * opts.pixelRatio - 5 * opts.pixelRatio); + context.lineTo(offset.x + arrowWidth, offset.y); + context.lineTo(offset.x + arrowWidth + Math.round(toolTipWidth), offset.y); + context.lineTo(offset.x + arrowWidth + Math.round(toolTipWidth), offset.y + toolTipHeight); + context.lineTo(offset.x + arrowWidth, offset.y + toolTipHeight); + context.lineTo(offset.x + arrowWidth, offset.y + 10 * opts.pixelRatio + 5 * opts.pixelRatio); + context.lineTo(offset.x, offset.y + 10 * opts.pixelRatio); + } + + context.closePath(); + context.fill(); + + // draw legend + textList.forEach(function(item, index) { + if (item.color !== null) { + context.beginPath(); + context.setFillStyle(item.color); + var startX = offset.x + arrowWidth + 2 * config.toolTipPadding; + var startY = offset.y + (config.toolTipLineHeight - config.fontSize) / 2 + config.toolTipLineHeight * index + + config.toolTipPadding + 1; + if (isOverRightBorder) { + startX = offset.x - toolTipWidth - arrowWidth + 2 * config.toolTipPadding; + } + context.fillRect(startX, startY, legendWidth, config.fontSize); + context.closePath(); + } + }); + + // draw text list + + textList.forEach(function(item, index) { + var startX = offset.x + arrowWidth + 2 * config.toolTipPadding + legendWidth + legendMarginRight; + if (isOverRightBorder) { + startX = offset.x - toolTipWidth - arrowWidth + 2 * config.toolTipPadding + +legendWidth + legendMarginRight; + } + var startY = offset.y + (config.toolTipLineHeight - config.fontSize) / 2 + config.toolTipLineHeight * index + + config.toolTipPadding; + context.beginPath(); + context.setFontSize(config.fontSize); + context.setFillStyle(toolTipOption.fontColor); + context.fillText(item.text, startX, startY + config.fontSize); + context.closePath(); + context.stroke(); + }); +} + +function drawYAxisTitle(title, opts, config, context) { + var startX = config.xAxisHeight + (opts.height - config.xAxisHeight - measureText(title)) / 2; + context.save(); + context.beginPath(); + context.setFontSize(config.fontSize); + context.setFillStyle(opts.yAxis.titleFontColor || '#333333'); + context.translate(0, opts.height); + context.rotate(-90 * Math.PI / 180); + context.fillText(title, startX, opts.padding[3] + 0.5 * config.fontSize); + context.closePath(); + context.stroke(); + context.restore(); +} + +function drawColumnDataPoints(series, opts, config, context) { + let process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1; + let xAxisData = opts.chartData.xAxisData, + xAxisPoints = xAxisData.xAxisPoints, + eachSpacing = xAxisData.eachSpacing; + let columnOption = assign({}, { + type: 'group', + width: eachSpacing / 2, + meter: { + border: 4, + fillColor: '#FFFFFF' + } + }, opts.extra.column); + + let calPoints = []; + context.save(); + + let leftNum=-2; + let rightNum=xAxisPoints.length+2; + + if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) { + context.translate(opts._scrollDistance_, 0); + leftNum=Math.floor(-opts._scrollDistance_/eachSpacing)-2; + rightNum=leftNum+opts.xAxis.itemCount+4; + } + if (opts.tooltip && opts.tooltip.textList && opts.tooltip.textList.length && process === 1) { + drawToolTipSplitArea(opts.tooltip.offset.x, opts, config, context, eachSpacing); + } + + series.forEach(function(eachSeries, seriesIndex) { + let ranges,minRange,maxRange; + ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]); + minRange = ranges.pop(); + maxRange = ranges.shift(); + + var data = eachSeries.data; + switch (columnOption.type) { + case 'group': + var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process); + var tooltipPoints = getStackDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, seriesIndex, series, process); + calPoints.push(tooltipPoints); + points = fixColumeData(points, eachSpacing, series.length, seriesIndex, config, opts); + for(let i=0;ileftNum && ileftNum && i 0) { + height -= height0; + } + context.moveTo(startX, item.y); + context.fillRect(startX, item.y, item.width - 2, height); + context.closePath(); + context.fill(); + } + }; + break; + case 'meter': + // 绘制温度计数据图 + var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process); + calPoints.push(points); + points = fixColumeMeterData(points, eachSpacing, series.length, seriesIndex, config, opts, columnOption.meter.border); + if (seriesIndex == 0) { + for(let i=0;ileftNum && i 0) { + context.beginPath(); + context.setStrokeStyle(eachSeries.color); + context.setLineWidth(columnOption.meter.border * opts.pixelRatio); + context.moveTo(startX + columnOption.meter.border * 0.5, item.y + height); + context.lineTo(startX + columnOption.meter.border * 0.5, item.y + columnOption.meter.border * 0.5); + context.lineTo(startX + item.width - columnOption.meter.border * 0.5, item.y + columnOption.meter.border * 0.5); + context.lineTo(startX + item.width - columnOption.meter.border * 0.5, item.y + height); + context.stroke(); + } + } + }; + } else { + for(let i=0;ileftNum && i 5 && arguments[5] !== undefined ? arguments[5] : 1; + var candleOption = assign({}, { + color: {}, + average: {} + }, opts.extra.candle); + candleOption.color = assign({}, { + upLine: '#f04864', + upFill: '#f04864', + downLine: '#2fc25b', + downFill: '#2fc25b' + }, candleOption.color); + candleOption.average = assign({}, { + show: false, + name: [], + day: [], + color: config.colors + }, candleOption.average); + opts.extra.candle = candleOption; + + let xAxisData = opts.chartData.xAxisData, + xAxisPoints = xAxisData.xAxisPoints, + eachSpacing = xAxisData.eachSpacing; + + let calPoints = []; + + context.save(); + + let leftNum=-2; + let rightNum=xAxisPoints.length+2; + let leftSpace=0; + let rightSpace=opts.width+eachSpacing; + + if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) { + context.translate(opts._scrollDistance_, 0); + leftNum=Math.floor(-opts._scrollDistance_/eachSpacing)-2; + rightNum=leftNum+opts.xAxis.itemCount+4; + leftSpace=-opts._scrollDistance_-eachSpacing+opts.area[3]; + rightSpace=leftSpace+(opts.xAxis.itemCount+4)*eachSpacing; + } + + //画均线 + if (candleOption.average.show) { + seriesMA.forEach(function(eachSeries, seriesIndex) { + let ranges,minRange,maxRange; + ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]); + minRange = ranges.pop(); + maxRange = ranges.shift(); + + var data = eachSeries.data; + var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process); + var splitPointList = splitPoints(points); + + for(let i=0;i leftSpace){ + context.moveTo(item.x, item.y); + startPoint=1; + } + if (j > 0 && item.x > leftSpace && item.x < rightSpace) { + var ctrlPoint = createCurveControlPoints(points, j - 1); + context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y,item.x, item.y); + } + } + context.moveTo(points[0].x, points[0].y); + } + context.closePath(); + context.stroke(); + } + }); + } + //画K线 + series.forEach(function(eachSeries, seriesIndex) { + let ranges,minRange,maxRange; + ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]); + minRange = ranges.pop(); + maxRange = ranges.shift(); + var data = eachSeries.data; + var points = getCandleDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process); + calPoints.push(points); + var splitPointList = splitPoints(points); + + for(let i=0;ileftNum && i 0) { + context.setStrokeStyle(candleOption.color.upLine); + context.setFillStyle(candleOption.color.upFill); + context.setLineWidth(1 * opts.pixelRatio); + context.moveTo(item[3].x, item[3].y); //顶点 + context.lineTo(item[1].x, item[1].y); //收盘中间点 + context.lineTo(item[1].x - eachSpacing / 4, item[1].y); //收盘左侧点 + context.lineTo(item[0].x - eachSpacing / 4, item[0].y); //开盘左侧点 + context.lineTo(item[0].x, item[0].y); //开盘中间点 + context.lineTo(item[2].x, item[2].y); //底点 + context.lineTo(item[0].x, item[0].y); //开盘中间点 + context.lineTo(item[0].x + eachSpacing / 4, item[0].y); //开盘右侧点 + context.lineTo(item[1].x + eachSpacing / 4, item[1].y); //收盘右侧点 + context.lineTo(item[1].x, item[1].y); //收盘中间点 + context.moveTo(item[3].x, item[3].y); //顶点 + } else { + context.setStrokeStyle(candleOption.color.downLine); + context.setFillStyle(candleOption.color.downFill); + context.setLineWidth(1 * opts.pixelRatio); + context.moveTo(item[3].x, item[3].y); //顶点 + context.lineTo(item[0].x, item[0].y); //开盘中间点 + context.lineTo(item[0].x - eachSpacing / 4, item[0].y); //开盘左侧点 + context.lineTo(item[1].x - eachSpacing / 4, item[1].y); //收盘左侧点 + context.lineTo(item[1].x, item[1].y); //收盘中间点 + context.lineTo(item[2].x, item[2].y); //底点 + context.lineTo(item[1].x, item[1].y); //收盘中间点 + context.lineTo(item[1].x + eachSpacing / 4, item[1].y); //收盘右侧点 + context.lineTo(item[0].x + eachSpacing / 4, item[0].y); //开盘右侧点 + context.lineTo(item[0].x, item[0].y); //开盘中间点 + context.moveTo(item[3].x, item[3].y); //顶点 + } + context.closePath(); + context.fill(); + context.stroke(); + } + } + }); + + context.restore(); + + return { + xAxisPoints: xAxisPoints, + calPoints: calPoints, + eachSpacing: eachSpacing + }; +} + +function drawAreaDataPoints(series, opts, config, context) { + var process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1; + var areaOption = assign({},{ + type: 'straight', + opacity: 0.2, + addLine: false, + width: 2, + gradient:false + },opts.extra.area); + + let xAxisData = opts.chartData.xAxisData, + xAxisPoints = xAxisData.xAxisPoints, + eachSpacing = xAxisData.eachSpacing; + + let endY = opts.height - opts.area[2]; + let calPoints = []; + + context.save(); + let leftSpace=0; + let rightSpace=opts.width+eachSpacing; + if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) { + context.translate(opts._scrollDistance_, 0); + leftSpace=-opts._scrollDistance_-eachSpacing+opts.area[3]; + rightSpace=leftSpace+(opts.xAxis.itemCount+4)*eachSpacing; + } + + series.forEach(function(eachSeries, seriesIndex) { + let ranges,minRange,maxRange; + ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]); + minRange = ranges.pop(); + maxRange = ranges.shift(); + let data = eachSeries.data; + let points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process); + calPoints.push(points); + + let splitPointList = splitPoints(points); + for (let i = 0; i < splitPointList.length; i++) { + let points = splitPointList[i]; + // 绘制区域数 + context.beginPath(); + context.setStrokeStyle(hexToRgb(eachSeries.color, areaOption.opacity)); + if(areaOption.gradient){ + let gradient = context.createLinearGradient(0, opts.area[0], 0, opts.height-opts.area[2]); + gradient.addColorStop('0', hexToRgb(eachSeries.color, areaOption.opacity)); + gradient.addColorStop('1.0',hexToRgb("#FFFFFF", 0.1)); + context.setFillStyle(gradient); + }else{ + context.setFillStyle(hexToRgb(eachSeries.color, areaOption.opacity)); + } + context.setLineWidth(areaOption.width * opts.pixelRatio); + if (points.length > 1) { + let firstPoint = points[0]; + let lastPoint = points[points.length - 1]; + context.moveTo(firstPoint.x, firstPoint.y); + let startPoint=0; + if (areaOption.type === 'curve') { + for(let j=0;j leftSpace){ + context.moveTo(item.x, item.y); + startPoint=1; + } + if (j > 0 && item.x > leftSpace && item.x < rightSpace) { + let ctrlPoint = createCurveControlPoints(points, j - 1); + context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y,item.x, item.y); + } + }; + } else { + for(let j=0;j leftSpace){ + context.moveTo(item.x, item.y); + startPoint=1; + } + if (j > 0 && item.x > leftSpace && item.x < rightSpace) { + context.lineTo(item.x, item.y); + } + }; + } + + context.lineTo(lastPoint.x, endY); + context.lineTo(firstPoint.x, endY); + context.lineTo(firstPoint.x, firstPoint.y); + } else { + let item = points[0]; + context.moveTo(item.x - eachSpacing / 2, item.y); + context.lineTo(item.x + eachSpacing / 2, item.y); + context.lineTo(item.x + eachSpacing / 2, endY); + context.lineTo(item.x - eachSpacing / 2, endY); + context.moveTo(item.x - eachSpacing / 2, item.y); + } + context.closePath(); + context.fill(); + + //画连线 + if (areaOption.addLine) { + if (eachSeries.lineType == 'dash') { + let dashLength = eachSeries.dashLength?eachSeries.dashLength:8; + dashLength *= opts.pixelRatio; + context.setLineDash([dashLength, dashLength]); + } + context.beginPath(); + context.setStrokeStyle(eachSeries.color); + context.setLineWidth(areaOption.width * opts.pixelRatio); + if (points.length === 1) { + context.moveTo(points[0].x, points[0].y); + context.arc(points[0].x, points[0].y, 1, 0, 2 * Math.PI); + } else { + context.moveTo(points[0].x, points[0].y); + let startPoint=0; + if (areaOption.type === 'curve') { + for(let j=0;j leftSpace){ + context.moveTo(item.x, item.y); + startPoint=1; + } + if (j > 0 && item.x > leftSpace && item.x < rightSpace) { + let ctrlPoint = createCurveControlPoints(points, j - 1); + context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y,item.x,item.y); + } + }; + } else { + for(let j=0;j leftSpace){ + context.moveTo(item.x, item.y); + startPoint=1; + } + if (j > 0 && item.x > leftSpace && item.x < rightSpace) { + context.lineTo(item.x, item.y); + } + }; + } + context.moveTo(points[0].x, points[0].y); + } + context.stroke(); + context.setLineDash([]); + } + } + + //画点 + if (opts.dataPointShape !== false) { + drawPointShape(points, eachSeries.color, eachSeries.pointShape, context, opts); + } + + }); + + if (opts.dataLabel !== false && process === 1) { + series.forEach(function(eachSeries, seriesIndex) { + let ranges,minRange,maxRange; + ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]); + minRange = ranges.pop(); + maxRange = ranges.shift(); + var data = eachSeries.data; + var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process); + drawPointText(points, eachSeries, config, context); + }); + } + + context.restore(); + + return { + xAxisPoints: xAxisPoints, + calPoints: calPoints, + eachSpacing: eachSpacing + }; +} + +function drawLineDataPoints(series, opts, config, context) { + var process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1; + var lineOption = assign({},{ + type: 'straight', + width: 2 + },opts.extra.line); + lineOption.width *=opts.pixelRatio; + + let xAxisData = opts.chartData.xAxisData, + xAxisPoints = xAxisData.xAxisPoints, + eachSpacing = xAxisData.eachSpacing; + var calPoints = []; + + context.save(); + let leftSpace=0; + let rightSpace=opts.width+eachSpacing; + if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) { + context.translate(opts._scrollDistance_, 0); + leftSpace=-opts._scrollDistance_-eachSpacing+opts.area[3]; + rightSpace=leftSpace+(opts.xAxis.itemCount+4)*eachSpacing; + } + + series.forEach(function(eachSeries, seriesIndex) { + let ranges,minRange,maxRange; + ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]); + minRange = ranges.pop(); + maxRange = ranges.shift(); + var data = eachSeries.data; + var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process); + calPoints.push(points); + var splitPointList = splitPoints(points); + + if (eachSeries.lineType == 'dash') { + let dashLength = eachSeries.dashLength?eachSeries.dashLength:8; + dashLength *= opts.pixelRatio; + context.setLineDash([dashLength, dashLength]); + } + context.beginPath(); + context.setStrokeStyle(eachSeries.color); + context.setLineWidth(lineOption.width); + + splitPointList.forEach(function(points, index) { + + if (points.length === 1) { + context.moveTo(points[0].x, points[0].y); + context.arc(points[0].x, points[0].y, 1, 0, 2 * Math.PI); + } else { + context.moveTo(points[0].x, points[0].y); + let startPoint=0; + if (lineOption.type === 'curve') { + for(let j=0;j leftSpace){ + context.moveTo(item.x, item.y); + startPoint=1; + } + if (j > 0 && item.x > leftSpace && item.x < rightSpace) { + var ctrlPoint = createCurveControlPoints(points, j - 1); + context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y,item.x, item.y); + } + }; + } else { + for(let j=0;j leftSpace){ + context.moveTo(item.x, item.y); + startPoint=1; + } + if (j > 0 && item.x > leftSpace && item.x < rightSpace) { + context.lineTo(item.x, item.y); + } + }; + } + context.moveTo(points[0].x, points[0].y); + } + + }); + + context.stroke(); + context.setLineDash([]); + + if (opts.dataPointShape !== false) { + drawPointShape(points, eachSeries.color, eachSeries.pointShape, context, opts); + } + }); + + if (opts.dataLabel !== false && process === 1) { + series.forEach(function(eachSeries, seriesIndex) { + let ranges,minRange,maxRange; + ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]); + minRange = ranges.pop(); + maxRange = ranges.shift(); + var data = eachSeries.data; + var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process); + drawPointText(points, eachSeries, config, context); + }); + } + + context.restore(); + + return { + xAxisPoints: xAxisPoints, + calPoints: calPoints, + eachSpacing: eachSpacing + }; +} + +function drawMixDataPoints(series, opts, config, context) { + let process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1; + + let xAxisData = opts.chartData.xAxisData, + xAxisPoints = xAxisData.xAxisPoints, + eachSpacing = xAxisData.eachSpacing; + + let endY = opts.height - opts.area[2]; + let calPoints = []; + + var columnIndex = 0; + var columnLength = 0; + series.forEach(function(eachSeries, seriesIndex) { + if (eachSeries.type == 'column') { + columnLength += 1; + } + }); + context.save(); + let leftNum=-2; + let rightNum=xAxisPoints.length+2; + let leftSpace=0; + let rightSpace=opts.width+eachSpacing; + if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) { + context.translate(opts._scrollDistance_, 0); + leftNum=Math.floor(-opts._scrollDistance_/eachSpacing)-2; + rightNum=leftNum+opts.xAxis.itemCount+4; + leftSpace=-opts._scrollDistance_-eachSpacing+opts.area[3]; + rightSpace=leftSpace+(opts.xAxis.itemCount+4)*eachSpacing; + } + + series.forEach(function(eachSeries, seriesIndex) { + let ranges,minRange,maxRange; + + ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]); + minRange = ranges.pop(); + maxRange = ranges.shift(); + + var data = eachSeries.data; + var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process); + calPoints.push(points); + + // 绘制柱状数据图 + if (eachSeries.type == 'column') { + points = fixColumeData(points, eachSpacing, columnLength, columnIndex, config, opts); + for(let i=0;ileftNum && i 1) { + var firstPoint = points[0]; + let lastPoint = points[points.length - 1]; + context.moveTo(firstPoint.x, firstPoint.y); + let startPoint=0; + if (eachSeries.style === 'curve') { + for(let j=0;j leftSpace){ + context.moveTo(item.x, item.y); + startPoint=1; + } + if (j > 0 && item.x > leftSpace && item.x < rightSpace) { + var ctrlPoint = createCurveControlPoints(points, j - 1); + context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y, item.x, item.y); + } + }; + } else { + for(let j=0;j leftSpace){ + context.moveTo(item.x, item.y); + startPoint=1; + } + if (j > 0 && item.x > leftSpace && item.x < rightSpace) { + context.lineTo(item.x, item.y); + } + }; + } + context.lineTo(lastPoint.x, endY); + context.lineTo(firstPoint.x, endY); + context.lineTo(firstPoint.x, firstPoint.y); + } else { + let item = points[0]; + context.moveTo(item.x - eachSpacing / 2, item.y); + context.lineTo(item.x + eachSpacing / 2, item.y); + context.lineTo(item.x + eachSpacing / 2, endY); + context.lineTo(item.x - eachSpacing / 2, endY); + context.moveTo(item.x - eachSpacing / 2, item.y); + } + context.closePath(); + context.fill(); + } + } + + // 绘制折线数据图 + if (eachSeries.type == 'line') { + var splitPointList = splitPoints(points); + splitPointList.forEach(function(points, index) { + if (eachSeries.lineType == 'dash') { + let dashLength = eachSeries.dashLength?eachSeries.dashLength:8; + dashLength *= opts.pixelRatio; + context.setLineDash([dashLength, dashLength]); + } + context.beginPath(); + context.setStrokeStyle(eachSeries.color); + context.setLineWidth(2 * opts.pixelRatio); + if (points.length === 1) { + context.moveTo(points[0].x, points[0].y); + context.arc(points[0].x, points[0].y, 1, 0, 2 * Math.PI); + } else { + context.moveTo(points[0].x, points[0].y); + let startPoint=0; + if (eachSeries.style == 'curve') { + for(let j=0;j leftSpace){ + context.moveTo(item.x, item.y); + startPoint=1; + } + if (j > 0 && item.x > leftSpace && item.x < rightSpace) { + var ctrlPoint = createCurveControlPoints(points, j - 1); + context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y,item.x,item.y); + } + } + } else { + for(let j=0;j leftSpace){ + context.moveTo(item.x, item.y); + startPoint=1; + } + if (j > 0 && item.x > leftSpace && item.x < rightSpace) { + context.lineTo(item.x, item.y); + } + } + } + context.moveTo(points[0].x, points[0].y); + } + context.stroke(); + context.setLineDash([]); + }); + } + + // 绘制点数据图 + if (eachSeries.type == 'point') { + eachSeries.addPoint = true; + } + + if (eachSeries.addPoint == true && eachSeries.type !== 'column' ) { + drawPointShape(points, eachSeries.color, eachSeries.pointShape, context, opts); + } + }); + if (opts.dataLabel !== false && process === 1) { + var columnIndex = 0; + series.forEach(function(eachSeries, seriesIndex) { + let ranges,minRange,maxRange; + + ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]); + minRange = ranges.pop(); + maxRange = ranges.shift(); + + var data = eachSeries.data; + var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process); + if (eachSeries.type !== 'column') { + drawPointText(points, eachSeries, config, context); + } else { + points = fixColumeData(points, eachSpacing, columnLength, columnIndex, config, opts); + drawPointText(points, eachSeries, config, context); + columnIndex += 1; + } + + }); + } + + context.restore(); + + return { + xAxisPoints: xAxisPoints, + calPoints: calPoints, + eachSpacing: eachSpacing, + } +} + +function drawToolTipBridge(opts, config, context, process, eachSpacing, xAxisPoints) { + var toolTipOption = opts.extra.tooltip || {}; + if (toolTipOption.horizentalLine && opts.tooltip && process === 1 && (opts.type == 'line' || opts.type == 'area' || opts.type == 'column' || opts.type == 'candle' || opts.type == 'mix')) { + drawToolTipHorizentalLine(opts, config, context, eachSpacing, xAxisPoints) + } + context.save(); + if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) { + context.translate(opts._scrollDistance_, 0); + } + if (opts.tooltip && opts.tooltip.textList && opts.tooltip.textList.length && process === 1) { + drawToolTip(opts.tooltip.textList, opts.tooltip.offset, opts, config, context, eachSpacing, xAxisPoints); + } + context.restore(); + +} + +function drawXAxis(categories, opts, config, context) { + + let xAxisData = opts.chartData.xAxisData, + xAxisPoints = xAxisData.xAxisPoints, + startX = xAxisData.startX, + endX = xAxisData.endX, + eachSpacing = xAxisData.eachSpacing; + var boundaryGap='center'; + if (opts.type == 'line'||opts.type == 'area'){ + boundaryGap=opts.xAxis.boundaryGap; + } + var startY = opts.height - opts.area[2]; + var endY = opts.area[0]; + + //绘制滚动条 + if (opts.enableScroll && opts.xAxis.scrollShow) { + var scrollY = opts.height - opts.area[2] + config.xAxisHeight; + var scrollScreenWidth = endX - startX; + var scrollTotalWidth = eachSpacing * (xAxisPoints.length - 1); + var scrollWidth = scrollScreenWidth * scrollScreenWidth / scrollTotalWidth; + var scrollLeft = 0; + if (opts._scrollDistance_) { + scrollLeft = -opts._scrollDistance_ * (scrollScreenWidth) / scrollTotalWidth; + } + context.beginPath(); + context.setLineCap('round'); + context.setLineWidth(6 * opts.pixelRatio); + context.setStrokeStyle(opts.xAxis.scrollBackgroundColor || "#EFEBEF"); + context.moveTo(startX, scrollY); + context.lineTo(endX, scrollY); + context.stroke(); + context.closePath(); + context.beginPath(); + context.setLineCap('round'); + context.setLineWidth(6 * opts.pixelRatio); + context.setStrokeStyle(opts.xAxis.scrollColor || "#A6A6A6"); + context.moveTo(startX + scrollLeft, scrollY); + context.lineTo(startX + scrollLeft + scrollWidth, scrollY); + context.stroke(); + context.closePath(); + context.setLineCap('butt'); + } + + context.save(); + + if (opts._scrollDistance_ && opts._scrollDistance_ !== 0) { + context.translate(opts._scrollDistance_, 0); + } + + //绘制X轴刻度线 + if (opts.xAxis.calibration === true) { + context.setStrokeStyle(opts.xAxis.gridColor || "#cccccc"); + context.setLineCap('butt'); + context.setLineWidth(1 * opts.pixelRatio); + xAxisPoints.forEach(function(item, index) { + if (index > 0) { + context.beginPath(); + context.moveTo(item - eachSpacing / 2, startY); + context.lineTo(item - eachSpacing / 2, startY + 3 * opts.pixelRatio); + context.closePath(); + context.stroke(); + } + }); + } + //绘制X轴网格 + if (opts.xAxis.disableGrid !== true) { + context.setStrokeStyle(opts.xAxis.gridColor || "#cccccc"); + context.setLineCap('butt'); + context.setLineWidth(1 * opts.pixelRatio); + if (opts.xAxis.gridType == 'dash') { + context.setLineDash([opts.xAxis.dashLength, opts.xAxis.dashLength]); + } + opts.xAxis.gridEval = opts.xAxis.gridEval || 1; + xAxisPoints.forEach(function(item, index) { + if (index % opts.xAxis.gridEval == 0) { + context.beginPath(); + context.moveTo(item, startY); + context.lineTo(item, endY); + context.stroke(); + } + }); + context.setLineDash([]); + } + + + //绘制X轴文案 + if (opts.xAxis.disabled !== true) { + // 对X轴列表做抽稀处理 + //默认全部显示X轴标签 + let maxXAxisListLength = categories.length; + //如果设置了X轴单屏数量 + if (opts.xAxis.labelCount) { + //如果设置X轴密度 + if (opts.xAxis.itemCount) { + maxXAxisListLength = Math.ceil(categories.length / opts.xAxis.itemCount * opts.xAxis.labelCount); + } else { + maxXAxisListLength = opts.xAxis.labelCount; + } + maxXAxisListLength -= 1; + } + + let ratio = Math.ceil(categories.length / maxXAxisListLength); + + let newCategories = []; + let cgLength = categories.length; + for (let i = 0; i < cgLength; i++) { + if (i % ratio !== 0) { + newCategories.push(""); + } else { + newCategories.push(categories[i]); + } + } + newCategories[cgLength - 1] = categories[cgLength - 1]; + + var xAxisFontSize = opts.xAxis.fontSize || config.fontSize; + if (config._xAxisTextAngle_ === 0) { + newCategories.forEach(function(item, index) { + var offset = - measureText(String(item), xAxisFontSize) / 2; + if(boundaryGap == 'center'){ + offset+=eachSpacing / 2; + } + var scrollHeight=0; + if(opts.xAxis.scrollShow){ + scrollHeight=6*opts.pixelRatio; + } + context.beginPath(); + context.setFontSize(xAxisFontSize); + context.setFillStyle(opts.xAxis.fontColor || '#666666'); + context.fillText(String(item), xAxisPoints[index] + offset, startY + xAxisFontSize + (config.xAxisHeight - scrollHeight - xAxisFontSize) / 2); + context.closePath(); + context.stroke(); + }); + + } else { + newCategories.forEach(function(item, index) { + context.save(); + context.beginPath(); + context.setFontSize(xAxisFontSize); + context.setFillStyle(opts.xAxis.fontColor || '#666666'); + var textWidth = measureText(String(item),xAxisFontSize); + var offset = - textWidth; + if(boundaryGap == 'center'){ + offset+=eachSpacing / 2; + } + var _calRotateTranslate = calRotateTranslate(xAxisPoints[index] + eachSpacing / 2, startY + xAxisFontSize / 2 + 5, opts.height), + transX = _calRotateTranslate.transX, + transY = _calRotateTranslate.transY; + + context.rotate(-1 * config._xAxisTextAngle_); + context.translate(transX, transY); + context.fillText(String(item), xAxisPoints[index] + offset, startY + xAxisFontSize + 5); + context.closePath(); + context.stroke(); + context.restore(); + }); + } + } + context.restore(); + + //绘制X轴轴线 + if(opts.xAxis.axisLine){ + context.beginPath(); + context.setStrokeStyle(opts.xAxis.axisLineColor); + context.setLineWidth(1 * opts.pixelRatio); + context.moveTo(startX,opts.height-opts.area[2]); + context.lineTo(endX,opts.height-opts.area[2]); + context.stroke(); + } +} + +function drawYAxisGrid(categories, opts, config, context) { + if (opts.yAxis.disableGrid === true) { + return; + } + let spacingValid = opts.height - opts.area[0] - opts.area[2]; + let eachSpacing = spacingValid / opts.yAxis.splitNumber; + let startX = opts.area[3]; + let xAxisPoints = opts.chartData.xAxisData.xAxisPoints, + xAxiseachSpacing = opts.chartData.xAxisData.eachSpacing; + let TotalWidth = xAxiseachSpacing * (xAxisPoints.length - 1); + let endX = startX + TotalWidth; + + let points = []; + for (let i = 0; i < opts.yAxis.splitNumber + 1; i++) { + points.push(opts.height - opts.area[2] - eachSpacing * i); + } + + context.save(); + if (opts._scrollDistance_ && opts._scrollDistance_ !== 0) { + context.translate(opts._scrollDistance_, 0); + } + + if (opts.yAxis.gridType == 'dash') { + context.setLineDash([opts.yAxis.dashLength, opts.yAxis.dashLength]); + } + context.setStrokeStyle(opts.yAxis.gridColor); + context.setLineWidth(1 * opts.pixelRatio); + points.forEach(function(item, index) { + context.beginPath(); + context.moveTo(startX, item); + context.lineTo(endX, item); + context.stroke(); + }); + context.setLineDash([]); + + context.restore(); +} + +function drawYAxis(series, opts, config, context) { + if (opts.yAxis.disabled === true) { + return; + } + var spacingValid = opts.height - opts.area[0] - opts.area[2]; + var eachSpacing = spacingValid / opts.yAxis.splitNumber; + var startX = opts.area[3]; + var endX = opts.width - opts.area[1]; + var endY = opts.height - opts.area[2]; + var fillEndY = endY + config.xAxisHeight; + if (opts.xAxis.scrollShow) { + fillEndY -= 3 * opts.pixelRatio; + } + if (opts.xAxis.rotateLabel){ + fillEndY = opts.height - opts.area[2]+3; + } + // set YAxis background + context.beginPath(); + context.setFillStyle(opts.background || '#ffffff'); + if (opts._scrollDistance_ < 0) { + context.fillRect(0, 0, startX, fillEndY); + } + if(opts.enableScroll == true){ + context.fillRect(endX, 0, opts.width, fillEndY); + } + context.closePath(); + context.stroke(); + + var points = []; + for (let i = 0; i <= opts.yAxis.splitNumber; i++) { + points.push(opts.area[0] + eachSpacing * i); + } + + let tStartLeft=opts.area[3]; + let tStartRight=opts.width-opts.area[1]; + + for (let i = 0; i < opts.yAxis.data.length; i++) { + let yData = opts.yAxis.data[i]; + if(yData.disabled !== true){ + let rangesFormat = opts.chartData.yAxisData.rangesFormat[i]; + let yAxisFontSize = yData.fontSize || config.fontSize; + let yAxisWidth = opts.chartData.yAxisData.yAxisWidth[i]; + //画Y轴刻度及文案 + rangesFormat.forEach(function(item, index) { + var pos = points[index] ? points[index] : endY; + context.beginPath(); + context.setFontSize(yAxisFontSize); + context.setLineWidth(1*opts.pixelRatio); + context.setStrokeStyle(yData.axisLineColor||'#cccccc'); + context.setFillStyle(yData.fontColor|| '#666666'); + if(yAxisWidth.position=='left'){ + context.fillText(String(item), tStartLeft - yAxisWidth.width , pos + yAxisFontSize / 2); + //画刻度线 + if(yData.calibration==true){ + context.moveTo(tStartLeft,pos); + context.lineTo(tStartLeft - 3*opts.pixelRatio,pos); + } + }else{ + context.fillText(String(item), tStartRight + 4*opts.pixelRatio, pos + yAxisFontSize / 2); + //画刻度线 + if(yData.calibration==true){ + context.moveTo(tStartRight,pos); + context.lineTo(tStartRight + 3*opts.pixelRatio,pos); + } + } + context.closePath(); + context.stroke(); + }); + //画Y轴轴线 + if (yData.axisLine!==false) { + context.beginPath(); + context.setStrokeStyle(yData.axisLineColor||'#cccccc'); + context.setLineWidth(1 * opts.pixelRatio); + if(yAxisWidth.position=='left'){ + context.moveTo(tStartLeft,opts.height-opts.area[2]); + context.lineTo(tStartLeft,opts.area[0]); + }else{ + context.moveTo(tStartRight,opts.height-opts.area[2]); + context.lineTo(tStartRight,opts.area[0]); + } + context.stroke(); + } + + //画Y轴标题 + if (opts.yAxis.showTitle) { + + let titleFontSize = yData.titleFontSize || config.fontSize; + let title = yData.title; + context.beginPath(); + context.setFontSize(titleFontSize); + context.setFillStyle(yData.titleFontColor || '#666666'); + if(yAxisWidth.position=='left'){ + context.fillText(title, tStartLeft - measureText(title,titleFontSize)/2, opts.area[0]-10*opts.pixelRatio); + }else{ + context.fillText(title,tStartRight - measureText(title,titleFontSize)/2, opts.area[0]-10*opts.pixelRatio); + } + context.closePath(); + context.stroke(); + } + if(yAxisWidth.position=='left'){ + tStartLeft -=(yAxisWidth.width + opts.yAxis.padding); + }else{ + tStartRight +=yAxisWidth.width+ opts.yAxis.padding; + } + } + } +} + +function drawLegend(series, opts, config, context, chartData) { + if (opts.legend.show === false) { + return; + } + let legendData = chartData.legendData; + let legendList = legendData.points; + let legendArea = legendData.area; + let padding = opts.legend.padding; + let fontSize = opts.legend.fontSize; + let shapeWidth = 15 * opts.pixelRatio; + let shapeRight = 5 * opts.pixelRatio; + let itemGap = opts.legend.itemGap; + let lineHeight = Math.max(opts.legend.lineHeight * opts.pixelRatio, fontSize); + + //画背景及边框 + context.beginPath(); + context.setLineWidth(opts.legend.borderWidth); + context.setStrokeStyle(opts.legend.borderColor); + context.setFillStyle(opts.legend.backgroundColor); + context.moveTo(legendArea.start.x, legendArea.start.y); + context.rect(legendArea.start.x, legendArea.start.y, legendArea.width, legendArea.height); + context.closePath(); + context.fill(); + context.stroke(); + + legendList.forEach(function(itemList, listIndex) { + let width = 0; + let height = 0; + width = legendData.widthArr[listIndex]; + height = legendData.heightArr[listIndex]; + let startX = 0; + let startY = 0; + if (opts.legend.position == 'top' || opts.legend.position == 'bottom') { + startX = legendArea.start.x + (legendArea.width - width) / 2; + startY = legendArea.start.y + padding + listIndex * lineHeight; + } else { + if (listIndex == 0) { + width = 0; + } else { + width = legendData.widthArr[listIndex - 1]; + } + startX = legendArea.start.x + padding + width; + startY = legendArea.start.y + padding + (legendArea.height - height) / 2; + } + + context.setFontSize(config.fontSize); + for (let i = 0; i < itemList.length; i++) { + let item = itemList[i]; + item.area = [0, 0, 0, 0]; + item.area[0] = startX; + item.area[1] = startY; + item.area[3] = startY + lineHeight; + context.beginPath(); + context.setLineWidth(1 * opts.pixelRatio); + context.setStrokeStyle(item.show ? item.color : opts.legend.hiddenColor); + context.setFillStyle(item.show ? item.color : opts.legend.hiddenColor); + switch (item.legendShape) { + case 'line': + context.moveTo(startX, startY + 0.5 * lineHeight - 2 * opts.pixelRatio); + context.fillRect(startX, startY + 0.5 * lineHeight - 2 * opts.pixelRatio, 15 * opts.pixelRatio, 4 * opts.pixelRatio); + break; + case 'triangle': + context.moveTo(startX + 7.5 * opts.pixelRatio, startY + 0.5 * lineHeight - 5 * opts.pixelRatio); + context.lineTo(startX + 2.5 * opts.pixelRatio, startY + 0.5 * lineHeight + 5 * opts.pixelRatio); + context.lineTo(startX + 12.5 * opts.pixelRatio, startY + 0.5 * lineHeight + 5 * opts.pixelRatio); + context.lineTo(startX + 7.5 * opts.pixelRatio, startY + 0.5 * lineHeight - 5 * opts.pixelRatio); + break; + case 'diamond': + context.moveTo(startX + 7.5 * opts.pixelRatio, startY + 0.5 * lineHeight - 5 * opts.pixelRatio); + context.lineTo(startX + 2.5 * opts.pixelRatio, startY + 0.5 * lineHeight); + context.lineTo(startX + 7.5 * opts.pixelRatio, startY + 0.5 * lineHeight + 5 * opts.pixelRatio); + context.lineTo(startX + 12.5 * opts.pixelRatio, startY + 0.5 * lineHeight); + context.lineTo(startX + 7.5 * opts.pixelRatio, startY + 0.5 * lineHeight - 5 * opts.pixelRatio); + break; + case 'circle': + context.moveTo(startX + 7.5 * opts.pixelRatio, startY + 0.5 * lineHeight); + context.arc(startX + 7.5 * opts.pixelRatio, startY + 0.5 * lineHeight, 5 * opts.pixelRatio, 0, 2 * Math.PI); + break; + case 'rect': + context.moveTo(startX, startY + 0.5 * lineHeight - 5 * opts.pixelRatio); + context.fillRect(startX, startY + 0.5 * lineHeight - 5 * opts.pixelRatio, 15 * opts.pixelRatio, 10 * opts.pixelRatio); + break; + default: + context.moveTo(startX, startY + 0.5 * lineHeight - 5 * opts.pixelRatio); + context.fillRect(startX, startY + 0.5 * lineHeight - 5 * opts.pixelRatio, 15 * opts.pixelRatio, 10 * opts.pixelRatio); + } + context.closePath(); + context.fill(); + context.stroke(); + + startX += shapeWidth + shapeRight; + let fontTrans = 0.5 * lineHeight + 0.5 * fontSize - 2; + context.beginPath(); + context.setFontSize(fontSize); + context.setFillStyle(item.show ? opts.legend.fontColor : opts.legend.hiddenColor); + context.fillText(item.name, startX, startY + fontTrans); + context.closePath(); + context.stroke(); + if (opts.legend.position == 'top' || opts.legend.position == 'bottom') { + startX += measureText(item.name, fontSize) + itemGap; + item.area[2] = startX; + } else { + item.area[2] = startX + measureText(item.name, fontSize) + itemGap;; + startX -= shapeWidth + shapeRight; + startY += lineHeight; + } + } + }); +} + +function drawPieDataPoints(series, opts, config, context) { + var process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1; + var pieOption = assign({}, { + activeOpacity: 0.5, + activeRadius: 10 * opts.pixelRatio, + offsetAngle: 0, + labelWidth: 15 * opts.pixelRatio, + ringWidth: 0, + border:false, + borderWidth:2, + borderColor:'#FFFFFF' + }, opts.extra.pie); + var centerPosition = { + x: opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2, + y: opts.area[0] + (opts.height - opts.area[0] - opts.area[2]) / 2 + }; + if (config.pieChartLinePadding == 0) { + config.pieChartLinePadding = pieOption.activeRadius; + } + + var radius = Math.min((opts.width - opts.area[1] - opts.area[3]) / 2 - config.pieChartLinePadding - config.pieChartTextPadding - config._pieTextMaxLength_, (opts.height - opts.area[0] - opts.area[2]) / 2 - config.pieChartLinePadding - config.pieChartTextPadding); + + series = getPieDataPoints(series, radius, process); + + var activeRadius = pieOption.activeRadius; + + series = series.map(function(eachSeries) { + eachSeries._start_ += (pieOption.offsetAngle) * Math.PI / 180; + return eachSeries; + }); + series.forEach(function(eachSeries, seriesIndex) { + if (opts.tooltip) { + if (opts.tooltip.index == seriesIndex) { + context.beginPath(); + context.setFillStyle(hexToRgb(eachSeries.color, opts.extra.pie.activeOpacity || 0.5)); + context.moveTo(centerPosition.x, centerPosition.y); + context.arc(centerPosition.x, centerPosition.y, eachSeries._radius_ + activeRadius, eachSeries._start_, + eachSeries._start_ + 2 * + eachSeries._proportion_ * Math.PI); + context.closePath(); + context.fill(); + } + } + context.beginPath(); + context.setLineWidth(pieOption.borderWidth * opts.pixelRatio); + context.lineJoin = "round"; + context.setStrokeStyle(pieOption.borderColor); + context.setFillStyle(eachSeries.color); + context.moveTo(centerPosition.x, centerPosition.y); + context.arc(centerPosition.x, centerPosition.y, eachSeries._radius_, eachSeries._start_, eachSeries._start_ + 2 * eachSeries._proportion_ * Math.PI); + context.closePath(); + context.fill(); + if (pieOption.border == true) { + context.stroke(); + } + }); + + if (opts.type === 'ring') { + var innerPieWidth = radius * 0.6; + if (typeof opts.extra.pie.ringWidth === 'number' && opts.extra.pie.ringWidth > 0) { + innerPieWidth = Math.max(0, radius - opts.extra.pie.ringWidth); + } + context.beginPath(); + context.setFillStyle(opts.background || '#ffffff'); + context.moveTo(centerPosition.x, centerPosition.y); + context.arc(centerPosition.x, centerPosition.y, innerPieWidth, 0, 2 * Math.PI); + context.closePath(); + context.fill(); + } + + if (opts.dataLabel !== false && process === 1) { + var valid = false; + for (var i = 0, len = series.length; i < len; i++) { + if (series[i].data > 0) { + valid = true; + break; + } + } + + if (valid) { + drawPieText(series, opts, config, context, radius, centerPosition); + } + } + + if (process === 1 && opts.type === 'ring') { + drawRingTitle(opts, config, context, centerPosition); + } + + return { + center: centerPosition, + radius: radius, + series: series + }; +} + +function drawRoseDataPoints(series, opts, config, context) { + var process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1; + var roseOption = assign({}, { + type: 'area', + activeOpacity: 0.5, + activeRadius: 10 * opts.pixelRatio, + offsetAngle: 0, + labelWidth: 15 * opts.pixelRatio, + border:false, + borderWidth:2, + borderColor:'#FFFFFF' + }, opts.extra.rose); + if (config.pieChartLinePadding == 0) { + config.pieChartLinePadding = roseOption.activeRadius; + } + var centerPosition = { + x: opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2, + y: opts.area[0] + (opts.height - opts.area[0] - opts.area[2]) / 2 + }; + var radius = Math.min((opts.width - opts.area[1] - opts.area[3]) / 2 - config.pieChartLinePadding - config.pieChartTextPadding - config._pieTextMaxLength_, (opts.height - opts.area[0] - opts.area[2]) / 2 - config.pieChartLinePadding - config.pieChartTextPadding); + var minRadius = roseOption.minRadius || radius * 0.5; + + series = getRoseDataPoints(series, roseOption.type, minRadius, radius, process); + + var activeRadius = roseOption.activeRadius; + + series = series.map(function(eachSeries) { + eachSeries._start_ += (roseOption.offsetAngle || 0) * Math.PI / 180; + return eachSeries; + }); + + series.forEach(function(eachSeries, seriesIndex) { + if (opts.tooltip) { + if (opts.tooltip.index == seriesIndex) { + context.beginPath(); + context.setFillStyle(hexToRgb(eachSeries.color, roseOption.activeOpacity || 0.5)); + context.moveTo(centerPosition.x, centerPosition.y); + context.arc(centerPosition.x, centerPosition.y, activeRadius + eachSeries._radius_, eachSeries._start_, + eachSeries._start_ + 2 * eachSeries._rose_proportion_ * Math.PI); + context.closePath(); + context.fill(); + } + } + context.beginPath(); + context.setLineWidth(roseOption.borderWidth * opts.pixelRatio); + context.lineJoin = "round"; + context.setStrokeStyle(roseOption.borderColor); + context.setFillStyle(eachSeries.color); + context.moveTo(centerPosition.x, centerPosition.y); + context.arc(centerPosition.x, centerPosition.y, eachSeries._radius_, eachSeries._start_, eachSeries._start_ + 2 * + eachSeries._rose_proportion_ * Math.PI); + context.closePath(); + context.fill(); + if (roseOption.border == true) { + context.stroke(); + } + }); + + if (opts.dataLabel !== false && process === 1) { + var valid = false; + for (var i = 0, len = series.length; i < len; i++) { + if (series[i].data > 0) { + valid = true; + break; + } + } + + if (valid) { + drawPieText(series, opts, config, context, radius, centerPosition); + } + } + + return { + center: centerPosition, + radius: radius, + series: series + }; +} + +function drawArcbarDataPoints(series, opts, config, context) { + var process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1; + var arcbarOption = assign({}, { + startAngle: 0.75, + endAngle: 0.25, + type: 'default', + width: 12 * opts.pixelRatio, + gap:2 * opts.pixelRatio + }, opts.extra.arcbar); + + series = getArcbarDataPoints(series, arcbarOption, process); + + var centerPosition; + if(arcbarOption.center){ + centerPosition=arcbarOption.center; + }else{ + centerPosition= { + x: opts.width / 2, + y: opts.height / 2 + }; + } + + var radius; + if(arcbarOption.radius){ + radius=arcbarOption.radius; + }else{ + radius = Math.min(centerPosition.x, centerPosition.y); + radius -= 5 * opts.pixelRatio; + radius -= arcbarOption.width / 2; + } + + for (let i = 0; i < series.length; i++) { + let eachSeries = series[i]; + //背景颜色 + context.setLineWidth(arcbarOption.width); + context.setStrokeStyle(arcbarOption.backgroundColor || '#E9E9E9'); + context.setLineCap('round'); + context.beginPath(); + if (arcbarOption.type == 'default') { + context.arc(centerPosition.x, centerPosition.y, radius-(arcbarOption.width+arcbarOption.gap)*i, arcbarOption.startAngle * Math.PI, arcbarOption.endAngle * Math.PI, false); + } else { + context.arc(centerPosition.x, centerPosition.y, radius-(arcbarOption.width+arcbarOption.gap)*i, 0, 2 * Math.PI, false); + } + context.stroke(); + //进度条 + context.setLineWidth(arcbarOption.width); + context.setStrokeStyle(eachSeries.color); + context.setLineCap('round'); + context.beginPath(); + context.arc(centerPosition.x, centerPosition.y, radius-(arcbarOption.width+arcbarOption.gap)*i, arcbarOption.startAngle * Math.PI, eachSeries._proportion_ * Math.PI, false); + context.stroke(); + } + + drawRingTitle(opts, config, context, centerPosition); + + return { + center: centerPosition, + radius: radius, + series: series + }; +} + +function drawGaugeDataPoints(categories, series, opts, config, context) { + var process = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 1; + var gaugeOption = assign({}, { + type:'default', + startAngle: 0.75, + endAngle: 0.25, + width: 15, + splitLine: { + fixRadius: 0, + splitNumber: 10, + width: 15, + color: '#FFFFFF', + childNumber: 5, + childWidth: 5 + }, + pointer: { + width: 15, + color: 'auto' + } + }, opts.extra.gauge); + + if (gaugeOption.oldAngle == undefined) { + gaugeOption.oldAngle = gaugeOption.startAngle; + } + if (gaugeOption.oldData == undefined) { + gaugeOption.oldData = 0; + } + categories = getGaugeAxisPoints(categories, gaugeOption.startAngle, gaugeOption.endAngle); + + var centerPosition = { + x: opts.width / 2, + y: opts.height / 2 + }; + var radius = Math.min(centerPosition.x, centerPosition.y); + radius -= 5 * opts.pixelRatio; + radius -= gaugeOption.width / 2; + var innerRadius = radius - gaugeOption.width; + var totalAngle=0; + + //判断仪表盘的样式:default百度样式,progress新样式 + if(gaugeOption.type == 'progress'){ + + //## 第一步画中心圆形背景和进度条背景 + //中心圆形背景 + var pieRadius = radius - gaugeOption.width*3; + context.beginPath(); + let gradient = context.createLinearGradient(centerPosition.x, centerPosition.y-pieRadius, centerPosition.x , centerPosition.y+pieRadius); + //配置渐变填充(起点:中心点向上减半径;结束点中心点向下加半径) + gradient.addColorStop('0', hexToRgb(series[0].color, 0.3)); + gradient.addColorStop('1.0',hexToRgb("#FFFFFF", 0.1)); + context.setFillStyle(gradient); + context.arc(centerPosition.x, centerPosition.y, pieRadius, 0, 2*Math.PI, false); + context.fill(); + //画进度条背景 + context.setLineWidth(gaugeOption.width); + context.setStrokeStyle(hexToRgb(series[0].color, 0.3)); + context.setLineCap('round'); + context.beginPath(); + context.arc(centerPosition.x, centerPosition.y, innerRadius , gaugeOption.startAngle * Math.PI, gaugeOption.endAngle *Math.PI, false); + context.stroke(); + + //## 第二步画刻度线 + totalAngle = gaugeOption.startAngle - gaugeOption.endAngle + 1; + let splitAngle = totalAngle / gaugeOption.splitLine.splitNumber; + let childAngle = totalAngle / gaugeOption.splitLine.splitNumber / gaugeOption.splitLine.childNumber; + let startX = -radius - gaugeOption.width * 0.5 - gaugeOption.splitLine.fixRadius; + let endX = -radius - gaugeOption.width - gaugeOption.splitLine.fixRadius + gaugeOption.splitLine.width; + context.save(); + context.translate(centerPosition.x, centerPosition.y); + context.rotate((gaugeOption.startAngle - 1) * Math.PI); + let len = gaugeOption.splitLine.splitNumber * gaugeOption.splitLine.childNumber + 1; + let proc = series[0].data * process; + for (let i = 0; i < len; i++) { + context.beginPath(); + //刻度线随进度变色 + if(proc>(i/len)){ + context.setStrokeStyle(hexToRgb(series[0].color, 1)); + }else{ + context.setStrokeStyle(hexToRgb(series[0].color, 0.3)); + } + context.setLineWidth(3 * opts.pixelRatio); + context.moveTo(startX, 0); + context.lineTo(endX, 0); + context.stroke(); + context.rotate(childAngle * Math.PI); + } + context.restore(); + + //## 第三步画进度条 + series = getArcbarDataPoints(series, gaugeOption, process); + context.setLineWidth(gaugeOption.width); + context.setStrokeStyle(series[0].color); + context.setLineCap('round'); + context.beginPath(); + context.arc(centerPosition.x, centerPosition.y, innerRadius , gaugeOption.startAngle * Math.PI, series[0]._proportion_ *Math.PI, false); + context.stroke(); + + //## 第四步画指针 + let pointerRadius = radius - gaugeOption.width*2.5; + context.save(); + context.translate(centerPosition.x, centerPosition.y); + context.rotate((series[0]._proportion_ - 1) * Math.PI); + context.beginPath(); + context.setLineWidth(gaugeOption.width/3); + let gradient3 = context.createLinearGradient(0, -pointerRadius*0.6, 0 , pointerRadius*0.6); + gradient3.addColorStop('0', hexToRgb('#FFFFFF', 0)); + gradient3.addColorStop('0.5', hexToRgb(series[0].color, 1)); + gradient3.addColorStop('1.0', hexToRgb('#FFFFFF', 0)); + context.setStrokeStyle(gradient3); + context.arc(0, 0, pointerRadius , 0.85* Math.PI, 1.15 * Math.PI, false); + context.stroke(); + context.beginPath(); + context.setLineWidth(1); + context.setStrokeStyle(series[0].color); + context.setFillStyle(series[0].color); + context.moveTo(-pointerRadius-gaugeOption.width/3/2,-4); + context.lineTo(-pointerRadius-gaugeOption.width/3/2-4,0); + context.lineTo(-pointerRadius-gaugeOption.width/3/2,4); + context.lineTo(-pointerRadius-gaugeOption.width/3/2,-4); + context.stroke(); + context.fill(); + context.restore(); + + //default百度样式 + }else{ + //画背景 + context.setLineWidth(gaugeOption.width); + context.setLineCap('butt'); + for (let i = 0; i < categories.length; i++) { + let eachCategories = categories[i]; + context.beginPath(); + context.setStrokeStyle(eachCategories.color); + context.arc(centerPosition.x, centerPosition.y, radius, eachCategories._startAngle_ * Math.PI, eachCategories._endAngle_ *Math.PI, false); + context.stroke(); + } + context.save(); + + //画刻度线 + totalAngle = gaugeOption.startAngle - gaugeOption.endAngle + 1; + let splitAngle = totalAngle / gaugeOption.splitLine.splitNumber; + let childAngle = totalAngle / gaugeOption.splitLine.splitNumber / gaugeOption.splitLine.childNumber; + let startX = -radius - gaugeOption.width * 0.5 - gaugeOption.splitLine.fixRadius; + let endX = -radius - gaugeOption.width * 0.5 - gaugeOption.splitLine.fixRadius + gaugeOption.splitLine.width; + let childendX = -radius - gaugeOption.width * 0.5 - gaugeOption.splitLine.fixRadius + gaugeOption.splitLine.childWidth; + + context.translate(centerPosition.x, centerPosition.y); + context.rotate((gaugeOption.startAngle - 1) * Math.PI); + + for (let i = 0; i < gaugeOption.splitLine.splitNumber + 1; i++) { + context.beginPath(); + context.setStrokeStyle(gaugeOption.splitLine.color); + context.setLineWidth(2 * opts.pixelRatio); + context.moveTo(startX, 0); + context.lineTo(endX, 0); + context.stroke(); + context.rotate(splitAngle * Math.PI); + } + context.restore(); + + context.save(); + context.translate(centerPosition.x, centerPosition.y); + context.rotate((gaugeOption.startAngle - 1) * Math.PI); + + for (let i = 0; i < gaugeOption.splitLine.splitNumber * gaugeOption.splitLine.childNumber + 1; i++) { + context.beginPath(); + context.setStrokeStyle(gaugeOption.splitLine.color); + context.setLineWidth(1 * opts.pixelRatio); + context.moveTo(startX, 0); + context.lineTo(childendX, 0); + context.stroke(); + context.rotate(childAngle * Math.PI); + } + context.restore(); + + //画指针 + series = getGaugeDataPoints(series, categories, gaugeOption, process); + + for (let i = 0; i < series.length; i++) { + let eachSeries = series[i]; + context.save(); + context.translate(centerPosition.x, centerPosition.y); + context.rotate((eachSeries._proportion_ - 1) * Math.PI); + context.beginPath(); + context.setFillStyle(eachSeries.color); + context.moveTo(gaugeOption.pointer.width, 0); + context.lineTo(0, -gaugeOption.pointer.width / 2); + context.lineTo(-innerRadius, 0); + context.lineTo(0, gaugeOption.pointer.width / 2); + context.lineTo(gaugeOption.pointer.width, 0); + context.closePath(); + context.fill(); + context.beginPath(); + context.setFillStyle('#FFFFFF'); + context.arc(0, 0, gaugeOption.pointer.width / 6, 0, 2 * Math.PI, false); + context.fill(); + context.restore(); + } + + if (opts.dataLabel !== false) { + drawGaugeLabel(gaugeOption, radius, centerPosition, opts, config, context); + } + } + + //画仪表盘标题,副标题 + drawRingTitle(opts, config, context, centerPosition); + + if (process === 1 && opts.type === 'gauge') { + opts.extra.gauge.oldAngle = series[0]._proportion_; + opts.extra.gauge.oldData = series[0].data; + } + return { + center: centerPosition, + radius: radius, + innerRadius: innerRadius, + categories: categories, + totalAngle: totalAngle + }; +} + +function drawRadarDataPoints(series, opts, config, context) { + var process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1; + var radarOption = assign({},{ + gridColor: '#cccccc', + labelColor: '#666666', + opacity: 0.2, + gridCount:3 + },opts.extra.radar); + + var coordinateAngle = getRadarCoordinateSeries(opts.categories.length); + + var centerPosition = { + x: opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2, + y: opts.area[0] + (opts.height - opts.area[0] - opts.area[2]) / 2 + }; + + var radius = Math.min(centerPosition.x - (getMaxTextListLength(opts.categories) + config.radarLabelTextMargin), + centerPosition.y - config.radarLabelTextMargin); + //TODO逻辑不对 + radius -= opts.padding[1]; + + // draw grid + context.beginPath(); + context.setLineWidth(1 * opts.pixelRatio); + context.setStrokeStyle(radarOption.gridColor); + coordinateAngle.forEach(function(angle) { + var pos = convertCoordinateOrigin(radius * Math.cos(angle), radius * Math.sin(angle), centerPosition); + context.moveTo(centerPosition.x, centerPosition.y); + context.lineTo(pos.x, pos.y); + }); + context.stroke(); + context.closePath(); + // draw split line grid + + var _loop = function _loop(i) { + var startPos = {}; + context.beginPath(); + context.setLineWidth(1 * opts.pixelRatio); + context.setStrokeStyle(radarOption.gridColor); + coordinateAngle.forEach(function(angle, index) { + var pos = convertCoordinateOrigin(radius / radarOption.gridCount * i * Math.cos(angle), radius / radarOption.gridCount * i * Math.sin(angle), centerPosition); + if (index === 0) { + startPos = pos; + context.moveTo(pos.x, pos.y); + } else { + context.lineTo(pos.x, pos.y); + } + }); + context.lineTo(startPos.x, startPos.y); + context.stroke(); + context.closePath(); + }; + + for (var i = 1; i <= radarOption.gridCount; i++) { + _loop(i); + } + + var radarDataPoints = getRadarDataPoints(coordinateAngle, centerPosition, radius, series, opts, process); + + radarDataPoints.forEach(function(eachSeries, seriesIndex) { + // 绘制区域数据 + context.beginPath(); + context.setFillStyle(hexToRgb(eachSeries.color, radarOption.opacity)); + eachSeries.data.forEach(function(item, index) { + if (index === 0) { + context.moveTo(item.position.x, item.position.y); + } else { + context.lineTo(item.position.x, item.position.y); + } + }); + context.closePath(); + context.fill(); + + if (opts.dataPointShape !== false) { + var points = eachSeries.data.map(function(item) { + return item.position; + }); + drawPointShape(points, eachSeries.color, eachSeries.pointShape, context, opts); + } + }); + // draw label text + drawRadarLabel(coordinateAngle, radius, centerPosition, opts, config, context); + + return { + center: centerPosition, + radius: radius, + angleList: coordinateAngle + }; +} + +function normalInt(min, max, iter) { + iter = iter==0?1:iter; + var arr = []; + for (var i = 0; i < iter; i++) { + arr[i] = Math.random(); + }; + return Math.floor(arr.reduce(function(i,j){return i+j})/iter*(max-min))+min; +}; + +function collisionNew(area,points,width,height){ + var isIn=false; + for(let i=0;ipoints[i].area[2]||area[1]>points[i].area[3]||area[2]width || area[3]>height){ + isIn=true; + break; + }else{ + isIn=false; + } + }else{ + isIn=true; + break; + } + } + } + return isIn; +}; + +function getBoundingBox(data) { + var bounds = {}, coords; + bounds.xMin = 180; + bounds.xMax = 0; + bounds.yMin = 90; + bounds.yMax = 0 + for (var i = 0; i < data.length; i++) { + var coorda = data[i].geometry.coordinates + for (var k = 0; k < coorda.length; k++) { + coords = coorda[k]; + if (coords.length == 1) { + coords = coords[0] + } + for (var j = 0; j < coords.length; j++) { + var longitude = coords[j][0]; + var latitude = coords[j][1]; + var point = { + x: longitude, + y: latitude + } + bounds.xMin = bounds.xMin < point.x ? bounds.xMin : point.x; + bounds.xMax = bounds.xMax > point.x ? bounds.xMax : point.x; + bounds.yMin = bounds.yMin < point.y ? bounds.yMin : point.y; + bounds.yMax = bounds.yMax > point.y ? bounds.yMax : point.y; + } + } + } + return bounds; +} + +function coordinateToPoint(latitude, longitude,bounds,scale,xoffset,yoffset) { + return { + x: (longitude - bounds.xMin) * scale+xoffset, + y: (bounds.yMax - latitude) * scale+yoffset + }; +} + +function pointToCoordinate(pointY, pointX,bounds,scale,xoffset,yoffset) { + return { + x: (pointX-xoffset)/scale+bounds.xMin, + y: bounds.yMax - (pointY-yoffset)/scale + }; +} + +function isRayIntersectsSegment(poi,s_poi,e_poi){ + if (s_poi[1]==e_poi[1]){return false;} + if (s_poi[1]>poi[1] && e_poi[1]>poi[1]){return false;} + if (s_poi[1]poi[1]){return false;} + if (e_poi[1]==poi[1] && s_poi[1]>poi[1]){return false;} + if (s_poi[0]0.7) { + return true; + }else {return false}; + }; + for (let i = 0; i < points.length; i++) { + let text = points[i].name; + let tHeight = points[i].textSize; + let tWidth = measureText(text,tHeight); + let isSpin = Spin(); + let x,y,area,areav; + let breaknum=0; + while(true) { + breaknum++; + let isCollision; + if (isSpin) { + x = normalInt(-opts.width/2, opts.width/2,5) - tWidth/2; + y = normalInt(-opts.height/2, opts.height/2,5)+tHeight/2; + area=[y-5-tWidth+opts.width/2,(-x-5+opts.height/2),y+5+opts.width/2,(-x+tHeight+5+opts.height/2)]; + areav=[opts.width-(opts.width/2-opts.height/2)-(-x+tHeight+5+opts.height/2)-5,(opts.height/2-opts.width/2)+(y-5-tWidth+opts.width/2)-5,opts.width-(opts.width/2-opts.height/2)-(-x+tHeight+5+opts.height/2)+tHeight,(opts.height/2-opts.width/2)+(y-5-tWidth+opts.width/2)+tWidth+5]; + isCollision = collisionNew(areav,points,opts.height,opts.width); + }else{ + x = normalInt(-opts.width/2, opts.width/2,5) - tWidth/2; + y = normalInt(-opts.height/2, opts.height/2,5)+tHeight/2; + area=[x-5+opts.width/2,y-5-tHeight+opts.height/2,x+tWidth+5+opts.width/2,y+5+opts.height/2]; + isCollision = collisionNew(area,points,opts.width,opts.height); + } + if (!isCollision) break; + if (breaknum==1000){ + area=[-1000,-1000,-1000,-1000]; + break; + } + }; + if (isSpin) { + points[i].area=areav; + points[i].areav=area; + }else{ + points[i].area=area; + } + points[i].rotate=isSpin; + }; + break; + } + return points; +} + + +function drawWordCloudDataPoints(series, opts, config, context) { + let process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1; + let wordOption = assign({},{ + type: 'normal', + autoColors: true + },opts.extra.word); + + context.beginPath(); + context.setFillStyle(opts.background||'#FFFFFF'); + context.rect(0,0,opts.width,opts.height); + context.fill(); + context.save(); + let points = opts.chartData.wordCloudData; + context.translate(opts.width/2,opts.height/2); + + for(let i=0;i0){ + if (opts.tooltip) { + if (opts.tooltip.index == i) { + context.strokeText(text,(points[i].areav[0]+5-opts.width/2)*process-tWidth*(1-process)/2,(points[i].areav[1]+5+tHeight-opts.height/2)*process); + }else{ + context.fillText(text,(points[i].areav[0]+5-opts.width/2)*process-tWidth*(1-process)/2,(points[i].areav[1]+5+tHeight-opts.height/2)*process); + } + }else{ + context.fillText(text,(points[i].areav[0]+5-opts.width/2)*process-tWidth*(1-process)/2,(points[i].areav[1]+5+tHeight-opts.height/2)*process); + } + } + }else{ + if(points[i].area[0]>0){ + if (opts.tooltip) { + if (opts.tooltip.index == i) { + context.strokeText(text,(points[i].area[0]+5-opts.width/2)*process-tWidth*(1-process)/2,(points[i].area[1]+5+tHeight-opts.height/2)*process); + }else{ + context.fillText(text,(points[i].area[0]+5-opts.width/2)*process-tWidth*(1-process)/2,(points[i].area[1]+5+tHeight-opts.height/2)*process); + } + }else{ + context.fillText(text,(points[i].area[0]+5-opts.width/2)*process-tWidth*(1-process)/2,(points[i].area[1]+5+tHeight-opts.height/2)*process); + } + + } + } + + context.stroke(); + context.restore(); + } + context.restore(); +} + +function drawFunnelDataPoints(series, opts, config, context) { + let process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1; + let funnelOption = assign({},{ + activeWidth:10, + activeOpacity:0.3, + border:false, + borderWidth:2, + borderColor:'#FFFFFF', + fillOpacity:1, + labelAlign:'right' + },opts.extra.funnel); + let eachSpacing = (opts.height - opts.area[0] - opts.area[2])/series.length; + let centerPosition = { + x: opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2, + y: opts.height-opts.area[2] + }; + let activeWidth = funnelOption.activeWidth; + let radius = Math.min((opts.width - opts.area[1] - opts.area[3]) / 2 - activeWidth, (opts.height - opts.area[0] - opts.area[2]) / 2 - activeWidth); + series = getFunnelDataPoints(series, radius, process); + context.save(); + context.translate(centerPosition.x,centerPosition.y); + for(let i=0;i0){ + opts.area[3] += yAxisWidth[i].width + opts.yAxis.padding; + }else{ + opts.area[3] += yAxisWidth[i].width; + } + leftIndex +=1; + }else{ + if(rightIndex>0){ + opts.area[1] += yAxisWidth[i].width + opts.yAxis.padding; + }else{ + opts.area[1] += yAxisWidth[i].width; + } + rightIndex +=1; + } + } + }else{ + config.yAxisWidth = yAxisWidth; + } + opts.chartData.yAxisData = _calYAxisData; + + if (opts.categories && opts.categories.length) { + opts.chartData.xAxisData = getXAxisPoints(opts.categories, opts, config); + let _calCategoriesData = calCategoriesData(opts.categories, opts, config, opts.chartData.xAxisData.eachSpacing), + xAxisHeight = _calCategoriesData.xAxisHeight, + angle = _calCategoriesData.angle; + config.xAxisHeight = xAxisHeight; + config._xAxisTextAngle_ = angle; + opts.area[2] += xAxisHeight; + opts.chartData.categoriesData = _calCategoriesData; + }else{ + if (opts.type === 'line' || opts.type === 'area' || opts.type === 'points') { + opts.chartData.xAxisData = calXAxisData(series, opts, config); + categories=opts.chartData.xAxisData.rangesFormat; + let _calCategoriesData = calCategoriesData(categories, opts, config, opts.chartData.xAxisData.eachSpacing), + xAxisHeight = _calCategoriesData.xAxisHeight, + angle = _calCategoriesData.angle; + config.xAxisHeight = xAxisHeight; + config._xAxisTextAngle_ = angle; + opts.area[2] += xAxisHeight; + opts.chartData.categoriesData = _calCategoriesData; + }else{ + opts.chartData.xAxisData={ + xAxisPoints: [] + }; + } + } + //计算右对齐偏移距离 + if (opts.enableScroll && opts.xAxis.scrollAlign == 'right' && opts._scrollDistance_ === undefined) { + let offsetLeft = 0, + xAxisPoints = opts.chartData.xAxisData.xAxisPoints, + startX = opts.chartData.xAxisData.startX, + endX = opts.chartData.xAxisData.endX, + eachSpacing = opts.chartData.xAxisData.eachSpacing; + let totalWidth = eachSpacing * (xAxisPoints.length - 1); + let screenWidth = endX - startX; + offsetLeft = screenWidth - totalWidth; + _this.scrollOption = { + currentOffset: offsetLeft, + startTouchX: offsetLeft, + distance: 0, + lastMoveTime: 0 + }; + opts._scrollDistance_ = offsetLeft; + } + + if (type === 'pie' || type === 'ring' || type === 'rose') { + config._pieTextMaxLength_ = opts.dataLabel === false ? 0 : getPieTextMaxLength(seriesMA); + } + + switch (type) { + case 'word': + let wordOption = assign({},{ + type: 'normal', + autoColors: true + },opts.extra.word); + if(opts.updateData==true || opts.updateData==undefined){ + opts.chartData.wordCloudData=getWordCloudPoint(opts,wordOption.type); + } + this.animationInstance = new Animation({ + timing: 'easeInOut', + duration: duration, + onProcess: function(process) { + context.clearRect(0, 0, opts.width, opts.height); + if (opts.rotate) { + contextRotate(context, opts); + } + drawWordCloudDataPoints(series, opts, config, context,process); + drawCanvas(opts, context); + }, + onAnimationFinish: function onAnimationFinish() { + _this.event.trigger('renderComplete'); + } + }); + break; + case 'map': + context.clearRect(0, 0, opts.width, opts.height); + drawMapDataPoints(series, opts, config, context); + break; + case 'funnel': + this.animationInstance = new Animation({ + timing: 'easeInOut', + duration: duration, + onProcess: function(process) { + context.clearRect(0, 0, opts.width, opts.height); + if (opts.rotate) { + contextRotate(context, opts); + } + opts.chartData.funnelData = drawFunnelDataPoints(series, opts, config, context, process); + drawLegend(opts.series, opts, config, context, opts.chartData); + drawToolTipBridge(opts, config, context, process); + drawCanvas(opts, context); + }, + onAnimationFinish: function onAnimationFinish() { + _this.event.trigger('renderComplete'); + } + }); + break; + case 'line': + this.animationInstance = new Animation({ + timing: 'easeIn', + duration: duration, + onProcess: function onProcess(process) { + context.clearRect(0, 0, opts.width, opts.height); + if (opts.rotate) { + contextRotate(context, opts); + } + drawYAxisGrid(categories, opts, config, context); + drawXAxis(categories, opts, config, context); + var _drawLineDataPoints = drawLineDataPoints(series, opts, config, context, process), + xAxisPoints = _drawLineDataPoints.xAxisPoints, + calPoints = _drawLineDataPoints.calPoints, + eachSpacing = _drawLineDataPoints.eachSpacing; + opts.chartData.xAxisPoints = xAxisPoints; + opts.chartData.calPoints = calPoints; + opts.chartData.eachSpacing = eachSpacing; + drawYAxis(series, opts, config, context); + if (opts.enableMarkLine !== false && process === 1) { + drawMarkLine(opts, config, context); + } + drawLegend(opts.series, opts, config, context, opts.chartData); + drawToolTipBridge(opts, config, context, process, eachSpacing, xAxisPoints); + drawCanvas(opts, context); + + }, + onAnimationFinish: function onAnimationFinish() { + _this.event.trigger('renderComplete'); + } + }); + break; + case 'mix': + this.animationInstance = new Animation({ + timing: 'easeIn', + duration: duration, + onProcess: function onProcess(process) { + context.clearRect(0, 0, opts.width, opts.height); + if (opts.rotate) { + contextRotate(context, opts); + } + drawYAxisGrid(categories, opts, config, context); + drawXAxis(categories, opts, config, context); + var _drawMixDataPoints = drawMixDataPoints(series, opts, config, context, process), + xAxisPoints = _drawMixDataPoints.xAxisPoints, + calPoints = _drawMixDataPoints.calPoints, + eachSpacing = _drawMixDataPoints.eachSpacing; + opts.chartData.xAxisPoints = xAxisPoints; + opts.chartData.calPoints = calPoints; + opts.chartData.eachSpacing = eachSpacing; + drawYAxis(series, opts, config, context); + if (opts.enableMarkLine !== false && process === 1) { + drawMarkLine(opts, config, context); + } + drawLegend(opts.series, opts, config, context, opts.chartData); + drawToolTipBridge(opts, config, context, process, eachSpacing, xAxisPoints); + drawCanvas(opts, context); + }, + onAnimationFinish: function onAnimationFinish() { + _this.event.trigger('renderComplete'); + } + }); + break; + case 'column': + this.animationInstance = new Animation({ + timing: 'easeIn', + duration: duration, + onProcess: function onProcess(process) { + context.clearRect(0, 0, opts.width, opts.height); + if (opts.rotate) { + contextRotate(context, opts); + } + drawYAxisGrid(categories, opts, config, context); + drawXAxis(categories, opts, config, context); + var _drawColumnDataPoints = drawColumnDataPoints(series, opts, config, context, process), + xAxisPoints = _drawColumnDataPoints.xAxisPoints, + calPoints = _drawColumnDataPoints.calPoints, + eachSpacing = _drawColumnDataPoints.eachSpacing; + opts.chartData.xAxisPoints = xAxisPoints; + opts.chartData.calPoints = calPoints; + opts.chartData.eachSpacing = eachSpacing; + drawYAxis(series, opts, config, context); + if (opts.enableMarkLine !== false && process === 1) { + drawMarkLine(opts, config, context); + } + drawLegend(opts.series, opts, config, context, opts.chartData); + drawToolTipBridge(opts, config, context, process, eachSpacing, xAxisPoints); + drawCanvas(opts, context); + }, + onAnimationFinish: function onAnimationFinish() { + _this.event.trigger('renderComplete'); + } + }); + break; + case 'area': + this.animationInstance = new Animation({ + timing: 'easeIn', + duration: duration, + onProcess: function onProcess(process) { + context.clearRect(0, 0, opts.width, opts.height); + if (opts.rotate) { + contextRotate(context, opts); + } + drawYAxisGrid(categories, opts, config, context); + drawXAxis(categories, opts, config, context); + var _drawAreaDataPoints = drawAreaDataPoints(series, opts, config, context, process), + xAxisPoints = _drawAreaDataPoints.xAxisPoints, + calPoints = _drawAreaDataPoints.calPoints, + eachSpacing = _drawAreaDataPoints.eachSpacing; + opts.chartData.xAxisPoints = xAxisPoints; + opts.chartData.calPoints = calPoints; + opts.chartData.eachSpacing = eachSpacing; + drawYAxis(series, opts, config, context); + if (opts.enableMarkLine !== false && process === 1) { + drawMarkLine(opts, config, context); + } + drawLegend(opts.series, opts, config, context, opts.chartData); + drawToolTipBridge(opts, config, context, process, eachSpacing, xAxisPoints); + drawCanvas(opts, context); + }, + onAnimationFinish: function onAnimationFinish() { + _this.event.trigger('renderComplete'); + } + }); + break; + case 'ring': + case 'pie': + this.animationInstance = new Animation({ + timing: 'easeInOut', + duration: duration, + onProcess: function onProcess(process) { + context.clearRect(0, 0, opts.width, opts.height); + if (opts.rotate) { + contextRotate(context, opts); + } + opts.chartData.pieData = drawPieDataPoints(series, opts, config, context, process); + drawLegend(opts.series, opts, config, context, opts.chartData); + drawToolTipBridge(opts, config, context, process); + drawCanvas(opts, context); + }, + onAnimationFinish: function onAnimationFinish() { + _this.event.trigger('renderComplete'); + } + }); + break; + case 'rose': + this.animationInstance = new Animation({ + timing: 'easeInOut', + duration: duration, + onProcess: function onProcess(process) { + context.clearRect(0, 0, opts.width, opts.height); + if (opts.rotate) { + contextRotate(context, opts); + } + opts.chartData.pieData = drawRoseDataPoints(series, opts, config, context, process); + drawLegend(opts.series, opts, config, context, opts.chartData); + drawToolTipBridge(opts, config, context, process); + drawCanvas(opts, context); + }, + onAnimationFinish: function onAnimationFinish() { + _this.event.trigger('renderComplete'); + } + }); + break; + case 'radar': + this.animationInstance = new Animation({ + timing: 'easeInOut', + duration: duration, + onProcess: function onProcess(process) { + context.clearRect(0, 0, opts.width, opts.height); + if (opts.rotate) { + contextRotate(context, opts); + } + opts.chartData.radarData = drawRadarDataPoints(series, opts, config, context, process); + drawLegend(opts.series, opts, config, context, opts.chartData); + drawToolTipBridge(opts, config, context, process); + drawCanvas(opts, context); + }, + onAnimationFinish: function onAnimationFinish() { + _this.event.trigger('renderComplete'); + } + }); + break; + case 'arcbar': + this.animationInstance = new Animation({ + timing: 'easeInOut', + duration: duration, + onProcess: function onProcess(process) { + context.clearRect(0, 0, opts.width, opts.height); + if (opts.rotate) { + contextRotate(context, opts); + } + opts.chartData.arcbarData = drawArcbarDataPoints(series, opts, config, context, process); + drawCanvas(opts, context); + }, + onAnimationFinish: function onAnimationFinish() { + _this.event.trigger('renderComplete'); + } + }); + break; + case 'gauge': + this.animationInstance = new Animation({ + timing: 'easeInOut', + duration: duration, + onProcess: function onProcess(process) { + context.clearRect(0, 0, opts.width, opts.height); + if (opts.rotate) { + contextRotate(context, opts); + } + opts.chartData.gaugeData = drawGaugeDataPoints(categories, series, opts, config, context, process); + drawCanvas(opts, context); + }, + onAnimationFinish: function onAnimationFinish() { + _this.event.trigger('renderComplete'); + } + }); + break; + case 'candle': + this.animationInstance = new Animation({ + timing: 'easeIn', + duration: duration, + onProcess: function onProcess(process) { + context.clearRect(0, 0, opts.width, opts.height); + if (opts.rotate) { + contextRotate(context, opts); + } + drawYAxisGrid(categories, opts, config, context); + drawXAxis(categories, opts, config, context); + var _drawCandleDataPoints = drawCandleDataPoints(series, seriesMA, opts, config, context, process), + xAxisPoints = _drawCandleDataPoints.xAxisPoints, + calPoints = _drawCandleDataPoints.calPoints, + eachSpacing = _drawCandleDataPoints.eachSpacing; + opts.chartData.xAxisPoints = xAxisPoints; + opts.chartData.calPoints = calPoints; + opts.chartData.eachSpacing = eachSpacing; + drawYAxis(series, opts, config, context); + if (opts.enableMarkLine !== false && process === 1) { + drawMarkLine(opts, config, context); + } + if (seriesMA) { + drawLegend(seriesMA, opts, config, context, opts.chartData); + } else { + drawLegend(opts.series, opts, config, context, opts.chartData); + } + drawToolTipBridge(opts, config, context, process, eachSpacing, xAxisPoints); + drawCanvas(opts, context); + }, + onAnimationFinish: function onAnimationFinish() { + _this.event.trigger('renderComplete'); + } + }); + break; + } +} + +// simple event implement + +function Event() { + this.events = {}; +} + +Event.prototype.addEventListener = function(type, listener) { + this.events[type] = this.events[type] || []; + this.events[type].push(listener); +}; + +Event.prototype.trigger = function() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var type = args[0]; + var params = args.slice(1); + if (!!this.events[type]) { + this.events[type].forEach(function(listener) { + try { + listener.apply(null, params); + } catch (e) { + console.error(e); + } + }); + } +}; + +var Charts = function Charts(opts) { + opts.pixelRatio = opts.pixelRatio ? opts.pixelRatio : 1; + opts.fontSize = opts.fontSize ? opts.fontSize * opts.pixelRatio : 13 * opts.pixelRatio; + opts.title = assign({}, opts.title); + opts.subtitle = assign({}, opts.subtitle); + opts.duration = opts.duration ? opts.duration : 1000; + opts.yAxis = assign({}, { + data:[], + showTitle:false, + disabled:false, + disableGrid:false, + splitNumber:5, + gridType: 'solid', + dashLength: 4 * opts.pixelRatio, + gridColor:'#cccccc', + padding:10, + fontColor:'#666666' + }, opts.yAxis); + opts.yAxis.dashLength *= opts.pixelRatio; + opts.yAxis.padding *= opts.pixelRatio; + opts.xAxis = assign({}, { + rotateLabel: false, + type: 'calibration', + gridType: 'solid', + dashLength: 4, + scrollAlign: 'left', + boundaryGap:'center', + axisLine:true, + axisLineColor:'#cccccc' + }, opts.xAxis); + opts.xAxis.dashLength *= opts.pixelRatio; + opts.legend = assign({}, { + show: true, + position: 'bottom', + float: 'center', + backgroundColor: 'rgba(0,0,0,0)', + borderColor: 'rgba(0,0,0,0)', + borderWidth: 0, + padding: 5, + margin: 5, + itemGap: 10, + fontSize: opts.fontSize, + lineHeight: opts.fontSize, + fontColor: '#333333', + format: {}, + hiddenColor: '#CECECE' + }, opts.legend); + opts.legend.borderWidth = opts.legend.borderWidth * opts.pixelRatio; + opts.legend.itemGap = opts.legend.itemGap * opts.pixelRatio; + opts.legend.padding = opts.legend.padding * opts.pixelRatio; + opts.legend.margin = opts.legend.margin * opts.pixelRatio; + opts.extra = assign({}, opts.extra); + opts.rotate = opts.rotate ? true : false; + opts.animation = opts.animation ? true : false; + opts.rotate = opts.rotate ? true : false; + + let config$$1 = JSON.parse(JSON.stringify(config)); + config$$1.colors = opts.colors ? opts.colors : config$$1.colors; + config$$1.yAxisTitleWidth = opts.yAxis.disabled !== true && opts.yAxis.title ? config$$1.yAxisTitleWidth : 0; + if (opts.type == 'pie' || opts.type == 'ring') { + config$$1.pieChartLinePadding = opts.dataLabel === false ? 0 : opts.extra.pie.labelWidth * opts.pixelRatio || config$$1.pieChartLinePadding * opts.pixelRatio; + } + if (opts.type == 'rose') { + config$$1.pieChartLinePadding = opts.dataLabel === false ? 0 : opts.extra.rose.labelWidth * opts.pixelRatio || config$$1.pieChartLinePadding * opts.pixelRatio; + } + config$$1.pieChartTextPadding = opts.dataLabel === false ? 0 : config$$1.pieChartTextPadding * opts.pixelRatio; + config$$1.yAxisSplit = opts.yAxis.splitNumber ? opts.yAxis.splitNumber : config.yAxisSplit; + + //屏幕旋转 + config$$1.rotate = opts.rotate; + if (opts.rotate) { + let tempWidth = opts.width; + let tempHeight = opts.height; + opts.width = tempHeight; + opts.height = tempWidth; + } + + //适配高分屏 + opts.padding = opts.padding ? opts.padding : config$$1.padding; + for (let i = 0; i < 4; i++) { + opts.padding[i] *= opts.pixelRatio; + } + config$$1.yAxisWidth = config.yAxisWidth * opts.pixelRatio; + config$$1.xAxisHeight = config.xAxisHeight * opts.pixelRatio; + if (opts.enableScroll && opts.xAxis.scrollShow) { + config$$1.xAxisHeight += 6 * opts.pixelRatio; + } + config$$1.xAxisLineHeight = config.xAxisLineHeight * opts.pixelRatio; + config$$1.fontSize = opts.fontSize; + config$$1.titleFontSize = config.titleFontSize * opts.pixelRatio; + config$$1.subtitleFontSize = config.subtitleFontSize * opts.pixelRatio; + config$$1.toolTipPadding = config.toolTipPadding * opts.pixelRatio; + config$$1.toolTipLineHeight = config.toolTipLineHeight * opts.pixelRatio; + config$$1.columePadding = config.columePadding * opts.pixelRatio; + opts.$this = opts.$this ? opts.$this : this; + + this.context = wx.createCanvasContext(opts.canvasId, opts.$this); + /* 兼容原生H5 + this.context = document.getElementById(opts.canvasId).getContext("2d"); + this.context.setStrokeStyle = function(e){ return this.strokeStyle=e; } + this.context.setLineWidth = function(e){ return this.lineWidth=e; } + this.context.setLineCap = function(e){ return this.lineCap=e; } + this.context.setFontSize = function(e){ return this.font=e+"px sans-serif"; } + this.context.setFillStyle = function(e){ return this.fillStyle=e; } + this.context.draw = function(){ } + */ + + opts.chartData = {}; + this.event = new Event(); + this.scrollOption = { + currentOffset: 0, + startTouchX: 0, + distance: 0, + lastMoveTime: 0 + }; + + this.opts = opts; + this.config = config$$1; + + drawCharts.call(this, opts.type, opts, config$$1, this.context); +}; + +Charts.prototype.updateData = function() { + let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + this.opts = assign({}, this.opts, data); + this.opts.updateData = true; + let scrollPosition = data.scrollPosition || 'current'; + switch (scrollPosition) { + case 'current': + this.opts._scrollDistance_ = this.scrollOption.currentOffset; + break; + case 'left': + this.opts._scrollDistance_ = 0; + this.scrollOption = { + currentOffset: 0, + startTouchX: 0, + distance: 0, + lastMoveTime: 0 + }; + break; + case 'right': + let _calYAxisData = calYAxisData(this.opts.series, this.opts, this.config), + yAxisWidth = _calYAxisData.yAxisWidth; + this.config.yAxisWidth = yAxisWidth; + let offsetLeft = 0; + let _getXAxisPoints0 = getXAxisPoints(this.opts.categories, this.opts, this.config), + xAxisPoints = _getXAxisPoints0.xAxisPoints, + startX = _getXAxisPoints0.startX, + endX = _getXAxisPoints0.endX, + eachSpacing = _getXAxisPoints0.eachSpacing; + let totalWidth = eachSpacing * (xAxisPoints.length - 1); + let screenWidth = endX - startX; + offsetLeft = screenWidth - totalWidth; + this.scrollOption = { + currentOffset: offsetLeft, + startTouchX: offsetLeft, + distance: 0, + lastMoveTime: 0 + }; + this.opts._scrollDistance_ = offsetLeft; + break; + } + drawCharts.call(this, this.opts.type, this.opts, this.config, this.context); +}; + +Charts.prototype.zoom = function() { + var val = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.opts.xAxis.itemCount; + if (this.opts.enableScroll !== true) { + console.log('请启用滚动条后使用!') + return; + } + //当前屏幕中间点 + let centerPoint = Math.round(Math.abs(this.scrollOption.currentOffset) / this.opts.chartData.eachSpacing) + Math.round( + this.opts.xAxis.itemCount / 2); + this.opts.animation = false; + this.opts.xAxis.itemCount = val.itemCount; + //重新计算x轴偏移距离 + let _calYAxisData = calYAxisData(this.opts.series, this.opts, this.config), + yAxisWidth = _calYAxisData.yAxisWidth; + this.config.yAxisWidth = yAxisWidth; + let offsetLeft = 0; + let _getXAxisPoints0 = getXAxisPoints(this.opts.categories, this.opts, this.config), + xAxisPoints = _getXAxisPoints0.xAxisPoints, + startX = _getXAxisPoints0.startX, + endX = _getXAxisPoints0.endX, + eachSpacing = _getXAxisPoints0.eachSpacing; + let centerLeft = eachSpacing * centerPoint; + let screenWidth = endX - startX; + let MaxLeft = screenWidth - eachSpacing * (xAxisPoints.length - 1); + offsetLeft = screenWidth / 2 - centerLeft; + if (offsetLeft > 0) { + offsetLeft = 0; + } + if (offsetLeft < MaxLeft) { + offsetLeft = MaxLeft; + } + this.scrollOption = { + currentOffset: offsetLeft, + startTouchX: offsetLeft, + distance: 0, + lastMoveTime: 0 + }; + this.opts._scrollDistance_ = offsetLeft; + drawCharts.call(this, this.opts.type, this.opts, this.config, this.context); +}; + +Charts.prototype.stopAnimation = function() { + this.animationInstance && this.animationInstance.stop(); +}; + +Charts.prototype.addEventListener = function(type, listener) { + this.event.addEventListener(type, listener); +}; + +Charts.prototype.getCurrentDataIndex = function(e) { + var touches = null; + if (e.changedTouches) { + touches = e.changedTouches[0]; + } else { + touches = e.mp.changedTouches[0]; + } + if (touches) { + let _touches$ = getTouches(touches, this.opts, e); + if (this.opts.type === 'pie' || this.opts.type === 'ring' || this.opts.type === 'rose') { + return findPieChartCurrentIndex({ + x: _touches$.x, + y: _touches$.y + }, this.opts.chartData.pieData); + } else if (this.opts.type === 'radar') { + return findRadarChartCurrentIndex({ + x: _touches$.x, + y: _touches$.y + }, this.opts.chartData.radarData, this.opts.categories.length); + } else if (this.opts.type === 'funnel') { + return findFunnelChartCurrentIndex({ + x: _touches$.x, + y: _touches$.y + }, this.opts.chartData.funnelData); + } else if (this.opts.type === 'map') { + return findMapChartCurrentIndex({ + x: _touches$.x, + y: _touches$.y + }, this.opts); + }else if (this.opts.type === 'word') { + return findWordChartCurrentIndex({ + x: _touches$.x, + y: _touches$.y + }, this.opts.chartData.wordCloudData); + } else { + return findCurrentIndex({ + x: _touches$.x, + y: _touches$.y + }, this.opts.chartData.calPoints, this.opts, this.config, Math.abs(this.scrollOption.currentOffset)); + } + } + return -1; +}; + +Charts.prototype.getLegendDataIndex = function(e) { + var touches = null; + if (e.changedTouches) { + touches = e.changedTouches[0]; + } else { + touches = e.mp.changedTouches[0]; + } + if (touches) { + let _touches$ = getTouches(touches, this.opts, e); + return findLegendIndex({ + x: _touches$.x, + y: _touches$.y + }, this.opts.chartData.legendData); + } + return -1; +}; + +Charts.prototype.touchLegend = function(e) { + var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + var touches = null; + if (e.changedTouches) { + touches = e.changedTouches[0]; + } else { + touches = e.mp.changedTouches[0]; + } + if (touches) { + var _touches$ = getTouches(touches, this.opts, e); + var index = this.getLegendDataIndex(e); + if (index >= 0) { + this.opts.series[index].show = !this.opts.series[index].show; + this.opts.animation = option.animation ? true : false; + this.opts._scrollDistance_= this.scrollOption.currentOffset; + drawCharts.call(this, this.opts.type, this.opts, this.config, this.context); + } + } + +}; + +Charts.prototype.showToolTip = function(e) { + var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + var touches = null; + if (e.changedTouches) { + touches = e.changedTouches[0]; + } else { + touches = e.mp.changedTouches[0]; + } + if (!touches) { + console.log("touchError"); + } + var _touches$ = getTouches(touches, this.opts, e); + var currentOffset = this.scrollOption.currentOffset; + var opts = assign({}, this.opts, { + _scrollDistance_: currentOffset, + animation: false + }); + if (this.opts.type === 'line' || this.opts.type === 'area' || this.opts.type === 'column') { + var index = option.index==undefined? this.getCurrentDataIndex(e):option.index ; + if (index > -1) { + var seriesData = getSeriesDataItem(this.opts.series, index); + if (seriesData.length !== 0) { + var _getToolTipData = getToolTipData(seriesData, this.opts.chartData.calPoints, index, this.opts.categories,option), + textList = _getToolTipData.textList, + offset = _getToolTipData.offset; + offset.y = _touches$.y; + opts.tooltip = { + textList: option.textList?option.textList:textList, + offset: offset, + option: option, + index: index + }; + } + } + drawCharts.call(this, opts.type, opts, this.config, this.context); + } + if (this.opts.type === 'mix') { + var index = option.index==undefined? this.getCurrentDataIndex(e):option.index ; + if (index > -1) { + var currentOffset = this.scrollOption.currentOffset; + var opts = assign({}, this.opts, { + _scrollDistance_: currentOffset, + animation: false + }); + var seriesData = getSeriesDataItem(this.opts.series, index); + if (seriesData.length !== 0) { + var _getMixToolTipData = getMixToolTipData(seriesData, this.opts.chartData.calPoints, index, this.opts.categories,option), + textList = _getMixToolTipData.textList, + offset = _getMixToolTipData.offset; + offset.y = _touches$.y; + opts.tooltip = { + textList: option.textList?option.textList:textList, + offset: offset, + option: option, + index: index + }; + } + } + drawCharts.call(this, opts.type, opts, this.config, this.context); + } + if (this.opts.type === 'candle') { + var index = option.index==undefined? this.getCurrentDataIndex(e):option.index ; + if (index > -1) { + var currentOffset = this.scrollOption.currentOffset; + var opts = assign({}, this.opts, { + _scrollDistance_: currentOffset, + animation: false + }); + var seriesData = getSeriesDataItem(this.opts.series, index); + if (seriesData.length !== 0) { + var _getToolTipData = getCandleToolTipData(this.opts.series[0].data, seriesData, this.opts.chartData.calPoints, + index, this.opts.categories, this.opts.extra.candle, option), + textList = _getToolTipData.textList, + offset = _getToolTipData.offset; + offset.y = _touches$.y; + opts.tooltip = { + textList: option.textList?option.textList:textList, + offset: offset, + option: option, + index: index + }; + } + } + drawCharts.call(this, opts.type, opts, this.config, this.context); + } + if (this.opts.type === 'pie' || this.opts.type === 'ring' || this.opts.type === 'rose'||this.opts.type === 'funnel' ) { + var index = option.index==undefined? this.getCurrentDataIndex(e):option.index ; + if (index > -1) { + var currentOffset = this.scrollOption.currentOffset; + var opts = assign({}, this.opts, { + _scrollDistance_: currentOffset, + animation: false + }); + var seriesData = this.opts._series_[index]; + var textList = [{ + text: option.format ? option.format(seriesData) : seriesData.name + ': ' + seriesData.data, + color: seriesData.color + }]; + var offset = { + x: _touches$.x, + y: _touches$.y + }; + opts.tooltip = { + textList: option.textList?option.textList:textList, + offset: offset, + option: option, + index: index + }; + } + drawCharts.call(this, opts.type, opts, this.config, this.context); + } + if (this.opts.type === 'map'||this.opts.type === 'word') { + var index = option.index==undefined? this.getCurrentDataIndex(e):option.index ; + if (index > -1) { + var currentOffset = this.scrollOption.currentOffset; + var opts = assign({}, this.opts, { + _scrollDistance_: currentOffset, + animation: false + }); + var seriesData = this.opts._series_[index]; + var textList = [{ + text: option.format ? option.format(seriesData) : seriesData.properties.name , + color: seriesData.color + }]; + var offset = { + x: _touches$.x, + y: _touches$.y + }; + opts.tooltip = { + textList: option.textList?option.textList:textList, + offset: offset, + option: option, + index: index + }; + } + opts.updateData = false; + drawCharts.call(this, opts.type, opts, this.config, this.context); + } + if (this.opts.type === 'radar') { + var index = option.index==undefined? this.getCurrentDataIndex(e):option.index ; + if (index > -1) { + var currentOffset = this.scrollOption.currentOffset; + var opts = assign({}, this.opts, { + _scrollDistance_: currentOffset, + animation: false + }); + var seriesData = getSeriesDataItem(this.opts.series, index); + if (seriesData.length !== 0) { + var textList = seriesData.map(function(item) { + return { + text: option.format ? option.format(item) : item.name + ': ' + item.data, + color: item.color + }; + }); + var offset = { + x: _touches$.x, + y: _touches$.y + }; + opts.tooltip = { + textList: option.textList?option.textList:textList, + offset: offset, + option: option, + index: index + }; + } + } + drawCharts.call(this, opts.type, opts, this.config, this.context); + } +}; + +Charts.prototype.translate = function(distance) { + this.scrollOption = { + currentOffset: distance, + startTouchX: distance, + distance: 0, + lastMoveTime: 0 + }; + let opts = assign({}, this.opts, { + _scrollDistance_: distance, + animation: false + }); + drawCharts.call(this, this.opts.type, opts, this.config, this.context); +}; + +Charts.prototype.scrollStart = function(e) { + var touches = null; + if (e.changedTouches) { + touches = e.changedTouches[0]; + } else { + touches = e.mp.changedTouches[0]; + } + var _touches$ = getTouches(touches, this.opts, e); + if (touches && this.opts.enableScroll === true) { + this.scrollOption.startTouchX = _touches$.x; + } +}; + +Charts.prototype.scroll = function(e) { + if (this.scrollOption.lastMoveTime === 0) { + this.scrollOption.lastMoveTime = Date.now(); + } + let Limit = this.opts.extra.touchMoveLimit || 20; + let currMoveTime = Date.now(); + let duration = currMoveTime - this.scrollOption.lastMoveTime; + if (duration < Math.floor(1000 / Limit)) return; + this.scrollOption.lastMoveTime = currMoveTime; + var touches = null; + if (e.changedTouches) { + touches = e.changedTouches[0]; + } else { + touches = e.mp.changedTouches[0]; + } + if (touches && this.opts.enableScroll === true) { + var _touches$ = getTouches(touches, this.opts, e); + var _distance; + _distance = _touches$.x - this.scrollOption.startTouchX; + var currentOffset = this.scrollOption.currentOffset; + var validDistance = calValidDistance(this,currentOffset + _distance, this.opts.chartData, this.config, this.opts); + this.scrollOption.distance = _distance = validDistance - currentOffset; + var opts = assign({}, this.opts, { + _scrollDistance_: currentOffset + _distance, + animation: false + }); + drawCharts.call(this, opts.type, opts, this.config, this.context); + return currentOffset + _distance; + } +}; + +Charts.prototype.scrollEnd = function(e) { + if (this.opts.enableScroll === true) { + var _scrollOption = this.scrollOption, + currentOffset = _scrollOption.currentOffset, + distance = _scrollOption.distance; + this.scrollOption.currentOffset = currentOffset + distance; + this.scrollOption.distance = 0; + } +}; +if (typeof module === "object" && typeof module.exports === "object") { + module.exports = Charts; + //export default Charts;//建议使用nodejs的module导出方式,如报错请使用export方式导出 +} diff --git a/miniprogram/utils/util.js b/miniprogram/utils/util.js new file mode 100644 index 0000000..66caaa2 --- /dev/null +++ b/miniprogram/utils/util.js @@ -0,0 +1,42 @@ +const formatTime = date => { + const year = date.getFullYear() + const month = date.getMonth() + 1 + const day = date.getDate() + const hour = date.getHours() + const minute = date.getMinutes() + const second = date.getSeconds() + + return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':') +} + +const formatNumber = n => { + n = n.toString() + return n[1] ? n : '0' + n +} + + +// 显示繁忙提示 +var showBusy = text => wx.showToast({ + title: text, + icon: 'loading', + duration: 10000 +}) + +// 显示成功提示 +var showSuccess = text => wx.showToast({ + title: text, + icon: 'success' +}) + +// 显示失败提示 +var showModel = (title, content) => { + wx.hideToast(); + + wx.showModal({ + title, + content: JSON.stringify(content), + showCancel: false + }) +} + +module.exports = { formatTime, showBusy, showSuccess, showModel } diff --git a/miniprogram/vendor/wafer2-client-sdk/LICENSE b/miniprogram/vendor/wafer2-client-sdk/LICENSE new file mode 100644 index 0000000..7bb43b8 --- /dev/null +++ b/miniprogram/vendor/wafer2-client-sdk/LICENSE @@ -0,0 +1,24 @@ +LICENSE - "MIT License" + +Copyright (c) 2016 by Tencent Cloud + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/miniprogram/vendor/wafer2-client-sdk/README.md b/miniprogram/vendor/wafer2-client-sdk/README.md new file mode 100644 index 0000000..ac48138 --- /dev/null +++ b/miniprogram/vendor/wafer2-client-sdk/README.md @@ -0,0 +1,247 @@ +# 微信小程序客户端腾讯云增强 SDK + +[![Build Status](https://travis-ci.org/tencentyun/wafer-client-sdk.svg?branch=master)](https://travis-ci.org/tencentyun/wafer-client-sdk) +[![Coverage Status](https://coveralls.io/repos/github/tencentyun/wafer-client-sdk/badge.svg?branch=master)](https://coveralls.io/github/tencentyun/wafer-client-sdk?branch=master) +[![License](https://img.shields.io/github/license/tencentyun/wafer-client-sdk.svg)](LICENSE) + +本 项目是 [Wafer](https://github.com/tencentyun/wafer-solution) 的组成部分,为小程序客户端开发提供 SDK 支持会话服务和信道服务。 + +## SDK 获取与安装 + +解决方案[客户端 Demo](https://github.com/tencentyun/wafer-client-demo) 已经集成并使用最新版的 SDK,需要快速了解的可以从 Demo 开始。 + +如果需要单独开始,本 SDK 已经发布为 bower 模块,可以直接安装到小程序目录中。 + +```sh +npm install -g bower +bower install qcloud-weapp-client-sdk +``` + +安装之后,就可以使用 `require` 引用 SDK 模块: + +```js +var qcloud = require('./bower_components/qcloud-weapp-client-sdk/index.js'); +``` + +## 会话服务 + +[会话服务](https://github.com/tencentyun/wafer-solution/wiki/%E4%BC%9A%E8%AF%9D%E6%9C%8D%E5%8A%A1)让小程序拥有会话管理能力。 + +### 登录 + +登录可以在小程序和服务器之间建立会话,服务器由此可以获取到用户的标识和信息。 + +```js +var qcloud = require('./bower_components/qcloud-weapp-client-sdk/index.js'); + +// 设置登录地址 +qcloud.setLoginUrl('https://199447.qcloud.la/login'); +qcloud.login({ + success: function (userInfo) { + console.log('登录成功', userInfo); + }, + fail: function (err) { + console.log('登录失败', err); + } +}); +``` +本 SDK 需要配合云端 SDK 才能提供完整会话服务。通过 [setLoginUrl](#setLoginUrl) 设置登录地址,云服务器在该地址上使用云端 SDK 处理登录请求。 + +> `setLoginUrl` 方法设置登录地址之后会一直有效,因此你可以在微信小程序启动时设置。 + +登录成功后,可以获取到当前微信用户的基本信息。 + +### 请求 + +如果希望小程序的网络请求包含会话,登录之后使用 [request](#request) 方法进行网络请求即可。 + +```js +qcloud.request({ + url: 'http://199447.qcloud.la/user', + success: function (response) { + console.log(response); + }, + fail: function (err) { + console.log(err); + } +}); +``` + +如果调用 `request` 之前还没有登录,则请求不会带有会话。`request` 方法也支持 `login` 参数支持在请求之前自动登录。 + +```js +// 使用 login 参数之前,需要设置登录地址 +qcloud.setLoginUrl('https://199447.qcloud.la/login'); +qcloud.request({ + login: true, + url: 'http://199447.qcloud.la/user', + success: function (response) { + console.log(response); + }, + fail: function (err) { + console.log(err); + } +}); +``` + +关于会话服务详细技术说明,请参考 [Wiki](https://github.com/tencentyun/wafer-solution/wiki/%E4%BC%9A%E8%AF%9D%E6%9C%8D%E5%8A%A1)。 + +## 信道服务 + +[信道服务](https://github.com/tencentyun/wafer-solution/wiki/%E4%BF%A1%E9%81%93%E6%9C%8D%E5%8A%A1)小程序支持利用腾讯云的信道资源使用 WebSocket 服务。 + +```js +// 创建信道,需要给定后台服务地址 +var tunnel = this.tunnel = new qcloud.Tunnel('https://199447.qcloud.la/tunnel'); + +// 监听信道内置消息,包括 connect/close/reconnecting/reconnect/error +tunnel.on('connect', () => console.log('WebSocket 信道已连接')); +tunnel.on('close', () => console.log('WebSocket 信道已断开')); +tunnel.on('reconnecting', () => console.log('WebSocket 信道正在重连...')); +tunnel.on('reconnect', () => console.log('WebSocket 信道重连成功')); +tunnel.on('error', error => console.error('信道发生错误:', error)); + +// 监听自定义消息(服务器进行推送) +tunnel.on('speak', speak => console.log('收到 speak 消息:', speak)); + +// 打开信道 +tunnel.open(); +// 发送消息 +tunnel.emit('speak', { word: "hello", who: { nickName: "techird" }}); +// 关闭信道 +tunnel.close(); +``` + +信道服务同样需要业务服务器配合云端 SDK 支持,构造信道实例的时候需要提供业务服务器提供的信道服务地址。通过监听信道消息以及自定义消息来通过信道实现业务。 + +关于信道使用的更完整实例,建议参考客户端 Demo 中的[三木聊天室应用源码](https://github.com/tencentyun/wafer-client-demo/blob/master/pages/chat/chat.js)。 + +关于信道服务详细技术说明,请参考 [Wiki](https://github.com/tencentyun/wafer-solution/wiki/%E4%BF%A1%E9%81%93%E6%9C%8D%E5%8A%A1)。 + +## API + + +### setLoginUrl +设置会话服务登录地址。 + +#### 语法 +```js +qcloud.setLoginUrl(loginUrl); +``` + +#### 参数 +|参数         |类型 |说明 +|-------------|---------------|-------------- +|loginUrl |string |会话服务登录地址 + +### login +登录,建立微信小程序会话。 + +#### 语法 +```js +qcloud.login(options); +``` + +#### 参数 +|参数         |类型 |说明 +|-------------|---------------|-------------- +|options     |PlainObject   |会话服务登录地址 +|options.success | () => void | 登录成功的回调 +|options.error | (error) => void | 登录失败的回调 + + +### request +进行带会话的请求。 + +#### 语法 +```js +qcloud.request(options); +``` + +#### 参数 +|参数         |类型 |说明 +|-------------|---------------|-------------- +|options     |PlainObject   | 会话服务登录地址 +|options.login | bool         | 是否自动登录以获取会话,默认为 false +|options.url   | string       | 必填,要请求的地址 +|options.header | PlainObject | 请求头设置,不允许设置 Referer +|options.method | string     | 请求的方法,默认为 GET +|options.success | (response) => void | 登录成功的回调。
  • `response.statusCode`:请求返回的状态码
  • `response.data`:请求返回的数据
+|options.error | (error) => void | 登录失败的回调 +|options.complete | () => void | 登录完成后回调,无论成功还是失败 + +### Tunnel + +表示一个信道。由于小程序的限制,同一时间只能有一个打开的信道。 + +#### constructor + +##### 语法 +```js +var tunnel = new Tunnel(tunnelUrl); +``` + +#### 参数 +|参数         |类型 |说明 +|-------------|---------------|-------------- +|tunnelUrl   |String   | 会话服务登录地址 + + +#### on +监听信道上的事件。信道上事件包括系统事件和服务器推送消息。 + +##### 语法 +```js +tunnel.on(type, listener); +``` + +##### 参数 +|参数         |类型 |说明 +|-------------|---------------|-------------- +|type       |string     | 监听的事件类型 +|listener     |(message?: any) => void | 监听器,具体类型的事件发生时调用监听器。如果是消息,则会有消息内容。 + +##### 事件 +|事件 |说明 +|-------------|------------------------------- +|connect |信道连接成功后回调 +|close |信道关闭后回调 +|reconnecting |信道发生重连时回调 +|reconnected |信道重连成功后回调 +|error |信道发生错误后回调 +|[message]   |信道服务器推送过来的消息类型,如果消息类型和上面内置的时间类型冲突,需要在监听的时候在消息类型前加 `@` +|\*           |监听所有事件和消息,监听器第一个参数接收到时间或消息类型  + +#### open +打开信道,建立连接。由于小程序的限制,同一时间只能有一个打开的信道。 + +##### 语法 +```js +tunnel.open(); +``` + +#### emit +向信道推送消息。 + +##### 语法 +```js +tunnel.emit(type, content); +``` + +##### 参数 +|参数         |类型 |说明 +|-------------|---------------|-------------- +|type       |string       | 要推送的消息的类型 +|content |any | 要推送的消息的内容 + +#### close +关闭信道 + +##### 语法 +```js +tunnel.close(); +``` + +## LICENSE + +[MIT](LICENSE) diff --git a/miniprogram/vendor/wafer2-client-sdk/index.js b/miniprogram/vendor/wafer2-client-sdk/index.js new file mode 100644 index 0000000..d2831a0 --- /dev/null +++ b/miniprogram/vendor/wafer2-client-sdk/index.js @@ -0,0 +1,26 @@ +var constants = require('./lib/constants'); +var login = require('./lib/login'); +var Session = require('./lib/session'); +var request = require('./lib/request'); +var Tunnel = require('./lib/tunnel'); + +var exports = module.exports = { + login: login.login, + loginWithCode: login.loginWithCode, + setLoginUrl: login.setLoginUrl, + + Session, + clearSession: Session.clear, + + request: request.request, + RequestError: request.RequestError, + + Tunnel: Tunnel, +}; + +// 导出错误类型码 +Object.keys(constants).forEach(function (key) { + if (key.indexOf('ERR_') === 0) { + exports[key] = constants[key]; + } +}); \ No newline at end of file diff --git a/miniprogram/vendor/wafer2-client-sdk/lib/constants.js b/miniprogram/vendor/wafer2-client-sdk/lib/constants.js new file mode 100644 index 0000000..b307772 --- /dev/null +++ b/miniprogram/vendor/wafer2-client-sdk/lib/constants.js @@ -0,0 +1,20 @@ +module.exports = { + WX_HEADER_CODE: 'X-WX-Code', + WX_HEADER_ENCRYPTED_DATA: 'X-WX-Encrypted-Data', + WX_HEADER_IV: 'X-WX-IV', + WX_HEADER_ID: 'X-WX-Id', + WX_HEADER_SKEY: 'X-WX-Skey', + + WX_SESSION_MAGIC_ID: 'F2C224D4-2BCE-4C64-AF9F-A6D872000D1A', + + ERR_INVALID_PARAMS: 'ERR_INVALID_PARAMS', + + ERR_WX_LOGIN_FAILED: 'ERR_WX_LOGIN_FAILED', + ERR_WX_GET_USER_INFO: 'ERR_WX_GET_USER_INFO', + ERR_LOGIN_TIMEOUT: 'ERR_LOGIN_TIMEOUT', + ERR_LOGIN_FAILED: 'ERR_LOGIN_FAILED', + ERR_LOGIN_SESSION_NOT_RECEIVED: 'ERR_LOGIN_MISSING_SESSION', + + ERR_SESSION_INVALID: 'ERR_SESSION_INVALID', + ERR_CHECK_LOGIN_FAILED: 'ERR_CHECK_LOGIN_FAILED', +}; \ No newline at end of file diff --git a/miniprogram/vendor/wafer2-client-sdk/lib/login.js b/miniprogram/vendor/wafer2-client-sdk/lib/login.js new file mode 100644 index 0000000..613964a --- /dev/null +++ b/miniprogram/vendor/wafer2-client-sdk/lib/login.js @@ -0,0 +1,167 @@ +/** + * README!!! + * 为了兼容微信修改的登录逻辑 + * 这里对登录的 SDK 进行重构 + * 微信公告:https://developers.weixin.qq.com/blogdetail?action=get_post_info&lang=zh_CN&token=&docid=0000a26e1aca6012e896a517556c01 + */ +var constants = require('./constants'); +var Session = require('./session'); + +/** + * 微信登录,获取 code 和 encryptData + */ +function getWxLoginResult (cb) { + wx.login({ + success (loginResult) { + wx.getUserInfo({ + success (userResult) { + cb(null, { + code: loginResult.code, + encryptedData: userResult.encryptedData, + iv: userResult.iv, + userInfo: userResult.userInfo + }) + }, + fail (userError) { + cb(new Error('获取微信用户信息失败,请检查网络状态'), null) + } + }); + }, + fail (loginError) { + cb(new Error('微信登录失败,请检查网络状态'), null) + } + }) +} + +const noop = function noop() {} +const defaultOptions = { + method: 'GET', + success: noop, + fail: noop, + loginUrl: null, +} + +/** + * @method + * 进行服务器登录,以获得登录会话 + * 受限于微信的限制,本函数需要在 的回调函数中调用 + * 需要先使用