guhongwei 3 tahun lalu
induk
melakukan
e45477b069
100 mengubah file dengan 2116 tambahan dan 8 penghapusan
  1. 38 7
      app.json
  2. 7 1
      app.wxss
  3. 1 0
      miniprogram_npm/vant-weapp/action-sheet/index.d.ts
  4. 43 0
      miniprogram_npm/vant-weapp/action-sheet/index.js
  5. 8 0
      miniprogram_npm/vant-weapp/action-sheet/index.json
  6. 51 0
      miniprogram_npm/vant-weapp/action-sheet/index.wxml
  7. 1 0
      miniprogram_npm/vant-weapp/action-sheet/index.wxss
  8. 1 0
      miniprogram_npm/vant-weapp/area/index.d.ts
  9. 212 0
      miniprogram_npm/vant-weapp/area/index.js
  10. 6 0
      miniprogram_npm/vant-weapp/area/index.json
  11. 18 0
      miniprogram_npm/vant-weapp/area/index.wxml
  12. 1 0
      miniprogram_npm/vant-weapp/area/index.wxss
  13. 1 0
      miniprogram_npm/vant-weapp/badge-group/index.d.ts
  14. 43 0
      miniprogram_npm/vant-weapp/badge-group/index.js
  15. 3 0
      miniprogram_npm/vant-weapp/badge-group/index.json
  16. 3 0
      miniprogram_npm/vant-weapp/badge-group/index.wxml
  17. 1 0
      miniprogram_npm/vant-weapp/badge-group/index.wxss
  18. 1 0
      miniprogram_npm/vant-weapp/badge/index.d.ts
  19. 30 0
      miniprogram_npm/vant-weapp/badge/index.js
  20. 6 0
      miniprogram_npm/vant-weapp/badge/index.json
  21. 17 0
      miniprogram_npm/vant-weapp/badge/index.wxml
  22. 1 0
      miniprogram_npm/vant-weapp/badge/index.wxss
  23. 1 0
      miniprogram_npm/vant-weapp/button/index.d.ts
  24. 38 0
      miniprogram_npm/vant-weapp/button/index.js
  25. 7 0
      miniprogram_npm/vant-weapp/button/index.json
  26. 51 0
      miniprogram_npm/vant-weapp/button/index.wxml
  27. 1 0
      miniprogram_npm/vant-weapp/button/index.wxss
  28. 1 0
      miniprogram_npm/vant-weapp/card/index.d.ts
  29. 38 0
      miniprogram_npm/vant-weapp/card/index.js
  30. 6 0
      miniprogram_npm/vant-weapp/card/index.json
  31. 45 0
      miniprogram_npm/vant-weapp/card/index.wxml
  32. 1 0
      miniprogram_npm/vant-weapp/card/index.wxss
  33. 1 0
      miniprogram_npm/vant-weapp/cell-group/index.d.ts
  34. 10 0
      miniprogram_npm/vant-weapp/cell-group/index.js
  35. 3 0
      miniprogram_npm/vant-weapp/cell-group/index.json
  36. 9 0
      miniprogram_npm/vant-weapp/cell-group/index.wxml
  37. 1 0
      miniprogram_npm/vant-weapp/cell-group/index.wxss
  38. 1 0
      miniprogram_npm/vant-weapp/cell/index.d.ts
  39. 37 0
      miniprogram_npm/vant-weapp/cell/index.js
  40. 6 0
      miniprogram_npm/vant-weapp/cell/index.json
  41. 45 0
      miniprogram_npm/vant-weapp/cell/index.wxml
  42. 1 0
      miniprogram_npm/vant-weapp/cell/index.wxss
  43. 1 0
      miniprogram_npm/vant-weapp/checkbox-group/index.d.ts
  44. 39 0
      miniprogram_npm/vant-weapp/checkbox-group/index.js
  45. 3 0
      miniprogram_npm/vant-weapp/checkbox-group/index.json
  46. 1 0
      miniprogram_npm/vant-weapp/checkbox-group/index.wxml
  47. 1 0
      miniprogram_npm/vant-weapp/checkbox-group/index.wxss
  48. 1 0
      miniprogram_npm/vant-weapp/checkbox/index.d.ts
  49. 74 0
      miniprogram_npm/vant-weapp/checkbox/index.js
  50. 6 0
      miniprogram_npm/vant-weapp/checkbox/index.json
  51. 18 0
      miniprogram_npm/vant-weapp/checkbox/index.wxml
  52. 1 0
      miniprogram_npm/vant-weapp/checkbox/index.wxss
  53. 1 0
      miniprogram_npm/vant-weapp/col/index.d.ts
  54. 23 0
      miniprogram_npm/vant-weapp/col/index.js
  55. 3 0
      miniprogram_npm/vant-weapp/col/index.json
  56. 8 0
      miniprogram_npm/vant-weapp/col/index.wxml
  57. 1 0
      miniprogram_npm/vant-weapp/col/index.wxss
  58. 1 0
      miniprogram_npm/vant-weapp/collapse-item/index.d.ts
  59. 96 0
      miniprogram_npm/vant-weapp/collapse-item/index.js
  60. 6 0
      miniprogram_npm/vant-weapp/collapse-item/index.json
  61. 44 0
      miniprogram_npm/vant-weapp/collapse-item/index.wxml
  62. 1 0
      miniprogram_npm/vant-weapp/collapse-item/index.wxss
  63. 1 0
      miniprogram_npm/vant-weapp/collapse/index.d.ts
  64. 50 0
      miniprogram_npm/vant-weapp/collapse/index.js
  65. 3 0
      miniprogram_npm/vant-weapp/collapse/index.json
  66. 3 0
      miniprogram_npm/vant-weapp/collapse/index.wxml
  67. 1 0
      miniprogram_npm/vant-weapp/collapse/index.wxss
  68. 4 0
      miniprogram_npm/vant-weapp/common/color.d.ts
  69. 4 0
      miniprogram_npm/vant-weapp/common/color.js
  70. 3 0
      miniprogram_npm/vant-weapp/common/component.d.ts
  71. 48 0
      miniprogram_npm/vant-weapp/common/component.js
  72. 1 0
      miniprogram_npm/vant-weapp/common/index.wxss
  73. 1 0
      miniprogram_npm/vant-weapp/common/style/clearfix.wxss
  74. 1 0
      miniprogram_npm/vant-weapp/common/style/ellipsis.wxss
  75. 1 0
      miniprogram_npm/vant-weapp/common/style/hairline.wxss
  76. 0 0
      miniprogram_npm/vant-weapp/common/style/mixins/clearfix.wxss
  77. 0 0
      miniprogram_npm/vant-weapp/common/style/mixins/ellipsis.wxss
  78. 0 0
      miniprogram_npm/vant-weapp/common/style/mixins/hairline.wxss
  79. 0 0
      miniprogram_npm/vant-weapp/common/style/var.wxss
  80. 7 0
      miniprogram_npm/vant-weapp/common/utils.d.ts
  81. 25 0
      miniprogram_npm/vant-weapp/common/utils.js
  82. 1 0
      miniprogram_npm/vant-weapp/datetime-picker/index.d.ts
  83. 287 0
      miniprogram_npm/vant-weapp/datetime-picker/index.js
  84. 6 0
      miniprogram_npm/vant-weapp/datetime-picker/index.json
  85. 16 0
      miniprogram_npm/vant-weapp/datetime-picker/index.wxml
  86. 1 0
      miniprogram_npm/vant-weapp/datetime-picker/index.wxss
  87. 32 0
      miniprogram_npm/vant-weapp/definitions/index.d.ts
  88. 0 0
      miniprogram_npm/vant-weapp/definitions/index.js
  89. 111 0
      miniprogram_npm/vant-weapp/definitions/weapp.d.ts
  90. 0 0
      miniprogram_npm/vant-weapp/definitions/weapp.js
  91. 45 0
      miniprogram_npm/vant-weapp/dialog/dialog.d.ts
  92. 61 0
      miniprogram_npm/vant-weapp/dialog/dialog.js
  93. 1 0
      miniprogram_npm/vant-weapp/dialog/index.d.ts
  94. 98 0
      miniprogram_npm/vant-weapp/dialog/index.js
  95. 7 0
      miniprogram_npm/vant-weapp/dialog/index.json
  96. 65 0
      miniprogram_npm/vant-weapp/dialog/index.wxml
  97. 1 0
      miniprogram_npm/vant-weapp/dialog/index.wxss
  98. 1 0
      miniprogram_npm/vant-weapp/field/index.d.ts
  99. 105 0
      miniprogram_npm/vant-weapp/field/index.js
  100. 0 0
      miniprogram_npm/vant-weapp/field/index.json

+ 38 - 7
app.json

@@ -1,14 +1,45 @@
 {
-  "pages":[
+  "pages": [
     "pages/index/index",
     "pages/logs/logs"
   ],
-  "window":{
-    "backgroundTextStyle":"light",
+  "usingComponents": {
+    "van-button": "/miniprogram_npm/vant-weapp/button/index",
+    "van-row": "/miniprogram_npm/vant-weapp/row/index",
+    "van-col": "/miniprogram_npm/vant-weapp/col/index",
+    "van-datetime-picker": "/miniprogram_npm/vant-weapp/datetime-picker/index",
+    "van-picker": "/miniprogram_npm/vant-weapp/picker/index",
+    "van-popup": "/miniprogram_npm/vant-weapp/popup/index",
+    "van-radio": "/miniprogram_npm/vant-weapp/radio/index",
+    "van-radio-group": "/miniprogram_npm/vant-weapp/radio-group/index",
+    "van-action-sheet": "/miniprogram_npm/vant-weapp/action-sheet/index",
+    "van-search": "/miniprogram_npm/vant-weapp/search/index",
+    "van-tree-select": "/miniprogram_npm/vant-weapp/tree-select/index",
+    "van-overlay": "/miniprogram_npm/vant-weapp/overlay/index",
+    "van-dialog": "/miniprogram_npm/vant-weapp/dialog/index",
+    "van-tab": "/miniprogram_npm/vant-weapp/tab/index",
+    "van-tabs": "/miniprogram_npm/vant-weapp/tabs/index",
+    "van-stepper": "/miniprogram_npm/vant-weapp/stepper/index",
+    "van-collapse": "/miniprogram_npm/vant-weapp/collapse/index",
+    "van-collapse-item": "/miniprogram_npm/vant-weapp/collapse-item/index",
+    "van-cell": "/miniprogram_npm/vant-weapp/cell/index",
+    "van-cell-group": "/miniprogram_npm/vant-weapp/cell-group/index",
+    "van-toast": "/miniprogram_npm/vant-weapp/toast/index",
+    "van-field": "/miniprogram_npm/vant-weapp/field/index",
+    "van-checkbox": "/miniprogram_npm/vant-weapp/checkbox/index",
+    "van-checkbox-group": "/miniprogram_npm/vant-weapp/checkbox-group/index",
+    "van-loading": "/miniprogram_npm/vant-weapp/loading/index",
+    "van-icon": "/miniprogram_npm/vant-weapp/icon/index",
+    "van-nav-bar": "/miniprogram_npm/vant-weapp/nav-bar/index",
+    "van-tabbar": "/miniprogram_npm/vant-weapp/tabbar/index",
+    "van-tabbar-item": "/miniprogram_npm/vant-weapp/tabbar-item/index",
+    "van-rate": "/miniprogram_npm/vant-weapp/rate/index"
+  },
+  "window": {
+    "backgroundTextStyle": "light",
     "navigationBarBackgroundColor": "#fff",
-    "navigationBarTitleText": "Weixin",
-    "navigationBarTextStyle":"black"
+    "navigationBarTitleText": "智慧食堂",
+    "navigationBarTextStyle": "black"
   },
-  "style": "v2",
   "sitemapLocation": "sitemap.json"
-}
+}

+ 7 - 1
app.wxss

@@ -7,4 +7,10 @@
   justify-content: space-between;
   padding: 200rpx 0;
   box-sizing: border-box;
-} 
+}
+
+.textOver {
+  overflow: hidden;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+}

+ 1 - 0
miniprogram_npm/vant-weapp/action-sheet/index.d.ts

@@ -0,0 +1 @@
+export {};

+ 43 - 0
miniprogram_npm/vant-weapp/action-sheet/index.js

@@ -0,0 +1,43 @@
+import { VantComponent } from '../common/component';
+import { safeArea } from '../mixins/safe-area';
+VantComponent({
+    mixins: [safeArea()],
+    props: {
+        show: Boolean,
+        title: String,
+        cancelText: String,
+        customStyle: String,
+        overlayStyle: String,
+        zIndex: {
+            type: Number,
+            value: 100
+        },
+        actions: {
+            type: Array,
+            value: []
+        },
+        overlay: {
+            type: Boolean,
+            value: true
+        },
+        closeOnClickOverlay: {
+            type: Boolean,
+            value: true
+        }
+    },
+    methods: {
+        onSelect(event) {
+            const { index } = event.currentTarget.dataset;
+            const item = this.data.actions[index];
+            if (item && !item.disabled && !item.loading) {
+                this.$emit('select', item);
+            }
+        },
+        onCancel() {
+            this.$emit('cancel');
+        },
+        onClose() {
+            this.$emit('close');
+        }
+    }
+});

+ 8 - 0
miniprogram_npm/vant-weapp/action-sheet/index.json

@@ -0,0 +1,8 @@
+{
+  "component": true,
+  "usingComponents": {
+    "van-icon": "../icon/index",
+    "van-popup": "../popup/index",
+    "van-loading": "../loading/index"
+  }
+}

+ 51 - 0
miniprogram_npm/vant-weapp/action-sheet/index.wxml

@@ -0,0 +1,51 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+
+<van-popup
+  show="{{ show }}"
+  position="bottom"
+  z-index="{{ zIndex }}"
+  overlay="{{ overlay }}"
+  custom-style="{{ customStyle }}"
+  overlay-style="{{ overlayStyle }}"
+  custom-class="van-action-sheet"
+  safe-area-inset-bottom="{{ safeAreaInsetBottom }}"
+  close-on-click-overlay="{{ closeOnClickOverlay }}"
+  bind:close="onClose"
+>
+  <view wx:if="{{ title }}" class="van-hairline--bottom van-action-sheet__header">
+    {{ title }}
+    <van-icon
+      name="close"
+      custom-class="van-action-sheet__close"
+      bind:click="onClose"
+    />
+  </view>
+  <view wx:if="{{ actions && actions.length }}">
+    <!-- button外包一层view,防止actions动态变化,导致渲染时button被打散 -->
+    <button
+      wx:for="{{ actions }}"
+      wx:key="index"
+      open-type="{{ item.openType }}"
+      class="{{ utils.bem('action-sheet__item', { disabled: item.disabled || item.loading }) }} van-hairline--top {{ item.className || '' }}"
+      hover-class="van-action-sheet__item--hover"
+      data-index="{{ index }}"
+      bind:tap="onSelect"
+    >
+      <block wx:if="{{ !item.loading }}">
+        {{ item.name }}
+        <text wx:if="{{ item.subname }}" class="van-action-sheet__subname" >{{ item.subname }}</text>
+      </block>
+      <van-loading wx:else size="20px" />
+    </button>
+  </view>
+  <slot />
+  <view
+    wx:if="{{ cancelText }}"
+    class="van-action-sheet__cancel"
+    hover-class="van-action-sheet__cancel--hover"
+    hover-stay-time="70"
+    bind:tap="onCancel"
+  >
+    {{ cancelText }}
+  </view>
+</van-popup>

File diff ditekan karena terlalu besar
+ 1 - 0
miniprogram_npm/vant-weapp/action-sheet/index.wxss


+ 1 - 0
miniprogram_npm/vant-weapp/area/index.d.ts

@@ -0,0 +1 @@
+export {};

+ 212 - 0
miniprogram_npm/vant-weapp/area/index.js

@@ -0,0 +1,212 @@
+import { VantComponent } from '../common/component';
+import { pickerProps } from '../picker/shared';
+const COLUMNSPLACEHOLDERCODE = '000000';
+VantComponent({
+    classes: ['active-class', 'toolbar-class', 'column-class'],
+    props: Object.assign({}, pickerProps, { value: String, areaList: {
+            type: Object,
+            value: {}
+        }, columnsNum: {
+            type: [String, Number],
+            value: 3
+        }, columnsPlaceholder: {
+            type: Array,
+            observer(val) {
+                this.setData({
+                    typeToColumnsPlaceholder: {
+                        province: val[0] || '',
+                        city: val[1] || '',
+                        county: val[2] || '',
+                    }
+                });
+            }
+        } }),
+    data: {
+        columns: [{ values: [] }, { values: [] }, { values: [] }],
+        displayColumns: [{ values: [] }, { values: [] }, { values: [] }],
+        typeToColumnsPlaceholder: {}
+    },
+    watch: {
+        value(value) {
+            this.code = value;
+            this.setValues();
+        },
+        areaList: 'setValues',
+        columnsNum(value) {
+            this.set({
+                displayColumns: this.data.columns.slice(0, +value)
+            });
+        }
+    },
+    mounted() {
+        setTimeout(() => {
+            this.setValues();
+        }, 0);
+    },
+    methods: {
+        getPicker() {
+            if (this.picker == null) {
+                this.picker = this.selectComponent('.van-area__picker');
+            }
+            return this.picker;
+        },
+        onCancel(event) {
+            this.emit('cancel', event.detail);
+        },
+        onConfirm(event) {
+            const { index } = event.detail;
+            let { value } = event.detail;
+            value = this.parseOutputValues(value);
+            this.emit('confirm', { value, index });
+        },
+        emit(type, detail) {
+            detail.values = detail.value;
+            delete detail.value;
+            this.$emit(type, detail);
+        },
+        // parse output columns data
+        parseOutputValues(values) {
+            const { columnsPlaceholder } = this.data;
+            return values.map((value, index) => {
+                // save undefined value
+                if (!value)
+                    return value;
+                value = JSON.parse(JSON.stringify(value));
+                if (!value.code || value.name === columnsPlaceholder[index]) {
+                    value.code = '';
+                    value.name = '';
+                }
+                return value;
+            });
+        },
+        onChange(event) {
+            const { index, picker, value } = event.detail;
+            this.code = value[index].code;
+            let getValues = picker.getValues();
+            getValues = this.parseOutputValues(getValues);
+            this.setValues().then(() => {
+                this.$emit('change', {
+                    picker,
+                    values: getValues,
+                    index
+                });
+            });
+        },
+        getConfig(type) {
+            const { areaList } = this.data;
+            return (areaList && areaList[`${type}_list`]) || {};
+        },
+        getList(type, code) {
+            const { typeToColumnsPlaceholder } = this.data;
+            let result = [];
+            if (type !== 'province' && !code) {
+                return result;
+            }
+            const list = this.getConfig(type);
+            result = Object.keys(list).map(code => ({
+                code,
+                name: list[code]
+            }));
+            if (code) {
+                // oversea code
+                if (code[0] === '9' && type === 'city') {
+                    code = '9';
+                }
+                result = result.filter(item => item.code.indexOf(code) === 0);
+            }
+            if (typeToColumnsPlaceholder[type] && result.length) {
+                // set columns placeholder
+                const codeFill = type === 'province' ? '' : type === 'city' ? COLUMNSPLACEHOLDERCODE.slice(2, 4) : COLUMNSPLACEHOLDERCODE.slice(4, 6);
+                result.unshift({
+                    code: `${code}${codeFill}`,
+                    name: typeToColumnsPlaceholder[type]
+                });
+            }
+            return result;
+        },
+        getIndex(type, code) {
+            let compareNum = type === 'province' ? 2 : type === 'city' ? 4 : 6;
+            const list = this.getList(type, code.slice(0, compareNum - 2));
+            // oversea code
+            if (code[0] === '9' && type === 'province') {
+                compareNum = 1;
+            }
+            code = code.slice(0, compareNum);
+            for (let i = 0; i < list.length; i++) {
+                if (list[i].code.slice(0, compareNum) === code) {
+                    return i;
+                }
+            }
+            return 0;
+        },
+        setValues() {
+            const county = this.getConfig('county');
+            let { code } = this;
+            if (!code) {
+                if (this.data.columnsPlaceholder.length) {
+                    code = COLUMNSPLACEHOLDERCODE;
+                }
+                else if (Object.keys(county)[0]) {
+                    code = Object.keys(county)[0];
+                }
+                else {
+                    code = '';
+                }
+            }
+            const province = this.getList('province');
+            const city = this.getList('city', code.slice(0, 2));
+            const picker = this.getPicker();
+            if (!picker) {
+                return;
+            }
+            const stack = [];
+            stack.push(picker.setColumnValues(0, province, false));
+            stack.push(picker.setColumnValues(1, city, false));
+            if (city.length && code.slice(2, 4) === '00') {
+                [{ code }] = city;
+            }
+            stack.push(picker.setColumnValues(2, this.getList('county', code.slice(0, 4)), false));
+            return Promise.all(stack)
+                .catch(() => { })
+                .then(() => picker.setIndexes([
+                this.getIndex('province', code),
+                this.getIndex('city', code),
+                this.getIndex('county', code)
+            ]))
+                .catch(() => { });
+        },
+        getValues() {
+            const picker = this.getPicker();
+            return picker ? picker.getValues().filter(value => !!value) : [];
+        },
+        getDetail() {
+            const values = this.getValues();
+            const area = {
+                code: '',
+                country: '',
+                province: '',
+                city: '',
+                county: ''
+            };
+            if (!values.length) {
+                return area;
+            }
+            const names = values.map((item) => item.name);
+            area.code = values[values.length - 1].code;
+            if (area.code[0] === '9') {
+                area.country = names[1] || '';
+                area.province = names[2] || '';
+            }
+            else {
+                area.province = names[0] || '';
+                area.city = names[1] || '';
+                area.county = names[2] || '';
+            }
+            return area;
+        },
+        reset() {
+            this.code = '';
+            return this.setValues();
+        }
+    }
+});

+ 6 - 0
miniprogram_npm/vant-weapp/area/index.json

@@ -0,0 +1,6 @@
+{
+  "component": true,
+  "usingComponents": {
+    "van-picker": "../picker/index"
+  }
+}

+ 18 - 0
miniprogram_npm/vant-weapp/area/index.wxml

@@ -0,0 +1,18 @@
+<van-picker
+  class="van-area__picker"
+  active-class="active-class"
+  toolbar-class="toolbar-class"
+  column-class="column-class"
+  show-toolbar
+  value-key="name"
+  title="{{ title }}"
+  loading="{{ loading }}"
+  columns="{{ displayColumns }}"
+  item-height="{{ itemHeight }}"
+  visible-item-count="{{ visibleItemCount }}"
+  cancel-button-text="{{ cancelButtonText }}"
+  confirm-button-text="{{ confirmButtonText }}"
+  bind:change="onChange"
+  bind:confirm="onConfirm"
+  bind:cancel="onCancel"
+/>

+ 1 - 0
miniprogram_npm/vant-weapp/area/index.wxss

@@ -0,0 +1 @@
+@import '../common/index.wxss';

+ 1 - 0
miniprogram_npm/vant-weapp/badge-group/index.d.ts

@@ -0,0 +1 @@
+export {};

+ 43 - 0
miniprogram_npm/vant-weapp/badge-group/index.js

@@ -0,0 +1,43 @@
+import { VantComponent } from '../common/component';
+VantComponent({
+    relation: {
+        name: 'badge',
+        type: 'descendant',
+        linked(target) {
+            this.badges.push(target);
+            this.setActive(this.data.active);
+        },
+        unlinked(target) {
+            this.badges = this.badges.filter(item => item !== target);
+            this.setActive(this.data.active);
+        }
+    },
+    props: {
+        active: {
+            type: Number,
+            value: 0,
+            observer: 'setActive'
+        }
+    },
+    beforeCreate() {
+        this.badges = [];
+        this.currentActive = -1;
+    },
+    methods: {
+        setActive(active) {
+            const { badges, currentActive } = this;
+            if (!badges.length) {
+                return Promise.resolve();
+            }
+            this.currentActive = active;
+            const stack = [];
+            if (currentActive !== active && badges[currentActive]) {
+                stack.push(badges[currentActive].setActive(false));
+            }
+            if (badges[active]) {
+                stack.push(badges[active].setActive(true));
+            }
+            return Promise.all(stack);
+        }
+    }
+});

+ 3 - 0
miniprogram_npm/vant-weapp/badge-group/index.json

@@ -0,0 +1,3 @@
+{
+  "component": true
+}

+ 3 - 0
miniprogram_npm/vant-weapp/badge-group/index.wxml

@@ -0,0 +1,3 @@
+<view class="van-badge-group van-hairline--top-bottom custom-class">
+  <slot />
+</view>

+ 1 - 0
miniprogram_npm/vant-weapp/badge-group/index.wxss

@@ -0,0 +1 @@
+@import '../common/index.wxss';.van-badge-group{width:85px}

+ 1 - 0
miniprogram_npm/vant-weapp/badge/index.d.ts

@@ -0,0 +1 @@
+export {};

+ 30 - 0
miniprogram_npm/vant-weapp/badge/index.js

@@ -0,0 +1,30 @@
+import { VantComponent } from '../common/component';
+VantComponent({
+    relation: {
+        type: 'ancestor',
+        name: 'badge-group',
+        linked(target) {
+            this.parent = target;
+        }
+    },
+    props: {
+        info: null,
+        title: String
+    },
+    methods: {
+        onClick() {
+            const { parent } = this;
+            if (!parent) {
+                return;
+            }
+            const index = parent.badges.indexOf(this);
+            parent.setActive(index).then(() => {
+                this.$emit('click', index);
+                parent.$emit('change', index);
+            });
+        },
+        setActive(active) {
+            return this.set({ active });
+        }
+    }
+});

+ 6 - 0
miniprogram_npm/vant-weapp/badge/index.json

@@ -0,0 +1,6 @@
+{
+  "component": true,
+  "usingComponents": {
+    "van-info": "../info/index"
+  }
+}

+ 17 - 0
miniprogram_npm/vant-weapp/badge/index.wxml

@@ -0,0 +1,17 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+
+<view
+  class="{{ utils.bem('badge', { active }) }} van-hairline custom-class"
+  hover-class="van-badge--hover"
+  hover-stay-time="70"
+  bind:tap="onClick"
+>
+  <view class="van-badge__text">
+    <van-info
+      wx:if="{{ info !== null }}"
+      info="{{ info }}"
+      custom-style="right: 4px"
+    />
+    {{ title }}
+  </view>
+</view>

File diff ditekan karena terlalu besar
+ 1 - 0
miniprogram_npm/vant-weapp/badge/index.wxss


+ 1 - 0
miniprogram_npm/vant-weapp/button/index.d.ts

@@ -0,0 +1 @@
+export {};

+ 38 - 0
miniprogram_npm/vant-weapp/button/index.js

@@ -0,0 +1,38 @@
+import { VantComponent } from '../common/component';
+import { button } from '../mixins/button';
+import { openType } from '../mixins/open-type';
+VantComponent({
+    mixins: [button, openType],
+    classes: ['hover-class', 'loading-class'],
+    props: {
+        icon: String,
+        color: String,
+        plain: Boolean,
+        block: Boolean,
+        round: Boolean,
+        square: Boolean,
+        loading: Boolean,
+        hairline: Boolean,
+        disabled: Boolean,
+        loadingText: String,
+        type: {
+            type: String,
+            value: 'default'
+        },
+        size: {
+            type: String,
+            value: 'normal'
+        },
+        loadingSize: {
+            type: String,
+            value: '20px'
+        }
+    },
+    methods: {
+        onClick() {
+            if (!this.data.disabled && !this.data.loading) {
+                this.$emit('click');
+            }
+        }
+    }
+});

+ 7 - 0
miniprogram_npm/vant-weapp/button/index.json

@@ -0,0 +1,7 @@
+{
+  "component": true,
+  "usingComponents": {
+    "van-icon": "../icon/index",
+    "van-loading": "../loading/index"
+  }
+}

+ 51 - 0
miniprogram_npm/vant-weapp/button/index.wxml

@@ -0,0 +1,51 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+
+<button
+  id="{{ id }}"
+  class="custom-class {{ utils.bem('button', [type, size, { block, round, plain, square, loading, disabled, hairline, unclickable: disabled || loading }]) }} {{ hairline ? 'van-hairline--surround' : '' }}"
+  open-type="{{ openType }}"
+  hover-class="van-button--active hover-class"
+  style="{{ color ? 'border-color: ' + color + ';' + (plain ? 'color: ' + color : 'color: #fff; background-color: ' + color) : '' }}"
+  lang="{{ lang }}"
+  business-id="{{ businessId }}"
+  session-from="{{ sessionFrom }}"
+  send-message-title="{{ sendMessageTitle }}"
+  send-message-path="{{ sendMessagePath }}"
+  send-message-img="{{ sendMessageImg }}"
+  show-message-card="{{ showMessageCard }}"
+  app-parameter="{{ appParameter }}"
+  aria-label="{{ ariaLabel }}"
+  bindtap="onClick"
+  bindgetuserinfo="bindGetUserInfo"
+  bindcontact="bindContact"
+  bindgetphonenumber="bindGetPhoneNumber"
+  binderror="bindError"
+  bindlaunchapp="bindLaunchApp"
+  bindopensetting="bindOpenSetting"
+>
+  <block wx:if="{{ loading }}">
+    <van-loading
+      custom-class="loading-class"
+      size="{{ loadingSize }}"
+      color="{{ type === 'default' ? '#c9c9c9' : '' }}"
+    />
+    <view
+      wx:if="{{ loadingText }}"
+      class="van-button__loading-text"
+    >
+      {{ loadingText }}
+    </view>
+  </block>
+  <block wx:else>
+    <van-icon
+      wx:if="{{ icon }}"
+      size="1.2em"
+      name="{{ icon }}"
+      class="van-button__icon"
+      custom-style="line-height: inherit;"
+    />
+    <view class="van-button__text">
+      <slot />
+    </view>
+  </block>
+</button>

File diff ditekan karena terlalu besar
+ 1 - 0
miniprogram_npm/vant-weapp/button/index.wxss


+ 1 - 0
miniprogram_npm/vant-weapp/card/index.d.ts

@@ -0,0 +1 @@
+export {};

+ 38 - 0
miniprogram_npm/vant-weapp/card/index.js

@@ -0,0 +1,38 @@
+import { link } from '../mixins/link';
+import { VantComponent } from '../common/component';
+VantComponent({
+    classes: [
+        'num-class',
+        'desc-class',
+        'thumb-class',
+        'title-class',
+        'price-class',
+        'origin-price-class',
+    ],
+    mixins: [link],
+    props: {
+        tag: String,
+        num: String,
+        desc: String,
+        thumb: String,
+        title: String,
+        price: String,
+        centered: Boolean,
+        lazyLoad: Boolean,
+        thumbLink: String,
+        originPrice: String,
+        thumbMode: {
+            type: String,
+            value: 'aspectFit'
+        },
+        currency: {
+            type: String,
+            value: '¥'
+        }
+    },
+    methods: {
+        onClickThumb() {
+            this.jumpLink('thumbLink');
+        }
+    }
+});

+ 6 - 0
miniprogram_npm/vant-weapp/card/index.json

@@ -0,0 +1,6 @@
+{
+  "component": true,
+  "usingComponents": {
+    "van-tag": "../tag/index"
+  }
+}

+ 45 - 0
miniprogram_npm/vant-weapp/card/index.wxml

@@ -0,0 +1,45 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+
+<view class="custom-class van-card">
+  <view class="{{ utils.bem('card__header', { center: centered }) }}">
+    <view class="van-card__thumb" bind:tap="onClickThumb">
+      <image
+        wx:if="{{ thumb }}"
+        src="{{ thumb }}"
+        mode="{{ thumbMode }}"
+        lazy-load="{{ lazyLoad }}"
+        class="van-card__img thumb-class"
+      />
+      <slot name="thumb" />
+      <van-tag
+        wx:if="{{ tag }}"
+        mark
+        type="danger"
+        custom-class="van-card__tag"
+      >
+        {{ tag }}
+      </van-tag>
+    </view>
+
+    <view class="van-card__content">
+      <view wx:if="{{ title }}" class="van-card__title title-class">{{ title }}</view>
+      <slot wx:else name="title" />
+
+      <view wx:if="{{ desc }}" class="van-card__desc desc-class">{{ desc }}</view>
+      <slot wx:else name="desc" />
+
+      <slot name="tags" />
+
+      <view class="van-card__bottom">
+        <view wx:if="{{ price || price === 0 }}" class="van-card__price price-class">{{ currency }} {{ price }}</view>
+        <view wx:if="{{ originPrice || originPrice === 0 }}" class="van-card__origin-price origin-price-class">{{ currency }} {{ originPrice }}</view>
+        <view wx:if="{{ num }}" class="van-card__num num-class">x {{ num }}</view>
+        <slot name="bottom" />
+      </view>
+    </view>
+  </view>
+
+  <view class="van-card__footer">
+    <slot name="footer" />
+  </view>
+</view>

File diff ditekan karena terlalu besar
+ 1 - 0
miniprogram_npm/vant-weapp/card/index.wxss


+ 1 - 0
miniprogram_npm/vant-weapp/cell-group/index.d.ts

@@ -0,0 +1 @@
+export {};

+ 10 - 0
miniprogram_npm/vant-weapp/cell-group/index.js

@@ -0,0 +1,10 @@
+import { VantComponent } from '../common/component';
+VantComponent({
+    props: {
+        title: String,
+        border: {
+            type: Boolean,
+            value: true
+        }
+    }
+});

+ 3 - 0
miniprogram_npm/vant-weapp/cell-group/index.json

@@ -0,0 +1,3 @@
+{
+  "component": true
+}

+ 9 - 0
miniprogram_npm/vant-weapp/cell-group/index.wxml

@@ -0,0 +1,9 @@
+<view
+  wx:if="{{ title }}"
+  class="van-cell-group__title"
+>
+  {{ title }}
+</view>
+<view class="custom-class van-cell-group {{ border ? 'van-hairline--top-bottom' : '' }}">
+  <slot />
+</view>

+ 1 - 0
miniprogram_npm/vant-weapp/cell-group/index.wxss

@@ -0,0 +1 @@
+@import '../common/index.wxss';.van-cell-group__title{font-size:14px;padding:15px 15px 5px;color:#999;line-height:16px}

+ 1 - 0
miniprogram_npm/vant-weapp/cell/index.d.ts

@@ -0,0 +1 @@
+export {};

+ 37 - 0
miniprogram_npm/vant-weapp/cell/index.js

@@ -0,0 +1,37 @@
+import { link } from '../mixins/link';
+import { VantComponent } from '../common/component';
+VantComponent({
+    classes: [
+        'title-class',
+        'label-class',
+        'value-class',
+        'right-icon-class',
+        'hover-class'
+    ],
+    mixins: [link],
+    props: {
+        title: null,
+        value: null,
+        icon: String,
+        size: String,
+        label: String,
+        center: Boolean,
+        isLink: Boolean,
+        required: Boolean,
+        clickable: Boolean,
+        titleWidth: String,
+        customStyle: String,
+        arrowDirection: String,
+        useLabelSlot: Boolean,
+        border: {
+            type: Boolean,
+            value: true
+        }
+    },
+    methods: {
+        onClick(event) {
+            this.$emit('click', event.detail);
+            this.jumpLink();
+        }
+    }
+});

+ 6 - 0
miniprogram_npm/vant-weapp/cell/index.json

@@ -0,0 +1,6 @@
+{
+  "component": true,
+  "usingComponents": {
+    "van-icon": "../icon/index"
+  }
+}

+ 45 - 0
miniprogram_npm/vant-weapp/cell/index.wxml

@@ -0,0 +1,45 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+
+<view
+  class="custom-class {{ utils.bem('cell', [size, { center, required, borderless: !border, clickable: isLink || clickable }]) }}"
+  hover-class="van-cell--hover hover-class"
+  hover-stay-time="70"
+  style="{{ customStyle }}"
+  bind:tap="onClick"
+>
+  <van-icon
+    wx:if="{{ icon }}"
+    name="{{ icon }}"
+    class="van-cell__left-icon-wrap"
+    custom-class="van-cell__left-icon"
+  />
+  <slot wx:else name="icon" />
+
+  <view
+    style="{{ titleWidth ? 'max-width:' + titleWidth + ';min-width:' + titleWidth : '' }}"
+    class="van-cell__title title-class"
+  >
+    <block wx:if="{{ title }}">{{ title }}</block>
+    <slot wx:else name="title" />
+
+    <view wx:if="{{ label || useLabelSlot }}" class="van-cell__label label-class">
+      <slot wx:if="{{ useLabelSlot }}" name="label" />
+      <block wx:elif="{{ label }}">{{ label }}</block>
+    </view>
+  </view>
+
+  <view class="van-cell__value value-class">
+    <block wx:if="{{ value || value === 0 }}">{{ value }}</block>
+    <slot wx:else />
+  </view>
+
+  <van-icon
+    wx:if="{{ isLink }}"
+    name="{{ arrowDirection ? 'arrow' + '-' + arrowDirection : 'arrow' }}"
+    class="van-cell__right-icon-wrap right-icon-class"
+    custom-class="van-cell__right-icon"
+  />
+  <slot wx:else name="right-icon" />
+
+  <slot name="extra" />
+</view>

File diff ditekan karena terlalu besar
+ 1 - 0
miniprogram_npm/vant-weapp/cell/index.wxss


+ 1 - 0
miniprogram_npm/vant-weapp/checkbox-group/index.d.ts

@@ -0,0 +1 @@
+export {};

+ 39 - 0
miniprogram_npm/vant-weapp/checkbox-group/index.js

@@ -0,0 +1,39 @@
+import { VantComponent } from '../common/component';
+VantComponent({
+    field: true,
+    relation: {
+        name: 'checkbox',
+        type: 'descendant',
+        linked(target) {
+            this.children = this.children || [];
+            this.children.push(target);
+            this.updateChild(target);
+        },
+        unlinked(target) {
+            this.children = this.children.filter((child) => child !== target);
+        }
+    },
+    props: {
+        max: Number,
+        value: {
+            type: Array,
+            observer: 'updateChildren'
+        },
+        disabled: {
+            type: Boolean,
+            observer: 'updateChildren'
+        }
+    },
+    methods: {
+        updateChildren() {
+            (this.children || []).forEach((child) => this.updateChild(child));
+        },
+        updateChild(child) {
+            const { value, disabled } = this.data;
+            child.set({
+                value: value.indexOf(child.data.name) !== -1,
+                disabled: disabled || child.data.disabled
+            });
+        }
+    }
+});

+ 3 - 0
miniprogram_npm/vant-weapp/checkbox-group/index.json

@@ -0,0 +1,3 @@
+{
+  "component": true
+}

+ 1 - 0
miniprogram_npm/vant-weapp/checkbox-group/index.wxml

@@ -0,0 +1 @@
+<slot />

+ 1 - 0
miniprogram_npm/vant-weapp/checkbox-group/index.wxss

@@ -0,0 +1 @@
+@import '../common/index.wxss';

+ 1 - 0
miniprogram_npm/vant-weapp/checkbox/index.d.ts

@@ -0,0 +1 @@
+export {};

+ 74 - 0
miniprogram_npm/vant-weapp/checkbox/index.js

@@ -0,0 +1,74 @@
+import { VantComponent } from '../common/component';
+function emit(target, value) {
+    target.$emit('input', value);
+    target.$emit('change', value);
+}
+VantComponent({
+    field: true,
+    relation: {
+        name: 'checkbox-group',
+        type: 'ancestor',
+        linked(target) {
+            this.parent = target;
+        },
+        unlinked() {
+            this.parent = null;
+        }
+    },
+    classes: ['icon-class', 'label-class'],
+    props: {
+        value: Boolean,
+        disabled: Boolean,
+        useIconSlot: Boolean,
+        checkedColor: String,
+        labelPosition: String,
+        labelDisabled: Boolean,
+        shape: {
+            type: String,
+            value: 'round'
+        }
+    },
+    methods: {
+        emitChange(value) {
+            if (this.parent) {
+                this.setParentValue(this.parent, value);
+            }
+            else {
+                emit(this, value);
+            }
+        },
+        toggle() {
+            const { disabled, value } = this.data;
+            if (!disabled) {
+                this.emitChange(!value);
+            }
+        },
+        onClickLabel() {
+            const { labelDisabled, disabled, value } = this.data;
+            if (!disabled && !labelDisabled) {
+                this.emitChange(!value);
+            }
+        },
+        setParentValue(parent, value) {
+            const parentValue = parent.data.value.slice();
+            const { name } = this.data;
+            const { max } = parent.data;
+            if (value) {
+                if (max && parentValue.length >= max) {
+                    return;
+                }
+                if (parentValue.indexOf(name) === -1) {
+                    parentValue.push(name);
+                    emit(parent, parentValue);
+                }
+            }
+            else {
+                const index = parentValue.indexOf(name);
+                if (index !== -1) {
+                    parentValue.splice(index, 1);
+                    emit(parent, parentValue);
+                }
+            }
+        }
+    }
+});

+ 6 - 0
miniprogram_npm/vant-weapp/checkbox/index.json

@@ -0,0 +1,6 @@
+{
+  "component": true,
+  "usingComponents": {
+    "van-icon": "../icon/index"
+  }
+}

+ 18 - 0
miniprogram_npm/vant-weapp/checkbox/index.wxml

@@ -0,0 +1,18 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+
+<view class="van-checkbox custom-class">
+  <view class="van-checkbox__icon-wrap" bindtap="toggle">
+    <slot wx:if="{{ useIconSlot }}" name="icon" />
+    <van-icon
+      wx:else
+      name="success"
+      class="{{ utils.bem('checkbox__icon', [shape, { disabled, checked: value }]) }}"
+      style="{{ checkedColor && value && !disabled ? 'border-color:' + checkedColor + '; background-color:' + checkedColor : '' }}"
+      custom-class="icon-class"
+      custom-style="line-height: 20px;"
+    />
+  </view>
+  <view class="label-class {{ utils.bem('checkbox__label', [labelPosition, { disabled }]) }}" bindtap="onClickLabel">
+    <slot />
+  </view>
+</view>

File diff ditekan karena terlalu besar
+ 1 - 0
miniprogram_npm/vant-weapp/checkbox/index.wxss


+ 1 - 0
miniprogram_npm/vant-weapp/col/index.d.ts

@@ -0,0 +1 @@
+export {};

+ 23 - 0
miniprogram_npm/vant-weapp/col/index.js

@@ -0,0 +1,23 @@
+import { VantComponent } from '../common/component';
+VantComponent({
+    relation: {
+        name: 'row',
+        type: 'ancestor'
+    },
+    props: {
+        span: Number,
+        offset: Number
+    },
+    data: {
+        style: ''
+    },
+    methods: {
+        setGutter(gutter) {
+            const padding = `${gutter / 2}px`;
+            const style = gutter ? `padding-left: ${padding}; padding-right: ${padding};` : '';
+            if (style !== this.data.style) {
+                this.set({ style });
+            }
+        }
+    }
+});

+ 3 - 0
miniprogram_npm/vant-weapp/col/index.json

@@ -0,0 +1,3 @@
+{
+  "component": true
+}

+ 8 - 0
miniprogram_npm/vant-weapp/col/index.wxml

@@ -0,0 +1,8 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+
+<view
+  class="custom-class {{ utils.bem('col', [span]) }} {{ offset ? 'van-col--offset-' + offset : '' }}"
+  style="{{ style }}"
+>
+  <slot />
+</view>

File diff ditekan karena terlalu besar
+ 1 - 0
miniprogram_npm/vant-weapp/col/index.wxss


+ 1 - 0
miniprogram_npm/vant-weapp/collapse-item/index.d.ts

@@ -0,0 +1 @@
+export {};

+ 96 - 0
miniprogram_npm/vant-weapp/collapse-item/index.js

@@ -0,0 +1,96 @@
+import { VantComponent } from '../common/component';
+const nextTick = () => new Promise(resolve => setTimeout(resolve, 20));
+VantComponent({
+    classes: ['title-class', 'content-class'],
+    relation: {
+        name: 'collapse',
+        type: 'ancestor',
+        linked(parent) {
+            this.parent = parent;
+        }
+    },
+    props: {
+        name: null,
+        title: null,
+        value: null,
+        icon: String,
+        label: String,
+        disabled: Boolean,
+        clickable: Boolean,
+        border: {
+            type: Boolean,
+            value: true
+        },
+        isLink: {
+            type: Boolean,
+            value: true
+        }
+    },
+    data: {
+        contentHeight: 0,
+        expanded: false,
+        transition: false
+    },
+    mounted() {
+        this.updateExpanded()
+            .then(nextTick)
+            .then(() => {
+            const data = { transition: true };
+            if (this.data.expanded) {
+                data.contentHeight = 'auto';
+            }
+            this.set(data);
+        });
+    },
+    methods: {
+        updateExpanded() {
+            if (!this.parent) {
+                return Promise.resolve();
+            }
+            const { value, accordion } = this.parent.data;
+            const { children = [] } = this.parent;
+            const { name } = this.data;
+            const index = children.indexOf(this);
+            const currentName = name == null ? index : name;
+            const expanded = accordion
+                ? value === currentName
+                : (value || []).some((name) => name === currentName);
+            const stack = [];
+            if (expanded !== this.data.expanded) {
+                stack.push(this.updateStyle(expanded));
+            }
+            stack.push(this.set({ index, expanded }));
+            return Promise.all(stack);
+        },
+        updateStyle(expanded) {
+            return this.getRect('.van-collapse-item__content')
+                .then((rect) => rect.height)
+                .then((height) => {
+                if (expanded) {
+                    return this.set({
+                        contentHeight: height ? `${height}px` : 'auto'
+                    });
+                }
+                return this.set({ contentHeight: `${height}px` })
+                    .then(nextTick)
+                    .then(() => this.set({ contentHeight: 0 }));
+            });
+        },
+        onClick() {
+            if (this.data.disabled) {
+                return;
+            }
+            const { name, expanded } = this.data;
+            const index = this.parent.children.indexOf(this);
+            const currentName = name == null ? index : name;
+            this.parent.switch(currentName, !expanded);
+        },
+        onTransitionEnd() {
+            if (this.data.expanded) {
+                this.set({
+                    contentHeight: 'auto'
+                });
+            }
+        }
+    }
+});

+ 6 - 0
miniprogram_npm/vant-weapp/collapse-item/index.json

@@ -0,0 +1,6 @@
+{
+  "component": true,
+  "usingComponents": {
+    "van-cell": "../cell/index"
+  }
+}

+ 44 - 0
miniprogram_npm/vant-weapp/collapse-item/index.wxml

@@ -0,0 +1,44 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+
+<view class="van-collapse-item custom-class {{ index !== 0 ? 'van-hairline--top' : '' }}">
+  <van-cell
+    title="{{ title }}"
+    title-class="title-class"
+    icon="{{ icon }}"
+    value="{{ value }}"
+    label="{{ label }}"
+    is-link="{{ isLink }}"
+    clickable="{{ clickable }}"
+    border="{{ border && expanded }}"
+    class="{{ utils.bem('collapse-item__title', { disabled, expanded }) }}"
+    right-icon-class="van-cell__right-icon"
+    custom-class="van-cell"
+    hover-class="van-cell--hover"
+    bind:click="onClick"
+  >
+    <slot
+      name="title"
+      slot="title"
+    />
+    <slot
+      name="icon"
+      slot="icon"
+    />
+    <slot name="value" />
+    <slot
+      name="right-icon"
+      slot="right-icon"
+    />
+  </van-cell>
+  <view
+    class="{{ utils.bem('collapse-item__wrapper', { transition }) }}"
+    style="height: {{ contentHeight }};"
+    bind:transitionend="onTransitionEnd"
+  >
+    <view
+      class="van-collapse-item__content content-class"
+    >
+      <slot />
+    </view>
+  </view>
+</view>

File diff ditekan karena terlalu besar
+ 1 - 0
miniprogram_npm/vant-weapp/collapse-item/index.wxss


+ 1 - 0
miniprogram_npm/vant-weapp/collapse/index.d.ts

@@ -0,0 +1 @@
+export {};

+ 50 - 0
miniprogram_npm/vant-weapp/collapse/index.js

@@ -0,0 +1,50 @@
+import { VantComponent } from '../common/component';
+VantComponent({
+    relation: {
+        name: 'collapse-item',
+        type: 'descendant',
+        linked(child) {
+            this.children.push(child);
+        },
+        unlinked(child) {
+            this.children = this.children.filter((item) => item !== child);
+        }
+    },
+    props: {
+        value: {
+            type: null,
+            observer: 'updateExpanded'
+        },
+        accordion: {
+            type: Boolean,
+            observer: 'updateExpanded'
+        },
+        border: {
+            type: Boolean,
+            value: true
+        }
+    },
+    beforeCreate() {
+        this.children = [];
+    },
+    methods: {
+        updateExpanded() {
+            this.children.forEach((child) => {
+                child.updateExpanded();
+            });
+        },
+        switch(name, expanded) {
+            const { accordion, value } = this.data;
+            if (!accordion) {
+                name = expanded
+                    ? (value || []).concat(name)
+                    : (value || []).filter((activeName) => activeName !== name);
+            }
+            else {
+                name = expanded ? name : '';
+            }
+            this.$emit('change', name);
+            this.$emit('input', name);
+        }
+    }
+});

+ 3 - 0
miniprogram_npm/vant-weapp/collapse/index.json

@@ -0,0 +1,3 @@
+{
+  "component": true
+}

+ 3 - 0
miniprogram_npm/vant-weapp/collapse/index.wxml

@@ -0,0 +1,3 @@
+<view class="custom-class van-collapse {{ border ? 'van-hairline--top-bottom' : '' }}">
+  <slot />
+</view>

+ 1 - 0
miniprogram_npm/vant-weapp/collapse/index.wxss

@@ -0,0 +1 @@
+@import '../common/index.wxss';

+ 4 - 0
miniprogram_npm/vant-weapp/common/color.d.ts

@@ -0,0 +1,4 @@
+export declare const RED = "#f44";
+export declare const BLUE = "#1989fa";
+export declare const GREEN = "#07c160";
+export declare const ORANGE = "#ff976a";

+ 4 - 0
miniprogram_npm/vant-weapp/common/color.js

@@ -0,0 +1,4 @@
+export const RED = '#f44';
+export const BLUE = '#1989fa';
+export const GREEN = '#07c160';
+export const ORANGE = '#ff976a';

+ 3 - 0
miniprogram_npm/vant-weapp/common/component.d.ts

@@ -0,0 +1,3 @@
+import { VantComponentOptions, CombinedComponentInstance } from '../definitions/index';
+declare function VantComponent<Data, Props, Methods, Computed>(vantOptions?: VantComponentOptions<Data, Props, Methods, Computed, CombinedComponentInstance<Data, Props, Methods, Computed>>): void;
+export { VantComponent };

+ 48 - 0
miniprogram_npm/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 };

File diff ditekan karena terlalu besar
+ 1 - 0
miniprogram_npm/vant-weapp/common/index.wxss


+ 1 - 0
miniprogram_npm/vant-weapp/common/style/clearfix.wxss

@@ -0,0 +1 @@
+.van-clearfix:after{content:"";display:table;clear:both}

+ 1 - 0
miniprogram_npm/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{overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-box-orient:vertical}.van-multi-ellipsis--l3{-webkit-line-clamp:3}

File diff ditekan karena terlalu besar
+ 1 - 0
miniprogram_npm/vant-weapp/common/style/hairline.wxss


+ 0 - 0
miniprogram_npm/vant-weapp/common/style/mixins/clearfix.wxss


+ 0 - 0
miniprogram_npm/vant-weapp/common/style/mixins/ellipsis.wxss


+ 0 - 0
miniprogram_npm/vant-weapp/common/style/mixins/hairline.wxss


+ 0 - 0
miniprogram_npm/vant-weapp/common/style/var.wxss


+ 7 - 0
miniprogram_npm/vant-weapp/common/utils.d.ts

@@ -0,0 +1,7 @@
+/// <reference types="miniprogram-api-typings" />
+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;

+ 25 - 0
miniprogram_npm/vant-weapp/common/utils.js

@@ -0,0 +1,25 @@
+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+$/.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;
+}

+ 1 - 0
miniprogram_npm/vant-weapp/datetime-picker/index.d.ts

@@ -0,0 +1 @@
+export {};

+ 287 - 0
miniprogram_npm/vant-weapp/datetime-picker/index.js

@@ -0,0 +1,287 @@
+import { VantComponent } from '../common/component';
+import { isDef } from '../common/utils';
+import { pickerProps } from '../picker/shared';
+const currentYear = new Date().getFullYear();
+function isValidDate(date) {
+    return isDef(date) && !isNaN(new Date(date).getTime());
+}
+function range(num, min, max) {
+    return Math.min(Math.max(num, min), max);
+}
+function padZero(val) {
+    return `00${val}`.slice(-2);
+}
+function times(n, iteratee) {
+    let index = -1;
+    const result = Array(n < 0 ? 0 : n);
+    while (++index < n) {
+        result[index] = iteratee(index);
+    }
+    return result;
+}
+function getTrueValue(formattedValue) {
+    if (!formattedValue)
+        return;
+    while (isNaN(parseInt(formattedValue, 10))) {
+        formattedValue = formattedValue.slice(1);
+    }
+    return parseInt(formattedValue, 10);
+}
+function getMonthEndDay(year, month) {
+    return 32 - new Date(year, month - 1, 32).getDate();
+}
+const defaultFormatter = (_, value) => value;
+VantComponent({
+    classes: ['active-class', 'toolbar-class', 'column-class'],
+    props: Object.assign({}, pickerProps, { formatter: {
+            type: Function,
+            value: defaultFormatter
+        }, value: null, type: {
+            type: String,
+            value: 'datetime'
+        }, showToolbar: {
+            type: Boolean,
+            value: true
+        }, minDate: {
+            type: Number,
+            value: new Date(currentYear - 10, 0, 1).getTime()
+        }, maxDate: {
+            type: Number,
+            value: new Date(currentYear + 10, 11, 31).getTime()
+        }, minHour: {
+            type: Number,
+            value: 0
+        }, maxHour: {
+            type: Number,
+            value: 23
+        }, minMinute: {
+            type: Number,
+            value: 0
+        }, maxMinute: {
+            type: Number,
+            value: 59
+        } }),
+    data: {
+        innerValue: Date.now(),
+        columns: []
+    },
+    watch: {
+        value: 'updateValue',
+        type: 'updateValue',
+        minDate: 'updateValue',
+        maxDate: 'updateValue',
+        minHour: 'updateValue',
+        maxHour: 'updateValue',
+        minMinute: 'updateValue',
+        maxMinute: 'updateValue'
+    },
+    methods: {
+        updateValue() {
+            const { data } = this;
+            const val = this.correctValue(this.data.value);
+            const isEqual = val === data.innerValue;
+            if (!isEqual) {
+                this.updateColumnValue(val).then(() => {
+                    this.$emit('input', val);
+                });
+            }
+            else {
+                this.updateColumns();
+            }
+        },
+        getPicker() {
+            if (this.picker == null) {
+                this.picker = this.selectComponent('.van-datetime-picker');
+                const { picker } = this;
+                const { setColumnValues } = picker;
+                picker.setColumnValues = (...args) => setColumnValues.apply(picker, [...args, false]);
+            }
+            return this.picker;
+        },
+        updateColumns() {
+            const { formatter = defaultFormatter } = this.data;
+            const results = this.getRanges().map(({ type, range }) => {
+                const values = times(range[1] - range[0] + 1, index => {
+                    let value = range[0] + index;
+                    value = type === 'year' ? `${value}` : padZero(value);
+                    return formatter(type, value);
+                });
+                return { values };
+            });
+            return this.set({ columns: results });
+        },
+        getRanges() {
+            const { data } = this;
+            if (data.type === 'time') {
+                return [
+                    {
+                        type: 'hour',
+                        range: [data.minHour, data.maxHour]
+                    },
+                    {
+                        type: 'minute',
+                        range: [data.minMinute, data.maxMinute]
+                    }
+                ];
+            }
+            const { maxYear, maxDate, maxMonth, maxHour, maxMinute } = this.getBoundary('max', data.innerValue);
+            const { minYear, minDate, minMonth, minHour, minMinute } = this.getBoundary('min', data.innerValue);
+            const result = [
+                {
+                    type: 'year',
+                    range: [minYear, maxYear]
+                },
+                {
+                    type: 'month',
+                    range: [minMonth, maxMonth]
+                },
+                {
+                    type: 'day',
+                    range: [minDate, maxDate]
+                },
+                {
+                    type: 'hour',
+                    range: [minHour, maxHour]
+                },
+                {
+                    type: 'minute',
+                    range: [minMinute, maxMinute]
+                }
+            ];
+            if (data.type === 'date')
+                result.splice(3, 2);
+            if (data.type === 'year-month')
+                result.splice(2, 3);
+            return result;
+        },
+        correctValue(value) {
+            const { data } = this;
+            // validate value
+            const isDateType = data.type !== 'time';
+            if (isDateType && !isValidDate(value)) {
+                value = data.minDate;
+            }
+            else if (!isDateType && !value) {
+                const { minHour } = data;
+                value = `${padZero(minHour)}:00`;
+            }
+            // time type
+            if (!isDateType) {
+                let [hour, minute] = value.split(':');
+                hour = padZero(range(hour, data.minHour, data.maxHour));
+                minute = padZero(range(minute, data.minMinute, data.maxMinute));
+                return `${hour}:${minute}`;
+            }
+            // date type
+            value = Math.max(value, data.minDate);
+            value = Math.min(value, data.maxDate);
+            return value;
+        },
+        getBoundary(type, innerValue) {
+            const value = new Date(innerValue);
+            const boundary = new Date(this.data[`${type}Date`]);
+            const year = boundary.getFullYear();
+            let month = 1;
+            let date = 1;
+            let hour = 0;
+            let minute = 0;
+            if (type === 'max') {
+                month = 12;
+                date = getMonthEndDay(value.getFullYear(), value.getMonth() + 1);
+                hour = 23;
+                minute = 59;
+            }
+            if (value.getFullYear() === year) {
+                month = boundary.getMonth() + 1;
+                if (value.getMonth() + 1 === month) {
+                    date = boundary.getDate();
+                    if (value.getDate() === date) {
+                        hour = boundary.getHours();
+                        if (value.getHours() === hour) {
+                            minute = boundary.getMinutes();
+                        }
+                    }
+                }
+            }
+            return {
+                [`${type}Year`]: year,
+                [`${type}Month`]: month,
+                [`${type}Date`]: date,
+                [`${type}Hour`]: hour,
+                [`${type}Minute`]: minute
+            };
+        },
+        onCancel() {
+            this.$emit('cancel');
+        },
+        onConfirm() {
+            this.$emit('confirm', this.data.innerValue);
+        },
+        onChange() {
+            const { data } = this;
+            let value;
+            const picker = this.getPicker();
+            if (data.type === 'time') {
+                const indexes = picker.getIndexes();
+                value = `${indexes[0] + data.minHour}:${indexes[1] + data.minMinute}`;
+            }
+            else {
+                const values = picker.getValues();
+                const year = getTrueValue(values[0]);
+                const month = getTrueValue(values[1]);
+                const maxDate = getMonthEndDay(year, month);
+                let date = getTrueValue(values[2]);
+                if (data.type === 'year-month') {
+                    date = 1;
+                }
+                date = date > maxDate ? maxDate : date;
+                let hour = 0;
+                let minute = 0;
+                if (data.type === 'datetime') {
+                    hour = getTrueValue(values[3]);
+                    minute = getTrueValue(values[4]);
+                }
+                value = new Date(year, month - 1, date, hour, minute);
+            }
+            value = this.correctValue(value);
+            this.updateColumnValue(value).then(() => {
+                this.$emit('input', value);
+                this.$emit('change', picker);
+            });
+        },
+        updateColumnValue(value) {
+            let values = [];
+            const { type, formatter = defaultFormatter } = this.data;
+            const picker = this.getPicker();
+            if (type === 'time') {
+                const pair = value.split(':');
+                values = [
+                    formatter('hour', pair[0]),
+                    formatter('minute', pair[1])
+                ];
+            }
+            else {
+                const date = new Date(value);
+                values = [
+                    formatter('year', `${date.getFullYear()}`),
+                    formatter('month', padZero(date.getMonth() + 1))
+                ];
+                if (type === 'date') {
+                    values.push(formatter('day', padZero(date.getDate())));
+                }
+                if (type === 'datetime') {
+                    values.push(formatter('day', padZero(date.getDate())), formatter('hour', padZero(date.getHours())), formatter('minute', padZero(date.getMinutes())));
+                }
+            }
+            return this.set({ innerValue: value })
+                .then(() => this.updateColumns())
+                .then(() => picker.setValues(values));
+        }
+    },
+    created() {
+        const innerValue = this.correctValue(this.data.value);
+        this.updateColumnValue(innerValue).then(() => {
+            this.$emit('input', innerValue);
+        });
+    }
+});

+ 6 - 0
miniprogram_npm/vant-weapp/datetime-picker/index.json

@@ -0,0 +1,6 @@
+{
+  "component": true,
+  "usingComponents": {
+    "van-picker": "../picker/index"
+  }
+}

+ 16 - 0
miniprogram_npm/vant-weapp/datetime-picker/index.wxml

@@ -0,0 +1,16 @@
+<van-picker
+  class="van-datetime-picker"
+  active-class="active-class"
+  toolbar-class="toolbar-class"
+  column-class="column-class"
+  title="{{ title }}"
+  columns="{{ columns }}"
+  item-height="{{ itemHeight }}"
+  show-toolbar="{{ showToolbar }}"
+  visible-item-count="{{ visibleItemCount }}"
+  confirm-button-text="{{ confirmButtonText }}"
+  cancel-button-text="{{ cancelButtonText }}"
+  bind:change="onChange"
+  bind:confirm="onConfirm"
+  bind:cancel="onCancel"
+/>

+ 1 - 0
miniprogram_npm/vant-weapp/datetime-picker/index.wxss

@@ -0,0 +1 @@
+@import '../common/index.wxss';

+ 32 - 0
miniprogram_npm/vant-weapp/definitions/index.d.ts

@@ -0,0 +1,32 @@
+/// <reference types="miniprogram-api-typings" />
+import { Weapp } from './weapp';
+declare type RecordToAny<T> = {
+    [K in keyof T]: any;
+};
+declare type RecordToReturn<T> = {
+    [P in keyof T]: T[P] extends (...args: any[]) => any ? ReturnType<T[P]> : T[P];
+};
+export declare type CombinedComponentInstance<Data, Props, Methods, Computed> = Methods & WechatMiniprogram.Component.TrivialInstance & Weapp.FormField & {
+    data: Data & RecordToReturn<Computed> & RecordToAny<Props>;
+};
+export interface VantComponentOptions<Data, Props, Methods, Computed, Instance> {
+    data?: Data;
+    field?: boolean;
+    classes?: string[];
+    mixins?: string[];
+    props?: Props & Weapp.PropertyOption;
+    watch?: Weapp.WatchOption<Instance>;
+    computed?: Computed & Weapp.ComputedOption<Instance>;
+    relation?: Weapp.RelationOption<Instance> & {
+        name: string;
+    };
+    relations?: {
+        [componentName: string]: Weapp.RelationOption<Instance>;
+    };
+    methods?: Methods & Weapp.MethodOption<Instance>;
+    beforeCreate?: (this: Instance) => void;
+    created?: (this: Instance) => void;
+    mounted?: (this: Instance) => void;
+    destroyed?: (this: Instance) => void;
+}
+export {};

+ 0 - 0
miniprogram_npm/vant-weapp/definitions/index.js


+ 111 - 0
miniprogram_npm/vant-weapp/definitions/weapp.d.ts

@@ -0,0 +1,111 @@
+/// <reference types="miniprogram-api-typings" />
+export declare namespace Weapp {
+    interface FormField {
+        data: {
+            name: string;
+            value: any;
+        };
+    }
+    interface Target {
+        id: string;
+        tagName: string;
+        dataset: {
+            [key: string]: any;
+        };
+    }
+    interface Event {
+        /**
+         * 代表事件的类型。
+         */
+        type: string;
+        /**
+         * 页面打开到触发事件所经过的毫秒数。
+         */
+        timeStamp: number;
+        /**
+         * 触发事件的源组件。
+         */
+        target: Target;
+        /**
+         * 事件绑定的当前组件。
+         */
+        currentTarget: Target;
+        /**
+         * 额外的信息
+         */
+        detail: any;
+    }
+    interface Touch {
+        /**
+         * 触摸点的标识符
+         */
+        identifier: number;
+        /**
+         * 距离文档左上角的距离,文档的左上角为原点 ,横向为X轴,纵向为Y轴
+         */
+        pageX: number;
+        /**
+         * 距离文档左上角的距离,文档的左上角为原点 ,横向为X轴,纵向为Y轴
+         */
+        pageY: number;
+        /**
+         * 距离页面可显示区域(屏幕除去导航条)左上角距离,横向为X轴,纵向为Y轴
+         */
+        clientX: number;
+        /**
+         * 距离页面可显示区域(屏幕除去导航条)左上角距离,横向为X轴,纵向为Y轴
+         */
+        clientY: number;
+    }
+    interface TouchEvent extends Event {
+        touches: Array<Touch>;
+        changedTouches: Array<Touch>;
+    }
+    /**
+     * relation定义,miniprogram-api-typings缺少this定义
+     */
+    interface RelationOption<Instance> {
+        /** 目标组件的相对关系 */
+        type: 'parent' | 'child' | 'ancestor' | 'descendant';
+        /** 关系生命周期函数,当关系被建立在页面节点树中时触发,触发时机在组件attached生命周期之后 */
+        linked?(this: Instance, target: WechatMiniprogram.Component.TrivialInstance): void;
+        /** 关系生命周期函数,当关系在页面节点树中发生改变时触发,触发时机在组件moved生命周期之后 */
+        linkChanged?(this: Instance, target: WechatMiniprogram.Component.TrivialInstance): void;
+        /** 关系生命周期函数,当关系脱离页面节点树时触发,触发时机在组件detached生命周期之后 */
+        unlinked?(this: Instance, target: WechatMiniprogram.Component.TrivialInstance): void;
+        /** 如果这一项被设置,则它表示关联的目标节点所应具有的behavior,所有拥有这一behavior的组件节点都会被关联 */
+        target?: string;
+    }
+    /**
+     * obverser定义,miniprogram-api-typings缺少this定义
+     */
+    type Observer<Instance, T> = (this: Instance, newVal: T, oldVal: T, changedPath: Array<string | number>) => void;
+    /**
+     * watch定义
+     */
+    interface WatchOption<Instance> {
+        [name: string]: string | Observer<Instance, any>;
+    }
+    /**
+     * methods定义,miniprogram-api-typings缺少this定义
+     */
+    interface MethodOption<Instance> {
+        [name: string]: (this: Instance, ...args: any[]) => any;
+    }
+    interface ComputedOption<Instance> {
+        [name: string]: (this: Instance) => any;
+    }
+    type PropertyType = StringConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor | ObjectConstructor | FunctionConstructor | null;
+    interface PropertyOption {
+        [name: string]: PropertyType | PropertyType[] | {
+            /** 属性类型 */
+            type: PropertyType | PropertyType[];
+            /** 属性初始值 */
+            value?: any;
+            /** 属性值被更改时的响应函数 */
+            observer?: string | Observer<WechatMiniprogram.Component.TrivialInstance, any>;
+            /** 属性的类型(可以指定多个) */
+            optionalTypes?: PropertyType[];
+        };
+    }
+}

+ 0 - 0
miniprogram_npm/vant-weapp/definitions/weapp.js


+ 45 - 0
miniprogram_npm/vant-weapp/dialog/dialog.d.ts

@@ -0,0 +1,45 @@
+/// <reference types="miniprogram-api-typings" />
+declare type DialogAction = 'confirm' | 'cancel';
+declare type DialogOptions = {
+    lang?: string;
+    show?: boolean;
+    title?: string;
+    zIndex?: number;
+    context?: WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance;
+    message?: string;
+    overlay?: boolean;
+    selector?: string;
+    ariaLabel?: string;
+    className?: string;
+    customStyle?: string;
+    transition?: string;
+    asyncClose?: boolean;
+    businessId?: number;
+    sessionFrom?: string;
+    appParameter?: string;
+    messageAlign?: string;
+    sendMessageImg?: string;
+    showMessageCard?: boolean;
+    sendMessagePath?: string;
+    sendMessageTitle?: string;
+    confirmButtonText?: string;
+    cancelButtonText?: string;
+    showConfirmButton?: boolean;
+    showCancelButton?: boolean;
+    closeOnClickOverlay?: boolean;
+    confirmButtonOpenType?: string;
+};
+interface Dialog {
+    (options: DialogOptions): Promise<DialogAction>;
+    alert?: (options: DialogOptions) => Promise<DialogAction>;
+    confirm?: (options: DialogOptions) => Promise<DialogAction>;
+    close?: () => void;
+    stopLoading?: () => void;
+    install?: () => void;
+    setDefaultOptions?: (options: DialogOptions) => void;
+    resetDefaultOptions?: () => void;
+    defaultOptions?: DialogOptions;
+    currentOptions?: DialogOptions;
+}
+declare const Dialog: Dialog;
+export default Dialog;

+ 61 - 0
miniprogram_npm/vant-weapp/dialog/dialog.js

@@ -0,0 +1,61 @@
+let queue = [];
+function getContext() {
+    const pages = getCurrentPages();
+    return pages[pages.length - 1];
+}
+const Dialog = options => {
+    options = Object.assign({}, Dialog.currentOptions, options);
+    return new Promise((resolve, reject) => {
+        const context = options.context || getContext();
+        const dialog = context.selectComponent(options.selector);
+        delete options.context;
+        delete options.selector;
+        if (dialog) {
+            dialog.set(Object.assign({ onCancel: reject, onConfirm: resolve }, options));
+            queue.push(dialog);
+        }
+        else {
+            console.warn('未找到 van-dialog 节点,请确认 selector 及 context 是否正确');
+        }
+    });
+};
+Dialog.defaultOptions = {
+    show: true,
+    title: '',
+    message: '',
+    zIndex: 100,
+    overlay: true,
+    className: '',
+    customStyle: '',
+    asyncClose: false,
+    messageAlign: '',
+    transition: 'scale',
+    selector: '#van-dialog',
+    confirmButtonText: '确认',
+    cancelButtonText: '取消',
+    showConfirmButton: true,
+    showCancelButton: false,
+    closeOnClickOverlay: false,
+    confirmButtonOpenType: ''
+};
+Dialog.alert = Dialog;
+Dialog.confirm = options => Dialog(Object.assign({ showCancelButton: true }, options));
+Dialog.close = () => {
+    queue.forEach(dialog => {
+        dialog.close();
+    });
+    queue = [];
+};
+Dialog.stopLoading = () => {
+    queue.forEach(dialog => {
+        dialog.stopLoading();
+    });
+};
+Dialog.setDefaultOptions = options => {
+    Object.assign(Dialog.currentOptions, options);
+};
+Dialog.resetDefaultOptions = () => {
+    Dialog.currentOptions = Object.assign({}, Dialog.defaultOptions);
+};
+Dialog.resetDefaultOptions();
+export default Dialog;

+ 1 - 0
miniprogram_npm/vant-weapp/dialog/index.d.ts

@@ -0,0 +1 @@
+export {};

+ 98 - 0
miniprogram_npm/vant-weapp/dialog/index.js

@@ -0,0 +1,98 @@
+import { VantComponent } from '../common/component';
+import { button } from '../mixins/button';
+import { openType } from '../mixins/open-type';
+VantComponent({
+    mixins: [button, openType],
+    props: {
+        show: Boolean,
+        title: String,
+        message: String,
+        useSlot: Boolean,
+        className: String,
+        customStyle: String,
+        asyncClose: Boolean,
+        messageAlign: String,
+        showCancelButton: Boolean,
+        closeOnClickOverlay: Boolean,
+        confirmButtonOpenType: String,
+        zIndex: {
+            type: Number,
+            value: 2000
+        },
+        confirmButtonText: {
+            type: String,
+            value: '确认'
+        },
+        cancelButtonText: {
+            type: String,
+            value: '取消'
+        },
+        showConfirmButton: {
+            type: Boolean,
+            value: true
+        },
+        overlay: {
+            type: Boolean,
+            value: true
+        },
+        transition: {
+            type: String,
+            value: 'scale'
+        }
+    },
+    data: {
+        loading: {
+            confirm: false,
+            cancel: false
+        }
+    },
+    watch: {
+        show(show) {
+            !show && this.stopLoading();
+        }
+    },
+    methods: {
+        onConfirm() {
+            this.handleAction('confirm');
+        },
+        onCancel() {
+            this.handleAction('cancel');
+        },
+        onClickOverlay() {
+            this.onClose('overlay');
+        },
+        handleAction(action) {
+            if (this.data.asyncClose) {
+                this.set({
+                    [`loading.${action}`]: true
+                });
+            }
+            this.onClose(action);
+        },
+        close() {
+            this.set({
+                show: false
+            });
+        },
+        stopLoading() {
+            this.set({
+                loading: {
+                    confirm: false,
+                    cancel: false
+                }
+            });
+        },
+        onClose(action) {
+            if (!this.data.asyncClose) {
+                this.close();
+            }
+            this.$emit('close', action);
+            // 把 dialog 实例传递出去,可以通过 stopLoading() 在外部关闭按钮的 loading
+            this.$emit(action, { dialog: this });
+            const callback = this.data[action === 'confirm' ? 'onConfirm' : 'onCancel'];
+            if (callback) {
+                callback(this);
+            }
+        }
+    }
+});

+ 7 - 0
miniprogram_npm/vant-weapp/dialog/index.json

@@ -0,0 +1,7 @@
+{
+  "component": true,
+  "usingComponents": {
+    "van-popup": "../popup/index",
+    "van-button": "../button/index"
+  }
+}

+ 65 - 0
miniprogram_npm/vant-weapp/dialog/index.wxml

@@ -0,0 +1,65 @@
+<van-popup
+  show="{{ show }}"
+  z-index="{{ zIndex }}"
+  overlay="{{ overlay }}"
+  custom-class="van-dialog {{ className }}"
+  transition="{{ transition }}"
+  custom-style="{{ customStyle }}"
+  close-on-click-overlay="{{ closeOnClickOverlay }}"
+  bind:close="onClickOverlay"
+>
+  <view
+    wx:if="{{ title }}"
+    class="van-dialog__header {{ message || useSlot ? '' : 'van-dialog--isolated' }}"
+  >
+    {{ title }}
+  </view>
+
+  <slot wx:if="{{ useSlot }}" />
+  <view
+    wx:elif="{{ message }}"
+    class="van-dialog__message {{ title ? 'van-dialog__message--has-title' : '' }} {{ messageAlign ? 'van-dialog__message--' + messageAlign : '' }}"
+  >
+    <text>{{ message }}</text>
+  </view>
+
+  <view class="van-hairline--top van-dialog__footer">
+    <van-button
+      wx:if="{{ showCancelButton }}"
+      size="large"
+      loading="{{ loading.cancel }}"
+      class="van-dialog__button van-hairline--right"
+      custom-class="van-dialog__cancel"
+      bind:click="onCancel"
+    >
+      {{ cancelButtonText }}
+    </van-button>
+    <van-button
+      wx:if="{{ showConfirmButton }}"
+      size="large"
+      class="van-dialog__button"
+      loading="{{ loading.confirm }}"
+      custom-class="van-dialog__confirm"
+
+      open-type="{{ confirmButtonOpenType }}"
+      lang="{{ lang }}"
+      business-id="{{ businessId }}"
+      session-from="{{ sessionFrom }}"
+      send-message-title="{{ sendMessageTitle }}"
+      send-message-path="{{ sendMessagePath }}"
+      send-message-img="{{ sendMessageImg }}"
+      show-message-card="{{ showMessageCard }}"
+      app-parameter="{{ appParameter }}"
+
+      bind:click="onConfirm"
+      bindgetuserinfo="bindGetUserInfo"
+      bindcontact="bindContact"
+      bindgetphonenumber="bindGetPhoneNumber"
+      binderror="bindError"
+      bindlaunchapp="bindLaunchApp"
+      bindopensetting="bindOpenSetting"
+    >
+      {{ confirmButtonText }}
+    </van-button>
+  </view>
+</van-popup>

File diff ditekan karena terlalu besar
+ 1 - 0
miniprogram_npm/vant-weapp/dialog/index.wxss


+ 1 - 0
miniprogram_npm/vant-weapp/field/index.d.ts

@@ -0,0 +1 @@
+export {};

+ 105 - 0
miniprogram_npm/vant-weapp/field/index.js

@@ -0,0 +1,105 @@
+import { VantComponent } from '../common/component';
+import { getSystemInfoSync } from '../common/utils';
+VantComponent({
+    field: true,
+    classes: ['input-class', 'right-icon-class'],
+    props: {
+        size: String,
+        icon: String,
+        label: String,
+        error: Boolean,
+        fixed: Boolean,
+        focus: Boolean,
+        center: Boolean,
+        isLink: Boolean,
+        leftIcon: String,
+        rightIcon: String,
+        disabled: Boolean,
+        autosize: Boolean,
+        readonly: Boolean,
+        required: Boolean,
+        password: Boolean,
+        iconClass: String,
+        clearable: Boolean,
+        inputAlign: String,
+        customStyle: String,
+        confirmType: String,
+        confirmHold: Boolean,
+        errorMessage: String,
+        placeholder: String,
+        placeholderStyle: String,
+        errorMessageAlign: String,
+        selectionEnd: {
+            type: Number,
+            value: -1
+        },
+        selectionStart: {
+            type: Number,
+            value: -1
+        },
+        showConfirmBar: {
+            type: Boolean,
+            value: true
+        },
+        adjustPosition: {
+            type: Boolean,
+            value: true
+        },
+        cursorSpacing: {
+            type: Number,
+            value: 50
+        },
+        maxlength: {
+            type: Number,
+            value: -1
+        },
+        type: {
+            type: String,
+            value: 'text'
+        },
+        border: {
+            type: Boolean,
+            value: true
+        },
+        titleWidth: {
+            type: String,
+            value: '90px'
+        }
+    },
+    data: {
+        focused: false,
+        system: getSystemInfoSync().system.split(' ').shift().toLowerCase()
+    },
+    methods: {
+        onInput(event) {
+            const { value = '' } = event.detail || {};
+            this.set({ value }, () => {
+                this.emitChange(value);
+            });
+        },
+        onFocus(event) {
+            this.set({ focused: true });
+            this.$emit('focus', event.detail);
+        },
+        onBlur(event) {
+            this.set({ focused: false });
+            this.$emit('blur', event.detail);
+        },
+        onClickIcon() {
+            this.$emit('click-icon');
+        },
+        onClear() {
+            this.set({ value: '' }, () => {
+                this.emitChange('');
+                this.$emit('clear', '');
+            });
+        },
+        onConfirm() {
+            this.$emit('confirm', this.data.value);
+        },
+        emitChange(value) {
+            this.$emit('input', value);
+            this.$emit('change', value);
+        }
+    }
+});

+ 0 - 0
miniprogram_npm/vant-weapp/field/index.json


Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini