From 561ec67bf3686a85dbb544f4ee2648a37ec6d157 Mon Sep 17 00:00:00 2001 From: Junling Bu Date: Wed, 4 Dec 2019 21:13:55 +0800 Subject: [PATCH] =?UTF-8?q?feat[litemall-wx]:=20=E9=87=87=E7=94=A8vant-wea?= =?UTF-8?q?pp=20tag=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- litemall-wx/app.json | 3 + litemall-wx/lib/vant-weapp/common/color.d.ts | 7 + litemall-wx/lib/vant-weapp/common/color.js | 7 + .../lib/vant-weapp/common/component.d.ts | 3 + .../lib/vant-weapp/common/component.js | 48 +++++++ litemall-wx/lib/vant-weapp/common/index.wxss | 1 + .../lib/vant-weapp/common/style/clearfix.wxss | 1 + .../lib/vant-weapp/common/style/ellipsis.wxss | 1 + .../lib/vant-weapp/common/style/hairline.wxss | 1 + .../common/style/mixins/clearfix.wxss | 0 .../common/style/mixins/ellipsis.wxss | 0 .../common/style/mixins/hairline.wxss | 0 .../lib/vant-weapp/common/style/theme.wxss | 0 .../lib/vant-weapp/common/style/var.wxss | 0 litemall-wx/lib/vant-weapp/common/utils.d.ts | 8 ++ litemall-wx/lib/vant-weapp/common/utils.js | 32 +++++ litemall-wx/lib/vant-weapp/mixins/basic.d.ts | 1 + litemall-wx/lib/vant-weapp/mixins/basic.js | 22 ++++ litemall-wx/lib/vant-weapp/mixins/button.d.ts | 1 + litemall-wx/lib/vant-weapp/mixins/button.js | 18 +++ litemall-wx/lib/vant-weapp/mixins/link.d.ts | 1 + litemall-wx/lib/vant-weapp/mixins/link.js | 17 +++ .../vant-weapp/mixins/observer/behavior.d.ts | 1 + .../vant-weapp/mixins/observer/behavior.js | 14 ++ .../lib/vant-weapp/mixins/observer/index.d.ts | 1 + .../lib/vant-weapp/mixins/observer/index.js | 19 +++ .../lib/vant-weapp/mixins/open-type.d.ts | 1 + .../lib/vant-weapp/mixins/open-type.js | 25 ++++ litemall-wx/lib/vant-weapp/mixins/touch.d.ts | 1 + litemall-wx/lib/vant-weapp/mixins/touch.js | 35 +++++ .../lib/vant-weapp/mixins/transition.d.ts | 1 + .../lib/vant-weapp/mixins/transition.js | 120 ++++++++++++++++++ litemall-wx/lib/vant-weapp/tag/index.d.ts | 1 + litemall-wx/lib/vant-weapp/tag/index.js | 21 +++ .../capsule => vant-weapp/tag}/index.json | 2 +- litemall-wx/lib/vant-weapp/tag/index.wxml | 14 ++ litemall-wx/lib/vant-weapp/tag/index.wxss | 1 + litemall-wx/lib/vant-weapp/wxs/array.wxs | 5 + litemall-wx/lib/vant-weapp/wxs/bem.wxs | 38 ++++++ litemall-wx/lib/vant-weapp/wxs/memoize.wxs | 54 ++++++++ litemall-wx/lib/vant-weapp/wxs/object.wxs | 13 ++ litemall-wx/lib/vant-weapp/wxs/utils.wxs | 7 + litemall-wx/lib/zanui-weapp/capsule/index.js | 31 ----- .../lib/zanui-weapp/capsule/index.wxml | 10 -- .../lib/zanui-weapp/capsule/index.wxss | 42 ------ .../groupon/grouponList/grouponList.json | 5 +- .../groupon/grouponList/grouponList.wxml | 4 +- .../groupon/grouponList/grouponList.wxss | 10 -- .../pages/groupon/myGroupon/myGroupon.json | 5 +- .../pages/groupon/myGroupon/myGroupon.wxml | 8 +- .../pages/groupon/myGroupon/myGroupon.wxss | 9 -- litemall-wx/pages/index/index.json | 5 +- litemall-wx/pages/index/index.wxml | 4 +- litemall-wx/pages/index/index.wxss | 10 -- 54 files changed, 552 insertions(+), 137 deletions(-) create mode 100644 litemall-wx/lib/vant-weapp/common/color.d.ts create mode 100644 litemall-wx/lib/vant-weapp/common/color.js create mode 100644 litemall-wx/lib/vant-weapp/common/component.d.ts create mode 100644 litemall-wx/lib/vant-weapp/common/component.js create mode 100644 litemall-wx/lib/vant-weapp/common/index.wxss create mode 100644 litemall-wx/lib/vant-weapp/common/style/clearfix.wxss create mode 100644 litemall-wx/lib/vant-weapp/common/style/ellipsis.wxss create mode 100644 litemall-wx/lib/vant-weapp/common/style/hairline.wxss create mode 100644 litemall-wx/lib/vant-weapp/common/style/mixins/clearfix.wxss create mode 100644 litemall-wx/lib/vant-weapp/common/style/mixins/ellipsis.wxss create mode 100644 litemall-wx/lib/vant-weapp/common/style/mixins/hairline.wxss create mode 100644 litemall-wx/lib/vant-weapp/common/style/theme.wxss create mode 100644 litemall-wx/lib/vant-weapp/common/style/var.wxss create mode 100644 litemall-wx/lib/vant-weapp/common/utils.d.ts create mode 100644 litemall-wx/lib/vant-weapp/common/utils.js create mode 100644 litemall-wx/lib/vant-weapp/mixins/basic.d.ts create mode 100644 litemall-wx/lib/vant-weapp/mixins/basic.js create mode 100644 litemall-wx/lib/vant-weapp/mixins/button.d.ts create mode 100644 litemall-wx/lib/vant-weapp/mixins/button.js create mode 100644 litemall-wx/lib/vant-weapp/mixins/link.d.ts create mode 100644 litemall-wx/lib/vant-weapp/mixins/link.js create mode 100644 litemall-wx/lib/vant-weapp/mixins/observer/behavior.d.ts create mode 100644 litemall-wx/lib/vant-weapp/mixins/observer/behavior.js create mode 100644 litemall-wx/lib/vant-weapp/mixins/observer/index.d.ts create mode 100644 litemall-wx/lib/vant-weapp/mixins/observer/index.js create mode 100644 litemall-wx/lib/vant-weapp/mixins/open-type.d.ts create mode 100644 litemall-wx/lib/vant-weapp/mixins/open-type.js create mode 100644 litemall-wx/lib/vant-weapp/mixins/touch.d.ts create mode 100644 litemall-wx/lib/vant-weapp/mixins/touch.js create mode 100644 litemall-wx/lib/vant-weapp/mixins/transition.d.ts create mode 100644 litemall-wx/lib/vant-weapp/mixins/transition.js create mode 100644 litemall-wx/lib/vant-weapp/tag/index.d.ts create mode 100644 litemall-wx/lib/vant-weapp/tag/index.js rename litemall-wx/lib/{zanui-weapp/capsule => vant-weapp/tag}/index.json (91%) create mode 100644 litemall-wx/lib/vant-weapp/tag/index.wxml create mode 100644 litemall-wx/lib/vant-weapp/tag/index.wxss create mode 100644 litemall-wx/lib/vant-weapp/wxs/array.wxs create mode 100644 litemall-wx/lib/vant-weapp/wxs/bem.wxs create mode 100644 litemall-wx/lib/vant-weapp/wxs/memoize.wxs create mode 100644 litemall-wx/lib/vant-weapp/wxs/object.wxs create mode 100644 litemall-wx/lib/vant-weapp/wxs/utils.wxs delete mode 100644 litemall-wx/lib/zanui-weapp/capsule/index.js delete mode 100644 litemall-wx/lib/zanui-weapp/capsule/index.wxml delete mode 100644 litemall-wx/lib/zanui-weapp/capsule/index.wxss diff --git a/litemall-wx/app.json b/litemall-wx/app.json index 11012f1d..9dda6d87 100644 --- a/litemall-wx/app.json +++ b/litemall-wx/app.json @@ -86,5 +86,8 @@ "downloadFile": 10000 }, "debug": true, + "usingComponents": { + "van-tag": "./lib/vant-weapp/tag/index" + }, "sitemapLocation": "sitemap.json" } \ No newline at end of file diff --git a/litemall-wx/lib/vant-weapp/common/color.d.ts b/litemall-wx/lib/vant-weapp/common/color.d.ts new file mode 100644 index 00000000..386f3077 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/common/color.d.ts @@ -0,0 +1,7 @@ +export declare const RED = "#ee0a24"; +export declare const BLUE = "#1989fa"; +export declare const WHITE = "#fff"; +export declare const GREEN = "#07c160"; +export declare const ORANGE = "#ff976a"; +export declare const GRAY = "#323233"; +export declare const GRAY_DARK = "#969799"; diff --git a/litemall-wx/lib/vant-weapp/common/color.js b/litemall-wx/lib/vant-weapp/common/color.js new file mode 100644 index 00000000..6b285bd6 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/common/color.js @@ -0,0 +1,7 @@ +export const RED = '#ee0a24'; +export const BLUE = '#1989fa'; +export const WHITE = '#fff'; +export const GREEN = '#07c160'; +export const ORANGE = '#ff976a'; +export const GRAY = '#323233'; +export const GRAY_DARK = '#969799'; diff --git a/litemall-wx/lib/vant-weapp/common/component.d.ts b/litemall-wx/lib/vant-weapp/common/component.d.ts new file mode 100644 index 00000000..307a96cc --- /dev/null +++ b/litemall-wx/lib/vant-weapp/common/component.d.ts @@ -0,0 +1,3 @@ +import { VantComponentOptions, CombinedComponentInstance } from '../definitions/index'; +declare function VantComponent(vantOptions?: VantComponentOptions>): void; +export { VantComponent }; diff --git a/litemall-wx/lib/vant-weapp/common/component.js b/litemall-wx/lib/vant-weapp/common/component.js new file mode 100644 index 00000000..63ef1a9d --- /dev/null +++ b/litemall-wx/lib/vant-weapp/common/component.js @@ -0,0 +1,48 @@ +import { basic } from '../mixins/basic'; +import { observe } from '../mixins/observer/index'; +function mapKeys(source, target, map) { + Object.keys(map).forEach(key => { + if (source[key]) { + target[map[key]] = source[key]; + } + }); +} +function VantComponent(vantOptions = {}) { + const options = {}; + mapKeys(vantOptions, options, { + data: 'data', + props: 'properties', + mixins: 'behaviors', + methods: 'methods', + beforeCreate: 'created', + created: 'attached', + mounted: 'ready', + relations: 'relations', + destroyed: 'detached', + classes: 'externalClasses' + }); + const { relation } = vantOptions; + if (relation) { + options.relations = Object.assign(options.relations || {}, { + [`../${relation.name}/index`]: relation + }); + } + // add default externalClasses + options.externalClasses = options.externalClasses || []; + options.externalClasses.push('custom-class'); + // add default behaviors + options.behaviors = options.behaviors || []; + options.behaviors.push(basic); + // map field to form-field behavior + if (vantOptions.field) { + options.behaviors.push('wx://form-field'); + } + // add default options + options.options = { + multipleSlots: true, + addGlobalClass: true + }; + observe(vantOptions, options); + Component(options); +} +export { VantComponent }; diff --git a/litemall-wx/lib/vant-weapp/common/index.wxss b/litemall-wx/lib/vant-weapp/common/index.wxss new file mode 100644 index 00000000..6e6891ff --- /dev/null +++ b/litemall-wx/lib/vant-weapp/common/index.wxss @@ -0,0 +1 @@ +.van-ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{display:-webkit-box;overflow:hidden;text-overflow:ellipsis;-webkit-box-orient:vertical}.van-multi-ellipsis--l3{-webkit-line-clamp:3}.van-clearfix:after{display:table;clear:both;content:""}.van-hairline,.van-hairline--bottom,.van-hairline--left,.van-hairline--right,.van-hairline--surround,.van-hairline--top,.van-hairline--top-bottom{position:relative}.van-hairline--bottom:after,.van-hairline--left:after,.van-hairline--right:after,.van-hairline--surround:after,.van-hairline--top-bottom:after,.van-hairline--top:after,.van-hairline:after{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:-50%;right:-50%;bottom:-50%;left:-50%;border:0 solid #eee;-webkit-transform:scale(.5);transform:scale(.5)}.van-hairline--top:after{border-top-width:1px}.van-hairline--left:after{border-left-width:1px}.van-hairline--right:after{border-right-width:1px}.van-hairline--bottom:after{border-bottom-width:1px}.van-hairline--top-bottom:after{border-width:1px 0}.van-hairline--surround:after{border-width:1px} \ No newline at end of file diff --git a/litemall-wx/lib/vant-weapp/common/style/clearfix.wxss b/litemall-wx/lib/vant-weapp/common/style/clearfix.wxss new file mode 100644 index 00000000..a0ca8384 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/common/style/clearfix.wxss @@ -0,0 +1 @@ +.van-clearfix:after{display:table;clear:both;content:""} \ No newline at end of file diff --git a/litemall-wx/lib/vant-weapp/common/style/ellipsis.wxss b/litemall-wx/lib/vant-weapp/common/style/ellipsis.wxss new file mode 100644 index 00000000..1e9dbc9e --- /dev/null +++ b/litemall-wx/lib/vant-weapp/common/style/ellipsis.wxss @@ -0,0 +1 @@ +.van-ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{display:-webkit-box;overflow:hidden;text-overflow:ellipsis;-webkit-box-orient:vertical}.van-multi-ellipsis--l3{-webkit-line-clamp:3} \ No newline at end of file diff --git a/litemall-wx/lib/vant-weapp/common/style/hairline.wxss b/litemall-wx/lib/vant-weapp/common/style/hairline.wxss new file mode 100644 index 00000000..f64e2f83 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/common/style/hairline.wxss @@ -0,0 +1 @@ +.van-hairline,.van-hairline--bottom,.van-hairline--left,.van-hairline--right,.van-hairline--surround,.van-hairline--top,.van-hairline--top-bottom{position:relative}.van-hairline--bottom:after,.van-hairline--left:after,.van-hairline--right:after,.van-hairline--surround:after,.van-hairline--top-bottom:after,.van-hairline--top:after,.van-hairline:after{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:-50%;right:-50%;bottom:-50%;left:-50%;border:0 solid #eee;-webkit-transform:scale(.5);transform:scale(.5)}.van-hairline--top:after{border-top-width:1px}.van-hairline--left:after{border-left-width:1px}.van-hairline--right:after{border-right-width:1px}.van-hairline--bottom:after{border-bottom-width:1px}.van-hairline--top-bottom:after{border-width:1px 0}.van-hairline--surround:after{border-width:1px} \ No newline at end of file diff --git a/litemall-wx/lib/vant-weapp/common/style/mixins/clearfix.wxss b/litemall-wx/lib/vant-weapp/common/style/mixins/clearfix.wxss new file mode 100644 index 00000000..e69de29b diff --git a/litemall-wx/lib/vant-weapp/common/style/mixins/ellipsis.wxss b/litemall-wx/lib/vant-weapp/common/style/mixins/ellipsis.wxss new file mode 100644 index 00000000..e69de29b diff --git a/litemall-wx/lib/vant-weapp/common/style/mixins/hairline.wxss b/litemall-wx/lib/vant-weapp/common/style/mixins/hairline.wxss new file mode 100644 index 00000000..e69de29b diff --git a/litemall-wx/lib/vant-weapp/common/style/theme.wxss b/litemall-wx/lib/vant-weapp/common/style/theme.wxss new file mode 100644 index 00000000..e69de29b diff --git a/litemall-wx/lib/vant-weapp/common/style/var.wxss b/litemall-wx/lib/vant-weapp/common/style/var.wxss new file mode 100644 index 00000000..e69de29b diff --git a/litemall-wx/lib/vant-weapp/common/utils.d.ts b/litemall-wx/lib/vant-weapp/common/utils.d.ts new file mode 100644 index 00000000..9fad27d9 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/common/utils.d.ts @@ -0,0 +1,8 @@ +/// +export declare function isDef(value: any): boolean; +export declare function isObj(x: any): boolean; +export declare function isNumber(value: any): boolean; +export declare function range(num: number, min: number, max: number): number; +export declare function nextTick(fn: Function): void; +export declare function getSystemInfoSync(): WechatMiniprogram.GetSystemInfoSuccessCallbackResult; +export declare function addUnit(value?: string | number): string | undefined; diff --git a/litemall-wx/lib/vant-weapp/common/utils.js b/litemall-wx/lib/vant-weapp/common/utils.js new file mode 100644 index 00000000..cc0f8f11 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/common/utils.js @@ -0,0 +1,32 @@ +export function isDef(value) { + return value !== undefined && value !== null; +} +export function isObj(x) { + const type = typeof x; + return x !== null && (type === 'object' || type === 'function'); +} +export function isNumber(value) { + return /^\d+(\.\d+)?$/.test(value); +} +export function range(num, min, max) { + return Math.min(Math.max(num, min), max); +} +export function nextTick(fn) { + setTimeout(() => { + fn(); + }, 1000 / 30); +} +let systemInfo = null; +export function getSystemInfoSync() { + if (systemInfo == null) { + systemInfo = wx.getSystemInfoSync(); + } + return systemInfo; +} +export function addUnit(value) { + if (!isDef(value)) { + return undefined; + } + value = String(value); + return isNumber(value) ? `${value}px` : value; +} diff --git a/litemall-wx/lib/vant-weapp/mixins/basic.d.ts b/litemall-wx/lib/vant-weapp/mixins/basic.d.ts new file mode 100644 index 00000000..b2733690 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/mixins/basic.d.ts @@ -0,0 +1 @@ +export declare const basic: string; diff --git a/litemall-wx/lib/vant-weapp/mixins/basic.js b/litemall-wx/lib/vant-weapp/mixins/basic.js new file mode 100644 index 00000000..2fdd634f --- /dev/null +++ b/litemall-wx/lib/vant-weapp/mixins/basic.js @@ -0,0 +1,22 @@ +export const basic = Behavior({ + methods: { + $emit(...args) { + this.triggerEvent(...args); + }, + getRect(selector, all) { + return new Promise(resolve => { + wx.createSelectorQuery() + .in(this)[all ? 'selectAll' : 'select'](selector) + .boundingClientRect(rect => { + if (all && Array.isArray(rect) && rect.length) { + resolve(rect); + } + if (!all && rect) { + resolve(rect); + } + }) + .exec(); + }); + } + } +}); diff --git a/litemall-wx/lib/vant-weapp/mixins/button.d.ts b/litemall-wx/lib/vant-weapp/mixins/button.d.ts new file mode 100644 index 00000000..b51db875 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/mixins/button.d.ts @@ -0,0 +1 @@ +export declare const button: string; diff --git a/litemall-wx/lib/vant-weapp/mixins/button.js b/litemall-wx/lib/vant-weapp/mixins/button.js new file mode 100644 index 00000000..5d3b4dc4 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/mixins/button.js @@ -0,0 +1,18 @@ +export const button = Behavior({ + externalClasses: ['hover-class'], + properties: { + id: String, + lang: { + type: String, + value: 'en' + }, + businessId: Number, + sessionFrom: String, + sendMessageTitle: String, + sendMessagePath: String, + sendMessageImg: String, + showMessageCard: Boolean, + appParameter: String, + ariaLabel: String + } +}); diff --git a/litemall-wx/lib/vant-weapp/mixins/link.d.ts b/litemall-wx/lib/vant-weapp/mixins/link.d.ts new file mode 100644 index 00000000..d58043bc --- /dev/null +++ b/litemall-wx/lib/vant-weapp/mixins/link.d.ts @@ -0,0 +1 @@ +export declare const link: string; diff --git a/litemall-wx/lib/vant-weapp/mixins/link.js b/litemall-wx/lib/vant-weapp/mixins/link.js new file mode 100644 index 00000000..d7aed0c9 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/mixins/link.js @@ -0,0 +1,17 @@ +export const link = Behavior({ + properties: { + url: String, + linkType: { + type: String, + value: 'navigateTo' + } + }, + methods: { + jumpLink(urlKey = 'url') { + const url = this.data[urlKey]; + if (url) { + wx[this.data.linkType]({ url }); + } + } + } +}); diff --git a/litemall-wx/lib/vant-weapp/mixins/observer/behavior.d.ts b/litemall-wx/lib/vant-weapp/mixins/observer/behavior.d.ts new file mode 100644 index 00000000..3da2a645 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/mixins/observer/behavior.d.ts @@ -0,0 +1 @@ +export declare const behavior: string; diff --git a/litemall-wx/lib/vant-weapp/mixins/observer/behavior.js b/litemall-wx/lib/vant-weapp/mixins/observer/behavior.js new file mode 100644 index 00000000..948f446b --- /dev/null +++ b/litemall-wx/lib/vant-weapp/mixins/observer/behavior.js @@ -0,0 +1,14 @@ +export const behavior = Behavior({ + methods: { + set(data, callback) { + return new Promise(resolve => { + this.setData(data, () => { + if (callback && typeof callback === 'function') { + callback.call(this); + } + resolve(); + }); + }); + } + } +}); diff --git a/litemall-wx/lib/vant-weapp/mixins/observer/index.d.ts b/litemall-wx/lib/vant-weapp/mixins/observer/index.d.ts new file mode 100644 index 00000000..4e54b2e5 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/mixins/observer/index.d.ts @@ -0,0 +1 @@ +export declare function observe(vantOptions: any, options: any): void; diff --git a/litemall-wx/lib/vant-weapp/mixins/observer/index.js b/litemall-wx/lib/vant-weapp/mixins/observer/index.js new file mode 100644 index 00000000..d6f608d1 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/mixins/observer/index.js @@ -0,0 +1,19 @@ +import { behavior } from './behavior'; +export function observe(vantOptions, options) { + const { watch } = vantOptions; + options.behaviors.push(behavior); + if (watch) { + const props = options.properties || {}; + Object.keys(watch).forEach(key => { + if (key in props) { + let prop = props[key]; + if (prop === null || !('type' in prop)) { + prop = { type: prop }; + } + prop.observer = watch[key]; + props[key] = prop; + } + }); + options.properties = props; + } +} diff --git a/litemall-wx/lib/vant-weapp/mixins/open-type.d.ts b/litemall-wx/lib/vant-weapp/mixins/open-type.d.ts new file mode 100644 index 00000000..64b023d7 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/mixins/open-type.d.ts @@ -0,0 +1 @@ +export declare const openType: string; diff --git a/litemall-wx/lib/vant-weapp/mixins/open-type.js b/litemall-wx/lib/vant-weapp/mixins/open-type.js new file mode 100644 index 00000000..514517e0 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/mixins/open-type.js @@ -0,0 +1,25 @@ +export const openType = Behavior({ + properties: { + openType: String + }, + methods: { + bindGetUserInfo(event) { + this.$emit('getuserinfo', event.detail); + }, + bindContact(event) { + this.$emit('contact', event.detail); + }, + bindGetPhoneNumber(event) { + this.$emit('getphonenumber', event.detail); + }, + bindError(event) { + this.$emit('error', event.detail); + }, + bindLaunchApp(event) { + this.$emit('launchapp', event.detail); + }, + bindOpenSetting(event) { + this.$emit('opensetting', event.detail); + }, + } +}); diff --git a/litemall-wx/lib/vant-weapp/mixins/touch.d.ts b/litemall-wx/lib/vant-weapp/mixins/touch.d.ts new file mode 100644 index 00000000..35ee831d --- /dev/null +++ b/litemall-wx/lib/vant-weapp/mixins/touch.d.ts @@ -0,0 +1 @@ +export declare const touch: string; diff --git a/litemall-wx/lib/vant-weapp/mixins/touch.js b/litemall-wx/lib/vant-weapp/mixins/touch.js new file mode 100644 index 00000000..2a794267 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/mixins/touch.js @@ -0,0 +1,35 @@ +const MIN_DISTANCE = 10; +function getDirection(x, y) { + if (x > y && x > MIN_DISTANCE) { + return 'horizontal'; + } + if (y > x && y > MIN_DISTANCE) { + return 'vertical'; + } + return ''; +} +export const touch = Behavior({ + methods: { + resetTouchStatus() { + this.direction = ''; + this.deltaX = 0; + this.deltaY = 0; + this.offsetX = 0; + this.offsetY = 0; + }, + touchStart(event) { + this.resetTouchStatus(); + const touch = event.touches[0]; + this.startX = touch.clientX; + this.startY = touch.clientY; + }, + touchMove(event) { + const touch = event.touches[0]; + this.deltaX = touch.clientX - this.startX; + this.deltaY = touch.clientY - this.startY; + this.offsetX = Math.abs(this.deltaX); + this.offsetY = Math.abs(this.deltaY); + this.direction = this.direction || getDirection(this.offsetX, this.offsetY); + } + } +}); diff --git a/litemall-wx/lib/vant-weapp/mixins/transition.d.ts b/litemall-wx/lib/vant-weapp/mixins/transition.d.ts new file mode 100644 index 00000000..ee7b6ca8 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/mixins/transition.d.ts @@ -0,0 +1 @@ +export declare const transition: (showDefaultValue: boolean) => any; diff --git a/litemall-wx/lib/vant-weapp/mixins/transition.js b/litemall-wx/lib/vant-weapp/mixins/transition.js new file mode 100644 index 00000000..a64df6ab --- /dev/null +++ b/litemall-wx/lib/vant-weapp/mixins/transition.js @@ -0,0 +1,120 @@ +import { isObj } from '../common/utils'; +const getClassNames = (name) => ({ + enter: `van-${name}-enter van-${name}-enter-active enter-class enter-active-class`, + 'enter-to': `van-${name}-enter-to van-${name}-enter-active enter-to-class enter-active-class`, + leave: `van-${name}-leave van-${name}-leave-active leave-class leave-active-class`, + 'leave-to': `van-${name}-leave-to van-${name}-leave-active leave-to-class leave-active-class` +}); +const nextTick = () => new Promise(resolve => setTimeout(resolve, 1000 / 30)); +export const transition = function (showDefaultValue) { + return Behavior({ + properties: { + customStyle: String, + // @ts-ignore + show: { + type: Boolean, + value: showDefaultValue, + observer: 'observeShow' + }, + // @ts-ignore + duration: { + type: null, + value: 300, + observer: 'observeDuration' + }, + name: { + type: String, + value: 'fade' + } + }, + data: { + type: '', + inited: false, + display: false + }, + attached() { + if (this.data.show) { + this.enter(); + } + }, + methods: { + observeShow(value) { + value ? this.enter() : this.leave(); + }, + enter() { + const { duration, name } = this.data; + const classNames = getClassNames(name); + const currentDuration = isObj(duration) ? duration.enter : duration; + this.status = 'enter'; + this.$emit('before-enter'); + Promise.resolve() + .then(nextTick) + .then(() => { + this.checkStatus('enter'); + this.$emit('enter'); + this.setData({ + inited: true, + display: true, + classes: classNames.enter, + currentDuration + }); + }) + .then(nextTick) + .then(() => { + this.checkStatus('enter'); + this.transitionEnded = false; + this.setData({ + classes: classNames['enter-to'] + }); + }) + .catch(() => { }); + }, + leave() { + if (!this.data.display) { + return; + } + const { duration, name } = this.data; + const classNames = getClassNames(name); + const currentDuration = isObj(duration) ? duration.leave : duration; + this.status = 'leave'; + this.$emit('before-leave'); + Promise.resolve() + .then(nextTick) + .then(() => { + this.checkStatus('leave'); + this.$emit('leave'); + this.setData({ + classes: classNames.leave, + currentDuration + }); + }) + .then(nextTick) + .then(() => { + this.checkStatus('leave'); + this.transitionEnded = false; + setTimeout(() => this.onTransitionEnd(), currentDuration); + this.setData({ + classes: classNames['leave-to'] + }); + }) + .catch(() => { }); + }, + checkStatus(status) { + if (status !== this.status) { + throw new Error(`incongruent status: ${status}`); + } + }, + onTransitionEnd() { + if (this.transitionEnded) { + return; + } + this.transitionEnded = true; + this.$emit(`after-${this.status}`); + const { show, display } = this.data; + if (!show && display) { + this.setData({ display: false }); + } + } + } + }); +}; diff --git a/litemall-wx/lib/vant-weapp/tag/index.d.ts b/litemall-wx/lib/vant-weapp/tag/index.d.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/tag/index.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/litemall-wx/lib/vant-weapp/tag/index.js b/litemall-wx/lib/vant-weapp/tag/index.js new file mode 100644 index 00000000..093acb56 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/tag/index.js @@ -0,0 +1,21 @@ +import { VantComponent } from '../common/component'; +VantComponent({ + props: { + size: String, + mark: Boolean, + color: String, + plain: Boolean, + round: Boolean, + textColor: String, + type: { + type: String, + value: 'default' + }, + closeable: Boolean + }, + methods: { + onClose() { + this.$emit('close'); + } + } +}); diff --git a/litemall-wx/lib/zanui-weapp/capsule/index.json b/litemall-wx/lib/vant-weapp/tag/index.json similarity index 91% rename from litemall-wx/lib/zanui-weapp/capsule/index.json rename to litemall-wx/lib/vant-weapp/tag/index.json index 467ce294..32640e0d 100644 --- a/litemall-wx/lib/zanui-weapp/capsule/index.json +++ b/litemall-wx/lib/vant-weapp/tag/index.json @@ -1,3 +1,3 @@ { "component": true -} +} \ No newline at end of file diff --git a/litemall-wx/lib/vant-weapp/tag/index.wxml b/litemall-wx/lib/vant-weapp/tag/index.wxml new file mode 100644 index 00000000..8c786865 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/tag/index.wxml @@ -0,0 +1,14 @@ + + + + + + diff --git a/litemall-wx/lib/vant-weapp/tag/index.wxss b/litemall-wx/lib/vant-weapp/tag/index.wxss new file mode 100644 index 00000000..211e3769 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/tag/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-tag{display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;line-height:normal;padding:.2em .5em;padding:var(--tag-padding,.2em .5em);color:#fff;color:var(--tag-text-color,#fff);font-size:10px;font-size:var(--tag-font-size,10px);border-radius:.2em;border-radius:var(--tag-border-radius,.2em)}.van-tag:after{border-color:currentColor;border-radius:.2em * 2;border-radius:var(--tag-border-radius,.2em) * 2}.van-tag--default{background-color:#969799;background-color:var(--tag-default-color,#969799)}.van-tag--default.van-tag--plain{color:#969799;color:var(--tag-default-color,#969799)}.van-tag--danger{background-color:#ee0a24;background-color:var(--tag-dander-color,#ee0a24)}.van-tag--danger.van-tag--plain{color:#ee0a24;color:var(--tag-dander-color,#ee0a24)}.van-tag--primary{background-color:#1989fa;background-color:var(--tag-primary-color,#1989fa)}.van-tag--primary.van-tag--plain{color:#1989fa;color:var(--tag-primary-color,#1989fa)}.van-tag--success{background-color:#07c160;background-color:var(--tag-success-color,#07c160)}.van-tag--success.van-tag--plain{color:#07c160;color:var(--tag-success-color,#07c160)}.van-tag--warning{background-color:#ff976a;background-color:var(--tag-warning-color,#ff976a)}.van-tag--warning.van-tag--plain{color:#ff976a;color:var(--tag-warning-color,#ff976a)}.van-tag--plain{background-color:#fff;background-color:var(--tag-plain-background-color,#fff)}.van-tag--mark{padding-right:.7em}.van-tag--mark,.van-tag--mark:after{border-radius:0 999px 999px 0;border-radius:0 var(--tag-round-border-radius,999px) var(--tag-round-border-radius,999px) 0}.van-tag--round,.van-tag--round:after{border-radius:999px;border-radius:var(--tag-round-border-radius,999px)}.van-tag--medium{font-size:12px;font-size:var(--tag-medium-font-size,12px)}.van-tag--large{font-size:14px;font-size:var(--tag-large-font-size,14px)}.van-tag__close{margin-left:2px} \ No newline at end of file diff --git a/litemall-wx/lib/vant-weapp/wxs/array.wxs b/litemall-wx/lib/vant-weapp/wxs/array.wxs new file mode 100644 index 00000000..610089cd --- /dev/null +++ b/litemall-wx/lib/vant-weapp/wxs/array.wxs @@ -0,0 +1,5 @@ +function isArray(array) { + return array && array.constructor === 'Array'; +} + +module.exports.isArray = isArray; diff --git a/litemall-wx/lib/vant-weapp/wxs/bem.wxs b/litemall-wx/lib/vant-weapp/wxs/bem.wxs new file mode 100644 index 00000000..93b2777b --- /dev/null +++ b/litemall-wx/lib/vant-weapp/wxs/bem.wxs @@ -0,0 +1,38 @@ +var array = require('./array.wxs'); +var object = require('./object.wxs'); +var PREFIX = 'van-'; + +function join(name, mods) { + name = PREFIX + name; + mods = mods.map(function(mod) { + return name + '--' + mod; + }); + mods.unshift(name); + return mods.join(' '); +} + +function traversing(mods, conf) { + if (!conf) { + return; + } + + if (typeof conf === 'string' || typeof conf === 'number') { + mods.push(conf); + } else if (array.isArray(conf)) { + conf.forEach(function(item) { + traversing(mods, item); + }); + } else if (typeof conf === 'object') { + object.keys(conf).forEach(function(key) { + conf[key] && mods.push(key); + }); + } +} + +function bem(name, conf) { + var mods = []; + traversing(mods, conf); + return join(name, mods); +} + +module.exports.bem = bem; diff --git a/litemall-wx/lib/vant-weapp/wxs/memoize.wxs b/litemall-wx/lib/vant-weapp/wxs/memoize.wxs new file mode 100644 index 00000000..261ae67d --- /dev/null +++ b/litemall-wx/lib/vant-weapp/wxs/memoize.wxs @@ -0,0 +1,54 @@ +/** + * Simple memoize + * wxs doesn't support fn.apply, so this memoize only support up to 2 args + */ + +function isPrimitive(value) { + var type = typeof value; + return ( + type === 'boolean' || + type === 'number' || + type === 'string' || + type === 'undefined' || + value === null + ); +} + +// mock simple fn.call in wxs +function call(fn, args) { + if (args.length === 2) { + return fn(args[0], args[1]); + } + + if (args.length === 1) { + return fn(args[0]); + } + + return fn(); +} + +function serializer(args) { + if (args.length === 1 && isPrimitive(args[0])) { + return args[0]; + } + var obj = {}; + for (var i = 0; i < args.length; i++) { + obj['key' + i] = args[i]; + } + return JSON.stringify(obj); +} + +function memoize(fn) { + var cache = {}; + + return function() { + var key = serializer(arguments); + if (cache[key] === undefined) { + cache[key] = call(fn, arguments); + } + + return cache[key]; + }; +} + +module.exports.memoize = memoize; diff --git a/litemall-wx/lib/vant-weapp/wxs/object.wxs b/litemall-wx/lib/vant-weapp/wxs/object.wxs new file mode 100644 index 00000000..e0771077 --- /dev/null +++ b/litemall-wx/lib/vant-weapp/wxs/object.wxs @@ -0,0 +1,13 @@ +/* eslint-disable */ +var REGEXP = getRegExp('{|}|"', 'g'); + +function keys(obj) { + return JSON.stringify(obj) + .replace(REGEXP, '') + .split(',') + .map(function(item) { + return item.split(':')[0]; + }); +} + +module.exports.keys = keys; diff --git a/litemall-wx/lib/vant-weapp/wxs/utils.wxs b/litemall-wx/lib/vant-weapp/wxs/utils.wxs new file mode 100644 index 00000000..a18662df --- /dev/null +++ b/litemall-wx/lib/vant-weapp/wxs/utils.wxs @@ -0,0 +1,7 @@ +var bem = require('./bem.wxs').bem; +var memoize = require('./memoize.wxs').memoize; + +module.exports = { + bem: memoize(bem), + memoize: memoize +}; diff --git a/litemall-wx/lib/zanui-weapp/capsule/index.js b/litemall-wx/lib/zanui-weapp/capsule/index.js deleted file mode 100644 index 7b8452cc..00000000 --- a/litemall-wx/lib/zanui-weapp/capsule/index.js +++ /dev/null @@ -1,31 +0,0 @@ -'use strict'; - -Component({ - externalClasses: ['custom-class'], - /** - * 组件的属性列表 - * 用于组件自定义设置 - */ - properties: { - // 颜色状态 - type: { - type: String, - value: '' - }, - // 自定义颜色 - color: { - type: String, - value: '' - }, - // 左侧内容 - leftText: { - type: String, - value: '' - }, - // 右侧内容 - rightText: { - type: String, - value: '' - } - } -}); \ No newline at end of file diff --git a/litemall-wx/lib/zanui-weapp/capsule/index.wxml b/litemall-wx/lib/zanui-weapp/capsule/index.wxml deleted file mode 100644 index 2c81021a..00000000 --- a/litemall-wx/lib/zanui-weapp/capsule/index.wxml +++ /dev/null @@ -1,10 +0,0 @@ - - - {{ leftText }} - {{ rightText }} - - - {{ leftText }} - {{ rightText }} - - \ No newline at end of file diff --git a/litemall-wx/lib/zanui-weapp/capsule/index.wxss b/litemall-wx/lib/zanui-weapp/capsule/index.wxss deleted file mode 100644 index 4ba0eec5..00000000 --- a/litemall-wx/lib/zanui-weapp/capsule/index.wxss +++ /dev/null @@ -1,42 +0,0 @@ -.zan-capsule { - display: inline-block; - font-size: 12px; - vertical-align: middle; - line-height: 19px; - -webkit-transform: scale(0.83); - transform: scale(0.83); -} - -.zan-capsule__left, .zan-capsule__right { - display: inline-block; - line-height: 17px; - height: 19px; - vertical-align: middle; - box-sizing: border-box; -} - -.zan-capsule__left { - padding: 0 2px; - color: #fff; - background: #999; - border-radius: 2px 0 0 2px; - border: 1rpx solid #999; -} - -.zan-capsule__right { - padding: 0 5px; - color: #999; - border-radius: 0 2px 2px 0; - border: 1rpx solid #999; -} - -.zan-capsule--danger .zan-capsule__left { - color: #fff; - background: #f24544; - border-color: #f24544; -} - -.zan-capsule--danger .zan-capsule__right { - color: #f24544; - border-color: #f24544; -} diff --git a/litemall-wx/pages/groupon/grouponList/grouponList.json b/litemall-wx/pages/groupon/grouponList/grouponList.json index 43f28ddf..264e14a5 100644 --- a/litemall-wx/pages/groupon/grouponList/grouponList.json +++ b/litemall-wx/pages/groupon/grouponList/grouponList.json @@ -1,6 +1,3 @@ { - "navigationBarTitleText": "团购专区", - "usingComponents": { - "zan-capsule": "/lib/zanui-weapp/capsule/index" - } + "navigationBarTitleText": "团购专区" } \ No newline at end of file diff --git a/litemall-wx/pages/groupon/grouponList/grouponList.wxml b/litemall-wx/pages/groupon/grouponList/grouponList.wxml index c90a7fe2..9bfcd8e0 100644 --- a/litemall-wx/pages/groupon/grouponList/grouponList.wxml +++ b/litemall-wx/pages/groupon/grouponList/grouponList.wxml @@ -8,9 +8,7 @@ {{item.name}} - - - + {{item.grouponMember}}人成团 {{item.brief}} diff --git a/litemall-wx/pages/groupon/grouponList/grouponList.wxss b/litemall-wx/pages/groupon/grouponList/grouponList.wxss index a265f775..2d621b97 100644 --- a/litemall-wx/pages/groupon/grouponList/grouponList.wxss +++ b/litemall-wx/pages/groupon/grouponList/grouponList.wxss @@ -54,16 +54,6 @@ page, .container { font-size: 30rpx; } -.groupon-list .capsule-tag { - float: right; - padding-right: 0rpx; - padding-top: 8rpx; -} - -.groupon-list .zan-capsule + .zan-capsule { - margin-left: 10px; -} - .groupon-list .desc { width: 476rpx; display: block; diff --git a/litemall-wx/pages/groupon/myGroupon/myGroupon.json b/litemall-wx/pages/groupon/myGroupon/myGroupon.json index 67a44db6..51e6af06 100644 --- a/litemall-wx/pages/groupon/myGroupon/myGroupon.json +++ b/litemall-wx/pages/groupon/myGroupon/myGroupon.json @@ -1,6 +1,3 @@ { - "navigationBarTitleText": "我的团购", - "usingComponents": { - "zan-capsule": "../../../lib/zanui-weapp/capsule/index" - } + "navigationBarTitleText": "我的团购" } \ No newline at end of file diff --git a/litemall-wx/pages/groupon/myGroupon/myGroupon.wxml b/litemall-wx/pages/groupon/myGroupon/myGroupon.wxml index 667f5d66..3ee52fda 100644 --- a/litemall-wx/pages/groupon/myGroupon/myGroupon.wxml +++ b/litemall-wx/pages/groupon/myGroupon/myGroupon.wxml @@ -40,12 +40,8 @@ 实付:¥{{item.actualPrice}} - - - - - - + {{item.joinerCount>=item.rules.discountMember?'已达成':'团购中'}} + {{item.creator}}发起 diff --git a/litemall-wx/pages/groupon/myGroupon/myGroupon.wxss b/litemall-wx/pages/groupon/myGroupon/myGroupon.wxss index 91c436df..fe1199c6 100644 --- a/litemall-wx/pages/groupon/myGroupon/myGroupon.wxss +++ b/litemall-wx/pages/groupon/myGroupon/myGroupon.wxss @@ -4,15 +4,6 @@ page { background: #f4f4f4; } -.capsule-tag { - float: right; - /* padding-right: 10rpx; */ -} - -.zan-capsule + .zan-capsule { - margin-left: 5px; -} - .orders-switch { width: 100%; background: #fff; diff --git a/litemall-wx/pages/index/index.json b/litemall-wx/pages/index/index.json index 7368d159..910c6fb2 100644 --- a/litemall-wx/pages/index/index.json +++ b/litemall-wx/pages/index/index.json @@ -1,7 +1,4 @@ { "navigationBarTitleText": "首页", - "enablePullDownRefresh": true, - "usingComponents": { - "zan-capsule": "../../lib/zanui-weapp/capsule/index" - } + "enablePullDownRefresh": true } \ No newline at end of file diff --git a/litemall-wx/pages/index/index.wxml b/litemall-wx/pages/index/index.wxml index d9330715..91d9d356 100644 --- a/litemall-wx/pages/index/index.wxml +++ b/litemall-wx/pages/index/index.wxml @@ -72,9 +72,7 @@ {{item.name}} - - - + {{item.grouponMember}}人成团 {{item.brief}} diff --git a/litemall-wx/pages/index/index.wxss b/litemall-wx/pages/index/index.wxss index adecbe48..4564770a 100644 --- a/litemall-wx/pages/index/index.wxss +++ b/litemall-wx/pages/index/index.wxss @@ -242,16 +242,6 @@ font-size: 30rpx; } -.a-groupon .capsule-tag { - float: right; - padding-right: 0rpx; - padding-top: 8rpx; -} - -.a-groupon .zan-capsule + .zan-capsule { - margin-left: 10px; -} - .a-groupon .b .desc { width: 476rpx; display: block;