From 0cde068ccfe5dd78866058e5ac06ec2cf08adcd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E8=B1=AA?= <781521347@qq.com> Date: Wed, 29 Sep 2021 19:01:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8B=9B=E5=95=86=E4=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.json | 7 +- app.wxss | 2 +- dist/helpers/arrayTreeFilter.js | 24 + dist/helpers/baseComponent.js | 77 + dist/helpers/checkIPhoneX.js | 29 + dist/helpers/classNames.js | 39 + dist/helpers/colors.js | 27 + dist/helpers/compareVersion.js | 27 + dist/helpers/computedBehavior.js | 48 + dist/helpers/createFieldsStore.js | 75 + dist/helpers/debounce.js | 56 + dist/helpers/eventsMixin.js | 53 + dist/helpers/funcBehavior.js | 97 + dist/helpers/gestures.js | 50 + dist/helpers/isEmpty.js | 19 + dist/helpers/mergeOptionsToData.js | 17 + dist/helpers/popupMixin.js | 314 ++ dist/helpers/relationsBehavior.js | 67 + dist/helpers/safeAreaBehavior.js | 46 + dist/helpers/safeSetDataBehavior.js | 57 + dist/helpers/shallowEqual.js | 65 + dist/helpers/styleToCssString.js | 138 + dist/step/index.js | 88 + dist/step/index.json | 6 + dist/step/index.wxml | 23 + dist/step/index.wxss | 122 + dist/steps/index.js | 49 + dist/steps/index.json | 3 + dist/steps/index.wxml | 3 + dist/steps/index.wxss | 4 + images/arror-r-s.png | Bin 0 -> 163 bytes images/collect.png | Bin 0 -> 670 bytes images/phone.png | Bin 0 -> 755 bytes pages/activity/describe/index.js | 183 ++ pages/activity/describe/index.json | 4 + pages/activity/describe/index.wxml | 31 + pages/activity/describe/index.wxss | 64 + pages/activity/detail/index.js | 222 ++ pages/activity/detail/index.json | 7 + pages/activity/detail/index.wxml | 81 + pages/activity/detail/index.wxss | 188 ++ pages/activity/index.js | 97 + pages/activity/index.json | 4 + pages/activity/index.wxml | 36 + pages/activity/index.wxss | 56 + pages/activity/signIn/confirm/index.js | 113 + pages/activity/signIn/confirm/index.json | 6 + pages/activity/signIn/confirm/index.wxml | 42 + pages/activity/signIn/confirm/index.wxss | 82 + pages/activity/signIn/index.js | 110 + pages/activity/signIn/index.json | 6 + pages/activity/signIn/index.wxml | 39 + pages/activity/signIn/index.wxss | 57 + pages/activity/signIn/paymentSuccess/index.js | 70 + .../activity/signIn/paymentSuccess/index.json | 6 + .../activity/signIn/paymentSuccess/index.wxml | 7 + .../activity/signIn/paymentSuccess/index.wxss | 30 + pages/demandHall/index.wxss | 3 - pages/demandHall/resourcesContact/index.js | 10 +- pages/index/index.js | 14 +- pages/index/index.wxml | 18 +- pages/release/companyAuth/index.js | 4 +- pages/release/companyAuth/index.wxss | 2 - pages/release/perfectPersonInfo/index.js | 3 +- pages/user/resourcesOrder/index.js | 4 +- utils/subutil.wxs | 31 + utils/util.js | 23 +- wxParse/html2json.js | 303 ++ wxParse/htmlparser.js | 192 ++ wxParse/showdown.js | 2532 +++++++++++++++++ wxParse/wxDiscode.js | 207 ++ wxParse/wxParse.js | 159 ++ wxParse/wxParse.wxml | 967 +++++++ wxParse/wxParse.wxss | 207 ++ 74 files changed, 7823 insertions(+), 29 deletions(-) create mode 100644 dist/helpers/arrayTreeFilter.js create mode 100644 dist/helpers/baseComponent.js create mode 100644 dist/helpers/checkIPhoneX.js create mode 100644 dist/helpers/classNames.js create mode 100644 dist/helpers/colors.js create mode 100644 dist/helpers/compareVersion.js create mode 100644 dist/helpers/computedBehavior.js create mode 100644 dist/helpers/createFieldsStore.js create mode 100644 dist/helpers/debounce.js create mode 100644 dist/helpers/eventsMixin.js create mode 100644 dist/helpers/funcBehavior.js create mode 100644 dist/helpers/gestures.js create mode 100644 dist/helpers/isEmpty.js create mode 100644 dist/helpers/mergeOptionsToData.js create mode 100644 dist/helpers/popupMixin.js create mode 100644 dist/helpers/relationsBehavior.js create mode 100644 dist/helpers/safeAreaBehavior.js create mode 100644 dist/helpers/safeSetDataBehavior.js create mode 100644 dist/helpers/shallowEqual.js create mode 100644 dist/helpers/styleToCssString.js create mode 100644 dist/step/index.js create mode 100644 dist/step/index.json create mode 100644 dist/step/index.wxml create mode 100644 dist/step/index.wxss create mode 100644 dist/steps/index.js create mode 100644 dist/steps/index.json create mode 100644 dist/steps/index.wxml create mode 100644 dist/steps/index.wxss create mode 100644 images/arror-r-s.png create mode 100644 images/collect.png create mode 100644 images/phone.png create mode 100644 pages/activity/describe/index.js create mode 100644 pages/activity/describe/index.json create mode 100644 pages/activity/describe/index.wxml create mode 100644 pages/activity/describe/index.wxss create mode 100644 pages/activity/detail/index.js create mode 100644 pages/activity/detail/index.json create mode 100644 pages/activity/detail/index.wxml create mode 100644 pages/activity/detail/index.wxss create mode 100644 pages/activity/index.js create mode 100644 pages/activity/index.json create mode 100644 pages/activity/index.wxml create mode 100644 pages/activity/index.wxss create mode 100644 pages/activity/signIn/confirm/index.js create mode 100644 pages/activity/signIn/confirm/index.json create mode 100644 pages/activity/signIn/confirm/index.wxml create mode 100644 pages/activity/signIn/confirm/index.wxss create mode 100644 pages/activity/signIn/index.js create mode 100644 pages/activity/signIn/index.json create mode 100644 pages/activity/signIn/index.wxml create mode 100644 pages/activity/signIn/index.wxss create mode 100644 pages/activity/signIn/paymentSuccess/index.js create mode 100644 pages/activity/signIn/paymentSuccess/index.json create mode 100644 pages/activity/signIn/paymentSuccess/index.wxml create mode 100644 pages/activity/signIn/paymentSuccess/index.wxss create mode 100644 utils/subutil.wxs create mode 100644 wxParse/html2json.js create mode 100644 wxParse/htmlparser.js create mode 100644 wxParse/showdown.js create mode 100644 wxParse/wxDiscode.js create mode 100644 wxParse/wxParse.js create mode 100644 wxParse/wxParse.wxml create mode 100644 wxParse/wxParse.wxss diff --git a/app.json b/app.json index 24761a1..32351f7 100644 --- a/app.json +++ b/app.json @@ -23,7 +23,6 @@ "pages/release/companyAuth/index", "pages/release/perfectPersonInfo/index", "pages/release/perfectCompanyInfo/index", - "pages/life/index", "pages/user/mine/index", "pages/user/agreement/index", @@ -31,6 +30,12 @@ "pages/user/profession/index", "pages/user/completeData/index", "pages/user/personalData/index", + "pages/activity/index", + "pages/activity/detail/index", + "pages/activity/describe/index", + "pages/activity/signIn/index", + "pages/activity/signIn/confirm/index", + "pages/activity/signIn/paymentSuccess/index", "pages/user/industry/index" ], "window":{ diff --git a/app.wxss b/app.wxss index d999bd8..fc290e7 100644 --- a/app.wxss +++ b/app.wxss @@ -148,4 +148,4 @@ radio .wx-radio-input.wx-radio-input-checked::before { font-size: 40rpx; color: #fff; margin-top: 160rpx; -} \ No newline at end of file +} diff --git a/dist/helpers/arrayTreeFilter.js b/dist/helpers/arrayTreeFilter.js new file mode 100644 index 0000000..94736eb --- /dev/null +++ b/dist/helpers/arrayTreeFilter.js @@ -0,0 +1,24 @@ +/** + * https://github.com/afc163/array-tree-filter + */ +function arrayTreeFilter(data, filterFn, options) { + options = options || {} + options.childrenKeyName = options.childrenKeyName || 'children' + let children = data || [] + const result = [] + let level = 0 + do { + const foundItem = children.filter(function(item) { + return filterFn(item, level) + })[0] + if (!foundItem) { + break + } + result.push(foundItem) + children = foundItem[options.childrenKeyName] || [] + level += 1 + } while (children.length > 0) + return result +} + +export default arrayTreeFilter \ No newline at end of file diff --git a/dist/helpers/baseComponent.js b/dist/helpers/baseComponent.js new file mode 100644 index 0000000..7c5d66d --- /dev/null +++ b/dist/helpers/baseComponent.js @@ -0,0 +1,77 @@ +import computedBehavior from './computedBehavior' +import relationsBehavior from './relationsBehavior' +import safeAreaBehavior from './safeAreaBehavior' +import safeSetDataBehavior from './safeSetDataBehavior' +import funcBehavior from './funcBehavior' +import compareVersion from './compareVersion' + +const { platform, SDKVersion } = wx.getSystemInfoSync() +const libVersion = '2.6.6' + +// check SDKVersion +if (platform === 'devtools' && compareVersion(SDKVersion, libVersion) < 0) { + if (wx && wx.showModal) { + wx.showModal({ + title: '提示', + content: `当前基础库版本(${SDKVersion})过低,无法使用 Wux Weapp 组件库,请更新基础库版本 >=${libVersion} 后重试。`, + }) + } +} + +const baseComponent = (options = {}) => { + // add default externalClasses + options.externalClasses = [ + 'wux-class', + 'wux-hover-class', + ...(options.externalClasses = options.externalClasses || []), + ] + + // add default behaviors + options.behaviors = [ + relationsBehavior, + safeSetDataBehavior, + ...(options.behaviors = options.behaviors || []), + computedBehavior, // make sure it's triggered + ] + + // use safeArea + if (options.useSafeArea) { + options.behaviors = [...options.behaviors, safeAreaBehavior] + delete options.useSafeArea + } + + // use func + if (options.useFunc) { + options.behaviors = [...options.behaviors, funcBehavior] + delete options.useFunc + } + + // use field + if (options.useField) { + options.behaviors = [...options.behaviors, 'wx://form-field'] + delete options.useField + } + + // use export + if (options.useExport) { + options.behaviors = [...options.behaviors, 'wx://component-export'] + options.methods = { + export () { + return this + }, + ...options.methods, + } + delete options.useExport + } + + // add default options + options.options = { + multipleSlots: true, + addGlobalClass: true, + ...options.options, + } + + return Component(options) +} + +export default baseComponent diff --git a/dist/helpers/checkIPhoneX.js b/dist/helpers/checkIPhoneX.js new file mode 100644 index 0000000..5d65c52 --- /dev/null +++ b/dist/helpers/checkIPhoneX.js @@ -0,0 +1,29 @@ +/** + * 获取系统信息 + */ + +let systemInfo = null + +export const getSystemInfo = (isForce) => { + if (!systemInfo || isForce) { + try { + systemInfo = wx.getSystemInfoSync() + } catch(e) { /* Ignore */ } + } + + return systemInfo +} + +// iPhoneX 竖屏安全区域 +export const safeAreaInset = { + top: 88, // StatusBar & NavBar + left: 0, + right: 0, + bottom: 34, // Home Indicator +} + +const isIPhoneX = ({ model, platform }) => { + return /iPhone X/.test(model) && platform === 'ios' +} + +export const checkIPhoneX = (isForce) => isIPhoneX(getSystemInfo(isForce)) diff --git a/dist/helpers/classNames.js b/dist/helpers/classNames.js new file mode 100644 index 0000000..e2eb2d4 --- /dev/null +++ b/dist/helpers/classNames.js @@ -0,0 +1,39 @@ +/*! + Copyright (c) 2018 Jed Watson. + Licensed under the MIT License (MIT), see + http://jedwatson.github.io/classnames +*/ +/* global define */ +'use strict'; + +var hasOwn = {}.hasOwnProperty; + +function classNames() { + var classes = []; + + for (var i = 0; i < arguments.length; i++) { + var arg = arguments[i]; + if (!arg) continue; + + var argType = typeof arg; + + if (argType === 'string' || argType === 'number') { + classes.push(arg); + } else if (Array.isArray(arg) && arg.length) { + var inner = classNames.apply(null, arg); + if (inner) { + classes.push(inner); + } + } else if (argType === 'object') { + for (var key in arg) { + if (hasOwn.call(arg, key) && arg[key]) { + classes.push(key); + } + } + } + } + + return classes.join(' '); +} + +export default classNames \ No newline at end of file diff --git a/dist/helpers/colors.js b/dist/helpers/colors.js new file mode 100644 index 0000000..0ffd500 --- /dev/null +++ b/dist/helpers/colors.js @@ -0,0 +1,27 @@ +/** + * Don't modify this file! + * Colors generated by themes! + */ + +/* eslint-disable */ + +export const colors = { + 'light': '#ddd', + 'stable': '#b2b2b2', + 'positive': '#EBB672', + 'calm': '#11c1f3', + 'balanced': '#33cd5f', + 'energized': '#ffc900', + 'assertive': '#ef473a', + 'royal': '#886aea', + 'dark': '#444', +} + +export const isPresetColor = (color) => { + if (!color) { + return false + } + return colors[color] ? colors[color] : color +} + +/* eslint-enable */ diff --git a/dist/helpers/compareVersion.js b/dist/helpers/compareVersion.js new file mode 100644 index 0000000..47a2d59 --- /dev/null +++ b/dist/helpers/compareVersion.js @@ -0,0 +1,27 @@ +function compareVersion(v1, v2) { + const $v1 = v1.split('.') + const $v2 = v2.split('.') + const len = Math.max($v1.length, $v2.length) + + while ($v1.length < len) { + $v1.push('0') + } + while ($v2.length < len) { + $v2.push('0') + } + + for (let i = 0; i < len; i++) { + const num1 = parseInt($v1[i]) + const num2 = parseInt($v2[i]) + + if (num1 > num2) { + return 1 + } else if (num1 < num2) { + return -1 + } + } + + return 0 +} + +export default compareVersion diff --git a/dist/helpers/computedBehavior.js b/dist/helpers/computedBehavior.js new file mode 100644 index 0000000..8650193 --- /dev/null +++ b/dist/helpers/computedBehavior.js @@ -0,0 +1,48 @@ +import isEmpty from './isEmpty' +import shallowEqual from './shallowEqual' + +const ALL_DATA_KEY = '**' + +const trim = (str = '') => str.replace(/\s/g, '') + +export default Behavior({ + lifetimes: { + attached() { + this.initComputed() + }, + }, + definitionFilter(defFields) { + const { computed = {} } = defFields + const observers = Object.keys(computed).reduce((acc, name) => { + const [field, getter] = Array.isArray(computed[name]) ? computed[name] : [ALL_DATA_KEY, computed[name]] + return { + ...acc, + [field]: function(...args) { + if (typeof getter === 'function') { + const newValue = getter.apply(this, args) + const oldValue = this.data[name] + if (!isEmpty(newValue) && !shallowEqual(newValue, oldValue)) { + this.setData({ [name]: newValue }) + } + } + }, + } + }, {}) + + Object.assign(defFields.observers = (defFields.observers || {}), observers) + Object.assign(defFields.methods = (defFields.methods || {}), { + initComputed: function(data = {}, isForce = false) { + if (!this.runInitComputed || isForce) { + this.runInitComputed = false + const context = this + const result = { ...this.data, ...data } + Object.keys(observers).forEach((key) => { + const values = trim(key).split(',').reduce((acc, name) => ([...acc, result[name]]), []) + observers[key].apply(context, values) + }) + this.runInitComputed = true + } + }, + }) + }, +}) diff --git a/dist/helpers/createFieldsStore.js b/dist/helpers/createFieldsStore.js new file mode 100644 index 0000000..9dbb3ee --- /dev/null +++ b/dist/helpers/createFieldsStore.js @@ -0,0 +1,75 @@ +class FieldsStore { + constructor(fields = {}) { + this.fields = fields + } + + setFields(fields) { + Object.assign(this.fields, fields) + } + + updateFields(fields) { + this.fields = fields + } + + clearField(name) { + delete this.fields[name] + } + + getValueFromFields(name, fields) { + const field = fields[name] + if (field && 'value' in field) { + return field.value + } + return field.initialValue + } + + getAllFieldsName() { + const { fields } = this + return fields ? Object.keys(fields) : [] + } + + getField(name) { + return { + ...this.fields[name], + name, + } + } + + getFieldValuePropValue(fieldOption) { + const { name, valuePropName } = fieldOption + const field = this.getField(name) + const fieldValue = 'value' in field ? field.value : field.initialValue + + return { + [valuePropName]: fieldValue, + } + } + + getFieldValue(name) { + return this.getValueFromFields(name, this.fields) + } + + getFieldsValue(names) { + const fields = names || this.getAllFieldsName() + return fields.reduce((acc, name) => { + acc[name] = this.getFieldValue(name) + return acc + }, {}) + } + + resetFields(ns) { + const { fields } = this + const names = ns || this.getAllFieldsName() + return names.reduce((acc, name) => { + const field = fields[name] + if (field) { + acc[name] = field.initialValue + } + return acc + }, {}) + } +} + +export default function createFieldsStore(fields) { + return new FieldsStore(fields) +} diff --git a/dist/helpers/debounce.js b/dist/helpers/debounce.js new file mode 100644 index 0000000..207e486 --- /dev/null +++ b/dist/helpers/debounce.js @@ -0,0 +1,56 @@ +export default function debounce(func, wait, immediate) { + let timeout, + args, + context, + timestamp, + result + + function later() { + const last = +(new Date()) - timestamp + if (last < wait && last >= 0) { + timeout = setTimeout(later, wait - last) + } else { + timeout = undefined + if (!immediate) { + result = func.apply(context, args) + if (!timeout) { + context = undefined + args = undefined + } + } + } + } + + function debounced() { + context = this + args = arguments + timestamp = +(new Date()) + + const callNow = immediate && !timeout + if (!timeout) { + timeout = setTimeout(later, wait) + } + + if (callNow) { + result = func.apply(context, args) + context = undefined + args = undefined + } + + return result + } + + function cancel() { + if (timeout !== undefined) { + clearTimeout(timeout) + timeout = undefined + } + + context = undefined + args = undefined + } + + debounced.cancel = cancel + + return debounced +} \ No newline at end of file diff --git a/dist/helpers/eventsMixin.js b/dist/helpers/eventsMixin.js new file mode 100644 index 0000000..f690335 --- /dev/null +++ b/dist/helpers/eventsMixin.js @@ -0,0 +1,53 @@ +const defaultEvents = { + onChange() {}, +} + +export default function eventsMixin(params = { defaultEvents }) { + return Behavior({ + lifetimes: { + created () { + this._oriTriggerEvent = this.triggerEvent + this.triggerEvent = this._triggerEvent + }, + }, + properties: { + events: { + type: Object, + value: defaultEvents, + }, + }, + data: { + inputEvents: defaultEvents, + }, + definitionFilter(defFields) { + // set default data + Object.assign(defFields.data = (defFields.data || {}), { + inputEvents: Object.assign({}, defaultEvents, defFields.inputEvents), + }) + + // set default methods + Object.assign(defFields.methods = (defFields.methods || {}), { + _triggerEvent(name, params, runCallbacks = true, option) { + const { inputEvents } = this.data + const method = `on${name[0].toUpperCase()}${name.slice(1)}` + const func = inputEvents[method] + + if (runCallbacks && typeof func === 'function') { + func.call(this, params) + } + + this._oriTriggerEvent(name, params, option) + }, + }) + + // set default observers + Object.assign(defFields.observers = (defFields.observers || {}), { + events(newVal) { + this.setData({ + inputEvents: Object.assign({}, defaultEvents, this.data.inputEvents, newVal), + }) + }, + }) + }, + }) +} diff --git a/dist/helpers/funcBehavior.js b/dist/helpers/funcBehavior.js new file mode 100644 index 0000000..948075c --- /dev/null +++ b/dist/helpers/funcBehavior.js @@ -0,0 +1,97 @@ +/** + * 过滤对象的函数属性 + * @param {Object} opts + */ +const mergeOptionsToData = (opts = {}) => { + const options = Object.assign({}, opts) + + for (const key in options) { + if (options.hasOwnProperty(key) && typeof options[key] === 'function') { + delete options[key] + } + } + + return options +} + +/** + * Simple bind, faster than native + * + * @param {Function} fn + * @param {Object} ctx + * @return {Function} + */ +const bind = (fn, ctx) => { + return (...args) => { + return args.length ? fn.apply(ctx, args) : fn.call(ctx) + } +} + +/** + * Object assign + */ +const assign = (...args) => Object.assign({}, ...args) + +export default Behavior({ + definitionFilter(defFields) { + defFields.data = mergeOptionsToData(defFields.data) + defFields.data.in = false + defFields.data.visible = false + }, + methods: { + /** + * 过滤对象的函数属性 + * @param {Object} opts + */ + $$mergeOptionsToData: mergeOptionsToData, + /** + * 合并参数并绑定方法 + * + * @param {Object} opts 参数对象 + * @param {Object} fns 方法挂载的属性 + */ + $$mergeOptionsAndBindMethods (opts = {}, fns = this.fns) { + const options = Object.assign({}, opts) + + for (const key in options) { + if (options.hasOwnProperty(key) && typeof options[key] === 'function') { + fns[key] = bind(options[key], this) + delete options[key] + } + } + + return options + }, + /** + * Promise setData + * @param {Array} args 参数对象 + */ + $$setData (...args) { + const params = assign({}, ...args) + + return new Promise((resolve) => { + this.setData(params, resolve) + }) + }, + /** + * 延迟指定时间执行回调函数 + * @param {Function} callback 回调函数 + * @param {Number} timeout 延迟时间 + */ + $$requestAnimationFrame (callback = () => {}, timeout = 1000 / 60) { + return new Promise((resolve) => setTimeout(resolve, timeout)).then(callback) + }, + }, + /** + * 组件生命周期函数,在组件实例进入页面节点树时执行 + */ + created () { + this.fns = {} + }, + /** + * 组件生命周期函数,在组件实例被从页面节点树移除时执行 + */ + detached () { + this.fns = {} + }, +}) diff --git a/dist/helpers/gestures.js b/dist/helpers/gestures.js new file mode 100644 index 0000000..99a4a40 --- /dev/null +++ b/dist/helpers/gestures.js @@ -0,0 +1,50 @@ +/** + * 获取触摸点位置信息 + */ +export const getTouchPoints = (nativeEvent, index = 0) => { + const touches = nativeEvent.touches + const changedTouches = nativeEvent.changedTouches + const hasTouches = touches && touches.length > 0 + const hasChangedTouches = changedTouches && changedTouches.length > 0 + const points = !hasTouches && hasChangedTouches ? changedTouches[index] : hasTouches ? touches[index] : nativeEvent + + return { + x: points.pageX, + y: points.pageY, + } +} + +/** + * 获取触摸点个数 + */ +export const getPointsNumber = (e) => e.touches && e.touches.length || e.changedTouches && e.changedTouches.length + +/** + * 判断是否为同一点 + */ +export const isEqualPoints = (p1, p2) => p1.x === p2.x && p1.y === p2.y + +/** + * 判断是否为相近的两点 + */ +export const isNearbyPoints = (p1, p2, DOUBLE_TAP_RADIUS = 25) => { + const xMove = Math.abs(p1.x - p2.x) + const yMove = Math.abs(p1.y - p2.y) + return xMove < DOUBLE_TAP_RADIUS & yMove < DOUBLE_TAP_RADIUS +} + +/** + * 获取两点之间的距离 + */ +export const getPointsDistance = (p1, p2) => { + const xMove = Math.abs(p1.x - p2.x) + const yMove = Math.abs(p1.y - p2.y) + return Math.sqrt(xMove * xMove + yMove * yMove) +} + +/** + * 获取触摸移动方向 + */ +export const getSwipeDirection = (x1, x2, y1, y2) => { + return Math.abs(x1 - x2) >= Math.abs(y1 - y2) ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down') +} diff --git a/dist/helpers/isEmpty.js b/dist/helpers/isEmpty.js new file mode 100644 index 0000000..56fc4f8 --- /dev/null +++ b/dist/helpers/isEmpty.js @@ -0,0 +1,19 @@ +/** + * Checks if a value is empty. + */ +function isEmpty(value) { + if (Array.isArray(value)) { + return value.length === 0 + } else if (typeof value === 'object') { + if (value) { + for (const _ in value) { + return false + } + } + return true + } else { + return !value + } +} + +export default isEmpty \ No newline at end of file diff --git a/dist/helpers/mergeOptionsToData.js b/dist/helpers/mergeOptionsToData.js new file mode 100644 index 0000000..47f5acc --- /dev/null +++ b/dist/helpers/mergeOptionsToData.js @@ -0,0 +1,17 @@ +/** + * 过滤对象的函数属性 + * @param {Object} opts + */ +const mergeOptionsToData = (opts = {}) => { + const options = Object.assign({}, opts) + + for (const key in options) { + if (options.hasOwnProperty(key) && typeof options[key] === 'function') { + delete options[key] + } + } + + return options +} + +export default mergeOptionsToData diff --git a/dist/helpers/popupMixin.js b/dist/helpers/popupMixin.js new file mode 100644 index 0000000..fd1d17f --- /dev/null +++ b/dist/helpers/popupMixin.js @@ -0,0 +1,314 @@ +import classNames from './classNames' +import eventsMixin from './eventsMixin' + +const DEFAULT_TRIGGER = 'onClick' +const CELL_NAME = '../cell/index' +const FIELD_NAME = '../field/index' + +const defaultToolbar = { + title: '请选择', + cancelText: '取消', + confirmText: '确定', +} + +const defaultEvents = { + onChange() {}, + onConfirm() {}, + onCancel() {}, + onVisibleChange() {}, + onValueChange() {}, +} + +const defaultPlatformProps = { + labelPropName: 'label', + format(values, props) { + return Array.isArray(values.displayValue) ? values.displayValue.join(',') : values.displayValue + }, +} + +const defaultFieldNames = { + label: 'label', + value: 'value', + children: 'children', +} + +export default function popupMixin(selector = '#wux-picker', platformProps = defaultPlatformProps) { + return Behavior({ + behaviors: [eventsMixin({ defaultEvents })], + properties: { + toolbar: { + type: Object, + value: defaultToolbar, + }, + trigger: { + type: String, + value: DEFAULT_TRIGGER, + }, + defaultVisible: { + type: Boolean, + value: false, + }, + visible: { + type: Boolean, + value: false, + }, + controlled: { + type: Boolean, + value: false, + }, + disabled: { + type: Boolean, + value: false, + }, + }, + data: { + mounted: false, + popupVisible: false, + inputValue: [], + }, + methods: { + /** + * 设置组件显示或隐藏 + */ + setVisibleState(popupVisible, callback = () => {}) { + if (this.data.popupVisible !== popupVisible) { + const params = { + mounted: true, + inputValue: this.data.value, // forceUpdate + popupVisible, + } + this.setData(popupVisible ? params : { popupVisible }, () => { + // collect field component & forceUpdate + if (popupVisible && this.hasFieldDecorator) { + const field = this.getFieldElem() + if (field) { + field.changeValue(field.data.value) + } + } + callback() + }) + } + }, + /** + * 触发 visibleChange 事件 + */ + fireVisibleChange(popupVisible) { + if (this.data.popupVisible !== popupVisible) { + if (!this.data.controlled) { + this.setVisibleState(popupVisible) + } + this.setScrollValue(undefined) + this.triggerEvent('visibleChange', { visible: popupVisible }) + } + }, + /** + * 打开 + */ + open() { + this.fireVisibleChange(true) + }, + /** + * 关闭 + */ + close(callback) { + if (typeof callback === 'function') { + const values = this.getPickerValue(this.scrollValue || this.data.inputValue) + callback.call(this, this.formatPickerValue(values)) + } + this.fireVisibleChange(false) + }, + /** + * 组件关闭时重置其内部数据 + */ + onClosed() { + this.picker = null + this.setData({ mounted: false, inputValue: null }) + }, + /** + * 点击确定按钮时的回调函数 + */ + onConfirm() { + this.close((values) => { + this.triggerEvent('change', values) // collect field component + this.triggerEvent('confirm', values) + }) + }, + /** + * 点击取消按钮时的回调函数 + */ + onCancel() { + this.close((values) => this.triggerEvent('cancel', values)) + }, + /** + * 每列数据选择变化后的回调函数 + */ + onValueChange(e) { + if (!this.data.mounted) return + const { value } = e.detail + if (this.data.cascade) { + this.setCasecadeScrollValue(value) + } else { + this.setScrollValue(value) + } + + this.updated(value, true) + this.triggerEvent('valueChange', this.formatPickerValue(e.detail)) + }, + /** + * 获取当前 picker 的值 + */ + getPickerValue(value = this.data.inputValue) { + this.picker = this.picker || this.selectComponent(selector) + return this.picker && this.picker.getValue(value) + }, + /** + * 格式化 picker 返回值 + */ + formatPickerValue(values) { + return { + ...values, + [platformProps.labelPropName]: platformProps.format(values, this.data), + } + }, + /** + * 获取 field 父元素 + */ + getFieldElem() { + return this.field = (this.field || this.getRelationNodes(FIELD_NAME)[0]) + }, + /** + * 设置子元素 props + */ + setChildProps() { + if (this.data.disabled) return + const elements = this.getRelationNodes(CELL_NAME) + const { trigger = DEFAULT_TRIGGER } = this.data + if (elements.length > 0) { + elements.forEach((inputElem) => { + const { inputEvents } = inputElem.data + const oriInputEvents = inputElem.data.oriInputEvents || { ...inputEvents } + inputEvents[trigger] = (...args) => { + if (oriInputEvents && oriInputEvents[trigger]) { + oriInputEvents[trigger](...args) + } + this.onTriggerClick() + } + inputElem.setData({ oriInputEvents, inputEvents }) + }) + } + }, + /** + * 触发事件 + */ + onTriggerClick() { + this.fireVisibleChange(!this.data.popupVisible) + }, + /** + * 阻止移动触摸 + */ + noop() {}, + /** + * 更新值 + */ + updated(inputValue, isForce) { + if (!this.hasFieldDecorator || isForce) { + if (this.data.inputValue !== inputValue) { + this.setData({ inputValue }) + } + } + }, + /** + * 记录每列数据的变化值 + */ + setScrollValue(value) { + this.scrollValue = value + }, + /** + * 记录每列数据的变化值 - 针对于级联 + */ + setCasecadeScrollValue(value) { + if (value && this.scrollValue) { + const length = this.scrollValue.length + if (length === value.length && this.scrollValue[length - 1] === value[length - 1]) { + return + } + } + this.setScrollValue(value) + }, + }, + lifetimes: { + ready() { + const { defaultVisible, visible, controlled, value } = this.data + const popupVisible = controlled ? visible : defaultVisible + + // 若 defaultFieldNames 存在,则缓存之,并传递给子组件,只生效一次 + if ('defaultFieldNames' in this.data) { + this.setData({ + fieldNames: Object.assign({}, defaultFieldNames, this.data.defaultFieldNames), + }) + } + + this.mounted = true + this.scrollValue = undefined + this.setVisibleState(popupVisible) + this.setChildProps() + }, + detached() { + this.mounted = false + }, + }, + definitionFilter(defFields) { + // set default child + Object.assign(defFields.relations = (defFields.relations || {}), { + [CELL_NAME]: { + type: 'child', + observer() { + this.setChildProps() + }, + }, + [FIELD_NAME]: { + type: 'ancestor', + }, + }) + + // set default classes + Object.assign(defFields.computed = (defFields.computed || {}), { + classes: ['prefixCls', function(prefixCls) { + const wrap = classNames(prefixCls) + const toolbar = `${prefixCls}__toolbar` + const inner = `${prefixCls}__inner` + const cancel = classNames(`${prefixCls}__button`, { + [`${prefixCls}__button--cancel`]: true, + }) + const confirm = classNames(`${prefixCls}__button`, { + [`${prefixCls}__button--confirm`]: true, + }) + const hover = `${prefixCls}__button--hover` + const title = `${prefixCls}__title` + + return { + wrap, + toolbar, + inner, + cancel, + confirm, + hover, + title, + } + }], + }) + + // set default observers + Object.assign(defFields.observers = (defFields.observers || {}), { + visible(popupVisible) { + if (this.data.controlled) { + this.setVisibleState(popupVisible) + } + }, + value(value) { + this.updated(value) + }, + }) + }, + }) +} diff --git a/dist/helpers/relationsBehavior.js b/dist/helpers/relationsBehavior.js new file mode 100644 index 0000000..2f05c35 --- /dev/null +++ b/dist/helpers/relationsBehavior.js @@ -0,0 +1,67 @@ +import isEmpty from './isEmpty' +import debounce from './debounce' + +/** + * bind func to obj + */ +function bindFunc(obj, method, observer) { + const oldFn = obj[method] + obj[method] = function(target) { + if (observer) { + observer.call(this, target, { + [method]: true, + }) + } + if (oldFn) { + oldFn.call(this, target) + } + } +} + +// default methods +const methods = ['linked', 'linkChanged', 'unlinked'] + +// extra props +const extProps = ['observer'] + +export default Behavior({ + lifetimes: { + created() { + this._debounce = null + }, + detached() { + if (this._debounce && this._debounce.cancel) { + this._debounce.cancel() + } + }, + }, + definitionFilter(defFields) { + const { relations } = defFields + + if (!isEmpty(relations)) { + for (const key in relations) { + const relation = relations[key] + + // bind func + methods.forEach((method) => bindFunc(relation, method, relation.observer)) + + // delete extProps + extProps.forEach((prop) => delete relation[prop]) + } + } + + Object.assign(defFields.methods = (defFields.methods || {}), { + getRelationsName: function(types = ['parent', 'child', 'ancestor', 'descendant']) { + return Object.keys(relations || {}).map((key) => { + if (relations[key] && types.includes(relations[key].type)) { + return key + } + return null + }).filter((v) => !!v) + }, + debounce: function(func, wait = 0, immediate = false) { + return (this._debounce = this._debounce || debounce(func.bind(this), wait, immediate)).call(this) + }, + }) + }, +}) diff --git a/dist/helpers/safeAreaBehavior.js b/dist/helpers/safeAreaBehavior.js new file mode 100644 index 0000000..c81fad0 --- /dev/null +++ b/dist/helpers/safeAreaBehavior.js @@ -0,0 +1,46 @@ +import { getSystemInfo, checkIPhoneX } from './checkIPhoneX' + +const defaultSafeArea = { + top: false, + bottom: false, +} + +const setSafeArea = (params) => { + if (typeof params === 'boolean') { + return Object.assign({}, defaultSafeArea, { + top: params, + bottom: params, + }) + } else if (params !== null && typeof params === 'object') { + return Object.assign({}, defaultSafeArea) + } else if (typeof params === 'string') { + return Object.assign({}, defaultSafeArea, { + [params]: true, + }) + } + return defaultSafeArea +} + +export default Behavior({ + properties: { + safeArea: { + type: [Boolean, String, Object], + value: false, + }, + }, + observers: { + safeArea(newVal) { + this.setData({ safeAreaConfig: setSafeArea(newVal) }) + }, + }, + definitionFilter(defFields) { + const { statusBarHeight } = getSystemInfo() || {} + const isIPhoneX = checkIPhoneX() + + Object.assign(defFields.data = (defFields.data || {}), { + safeAreaConfig: defaultSafeArea, + statusBarHeight, + isIPhoneX, + }) + }, +}) diff --git a/dist/helpers/safeSetDataBehavior.js b/dist/helpers/safeSetDataBehavior.js new file mode 100644 index 0000000..f00f0ae --- /dev/null +++ b/dist/helpers/safeSetDataBehavior.js @@ -0,0 +1,57 @@ +export default Behavior({ + lifetimes: { + created() { + this.nextCallback = null + }, + detached() { + this.cancelNextCallback() + }, + }, + methods: { + /** + * safeSetData + * @param {Object} nextData 数据对象 + * @param {Function} callback 回调函数 + */ + safeSetData(nextData, callback) { + this.pendingData = Object.assign({}, this.data, nextData) + callback = this.setNextCallback(callback) + + this.setData(nextData, () => { + this.pendingData = null + callback() + }) + }, + /** + * 设置下一回调函数 + * @param {Function} callback 回调函数 + */ + setNextCallback(callback) { + let active = true + + this.nextCallback = (event) => { + if (active) { + active = false + this.nextCallback = null + + callback.call(this, event) + } + } + + this.nextCallback.cancel = () => { + active = false + } + + return this.nextCallback + }, + /** + * 取消下一回调函数 + */ + cancelNextCallback() { + if (this.nextCallback !== null) { + this.nextCallback.cancel() + this.nextCallback = null + } + }, + }, +}) \ No newline at end of file diff --git a/dist/helpers/shallowEqual.js b/dist/helpers/shallowEqual.js new file mode 100644 index 0000000..8aece72 --- /dev/null +++ b/dist/helpers/shallowEqual.js @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @typechecks + * + */ + +/*eslint-disable no-self-compare */ + +'use strict'; + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * inlined Object.is polyfill to avoid requiring consumers ship their own + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + */ +function is(x, y) { + // SameValue algorithm + if (x === y) { + // Steps 1-5, 7-10 + // Steps 6.b-6.e: +0 != -0 + // Added the nonzero y check to make Flow happy, but it is redundant + return x !== 0 || y !== 0 || 1 / x === 1 / y; + } else { + // Step 6.a: NaN == NaN + return x !== x && y !== y; + } +} + +/** + * Performs equality by iterating through keys on an object and returning false + * when any key has values which are not strictly equal between the arguments. + * Returns true when the values of all keys are strictly equal. + */ +function shallowEqual(objA, objB) { + if (is(objA, objB)) { + return true; + } + + if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { + return false; + } + + var keysA = Object.keys(objA); + var keysB = Object.keys(objB); + + if (keysA.length !== keysB.length) { + return false; + } + + // Test for A's keys different from B. + for (var i = 0; i < keysA.length; i++) { + if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) { + return false; + } + } + + return true; +} + +export default shallowEqual \ No newline at end of file diff --git a/dist/helpers/styleToCssString.js b/dist/helpers/styleToCssString.js new file mode 100644 index 0000000..1665cf7 --- /dev/null +++ b/dist/helpers/styleToCssString.js @@ -0,0 +1,138 @@ +'use strict'; + +/** + * CSS properties which accept numbers but are not in units of "px". + */ +var isUnitlessNumber = { + boxFlex: true, + boxFlexGroup: true, + columnCount: true, + flex: true, + flexGrow: true, + flexPositive: true, + flexShrink: true, + flexNegative: true, + fontWeight: true, + lineClamp: true, + lineHeight: true, + opacity: true, + order: true, + orphans: true, + widows: true, + zIndex: true, + zoom: true, + + // SVG-related properties + fillOpacity: true, + strokeDashoffset: true, + strokeOpacity: true, + strokeWidth: true +}; + +/** + * @param {string} prefix vendor-specific prefix, eg: Webkit + * @param {string} key style name, eg: transitionDuration + * @return {string} style name prefixed with `prefix`, properly camelCased, eg: + * WebkitTransitionDuration + */ +function prefixKey(prefix, key) { + return prefix + key.charAt(0).toUpperCase() + key.substring(1); +} + +/** + * Support style names that may come passed in prefixed by adding permutations + * of vendor prefixes. + */ +var prefixes = ['Webkit', 'ms', 'Moz', 'O']; + +// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an +// infinite loop, because it iterates over the newly added props too. +Object.keys(isUnitlessNumber).forEach(function(prop) { + prefixes.forEach(function(prefix) { + isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop]; + }); +}); + +var msPattern = /^ms-/; + +var _uppercasePattern = /([A-Z])/g; + +/** + * Hyphenates a camelcased string, for example: + * + * > hyphenate('backgroundColor') + * < "background-color" + * + * For CSS style names, use `hyphenateStyleName` instead which works properly + * with all vendor prefixes, including `ms`. + * + * @param {string} string + * @return {string} + */ +function hyphenate(string) { + return string.replace(_uppercasePattern, '-$1').toLowerCase(); +} + +/** + * Hyphenates a camelcased CSS property name, for example: + * + * > hyphenateStyleName('backgroundColor') + * < "background-color" + * > hyphenateStyleName('MozTransition') + * < "-moz-transition" + * > hyphenateStyleName('msTransition') + * < "-ms-transition" + * + * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix + * is converted to `-ms-`. + * + * @param {string} string + * @return {string} + */ +function hyphenateStyleName(string) { + return hyphenate(string).replace(msPattern, '-ms-'); +} + +var isArray = Array.isArray; +var keys = Object.keys; + +var counter = 1; +// Follows syntax at https://developer.mozilla.org/en-US/docs/Web/CSS/content, +// including multiple space separated values. +var unquotedContentValueRegex = /^(normal|none|(\b(url\([^)]*\)|chapter_counter|attr\([^)]*\)|(no-)?(open|close)-quote|inherit)((\b\s*)|$|\s+))+)$/; + +function buildRule(key, value) { + if (!isUnitlessNumber[key] && typeof value === 'number') { + value = '' + value + 'px'; + } else if (key === 'content' && !unquotedContentValueRegex.test(value)) { + value = "'" + value.replace(/'/g, "\\'") + "'"; + } + + return hyphenateStyleName(key) + ': ' + value + '; '; +} + +function styleToCssString(rules) { + var result = '' + if (typeof rules === 'string') { + return rules + } + if (!rules || keys(rules).length === 0) { + return result; + } + var styleKeys = keys(rules); + for (var j = 0, l = styleKeys.length; j < l; j++) { + var styleKey = styleKeys[j]; + var value = rules[styleKey]; + + if (isArray(value)) { + for (var i = 0, len = value.length; i < len; i++) { + result += buildRule(styleKey, value[i]); + } + } else { + result += buildRule(styleKey, value); + } + } + return result; +} + +export default styleToCssString \ No newline at end of file diff --git a/dist/step/index.js b/dist/step/index.js new file mode 100644 index 0000000..81fe7ed --- /dev/null +++ b/dist/step/index.js @@ -0,0 +1,88 @@ +import baseComponent from '../helpers/baseComponent' +import classNames from '../helpers/classNames' + +const defaultStatus = ['wait', 'process', 'finish', 'error'] +const defaultIcon = 'ios-checkmark' + +baseComponent({ + relations: { + '../steps/index': { + type: 'parent', + }, + }, + properties: { + prefixCls: { + type: String, + value: 'wux-step', + }, + status: { + type: String, + value: '', + }, + title: { + type: String, + value: '', + }, + content: { + type: String, + value: '', + }, + icon: { + type: String, + value: '', + }, + }, + data: { + width: '100%', + length: 1, + index: 0, + current: 0, + direction: 'horizontal', + }, + computed: { + classes: ['prefixCls, direction', function(prefixCls, direction) { + const wrap = classNames(prefixCls, { + [`${prefixCls}--${direction}`]: direction, + }) + const hd = `${prefixCls}__hd` + const icon = `${prefixCls}__icon` + const thumb = `${prefixCls}__thumb` + const bd = `${prefixCls}__bd` + const title = `${prefixCls}__title` + const content = `${prefixCls}__content` + const ft = `${prefixCls}__ft` + + return { + wrap, + hd, + icon, + thumb, + bd, + title, + content, + ft, + } + }], + }, + methods: { + updateCurrent(opts = {}) { + const width = opts.direction === 'horizontal' ? 100 / opts.length + '%' : '100%' + const index = defaultStatus.indexOf(this.data.status) + const hasIcon = opts.index < opts.current || this.data.icon + const thumb = this.data.icon || defaultIcon + const suffix = index !== -1 ? defaultStatus[index] : opts.index < opts.current ? 'finish' : opts.index === opts.current ? 'process' : '' + const className = `${this.data.prefixCls}--${suffix}` + const options = Object.assign({ + width, + className, + hasIcon, + thumb, + }, opts) + + this.setData(options) + }, + }, + attached() { + this.updateCurrent(this.data) + }, +}) diff --git a/dist/step/index.json b/dist/step/index.json new file mode 100644 index 0000000..6505d1c --- /dev/null +++ b/dist/step/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "wux-icon": "../icon/index" + } +} \ No newline at end of file diff --git a/dist/step/index.wxml b/dist/step/index.wxml new file mode 100644 index 0000000..34c5c27 --- /dev/null +++ b/dist/step/index.wxml @@ -0,0 +1,23 @@ + + + {{ index + 1 }} + + + + + + + {{ title }} + + + + + + {{ content }} + + + + + + + \ No newline at end of file diff --git a/dist/step/index.wxss b/dist/step/index.wxss new file mode 100644 index 0000000..ca7b91b --- /dev/null +++ b/dist/step/index.wxss @@ -0,0 +1,122 @@ +.wux-step { + font-size: 0; + position: relative; + display: inline-block; + box-sizing: border-box; + padding: 0 10rpx; + vertical-align: top +} +.wux-step--vertical { + padding-bottom: 60rpx +} +.wux-step--vertical .wux-step__hd { + float: left +} +.wux-step--vertical .wux-step__bd { + overflow: hidden; + display: block; + margin-left: 80rpx; + margin-top: 0; + text-align: left; + clear: inherit +} +.wux-step--vertical .wux-step__ft { + position: absolute; + left: 38rpx; + top: 0; + height: 100%; + width: 2rpx; + padding: 60rpx 0 8rpx; + margin-left: 0 +} +.wux-step--vertical .wux-step__ft::after { + width: 2rpx; + height: 100% +} +.wux-step__ft { + position: absolute; + left: 50%; + width: 100%; + top: 24rpx; + padding: 0 48rpx; + margin-left: 6rpx; + box-sizing: border-box +} +.wux-step__ft::after { + content: ""; + display: inline-block; + background: #d9d9d9; + height: 2rpx; + border-radius: 2rpx; + width: 100%; + transition: background .3s; + position: relative; + left: -4rpx +} +.wux-step__icon { + box-sizing: border-box; + font-size: 24rpx; + width: 48rpx; + height: 100%; + border-radius: 50%; + background: #fff; + position: relative; + z-index: 2; + margin: 0 auto; + border: #e9eaec solid 2rpx +} +.wux-step__thumb { + width: 100%; + height: 100%; + display: inline-block; + overflow: hidden +} +.wux-step--process .wux-step__icon { + border: #EBB672 solid 2rpx; + color: #fff; + background: #EBB672 +} +.wux-step--wait .wux-step__icon { + border: #e9eaec solid 2rpx; + color: #e9eaec +} +.wux-step--wait .wux-step__ft::after { + background: #e9eaec +} +.wux-step--finish .wux-step__icon { + border: #EBB672 solid 2rpx; + color: #EBB672 +} +.wux-step--finish .wux-step__ft::after { + background: #EBB672 +} +.wux-step--error .wux-step__icon { + border: #ef473a solid 2rpx; + color: #ef473a +} +.wux-step--error .wux-step__ft::after { + background: #ef473a +} +.wux-step__hd { + width: auto; + height: 48rpx; + line-height: 48rpx; + text-align: center; + box-sizing: border-box +} +.wux-step__bd { + margin-top: 20rpx; + text-align: center; + clear: both +} +.wux-step__title { + font-size: 28rpx; + font-weight: 700; + color: #333; +} +.wux-step__content { + font-size: 24rpx; + margin-top: 6rpx; + color: rgba(0,0,0,.65); + line-height: 36rpx; +} \ No newline at end of file diff --git a/dist/steps/index.js b/dist/steps/index.js new file mode 100644 index 0000000..d61b6e5 --- /dev/null +++ b/dist/steps/index.js @@ -0,0 +1,49 @@ +import baseComponent from '../helpers/baseComponent' +import classNames from '../helpers/classNames' + +baseComponent({ + relations: { + '../step/index': { + type: 'child', + observer() { + this.debounce(this.updateCurrent) + }, + }, + }, + properties: { + prefixCls: { + type: String, + value: 'wux-steps', + }, + current: { + type: Number, + value: 0, + observer: 'updateCurrent', + }, + // status: { + // type: String, + // value: '', + // }, + direction: { + type: String, + value: 'horizontal', + }, + }, + methods: { + updateCurrent() { + const elements = this.getRelationNodes('../step/index') + const { current, direction } = this.data + + if (elements.length > 0) { + elements.forEach((element, index) => { + element.updateCurrent({ + length: elements.length, + index, + current, + direction, + }) + }) + } + }, + }, +}) diff --git a/dist/steps/index.json b/dist/steps/index.json new file mode 100644 index 0000000..fba482a --- /dev/null +++ b/dist/steps/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/dist/steps/index.wxml b/dist/steps/index.wxml new file mode 100644 index 0000000..2779365 --- /dev/null +++ b/dist/steps/index.wxml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/dist/steps/index.wxss b/dist/steps/index.wxss new file mode 100644 index 0000000..ab579db --- /dev/null +++ b/dist/steps/index.wxss @@ -0,0 +1,4 @@ +.wux-steps { + position: relative; + width: 100% +} \ No newline at end of file diff --git a/images/arror-r-s.png b/images/arror-r-s.png new file mode 100644 index 0000000000000000000000000000000000000000..0043cf573651253d417c1e8c13fdaabf5fe81165 GIT binary patch literal 163 zcmeAS@N?(olHy`uVBq!ia0vp^5+KY0Bp8m$B&h(YEKe855RLQ6Kl+&s1SV({Rkz0` zDbIdq{KoC=ldxUgcl#bYO`5(Tx-Qb|gG5>Q-QZ{U8t?8r|Mf;#()Z)m*~=tv*#5XW zc_Hua^Yv~9B@d=LP(C1KIBB L>gTe~DWM4fGL}B# literal 0 HcmV?d00001 diff --git a/images/collect.png b/images/collect.png new file mode 100644 index 0000000000000000000000000000000000000000..2abf0ebe77a75a1d51b8e44140c4931e571a7d88 GIT binary patch literal 670 zcmV;P0%84$P)LiZUV;%IO?)>0LWL-0g1bo^97h&(q=D-{+ot&hK{)7qQI7iUA9w zpB9$`x@_PWG!A+Jz-JVMtWe{C+C_t)1DxSt6+AQs!Zzp;;tH%?G6Xu+$gmB%jetlM zJP<;Ni{MfWfNROshOE$+A1v76p4x2(Pb@FE3Dtkp?yLm{bAj;4{kEoJxRo3@1Eo!e z@4N}>!Tj^{dt4?p!H#J1;Y_(YLiNsLkAvx;s|>B#($dvgks2@SPk~|e-Gv+WU-tjZ z_~Q5ve`o6^GXMo|HP8U=qdjBMY-d0TJUv|pElHph!0&tqXB=v@8Oq>&J}?9x4eW!; zkGbQ0X7Fm@s|8lQ$`wCQ244LGF-hk)HtS+z#CL#rO_fR-hBc^`o5dT<<0 zW;qWH@LHPUU2?EkglSF>0AB3w? zuoe7?@PYNvIGiB2Gj=-#Vx=%8gb+%fM?J*}@($`{;5*ob5K6BbV08&Vqc1MRJeXzR z8(8L+x?KR4bHQnENn(~SP!yMdcr7^W02S?XLI{x{b(PR8UGx+6vawzWX%(yzibmw6 z(O(6Qj!=3IroH9he3|VsR>miEw{_&hXJuvnI%IGE07tifAs9drVgLXD07*qoM6N<$ Ef-hb%+yDRo literal 0 HcmV?d00001 diff --git a/images/phone.png b/images/phone.png new file mode 100644 index 0000000000000000000000000000000000000000..6bfb6b486ca02f124f8810d52cd93cc9d3e04140 GIT binary patch literal 755 zcmV1u2oyPG-VWlNx6c{CRfilEQuuTw%h(r`YcB7Impb**3F1DzsHes{~tcZ%V zwCF~Hy2y;~7cmPdf-syAEuArE{?~g{g`0s&^+WWnu z0F3=MNVpj`V3Ytb=3$tCQ4C3y#W4AcUvl-002sxP)FQ2e%zmF#8_C$LvNjW-+*dDG zI&ASthXJsxY99`8+I{uX=ZSDmlGJl_b8Z4)KRXO?8yW_c`beT${M!R{OMvZ02v7yz z{L(4d5O8F5JRArC9z&B~^2U=XNlmF~`IY_B+euhzf&q6lyMG@EDAfA>^FZJRT$K}cgmmk( z2o?=Ur7+ta0DOQGGVBzF&O<5emwHoSR{$`O8d)bT<4h>vo<~HZ)EtTRS^&}CCCTF) zZbVySN&F-o1INSgX1dzK-0w10!i2W)T;m|*dF0B0#K&O)#&THWRnJ0*9_+W5o0o2D zGxw#wY$!6+vjifJcqCo40gg&@BkNuO#fIFgfs8htw=yo<0$YEYI-fHQ)_bIrHi+J6 zC8b?8agfzvYL#DRL4jL(Itw7BUDBIrko?HhTRZ1NcBkYz={ + console.log(res) + if(res.data.success){ + this.setData({activityDetail:res.data.data}); + let article = res.data.data.content; + WxParse.wxParse('article', 'html', article, that,5); + } else{ + wx.showToast({ + title: res.data.msg, + icon:'none' + }) + } + }) + }, + call(){ + wx.makePhoneCall({ + phoneNumber: this.data.activityDetail.publisherVo.phone, + fail:function(){ + console.log('取消') + } + }) + }, + collect(){ + let data = {}; + data.id = this.data.activityDetail.id; + data.type = 'collect'; + data.status = this.data.activityDetail.collect ? false : true; + if(wx.getStorageSync('userInfo') != ''){ + this.requestCollect(data) + } else{ + wx.getUserProfile({ + desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 + success: (res) => { + console.log(res) + var iv = res.iv; + var encryptedData = res.encryptedData; + var userInfo = res.userInfo; + wx.login({ + success: request => { + // 发送 res.code 到后台换取 openId, sessionKey, unionId + app.http('POST','wxapp/auth',{code : request.code,iv:iv,encryptedData:encryptedData}).then( + response =>{ + if(response.data.success){ + wx.setStorageSync('token', 'Bearer '+ response.data.data.token); + wx.setStorageSync('userInfo', userInfo); + this.requestCollect(data) + } else{ + wx.showToast({ + title: response.data.msg, + icon : 'none' + }) + } + } + ) + } + }) + } + }) + } + }, + requestCollect(data){ + app.http('POST','activity/collect',data).then((res)=>{ + if(res.data.success){ + wx.showToast({ + title: '操作成功!', + }) + this.getDetail(); + } else{ + wx.showToast({ + title: res.data.msg, + icon:'none' + }) + } + }) + }, + toSignPage(){ + if(wx.getStorageSync('userInfo') != ''){ + wx.navigateTo({ + url: '../signIn/index?id='+this.data.activityId, + }) + } else{ + wx.getUserProfile({ + desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 + success: (res) => { + console.log(res) + var iv = res.iv; + var encryptedData = res.encryptedData; + var userInfo = res.userInfo; + wx.login({ + success: request => { + // 发送 res.code 到后台换取 openId, sessionKey, unionId + app.http('POST','wxapp/auth',{code : request.code,iv:iv,encryptedData:encryptedData}).then( + response =>{ + if(response.data.success){ + wx.setStorageSync('token', 'Bearer '+ response.data.data.token); + wx.setStorageSync('userInfo', userInfo); + wx.navigateTo({ + url: '../signIn/index?id='+this.data.activityId, + }) + } else{ + wx.showToast({ + title: response.data.msg, + icon : 'none' + }) + } + } + ) + } + }) + } + }) + } + }, + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/pages/activity/describe/index.json b/pages/activity/describe/index.json new file mode 100644 index 0000000..facafdc --- /dev/null +++ b/pages/activity/describe/index.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "活动详情" +} \ No newline at end of file diff --git a/pages/activity/describe/index.wxml b/pages/activity/describe/index.wxml new file mode 100644 index 0000000..27fb68f --- /dev/null +++ b/pages/activity/describe/index.wxml @@ -0,0 +1,31 @@ + + + + {{activityDetail.name}} + + {{activityDetail.publisherVo.name}} + {{activityDetail.updateTime}} 发布 + + + +