Browse Source

提交vant组件库问题

wangming 2 months ago
parent
commit
d77647ef0b
45 changed files with 1484 additions and 97 deletions
  1. 9 0
      src/pages.json
  2. 22 17
      src/pagesA/devices/devices.vue
  3. 0 80
      src/pagesA/fenbao/fenbao.vue
  4. 28 0
      src/pagesA/homeManage/homeManage.vue
  5. 1 0
      src/wxcomponents/vant/action-sheet/index.d.ts
  6. 78 0
      src/wxcomponents/vant/action-sheet/index.js
  7. 8 0
      src/wxcomponents/vant/action-sheet/index.json
  8. 70 0
      src/wxcomponents/vant/action-sheet/index.wxml
  9. 1 0
      src/wxcomponents/vant/action-sheet/index.wxss
  10. 1 0
      src/wxcomponents/vant/area/index.d.ts
  11. 235 0
      src/wxcomponents/vant/area/index.js
  12. 6 0
      src/wxcomponents/vant/area/index.json
  13. 20 0
      src/wxcomponents/vant/area/index.wxml
  14. 8 0
      src/wxcomponents/vant/area/index.wxs
  15. 1 0
      src/wxcomponents/vant/area/index.wxss
  16. 1 0
      src/wxcomponents/vant/card/index.d.ts
  17. 51 0
      src/wxcomponents/vant/card/index.js
  18. 6 0
      src/wxcomponents/vant/card/index.json
  19. 56 0
      src/wxcomponents/vant/card/index.wxml
  20. 1 0
      src/wxcomponents/vant/card/index.wxss
  21. 55 0
      src/wxcomponents/vant/dialog/dialog.d.ts
  22. 92 0
      src/wxcomponents/vant/dialog/dialog.js
  23. 1 0
      src/wxcomponents/vant/dialog/index.d.ts
  24. 135 0
      src/wxcomponents/vant/dialog/index.js
  25. 9 0
      src/wxcomponents/vant/dialog/index.json
  26. 125 0
      src/wxcomponents/vant/dialog/index.wxml
  27. 1 0
      src/wxcomponents/vant/dialog/index.wxss
  28. 1 0
      src/wxcomponents/vant/field/index.d.ts
  29. 152 0
      src/wxcomponents/vant/field/index.js
  30. 7 0
      src/wxcomponents/vant/field/index.json
  31. 56 0
      src/wxcomponents/vant/field/index.wxml
  32. 18 0
      src/wxcomponents/vant/field/index.wxs
  33. 0 0
      src/wxcomponents/vant/field/index.wxss
  34. 31 0
      src/wxcomponents/vant/field/input.wxml
  35. 4 0
      src/wxcomponents/vant/field/props.d.ts
  36. 59 0
      src/wxcomponents/vant/field/props.js
  37. 32 0
      src/wxcomponents/vant/field/textarea.wxml
  38. 8 0
      src/wxcomponents/vant/field/types.d.ts
  39. 2 0
      src/wxcomponents/vant/field/types.js
  40. 1 0
      src/wxcomponents/vant/icon/index.d.ts
  41. 23 0
      src/wxcomponents/vant/icon/index.js
  42. 6 0
      src/wxcomponents/vant/icon/index.json
  43. 20 0
      src/wxcomponents/vant/icon/index.wxml
  44. 43 0
      src/wxcomponents/vant/icon/index.wxs
  45. 0 0
      src/wxcomponents/vant/icon/index.wxss

+ 9 - 0
src/pages.json

@@ -156,6 +156,15 @@
                         "navigationBarBackgroundColor": "#faede2",
                         "navigationBarTextStyle": "black"
                     }
+                },
+                {
+                    "path": "homeManage/homeManage",
+                    "style": {
+                        "enablePullDownRefresh": true,
+                        "navigationBarTitleText": "家庭管理",
+                        "navigationBarBackgroundColor": "#faede2",
+                        "navigationBarTextStyle": "black"
+                    }
                 }
             ]
         }

+ 22 - 17
src/pagesA/devices/devices.vue

@@ -40,10 +40,11 @@
                         <view class="cardError" v-if="item.lastTargetTime"
                             >当前无人</view
                         >
-                        <view class="endTime"
+                        <view class="endTime" v-if="item.lastTargetTime"
                             >离开时间
                             {{ forMateTime(item.lastTargetTime) }}</view
                         >
+                        <view class="cardError" v-else>当前无人</view>
                     </view>
                 </view>
                 <view v-else style="margin-top: 18rpx">
@@ -164,24 +165,28 @@ export default {
                             } else {
                                 devs[i].wcTimes = 0;
                             }
-                            const signalTimeStr = devs[
-                                i
-                            ].lastTargetTime.replace(/-/g, "/");
-                            const signalTime = new Date(
-                                signalTimeStr
-                            ).getTime();
+                            if (devs[i].lastTargetTime) {
+                                const signalTimeStr = devs[
+                                    i
+                                ].lastTargetTime.replace(/-/g, "/");
+                                const signalTime = new Date(
+                                    signalTimeStr
+                                ).getTime();
 
-                            if (isNaN(signalTime)) {
-                                devs[i].judge = false;
-                            } else {
-                                const currentTime = Date.now();
-                                const diff = Math.abs(currentTime - signalTime);
-                                devs[i].judge = diff <= 10000; // 10秒内为 true
+                                if (isNaN(signalTime)) {
+                                    devs[i].judge = false;
+                                } else {
+                                    const currentTime = Date.now();
+                                    const diff = Math.abs(
+                                        currentTime - signalTime
+                                    );
+                                    devs[i].judge = diff <= 10000; // 10秒内为 true
+                                }
                             }
-                            devs[i].signalTime = common.timestampToTime(
-                                devs[i].signalTime,
-                                6
-                            );
+                            // devs[i].signalTime = common.timestampToTime(
+                            //     devs[i].signalTime,
+                            //     6
+                            // );
                         }
                         this.devs = devs;
                         console.log(this.devs, 99999);

+ 0 - 80
src/pagesA/fenbao/fenbao.vue

@@ -1,80 +0,0 @@
-<template>
-	<view>
-		这个是分包页面
-	</view>
-</template>
-
-<script>
-	const airkiss = requirePlugin('airkiss');
-	export default {
-		data() {
-			return {
-				ssid: '',
-				password: '',
-				pwzt: false,
-				height: 2.5,
-				north_angle: ''
-			};
-		},
-		methods: {
-			kspw() {
-				if (!this.ssid) {
-					wx.showModal({
-						content: '请连接无线网络,连接后点击刷新',
-						showCancel: false
-					})
-					return;
-				}
-
-				if (this.password.length < 8) {
-					wx.showModal({
-						content: '请输入不少于8位的密码',
-						showCancel: false
-					})
-					return;
-				}
-				var that = this
-				wx.showLoading({
-					title: '配网中',
-				})
-				airkiss.startAirkiss(this.ssid, this.password, function(res) {
-					wx.hideLoading();
-					console.log(res)
-					switch (res.code) {
-						case 0:
-							wx.showModal({
-								title: '初始化失败',
-								content: res.result,
-								showCancel: false,
-							})
-							break;
-						case 1:
-							wx.showModal({
-								title: '配网成功',
-								content: '设备IP:' + res.ip + '\r\n 设备Mac:' + res.bssid,
-								showCancel: false,
-							})
-							that.setData({
-								pwzt: true
-							})
-							break;
-						case 2:
-							wx.showModal({
-								title: '配网失败',
-								content: '请检查密码是否正确',
-								showCancel: false,
-							})
-							break;
-
-						default:
-							break;
-					}
-				})
-			},
-		}
-	}
-</script>
-
-<style lang="less">
-
-</style>

+ 28 - 0
src/pagesA/homeManage/homeManage.vue

@@ -0,0 +1,28 @@
+<template>
+    <div class="box">
+        <!-- 页面内容 -->
+    </div>
+</template>
+
+<script>
+export default {
+    name: "HomeManage",
+    data() {
+        return {
+            // 数据属性
+        };
+    },
+    methods: {
+        // 方法
+    },
+    mounted() {
+        // 生命周期钩子
+    },
+};
+</script>
+
+<style scoped>
+.home-manage {
+    /* 样式 */
+}
+</style>

+ 1 - 0
src/wxcomponents/vant/action-sheet/index.d.ts

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

+ 78 - 0
src/wxcomponents/vant/action-sheet/index.js

@@ -0,0 +1,78 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+var component_1 = require("../common/component");
+var button_1 = require("../mixins/button");
+(0, component_1.VantComponent)({
+    classes: ['list-class'],
+    mixins: [button_1.button],
+    props: {
+        show: Boolean,
+        title: String,
+        cancelText: String,
+        description: String,
+        round: {
+            type: Boolean,
+            value: true,
+        },
+        zIndex: {
+            type: Number,
+            value: 100,
+        },
+        actions: {
+            type: Array,
+            value: [],
+        },
+        overlay: {
+            type: Boolean,
+            value: true,
+        },
+        closeOnClickOverlay: {
+            type: Boolean,
+            value: true,
+        },
+        closeOnClickAction: {
+            type: Boolean,
+            value: true,
+        },
+        safeAreaInsetBottom: {
+            type: Boolean,
+            value: true,
+        },
+        rootPortal: {
+            type: Boolean,
+            value: false,
+        },
+    },
+    methods: {
+        onSelect: function (event) {
+            var _this = this;
+            var index = event.currentTarget.dataset.index;
+            var _a = this.data, actions = _a.actions, closeOnClickAction = _a.closeOnClickAction, canIUseGetUserProfile = _a.canIUseGetUserProfile;
+            var item = actions[index];
+            if (item) {
+                this.$emit('select', item);
+                if (closeOnClickAction) {
+                    this.onClose();
+                }
+                if (item.openType === 'getUserInfo' && canIUseGetUserProfile) {
+                    wx.getUserProfile({
+                        desc: item.getUserProfileDesc || '  ',
+                        complete: function (userProfile) {
+                            _this.$emit('getuserinfo', userProfile);
+                        },
+                    });
+                }
+            }
+        },
+        onCancel: function () {
+            this.$emit('cancel');
+        },
+        onClose: function () {
+            this.$emit('close');
+        },
+        onClickOverlay: function () {
+            this.$emit('click-overlay');
+            this.onClose();
+        },
+    },
+});

+ 8 - 0
src/wxcomponents/vant/action-sheet/index.json

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

+ 70 - 0
src/wxcomponents/vant/action-sheet/index.wxml

@@ -0,0 +1,70 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+
+<van-popup
+  show="{{ show }}"
+  position="bottom"
+  round="{{ round }}"
+  z-index="{{ zIndex }}"
+  overlay="{{ overlay }}"
+  custom-class="van-action-sheet custom-class"
+  safe-area-inset-bottom="{{ safeAreaInsetBottom }}"
+  close-on-click-overlay="{{ closeOnClickOverlay }}"
+  root-portal="{{ rootPortal }}"
+  bind:close="onClickOverlay"
+>
+  <view wx:if="{{ title }}" class="van-action-sheet__header">
+    {{ title }}
+    <van-icon
+      name="cross"
+      custom-class="van-action-sheet__close"
+      bind:click="onClose"
+    />
+  </view>
+  <view wx:if="{{ description }}" class="van-action-sheet__description van-hairline--bottom">
+    {{ description }}
+  </view>
+  <view wx:if="{{ actions && actions.length }}" class="list-class">
+    <!-- button外包一层view,防止actions动态变化,导致渲染时button被打散 -->
+    <button
+      wx:for="{{ actions }}"
+      wx:key="index"
+      open-type="{{ item.disabled || item.loading || (canIUseGetUserProfile && item.openType === 'getUserInfo') ? '' : item.openType }}"
+      style="{{ item.color ? 'color: ' + item.color : '' }}"
+      class="{{ utils.bem('action-sheet__item', { disabled: item.disabled || item.loading }) }} {{ item.className || '' }}"
+      hover-class="van-action-sheet__item--hover"
+      data-index="{{ index }}"
+      bindtap="{{ item.disabled || item.loading ? '' : 'onSelect' }}"
+      bindgetuserinfo="onGetUserInfo"
+      bindcontact="onContact"
+      bindgetphonenumber="onGetPhoneNumber"
+      binderror="onError"
+      bindlaunchapp="onLaunchApp"
+      bindopensetting="onOpenSetting"
+      lang="{{ lang }}"
+      session-from="{{ sessionFrom }}"
+      send-message-title="{{ sendMessageTitle }}"
+      send-message-path="{{ sendMessagePath }}"
+      send-message-img="{{ sendMessageImg }}"
+      show-message-card="{{ showMessageCard }}"
+      app-parameter="{{ appParameter }}"
+    >
+      <block wx:if="{{ !item.loading }}">
+        {{ item.name }}
+        <view wx:if="{{ item.subname }}" class="van-action-sheet__subname" >{{ item.subname }}</view>
+      </block>
+      <van-loading wx:else custom-class="van-action-sheet__loading" size="22px" />
+    </button>
+  </view>
+  <slot />
+  <block wx:if="{{ cancelText }}">
+    <view class="van-action-sheet__gap" />
+    <view
+      class="van-action-sheet__cancel"
+      hover-class="van-action-sheet__cancel--hover"
+      hover-stay-time="70"
+      bind:tap="onCancel"
+    >
+      {{ cancelText }}
+    </view>
+  </block>
+</van-popup>

+ 1 - 0
src/wxcomponents/vant/action-sheet/index.wxss

@@ -0,0 +1 @@
+@import '../common/index.wxss';.van-action-sheet{color:var(--action-sheet-item-text-color,#323233);max-height:var(--action-sheet-max-height,90%)!important}.van-action-sheet__cancel,.van-action-sheet__item{background-color:var(--action-sheet-item-background,#fff);font-size:var(--action-sheet-item-font-size,16px);line-height:var(--action-sheet-item-line-height,22px);padding:14px 16px;text-align:center}.van-action-sheet__cancel--hover,.van-action-sheet__item--hover{background-color:#f2f3f5}.van-action-sheet__cancel:after,.van-action-sheet__item:after{border-width:0}.van-action-sheet__cancel{color:var(--action-sheet-cancel-text-color,#646566)}.van-action-sheet__gap{background-color:var(--action-sheet-cancel-padding-color,#f7f8fa);display:block;height:var(--action-sheet-cancel-padding-top,8px)}.van-action-sheet__item--disabled{color:var(--action-sheet-item-disabled-text-color,#c8c9cc)}.van-action-sheet__item--disabled.van-action-sheet__item--hover{background-color:var(--action-sheet-item-background,#fff)}.van-action-sheet__subname{color:var(--action-sheet-subname-color,#969799);font-size:var(--action-sheet-subname-font-size,12px);line-height:var(--action-sheet-subname-line-height,20px);margin-top:var(--padding-xs,8px)}.van-action-sheet__header{font-size:var(--action-sheet-header-font-size,16px);font-weight:var(--font-weight-bold,500);line-height:var(--action-sheet-header-height,48px);text-align:center}.van-action-sheet__description{color:var(--action-sheet-description-color,#969799);font-size:var(--action-sheet-description-font-size,14px);line-height:var(--action-sheet-description-line-height,20px);padding:20px var(--padding-md,16px);text-align:center}.van-action-sheet__close{color:var(--action-sheet-close-icon-color,#c8c9cc);font-size:var(--action-sheet-close-icon-size,22px)!important;line-height:inherit!important;padding:var(--action-sheet-close-icon-padding,0 16px);position:absolute!important;right:0;top:0}.van-action-sheet__loading{display:flex!important}

+ 1 - 0
src/wxcomponents/vant/area/index.d.ts

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

+ 235 - 0
src/wxcomponents/vant/area/index.js

@@ -0,0 +1,235 @@
+"use strict";
+var __assign = (this && this.__assign) || function () {
+    __assign = Object.assign || function(t) {
+        for (var s, i = 1, n = arguments.length; i < n; i++) {
+            s = arguments[i];
+            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
+                t[p] = s[p];
+        }
+        return t;
+    };
+    return __assign.apply(this, arguments);
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+var component_1 = require("../common/component");
+var shared_1 = require("../picker/shared");
+var utils_1 = require("../common/utils");
+var EMPTY_CODE = '000000';
+(0, component_1.VantComponent)({
+    classes: ['active-class', 'toolbar-class', 'column-class'],
+    props: __assign(__assign({}, shared_1.pickerProps), { showToolbar: {
+            type: Boolean,
+            value: true,
+        }, value: {
+            type: String,
+            observer: function (value) {
+                this.code = value;
+                this.setValues();
+            },
+        }, areaList: {
+            type: Object,
+            value: {},
+            observer: 'setValues',
+        }, columnsNum: {
+            type: null,
+            value: 3,
+        }, columnsPlaceholder: {
+            type: Array,
+            observer: function (val) {
+                this.setData({
+                    typeToColumnsPlaceholder: {
+                        province: val[0] || '',
+                        city: val[1] || '',
+                        county: val[2] || '',
+                    },
+                });
+            },
+        } }),
+    data: {
+        columns: [{ values: [] }, { values: [] }, { values: [] }],
+        typeToColumnsPlaceholder: {},
+    },
+    mounted: function () {
+        var _this = this;
+        (0, utils_1.requestAnimationFrame)(function () {
+            _this.setValues();
+        });
+    },
+    methods: {
+        getPicker: function () {
+            if (this.picker == null) {
+                this.picker = this.selectComponent('.van-area__picker');
+            }
+            return this.picker;
+        },
+        onCancel: function (event) {
+            this.emit('cancel', event.detail);
+        },
+        onConfirm: function (event) {
+            var index = event.detail.index;
+            var value = event.detail.value;
+            value = this.parseValues(value);
+            this.emit('confirm', { value: value, index: index });
+        },
+        emit: function (type, detail) {
+            detail.values = detail.value;
+            delete detail.value;
+            this.$emit(type, detail);
+        },
+        parseValues: function (values) {
+            var columnsPlaceholder = this.data.columnsPlaceholder;
+            return values.map(function (value, index) {
+                if (value &&
+                    (!value.code || value.name === columnsPlaceholder[index])) {
+                    return __assign(__assign({}, value), { code: '', name: '' });
+                }
+                return value;
+            });
+        },
+        onChange: function (event) {
+            var _this = this;
+            var _a;
+            var _b = event.detail, index = _b.index, picker = _b.picker, value = _b.value;
+            this.code = value[index].code;
+            (_a = this.setValues()) === null || _a === void 0 ? void 0 : _a.then(function () {
+                _this.$emit('change', {
+                    picker: picker,
+                    values: _this.parseValues(picker.getValues()),
+                    index: index,
+                });
+            });
+        },
+        getConfig: function (type) {
+            var areaList = this.data.areaList;
+            return (areaList && areaList["".concat(type, "_list")]) || {};
+        },
+        getList: function (type, code) {
+            if (type !== 'province' && !code) {
+                return [];
+            }
+            var typeToColumnsPlaceholder = this.data.typeToColumnsPlaceholder;
+            var list = this.getConfig(type);
+            var result = Object.keys(list).map(function (code) { return ({
+                code: code,
+                name: list[code],
+            }); });
+            if (code != null) {
+                // oversea code
+                if (code[0] === '9' && type === 'city') {
+                    code = '9';
+                }
+                result = result.filter(function (item) { return item.code.indexOf(code) === 0; });
+            }
+            if (typeToColumnsPlaceholder[type] && result.length) {
+                // set columns placeholder
+                var codeFill = type === 'province'
+                    ? ''
+                    : type === 'city'
+                        ? EMPTY_CODE.slice(2, 4)
+                        : EMPTY_CODE.slice(4, 6);
+                result.unshift({
+                    code: "".concat(code).concat(codeFill),
+                    name: typeToColumnsPlaceholder[type],
+                });
+            }
+            return result;
+        },
+        getIndex: function (type, code) {
+            var compareNum = type === 'province' ? 2 : type === 'city' ? 4 : 6;
+            var 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 (var i = 0; i < list.length; i++) {
+                if (list[i].code.slice(0, compareNum) === code) {
+                    return i;
+                }
+            }
+            return 0;
+        },
+        setValues: function () {
+            var picker = this.getPicker();
+            if (!picker) {
+                return;
+            }
+            var code = this.code || this.getDefaultCode();
+            var provinceList = this.getList('province');
+            var cityList = this.getList('city', code.slice(0, 2));
+            var stack = [];
+            var indexes = [];
+            var columnsNum = this.data.columnsNum;
+            if (columnsNum >= 1) {
+                stack.push(picker.setColumnValues(0, provinceList, false));
+                indexes.push(this.getIndex('province', code));
+            }
+            if (columnsNum >= 2) {
+                stack.push(picker.setColumnValues(1, cityList, false));
+                indexes.push(this.getIndex('city', code));
+                if (cityList.length && code.slice(2, 4) === '00') {
+                    code = cityList[0].code;
+                }
+            }
+            if (columnsNum === 3) {
+                stack.push(picker.setColumnValues(2, this.getList('county', code.slice(0, 4)), false));
+                indexes.push(this.getIndex('county', code));
+            }
+            return Promise.all(stack)
+                .catch(function () { })
+                .then(function () { return picker.setIndexes(indexes); })
+                .catch(function () { });
+        },
+        getDefaultCode: function () {
+            var columnsPlaceholder = this.data.columnsPlaceholder;
+            if (columnsPlaceholder.length) {
+                return EMPTY_CODE;
+            }
+            var countyCodes = Object.keys(this.getConfig('county'));
+            if (countyCodes[0]) {
+                return countyCodes[0];
+            }
+            var cityCodes = Object.keys(this.getConfig('city'));
+            if (cityCodes[0]) {
+                return cityCodes[0];
+            }
+            return '';
+        },
+        getValues: function () {
+            var picker = this.getPicker();
+            if (!picker) {
+                return [];
+            }
+            return this.parseValues(picker.getValues().filter(function (value) { return !!value; }));
+        },
+        getDetail: function () {
+            var values = this.getValues();
+            var area = {
+                code: '',
+                country: '',
+                province: '',
+                city: '',
+                county: '',
+            };
+            if (!values.length) {
+                return area;
+            }
+            var names = values.map(function (item) { return 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: function (code) {
+            this.code = code || '';
+            return this.setValues();
+        },
+    },
+});

+ 6 - 0
src/wxcomponents/vant/area/index.json

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

+ 20 - 0
src/wxcomponents/vant/area/index.wxml

@@ -0,0 +1,20 @@
+<wxs src="./index.wxs" module="computed" />
+
+<van-picker
+  class="van-area__picker"
+  active-class="active-class"
+  toolbar-class="toolbar-class"
+  column-class="column-class"
+  show-toolbar="{{ showToolbar }}"
+  value-key="name"
+  title="{{ title }}"
+  loading="{{ loading }}"
+  columns="{{ computed.displayColumns(columns, columnsNum) }}"
+  item-height="{{ itemHeight }}"
+  visible-item-count="{{ visibleItemCount }}"
+  cancel-button-text="{{ cancelButtonText }}"
+  confirm-button-text="{{ confirmButtonText }}"
+  bind:change="onChange"
+  bind:confirm="onConfirm"
+  bind:cancel="onCancel"
+/>

+ 8 - 0
src/wxcomponents/vant/area/index.wxs

@@ -0,0 +1,8 @@
+/* eslint-disable */
+function displayColumns(columns, columnsNum) {
+  return columns.slice(0, +columnsNum);
+}
+
+module.exports = {
+  displayColumns: displayColumns,
+};

+ 1 - 0
src/wxcomponents/vant/area/index.wxss

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

+ 1 - 0
src/wxcomponents/vant/card/index.d.ts

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

+ 51 - 0
src/wxcomponents/vant/card/index.js

@@ -0,0 +1,51 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+var link_1 = require("../mixins/link");
+var component_1 = require("../common/component");
+(0, component_1.VantComponent)({
+    classes: [
+        'num-class',
+        'desc-class',
+        'thumb-class',
+        'title-class',
+        'price-class',
+        'origin-price-class',
+    ],
+    mixins: [link_1.link],
+    props: {
+        tag: String,
+        num: String,
+        desc: String,
+        thumb: String,
+        title: String,
+        price: {
+            type: String,
+            observer: 'updatePrice',
+        },
+        centered: Boolean,
+        lazyLoad: Boolean,
+        thumbLink: String,
+        originPrice: String,
+        thumbMode: {
+            type: String,
+            value: 'aspectFit',
+        },
+        currency: {
+            type: String,
+            value: '¥',
+        },
+    },
+    methods: {
+        updatePrice: function () {
+            var price = this.data.price;
+            var priceArr = price.toString().split('.');
+            this.setData({
+                integerStr: priceArr[0],
+                decimalStr: priceArr[1] ? ".".concat(priceArr[1]) : '',
+            });
+        },
+        onClickThumb: function () {
+            this.jumpLink('thumbLink');
+        },
+    },
+});

+ 6 - 0
src/wxcomponents/vant/card/index.json

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

+ 56 - 0
src/wxcomponents/vant/card/index.wxml

@@ -0,0 +1,56 @@
+<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 wx:else name="thumb" />
+      <van-tag
+        wx:if="{{ tag }}"
+        mark
+        type="danger"
+        custom-class="van-card__tag"
+      >
+        {{ tag }}
+      </van-tag>
+      <slot wx:else name="tag" />
+    </view>
+
+    <view class="van-card__content {{ utils.bem('card__content', { center: centered }) }}">
+      <view>
+        <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>
+
+      <view class="van-card__bottom">
+        <slot name="price-top" />
+        <view wx:if="{{ price || price === 0 }}" class="van-card__price price-class">
+          <text>{{ currency }}</text>
+          <text class="van-card__price-integer">{{ integerStr }}</text>
+          <text class="van-card__price-decimal">{{ decimalStr }}</text>
+        </view>
+        <slot wx:else name="price" />
+        <view wx:if="{{ originPrice || originPrice === 0 }}" class="van-card__origin-price origin-price-class">{{ currency }} {{ originPrice }}</view>
+        <slot wx:else name="origin-price" />
+        <view wx:if="{{ num }}" class="van-card__num num-class">x {{ num }}</view>
+        <slot wx:else  name="num" />
+        <slot name="bottom" />
+      </view>
+    </view>
+  </view>
+
+  <view class="van-card__footer">
+    <slot name="footer" />
+  </view>
+</view>

+ 1 - 0
src/wxcomponents/vant/card/index.wxss

@@ -0,0 +1 @@
+@import '../common/index.wxss';.van-card{background-color:var(--card-background-color,#fafafa);box-sizing:border-box;color:var(--card-text-color,#323233);font-size:var(--card-font-size,12px);padding:var(--card-padding,8px 16px);position:relative}.van-card__header{display:flex}.van-card__header--center{align-items:center;justify-content:center}.van-card__thumb{flex:none;height:var(--card-thumb-size,88px);margin-right:var(--padding-xs,8px);position:relative;width:var(--card-thumb-size,88px)}.van-card__thumb:empty{display:none}.van-card__img{border-radius:8px;height:100%;width:100%}.van-card__content{display:flex;flex:1;flex-direction:column;justify-content:space-between;min-height:var(--card-thumb-size,88px);min-width:0;position:relative}.van-card__content--center{justify-content:center}.van-card__desc,.van-card__title{word-wrap:break-word}.van-card__title{font-weight:700;line-height:var(--card-title-line-height,16px)}.van-card__desc{color:var(--card-desc-color,#646566);line-height:var(--card-desc-line-height,20px)}.van-card__bottom{line-height:20px}.van-card__price{color:var(--card-price-color,#ee0a24);display:inline-block;font-size:var(--card-price-font-size,12px);font-weight:700}.van-card__price-integer{font-size:var(--card-price-integer-font-size,16px)}.van-card__price-decimal,.van-card__price-integer{font-family:var(--card-price-font-family,Avenir-Heavy,PingFang SC,Helvetica Neue,Arial,sans-serif)}.van-card__origin-price{color:var(--card-origin-price-color,#646566);display:inline-block;font-size:var(--card-origin-price-font-size,10px);margin-left:5px;text-decoration:line-through}.van-card__num{float:right}.van-card__tag{left:0;position:absolute!important;top:2px}.van-card__footer{flex:none;text-align:right;width:100%}

+ 55 - 0
src/wxcomponents/vant/dialog/dialog.d.ts

@@ -0,0 +1,55 @@
+/// <reference types="miniprogram-api-typings" />
+/// <reference types="miniprogram-api-typings" />
+export type Action = 'confirm' | 'cancel' | 'overlay';
+type DialogContext = WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance;
+interface DialogOptions {
+    lang?: string;
+    show?: boolean;
+    title?: string;
+    width?: string | number | null;
+    zIndex?: number;
+    theme?: string;
+    context?: (() => DialogContext) | DialogContext;
+    message?: string;
+    overlay?: boolean;
+    selector?: string;
+    ariaLabel?: string;
+    /**
+     * @deprecated use custom-class instead
+     */
+    className?: string;
+    customStyle?: string;
+    transition?: string;
+    /**
+     * @deprecated use beforeClose instead
+     */
+    asyncClose?: boolean;
+    beforeClose?: null | ((action: Action) => Promise<void | boolean> | void);
+    businessId?: number;
+    sessionFrom?: string;
+    overlayStyle?: 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;
+}
+declare const Dialog: {
+    (options: DialogOptions): Promise<WechatMiniprogram.Component.TrivialInstance>;
+    alert(options: DialogOptions): Promise<WechatMiniprogram.Component.TrivialInstance>;
+    confirm(options: DialogOptions): Promise<WechatMiniprogram.Component.TrivialInstance>;
+    close(): void;
+    stopLoading(): void;
+    currentOptions: DialogOptions;
+    defaultOptions: DialogOptions;
+    setDefaultOptions(options: DialogOptions): void;
+    resetDefaultOptions(): void;
+};
+export default Dialog;

+ 92 - 0
src/wxcomponents/vant/dialog/dialog.js

@@ -0,0 +1,92 @@
+"use strict";
+var __assign = (this && this.__assign) || function () {
+    __assign = Object.assign || function(t) {
+        for (var s, i = 1, n = arguments.length; i < n; i++) {
+            s = arguments[i];
+            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
+                t[p] = s[p];
+        }
+        return t;
+    };
+    return __assign.apply(this, arguments);
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+var queue = [];
+var defaultOptions = {
+    show: false,
+    title: '',
+    width: null,
+    theme: 'default',
+    message: '',
+    zIndex: 100,
+    overlay: true,
+    selector: '#van-dialog',
+    className: '',
+    asyncClose: false,
+    beforeClose: null,
+    transition: 'scale',
+    customStyle: '',
+    messageAlign: '',
+    overlayStyle: '',
+    confirmButtonText: '确认',
+    cancelButtonText: '取消',
+    showConfirmButton: true,
+    showCancelButton: false,
+    closeOnClickOverlay: false,
+    confirmButtonOpenType: '',
+};
+var currentOptions = __assign({}, defaultOptions);
+function getContext() {
+    var pages = getCurrentPages();
+    return pages[pages.length - 1];
+}
+var Dialog = function (options) {
+    options = __assign(__assign({}, currentOptions), options);
+    return new Promise(function (resolve, reject) {
+        var context = (typeof options.context === 'function'
+            ? options.context()
+            : options.context) || getContext();
+        var dialog = context.selectComponent(options.selector);
+        delete options.context;
+        delete options.selector;
+        if (dialog) {
+            dialog.setData(__assign({ callback: function (action, instance) {
+                    action === 'confirm' ? resolve(instance) : reject(instance);
+                } }, options));
+            wx.nextTick(function () {
+                dialog.setData({ show: true });
+            });
+            queue.push(dialog);
+        }
+        else {
+            console.warn('未找到 van-dialog 节点,请确认 selector 及 context 是否正确');
+        }
+    });
+};
+Dialog.alert = function (options) { return Dialog(options); };
+Dialog.confirm = function (options) {
+    return Dialog(__assign({ showCancelButton: true }, options));
+};
+Dialog.close = function () {
+    queue.forEach(function (dialog) {
+        dialog.close();
+    });
+    queue = [];
+};
+Dialog.stopLoading = function () {
+    queue.forEach(function (dialog) {
+        dialog.stopLoading();
+    });
+};
+Dialog.currentOptions = currentOptions;
+Dialog.defaultOptions = defaultOptions;
+Dialog.setDefaultOptions = function (options) {
+    currentOptions = __assign(__assign({}, currentOptions), options);
+    Dialog.currentOptions = currentOptions;
+};
+Dialog.resetDefaultOptions = function () {
+    currentOptions = __assign({}, defaultOptions);
+    Dialog.currentOptions = currentOptions;
+};
+Dialog.resetDefaultOptions();
+exports.default = Dialog;

+ 1 - 0
src/wxcomponents/vant/dialog/index.d.ts

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

+ 135 - 0
src/wxcomponents/vant/dialog/index.js

@@ -0,0 +1,135 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+var component_1 = require("../common/component");
+var button_1 = require("../mixins/button");
+var color_1 = require("../common/color");
+var utils_1 = require("../common/utils");
+(0, component_1.VantComponent)({
+    mixins: [button_1.button],
+    classes: ['cancle-button-class', 'confirm-button-class'],
+    props: {
+        show: {
+            type: Boolean,
+            observer: function (show) {
+                !show && this.stopLoading();
+            },
+        },
+        title: String,
+        message: String,
+        theme: {
+            type: String,
+            value: 'default',
+        },
+        confirmButtonId: String,
+        className: String,
+        customStyle: String,
+        asyncClose: Boolean,
+        messageAlign: String,
+        beforeClose: null,
+        overlayStyle: String,
+        useSlot: Boolean,
+        useTitleSlot: Boolean,
+        useConfirmButtonSlot: Boolean,
+        useCancelButtonSlot: Boolean,
+        showCancelButton: Boolean,
+        closeOnClickOverlay: Boolean,
+        confirmButtonOpenType: String,
+        width: null,
+        zIndex: {
+            type: Number,
+            value: 2000,
+        },
+        confirmButtonText: {
+            type: String,
+            value: '确认',
+        },
+        cancelButtonText: {
+            type: String,
+            value: '取消',
+        },
+        confirmButtonColor: {
+            type: String,
+            value: color_1.RED,
+        },
+        cancelButtonColor: {
+            type: String,
+            value: color_1.GRAY,
+        },
+        showConfirmButton: {
+            type: Boolean,
+            value: true,
+        },
+        overlay: {
+            type: Boolean,
+            value: true,
+        },
+        transition: {
+            type: String,
+            value: 'scale',
+        },
+        rootPortal: {
+            type: Boolean,
+            value: false,
+        },
+    },
+    data: {
+        loading: {
+            confirm: false,
+            cancel: false,
+        },
+        callback: (function () { }),
+    },
+    methods: {
+        onConfirm: function () {
+            this.handleAction('confirm');
+        },
+        onCancel: function () {
+            this.handleAction('cancel');
+        },
+        onClickOverlay: function () {
+            this.close('overlay');
+        },
+        close: function (action) {
+            var _this = this;
+            this.setData({ show: false });
+            wx.nextTick(function () {
+                _this.$emit('close', action);
+                var callback = _this.data.callback;
+                if (callback) {
+                    callback(action, _this);
+                }
+            });
+        },
+        stopLoading: function () {
+            this.setData({
+                loading: {
+                    confirm: false,
+                    cancel: false,
+                },
+            });
+        },
+        handleAction: function (action) {
+            var _a;
+            var _this = this;
+            this.$emit(action, { dialog: this });
+            var _b = this.data, asyncClose = _b.asyncClose, beforeClose = _b.beforeClose;
+            if (!asyncClose && !beforeClose) {
+                this.close(action);
+                return;
+            }
+            this.setData((_a = {},
+                _a["loading.".concat(action)] = true,
+                _a));
+            if (beforeClose) {
+                (0, utils_1.toPromise)(beforeClose(action)).then(function (value) {
+                    if (value) {
+                        _this.close(action);
+                    }
+                    else {
+                        _this.stopLoading();
+                    }
+                });
+            }
+        },
+    },
+});

+ 9 - 0
src/wxcomponents/vant/dialog/index.json

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

+ 125 - 0
src/wxcomponents/vant/dialog/index.wxml

@@ -0,0 +1,125 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+
+<van-popup
+  show="{{ show }}"
+  z-index="{{ zIndex }}"
+  overlay="{{ overlay }}"
+  transition="{{ transition }}"
+  custom-class="van-dialog van-dialog--{{ theme }}{{ className }} custom-class"
+  custom-style="width: {{ utils.addUnit(width) }};{{ customStyle }}"
+  overlay-style="{{ overlayStyle }}"
+  close-on-click-overlay="{{ closeOnClickOverlay }}"
+  root-portal="{{ rootPortal }}"
+  bind:close="onClickOverlay"
+>
+  <view
+    wx:if="{{ title || useTitleSlot  }}"
+    class="{{ utils.bem('dialog__header', { isolated: !(message || useSlot) }) }}"
+  >
+    <slot wx:if="{{ useTitleSlot }}" name="title" />
+    <block wx:elif="{{ title }}">{{ title }}</block>
+  </view>
+
+  <slot wx:if="{{ useSlot }}" />
+  <view
+    wx:elif="{{ message }}"
+    class="{{ utils.bem('dialog__message', [theme, messageAlign, { hasTitle: title }]) }}"
+  >
+    <text class="van-dialog__message-text">{{ message }}</text>
+  </view>
+
+  <van-goods-action wx:if="{{ theme === 'round-button' }}" custom-class="van-dialog__footer--round-button">
+    <van-goods-action-button
+      wx:if="{{ showCancelButton }}"
+      size="large"
+      loading="{{ loading.cancel }}"
+      class="van-dialog__button van-hairline--right"
+      custom-class="van-dialog__cancel cancle-button-class"
+      custom-style="color: {{ cancelButtonColor }}"
+      bind:click="onCancel"
+    >
+      {{ cancelButtonText }}
+    </van-goods-action-button>
+    <van-goods-action-button
+      wx:if="{{ showConfirmButton }}"
+      size="large"
+      class="van-dialog__button"
+      loading="{{ loading.confirm }}"
+      custom-class="van-dialog__confirm confirm-button-class"
+      custom-style="color: {{ confirmButtonColor }}"
+      button-id="{{ confirmButtonId }}"
+      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 }}"
+      bindagreeprivacyauthorization="onAgreePrivacyAuthorization"
+      bindgetRealTimePhoneNumber="onGetRealTimePhoneNumber"
+      bind:click="onConfirm"
+      bindgetuserinfo="onGetUserInfo"
+      bindcontact="onContact"
+      bindgetphonenumber="onGetPhoneNumber"
+      binderror="onError"
+      bindlaunchapp="onLaunchApp"
+      bindopensetting="onOpenSetting"
+    >
+      {{ confirmButtonText }}
+    </van-goods-action-button>
+  </van-goods-action>
+
+  <view wx:elif="{{ showCancelButton || showConfirmButton }}" class="van-hairline--top van-dialog__footer">
+    <block wx:if="{{ showCancelButton }}">
+      <slot wx:if="{{ useCancelButtonSlot }}" name="cancel-button" />
+
+      <van-button
+        wx:else
+        size="large"
+        loading="{{ loading.cancel }}"
+        class="van-dialog__button van-hairline--right"
+        custom-class="van-dialog__cancel cancle-button-class"
+        custom-style="color: {{ cancelButtonColor }}"
+        bind:click="onCancel"
+      >
+        {{ cancelButtonText }}
+      </van-button>
+    </block>
+
+    <block wx:if="{{ showConfirmButton }}">
+      <slot wx:if="{{ useConfirmButtonSlot }}" name="confirm-button" />
+
+      <van-button
+        wx:else
+        size="large"
+        class="van-dialog__button"
+        loading="{{ loading.confirm }}"
+        custom-class="van-dialog__confirm confirm-button-class"
+        custom-style="color: {{ confirmButtonColor }}"
+        button-id="{{ confirmButtonId }}"
+        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 }}"
+        bindagreeprivacyauthorization="onAgreePrivacyAuthorization"
+        bindgetRealTimePhoneNumber="onGetRealTimePhoneNumber"
+        bind:click="onConfirm"
+        bindgetuserinfo="onGetUserInfo"
+        bindcontact="onContact"
+        bindgetphonenumber="onGetPhoneNumber"
+        binderror="onError"
+        bindlaunchapp="onLaunchApp"
+        bindopensetting="onOpenSetting"
+      >
+        {{ confirmButtonText }}
+      </van-button>
+    </block>
+  </view>
+</van-popup>

+ 1 - 0
src/wxcomponents/vant/dialog/index.wxss

@@ -0,0 +1 @@
+@import '../common/index.wxss';.van-dialog{background-color:var(--dialog-background-color,#fff);border-radius:var(--dialog-border-radius,16px);font-size:var(--dialog-font-size,16px);overflow:hidden;top:45%!important;width:var(--dialog-width,320px)}@media (max-width:321px){.van-dialog{width:var(--dialog-small-screen-width,90%)}}.van-dialog__header{font-weight:var(--dialog-header-font-weight,500);line-height:var(--dialog-header-line-height,24px);padding-top:var(--dialog-header-padding-top,24px);text-align:center}.van-dialog__header--isolated{padding:var(--dialog-header-isolated-padding,24px 0)}.van-dialog__message{-webkit-overflow-scrolling:touch;font-size:var(--dialog-message-font-size,14px);line-height:var(--dialog-message-line-height,20px);max-height:var(--dialog-message-max-height,60vh);overflow-y:auto;padding:var(--dialog-message-padding,24px);text-align:center}.van-dialog__message-text{word-wrap:break-word}.van-dialog__message--hasTitle{color:var(--dialog-has-title-message-text-color,#646566);padding-top:var(--dialog-has-title-message-padding-top,8px)}.van-dialog__message--round-button{color:#323233;padding-bottom:16px}.van-dialog__message--left{text-align:left}.van-dialog__message--right{text-align:right}.van-dialog__message--justify{text-align:justify}.van-dialog__footer{display:flex}.van-dialog__footer--round-button{padding:8px 24px 16px!important;position:relative!important}.van-dialog__button{flex:1}.van-dialog__cancel,.van-dialog__confirm{border:0!important}.van-dialog-bounce-enter{opacity:0;transform:translate3d(-50%,-50%,0) scale(.7)}.van-dialog-bounce-leave-active{opacity:0;transform:translate3d(-50%,-50%,0) scale(.9)}

+ 1 - 0
src/wxcomponents/vant/field/index.d.ts

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

+ 152 - 0
src/wxcomponents/vant/field/index.js

@@ -0,0 +1,152 @@
+"use strict";
+var __assign = (this && this.__assign) || function () {
+    __assign = Object.assign || function(t) {
+        for (var s, i = 1, n = arguments.length; i < n; i++) {
+            s = arguments[i];
+            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
+                t[p] = s[p];
+        }
+        return t;
+    };
+    return __assign.apply(this, arguments);
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+var utils_1 = require("../common/utils");
+var component_1 = require("../common/component");
+var props_1 = require("./props");
+(0, component_1.VantComponent)({
+    field: true,
+    classes: ['input-class', 'right-icon-class', 'label-class'],
+    props: __assign(__assign(__assign(__assign({}, props_1.commonProps), props_1.inputProps), props_1.textareaProps), { size: String, icon: String, label: String, error: Boolean, center: Boolean, isLink: Boolean, leftIcon: String, rightIcon: String, autosize: null, required: Boolean, iconClass: String, clickable: Boolean, inputAlign: String, customStyle: String, errorMessage: String, arrowDirection: String, showWordLimit: Boolean, errorMessageAlign: String, readonly: {
+            type: Boolean,
+            observer: 'setShowClear',
+        }, clearable: {
+            type: Boolean,
+            observer: 'setShowClear',
+        }, clearTrigger: {
+            type: String,
+            value: 'focus',
+        }, border: {
+            type: Boolean,
+            value: true,
+        }, titleWidth: {
+            type: String,
+            value: '6.2em',
+        }, clearIcon: {
+            type: String,
+            value: 'clear',
+        }, extraEventParams: {
+            type: Boolean,
+            value: false,
+        } }),
+    data: {
+        focused: false,
+        innerValue: '',
+        showClear: false,
+    },
+    watch: {
+        value: function (value) {
+            if (value !== this.value) {
+                this.setData({ innerValue: value });
+                this.value = value;
+                this.setShowClear();
+            }
+        },
+        clearTrigger: function () {
+            this.setShowClear();
+        },
+    },
+    created: function () {
+        this.value = this.data.value;
+        this.setData({ innerValue: this.value });
+    },
+    methods: {
+        formatValue: function (value) {
+            var maxlength = this.data.maxlength;
+            if (maxlength !== -1 && value.length > maxlength) {
+                return value.slice(0, maxlength);
+            }
+            return value;
+        },
+        onInput: function (event) {
+            var _a = (event.detail || {}).value, value = _a === void 0 ? '' : _a;
+            var formatValue = this.formatValue(value);
+            this.value = formatValue;
+            this.setShowClear();
+            return this.emitChange(__assign(__assign({}, event.detail), { value: formatValue }));
+        },
+        onFocus: function (event) {
+            this.focused = true;
+            this.setShowClear();
+            this.$emit('focus', event.detail);
+        },
+        onBlur: function (event) {
+            this.focused = false;
+            this.setShowClear();
+            this.$emit('blur', event.detail);
+        },
+        onClickIcon: function () {
+            this.$emit('click-icon');
+        },
+        onClickInput: function (event) {
+            this.$emit('click-input', event.detail);
+        },
+        onClear: function () {
+            var _this = this;
+            this.setData({ innerValue: '' });
+            this.value = '';
+            this.setShowClear();
+            (0, utils_1.nextTick)(function () {
+                _this.emitChange({ value: '' });
+                _this.$emit('clear', '');
+            });
+        },
+        onConfirm: function (event) {
+            var _a = (event.detail || {}).value, value = _a === void 0 ? '' : _a;
+            this.value = value;
+            this.setShowClear();
+            this.$emit('confirm', value);
+        },
+        setValue: function (value) {
+            this.value = value;
+            this.setShowClear();
+            if (value === '') {
+                this.setData({ innerValue: '' });
+            }
+            this.emitChange({ value: value });
+        },
+        onLineChange: function (event) {
+            this.$emit('linechange', event.detail);
+        },
+        onKeyboardHeightChange: function (event) {
+            this.$emit('keyboardheightchange', event.detail);
+        },
+        onBindNicknameReview: function (event) {
+            this.$emit('nicknamereview', event.detail);
+        },
+        emitChange: function (detail) {
+            var extraEventParams = this.data.extraEventParams;
+            this.setData({ value: detail.value });
+            var result;
+            var data = extraEventParams
+                ? __assign(__assign({}, detail), { callback: function (data) {
+                        result = data;
+                    } }) : detail.value;
+            this.$emit('input', data);
+            this.$emit('change', data);
+            return result;
+        },
+        setShowClear: function () {
+            var _a = this.data, clearable = _a.clearable, readonly = _a.readonly, clearTrigger = _a.clearTrigger;
+            var _b = this, focused = _b.focused, value = _b.value;
+            var showClear = false;
+            if (clearable && !readonly) {
+                var hasValue = !!value;
+                var trigger = clearTrigger === 'always' || (clearTrigger === 'focus' && focused);
+                showClear = hasValue && trigger;
+            }
+            this.setView({ showClear: showClear });
+        },
+        noop: function () { },
+    },
+});

+ 7 - 0
src/wxcomponents/vant/field/index.json

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

+ 56 - 0
src/wxcomponents/vant/field/index.wxml

@@ -0,0 +1,56 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+<wxs src="./index.wxs" module="computed" />
+
+<van-cell
+  size="{{ size }}"
+  icon="{{ leftIcon }}"
+  center="{{ center }}"
+  border="{{ border }}"
+  is-link="{{ isLink }}"
+  required="{{ required }}"
+  clickable="{{ clickable }}"
+  title-width="{{ titleWidth }}"
+  title-style="margin-right: 12px;"
+  custom-style="{{ customStyle }}"
+  arrow-direction="{{ arrowDirection }}"
+  custom-class="custom-class van-field"
+>
+  <slot name="left-icon" slot="icon" />
+  <label for="{{ name }}" wx:if="{{ label }}" class="label-class {{ utils.bem('field__label', { disabled }) }}" slot="title">
+    {{ label }}
+  </label>
+  <slot wx:else name="label" slot="title" />
+  <view class="{{ utils.bem('field__body', [type]) }}">
+    <view class="{{ utils.bem('field__control', [inputAlign, 'custom']) }}" bindtap="onClickInput">
+      <slot name="input" />
+    </view>
+    <include wx:if="{{ type === 'textarea' }}" src="./textarea.wxml" />
+    <include wx:else src="./input.wxml" />
+
+    <van-icon
+      wx:if="{{ showClear }}"
+      name="{{ clearIcon }}"
+      class="van-field__clear-root van-field__icon-root"
+      catch:touchstart="onClear"
+    />
+    <view class="van-field__icon-container" bind:tap="onClickIcon">
+      <van-icon
+        wx:if="{{ rightIcon || icon }}"
+        name="{{ rightIcon || icon }}"
+        class="van-field__icon-root {{ iconClass }}"
+        custom-class="right-icon-class"
+      />
+      <slot name="right-icon" />
+      <slot name="icon" />
+    </view>
+    <view class="van-field__button">
+      <slot name="button" />
+    </view>
+  </view>
+  <label for="{{ name }}" wx:if="{{ showWordLimit && maxlength }}" class="van-field__word-limit">
+    <view class="{{ utils.bem('field__word-num', { full: value.length >= maxlength }) }}">{{ value.length >= maxlength ? maxlength : value.length }}</view>/{{ maxlength }}
+  </label>
+  <label for="{{ name }}"  wx:if="{{ errorMessage }}" class="{{ utils.bem('field__error-message', [errorMessageAlign, { disabled, error }]) }}">
+    {{ errorMessage }}
+  </label>
+</van-cell>

+ 18 - 0
src/wxcomponents/vant/field/index.wxs

@@ -0,0 +1,18 @@
+/* eslint-disable */
+var style = require('../wxs/style.wxs');
+var addUnit = require('../wxs/add-unit.wxs');
+
+function inputStyle(autosize) {
+  if (autosize && autosize.constructor === 'Object') {
+    return style({
+      'min-height': addUnit(autosize.minHeight),
+      'max-height': addUnit(autosize.maxHeight),
+    });
+  }
+
+  return '';
+}
+
+module.exports = {
+  inputStyle: inputStyle,
+};

File diff suppressed because it is too large
+ 0 - 0
src/wxcomponents/vant/field/index.wxss


+ 31 - 0
src/wxcomponents/vant/field/input.wxml

@@ -0,0 +1,31 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+<input
+  id="{{ name }}"
+  class="{{ utils.bem('field__control', [inputAlign, { disabled, error }]) }} input-class"
+  type="{{ type }}"
+  focus="{{ focus }}"
+  cursor="{{ cursor }}"
+  value="{{ innerValue }}"
+  auto-focus="{{ autoFocus }}"
+  disabled="{{ disabled || readonly }}"
+  maxlength="{{ maxlength }}"
+  placeholder="{{ placeholder }}"
+  placeholder-style="{{ placeholderStyle }}"
+  placeholder-class="{{ utils.bem('field__placeholder', { error }) }}"
+  confirm-type="{{ confirmType }}"
+  confirm-hold="{{ confirmHold }}"
+  hold-keyboard="{{ holdKeyboard }}"
+  cursor-spacing="{{ cursorSpacing }}"
+  adjust-position="{{ adjustPosition }}"
+  selection-end="{{ selectionEnd }}"
+  selection-start="{{ selectionStart }}"
+  always-embed="{{ alwaysEmbed }}"
+  password="{{ password || type === 'password' }}"
+  bindinput="onInput"
+  bindtap="onClickInput"
+  bindblur="onBlur"
+  bindfocus="onFocus"
+  bindconfirm="onConfirm"
+  bindkeyboardheightchange="onKeyboardHeightChange"
+  bindnicknamereview="onBindNicknameReview"
+/>

+ 4 - 0
src/wxcomponents/vant/field/props.d.ts

@@ -0,0 +1,4 @@
+/// <reference types="miniprogram-api-typings" />
+export declare const commonProps: WechatMiniprogram.Component.PropertyOption;
+export declare const inputProps: WechatMiniprogram.Component.PropertyOption;
+export declare const textareaProps: WechatMiniprogram.Component.PropertyOption;

+ 59 - 0
src/wxcomponents/vant/field/props.js

@@ -0,0 +1,59 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.textareaProps = exports.inputProps = exports.commonProps = void 0;
+exports.commonProps = {
+    value: String,
+    placeholder: String,
+    placeholderStyle: String,
+    placeholderClass: String,
+    disabled: Boolean,
+    maxlength: {
+        type: Number,
+        value: -1,
+    },
+    cursorSpacing: {
+        type: Number,
+        value: 50,
+    },
+    autoFocus: Boolean,
+    focus: Boolean,
+    cursor: {
+        type: Number,
+        value: -1,
+    },
+    selectionStart: {
+        type: Number,
+        value: -1,
+    },
+    selectionEnd: {
+        type: Number,
+        value: -1,
+    },
+    adjustPosition: {
+        type: Boolean,
+        value: true,
+    },
+    holdKeyboard: Boolean,
+};
+exports.inputProps = {
+    type: {
+        type: String,
+        value: 'text',
+    },
+    password: Boolean,
+    confirmType: String,
+    confirmHold: Boolean,
+    alwaysEmbed: Boolean,
+};
+exports.textareaProps = {
+    autoHeight: Boolean,
+    fixed: Boolean,
+    showConfirmBar: {
+        type: Boolean,
+        value: true,
+    },
+    disableDefaultPadding: {
+        type: Boolean,
+        value: true,
+    },
+};

+ 32 - 0
src/wxcomponents/vant/field/textarea.wxml

@@ -0,0 +1,32 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+<wxs src="./index.wxs" module="computed" />
+<textarea
+  id="{{ name }}"
+  class="{{ utils.bem('field__control', [inputAlign, type, { disabled, error }]) }} input-class"
+  fixed="{{ fixed }}"
+  focus="{{ focus }}"
+  cursor="{{ cursor }}"
+  value="{{ innerValue }}"
+  auto-focus="{{ autoFocus }}"
+  disabled="{{ disabled || readonly }}"
+  maxlength="{{ maxlength }}"
+  placeholder="{{ placeholder }}"
+  placeholder-style="{{ placeholderStyle }}"
+  placeholder-class="{{ utils.bem('field__placeholder', { error, disabled }) }}"
+  auto-height="{{ !!autosize }}"
+  style="{{ computed.inputStyle(autosize) }}"
+  cursor-spacing="{{ cursorSpacing }}"
+  adjust-position="{{ adjustPosition }}"
+  show-confirm-bar="{{ showConfirmBar }}"
+  hold-keyboard="{{ holdKeyboard }}"
+  selection-end="{{ selectionEnd }}"
+  selection-start="{{ selectionStart }}"
+  disable-default-padding="{{ disableDefaultPadding }}"
+  bindinput="onInput"
+  bindtap="onClickInput"
+  bindblur="onBlur"
+  bindfocus="onFocus"
+  bindconfirm="onConfirm"
+  bindlinechange="onLineChange"
+  bindkeyboardheightchange="onKeyboardHeightChange"
+/>

+ 8 - 0
src/wxcomponents/vant/field/types.d.ts

@@ -0,0 +1,8 @@
+export interface InputDetails {
+    /** 输入框内容 */
+    value: string;
+    /** 光标位置 */
+    cursor?: number;
+    /** keyCode 为键值 (目前工具还不支持返回keyCode参数) `2.1.0` 起支持 */
+    keyCode?: number;
+}

+ 2 - 0
src/wxcomponents/vant/field/types.js

@@ -0,0 +1,2 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });

+ 1 - 0
src/wxcomponents/vant/icon/index.d.ts

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

+ 23 - 0
src/wxcomponents/vant/icon/index.js

@@ -0,0 +1,23 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+var component_1 = require("../common/component");
+(0, component_1.VantComponent)({
+    classes: ['info-class'],
+    props: {
+        dot: Boolean,
+        info: null,
+        size: null,
+        color: String,
+        customStyle: String,
+        classPrefix: {
+            type: String,
+            value: 'van-icon',
+        },
+        name: String,
+    },
+    methods: {
+        onClick: function () {
+            this.$emit('click');
+        },
+    },
+});

+ 6 - 0
src/wxcomponents/vant/icon/index.json

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

+ 20 - 0
src/wxcomponents/vant/icon/index.wxml

@@ -0,0 +1,20 @@
+<wxs src="./index.wxs" module="computed" />
+
+<view
+  class="{{ computed.rootClass({ classPrefix, name }) }}"
+  style="{{ computed.rootStyle({ customStyle, color, size }) }}"
+  bindtap="onClick"
+>
+  <van-info
+    wx:if="{{ info !== null || dot }}"
+    dot="{{ dot }}"
+    info="{{ info }}"
+    custom-class="van-icon__info info-class"
+  />
+  <image
+    wx:if="{{ computed.isImage(name) }}"
+    src="{{ name }}"
+    mode="aspectFit"
+    class="van-icon__image"
+  />
+</view>

+ 43 - 0
src/wxcomponents/vant/icon/index.wxs

@@ -0,0 +1,43 @@
+/* eslint-disable */
+var style = require('../wxs/style.wxs');
+var addUnit = require('../wxs/add-unit.wxs');
+
+function isImage(name) {
+  return name.indexOf('/') !== -1;
+}
+
+function rootClass(data) {
+  var classes = ['custom-class'];
+
+  if (data.classPrefix !== 'van-icon') {
+    classes.push('van-icon--custom')
+  }
+
+  if (data.classPrefix != null) {
+    classes.push(data.classPrefix);
+  }
+
+  if (isImage(data.name)) {
+    classes.push('van-icon--image');
+  } else if (data.classPrefix != null) {
+    classes.push(data.classPrefix + '-' + data.name);
+  }
+
+  return classes.join(' ');
+}
+
+function rootStyle(data) {
+  return style([
+    {
+      color: data.color,
+      'font-size': addUnit(data.size),
+    },
+    data.customStyle,
+  ]);
+}
+
+module.exports = {
+  isImage: isImage,
+  rootClass: rootClass,
+  rootStyle: rootStyle,
+};

File diff suppressed because it is too large
+ 0 - 0
src/wxcomponents/vant/icon/index.wxss


Some files were not shown because too many files changed in this diff