├── .babelrc ├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .postcssrc.js ├── LICENSE ├── README.md ├── build ├── build.js ├── check-versions.js ├── dev-client.js ├── dev-server.js ├── utils.js ├── vue-loader.conf.js ├── webpack.base.conf.js ├── webpack.dev.conf.js └── webpack.prod.conf.js ├── config ├── dev.env.js ├── index.js └── prod.env.js ├── index.html ├── package-lock.json ├── package.json ├── project.config.json ├── screen.gif ├── src ├── App.vue ├── components │ ├── card.vue │ ├── color-selector.vue │ ├── homepage.vue │ ├── like.vue │ └── make.vue ├── main.js ├── pages │ ├── index │ │ ├── index.vue │ │ └── main.js │ └── maker │ │ ├── index.vue │ │ └── main.js └── utils │ └── index.js ├── static ├── .gitkeep ├── assets │ ├── banner.png │ ├── banner2.png │ ├── banner_bak.png │ ├── zan.png │ └── zan2.jpg ├── iview │ ├── action-sheet │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── alert │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── avatar │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── badge │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── base │ │ └── index.js │ ├── button │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── card │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── cell-group │ │ ├── index.js │ │ ├── index.json │ │ └── index.wxml │ ├── cell │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── checkbox-group │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── checkbox │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── col │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── collapse-item │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── collapse │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── count-down │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── divider │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── drawer │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── grid-icon │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── grid-item │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── grid-label │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── grid │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── icon │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── index-item │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── index │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── input-number │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── input │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── load-more │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── message │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── modal │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── notice-bar │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── page │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── panel │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── progress │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── radio-group │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── radio │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── rate │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── row │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── slide │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── spin │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── step │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── steps │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── sticky-item │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── sticky │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── swipeout │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── switch │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── tab-bar-item │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── tab-bar │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── tab │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── tabs │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ ├── tag │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss │ └── toast │ │ ├── index.js │ │ ├── index.json │ │ ├── index.wxml │ │ └── index.wxss └── sdk │ ├── ald-stat-conf.js │ └── ald-stat.js └── 开发笔记.md /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["env", { 4 | "modules": false, 5 | "targets": { 6 | "browsers": ["> 1%", "last 2 versions", "not ie <= 8"] 7 | } 8 | }], 9 | "stage-2" 10 | ], 11 | "plugins": ["transform-runtime"], 12 | "env": { 13 | "test": { 14 | "presets": ["env", "stage-2"], 15 | "plugins": ["istanbul"] 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | build/*.js 2 | config/*.js 3 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | // http://eslint.org/docs/user-guide/configuring 2 | 3 | module.exports = { 4 | root: true, 5 | parser: 'babel-eslint', 6 | parserOptions: { 7 | sourceType: 'module' 8 | }, 9 | env: { 10 | browser: false, 11 | node: true, 12 | es6: true 13 | }, 14 | // https://github.com/standard/standard/blob/master/docs/RULES-en.md 15 | extends: 'standard', 16 | // required to lint *.vue files 17 | plugins: [ 18 | 'html' 19 | ], 20 | // add your custom rules here 21 | 'rules': { 22 | // allow paren-less arrow functions 23 | 'arrow-parens': 0, 24 | // allow async-await 25 | 'generator-star-spacing': 0, 26 | // allow debugger during development 27 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0 28 | }, 29 | globals: { 30 | App: true, 31 | Page: true, 32 | wx: true, 33 | getApp: true, 34 | getPage: true, 35 | requirePlugin: true 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | dist/ 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Editor directories and files 9 | .idea 10 | *.suo 11 | *.ntvs* 12 | *.njsproj 13 | *.sln 14 | -------------------------------------------------------------------------------- /.postcssrc.js: -------------------------------------------------------------------------------- 1 | // https://github.com/michael-ciniawsky/postcss-load-config 2 | 3 | module.exports = { 4 | "plugins": { 5 | "postcss-mpvue-wxss": {} 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bqb-mpvue 2 | 3 | > 基于 [mpvue](https://github.com/Meituan-Dianping/mpvue) 的表情包斗图微信小程序。 4 | > 组件库使用 [iview-weapp](https://github.com/TalkingData/iview-weapp) 5 | 6 | ## 截图 7 | ![](/screen.gif) 8 | ## 扫码体验 9 | ![](http://y.photo.qq.com/img?s=jDVe2bxHb&l=y.jpg) 10 | ## Setup 11 | ``` bash 12 | # install dependencies 13 | npm install 14 | 15 | # serve with hot reload at localhost:8080 16 | npm run dev 17 | 18 | # build for production with minification 19 | npm run build 20 | 21 | # build for production and view the bundle analyzer report 22 | npm run build --report 23 | ``` 24 | -------------------------------------------------------------------------------- /build/build.js: -------------------------------------------------------------------------------- 1 | require('./check-versions')() 2 | 3 | process.env.NODE_ENV = 'production' 4 | 5 | var ora = require('ora') 6 | var rm = require('rimraf') 7 | var path = require('path') 8 | var chalk = require('chalk') 9 | var webpack = require('webpack') 10 | var config = require('../config') 11 | var webpackConfig = require('./webpack.prod.conf') 12 | 13 | var spinner = ora('building for production...') 14 | spinner.start() 15 | 16 | rm(path.join(config.build.assetsRoot, '*'), err => { 17 | if (err) throw err 18 | webpack(webpackConfig, function (err, stats) { 19 | spinner.stop() 20 | if (err) throw err 21 | process.stdout.write(stats.toString({ 22 | colors: true, 23 | modules: false, 24 | children: false, 25 | chunks: false, 26 | chunkModules: false 27 | }) + '\n\n') 28 | 29 | if (stats.hasErrors()) { 30 | console.log(chalk.red(' Build failed with errors.\n')) 31 | process.exit(1) 32 | } 33 | 34 | console.log(chalk.cyan(' Build complete.\n')) 35 | console.log(chalk.yellow( 36 | ' Tip: built files are meant to be served over an HTTP server.\n' + 37 | ' Opening index.html over file:// won\'t work.\n' 38 | )) 39 | }) 40 | }) 41 | -------------------------------------------------------------------------------- /build/check-versions.js: -------------------------------------------------------------------------------- 1 | var chalk = require('chalk') 2 | var semver = require('semver') 3 | var packageConfig = require('../package.json') 4 | var shell = require('shelljs') 5 | function exec (cmd) { 6 | return require('child_process').execSync(cmd).toString().trim() 7 | } 8 | 9 | var versionRequirements = [ 10 | { 11 | name: 'node', 12 | currentVersion: semver.clean(process.version), 13 | versionRequirement: packageConfig.engines.node 14 | } 15 | ] 16 | 17 | if (shell.which('npm')) { 18 | versionRequirements.push({ 19 | name: 'npm', 20 | currentVersion: exec('npm --version'), 21 | versionRequirement: packageConfig.engines.npm 22 | }) 23 | } 24 | 25 | module.exports = function () { 26 | var warnings = [] 27 | for (var i = 0; i < versionRequirements.length; i++) { 28 | var mod = versionRequirements[i] 29 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { 30 | warnings.push(mod.name + ': ' + 31 | chalk.red(mod.currentVersion) + ' should be ' + 32 | chalk.green(mod.versionRequirement) 33 | ) 34 | } 35 | } 36 | 37 | if (warnings.length) { 38 | console.log('') 39 | console.log(chalk.yellow('To use this template, you must update following to modules:')) 40 | console.log() 41 | for (var i = 0; i < warnings.length; i++) { 42 | var warning = warnings[i] 43 | console.log(' ' + warning) 44 | } 45 | console.log() 46 | process.exit(1) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /build/dev-client.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | require('eventsource-polyfill') 3 | var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true') 4 | 5 | hotClient.subscribe(function (event) { 6 | if (event.action === 'reload') { 7 | window.location.reload() 8 | } 9 | }) 10 | -------------------------------------------------------------------------------- /build/dev-server.js: -------------------------------------------------------------------------------- 1 | require('./check-versions')() 2 | 3 | var config = require('../config') 4 | if (!process.env.NODE_ENV) { 5 | process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV) 6 | } 7 | 8 | // var opn = require('opn') 9 | var path = require('path') 10 | var express = require('express') 11 | var webpack = require('webpack') 12 | var proxyMiddleware = require('http-proxy-middleware') 13 | var portfinder = require('portfinder') 14 | var webpackConfig = require('./webpack.dev.conf') 15 | 16 | // default port where dev server listens for incoming traffic 17 | var port = process.env.PORT || config.dev.port 18 | // automatically open browser, if not set will be false 19 | var autoOpenBrowser = !!config.dev.autoOpenBrowser 20 | // Define HTTP proxies to your custom API backend 21 | // https://github.com/chimurai/http-proxy-middleware 22 | var proxyTable = config.dev.proxyTable 23 | 24 | var app = express() 25 | var compiler = webpack(webpackConfig) 26 | 27 | // var devMiddleware = require('webpack-dev-middleware')(compiler, { 28 | // publicPath: webpackConfig.output.publicPath, 29 | // quiet: true 30 | // }) 31 | 32 | // var hotMiddleware = require('webpack-hot-middleware')(compiler, { 33 | // log: false, 34 | // heartbeat: 2000 35 | // }) 36 | // force page reload when html-webpack-plugin template changes 37 | // compiler.plugin('compilation', function (compilation) { 38 | // compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) { 39 | // hotMiddleware.publish({ action: 'reload' }) 40 | // cb() 41 | // }) 42 | // }) 43 | 44 | // proxy api requests 45 | Object.keys(proxyTable).forEach(function (context) { 46 | var options = proxyTable[context] 47 | if (typeof options === 'string') { 48 | options = { target: options } 49 | } 50 | app.use(proxyMiddleware(options.filter || context, options)) 51 | }) 52 | 53 | // handle fallback for HTML5 history API 54 | app.use(require('connect-history-api-fallback')()) 55 | 56 | // serve webpack bundle output 57 | // app.use(devMiddleware) 58 | 59 | // enable hot-reload and state-preserving 60 | // compilation error display 61 | // app.use(hotMiddleware) 62 | 63 | // serve pure static assets 64 | var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory) 65 | app.use(staticPath, express.static('./static')) 66 | 67 | // var uri = 'http://localhost:' + port 68 | 69 | var _resolve 70 | var readyPromise = new Promise(resolve => { 71 | _resolve = resolve 72 | }) 73 | 74 | // console.log('> Starting dev server...') 75 | // devMiddleware.waitUntilValid(() => { 76 | // console.log('> Listening at ' + uri + '\n') 77 | // // when env is testing, don't need open it 78 | // if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') { 79 | // opn(uri) 80 | // } 81 | // _resolve() 82 | // }) 83 | 84 | module.exports = new Promise((resolve, reject) => { 85 | portfinder.basePort = port 86 | portfinder.getPortPromise() 87 | .then(newPort => { 88 | if (port !== newPort) { 89 | console.log(`${port}端口被占用,开启新端口${newPort}`) 90 | } 91 | var server = app.listen(newPort, 'localhost') 92 | // for 小程序的文件保存机制 93 | require('webpack-dev-middleware-hard-disk')(compiler, { 94 | publicPath: webpackConfig.output.publicPath, 95 | quiet: true 96 | }) 97 | resolve({ 98 | ready: readyPromise, 99 | close: () => { 100 | server.close() 101 | } 102 | }) 103 | }).catch(error => { 104 | console.log('没有找到空闲端口,请打开任务管理器杀死进程端口再试', error) 105 | }) 106 | }) 107 | -------------------------------------------------------------------------------- /build/utils.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var config = require('../config') 3 | var ExtractTextPlugin = require('extract-text-webpack-plugin') 4 | 5 | exports.assetsPath = function (_path) { 6 | var assetsSubDirectory = process.env.NODE_ENV === 'production' 7 | ? config.build.assetsSubDirectory 8 | : config.dev.assetsSubDirectory 9 | return path.posix.join(assetsSubDirectory, _path) 10 | } 11 | 12 | exports.cssLoaders = function (options) { 13 | options = options || {} 14 | 15 | var cssLoader = { 16 | loader: 'css-loader', 17 | options: { 18 | minimize: process.env.NODE_ENV === 'production', 19 | sourceMap: options.sourceMap 20 | } 21 | } 22 | 23 | var postcssLoader = { 24 | loader: 'postcss-loader', 25 | options: { 26 | sourceMap: true 27 | } 28 | } 29 | 30 | var px2rpxLoader = { 31 | loader: 'px2rpx-loader', 32 | options: { 33 | baseDpr: 1, 34 | rpxUnit: 0.5 35 | } 36 | } 37 | 38 | // generate loader string to be used with extract text plugin 39 | function generateLoaders (loader, loaderOptions) { 40 | var loaders = [cssLoader, px2rpxLoader, postcssLoader] 41 | if (loader) { 42 | loaders.push({ 43 | loader: loader + '-loader', 44 | options: Object.assign({}, loaderOptions, { 45 | sourceMap: options.sourceMap 46 | }) 47 | }) 48 | } 49 | 50 | // Extract CSS when that option is specified 51 | // (which is the case during production build) 52 | if (options.extract) { 53 | return ExtractTextPlugin.extract({ 54 | use: loaders, 55 | fallback: 'vue-style-loader' 56 | }) 57 | } else { 58 | return ['vue-style-loader'].concat(loaders) 59 | } 60 | } 61 | 62 | // https://vue-loader.vuejs.org/en/configurations/extract-css.html 63 | return { 64 | css: generateLoaders(), 65 | wxss: generateLoaders(), 66 | postcss: generateLoaders(), 67 | less: generateLoaders('less'), 68 | sass: generateLoaders('sass', { indentedSyntax: true }), 69 | scss: generateLoaders('sass'), 70 | stylus: generateLoaders('stylus'), 71 | styl: generateLoaders('stylus') 72 | } 73 | } 74 | 75 | // Generate loaders for standalone style files (outside of .vue) 76 | exports.styleLoaders = function (options) { 77 | var output = [] 78 | var loaders = exports.cssLoaders(options) 79 | for (var extension in loaders) { 80 | var loader = loaders[extension] 81 | output.push({ 82 | test: new RegExp('\\.' + extension + '$'), 83 | use: loader 84 | }) 85 | } 86 | return output 87 | } 88 | -------------------------------------------------------------------------------- /build/vue-loader.conf.js: -------------------------------------------------------------------------------- 1 | var utils = require('./utils') 2 | var config = require('../config') 3 | // var isProduction = process.env.NODE_ENV === 'production' 4 | // for mp 5 | var isProduction = true 6 | 7 | module.exports = { 8 | loaders: utils.cssLoaders({ 9 | sourceMap: isProduction 10 | ? config.build.productionSourceMap 11 | : config.dev.cssSourceMap, 12 | extract: isProduction 13 | }), 14 | transformToRequire: { 15 | video: 'src', 16 | source: 'src', 17 | img: 'src', 18 | image: 'xlink:href' 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /build/webpack.base.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var fs = require('fs') 3 | var utils = require('./utils') 4 | var config = require('../config') 5 | var vueLoaderConfig = require('./vue-loader.conf') 6 | var MpvuePlugin = require('webpack-mpvue-asset-plugin') 7 | var glob = require('glob') 8 | 9 | function resolve (dir) { 10 | return path.join(__dirname, '..', dir) 11 | } 12 | 13 | function getEntry (rootSrc, pattern) { 14 | var files = glob.sync(path.resolve(rootSrc, pattern)) 15 | return files.reduce((res, file) => { 16 | var info = path.parse(file) 17 | var key = info.dir.slice(rootSrc.length + 1) + '/' + info.name 18 | res[key] = path.resolve(file) 19 | return res 20 | }, {}) 21 | } 22 | 23 | const appEntry = { app: resolve('./src/main.js') } 24 | const pagesEntry = getEntry(resolve('./src'), 'pages/**/main.js') 25 | const entry = Object.assign({}, appEntry, pagesEntry) 26 | 27 | module.exports = { 28 | // 如果要自定义生成的 dist 目录里面的文件路径, 29 | // 可以将 entry 写成 {'toPath': 'fromPath'} 的形式, 30 | // toPath 为相对于 dist 的路径, 例:index/demo,则生成的文件地址为 dist/index/demo.js 31 | entry, 32 | target: require('mpvue-webpack-target'), 33 | output: { 34 | path: config.build.assetsRoot, 35 | filename: '[name].js', 36 | publicPath: process.env.NODE_ENV === 'production' 37 | ? config.build.assetsPublicPath 38 | : config.dev.assetsPublicPath 39 | }, 40 | resolve: { 41 | extensions: ['.js', '.vue', '.json'], 42 | alias: { 43 | 'vue': 'mpvue', 44 | '@': resolve('src') 45 | }, 46 | symlinks: false, 47 | aliasFields: ['mpvue', 'weapp', 'browser'], 48 | mainFields: ['browser', 'module', 'main'] 49 | }, 50 | module: { 51 | rules: [ 52 | { 53 | test: /\.(js|vue)$/, 54 | loader: 'eslint-loader', 55 | enforce: 'pre', 56 | include: [resolve('src'), resolve('test')], 57 | options: { 58 | formatter: require('eslint-friendly-formatter') 59 | } 60 | }, 61 | { 62 | test: /\.vue$/, 63 | loader: 'mpvue-loader', 64 | options: vueLoaderConfig 65 | }, 66 | { 67 | test: /\.js$/, 68 | include: [resolve('src'), resolve('test')], 69 | use: [ 70 | 'babel-loader', 71 | { 72 | loader: 'mpvue-loader', 73 | options: { 74 | checkMPEntry: true 75 | } 76 | }, 77 | ] 78 | }, 79 | { 80 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 81 | loader: 'url-loader', 82 | options: { 83 | limit: 10000, 84 | name: utils.assetsPath('img/[name].[ext]') 85 | } 86 | }, 87 | { 88 | test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, 89 | loader: 'url-loader', 90 | options: { 91 | limit: 10000, 92 | name: utils.assetsPath('media/[name].[ext]') 93 | } 94 | }, 95 | { 96 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 97 | loader: 'url-loader', 98 | options: { 99 | limit: 10000, 100 | name: utils.assetsPath('fonts/[name].[ext]') 101 | } 102 | } 103 | ] 104 | }, 105 | plugins: [ 106 | new MpvuePlugin() 107 | ] 108 | } 109 | -------------------------------------------------------------------------------- /build/webpack.dev.conf.js: -------------------------------------------------------------------------------- 1 | var utils = require('./utils') 2 | var webpack = require('webpack') 3 | var config = require('../config') 4 | var merge = require('webpack-merge') 5 | var baseWebpackConfig = require('./webpack.base.conf') 6 | // var HtmlWebpackPlugin = require('html-webpack-plugin') 7 | var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') 8 | 9 | // copy from ./webpack.prod.conf.js 10 | var path = require('path') 11 | var ExtractTextPlugin = require('extract-text-webpack-plugin') 12 | var CopyWebpackPlugin = require('copy-webpack-plugin') 13 | var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') 14 | 15 | // add hot-reload related code to entry chunks 16 | // Object.keys(baseWebpackConfig.entry).forEach(function (name) { 17 | // baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name]) 18 | // }) 19 | 20 | module.exports = merge(baseWebpackConfig, { 21 | module: { 22 | rules: utils.styleLoaders({ 23 | sourceMap: config.dev.cssSourceMap, 24 | extract: true 25 | }) 26 | }, 27 | // cheap-module-eval-source-map is faster for development 28 | // devtool: '#cheap-module-eval-source-map', 29 | devtool: '#source-map', 30 | output: { 31 | path: config.build.assetsRoot, 32 | // filename: utils.assetsPath('js/[name].[chunkhash].js'), 33 | // chunkFilename: utils.assetsPath('js/[id].[chunkhash].js') 34 | filename: utils.assetsPath('js/[name].js'), 35 | chunkFilename: utils.assetsPath('js/[id].js') 36 | }, 37 | plugins: [ 38 | new webpack.DefinePlugin({ 39 | 'process.env': config.dev.env 40 | }), 41 | 42 | // copy from ./webpack.prod.conf.js 43 | // extract css into its own file 44 | new ExtractTextPlugin({ 45 | // filename: utils.assetsPath('css/[name].[contenthash].css') 46 | filename: utils.assetsPath('css/[name].wxss') 47 | }), 48 | // Compress extracted CSS. We are using this plugin so that possible 49 | // duplicated CSS from different components can be deduped. 50 | new OptimizeCSSPlugin({ 51 | cssProcessorOptions: { 52 | safe: true 53 | } 54 | }), 55 | new webpack.optimize.CommonsChunkPlugin({ 56 | name: 'vendor', 57 | minChunks: function (module, count) { 58 | // any required modules inside node_modules are extracted to vendor 59 | return ( 60 | module.resource && 61 | /\.js$/.test(module.resource) && 62 | module.resource.indexOf('node_modules') >= 0 63 | ) || count > 1 64 | } 65 | }), 66 | new webpack.optimize.CommonsChunkPlugin({ 67 | name: 'manifest', 68 | chunks: ['vendor'] 69 | }), 70 | // copy custom static assets 71 | new CopyWebpackPlugin([ 72 | { 73 | from: path.resolve(__dirname, '../static'), 74 | to: config.build.assetsSubDirectory, 75 | ignore: ['.*'] 76 | } 77 | ]), 78 | 79 | // https://github.com/glenjamin/webpack-hot-middleware#installation--usage 80 | // new webpack.HotModuleReplacementPlugin(), 81 | new webpack.NoEmitOnErrorsPlugin(), 82 | // https://github.com/ampedandwired/html-webpack-plugin 83 | // new HtmlWebpackPlugin({ 84 | // filename: 'index.html', 85 | // template: 'index.html', 86 | // inject: true 87 | // }), 88 | new FriendlyErrorsPlugin() 89 | ] 90 | }) 91 | -------------------------------------------------------------------------------- /build/webpack.prod.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var utils = require('./utils') 3 | var webpack = require('webpack') 4 | var config = require('../config') 5 | var merge = require('webpack-merge') 6 | var baseWebpackConfig = require('./webpack.base.conf') 7 | var UglifyJsPlugin = require('uglifyjs-webpack-plugin') 8 | var CopyWebpackPlugin = require('copy-webpack-plugin') 9 | // var HtmlWebpackPlugin = require('html-webpack-plugin') 10 | var ExtractTextPlugin = require('extract-text-webpack-plugin') 11 | var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') 12 | 13 | var env = config.build.env 14 | 15 | var webpackConfig = merge(baseWebpackConfig, { 16 | module: { 17 | rules: utils.styleLoaders({ 18 | sourceMap: config.build.productionSourceMap, 19 | extract: true 20 | }) 21 | }, 22 | devtool: config.build.productionSourceMap ? '#source-map' : false, 23 | output: { 24 | path: config.build.assetsRoot, 25 | // filename: utils.assetsPath('js/[name].[chunkhash].js'), 26 | // chunkFilename: utils.assetsPath('js/[id].[chunkhash].js') 27 | filename: utils.assetsPath('js/[name].js'), 28 | chunkFilename: utils.assetsPath('js/[id].js') 29 | }, 30 | plugins: [ 31 | // http://vuejs.github.io/vue-loader/en/workflow/production.html 32 | new webpack.DefinePlugin({ 33 | 'process.env': env 34 | }), 35 | new UglifyJsPlugin({ 36 | sourceMap: true 37 | }), 38 | // extract css into its own file 39 | new ExtractTextPlugin({ 40 | // filename: utils.assetsPath('css/[name].[contenthash].css') 41 | filename: utils.assetsPath('css/[name].wxss') 42 | }), 43 | // Compress extracted CSS. We are using this plugin so that possible 44 | // duplicated CSS from different components can be deduped. 45 | new OptimizeCSSPlugin({ 46 | cssProcessorOptions: { 47 | safe: true 48 | } 49 | }), 50 | // generate dist index.html with correct asset hash for caching. 51 | // you can customize output by editing /index.html 52 | // see https://github.com/ampedandwired/html-webpack-plugin 53 | // new HtmlWebpackPlugin({ 54 | // filename: config.build.index, 55 | // template: 'index.html', 56 | // inject: true, 57 | // minify: { 58 | // removeComments: true, 59 | // collapseWhitespace: true, 60 | // removeAttributeQuotes: true 61 | // // more options: 62 | // // https://github.com/kangax/html-minifier#options-quick-reference 63 | // }, 64 | // // necessary to consistently work with multiple chunks via CommonsChunkPlugin 65 | // chunksSortMode: 'dependency' 66 | // }), 67 | // keep module.id stable when vender modules does not change 68 | new webpack.HashedModuleIdsPlugin(), 69 | // split vendor js into its own file 70 | new webpack.optimize.CommonsChunkPlugin({ 71 | name: 'vendor', 72 | minChunks: function (module, count) { 73 | // any required modules inside node_modules are extracted to vendor 74 | return ( 75 | module.resource && 76 | /\.js$/.test(module.resource) && 77 | module.resource.indexOf('node_modules') >= 0 78 | ) || count > 1 79 | } 80 | }), 81 | // extract webpack runtime and module manifest to its own file in order to 82 | // prevent vendor hash from being updated whenever app bundle is updated 83 | new webpack.optimize.CommonsChunkPlugin({ 84 | name: 'manifest', 85 | chunks: ['vendor'] 86 | }), 87 | // copy custom static assets 88 | new CopyWebpackPlugin([ 89 | { 90 | from: path.resolve(__dirname, '../static'), 91 | to: config.build.assetsSubDirectory, 92 | ignore: ['.*'] 93 | } 94 | ]) 95 | ] 96 | }) 97 | 98 | // if (config.build.productionGzip) { 99 | // var CompressionWebpackPlugin = require('compression-webpack-plugin') 100 | 101 | // webpackConfig.plugins.push( 102 | // new CompressionWebpackPlugin({ 103 | // asset: '[path].gz[query]', 104 | // algorithm: 'gzip', 105 | // test: new RegExp( 106 | // '\\.(' + 107 | // config.build.productionGzipExtensions.join('|') + 108 | // ')$' 109 | // ), 110 | // threshold: 10240, 111 | // minRatio: 0.8 112 | // }) 113 | // ) 114 | // } 115 | 116 | if (config.build.bundleAnalyzerReport) { 117 | var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin 118 | webpackConfig.plugins.push(new BundleAnalyzerPlugin()) 119 | } 120 | 121 | module.exports = webpackConfig 122 | -------------------------------------------------------------------------------- /config/dev.env.js: -------------------------------------------------------------------------------- 1 | var merge = require('webpack-merge') 2 | var prodEnv = require('./prod.env') 3 | 4 | module.exports = merge(prodEnv, { 5 | NODE_ENV: '"development"' 6 | }) 7 | -------------------------------------------------------------------------------- /config/index.js: -------------------------------------------------------------------------------- 1 | // see http://vuejs-templates.github.io/webpack for documentation. 2 | var path = require('path') 3 | 4 | module.exports = { 5 | build: { 6 | env: require('./prod.env'), 7 | index: path.resolve(__dirname, '../dist/index.html'), 8 | assetsRoot: path.resolve(__dirname, '../dist'), 9 | assetsSubDirectory: 'static', 10 | assetsPublicPath: '/', 11 | productionSourceMap: false, 12 | // Gzip off by default as many popular static hosts such as 13 | // Surge or Netlify already gzip all static assets for you. 14 | // Before setting to `true`, make sure to: 15 | // npm install --save-dev compression-webpack-plugin 16 | productionGzip: false, 17 | productionGzipExtensions: ['js', 'css'], 18 | // Run the build command with an extra argument to 19 | // View the bundle analyzer report after build finishes: 20 | // `npm run build --report` 21 | // Set to `true` or `false` to always turn it on or off 22 | bundleAnalyzerReport: process.env.npm_config_report 23 | }, 24 | dev: { 25 | env: require('./dev.env'), 26 | port: 8080, 27 | // 在小程序开发者工具中不需要自动打开浏览器 28 | autoOpenBrowser: false, 29 | assetsSubDirectory: 'static', 30 | assetsPublicPath: '/', 31 | proxyTable: {}, 32 | // CSS Sourcemaps off by default because relative paths are "buggy" 33 | // with this option, according to the CSS-Loader README 34 | // (https://github.com/webpack/css-loader#sourcemaps) 35 | // In our experience, they generally work as expected, 36 | // just be aware of this issue when enabling this option. 37 | cssSourceMap: false 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /config/prod.env.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | NODE_ENV: '"production"' 3 | } 4 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | mpvue-bqb 6 | 7 | 8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mpvue-bqb", 3 | "version": "1.0.0", 4 | "description": "A Mpvue project", 5 | "author": "Yang Shuang ", 6 | "private": true, 7 | "scripts": { 8 | "dev": "node build/dev-server.js", 9 | "start": "node build/dev-server.js", 10 | "build": "node build/build.js", 11 | "lint": "eslint --ext .js,.vue src" 12 | }, 13 | "dependencies": { 14 | "flyio": "^0.5.9", 15 | "mpvue": "^1.0.11", 16 | "vuex": "^3.0.1" 17 | }, 18 | "devDependencies": { 19 | "mpvue-loader": "^1.0.13", 20 | "mpvue-webpack-target": "^1.0.0", 21 | "mpvue-template-compiler": "^1.0.11", 22 | "portfinder": "^1.0.13", 23 | "postcss-mpvue-wxss": "^1.0.0", 24 | "prettier": "~1.12.1", 25 | "px2rpx-loader": "^0.1.10", 26 | "babel-core": "^6.22.1", 27 | "glob": "^7.1.2", 28 | "webpack-mpvue-asset-plugin": "^0.0.2", 29 | "babel-eslint": "^8.2.3", 30 | "babel-loader": "^7.1.1", 31 | "babel-plugin-transform-runtime": "^6.22.0", 32 | "babel-preset-env": "^1.3.2", 33 | "babel-preset-stage-2": "^6.22.0", 34 | "babel-register": "^6.22.0", 35 | "chalk": "^2.4.0", 36 | "connect-history-api-fallback": "^1.3.0", 37 | "copy-webpack-plugin": "^4.5.1", 38 | "css-loader": "^0.28.11", 39 | "cssnano": "^3.10.0", 40 | "eslint": "^4.19.1", 41 | "eslint-friendly-formatter": "^4.0.1", 42 | "eslint-loader": "^2.0.0", 43 | "eslint-plugin-import": "^2.11.0", 44 | "eslint-plugin-node": "^6.0.1", 45 | "eslint-plugin-html": "^4.0.3", 46 | "eslint-config-standard": "^11.0.0", 47 | "eslint-plugin-promise": "^3.4.0", 48 | "eslint-plugin-standard": "^3.0.1", 49 | "eventsource-polyfill": "^0.9.6", 50 | "express": "^4.16.3", 51 | "extract-text-webpack-plugin": "^3.0.2", 52 | "file-loader": "^1.1.11", 53 | "friendly-errors-webpack-plugin": "^1.7.0", 54 | "html-webpack-plugin": "^3.2.0", 55 | "http-proxy-middleware": "^0.18.0", 56 | "webpack-bundle-analyzer": "^2.2.1", 57 | "semver": "^5.3.0", 58 | "shelljs": "^0.8.1", 59 | "uglifyjs-webpack-plugin": "^1.2.5", 60 | "optimize-css-assets-webpack-plugin": "^3.2.0", 61 | "ora": "^2.0.0", 62 | "rimraf": "^2.6.0", 63 | "url-loader": "^1.0.1", 64 | "vue-style-loader": "^4.1.0", 65 | "webpack": "^3.11.0", 66 | "webpack-dev-middleware-hard-disk": "^1.12.0", 67 | "webpack-merge": "^4.1.0", 68 | "postcss-loader": "^2.1.4" 69 | }, 70 | "engines": { 71 | "node": ">= 4.0.0", 72 | "npm": ">= 3.0.0" 73 | }, 74 | "browserslist": [ 75 | "> 1%", 76 | "last 2 versions", 77 | "not ie <= 8" 78 | ] 79 | } 80 | -------------------------------------------------------------------------------- /project.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "项目配置文件。", 3 | "setting": { 4 | "urlCheck": true, 5 | "es6": false, 6 | "postcss": true, 7 | "minified": true, 8 | "newFeature": true 9 | }, 10 | "miniprogramRoot": "./dist/", 11 | "compileType": "miniprogram", 12 | "appid": "touristappid", 13 | "projectname": "mpvue-bqb", 14 | "condition": { 15 | "search": { 16 | "current": -1, 17 | "list": [] 18 | }, 19 | "conversation": { 20 | "current": -1, 21 | "list": [] 22 | }, 23 | "game": { 24 | "currentL": -1, 25 | "list": [] 26 | }, 27 | "miniprogram": { 28 | "current": -1, 29 | "list": [] 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /screen.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yshkk/bqb-mpvue/5b86537529eb3693bca7ccd38c6b83e479926887/screen.gif -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 24 | -------------------------------------------------------------------------------- /src/components/card.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 14 | 15 | 20 | -------------------------------------------------------------------------------- /src/components/color-selector.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 24 | 25 | 44 | -------------------------------------------------------------------------------- /src/components/like.vue: -------------------------------------------------------------------------------- 1 | 23 | 24 | 74 | 75 | 105 | -------------------------------------------------------------------------------- /src/components/make.vue: -------------------------------------------------------------------------------- 1 | 32 | 33 | 142 | 143 | 157 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import '../static/sdk/ald-stat' 2 | import Vue from 'vue' 3 | import App from './App' 4 | 5 | Vue.config.productionTip = false 6 | App.mpType = 'app' 7 | 8 | const app = new Vue(App) 9 | app.$mount() 10 | 11 | export default { 12 | // 这个字段走 app.json 13 | config: { 14 | // 页面前带有 ^ 符号的,会被编译成首页,其他页面可以选填,我们会自动把 webpack entry 里面的入口页面加进去 15 | pages: ['^pages/index/main', 'pages/maker/main'], 16 | window: { 17 | backgroundTextStyle: 'light', 18 | navigationBarBackgroundColor: '#2d8cf0', 19 | navigationBarTitleText: '熊猫斗图助手', 20 | navigationBarTextStyle: 'light' 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/pages/index/index.vue: -------------------------------------------------------------------------------- 1 | 23 | 24 | 60 | 61 | 66 | -------------------------------------------------------------------------------- /src/pages/index/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './index' 3 | 4 | const app = new Vue(App) 5 | app.$mount() 6 | export default { 7 | config: { 8 | 'usingComponents': { 9 | 'i-button': '../../static/iview/button/index', 10 | 'i-input': '../../static/iview/input/index', 11 | 'i-tab-bar': '../../static/iview/tab-bar/index', 12 | 'i-tab-bar-item': '../../static/iview/tab-bar-item/index', 13 | 'i-icon': '../../static/iview/icon/index', 14 | 'i-row': '../../static/iview/row/index', 15 | 'i-col': '../../static/iview/col/index', 16 | 'i-message': '../../static/iview/message/index', 17 | 'i-spin': '../../static/iview/spin/index', 18 | 'i-page': '../../static/iview/page/index', 19 | 'i-modal': '../../static/iview/modal/index', 20 | 'i-panel': '../../static/iview/panel/index' 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/pages/maker/index.vue: -------------------------------------------------------------------------------- 1 | 26 | 27 | 141 | 142 | 198 | -------------------------------------------------------------------------------- /src/pages/maker/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './index' 3 | 4 | const app = new Vue(App) 5 | app.$mount() 6 | export default { 7 | config: { 8 | 'usingComponents': { 9 | 'i-button': '../../static/iview/button/index', 10 | 'i-input': '../../static/iview/input/index', 11 | 'i-tab-bar': '../../static/iview/tab-bar/index', 12 | 'i-tab-bar-item': '../../static/iview/tab-bar-item/index', 13 | 'i-icon': '../../static/iview/icon/index', 14 | 'i-row': '../../static/iview/row/index', 15 | 'i-col': '../../static/iview/col/index', 16 | 'i-message': '../../static/iview/message/index', 17 | 'i-spin': '../../static/iview/spin/index', 18 | 'i-page': '../../static/iview/page/index', 19 | 'i-modal': '../../static/iview/modal/index', 20 | 'i-input-number': '../../static/iview/input-number/index', 21 | 'i-tabs': '../../static/iview/tabs/index', 22 | 'i-tab': '../../static/iview/tab/index', 23 | 'i-divider': '../../static/iview/divider/index' 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/utils/index.js: -------------------------------------------------------------------------------- 1 | function formatNumber (n) { 2 | const str = n.toString() 3 | return str[1] ? str : `0${str}` 4 | } 5 | 6 | export function formatTime (date) { 7 | const year = date.getFullYear() 8 | const month = date.getMonth() + 1 9 | const day = date.getDate() 10 | 11 | const hour = date.getHours() 12 | const minute = date.getMinutes() 13 | const second = date.getSeconds() 14 | 15 | const t1 = [year, month, day].map(formatNumber).join('/') 16 | const t2 = [hour, minute, second].map(formatNumber).join(':') 17 | 18 | return `${t1} ${t2}` 19 | } 20 | var lastFrameTime = 0 21 | // 模拟 requestAnimationFrame copied from https://www.dennic365.com/blog/?p=87 22 | export function doAnimationFrame (fn) { 23 | var currTime = new Date().getTime() 24 | var timeToCall = Math.max(0, 16 - (currTime - lastFrameTime)) 25 | var id = setTimeout(function () { 26 | fn(currTime + timeToCall) 27 | }, timeToCall) 28 | lastFrameTime = currTime + timeToCall 29 | return id 30 | } 31 | // 模拟 cancelAnimationFrame 32 | export function abortAnimationFrame (id) { 33 | clearTimeout(id) 34 | } 35 | 36 | export default { 37 | formatNumber, 38 | formatTime, 39 | doAnimationFrame, 40 | abortAnimationFrame 41 | } 42 | -------------------------------------------------------------------------------- /static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yshkk/bqb-mpvue/5b86537529eb3693bca7ccd38c6b83e479926887/static/.gitkeep -------------------------------------------------------------------------------- /static/assets/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yshkk/bqb-mpvue/5b86537529eb3693bca7ccd38c6b83e479926887/static/assets/banner.png -------------------------------------------------------------------------------- /static/assets/banner2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yshkk/bqb-mpvue/5b86537529eb3693bca7ccd38c6b83e479926887/static/assets/banner2.png -------------------------------------------------------------------------------- /static/assets/banner_bak.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yshkk/bqb-mpvue/5b86537529eb3693bca7ccd38c6b83e479926887/static/assets/banner_bak.png -------------------------------------------------------------------------------- /static/assets/zan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yshkk/bqb-mpvue/5b86537529eb3693bca7ccd38c6b83e479926887/static/assets/zan.png -------------------------------------------------------------------------------- /static/assets/zan2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yshkk/bqb-mpvue/5b86537529eb3693bca7ccd38c6b83e479926887/static/assets/zan2.jpg -------------------------------------------------------------------------------- /static/iview/action-sheet/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class', 'i-class-mask', 'i-class-header'], 3 | 4 | options: { 5 | multipleSlots: true 6 | }, 7 | 8 | properties: { 9 | visible: { 10 | type: Boolean, 11 | value: false 12 | }, 13 | maskClosable: { 14 | type: Boolean, 15 | value: true 16 | }, 17 | showCancel: { 18 | type: Boolean, 19 | value: false 20 | }, 21 | cancelText: { 22 | type: String, 23 | value: '取消' 24 | }, 25 | actions: { 26 | type: Array, 27 | value: [] 28 | } 29 | }, 30 | 31 | methods: { 32 | handleClickMask () { 33 | if (!this.data.maskClosable) return; 34 | this.handleClickCancel(); 35 | }, 36 | 37 | handleClickItem ({ currentTarget = {} }) { 38 | const dataset = currentTarget.dataset || {}; 39 | const { index } = dataset; 40 | this.triggerEvent('click', { index }); 41 | }, 42 | 43 | handleClickCancel () { 44 | this.triggerEvent('cancel'); 45 | } 46 | } 47 | }); 48 | -------------------------------------------------------------------------------- /static/iview/action-sheet/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": 4 | { 5 | "i-button": "../button/index", 6 | "i-icon": "../icon/index" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /static/iview/action-sheet/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 14 | 15 | 16 | {{ item.name }} 17 | 18 | 19 | 20 | 21 | {{ cancelText }} 22 | 23 | 24 | -------------------------------------------------------------------------------- /static/iview/action-sheet/index.wxss: -------------------------------------------------------------------------------- 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)}} -------------------------------------------------------------------------------- /static/iview/alert/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | options: { 4 | multipleSlots: true 5 | }, 6 | properties: { 7 | //info, success, warning, error 8 | type: { 9 | type: String, 10 | value: 'info' 11 | }, 12 | closable: { 13 | type: Boolean, 14 | value: false 15 | }, 16 | showIcon: { 17 | type: Boolean, 18 | default: false 19 | }, 20 | desc: { 21 | type: Boolean, 22 | default: false 23 | }, 24 | }, 25 | data: { 26 | closed: false 27 | }, 28 | methods: { 29 | handleTap() { 30 | this.setData({ 31 | closed: !this.data.closed, 32 | }); 33 | this.triggerEvent('close'); 34 | }, 35 | 36 | } 37 | }); 38 | -------------------------------------------------------------------------------- /static/iview/alert/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": 4 | { 5 | "i-icon": "../icon/index" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /static/iview/alert/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /static/iview/alert/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/avatar/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | 4 | properties: { 5 | // circle || square 6 | shape: { 7 | type: String, 8 | value: 'circle' 9 | }, 10 | // small || large || default 11 | size: { 12 | type: String, 13 | value: 'default' 14 | }, 15 | src: { 16 | type: String, 17 | value: '' 18 | } 19 | } 20 | }); 21 | -------------------------------------------------------------------------------- /static/iview/avatar/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/avatar/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /static/iview/avatar/index.wxss: -------------------------------------------------------------------------------- 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%} -------------------------------------------------------------------------------- /static/iview/badge/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class', 'i-class-alone'], 3 | 4 | properties: { 5 | count: { 6 | type: Number, 7 | value: 0, 8 | observer: 'finalCount' 9 | }, 10 | overflowCount: { 11 | type: Number, 12 | value: 99 13 | }, 14 | dot: { 15 | type: Boolean, 16 | value: false 17 | }, 18 | }, 19 | data: { 20 | finalCount: 0 21 | }, 22 | methods: { 23 | finalCount() { 24 | this.setData({ 25 | finalCount: parseInt(this.data.count) >= parseInt(this.data.overflowCount) ? `${this.data.overflowCount}+` : this.data.count 26 | }); 27 | }, 28 | } 29 | }); 30 | -------------------------------------------------------------------------------- /static/iview/badge/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/badge/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{ finalCount }} 5 | 6 | -------------------------------------------------------------------------------- /static/iview/badge/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/base/index.js: -------------------------------------------------------------------------------- 1 | function getCtx (selector) { 2 | const pages = getCurrentPages(); 3 | const ctx = pages[pages.length - 1]; 4 | 5 | const componentCtx = ctx.selectComponent(selector); 6 | 7 | if (!componentCtx) { 8 | console.error('无法找到对应的组件,请按文档说明使用组件'); 9 | return null; 10 | } 11 | return componentCtx; 12 | } 13 | 14 | function Toast(options) { 15 | const { selector = '#toast' } = options; 16 | const ctx = getCtx(selector); 17 | 18 | ctx.handleShow(options); 19 | } 20 | 21 | Toast.hide = function (selector = '#toast') { 22 | const ctx = getCtx(selector); 23 | 24 | ctx.handleHide(); 25 | }; 26 | 27 | function Message(options) { 28 | const { selector = '#message' } = options; 29 | const ctx = getCtx(selector); 30 | 31 | ctx.handleShow(options); 32 | } 33 | 34 | module.exports = { 35 | $Toast: Toast, 36 | $Message: Message 37 | }; -------------------------------------------------------------------------------- /static/iview/button/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | 4 | properties: { 5 | // default, primary, ghost, info, success, warning, error 6 | type: { 7 | type: String, 8 | value: '', 9 | }, 10 | inline: { 11 | type: Boolean, 12 | value: false 13 | }, 14 | // default, large, small 15 | size: { 16 | type: String, 17 | value: '', 18 | }, 19 | // circle, square 20 | shape: { 21 | type: String, 22 | value: 'square' 23 | }, 24 | disabled: { 25 | type: Boolean, 26 | value: false, 27 | }, 28 | loading: { 29 | type: Boolean, 30 | value: false, 31 | }, 32 | long: { 33 | type: Boolean, 34 | value: false 35 | }, 36 | openType: String, 37 | appParameter: String, 38 | hoverStopPropagation: Boolean, 39 | hoverStartTime: { 40 | type: Number, 41 | value: 20 42 | }, 43 | hoverStayTime: { 44 | type: Number, 45 | value: 70 46 | }, 47 | lang: { 48 | type: String, 49 | value: 'en' 50 | }, 51 | sessionFrom: { 52 | type: String, 53 | value: '' 54 | }, 55 | sendMessageTitle: String, 56 | sendMessagePath: String, 57 | sendMessageImg: String, 58 | showMessageCard: Boolean 59 | }, 60 | 61 | methods: { 62 | handleTap () { 63 | if (this.data.disabled) return false; 64 | 65 | this.triggerEvent('click'); 66 | }, 67 | bindgetuserinfo({ detail = {} } = {}) { 68 | this.triggerEvent('getuserinfo', detail); 69 | }, 70 | bindcontact({ detail = {} } = {}) { 71 | this.triggerEvent('contact', detail); 72 | }, 73 | bindgetphonenumber({ detail = {} } = {}) { 74 | this.triggerEvent('getphonenumber', detail); 75 | }, 76 | binderror({ detail = {} } = {}) { 77 | this.triggerEvent('error', detail); 78 | } 79 | } 80 | }); 81 | -------------------------------------------------------------------------------- /static/iview/button/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/button/index.wxml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /static/iview/button/index.wxss: -------------------------------------------------------------------------------- 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;box-shadow:inset 0 0 0 1px rgba(0,0,0,.1);color:#fff!important;background:#f7f7f7!important;color:#495060!important;margin:0;height:34px;line-height:34px;}.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)}} 2 | -------------------------------------------------------------------------------- /static/iview/card/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | 4 | options: { 5 | multipleSlots: true 6 | }, 7 | 8 | properties: { 9 | full: { 10 | type: Boolean, 11 | value: false 12 | }, 13 | thumb: { 14 | type: String, 15 | value: '' 16 | }, 17 | title: { 18 | type: String, 19 | value: '' 20 | }, 21 | extra: { 22 | type: String, 23 | value: '' 24 | } 25 | } 26 | }); 27 | -------------------------------------------------------------------------------- /static/iview/card/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/card/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{ title }} 6 | 7 | {{ extra }} 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /static/iview/card/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/cell-group/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | 4 | relations: { 5 | '../cell/index': { 6 | type: 'child', 7 | linked () { 8 | this._updateIsLastCell(); 9 | }, 10 | linkChanged () { 11 | this._updateIsLastCell(); 12 | }, 13 | unlinked () { 14 | this._updateIsLastCell(); 15 | } 16 | } 17 | }, 18 | 19 | methods: { 20 | _updateIsLastCell() { 21 | let cells = this.getRelationNodes('../cell/index'); 22 | const len = cells.length; 23 | 24 | if (len > 0) { 25 | let lastIndex = len - 1; 26 | 27 | cells.forEach((cell, index) => { 28 | cell.updateIsLastCell(index === lastIndex); 29 | }); 30 | } 31 | } 32 | } 33 | }); 34 | -------------------------------------------------------------------------------- /static/iview/cell-group/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/cell-group/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /static/iview/cell/index.js: -------------------------------------------------------------------------------- 1 | const warn = (msg, getValue) => { 2 | console.warn(msg); 3 | console.log('接受到的值为:', getValue); 4 | }; 5 | 6 | Component({ 7 | externalClasses: ['i-class'], 8 | 9 | options: { 10 | multipleSlots: true 11 | }, 12 | 13 | relations: { 14 | '../cell-group/index': { 15 | type: 'parent' 16 | } 17 | }, 18 | 19 | properties: { 20 | // 左侧标题 21 | title: { 22 | type: String 23 | }, 24 | // 标题下方的描述信息 25 | label: { 26 | type: String 27 | }, 28 | // 右侧内容 29 | value: { 30 | type: String 31 | }, 32 | // 只有点击 footer 区域才触发 tab 事件 33 | onlyTapFooter: { 34 | type: Boolean 35 | }, 36 | // 是否展示右侧箭头并开启尝试以 url 跳转 37 | isLink: { 38 | type: null, 39 | value: '' 40 | }, 41 | // 链接类型,可选值为 navigateTo,redirectTo,switchTab,reLaunch 42 | linkType: { 43 | type: String, 44 | value: 'navigateTo' 45 | }, 46 | url: { 47 | type: String, 48 | value: '' 49 | } 50 | }, 51 | 52 | data: { 53 | isLastCell: true 54 | }, 55 | 56 | methods: { 57 | navigateTo () { 58 | const { url } = this.data; 59 | const type = typeof this.data.isLink; 60 | 61 | this.triggerEvent('click', {}); 62 | 63 | if (!this.data.isLink || !url || url === 'true' || url === 'false') return; 64 | 65 | if (type !== 'boolean' && type !== 'string') { 66 | warn('isLink 属性值必须是一个字符串或布尔值', this.data.isLink); 67 | return; 68 | } 69 | 70 | if (['navigateTo', 'redirectTo', 'switchTab', 'reLaunch'].indexOf(this.data.linkType) === -1) { 71 | warn('linkType 属性可选值为 navigateTo,redirectTo,switchTab,reLaunch', this.data.linkType); 72 | return; 73 | } 74 | wx[this.data.linkType].call(wx, {url}); 75 | }, 76 | handleTap () { 77 | if (!this.data.onlyTapFooter) { 78 | this.navigateTo(); 79 | } 80 | }, 81 | 82 | updateIsLastCell (isLastCell) { 83 | this.setData({ isLastCell }); 84 | } 85 | } 86 | }); 87 | -------------------------------------------------------------------------------- /static/iview/cell/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/cell/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{ title }} 7 | {{ label }} 8 | 9 | 10 | 11 | {{ value }} 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /static/iview/cell/index.wxss: -------------------------------------------------------------------------------- 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)} -------------------------------------------------------------------------------- /static/iview/checkbox-group/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | relations: { 4 | '../checkbox/index': { 5 | type: 'child', 6 | linked() { 7 | this.changeCurrent(); 8 | }, 9 | linkChanged() { 10 | this.changeCurrent(); 11 | }, 12 | unlinked() { 13 | this.changeCurrent(); 14 | } 15 | } 16 | }, 17 | properties: { 18 | current: { 19 | type: Array, 20 | value: [], 21 | observer: 'changeCurrent' 22 | }, 23 | }, 24 | methods: { 25 | changeCurrent(val = this.data.current) { 26 | let items = this.getRelationNodes('../checkbox/index'); 27 | const len = items.length; 28 | if (len > 0) { 29 | items.forEach(item => { 30 | item.changeCurrent(val.indexOf(item.data.value) !== -1); 31 | }); 32 | } 33 | }, 34 | emitEvent(current) { 35 | this.triggerEvent('change', current); 36 | } 37 | } 38 | }); 39 | -------------------------------------------------------------------------------- /static/iview/checkbox-group/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": 4 | { 5 | "i-cell-group": "../cell-group/index" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /static/iview/checkbox-group/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /static/iview/checkbox-group/index.wxss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yshkk/bqb-mpvue/5b86537529eb3693bca7ccd38c6b83e479926887/static/iview/checkbox-group/index.wxss -------------------------------------------------------------------------------- /static/iview/checkbox/index.js: -------------------------------------------------------------------------------- 1 | const prefixCls = 'i-checkbox'; 2 | 3 | Component({ 4 | externalClasses: ['i-class'], 5 | relations: { 6 | '../checkbox-group/index': { 7 | type: 'parent' 8 | } 9 | }, 10 | properties: { 11 | value: { 12 | type: String, 13 | value: '' 14 | }, 15 | checked: { 16 | type: Boolean, 17 | value: false 18 | }, 19 | disabled: { 20 | type: Boolean, 21 | value: false 22 | }, 23 | color: { 24 | type: String, 25 | value: '#2d8cf0' 26 | }, 27 | position: { 28 | type: String, 29 | value: 'left', //left right 30 | observer: 'setPosition' 31 | } 32 | }, 33 | data: { 34 | checked: true, 35 | positionCls: `${prefixCls}-checkbox-left`, 36 | }, 37 | attached() { 38 | this.setPosition(); 39 | }, 40 | methods: { 41 | changeCurrent(current) { 42 | this.setData({ checked: current }); 43 | }, 44 | checkboxChange() { 45 | if (this.data.disabled) return; 46 | const item = { current: !this.data.checked, value: this.data.value }; 47 | const parent = this.getRelationNodes('../checkbox-group/index')[0]; 48 | parent ? parent.emitEvent(item) : this.triggerEvent('change', item); 49 | }, 50 | setPosition() { 51 | this.setData({ 52 | positionCls: this.data.position.indexOf('left') !== -1 ? `${prefixCls}-checkbox-left` : `${prefixCls}-checkbox-right`, 53 | }); 54 | } 55 | } 56 | }); 57 | -------------------------------------------------------------------------------- /static/iview/checkbox/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": 4 | { 5 | "i-cell": "../cell/index" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /static/iview/checkbox/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /static/iview/checkbox/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/col/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | 4 | relations: { 5 | '../row/index': { 6 | type: 'parent' 7 | } 8 | }, 9 | 10 | properties: { 11 | span: { 12 | value: 0, 13 | type: Number 14 | }, 15 | offset: { 16 | value: 0, 17 | type: Number 18 | } 19 | } 20 | }); 21 | -------------------------------------------------------------------------------- /static/iview/col/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } -------------------------------------------------------------------------------- /static/iview/col/index.wxml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /static/iview/col/index.wxss: -------------------------------------------------------------------------------- 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%} -------------------------------------------------------------------------------- /static/iview/collapse-item/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class-content', 'i-class-title', 'i-class'], 3 | 4 | relations: { 5 | '../collapse/index': { 6 | type: 'parent', 7 | linked: function (target) { 8 | const options = { 9 | accordion: target.data.accordion 10 | } 11 | if (target.data.name === this.data.name) { 12 | options.showContent = 'i-collapse-item-show-content'; 13 | } 14 | this.setData(options); 15 | } 16 | } 17 | }, 18 | 19 | properties: { 20 | title: String, 21 | name: String 22 | }, 23 | 24 | data: { 25 | showContent: '', 26 | accordion: false 27 | }, 28 | 29 | options: { 30 | multipleSlots: true 31 | }, 32 | 33 | methods: { 34 | trigger(e) { 35 | const data = this.data; 36 | if (data.accordion) { 37 | this.triggerEvent('collapse', {name: data.name}, {composed: true, bubbles: true}); 38 | } else { 39 | this.setData({ 40 | showContent: data.showContent ? '' : 'i-collapse-item-show-content' 41 | }); 42 | } 43 | }, 44 | } 45 | }); 46 | 47 | -------------------------------------------------------------------------------- /static/iview/collapse-item/index.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "component": true, 4 | "usingComponents": { 5 | "i-icon": "../icon/index" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /static/iview/collapse-item/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{title}} 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /static/iview/collapse-item/index.wxss: -------------------------------------------------------------------------------- 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)} -------------------------------------------------------------------------------- /static/iview/collapse/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | 4 | relations: { 5 | '../collapse-item/index': { 6 | type: 'child' 7 | } 8 | }, 9 | properties: { 10 | name: String, 11 | accordion: Boolean 12 | }, 13 | methods: { 14 | clickfn(e) { 15 | const params = e.detail; 16 | const allList = this.getRelationNodes('../collapse-item/index'); 17 | allList.forEach((item) => { 18 | if (params.name === item.data.name) { 19 | item.setData({ 20 | showContent: 'i-collapse-item-show-content' 21 | }); 22 | } else { 23 | item.setData({ 24 | showContent: '' 25 | }); 26 | } 27 | }); 28 | }, 29 | } 30 | }); 31 | 32 | -------------------------------------------------------------------------------- /static/iview/collapse/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/collapse/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /static/iview/collapse/index.wxss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yshkk/bqb-mpvue/5b86537529eb3693bca7ccd38c6b83e479926887/static/iview/collapse/index.wxss -------------------------------------------------------------------------------- /static/iview/count-down/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | properties: { 3 | target: Number, 4 | showDay: Boolean, 5 | callback: String, 6 | format: Array, 7 | clearTimer: Boolean 8 | }, 9 | externalClasses: ['countdown-class'], 10 | data: { 11 | time: '', 12 | resultFormat: [], 13 | changeFormat: false 14 | }, 15 | ready() { 16 | this.getFormat(); 17 | 18 | }, 19 | methods: { 20 | getFormat() { 21 | const data = this.data; 22 | const len = data.format.length; 23 | 24 | if (!data.showDay) data.resultFormat.push(''); 25 | 26 | if (len >= 3) { 27 | for (let i = 0; i < len; i++) { 28 | if (data.resultFormat.length >= 4) break; 29 | if (data.format[i]) { 30 | data.resultFormat.push(data.format[i].toString()); 31 | } 32 | } 33 | 34 | if (data.resultFormat.length >= 4) data.changeFormat = true; 35 | } 36 | 37 | this.getLastTime(); 38 | }, 39 | init() { 40 | const self = this; 41 | setTimeout(function () { 42 | self.getLastTime.call(self); 43 | }, 1000); 44 | }, 45 | getLastTime() { 46 | const data = this.data; 47 | const gapTime = Math.ceil((data.target - new Date().getTime()) / 1000); 48 | let result = ''; 49 | let time = '00:00:00'; 50 | let day = '00'; 51 | const format = data.resultFormat; 52 | 53 | if (gapTime > 0) { 54 | day = this.formatNum(parseInt(gapTime / 86400)); 55 | let lastTime = gapTime % 86400; 56 | const hour = this.formatNum(parseInt(lastTime / 3600)); 57 | lastTime = lastTime % 3600; 58 | const minute = this.formatNum(parseInt(lastTime / 60)); 59 | const second = this.formatNum(lastTime % 60); 60 | 61 | if (data.changeFormat) time = `${hour}${format[1]}${minute}${format[2]}${second}${format[3]}`; 62 | else time = `${hour}:${minute}:${second}`; 63 | 64 | if (!data.clearTimer) this.init.call(this); 65 | } else { 66 | this.endfn(); 67 | } 68 | 69 | if (data.showDay) { 70 | if (data.changeFormat) { 71 | result = `${day}${format[0]} ${time}`; 72 | } else { 73 | result = `${day}d ${time}`; 74 | } 75 | } else { 76 | result = time; 77 | } 78 | this.setData({ 79 | time: result 80 | }); 81 | 82 | }, 83 | formatNum(num) { 84 | return num > 9 ? num : `0${num}`; 85 | }, 86 | endfn() { 87 | this.triggerEvent('callback', {}); 88 | } 89 | } 90 | }); 91 | -------------------------------------------------------------------------------- /static/iview/count-down/index.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "component": true 4 | } 5 | -------------------------------------------------------------------------------- /static/iview/count-down/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | {{time}} 3 | 4 | 5 | -------------------------------------------------------------------------------- /static/iview/count-down/index.wxss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yshkk/bqb-mpvue/5b86537529eb3693bca7ccd38c6b83e479926887/static/iview/count-down/index.wxss -------------------------------------------------------------------------------- /static/iview/divider/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | properties: { 4 | content: { 5 | type: String, 6 | value: '' 7 | }, 8 | height: { 9 | type: Number, 10 | value: 48 11 | }, 12 | color: { 13 | type: String, 14 | value: '#80848f' 15 | }, 16 | lineColor: { 17 | type: String, 18 | value: '#e9eaec' 19 | }, 20 | size: { 21 | type: String, 22 | value: 12 23 | } 24 | } 25 | }) 26 | -------------------------------------------------------------------------------- /static/iview/divider/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/divider/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{content}} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | module.exports = { 12 | getStyle : function(color,size,height){ 13 | var color = 'color:' + color +';'; 14 | var size = 'font-size:' + size + 'px;'; 15 | var height = 'height:' + height+'px;' 16 | return color + size + height; 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /static/iview/divider/index.wxss: -------------------------------------------------------------------------------- 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:2rpx;background-color:#f7f7f7;top:50%}.i-divider-content{background:#fff;position:relative;z-index:1;display:inline-block;padding:0 10px} 2 | -------------------------------------------------------------------------------- /static/iview/drawer/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | properties: { 4 | visible: { 5 | type: Boolean, 6 | value: false 7 | }, 8 | 9 | mask: { 10 | type: Boolean, 11 | value: true 12 | }, 13 | 14 | maskClosable: { 15 | type: Boolean, 16 | value: true 17 | }, 18 | 19 | mode: { 20 | type: String, 21 | value: 'left' // left right 22 | } 23 | }, 24 | data: {}, 25 | methods: { 26 | handleMaskClick() { 27 | if (!this.data.maskClosable) { 28 | return; 29 | } 30 | this.triggerEvent('close', {}); 31 | } 32 | } 33 | }); 34 | -------------------------------------------------------------------------------- /static/iview/drawer/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/drawer/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /static/iview/drawer/index.wxss: -------------------------------------------------------------------------------- 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)} -------------------------------------------------------------------------------- /static/iview/grid-icon/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | 4 | relations: { 5 | '../grid-item/index': { 6 | type: 'parent' 7 | } 8 | }, 9 | 10 | }); 11 | -------------------------------------------------------------------------------- /static/iview/grid-icon/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/grid-icon/index.wxml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /static/iview/grid-icon/index.wxss: -------------------------------------------------------------------------------- 1 | .i-grid-icon{display:block;width:28px;height:28px;margin:0 auto}.i-grid-icon image{width:100%;height:100%} -------------------------------------------------------------------------------- /static/iview/grid-item/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | 4 | relations: { 5 | '../grid/index': { 6 | type: 'parent' 7 | }, 8 | '../grid-icon/index': { 9 | type: 'child' 10 | } 11 | }, 12 | 13 | data: { 14 | width: '33.33%' 15 | } 16 | }); 17 | -------------------------------------------------------------------------------- /static/iview/grid-item/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/grid-item/index.wxml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /static/iview/grid-item/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/grid-label/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | 4 | relations: { 5 | '../grid-item/index': { 6 | type: 'parent' 7 | } 8 | }, 9 | 10 | }); 11 | -------------------------------------------------------------------------------- /static/iview/grid-label/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/grid-label/index.wxml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /static/iview/grid-label/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/grid/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | 4 | relations: { 5 | '../grid-item/index': { 6 | type: 'child', 7 | linked () { 8 | this.setGridItemWidth(); 9 | }, 10 | linkChanged () { 11 | this.setGridItemWidth(); 12 | }, 13 | unlinked () { 14 | this.setGridItemWidth(); 15 | } 16 | } 17 | }, 18 | 19 | methods: { 20 | setGridItemWidth () { 21 | const nodes = this.getRelationNodes('../grid-item/index'); 22 | 23 | // const len = nodes.length; 24 | // if (len < 3) { 25 | // nodes.forEach(item => { 26 | // item.setData({ 27 | // 'width': '33.33%' 28 | // }); 29 | // }); 30 | // } else { 31 | // const width = 100 / nodes.length; 32 | // nodes.forEach(item => { 33 | // item.setData({ 34 | // 'width': width + '%' 35 | // }); 36 | // }); 37 | // } 38 | const width = 100 / nodes.length; 39 | nodes.forEach(item => { 40 | item.setData({ 41 | 'width': width + '%' 42 | }); 43 | }); 44 | } 45 | }, 46 | 47 | ready () { 48 | this.setGridItemWidth(); 49 | } 50 | }); 51 | -------------------------------------------------------------------------------- /static/iview/grid/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/grid/index.wxml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /static/iview/grid/index.wxss: -------------------------------------------------------------------------------- 1 | .i-grid{border-top:1rpx solid #e9eaec;border-left:1rpx solid #e9eaec;overflow:hidden} -------------------------------------------------------------------------------- /static/iview/icon/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | 4 | properties: { 5 | type: { 6 | type: String, 7 | value: '' 8 | }, 9 | custom: { 10 | type: String, 11 | value: '' 12 | }, 13 | size: { 14 | type: Number, 15 | value: 14 16 | }, 17 | color: { 18 | type: String, 19 | value: '' 20 | } 21 | } 22 | }); 23 | -------------------------------------------------------------------------------- /static/iview/icon/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/icon/index.wxml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /static/iview/index-item/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | properties : { 4 | name : { 5 | type : String, 6 | value : '' 7 | } 8 | }, 9 | relations : { 10 | '../index/index' : { 11 | type : 'parent' 12 | } 13 | }, 14 | data : { 15 | top : 0, 16 | height : 0, 17 | currentName : '' 18 | }, 19 | methods: { 20 | updateDataChange() { 21 | const className = '.i-index-item'; 22 | const query = wx.createSelectorQuery().in(this); 23 | query.select( className ).boundingClientRect((res)=>{ 24 | this.setData({ 25 | top : res.top, 26 | height : res.height, 27 | currentName : this.data.name 28 | }) 29 | }).exec() 30 | } 31 | } 32 | }) -------------------------------------------------------------------------------- /static/iview/index-item/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/index-item/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | {{name}} 3 | 4 | 5 | 6 | 7 | 8 | module.exports = { 9 | 10 | } 11 | 12 | -------------------------------------------------------------------------------- /static/iview/index-item/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/index/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | properties : { 4 | height : { 5 | type : String, 6 | value : '300' 7 | }, 8 | itemHeight : { 9 | type : Number, 10 | value : 18 11 | } 12 | }, 13 | relations : { 14 | '../index-item/index' : { 15 | type : 'child', 16 | linked(){ 17 | this._updateDataChange(); 18 | }, 19 | linkChanged () { 20 | this._updateDataChange(); 21 | }, 22 | unlinked () { 23 | this._updateDataChange(); 24 | } 25 | } 26 | }, 27 | data : { 28 | scrollTop : 0, 29 | fixedData : [], 30 | current : 0, 31 | timer : null, 32 | startTop : 0, 33 | itemLength : 0, 34 | currentName : '', 35 | isTouches : false 36 | }, 37 | methods : { 38 | loop(){}, 39 | _updateDataChange( ){ 40 | const indexItems = this.getRelationNodes('../index-item/index'); 41 | const len = indexItems.length; 42 | const fixedData = this.data.fixedData; 43 | /* 44 | * 使用函数节流限制重复去设置数组内容进而限制多次重复渲染 45 | * 暂时没有研究微信在渲染的时候是否会进行函数节流 46 | */ 47 | if (len > 0) { 48 | 49 | if( this.data.timer ){ 50 | clearTimeout( this.data.timer ) 51 | this.setData({ 52 | timer : null 53 | }) 54 | } 55 | 56 | this.data.timer = setTimeout(()=>{ 57 | const data = []; 58 | indexItems.forEach((item) => { 59 | if( item.data.name && fixedData.indexOf( item.data.name ) === -1 ){ 60 | data.push(item.data.name); 61 | item.updateDataChange(); 62 | } 63 | }) 64 | this.setData({ 65 | fixedData : data, 66 | itemLength : indexItems.length 67 | }) 68 | //组件加载完成之后重新设置顶部高度 69 | this.setTouchStartVal(); 70 | },0); 71 | this.setData({ 72 | timer : this.data.timer 73 | }) 74 | 75 | } 76 | }, 77 | handlerScroll(event){ 78 | const detail = event.detail; 79 | const scrollTop = detail.scrollTop; 80 | const indexItems = this.getRelationNodes('../index-item/index'); 81 | indexItems.forEach((item,index)=>{ 82 | let data = item.data; 83 | let offset = data.top + data.height; 84 | if( scrollTop < offset && scrollTop >= data.top ){ 85 | this.setData({ 86 | current : index, 87 | currentName : data.currentName 88 | }) 89 | } 90 | }) 91 | }, 92 | getCurrentItem(index){ 93 | const indexItems = this.getRelationNodes('../index-item/index'); 94 | let result = {}; 95 | result = indexItems[index].data; 96 | result.total = indexItems.length; 97 | return result; 98 | }, 99 | triggerCallback(options){ 100 | this.triggerEvent('change',options) 101 | }, 102 | handlerFixedTap(event){ 103 | const eindex = event.currentTarget.dataset.index; 104 | const item = this.getCurrentItem(eindex); 105 | this.setData({ 106 | scrollTop : item.top, 107 | currentName : item.currentName, 108 | isTouches : true 109 | }) 110 | this.triggerCallback({ 111 | index : eindex, 112 | current : item.currentName 113 | }) 114 | }, 115 | handlerTouchMove(event){ 116 | const data = this.data; 117 | const touches = event.touches[0] || {}; 118 | const pageY = touches.pageY; 119 | const rest = pageY - data.startTop; 120 | let index = Math.ceil( rest/data.itemHeight ); 121 | index = index >= data.itemLength ? data.itemLength -1 : index; 122 | const movePosition = this.getCurrentItem(index); 123 | 124 | /* 125 | * 当touch选中的元素和当前currentName不相等的时候才震动一下 126 | * 微信震动事件 127 | */ 128 | if( movePosition.name !== this.data.currentName ){ 129 | wx.vibrateShort(); 130 | } 131 | 132 | this.setData({ 133 | scrollTop : movePosition.top, 134 | currentName : movePosition.name, 135 | isTouches : true 136 | }) 137 | 138 | this.triggerCallback({ 139 | index : index, 140 | current : movePosition.name 141 | }) 142 | }, 143 | handlerTouchEnd(){ 144 | this.setData({ 145 | isTouches : false 146 | }) 147 | }, 148 | setTouchStartVal(){ 149 | const className = '.i-index-fixed'; 150 | const query = wx.createSelectorQuery().in(this); 151 | query.select( className ).boundingClientRect((res)=>{ 152 | this.setData({ 153 | startTop : res.top 154 | }) 155 | }).exec() 156 | } 157 | } 158 | }) -------------------------------------------------------------------------------- /static/iview/index/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/index/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 17 | {{item}} 18 | 19 | 20 | {{currentName}} 21 | 22 | 23 | 24 | module.exports = { 25 | setScrollStyle : function(height){ 26 | var units = ['%','px','rem','rpx','em','rem']; 27 | var hasUnits = false; 28 | for( var i = 0; i < units.length;i++ ){ 29 | var u = units[i]; 30 | if( height.indexOf( u ) > -1 ){ 31 | hasUnits = true; 32 | break; 33 | } 34 | } 35 | return 'height:'+ ( hasUnits ? height : height+'px' ); 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /static/iview/index/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/input-number/index.js: -------------------------------------------------------------------------------- 1 | function addNum (num1, num2) { 2 | let sq1, sq2, m; 3 | try { 4 | sq1 = num1.toString().split('.')[1].length; 5 | } 6 | catch (e) { 7 | sq1 = 0; 8 | } 9 | try { 10 | sq2 = num2.toString().split('.')[1].length; 11 | } 12 | catch (e) { 13 | sq2 = 0; 14 | } 15 | m = Math.pow(10, Math.max(sq1, sq2)); 16 | return (Math.round(num1 * m) + Math.round(num2 * m)) / m; 17 | } 18 | 19 | Component({ 20 | externalClasses: ['i-class'], 21 | 22 | properties: { 23 | // small || default || large 24 | size: String, 25 | value: { 26 | type: Number, 27 | value: 1 28 | }, 29 | min: { 30 | type: Number, 31 | value: -Infinity 32 | }, 33 | max: { 34 | type: Number, 35 | value: Infinity 36 | }, 37 | step: { 38 | type: Number, 39 | value: 1 40 | } 41 | }, 42 | 43 | 44 | methods: { 45 | handleChangeStep(e, type) { 46 | const { dataset = {} } = e.currentTarget; 47 | const { disabled } = dataset; 48 | const { step } = this.data; 49 | let { value } = this.data; 50 | 51 | if (disabled) return null; 52 | 53 | if (type === 'minus') { 54 | value = addNum(value, -step); 55 | } else if (type === 'plus') { 56 | value = addNum(value, step); 57 | } 58 | 59 | if (value < this.data.min || value > this.data.max) return null; 60 | 61 | this.handleEmit(value, type); 62 | }, 63 | 64 | handleMinus(e) { 65 | this.handleChangeStep(e, 'minus'); 66 | }, 67 | 68 | handlePlus(e) { 69 | this.handleChangeStep(e, 'plus'); 70 | }, 71 | 72 | handleBlur(e) { 73 | let { value } = e.detail; 74 | const { min, max } = this.data; 75 | 76 | if (!value) { 77 | setTimeout(() => { 78 | this.handleEmit(value); 79 | }, 16); 80 | return; 81 | } 82 | 83 | value = +value; 84 | if (value > max) { 85 | value = max; 86 | } else if (value < min) { 87 | value = min; 88 | } 89 | 90 | this.handleEmit(value); 91 | }, 92 | handleEmit (value, type) { 93 | const data = { 94 | value: value 95 | }; 96 | if (type) data.type = type; 97 | 98 | this.triggerEvent('change', data); 99 | } 100 | } 101 | }); 102 | -------------------------------------------------------------------------------- /static/iview/input-number/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/input-number/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | - 3 | 4 | + 5 | 6 | -------------------------------------------------------------------------------- /static/iview/input-number/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/input/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | behaviors: ['wx://form-field'], 3 | 4 | externalClasses: ['i-class'], 5 | 6 | properties: { 7 | title: { 8 | type: String 9 | }, 10 | // text || textarea || password || number 11 | type: { 12 | type: String, 13 | value: 'text' 14 | }, 15 | disabled: { 16 | type: Boolean, 17 | value: false 18 | }, 19 | placeholder: { 20 | type: String, 21 | value: '' 22 | }, 23 | autofocus: { 24 | type: Boolean, 25 | value: false 26 | }, 27 | mode: { 28 | type: String, 29 | value: 'normal' 30 | }, 31 | right: { 32 | type: Boolean, 33 | value: false 34 | }, 35 | error: { 36 | type: Boolean, 37 | value: false 38 | }, 39 | maxlength: { 40 | type: Number 41 | } 42 | }, 43 | 44 | methods: { 45 | handleInputChange(event) { 46 | const { detail = {} } = event; 47 | const { value = '' } = detail; 48 | this.setData({ value }); 49 | 50 | this.triggerEvent('change', event); 51 | }, 52 | 53 | handleInputFocus(event) { 54 | this.triggerEvent('focus', event); 55 | }, 56 | 57 | handleInputBlur(event) { 58 | this.triggerEvent('blur', event); 59 | } 60 | } 61 | }); 62 | -------------------------------------------------------------------------------- /static/iview/input/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/input/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | {{ title }} 3 | 17 | 31 | 32 | -------------------------------------------------------------------------------- /static/iview/input/index.wxss: -------------------------------------------------------------------------------- 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;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} 2 | -------------------------------------------------------------------------------- /static/iview/load-more/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | 4 | properties: { 5 | loading: { 6 | type: Boolean, 7 | value: true 8 | }, 9 | tip: { 10 | type: String, 11 | value: '' 12 | } 13 | }, 14 | }); 15 | -------------------------------------------------------------------------------- /static/iview/load-more/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/load-more/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{ tip }} 5 | 正在加载 6 | 7 | 8 | -------------------------------------------------------------------------------- /static/iview/load-more/index.wxss: -------------------------------------------------------------------------------- 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)}} -------------------------------------------------------------------------------- /static/iview/message/index.js: -------------------------------------------------------------------------------- 1 | const default_data = { 2 | visible: false, 3 | content: '', 4 | duration: 2, 5 | type: 'default', // default || success || warning || error 6 | }; 7 | 8 | let timmer = null; 9 | 10 | Component({ 11 | externalClasses: ['i-class'], 12 | 13 | data: { 14 | ...default_data 15 | }, 16 | 17 | methods: { 18 | handleShow (options) { 19 | const { type = 'default', duration = 2 } = options; 20 | 21 | this.setData({ 22 | ...options, 23 | type, 24 | duration, 25 | visible: true 26 | }); 27 | 28 | const d = this.data.duration * 1000; 29 | 30 | if (timmer) clearTimeout(timmer); 31 | if (d !== 0) { 32 | timmer = setTimeout(() => { 33 | this.handleHide(); 34 | timmer = null; 35 | }, d); 36 | } 37 | }, 38 | 39 | handleHide () { 40 | this.setData({ 41 | ...default_data 42 | }); 43 | } 44 | } 45 | }); -------------------------------------------------------------------------------- /static/iview/message/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/message/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | {{ content }} 3 | -------------------------------------------------------------------------------- /static/iview/message/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/modal/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class', 'i-class-mask'], 3 | 4 | properties: { 5 | visible: { 6 | type: Boolean, 7 | value: false 8 | }, 9 | title: { 10 | type: String, 11 | value: '' 12 | }, 13 | showOk: { 14 | type: Boolean, 15 | value: true 16 | }, 17 | showCancel: { 18 | type: Boolean, 19 | value: true 20 | }, 21 | okText: { 22 | type: String, 23 | value: '确定' 24 | }, 25 | cancelText: { 26 | type: String, 27 | value: '取消' 28 | }, 29 | // 按钮组,有此值时,不显示 ok 和 cancel 按钮 30 | actions: { 31 | type: Array, 32 | value: [] 33 | }, 34 | // horizontal || vertical 35 | actionMode: { 36 | type: String, 37 | value: 'horizontal' 38 | } 39 | }, 40 | 41 | methods: { 42 | handleClickItem ({ currentTarget = {} }) { 43 | const dataset = currentTarget.dataset || {}; 44 | const { index } = dataset; 45 | this.triggerEvent('click', { index }); 46 | }, 47 | handleClickOk () { 48 | this.triggerEvent('ok'); 49 | }, 50 | handleClickCancel () { 51 | this.triggerEvent('cancel'); 52 | } 53 | } 54 | }); 55 | -------------------------------------------------------------------------------- /static/iview/modal/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": { 4 | "i-grid": "../grid/index", 5 | "i-grid-item": "../grid-item/index", 6 | "i-button": "../button/index", 7 | "i-icon": "../icon/index" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /static/iview/modal/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{ title }} 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | {{ cancelText }} 25 | 26 | 27 | {{ okText }} 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /static/iview/modal/index.wxss: -------------------------------------------------------------------------------- 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)}} -------------------------------------------------------------------------------- /static/iview/notice-bar/index.js: -------------------------------------------------------------------------------- 1 | const VALID_MODE = ['closeable']; 2 | const FONT_COLOR = '#f60'; 3 | const BG_COLOR = '#fff7cc'; 4 | 5 | Component({ 6 | externalClasses: ['i-class'], 7 | 8 | properties: { 9 | closable: { 10 | type: Boolean, 11 | value: false 12 | }, 13 | icon: { 14 | type: String, 15 | value: '' 16 | }, 17 | loop: { 18 | type: Boolean, 19 | value: false 20 | }, 21 | // 背景颜色 22 | backgroundcolor: { 23 | type: String, 24 | value: '#fefcec' 25 | }, 26 | // 字体及图标颜色 27 | color: { 28 | type: String, 29 | value: '#f76a24' 30 | }, 31 | // 滚动速度 32 | speed: { 33 | type: Number, 34 | value: 1000 35 | } 36 | }, 37 | 38 | data: { 39 | show: true, 40 | wrapWidth: 0, 41 | width: 0, 42 | duration: 0, 43 | animation: null, 44 | timer: null, 45 | }, 46 | detached() { 47 | this.destroyTimer(); 48 | }, 49 | ready() { 50 | if (this.data.loop) { 51 | this.initAnimation(); 52 | } 53 | }, 54 | 55 | methods: { 56 | initAnimation() { 57 | wx.createSelectorQuery().in(this).select('.i-noticebar-content-wrap').boundingClientRect((wrapRect) => { 58 | wx.createSelectorQuery().in(this).select('.i-noticebar-content').boundingClientRect((rect) => { 59 | const duration = rect.width / 40 * this.data.speed; 60 | const animation = wx.createAnimation({ 61 | duration: duration, 62 | timingFunction: "linear", 63 | }); 64 | this.setData({ 65 | wrapWidth: wrapRect.width, 66 | width: rect.width, 67 | duration: duration, 68 | animation: animation 69 | }, () => { 70 | this.startAnimation(); 71 | }); 72 | }).exec(); 73 | 74 | }).exec(); 75 | }, 76 | startAnimation() { 77 | //reset 78 | if (this.data.animation.option.transition.duration !== 0) { 79 | this.data.animation.option.transition.duration = 0; 80 | const resetAnimation = this.data.animation.translateX(this.data.wrapWidth).step(); 81 | this.setData({ 82 | animationData: resetAnimation.export() 83 | }); 84 | } 85 | this.data.animation.option.transition.duration = this.data.duration; 86 | const animationData = this.data.animation.translateX(-this.data.width).step(); 87 | setTimeout(() => { 88 | this.setData({ 89 | animationData: animationData.export() 90 | }); 91 | }, 100); 92 | const timer = setTimeout(() => { 93 | this.startAnimation(); 94 | }, this.data.duration); 95 | this.setData({ 96 | timer, 97 | }); 98 | }, 99 | destroyTimer() { 100 | if (this.data.timer) { 101 | clearTimeout(this.data.timer); 102 | } 103 | }, 104 | handleClose() { 105 | this.destroyTimer(); 106 | this.setData({ 107 | show: false, 108 | timer: null 109 | }); 110 | } 111 | } 112 | }); 113 | -------------------------------------------------------------------------------- /static/iview/notice-bar/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": 4 | { 5 | "i-icon": "../icon/index" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /static/iview/notice-bar/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /static/iview/notice-bar/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/page/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | 4 | options: { 5 | multipleSlots: true 6 | }, 7 | 8 | properties: { 9 | // button || number || pointer 10 | mode: { 11 | type: String, 12 | value: 'button' 13 | }, 14 | current: { 15 | type: Number, 16 | value: 1 17 | }, 18 | total: { 19 | type: Number, 20 | value: 0 21 | }, 22 | // 是否隐藏数值 23 | simple: { 24 | type: Boolean, 25 | value: false 26 | } 27 | }, 28 | 29 | methods: { 30 | handleChange (type) { 31 | this.triggerEvent('change', { 32 | type: type 33 | }); 34 | }, 35 | handlePrev () { 36 | this.handleChange('prev'); 37 | }, 38 | handleNext () { 39 | this.handleChange('next'); 40 | } 41 | } 42 | }); 43 | -------------------------------------------------------------------------------- /static/iview/page/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": 4 | { 5 | "i-button": "../button/index" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /static/iview/page/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{ current }}/{{total}} 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /static/iview/page/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/panel/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | 4 | properties: { 5 | title: { 6 | type: String, 7 | value: '' 8 | }, 9 | // 标题顶部距离 10 | hideTop: { 11 | type: Boolean, 12 | value: false 13 | }, 14 | hideBorder: { 15 | type: Boolean, 16 | value: false 17 | } 18 | } 19 | }); 20 | -------------------------------------------------------------------------------- /static/iview/panel/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/panel/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | {{ title }} 3 | 4 | 5 | -------------------------------------------------------------------------------- /static/iview/panel/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/progress/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | 4 | properties: { 5 | percent: { 6 | type: Number, 7 | value: 0 8 | }, 9 | // normal || active || wrong || success 10 | status: { 11 | type: String, 12 | value: 'normal' 13 | }, 14 | strokeWidth: { 15 | type: Number, 16 | value: 10 17 | }, 18 | hideInfo: { 19 | type: Boolean, 20 | value: false 21 | } 22 | } 23 | }); 24 | -------------------------------------------------------------------------------- /static/iview/progress/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/progress/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ percent }}% 9 | 10 | -------------------------------------------------------------------------------- /static/iview/progress/index.wxss: -------------------------------------------------------------------------------- 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%}} -------------------------------------------------------------------------------- /static/iview/radio-group/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | relations: { 4 | '../radio/index': { 5 | type: 'child', 6 | linked() { 7 | this.changeCurrent(); 8 | }, 9 | linkChanged() { 10 | this.changeCurrent(); 11 | }, 12 | unlinked() { 13 | this.changeCurrent(); 14 | } 15 | } 16 | }, 17 | properties: { 18 | current: { 19 | type: String, 20 | value: '', 21 | observer: 'changeCurrent' 22 | }, 23 | }, 24 | methods: { 25 | changeCurrent(val = this.data.current) { 26 | let items = this.getRelationNodes('../radio/index'); 27 | const len = items.length; 28 | if (len > 0) { 29 | items.forEach(item => { 30 | item.changeCurrent(val === item.data.value); 31 | }); 32 | } 33 | }, 34 | emitEvent(current) { 35 | this.triggerEvent('change', current); 36 | } 37 | } 38 | }); 39 | -------------------------------------------------------------------------------- /static/iview/radio-group/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": 4 | { 5 | "i-cell-group": "../cell-group/index" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /static/iview/radio-group/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /static/iview/radio-group/index.wxss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yshkk/bqb-mpvue/5b86537529eb3693bca7ccd38c6b83e479926887/static/iview/radio-group/index.wxss -------------------------------------------------------------------------------- /static/iview/radio/index.js: -------------------------------------------------------------------------------- 1 | const prefixCls = 'i-radio'; 2 | 3 | Component({ 4 | externalClasses: ['i-class'], 5 | relations: { 6 | '../radio-group/index': { 7 | type: 'parent' 8 | } 9 | }, 10 | properties: { 11 | value: { 12 | type: String, 13 | value: '' 14 | }, 15 | checked: { 16 | type: Boolean, 17 | value: false 18 | }, 19 | disabled: { 20 | type: Boolean, 21 | value: false 22 | }, 23 | color: { 24 | type: String, 25 | value: '#2d8cf0' 26 | }, 27 | position: { 28 | type: String, 29 | value: 'left', //left right 30 | observer: 'setPosition' 31 | } 32 | }, 33 | data: { 34 | checked: true, 35 | positionCls: `${prefixCls}-radio-left`, 36 | }, 37 | attached() { 38 | this.setPosition(); 39 | }, 40 | methods: { 41 | changeCurrent(current) { 42 | this.setData({ checked: current }); 43 | }, 44 | radioChange() { 45 | if (this.data.disabled) return; 46 | const item = { current: !this.data.checked, value: this.data.value }; 47 | const parent = this.getRelationNodes('../radio-group/index')[0]; 48 | parent ? parent.emitEvent(item) : this.triggerEvent('change', item); 49 | }, 50 | setPosition() { 51 | this.setData({ 52 | positionCls: this.data.position.indexOf('left') !== -1 ? `${prefixCls}-radio-left` : `${prefixCls}-radio-right`, 53 | }); 54 | } 55 | } 56 | }); 57 | -------------------------------------------------------------------------------- /static/iview/radio/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": 4 | { 5 | "i-cell": "../cell/index" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /static/iview/radio/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /static/iview/radio/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/rate/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | properties : { 4 | count : { 5 | type : Number, 6 | value : 5 7 | }, 8 | value : { 9 | type : Number, 10 | value : 0 11 | }, 12 | disabled : { 13 | type : Boolean, 14 | value : false 15 | }, 16 | size : { 17 | type : Number, 18 | value : 20 19 | }, 20 | name : { 21 | type : String, 22 | value : '' 23 | } 24 | }, 25 | data : { 26 | touchesStart : { 27 | pageX : 0 28 | } 29 | }, 30 | methods : { 31 | handleClick(e){ 32 | const data = this.data; 33 | if( data.disabled ){ 34 | return; 35 | } 36 | const index = e.currentTarget.dataset.index; 37 | this.triggerEvent('change',{ 38 | index : index + 1 39 | }) 40 | }, 41 | handleTouchMove(e){ 42 | const data = this.data; 43 | if( data.disabled ){ 44 | return; 45 | } 46 | if( !e.changedTouches[0] ){ 47 | return; 48 | } 49 | const movePageX = e.changedTouches[0].pageX; 50 | const space = movePageX - data.touchesStart.pageX; 51 | 52 | if( space <= 0 ){ 53 | return; 54 | } 55 | let setIndex = Math.ceil( space/data.size ); 56 | setIndex = setIndex > data.count ? data.count : setIndex ; 57 | this.triggerEvent('change',{ 58 | index : setIndex 59 | }) 60 | } 61 | }, 62 | ready(){ 63 | const className = '.i-rate'; 64 | var query = wx.createSelectorQuery().in(this) 65 | query.select( className ).boundingClientRect((res)=>{ 66 | this.data.touchesStart.pageX = res.left || 0; 67 | }).exec() 68 | } 69 | }); 70 | -------------------------------------------------------------------------------- /static/iview/rate/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents":{ 4 | "i-icon": "../icon/index" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /static/iview/rate/index.wxml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 10 | 11 | 12 | 13 | 14 | 15 | var prefixCls = 'i-rate'; 16 | module.exports = { 17 | getCurrent : function( value,index ){ 18 | if( index < value ){ 19 | return prefixCls + '-current' 20 | } 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /static/iview/rate/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/row/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | 4 | relations: { 5 | '../col/index': { 6 | type: 'child' 7 | } 8 | } 9 | }); 10 | -------------------------------------------------------------------------------- /static/iview/row/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/row/index.wxml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /static/iview/row/index.wxss: -------------------------------------------------------------------------------- 1 | .i-row:after{content:"";display:table;clear:both} -------------------------------------------------------------------------------- /static/iview/slide/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | options: { 4 | // 在组件定义时的选项中启用多slot支持 5 | multipleSlots: true 6 | }, 7 | methods : { 8 | handleTap2(){ 9 | console.log(event,1111111) 10 | }, 11 | handleTap3(){ 12 | 13 | } 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /static/iview/slide/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": 4 | { 5 | "i-button": "../button/index", 6 | "i-icon": "../icon/index" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /static/iview/slide/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 1111 3 | 4 | -------------------------------------------------------------------------------- /static/iview/slide/index.wxss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yshkk/bqb-mpvue/5b86537529eb3693bca7ccd38c6b83e479926887/static/iview/slide/index.wxss -------------------------------------------------------------------------------- /static/iview/spin/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | 4 | properties: { 5 | // small || default || large 6 | size: { 7 | type: String, 8 | value: 'default' 9 | }, 10 | fix: { 11 | type: Boolean, 12 | value: false 13 | }, 14 | fullscreen: { 15 | type: Boolean, 16 | value: false 17 | }, 18 | custom: { 19 | type: Boolean, 20 | value: false 21 | } 22 | } 23 | }); 24 | -------------------------------------------------------------------------------- /static/iview/spin/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/spin/index.wxml: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 |
5 |
6 |
7 | -------------------------------------------------------------------------------- /static/iview/spin/index.wxss: -------------------------------------------------------------------------------- 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}} -------------------------------------------------------------------------------- /static/iview/step/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | properties : { 4 | status : { 5 | type : String, 6 | //wait、process、finish、error 7 | value : '' 8 | }, 9 | title : { 10 | type : String, 11 | value : '' 12 | }, 13 | content : { 14 | type : String, 15 | value : '' 16 | }, 17 | icon : { 18 | type : String, 19 | value : '' 20 | } 21 | }, 22 | options: { 23 | // 在组件定义时的选项中启用多slot支持 24 | multipleSlots: true 25 | }, 26 | relations : { 27 | '../steps/index' : { 28 | type : 'parent' 29 | } 30 | }, 31 | data : { 32 | //step length 33 | len : 1, 34 | //current in step index 35 | index : 0, 36 | //parent component select current index 37 | current : 0, 38 | //css direction 39 | direction : 'horizontal' 40 | }, 41 | methods : { 42 | updateDataChange( options ){ 43 | this.setData({ 44 | len : options.len, 45 | index : options.index, 46 | current : options.current, 47 | direction : options.direction 48 | }) 49 | } 50 | } 51 | 52 | }) -------------------------------------------------------------------------------- /static/iview/step/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": 4 | { 5 | "i-icon": "../icon/index" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /static/iview/step/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ index+1 }} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | {{title}} 12 | 13 | 14 | 15 | 16 | 17 | {{content}} 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | var allStatus = ['wait','process','finish','error']; 26 | module.exports = { 27 | noIco : function( status,current,index,icon ){ 28 | var aindex = allStatus.indexOf(status); 29 | var noIcon = true; 30 | if( index < current || icon !== '' ){ 31 | noIcon = false; 32 | } 33 | return noIcon; 34 | }, 35 | getIcoClass : function( status,ico ){ 36 | var class = ''; 37 | if( status === 'error' ){ 38 | class = 'close'; 39 | }else{ 40 | class = 'right'; 41 | } 42 | if( ico !== '' ){ 43 | class = ico; 44 | } 45 | return class; 46 | }, 47 | getItemStyle : function(len,direction){ 48 | if( direction === 'horizontal' ){ 49 | return 'width :'+100/len + '%'; 50 | }else{ 51 | return 'width : 100%;'; 52 | } 53 | }, 54 | getClass : function( status,current,index ) { 55 | //wait、process、finish、error 56 | var startClass = 'i-step-' 57 | var classes = ''; 58 | var cindex = allStatus.indexOf( status ); 59 | if( cindex !== -1 ){ 60 | classes = startClass + allStatus[cindex]; 61 | } 62 | if( index < current ){ 63 | classes = startClass + 'finish'; 64 | }else if( index === current ){ 65 | classes = startClass + 'process'; 66 | } 67 | return classes; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /static/iview/step/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/steps/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | properties : { 4 | current : { 5 | type : Number, 6 | value : -1, 7 | observer : '_updateDataChange' 8 | }, 9 | status : { 10 | type : String, 11 | //wait、process、finish、error 12 | value : '' 13 | }, 14 | direction : { 15 | type : String, 16 | //value has horizontal or vertical 17 | value : 'horizontal' 18 | } 19 | }, 20 | relations : { 21 | '../step/index' : { 22 | type : 'child', 23 | linked(){ 24 | this._updateDataChange(); 25 | }, 26 | linkChanged () { 27 | this._updateDataChange(); 28 | }, 29 | unlinked () { 30 | this._updateDataChange(); 31 | } 32 | } 33 | }, 34 | methods: { 35 | _updateDataChange() { 36 | let steps = this.getRelationNodes('../step/index'); 37 | const len = steps.length; 38 | if (len > 0) { 39 | steps.forEach((step, index) => { 40 | step.updateDataChange({ 41 | len : len, 42 | index : index, 43 | current : this.data.current, 44 | direction : this.data.direction 45 | }); 46 | }); 47 | } 48 | } 49 | } 50 | }) -------------------------------------------------------------------------------- /static/iview/steps/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/steps/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /static/iview/steps/index.wxss: -------------------------------------------------------------------------------- 1 | .i-steps{width:100%} -------------------------------------------------------------------------------- /static/iview/sticky-item/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | options: { 4 | multipleSlots: true 5 | }, 6 | relations : { 7 | '../sticky/index' : { 8 | type : 'parent' 9 | } 10 | }, 11 | data : { 12 | top : 0, 13 | height : 0, 14 | isFixed : false, 15 | index : -1, 16 | }, 17 | methods: { 18 | updateScrollTopChange(scrollTop){ 19 | const data = this.data; 20 | const top = data.top; 21 | const height = data.height; 22 | this.setData({ 23 | isFixed : ( scrollTop >= top && scrollTop < top + height ) ? true : false 24 | }) 25 | }, 26 | updateDataChange(index) { 27 | const className = '.i-sticky-item'; 28 | const query = wx.createSelectorQuery().in(this); 29 | query.select( className ).boundingClientRect((res)=>{ 30 | if( res ){ 31 | this.setData({ 32 | top : res.top, 33 | height : res.height, 34 | index : index 35 | }) 36 | } 37 | }).exec() 38 | } 39 | } 40 | }) -------------------------------------------------------------------------------- /static/iview/sticky-item/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/sticky-item/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /static/iview/sticky-item/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/sticky/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | properties : { 4 | scrollTop : { 5 | type : Number, 6 | observer(val){ 7 | this._updateScrollTopChange(); 8 | } 9 | } 10 | }, 11 | relations : { 12 | '../sticky-item/index' : { 13 | type : 'child', 14 | linked(){ 15 | this._updateDataChange(); 16 | }, 17 | linkChanged () { 18 | this._updateDataChange(); 19 | }, 20 | unlinked () { 21 | this._updateDataChange(); 22 | } 23 | } 24 | }, 25 | data : { 26 | timer : null, 27 | itemLength : 0, 28 | }, 29 | methods : { 30 | _updateScrollTopChange(){ 31 | const stickies = this.getRelationNodes('../sticky-item/index'); 32 | if( stickies.length > 0 ){ 33 | stickies.forEach((item) => { 34 | if( item ){ 35 | item.updateScrollTopChange( this.data.scrollTop ); 36 | } 37 | }) 38 | } 39 | }, 40 | _updateDataChange( ){ 41 | const stickies = this.getRelationNodes('../sticky-item/index'); 42 | if( stickies.length > 0 ){ 43 | if( this.data.timer ){ 44 | clearTimeout( this.data.timer ) 45 | this.setData({ 46 | timer : null 47 | }) 48 | } 49 | this.data.timer = setTimeout(()=>{ 50 | stickies.forEach((item,index) => { 51 | if( item ){ 52 | item.updateDataChange(index); 53 | } 54 | }) 55 | },0) 56 | this.setData({ 57 | timer : this.data.timer 58 | }) 59 | } 60 | } 61 | } 62 | 63 | }) -------------------------------------------------------------------------------- /static/iview/sticky/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/sticky/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /static/iview/sticky/index.wxss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yshkk/bqb-mpvue/5b86537529eb3693bca7ccd38c6b83e479926887/static/iview/sticky/index.wxss -------------------------------------------------------------------------------- /static/iview/swipeout/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * touch事件判断方式 3 | * https://github.com/madrobby/zepto/blob/master/src/touch.js#files 4 | */ 5 | function swipeDirection(x1, x2, y1, y2) { 6 | return Math.abs(x1 - x2) >= 7 | Math.abs(y1 - y2) ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down') 8 | } 9 | 10 | Component({ 11 | externalClasses: ['i-class'], 12 | properties: { 13 | actions: { 14 | value: [], 15 | type: Array, 16 | observer : '_updateButtonSize' 17 | }, 18 | unclosable : { 19 | value : false, 20 | type : Boolean 21 | }, 22 | toggle : { 23 | value : false, 24 | type : Boolean, 25 | observer : 'closeButtonGroup' 26 | }, 27 | operateWidth : { 28 | type : Number, 29 | value : 160 30 | } 31 | }, 32 | options: { 33 | // 在组件定义时的选项中启用多slot支持 34 | multipleSlots: true 35 | }, 36 | data : { 37 | //touch start position 38 | tStart : { 39 | pageX : 0, 40 | pageY : 0 41 | }, 42 | //限制滑动距离 43 | limitMove : 0, 44 | //element move position 45 | position : { 46 | pageX : 0, 47 | pageY : 0 48 | } 49 | }, 50 | methods : { 51 | //阻止事件冒泡 52 | loop(){}, 53 | _updateButtonSize(){ 54 | const actions = this.data.actions; 55 | if( actions.length > 0 ){ 56 | const query = wx.createSelectorQuery().in(this); 57 | let limitMovePosition = 0; 58 | actions.forEach(item => { 59 | limitMovePosition += item.width || 0; 60 | }); 61 | this.data.limitMove = limitMovePosition; 62 | /* 63 | * 动态获取每个传进值的按钮尺寸不能正确获取,在安卓上少了6px 64 | * 暂时实现需要在actions里面传递宽度 65 | * 需要后期调研 66 | */ 67 | //query.selectAll('.i-swipeout-button-right-item').boundingClientRect((rects)=>{ 68 | // if( rects ){ 69 | // console.log(rects,1111111) 70 | // rects.forEach(item => { 71 | // limitMovePosition += item.width; 72 | // }); 73 | // this.data.limitMove = limitMovePosition; 74 | // console.log(limitMovePosition,111111111) 75 | // } 76 | // }).exec() 77 | }else{ 78 | this.data.limitMove = this.data.operateWidth; 79 | 80 | } 81 | }, 82 | handlerTouchstart(event){ 83 | const touches = event.touches ? event.touches[0] : {}; 84 | const tStart = this.data.tStart; 85 | if( touches ){ 86 | for( let i in tStart ){ 87 | if( touches[i] ){ 88 | tStart[i] = touches[i]; 89 | } 90 | } 91 | } 92 | }, 93 | swipper(touches){ 94 | const data = this.data; 95 | const start = data.tStart; 96 | const spacing = { 97 | pageX : touches.pageX - start.pageX, 98 | pageY : touches.pageY - start.pageY 99 | } 100 | if( data.limitMove < Math.abs( spacing.pageX ) ){ 101 | spacing.pageX = -data.limitMove; 102 | 103 | } 104 | this.setData({ 105 | 'position' : spacing 106 | }) 107 | }, 108 | handlerTouchmove(event){ 109 | const start = this.data.tStart; 110 | const touches = event.touches ? event.touches[0] : {}; 111 | if( touches ){ 112 | const direction = swipeDirection( start.pageX,touches.pageX,start.pageY,touches.pageY ); 113 | if( direction === 'Left' ){ 114 | this.swipper( touches ); 115 | } 116 | } 117 | }, 118 | handlerTouchend(event){ 119 | const start = this.data.tStart; 120 | const touches = event.changedTouches ? event.changedTouches[0] : {}; 121 | if( touches ){ 122 | const direction = swipeDirection( start.pageX,touches.pageX,start.pageY,touches.pageY ); 123 | const spacing = { 124 | pageX : touches.pageX - start.pageX, 125 | pageY : touches.pageY - start.pageY 126 | } 127 | if( Math.abs( spacing.pageX ) >= 40 && direction === "Left" ){ 128 | spacing.pageX = spacing.pageX < 0 ? - this.data.limitMove : this.data.limitMove; 129 | }else{ 130 | spacing.pageX = 0; 131 | } 132 | this.setData({ 133 | 'position' : spacing 134 | }) 135 | } 136 | }, 137 | handlerButton(event){ 138 | if( !this.data.unclosable ){ 139 | this.closeButtonGroup(); 140 | } 141 | const dataset = event.currentTarget.dataset; 142 | this.triggerEvent('change',{ 143 | index : dataset.index 144 | }) 145 | }, 146 | closeButtonGroup(){ 147 | this.setData({ 148 | 'position' : {pageX : 0,pageY : 0} 149 | }) 150 | }, 151 | //控制自定义组件 152 | handlerParentButton(event){ 153 | if( !this.data.unclosable ){ 154 | this.closeButtonGroup(); 155 | } 156 | } 157 | }, 158 | ready(){ 159 | this._updateButtonSize(); 160 | } 161 | }); 162 | -------------------------------------------------------------------------------- /static/iview/swipeout/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": { 4 | "i-cell": "../cell/index", 5 | "i-icon": "../icon/index" 6 | } 7 | } -------------------------------------------------------------------------------- /static/iview/swipeout/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 15 | 20 | 21 | {{item.name}} 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | module.exports = { 31 | setStyle : function( item ){ 32 | var defaults = '#f7f7f7'; 33 | return 'background:' + ( item.background ? item.background : defaults ) +';' + 'color:'+ item.color; 34 | }, 35 | setPosition : function( position ){ 36 | return 'transform:translate(' + position.pageX + 'px,0);'; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /static/iview/swipeout/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/switch/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | properties : { 4 | value : { 5 | type : Boolean, 6 | value : false 7 | }, 8 | //large small default 9 | size : { 10 | type : String, 11 | value : 'default' 12 | }, 13 | // is or not disable 14 | disabled : { 15 | type : Boolean, 16 | value : false 17 | }, 18 | // hidden inut name 19 | name : { 20 | type : String, 21 | value : '' 22 | } 23 | }, 24 | options: { 25 | // 在组件定义时的选项中启用多slot支持 26 | multipleSlots: true 27 | }, 28 | methods : { 29 | toggle(){ 30 | if( this.data.disabled ) return; 31 | const data = this.data; 32 | const value = data.value ? false : true; 33 | this.triggerEvent('change',{ 34 | value : value 35 | }) 36 | } 37 | } 38 | }); 39 | -------------------------------------------------------------------------------- /static/iview/switch/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/switch/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | var sizes = ['large', 'default']; 12 | var prefixCls = 'i-switch'; 13 | module.exports = { 14 | setSize : function( size ){ 15 | var index = sizes.indexOf( size ); 16 | return prefixCls + ( index > -1 ? ( '-'+size ) : 'default' ) 17 | }, 18 | setCurrent : function( value,disabled ){ 19 | var className = value && !disabled ? prefixCls + '-checked' : ''; 20 | if( disabled ){ 21 | className += ' ' + prefixCls + '-disabled'; 22 | } 23 | return className; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /static/iview/switch/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/tab-bar-item/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | 4 | relations: { 5 | '../tab-bar/index': { 6 | type: 'parent' 7 | } 8 | }, 9 | 10 | properties: { 11 | icon: { 12 | type: String, 13 | value: '' 14 | }, 15 | currentIcon: { 16 | type: String, 17 | value: '' 18 | }, 19 | img: { 20 | type: String, 21 | value: '' 22 | }, 23 | currentImg: { 24 | type: String, 25 | value: '' 26 | }, 27 | key: { 28 | type: String, 29 | value: '' 30 | }, 31 | title: { 32 | type: String, 33 | value: '' 34 | }, 35 | dot: { 36 | type: Boolean, 37 | value: false 38 | }, 39 | count: { 40 | type: Number, 41 | value: 0 42 | } 43 | }, 44 | 45 | data: { 46 | current: false, 47 | currentColor: '' 48 | }, 49 | 50 | methods: { 51 | changeCurrent (current) { 52 | this.setData({ current }); 53 | }, 54 | changeCurrentColor (currentColor) { 55 | this.setData({ currentColor }); 56 | }, 57 | handleClickItem () { 58 | const parent = this.getRelationNodes('../tab-bar/index')[0]; 59 | parent.emitEvent(this.data.key); 60 | } 61 | } 62 | }); 63 | -------------------------------------------------------------------------------- /static/iview/tab-bar-item/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": 4 | { 5 | "i-badge": "../badge/index", 6 | "i-icon": "../icon/index" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /static/iview/tab-bar-item/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{ title }} 7 | {{ title }} 8 | 9 | 10 | -------------------------------------------------------------------------------- /static/iview/tab-bar-item/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/tab-bar/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | 4 | relations: { 5 | '../tab-bar-item/index': { 6 | type: 'child', 7 | linked () { 8 | this.changeCurrent(); 9 | }, 10 | linkChanged () { 11 | this.changeCurrent(); 12 | }, 13 | unlinked () { 14 | this.changeCurrent(); 15 | } 16 | } 17 | }, 18 | 19 | properties: { 20 | current: { 21 | type: String, 22 | value: '', 23 | observer: 'changeCurrent' 24 | }, 25 | color: { 26 | type: String, 27 | value: '' 28 | }, 29 | fixed: { 30 | type: Boolean, 31 | value: false 32 | } 33 | }, 34 | 35 | data: { 36 | list: [] 37 | }, 38 | 39 | methods: { 40 | changeCurrent (val = this.data.current) { 41 | let items = this.getRelationNodes('../tab-bar-item/index'); 42 | const len = items.length; 43 | 44 | if (len > 0) { 45 | const list = []; 46 | items.forEach(item => { 47 | item.changeCurrent(item.data.key === val); 48 | item.changeCurrentColor(this.data.color); 49 | list.push({ 50 | key: item.data.key 51 | }); 52 | }); 53 | this.setData({ 54 | list: list 55 | }); 56 | } 57 | }, 58 | emitEvent (key) { 59 | this.triggerEvent('change', { key }); 60 | }, 61 | handleClickItem (e) { 62 | const key = e.currentTarget.dataset.key; 63 | this.emitEvent(key); 64 | } 65 | } 66 | }); 67 | -------------------------------------------------------------------------------- /static/iview/tab-bar/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/tab-bar/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /static/iview/tab-bar/index.wxss: -------------------------------------------------------------------------------- 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%} -------------------------------------------------------------------------------- /static/iview/tab/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | 4 | relations: { 5 | '../tabs/index': { 6 | type: 'parent' 7 | } 8 | }, 9 | 10 | properties: { 11 | key: { 12 | type: String, 13 | value: '' 14 | }, 15 | title: { 16 | type: String, 17 | value: '' 18 | }, 19 | dot: { 20 | type: Boolean, 21 | value: false 22 | }, 23 | count: { 24 | type: Number, 25 | value: 0 26 | } 27 | }, 28 | 29 | data: { 30 | current: false, 31 | currentColor: '', 32 | scroll: false 33 | }, 34 | 35 | methods: { 36 | changeCurrent (current) { 37 | this.setData({ current }); 38 | }, 39 | changeCurrentColor (currentColor) { 40 | this.setData({ currentColor }); 41 | }, 42 | changeScroll (scroll) { 43 | this.setData({ scroll }); 44 | }, 45 | handleClickItem () { 46 | const parent = this.getRelationNodes('../tabs/index')[0]; 47 | parent.emitEvent(this.data.key); 48 | } 49 | } 50 | }); 51 | -------------------------------------------------------------------------------- /static/iview/tab/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": 4 | { 5 | "i-badge": "../badge/index" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /static/iview/tab/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{ title }} 5 | {{ title }} 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /static/iview/tab/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/tabs/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | 4 | relations: { 5 | '../tab/index': { 6 | type: 'child', 7 | linked () { 8 | this.changeCurrent(); 9 | }, 10 | linkChanged () { 11 | this.changeCurrent(); 12 | }, 13 | unlinked () { 14 | this.changeCurrent(); 15 | } 16 | } 17 | }, 18 | 19 | properties: { 20 | current: { 21 | type: String, 22 | value: '', 23 | observer: 'changeCurrent' 24 | }, 25 | color: { 26 | type: String, 27 | value: '' 28 | }, 29 | scroll: { 30 | type: Boolean, 31 | value: false 32 | }, 33 | fixed: { 34 | type: Boolean, 35 | value: false 36 | } 37 | }, 38 | 39 | methods: { 40 | changeCurrent (val = this.data.current) { 41 | let items = this.getRelationNodes('../tab/index'); 42 | const len = items.length; 43 | 44 | if (len > 0) { 45 | items.forEach(item => { 46 | item.changeScroll(this.data.scroll); 47 | item.changeCurrent(item.data.key === val); 48 | item.changeCurrentColor(this.data.color); 49 | }); 50 | } 51 | }, 52 | emitEvent (key) { 53 | this.triggerEvent('change', { key }); 54 | } 55 | } 56 | }); 57 | -------------------------------------------------------------------------------- /static/iview/tabs/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /static/iview/tabs/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /static/iview/tabs/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/tag/index.js: -------------------------------------------------------------------------------- 1 | Component({ 2 | externalClasses: ['i-class'], 3 | properties : { 4 | //slot name 5 | name : { 6 | type : String, 7 | value : '' 8 | }, 9 | //can click or not click 10 | checkable : { 11 | type : Boolean, 12 | value : false 13 | }, 14 | //is current choose 15 | checked : { 16 | type : Boolean, 17 | value : true 18 | }, 19 | //background and color setting 20 | color : { 21 | type : String, 22 | value : 'default' 23 | }, 24 | //control fill or not 25 | type : { 26 | type : String, 27 | value : 'dot' 28 | } 29 | }, 30 | methods : { 31 | tapTag(){ 32 | const data = this.data; 33 | if( data.checkable ){ 34 | const checked = data.checked ? false : true; 35 | this.triggerEvent('change',{ 36 | name : data.name || '', 37 | checked : checked 38 | }); 39 | } 40 | } 41 | } 42 | }) -------------------------------------------------------------------------------- /static/iview/tag/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component" : true 3 | } -------------------------------------------------------------------------------- /static/iview/tag/index.wxml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | module.exports = { 8 | getClass : function(color,type,checked,checkable) { 9 | var initColorList = ['blue', 'green', 'red', 'yellow', 'default']; 10 | var theme = ''; 11 | var className = 'i-tag-'; 12 | if( initColorList.indexOf( color ) > -1 ){ 13 | theme = className + color; 14 | } 15 | if( type === 'border' ){ 16 | theme = className+color+'-border'; 17 | } 18 | if( checkable && checked ){ 19 | theme = className+color+'-checked'; 20 | }else if( checkable && !checked ){ 21 | theme = ( type === 'border' ? className + color +'-border' : className+'none' ); 22 | } 23 | 24 | return theme; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /static/iview/tag/index.wxss: -------------------------------------------------------------------------------- 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} -------------------------------------------------------------------------------- /static/iview/toast/index.js: -------------------------------------------------------------------------------- 1 | const default_data = { 2 | visible: false, 3 | content: '', 4 | icon: '', 5 | image: '', 6 | duration: 2, 7 | mask: true, 8 | type: 'default', // default || success || warning || error || loading 9 | }; 10 | 11 | let timmer = null; 12 | 13 | Component({ 14 | externalClasses: ['i-class'], 15 | 16 | data: { 17 | ...default_data 18 | }, 19 | 20 | methods: { 21 | handleShow (options) { 22 | const { type = 'default', duration = 2 } = options; 23 | 24 | this.setData({ 25 | ...options, 26 | type, 27 | duration, 28 | visible: true 29 | }); 30 | 31 | const d = this.data.duration * 1000; 32 | 33 | if (timmer) clearTimeout(timmer); 34 | if (d !== 0) { 35 | timmer = setTimeout(() => { 36 | this.handleHide(); 37 | timmer = null; 38 | }, d); 39 | } 40 | }, 41 | 42 | handleHide () { 43 | this.setData({ 44 | ...default_data 45 | }); 46 | } 47 | } 48 | }); 49 | -------------------------------------------------------------------------------- /static/iview/toast/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": 4 | { 5 | "i-icon": "../icon/index" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /static/iview/toast/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | {{ content }} 16 | -------------------------------------------------------------------------------- /static/iview/toast/index.wxss: -------------------------------------------------------------------------------- 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)}} -------------------------------------------------------------------------------- /static/sdk/ald-stat-conf.js: -------------------------------------------------------------------------------- 1 | exports.app_key = 'fa3434d39134730d1ad63ab02e27d7f1' // 请在此行填写从阿拉丁后台获取的appkey 2 | exports.getLocation = false // 默认不获取用户坐标位置 3 | exports.plugin = false // 您的小程序中是否使用了插件。根据是否启用插件会有不同的接入方式,请参考文档文档。 4 | -------------------------------------------------------------------------------- /开发笔记.md: -------------------------------------------------------------------------------- 1 | # 基于 mpvue 的表情包小程序 2 | ## 初衷 3 | 之前用过 [wepy](https://github.com/Tencent/wepy) 框架写了个小程序 [GitHub - yshkk/shanbay-mina: 基于 wepy 框架的 “扇贝阅读” 微信小程序](https://github.com/yshkk/shanbay-mina),感觉写法上类似 vue,但不那么彻底。现在美团点评发布的 [mpvue](https://github.com/Meituan-Dianping/mpvue) 支持开发者可以用 vue 的语法开发微信小程序,正好有强需求需要一个斗图小程序撑起我斗图的意志,所以就尝试了下。 4 | ## 项目地址 5 | [GitHub - yshkk/bqb-mpvue: 基于 mpvue 的表情包斗图微信小程序](https://github.com/yshkk/bqb-mpvue) 6 | ## 扫码体验 7 | ![](https://user-gold-cdn.xitu.io/2018/7/20/164b559252f057c9?w=344&h=344&f=jpeg&s=23134) 8 | ## 截图 9 | ![](https://user-gold-cdn.xitu.io/2018/7/20/164b55930c095189?w=772&h=1322&f=gif&s=3099084) 10 | 11 | ## 开发细节和坑 12 | ### 使用 `iView Weapp` 组件库 13 | > 相关代码 pages/index/main.js 第 8 行 14 | 15 | 将组件库的 dist 目录拷贝到自己项目 static 目录,然后在需要用到组件的页面配置 `usingComponents` 即可。开发期间可能对组件的样式不太满意,或者一些蜜汁问题(比如 input 下边框突然消失 [issue](https://github.com/TalkingData/iview-weapp/issues/37)),要改的话方式非常诡异 [相关 issue](https://github.com/TalkingData/iview-weapp/issues/51),所以粗暴点的方式就是直接改组件库里的 wxss 文件。 16 | ### v-show 和 v-model 不好使 17 | > 相关代码 pages/index/index.vue 第 4 行 18 | 19 | 关于 `v-show` 相关 [issue](https://github.com/Meituan-Dianping/mpvue/issues/178 ),所以只能用 `v-if` 替代。使用 `v-if` 会销毁不显示的组件,但有个场景是期望保留原来的组件,因此只能曲线救国在组件外层包一个 `< view >` 使用 ` 20 | :style="{display?condition?'block':'none'}" 21 | ` 的方式(其实最好是用 keep-alive 的方法,可惜 mpvue 不支持)。 22 | 23 | `v-model` 就很奇怪了,好像 input 不能双向绑定,原因是自定义组件就没有支持 `v-model`,所以得手动 update data。同理使用组件库 input 后不能使用 `v-focus`。(相关 [issue](https://github.com/Meituan-Dianping/mpvue/issues/766)) 24 | ### 模板语法里不能调用 methods 方法 25 | > 相关代码 components/homppage.vue 第 52 行 26 | 27 | 可以说是血坑了,一直以为我使用姿势有误,费了好长时间。后来才从 [articles / 美团小程序框架 mpvue 蹲坑指南. md at master · noahlam/articles · GitHub](https://github.com/noahlam/articles/blob/master/%E7%BE%8E%E5%9B%A2%E5%B0%8F%E7%A8%8B%E5%BA%8F%E6%A1%86%E6%9E%B6mpvue%E8%B9%B2%E5%9D%91%E6%8C%87%E5%8D%97.md) 看到原来这是 mpvue 不支持。 28 | 当时的场景是这样的: 在图片列表里,给被用户 “收藏” 过的图片加个额外的 className,该 className 可以给图片加个粉色边框,这样就能在图片列表中一眼看到哪些是被收藏过的。data 里有一个表示所有图片的数组 `imageList` 和一个表示收藏列表的数组 `favoriteList` 。起初的写法是 29 | ```html 30 | 相关代码 components/homppage.vue 第 63 行 35 | 36 | 用户收藏的表情会放到微信提供的 storage,类似浏览器的 localstorage,这样在关闭小程序以后下次来还能看到自己的收藏,因此在组件需要 watch `favoriteList` 的变更并调用 `wx.setStorage` 方法。但是不知为何直接 watch `favoriteList` 并不会触发相应函数,而 watch ‘favoriteList.length’就能触发,希望有大佬能指点下。 37 | ```javascript 38 | watch: { 39 | 'favoriteList.length': { 40 | // 将变化更新到本地存储 41 | handler: function (val, oldval) { 42 | this.updateStorage({method: val > oldval ? 'ADD' : 'DELETE'}) 43 | } 44 | } 45 | } 46 | ``` 47 | 48 | ### 表情包图片制作 49 | > 相关代码 pages/maker/index.vue 50 | 51 | 思路是初始化一个 canvas,将表情模版(一张图片,url 从跳转过来的页面的 query 里取得)绘制到 canvas 上,用户打字 / 设置颜色字体 的时候调用 `updateCanvas` 。最后调用 `wx.canvasToTempFilePath` 方法输出成图片。 52 | 关键代码如下 53 | ```javascript 54 | ctx = wx.createCanvasContext('maker') // 选择当前 canvas 55 | ... 56 | updateCanvas () { 57 | ctx.drawImage(this.path, 0, 0, 300, 300) //path 为当前表情包的路径 58 | ctx.setTextAlign('center') // 必须每次在 updateCanvas 重新设置,否则模拟器上生效但真机下不会生效 59 | ctx.setFontSize(this.fontSize) 60 | ctx.setFillStyle(this.currentColor) 61 | ctx.fillText(this.txt, this.x, this.y) 62 | ctx.draw() 63 | }, 64 | ``` 65 | 有几个小坑: 66 | * 将图片绘制到 canvas 时指定的图片不能是一个远端图床的链接,必须先本地下载下来(调用 `wx.getImageInfo` 获取图片,得到本地一个临时 path)才能绘制。 67 | * canvas 指定的大小单位是 px,而用 css 控制的单位是 rpx(mpvue 用了 `px2rpx-loader` ,就算在 css 里写成 px 也会被编译成 rpx)。 68 | * 小程序 canvas 的 `save` 和 `restore` 功能在这里很鸡肋,每次都需要完全重绘一次。特别是用户拖动文字更新文字坐标的功能,`touchmove` 事件一直触发,就一直更新 canvas,小程序里没有 `requestAnimationFrame` 的方法,所以就自己得~~ 从网上找~~ 封装一个,在拖动时起到节流的效果。 69 | * canvas 输出的图片只支持 jpg 或者 png,因此即使用 gif 图的模版也只能生成静态的表情包,残念。 70 | ## 总结 71 | 大体上使用 mpvue 的体验还是挺好的。mpvue 和 wepy 的写法上比较类似,mpvue 对 vue 开发者来说更友好容易上手,wepy 更接近于原生小程序。**但是不管用什么框架,原生小程序的文档最好还是要读的**,有一大堆的坑等着要踩,有时候不得不从编辑出的文件里面找原因。 72 | --------------------------------------------------------------------------------