diff --git a/mini-app/.editorconfig b/mini-app/.editorconfig new file mode 100644 index 000000000..9d08a1a82 --- /dev/null +++ b/mini-app/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/mini-app/.eslintignore b/mini-app/.eslintignore new file mode 100644 index 000000000..a261f2917 --- /dev/null +++ b/mini-app/.eslintignore @@ -0,0 +1 @@ +dist/* diff --git a/mini-app/.eslintrc.js b/mini-app/.eslintrc.js new file mode 100644 index 000000000..030a22e87 --- /dev/null +++ b/mini-app/.eslintrc.js @@ -0,0 +1,32 @@ +module.exports = { + root: true, + globals: { wx: true }, + parser: 'babel-eslint', + parserOptions: { + sourceType: 'module' + }, + env: { + browser: true, + node: true, + es6: true + }, + // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style + extends: 'standard', + // required to lint *.wpy files + plugins: [ + 'html' + ], + settings: { + 'html/html-extensions': ['.html', '.wpy'] + }, + // add your custom rules here + 'rules': { + // allow paren-less arrow functions + 'arrow-parens': 0, + // allow async-await + 'generator-star-spacing': 0, + // allow debugger during development + 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, + 'space-before-function-paren': 0 + } +}; diff --git a/mini-app/.prettierrc b/mini-app/.prettierrc new file mode 100644 index 000000000..544138be4 --- /dev/null +++ b/mini-app/.prettierrc @@ -0,0 +1,3 @@ +{ + "singleQuote": true +} diff --git a/mini-app/.wepyignore b/mini-app/.wepyignore new file mode 100644 index 000000000..e4f5602c8 --- /dev/null +++ b/mini-app/.wepyignore @@ -0,0 +1,4 @@ +node_modules +dist +.DS_Store +*.wpy___jb_tmp___ diff --git a/mini-app/package.json b/mini-app/package.json new file mode 100644 index 000000000..def55ee03 --- /dev/null +++ b/mini-app/package.json @@ -0,0 +1,42 @@ +{ + "name": "hope_wine", + "version": "0.0.2", + "description": "A WePY project", + "main": "weapp/app.js", + "scripts": { + "dev": "./node_modules/.bin/wepy build --watch", + "build": "cross-env NODE_ENV=production ./node_modules/.bin/wepy build --no-cache", + "clean": "rm -rf weapp", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "wepy": { + "module-a": false, + "./src/components/list": "./src/components/wepy-list.wpy" + }, + "author": "Machengtianjiang ", + "license": "MIT", + "dependencies": { + "@wepy/core": "^2.0.0-alpha.16", + "@wepy/x": "^2.0.2", + "miniprogram-slide-view": "0.0.3" + }, + "devDependencies": { + "@babel/core": "^7.1.0", + "@babel/plugin-proposal-class-properties": "^7.12.1", + "@babel/preset-env": "^7.1.0", + "@wepy/babel-plugin-import-regenerator": "0.0.2", + "@wepy/cli": "^2.0.0-alpha.28", + "@wepy/compiler-babel": "^2.0.1", + "@wepy/compiler-less": "^2.0.1", + "babel-eslint": "^7.2.1", + "cross-env": "^5.1.3", + "eslint": "^3.18.0", + "eslint-config-standard": "^7.1.0", + "eslint-friendly-formatter": "^2.0.7", + "eslint-plugin-html": "^2.0.1", + "eslint-plugin-promise": "^3.5.0", + "eslint-plugin-standard": "^2.0.1", + "less": "^3.8.1", + "wepy-eslint": "^1.5.3" + } +} diff --git a/mini-app/project.config.json b/mini-app/project.config.json new file mode 100644 index 000000000..353f5131e --- /dev/null +++ b/mini-app/project.config.json @@ -0,0 +1,112 @@ +{ + "description": "A WePY project", + "setting": { + "urlCheck": false, + "es6": false, + "enhance": true, + "postcss": false, + "preloadBackgroundData": false, + "minified": false, + "newFeature": true, + "coverView": true, + "nodeModules": true, + "autoAudits": false, + "showShadowRootInWxmlPanel": true, + "scopeDataCheck": false, + "checkInvalidKey": true, + "checkSiteMap": true, + "uploadWithSourceMap": true, + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "compileType": "miniprogram", + "appid": "wx76ec015fc31a1946", + "projectname": "hope_wine", + "miniprogramRoot": "weapp/", + "simulatorType": "wechat", + "simulatorPluginLibVersion": {}, + "condition": { + "search": { + "current": -1, + "list": [] + }, + "conversation": { + "current": -1, + "list": [] + }, + "plugin": { + "current": -1, + "list": [] + }, + "game": { + "list": [] + }, + "gamePlugin": { + "current": -1, + "list": [] + }, + "miniprogram": { + "current": -1, + "list": [ + { + "id": -1, + "name": "pages/form1", + "pathName": "pages/form1", + "query": "", + "scene": null + }, + { + "id": -1, + "name": "pages/form2", + "pathName": "pages/form2", + "query": "", + "scene": null + }, + { + "id": -1, + "name": "pages/form3", + "pathName": "pages/form3", + "query": "", + "scene": null + }, + { + "id": -1, + "name": "pages/form4", + "pathName": "pages/form4", + "query": "", + "scene": null + }, + { + "id": -1, + "name": "pages/form5", + "pathName": "pages/form5", + "query": "", + "scene": null + }, + { + "id": -1, + "name": "pages/form6", + "pathName": "pages/form6", + "query": "", + "scene": null + }, + { + "id": -1, + "name": "商城首页", + "pathName": "pages/mall/index", + "query": "", + "scene": null + }, + { + "id": -1, + "name": "商品详情", + "pathName": "pages/mall/goods-detail", + "scene": null + } + ] + } + } +} \ No newline at end of file diff --git a/mini-app/src/apis/userApis.js b/mini-app/src/apis/userApis.js new file mode 100644 index 000000000..f14e11d0b --- /dev/null +++ b/mini-app/src/apis/userApis.js @@ -0,0 +1,65 @@ + +import request from '../js/request' +import { baseUrl, formHeader, jsonHeader } from './xiao4rApis' +import { MINI_DEPTID } from '../config' + +/** + * 用户相关接口 + */ +class UserApis { + /** + * 注册 + * @param data + * @returns {Promise实例对象} + */ + registrationByMini(data) { + data.deptId = MINI_DEPTID + return request.post({ + url: baseUrl + 'mini/user/registrationByMini', + data: data + }) + } + + /** + * 登录 + * @param data + * @returns {Promise实例对象} + */ + loginByMini(data) { + data.deptId = MINI_DEPTID + return request.post({ + url: baseUrl + 'mini/user/loginByMini', + data: data + }) + } + + getSession(code) { + return request.get({ + url: baseUrl + 'mini/user/getSession', + header: formHeader, + data: { + 'code': code, + 'deptId': MINI_DEPTID + } + }) + } + + sendMobile(data) { + data.deptId = MINI_DEPTID + return request.post({ + url: baseUrl + 'mini/user/sendMobile', + header: jsonHeader, + data: data + }) + } + + getAuthTest(data) { + return request.get({ + url: baseUrl + 'mini/user/test', + header: formHeader, + data: data + }) + } +} + +export default new UserApis() diff --git a/mini-app/src/apis/xiao4rApis.js b/mini-app/src/apis/xiao4rApis.js new file mode 100644 index 000000000..8ab359fc6 --- /dev/null +++ b/mini-app/src/apis/xiao4rApis.js @@ -0,0 +1,38 @@ + +import request from '../js/request' + +export const baseUrl = 'http://127.0.0.1:18989/winery/' +// export const baseUrl = 'http://36.1.50.18:18989/winery/' +// export const baseUrl = 'http://62.234.123.172:18989/api/' +// export const baseUrl = 'https://www.xiao4r.com/wine/winery/' + +export const jsonHeader = { + 'Content-Type': 'application/json' +} + +export const formHeader = { + 'Content-Type': 'application/x-www-form-urlencoded' +} + +/** + * 接口 + */ +class Xiao4rApis { + postForm(data) { + return request.post({ + url: baseUrl + 'mini/postForm', + header: jsonHeader, + data: data + }) + } + + getForm(data) { + return request.get({ + url: baseUrl + 'mini/getForm', + header: formHeader, + data: data + }) + } +} + +export default new Xiao4rApis() diff --git a/mini-app/src/app.wpy b/mini-app/src/app.wpy new file mode 100644 index 000000000..d9f6ecdde --- /dev/null +++ b/mini-app/src/app.wpy @@ -0,0 +1,143 @@ + + + + +{ +pages: [ +'pages/index', +'pages/form1', +'pages/form2', +'pages/form3', +'pages/form4', +'pages/form5', +'pages/form6', +'pages/mall/index', +'pages/mall/goods-detail' +], +navigateToMiniProgramAppIdList: [ +'wx88736d7d39e2eda6' +], +window: { +backgroundTextStyle: 'light', +navigationBarBackgroundColor: '#fff', +navigationBarTitleText: 'WeChat', +navigationBarTextStyle: 'white', +navigationStyle: 'custom', +}, +usingComponents: { +'nav-bar': './components/nav-bar', +'van-button': './vant/button/index', +'van-divider': './vant/divider/index', +'van-field': './vant/field/index', +'van-radio': './vant/radio/index', +'van-radio-group': './vant/radio-group/index', +'van-checkbox': './vant/checkbox/index', +'van-checkbox-group': './vant/checkbox-group/index', +'van-cell': './vant/cell/index', +'van-cell-group': './vant/cell-group/index', +'van-datetime-picker': './vant/datetime-picker/index', +'van-nav-bar': './vant/nav-bar/index', +'van-icon': './vant/icon/index', +'van-steps': './vant/steps/index', +'van-row': './vant/row/index', +'van-col': './vant/col/index', +'van-col': './vant/col/index', +'van-tabbar': './vant/tabbar/index', +'van-tabbar-item': './vant/tabbar-item/index', +'van-card': './vant/card/index', +'van-popup': './vant/popup/index', +'van-stepper': './vant/stepper/index', +'van-submit-bar': './vant/submit-bar/index', +'van-panel': './vant/panel/index', +"van-grid": "./vant/grid/index", +"van-grid-item": "./vant/grid-item/index", +"van-dialog": "./vant/dialog/index", +"van-image": "./vant/image/index" +} +} + diff --git a/mini-app/src/common/eventHub.js b/mini-app/src/common/eventHub.js new file mode 100644 index 000000000..491ddaea1 --- /dev/null +++ b/mini-app/src/common/eventHub.js @@ -0,0 +1,5 @@ +import wepy from '@wepy/core'; + +let eventHub = new wepy(); + +export default eventHub; diff --git a/mini-app/src/components/counter.wpy b/mini-app/src/components/counter.wpy new file mode 100644 index 000000000..c6bc2ac33 --- /dev/null +++ b/mini-app/src/components/counter.wpy @@ -0,0 +1,77 @@ + + + + diff --git a/mini-app/src/components/group.wpy b/mini-app/src/components/group.wpy new file mode 100644 index 000000000..94dcb8b1b --- /dev/null +++ b/mini-app/src/components/group.wpy @@ -0,0 +1,41 @@ + + + + +{ + usingComponents: { + 'groupitem': './groupitem' + } +} + diff --git a/mini-app/src/components/groupitem.wpy b/mini-app/src/components/groupitem.wpy new file mode 100644 index 000000000..a7db14128 --- /dev/null +++ b/mini-app/src/components/groupitem.wpy @@ -0,0 +1,28 @@ + + + diff --git a/mini-app/src/components/list.wpy b/mini-app/src/components/list.wpy new file mode 100644 index 000000000..d9c5b7b4f --- /dev/null +++ b/mini-app/src/components/list.wpy @@ -0,0 +1,48 @@ + + + diff --git a/mini-app/src/components/mall/mall-bbs.wpy b/mini-app/src/components/mall/mall-bbs.wpy new file mode 100644 index 000000000..53f777469 --- /dev/null +++ b/mini-app/src/components/mall/mall-bbs.wpy @@ -0,0 +1,108 @@ + + + + + +{ +navigationBarTitleText: '' +} + diff --git a/mini-app/src/components/mall/mall-car.wpy b/mini-app/src/components/mall/mall-car.wpy new file mode 100644 index 000000000..40e945ed5 --- /dev/null +++ b/mini-app/src/components/mall/mall-car.wpy @@ -0,0 +1,121 @@ + + + + +{ +navigationBarTitleText: '', +usingComponents: { +}, +styleIsolation: 'shared', +addGlobalClass: true, + +} + + diff --git a/mini-app/src/components/mall/mall-home.wpy b/mini-app/src/components/mall/mall-home.wpy new file mode 100644 index 000000000..aa5d3917a --- /dev/null +++ b/mini-app/src/components/mall/mall-home.wpy @@ -0,0 +1,49 @@ + + + + + +{ +navigationBarTitleText: '' +} + diff --git a/mini-app/src/components/mall/mall-my.wpy b/mini-app/src/components/mall/mall-my.wpy new file mode 100644 index 000000000..1ef56afe3 --- /dev/null +++ b/mini-app/src/components/mall/mall-my.wpy @@ -0,0 +1,45 @@ + + + + + +{ +navigationBarTitleText: '' +} + diff --git a/mini-app/src/components/mall/mall-shopping.wpy b/mini-app/src/components/mall/mall-shopping.wpy new file mode 100644 index 000000000..691cea7db --- /dev/null +++ b/mini-app/src/components/mall/mall-shopping.wpy @@ -0,0 +1,66 @@ + + + + +{ +navigationBarTitleText: '' +} + + diff --git a/mini-app/src/components/nav-bar.wpy b/mini-app/src/components/nav-bar.wpy new file mode 100644 index 000000000..4f60238d3 --- /dev/null +++ b/mini-app/src/components/nav-bar.wpy @@ -0,0 +1,43 @@ + + + diff --git a/mini-app/src/components/panel.wpy b/mini-app/src/components/panel.wpy new file mode 100644 index 000000000..1dc914a65 --- /dev/null +++ b/mini-app/src/components/panel.wpy @@ -0,0 +1,40 @@ + + diff --git a/mini-app/src/components/user/dialog-registration.wpy b/mini-app/src/components/user/dialog-registration.wpy new file mode 100644 index 000000000..d04f1a420 --- /dev/null +++ b/mini-app/src/components/user/dialog-registration.wpy @@ -0,0 +1,190 @@ + + + + + +{ +navigationBarTitleText: '' +} + diff --git a/mini-app/src/components/user/login.wpy b/mini-app/src/components/user/login.wpy new file mode 100644 index 000000000..89d8fe890 --- /dev/null +++ b/mini-app/src/components/user/login.wpy @@ -0,0 +1,49 @@ + + + + + +{ +navigationBarTitleText: '' +} + diff --git a/mini-app/src/components/wepy-list.wpy b/mini-app/src/components/wepy-list.wpy new file mode 100644 index 000000000..8c870c171 --- /dev/null +++ b/mini-app/src/components/wepy-list.wpy @@ -0,0 +1,58 @@ + + + diff --git a/mini-app/src/config.js b/mini-app/src/config.js new file mode 100644 index 000000000..6a7f27741 --- /dev/null +++ b/mini-app/src/config.js @@ -0,0 +1,5 @@ +/** + * 常量 + */ + +export const MINI_DEPTID = 100 diff --git a/mini-app/src/js/request.js b/mini-app/src/js/request.js new file mode 100644 index 000000000..2b4c617b8 --- /dev/null +++ b/mini-app/src/js/request.js @@ -0,0 +1,71 @@ +import xiao4rBase from '../xiao4rBase' +import { uuid } from './utils/uuid' +import store from '@/store' + +class Xiao4rRequest { + // 网络请求任务对象 Map + requestTaskMap = new Map() + + /** + * requestPromise用于将wx.request改写成Promise方式 + * @param:{string} myUrl 接口地址 + * @return: Promise实例对象 + */ + requestPromise(req) { + let id = uuid() + let self = this + + if (store.state.user.token) { + if (req.header) { + req.header['Authorization'] = store.state.user.token + } else { + req.header = { + Authorization: store.state.user.token + } + } + } + + let promise = new Promise((resolve, reject) => { + const task = wx.request({ + url: req.url, + method: req.method, + header: req.header, + data: req.data, + success: rsp => resolve(rsp.data), + fail: error => { + xiao4rBase.showToast('网络连接异常.') + reject(error) + }, + complete: () => { + this.requestTaskMap.delete(id) + } + }) + self.requestTaskMap.set(id, task) + }) + // 返回一个Promise实例对象 + promise.taskId = id + return promise + } + + post(req) { + req.method = 'POST' + return this.requestPromise(req) + } + + get(req) { + req.method = 'GET' + return this.requestPromise(req) + } + + put(req) { + req.method = 'PUT' + return this.requestPromise(req) + } + + del(req) { + req.method = 'DEL' + return this.requestPromise(req) + } +} + +export default new Xiao4rRequest() diff --git a/mini-app/src/js/utils/uuid.js b/mini-app/src/js/utils/uuid.js new file mode 100644 index 000000000..92701019d --- /dev/null +++ b/mini-app/src/js/utils/uuid.js @@ -0,0 +1,14 @@ + +export function uuid() { + var s = [] + var hexDigits = '0123456789abcdef' + for (var i = 0; i < 36; i++) { + s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1) + } + s[14] = '4' // bits 12-15 of the time_hi_and_version field to 0010 + s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1) // bits 6-7 of the clock_seq_hi_and_reserved to 01 + s[8] = s[13] = s[18] = s[23] = '-' + + var uuid = s.join('') + return uuid +} diff --git a/mini-app/src/js/utils/validateUtils.js b/mini-app/src/js/utils/validateUtils.js new file mode 100644 index 000000000..1a0212cea --- /dev/null +++ b/mini-app/src/js/utils/validateUtils.js @@ -0,0 +1,23 @@ +class ValidateUtils { + isEmail(value) { + + const reg = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/ + + return reg.test(value) + + } + + /** + * 校验数字或者小数 + * @param text + * @returns {boolean} + */ + isIntOrDecimal(text) { + + let pattern = /^[0-9]+([.]{1}[0-9]+){0,1}$/; + return pattern.test(text) + } + +} + +export default new ValidateUtils() diff --git a/mini-app/src/mixins/test.js b/mini-app/src/mixins/test.js new file mode 100644 index 000000000..d3fe7cba4 --- /dev/null +++ b/mini-app/src/mixins/test.js @@ -0,0 +1,19 @@ + + +export default { + data: { + mixin: 'MixinText' + }, + methods: { + mixintap () { + this.mixin = 'MixinText' + (Math.random() + '').substring(3, 7); + console.log('mixin method tap'); + }, + tap () { + console.log('tap in mixin'); + } + }, + created () { + console.log('created in mixin'); + } +} diff --git a/mini-app/src/pages/form1.wpy b/mini-app/src/pages/form1.wpy new file mode 100644 index 000000000..0d043ce9e --- /dev/null +++ b/mini-app/src/pages/form1.wpy @@ -0,0 +1,267 @@ + + + + + +{ +navigationBarTitleText: '' +} + diff --git a/mini-app/src/pages/form2.wpy b/mini-app/src/pages/form2.wpy new file mode 100644 index 000000000..ddb032a37 --- /dev/null +++ b/mini-app/src/pages/form2.wpy @@ -0,0 +1,139 @@ + + + + + +{ +navigationBarTitleText: '' +} + diff --git a/mini-app/src/pages/form3.wpy b/mini-app/src/pages/form3.wpy new file mode 100644 index 000000000..cda16dbb1 --- /dev/null +++ b/mini-app/src/pages/form3.wpy @@ -0,0 +1,374 @@ + + + + + +{ +navigationBarTitleText: '' +} + diff --git a/mini-app/src/pages/form4.wpy b/mini-app/src/pages/form4.wpy new file mode 100644 index 000000000..8bcb40ea9 --- /dev/null +++ b/mini-app/src/pages/form4.wpy @@ -0,0 +1,158 @@ + + + + + +{ +navigationBarTitleText: '' +} + diff --git a/mini-app/src/pages/form5.wpy b/mini-app/src/pages/form5.wpy new file mode 100644 index 000000000..18fbb1381 --- /dev/null +++ b/mini-app/src/pages/form5.wpy @@ -0,0 +1,242 @@ + +