From 91eef9a5969de0e9c03b503564a1cd5d7ee72f43 Mon Sep 17 00:00:00 2001 From: neverland Date: Sun, 12 Aug 2018 17:35:13 +0800 Subject: [PATCH] [Doc] support share demo (#409) --- example/app.js | 1 - example/common/page.js | 10 +++++++++ example/pages/actionsheet/index.js | 3 +++ example/pages/badge/index.js | 2 ++ example/pages/button/index.js | 4 +++- example/pages/card/index.js | 2 ++ example/pages/cell/index.js | 32 ++--------------------------- example/pages/dashboard/index.js | 11 ++++++++-- example/pages/field/index.js | 2 ++ example/pages/icon/index.js | 2 ++ example/pages/layout/index.js | 4 +++- example/pages/loading/index.js | 4 +++- example/pages/nav-bar/index.js | 2 ++ example/pages/notice-bar/index.js | 2 ++ example/pages/notify/index.js | 3 ++- example/pages/panel/index.js | 12 ++--------- example/pages/popup/index.js | 2 ++ example/pages/search/index.js | 2 ++ example/pages/stepper/index.js | 4 +++- example/pages/steps/index.js | 2 ++ example/pages/switch/index.js | 2 ++ example/pages/tag/index.js | 4 +++- example/pages/tree-select/config.js | 2 +- example/pages/tree-select/index.js | 7 ++++--- 24 files changed, 68 insertions(+), 53 deletions(-) create mode 100644 example/common/page.js diff --git a/example/app.js b/example/app.js index d41b07d1..d439e30e 100644 --- a/example/app.js +++ b/example/app.js @@ -1,4 +1,3 @@ - App({ globalData: {} }); diff --git a/example/common/page.js b/example/common/page.js new file mode 100644 index 00000000..294559d2 --- /dev/null +++ b/example/common/page.js @@ -0,0 +1,10 @@ +export default function(options = {}) { + return Page({ + onShareAppMessage() { + return { + title: 'Vant Weapp 组件库演示' + }; + }, + ...options + }); +} diff --git a/example/pages/actionsheet/index.js b/example/pages/actionsheet/index.js index 4568c164..b7a70d3d 100644 --- a/example/pages/actionsheet/index.js +++ b/example/pages/actionsheet/index.js @@ -1,3 +1,6 @@ + +import Page from '../../common/page'; + Page({ data: { show1: false, diff --git a/example/pages/badge/index.js b/example/pages/badge/index.js index d908cafb..2cae4c79 100644 --- a/example/pages/badge/index.js +++ b/example/pages/badge/index.js @@ -1,3 +1,5 @@ +import Page from '../../common/page'; + Page({ onChange(event) { wx.showToast({ diff --git a/example/pages/button/index.js b/example/pages/button/index.js index 560d44d4..cc11dfda 100644 --- a/example/pages/button/index.js +++ b/example/pages/button/index.js @@ -1 +1,3 @@ -Page({}); +import Page from '../../common/page'; + +Page(); diff --git a/example/pages/card/index.js b/example/pages/card/index.js index 593772a5..9e1b000f 100644 --- a/example/pages/card/index.js +++ b/example/pages/card/index.js @@ -1,3 +1,5 @@ +import Page from '../../common/page'; + Page({ data: { imageURL: '//img.yzcdn.cn/upload_files/2017/07/02/af5b9f44deaeb68000d7e4a711160c53.jpg' diff --git a/example/pages/cell/index.js b/example/pages/cell/index.js index 576cca2a..cc11dfda 100644 --- a/example/pages/cell/index.js +++ b/example/pages/cell/index.js @@ -1,31 +1,3 @@ -var Zan = require('../../dist/index'); +import Page from '../../common/page'; -Page(Object.assign({}, Zan.Switch, { - data: { - checked: false, - show: true, - date: '' - }, - - onLoad() { - }, - - onShow() { - }, - - handleZanSwitchChange(e) { - this.setData({ - checked: e.checked - }); - }, - - bindDateChange(e) { - this.setData({ - date: e.detail.value - }); - }, - - handleTap() { - console.log('cell tapped'); - } -})); +Page(); diff --git a/example/pages/dashboard/index.js b/example/pages/dashboard/index.js index 59adad7a..51b5eb26 100644 --- a/example/pages/dashboard/index.js +++ b/example/pages/dashboard/index.js @@ -1,7 +1,14 @@ -import componentsConfig from './config'; +import config from './config'; +import Page from '../../common/page'; Page({ data: { - list: componentsConfig + list: config + }, + + onShareAppMessage() { + return { + title: 'Vant Weapp 组件库演示' + }; } }); diff --git a/example/pages/field/index.js b/example/pages/field/index.js index 28075b3e..cddd9b9b 100644 --- a/example/pages/field/index.js +++ b/example/pages/field/index.js @@ -1,3 +1,5 @@ +import Page from '../../common/page'; + Page({ data: { sms: '', diff --git a/example/pages/icon/index.js b/example/pages/icon/index.js index c3f362a2..8838b742 100644 --- a/example/pages/icon/index.js +++ b/example/pages/icon/index.js @@ -1,3 +1,5 @@ +import Page from '../../common/page'; + Page({ data: { icons: [ diff --git a/example/pages/layout/index.js b/example/pages/layout/index.js index 560d44d4..cc11dfda 100644 --- a/example/pages/layout/index.js +++ b/example/pages/layout/index.js @@ -1 +1,3 @@ -Page({}); +import Page from '../../common/page'; + +Page(); diff --git a/example/pages/loading/index.js b/example/pages/loading/index.js index 560d44d4..cc11dfda 100644 --- a/example/pages/loading/index.js +++ b/example/pages/loading/index.js @@ -1 +1,3 @@ -Page({}); +import Page from '../../common/page'; + +Page(); diff --git a/example/pages/nav-bar/index.js b/example/pages/nav-bar/index.js index f283faa8..265d9d52 100644 --- a/example/pages/nav-bar/index.js +++ b/example/pages/nav-bar/index.js @@ -1,3 +1,5 @@ +import Page from '../../common/page'; + Page({ onTapLeft() { wx.showToast({ title: '点击返回', icon: 'none' }); diff --git a/example/pages/notice-bar/index.js b/example/pages/notice-bar/index.js index be0e7e7f..691ec4bd 100644 --- a/example/pages/notice-bar/index.js +++ b/example/pages/notice-bar/index.js @@ -1,3 +1,5 @@ +import Page from '../../common/page'; + Page({ data: { text: '足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。' diff --git a/example/pages/notify/index.js b/example/pages/notify/index.js index d874dbe1..948dc9c4 100644 --- a/example/pages/notify/index.js +++ b/example/pages/notify/index.js @@ -1,4 +1,5 @@ -const Notify = require('../../dist/notify/index'); +import Page from '../../common/page'; +import Notify from '../../dist/notify/index'; Page({ showNotify() { diff --git a/example/pages/panel/index.js b/example/pages/panel/index.js index 454020c0..cc11dfda 100644 --- a/example/pages/panel/index.js +++ b/example/pages/panel/index.js @@ -1,11 +1,3 @@ -Page({ - data: { - }, +import Page from '../../common/page'; - onLoad: function () { - - }, - - onShow: function() { - }, -}) +Page(); diff --git a/example/pages/popup/index.js b/example/pages/popup/index.js index 664139bd..d040e499 100644 --- a/example/pages/popup/index.js +++ b/example/pages/popup/index.js @@ -1,3 +1,5 @@ +import Page from '../../common/page'; + Page({ data: { show: { diff --git a/example/pages/search/index.js b/example/pages/search/index.js index 2c08c126..794f5826 100644 --- a/example/pages/search/index.js +++ b/example/pages/search/index.js @@ -1,3 +1,5 @@ +import Page from '../../common/page'; + Page({ data: { value: '' diff --git a/example/pages/stepper/index.js b/example/pages/stepper/index.js index 560d44d4..cc11dfda 100644 --- a/example/pages/stepper/index.js +++ b/example/pages/stepper/index.js @@ -1 +1,3 @@ -Page({}); +import Page from '../../common/page'; + +Page(); diff --git a/example/pages/steps/index.js b/example/pages/steps/index.js index 5f3d9480..3ac017f8 100644 --- a/example/pages/steps/index.js +++ b/example/pages/steps/index.js @@ -1,3 +1,5 @@ +import Page from '../../common/page'; + Page({ data: { active: 0, diff --git a/example/pages/switch/index.js b/example/pages/switch/index.js index 55e1813f..598eb515 100644 --- a/example/pages/switch/index.js +++ b/example/pages/switch/index.js @@ -1,3 +1,5 @@ +import Page from '../../common/page'; + Page({ data: { checked: true, diff --git a/example/pages/tag/index.js b/example/pages/tag/index.js index 560d44d4..cc11dfda 100644 --- a/example/pages/tag/index.js +++ b/example/pages/tag/index.js @@ -1 +1,3 @@ -Page({}); +import Page from '../../common/page'; + +Page(); diff --git a/example/pages/tree-select/config.js b/example/pages/tree-select/config.js index 8d32aa89..ac99f37f 100644 --- a/example/pages/tree-select/config.js +++ b/example/pages/tree-select/config.js @@ -1,4 +1,4 @@ -module.exports = { +export default { pro1Name: '浙江', pro1: [{ text: '杭州', diff --git a/example/pages/tree-select/index.js b/example/pages/tree-select/index.js index 52e65c7b..a38947b7 100644 --- a/example/pages/tree-select/index.js +++ b/example/pages/tree-select/index.js @@ -1,4 +1,5 @@ -const config = require('./config'); +import Page from '../../common/page'; +import config from './config'; Page({ data: { @@ -22,13 +23,13 @@ Page({ activeId: 1002 }, - onNavClick({ detail = {} }) { + onNavClick({ detail }) { this.setData({ mainActiveIndex: detail.index || 0 }); }, - onItemClick({ detail = {} }) { + onItemClick({ detail }) { this.setData({ activeId: detail.id });