瀏覽代碼

新增权限

XWookey 1 年之前
父節點
當前提交
da56a567f8
共有 100 個文件被更改,包括 1949 次插入9 次删除
  1. 2 1
      app.json
  2. 48 2
      pages/index/index.js
  3. 3 1
      pages/index/index.json
  4. 25 3
      pages/index/index.wxml
  5. 73 1
      pages/index/index.wxss
  6. 1 1
      project.private.config.json
  7. 1 0
      vant/button/index.d.ts
  8. 64 0
      vant/button/index.js
  9. 7 0
      vant/button/index.json
  10. 56 0
      vant/button/index.wxml
  11. 39 0
      vant/button/index.wxs
  12. 0 0
      vant/button/index.wxss
  13. 7 0
      vant/common/color.d.ts
  14. 7 0
      vant/common/color.js
  15. 4 0
      vant/common/component.d.ts
  16. 46 0
      vant/common/component.js
  17. 1 0
      vant/common/index.wxss
  18. 15 0
      vant/common/relation.d.ts
  19. 56 0
      vant/common/relation.js
  20. 1 0
      vant/common/style/clearfix.wxss
  21. 1 0
      vant/common/style/ellipsis.wxss
  22. 1 0
      vant/common/style/hairline.wxss
  23. 0 0
      vant/common/style/mixins/clearfix.wxss
  24. 0 0
      vant/common/style/mixins/ellipsis.wxss
  25. 0 0
      vant/common/style/mixins/hairline.wxss
  26. 0 0
      vant/common/style/var.wxss
  27. 20 0
      vant/common/utils.d.ts
  28. 84 0
      vant/common/utils.js
  29. 9 0
      vant/common/validator.d.ts
  30. 31 0
      vant/common/validator.js
  31. 9 0
      vant/common/version.d.ts
  32. 59 0
      vant/common/version.js
  33. 55 0
      vant/dialog/dialog.d.ts
  34. 77 0
      vant/dialog/dialog.js
  35. 1 0
      vant/dialog/index.d.ts
  36. 126 0
      vant/dialog/index.js
  37. 9 0
      vant/dialog/index.json
  38. 122 0
      vant/dialog/index.wxml
  39. 1 0
      vant/dialog/index.wxss
  40. 1 0
      vant/goods-action-button/index.d.ts
  41. 40 0
      vant/goods-action-button/index.js
  42. 6 0
      vant/goods-action-button/index.json
  43. 33 0
      vant/goods-action-button/index.wxml
  44. 1 0
      vant/goods-action-button/index.wxss
  45. 1 0
      vant/goods-action-icon/index.d.ts
  46. 27 0
      vant/goods-action-icon/index.js
  47. 7 0
      vant/goods-action-icon/index.json
  48. 41 0
      vant/goods-action-icon/index.wxml
  49. 1 0
      vant/goods-action-icon/index.wxss
  50. 1 0
      vant/goods-action/index.d.ts
  51. 15 0
      vant/goods-action/index.js
  52. 3 0
      vant/goods-action/index.json
  53. 5 0
      vant/goods-action/index.wxml
  54. 1 0
      vant/goods-action/index.wxss
  55. 1 0
      vant/icon/index.d.ts
  56. 21 0
      vant/icon/index.js
  57. 6 0
      vant/icon/index.json
  58. 20 0
      vant/icon/index.wxml
  59. 43 0
      vant/icon/index.wxs
  60. 0 0
      vant/icon/index.wxss
  61. 1 0
      vant/info/index.d.ts
  62. 8 0
      vant/info/index.js
  63. 3 0
      vant/info/index.json
  64. 7 0
      vant/info/index.wxml
  65. 1 0
      vant/info/index.wxss
  66. 1 0
      vant/loading/index.d.ts
  67. 16 0
      vant/loading/index.js
  68. 3 0
      vant/loading/index.json
  69. 19 0
      vant/loading/index.wxml
  70. 22 0
      vant/loading/index.wxs
  71. 0 0
      vant/loading/index.wxss
  72. 1 0
      vant/mixins/basic.d.ts
  73. 11 0
      vant/mixins/basic.js
  74. 1 0
      vant/mixins/button.d.ts
  75. 51 0
      vant/mixins/button.js
  76. 1 0
      vant/mixins/link.d.ts
  77. 23 0
      vant/mixins/link.js
  78. 6 0
      vant/mixins/page-scroll.d.ts
  79. 42 0
      vant/mixins/page-scroll.js
  80. 1 0
      vant/mixins/touch.d.ts
  81. 37 0
      vant/mixins/touch.js
  82. 1 0
      vant/mixins/transition.d.ts
  83. 118 0
      vant/mixins/transition.js
  84. 1 0
      vant/overlay/index.d.ts
  85. 30 0
      vant/overlay/index.js
  86. 6 0
      vant/overlay/index.json
  87. 7 0
      vant/overlay/index.wxml
  88. 1 0
      vant/overlay/index.wxss
  89. 10 0
      vant/overlay/overlay.wxml
  90. 1 0
      vant/popup/index.d.ts
  91. 97 0
      vant/popup/index.js
  92. 7 0
      vant/popup/index.json
  93. 21 0
      vant/popup/index.wxml
  94. 18 0
      vant/popup/index.wxs
  95. 0 0
      vant/popup/index.wxss
  96. 14 0
      vant/popup/popup.wxml
  97. 1 0
      vant/transition/index.d.ts
  98. 13 0
      vant/transition/index.js
  99. 3 0
      vant/transition/index.json
  100. 10 0
      vant/transition/index.wxml

+ 2 - 1
app.json

@@ -70,5 +70,6 @@
     "connectSocket": 300000
   },
   "debug": false,
-  "sitemapLocation": "sitemap.json"
+  "sitemapLocation": "sitemap.json",
+  "__usePrivacyCheck__": true
 }

+ 48 - 2
pages/index/index.js

@@ -78,7 +78,8 @@ Page({
     }],
     showModal: false,
     notice: null,
-    carParkingRate: false
+    carParkingRate: false,
+    showPrivacy:false
   },
   howtouse(){
     wx.navigateTo({
@@ -236,6 +237,32 @@ Page({
   },
 
   onLoad(e) {
+    // 隐私开始
+    wx.getPrivacySetting({
+        success: res => {
+          console.log(res) // 返回结果为: res = { needAuthorization: true/false, privacyContractName: '《xxx隐私保护指引》' }
+          if (res.needAuthorization) {
+            // 需要弹出隐私协议
+            this.setData({
+              showPrivacy: true
+            })
+          } else {
+            // 用户已经同意过隐私协议,所以不需要再弹出隐私协议,也能调用已声明过的隐私接口
+            // wx.getUserProfile()
+            // wx.chooseMedia()
+            // wx.getClipboardData()
+            // wx.startRecord()
+          }
+        },
+        fail: () => {},
+        complete: () => {}
+      })
+  
+
+
+    // 隐私结束
+
+
    this.data.scanFlag = false;
     wx.hideLoading();
     if (e.q) {
@@ -1146,6 +1173,25 @@ Page({
     this.setData({
       showModal: false
     });
+  },
+  handleAgreePrivacyAuthorization() {
+      console.info('3333333333333');
+      this.setData({
+        showPrivacy: false
+      })
+    // 用户同意隐私协议事件回调
+    // 用户点击了同意,之后所有已声明过的隐私接口和组件都可以调用了
+    // wx.getUserProfile()
+    // wx.chooseMedia()
+    // wx.getClipboardData()
+    // wx.startRecord()
+  },
+  handleOpenPrivacyContract() {
+    // 打开隐私协议页面
+    wx.openPrivacyContract({
+      success: () => {}, // 打开成功
+      fail: () => {}, // 打开失败
+      complete: () => {}
+    })
   }
-  
 })

+ 3 - 1
pages/index/index.json

@@ -1,5 +1,7 @@
 {
     "navigationBarTitleText": "派捷充电",
-    "usingComponents": {}
+    "usingComponents": {
+        "van-dialog": "/vant/dialog/index"
+    }
 
 }

+ 25 - 3
pages/index/index.wxml

@@ -27,10 +27,10 @@
           <text>距离{{distanceinfo[distanceinfoindex].text}}</text>
         </picker>
       </view>
-      <cover-view class='map_location' bindtap='click_location_control' hover-class='map_location_hover'>
+      <cover-view  wx:if='{{(!(!(textData.name)&&showModal&&notice.noticeTitle))  && (!showPrivacy)}}' class='map_location' bindtap='click_location_control' hover-class='map_location_hover'>
         <cover-image class='circle1' src='/images/circle1.png'></cover-image>
       </cover-view>
-      <cover-view wx:if='{{!(!(textData.name)&&showModal&&notice.noticeTitle)}}' class='map_center'>
+      <cover-view wx:if='{{(!(!(textData.name)&&showModal&&notice.noticeTitle))  && (!showPrivacy)}}' class='map_center'>
         <cover-image src='/images/map_center.png'></cover-image>
       </cover-view>
     </map>
@@ -65,12 +65,34 @@
     </view>
   </view>
 </view>
-<view wx:if='{{!(textData.name)&&showModal&&notice.noticeTitle}}'>
+
+<!-- 通知 -->
+<van-dialog custom-class="privacy_box" 
+use-slot
+width="300"
+custom-class="privacy_box_modal"
+show-confirm-button="{{false}}"
+show ="{{showPrivacy}}"
+>  
+<view class="privacy_box">
+<text class="title">个人信息保护指引</text>
+<text style="height:40rpx">感谢您使用派捷充电!</text>
+<text style="height:140rpx">为向您提供更好的充电服务,在使用我们的产品前,请您阅读并同意<text bindtap="handleOpenPrivacyContract" class="userPrivacy">《用户隐私保护指引》</text>。
+</text>
+<text style="height:150rpx">当您点击同意并开始使用产品服务时,即表示你已理解并同意该条款内容,该条款将对您产生法律约束力。如您拒绝,将无法使用相关产品服务。</text>
+<button class="agree" id="agree-btn" open-type="agreePrivacyAuthorization" bindagreeprivacyauthorization="handleAgreePrivacyAuthorization">同意并继续</button>
+   <navigator class="reject" open-type="exit" target="miniProgram">不同意</navigator>
+</view>   
+</van-dialog>
+
+<!-- 公告 -->
+<view wx:if='{{(!(textData.name)&&showModal&&notice.noticeTitle) && (!showPrivacy)}}'>
 
   <view class="modal_box">
     <view class="title">
       <image src='/images/notice.png' />
     </view>
+    
     <view class="content_msg">
       <view class='content_title'>{{notice.noticeTitle}}</view>
       <view class='content'>

+ 73 - 1
pages/index/index.wxss

@@ -327,7 +327,7 @@ text.price {
   position: fixed;
   top: 50%;
   left: 0;
-  z-index:9999;
+  z-index:9998;
   margin: -416rpx 95rpx 0 95rpx;
 }
  
@@ -504,4 +504,76 @@ rich-text{
   color: #9d9d9d;
   line-height: 25rpx;
   padding-left: 5rpx;
+}
+
+
+/* 通知相关 begin */
+.privacy_box {
+    height: 545rpx;
+    /* overflow: hidden; */
+    /* position: fixed; */
+    /* top: 54%; */
+    /* z-index:9999; */
+    /* margin: -416rpx 95rpx 0 95rpx; */
+    background-color: #FFFFFF;
+    margin:40rpx 40rpx;
+    border-radius: 20rpx;
+  }
+
+  .privacy_box_modal{
+      width: 400rpx;
+  }
+
+  .privacy_box .title{
+      text-align: center;
+      width: initial;
+      background-color: initial;
+      margin: initial;
+      border-radius: initial;
+      font-size: 32rpx;
+      line-height: 38rpx;
+      margin-bottom: 20rpx;
+  }
+
+  .privacy_box text{
+    word-wrap: break-word;
+    word-break: break-all;
+    white-space: pre-line;
+    margin: initial;
+    height:initial;
+    min-height: initial;
+    font-size: 28rpx;
+    line-height: 40rpx;
+    text-align:justify;
+  }
+
+  .privacy_box text text{
+    display: inline;
+  }
+
+  .privacy_box .agree{
+      width:400rpx;
+      height: 60rpx;
+      font-size: 32rpx;
+      color:#FFFFFF;
+      line-height: 60rpx;
+      text-align: center;
+      background-color: #21ADFF;
+      border-radius: 10rpx;
+      margin: 5rpx auto ;
+      margin-top:50rpx;
+  }
+
+  .privacy_box .reject{
+    width:400rpx;
+    height: 60rpx;
+    font-size: 28rpx;
+    color:#848484;
+    line-height: 60rpx;
+    text-align: center;
+    margin: 5rpx auto ;
+}
+
+.userPrivacy{
+    color:#21ADFF;
 }

+ 1 - 1
project.private.config.json

@@ -4,5 +4,5 @@
   "setting": {
     "compileHotReLoad": true
   },
-  "libVersion": "3.0.0"
+  "libVersion": "3.0.2"
 }

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

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

+ 64 - 0
vant/button/index.js

@@ -0,0 +1,64 @@
+import { VantComponent } from '../common/component';
+import { button } from '../mixins/button';
+import { canIUseFormFieldButton } from '../common/version';
+const mixins = [button];
+if (canIUseFormFieldButton()) {
+    mixins.push('wx://form-field-button');
+}
+VantComponent({
+    mixins,
+    classes: ['hover-class', 'loading-class'],
+    data: {
+        baseStyle: '',
+    },
+    props: {
+        formType: String,
+        icon: String,
+        classPrefix: {
+            type: String,
+            value: 'van-icon',
+        },
+        plain: Boolean,
+        block: Boolean,
+        round: Boolean,
+        square: Boolean,
+        loading: Boolean,
+        hairline: Boolean,
+        disabled: Boolean,
+        loadingText: String,
+        customStyle: String,
+        loadingType: {
+            type: String,
+            value: 'circular',
+        },
+        type: {
+            type: String,
+            value: 'default',
+        },
+        dataset: null,
+        size: {
+            type: String,
+            value: 'normal',
+        },
+        loadingSize: {
+            type: String,
+            value: '20px',
+        },
+        color: String,
+    },
+    methods: {
+        onClick(event) {
+            this.$emit('click', event);
+            const { canIUseGetUserProfile, openType, getUserProfileDesc, lang, } = this.data;
+            if (openType === 'getUserInfo' && canIUseGetUserProfile) {
+                wx.getUserProfile({
+                    desc: getUserProfileDesc || '  ',
+                    lang: lang || 'en',
+                    complete: (userProfile) => {
+                        this.$emit('getuserinfo', userProfile);
+                    },
+                });
+            }
+        },
+    },
+});

+ 7 - 0
vant/button/index.json

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

+ 56 - 0
vant/button/index.wxml

@@ -0,0 +1,56 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+<wxs src="./index.wxs" module="computed" />
+
+<button
+  id="{{ id || buttonId }}"
+  data-detail="{{ dataset }}"
+  class="custom-class {{ utils.bem('button', [type, size, { block, round, plain, square, loading, disabled, hairline, unclickable: disabled || loading }]) }} {{ hairline ? 'van-hairline--surround' : '' }}"
+  hover-class="{{ disabled || loading ? '' : 'van-button--active hover-class'}}"
+  lang="{{ lang }}"
+  form-type="{{ formType }}"
+  style="{{ computed.rootStyle({ plain, color, customStyle }) }}"
+  open-type="{{ disabled || loading || (canIUseGetUserProfile && openType === 'getUserInfo') ? '' : openType }}"
+  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="{{ disabled || loading ? '' : 'onClick' }}"
+  bindgetuserinfo="onGetUserInfo"
+  bindcontact="onContact"
+  bindgetphonenumber="onGetPhoneNumber"
+  bindgetrealtimephonenumber="onGetRealTimePhoneNumber"
+  bindagreeprivacyauthorization="onAgreePrivacyAuthorization"
+  binderror="onError"
+  bindlaunchapp="onLaunchApp"
+  bindopensetting="onOpenSetting"
+  bindchooseavatar="onChooseAvatar"
+>
+  <block wx:if="{{ loading }}">
+    <van-loading
+      custom-class="loading-class"
+      size="{{ loadingSize }}"
+      type="{{ loadingType }}"
+      color="{{ computed.loadingColor({ type, color, plain }) }}"
+    />
+    <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-prefix="{{ classPrefix }}"
+      class="van-button__icon"
+      custom-style="line-height: inherit;"
+    />
+    <view class="van-button__text">
+      <slot />
+    </view>
+  </block>
+</button>

+ 39 - 0
vant/button/index.wxs

@@ -0,0 +1,39 @@
+/* eslint-disable */
+var style = require('../wxs/style.wxs');
+
+function rootStyle(data) {
+  if (!data.color) {
+    return data.customStyle;
+  }
+
+  var properties = {
+    color: data.plain ? data.color : '#fff',
+    background: data.plain ? null : data.color,
+  };
+
+  // hide border when color is linear-gradient
+  if (data.color.indexOf('gradient') !== -1) {
+    properties.border = 0;
+  } else {
+    properties['border-color'] = data.color;
+  }
+
+  return style([properties, data.customStyle]);
+}
+
+function loadingColor(data) {
+  if (data.plain) {
+    return data.color ? data.color : '#c9c9c9';
+  }
+
+  if (data.type === 'default') {
+    return '#c9c9c9';
+  }
+
+  return '#fff';
+}
+
+module.exports = {
+  rootStyle: rootStyle,
+  loadingColor: loadingColor,
+};

文件差異過大導致無法顯示
+ 0 - 0
vant/button/index.wxss


+ 7 - 0
vant/common/color.d.ts

@@ -0,0 +1,7 @@
+export declare const RED = "#ee0a24";
+export declare const BLUE = "#1989fa";
+export declare const WHITE = "#fff";
+export declare const GREEN = "#07c160";
+export declare const ORANGE = "#ff976a";
+export declare const GRAY = "#323233";
+export declare const GRAY_DARK = "#969799";

+ 7 - 0
vant/common/color.js

@@ -0,0 +1,7 @@
+export const RED = '#ee0a24';
+export const BLUE = '#1989fa';
+export const WHITE = '#fff';
+export const GREEN = '#07c160';
+export const ORANGE = '#ff976a';
+export const GRAY = '#323233';
+export const GRAY_DARK = '#969799';

+ 4 - 0
vant/common/component.d.ts

@@ -0,0 +1,4 @@
+/// <reference types="miniprogram-api-typings" />
+import { VantComponentOptions } from 'definitions/index';
+declare function VantComponent<Data extends WechatMiniprogram.Component.DataOption, Props extends WechatMiniprogram.Component.PropertyOption, Methods extends WechatMiniprogram.Component.MethodOption>(vantOptions: VantComponentOptions<Data, Props, Methods>): void;
+export { VantComponent };

+ 46 - 0
vant/common/component.js

@@ -0,0 +1,46 @@
+import { basic } from '../mixins/basic';
+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',
+        watch: 'observers',
+        mixins: 'behaviors',
+        methods: 'methods',
+        beforeCreate: 'created',
+        created: 'attached',
+        mounted: 'ready',
+        destroyed: 'detached',
+        classes: 'externalClasses',
+    });
+    // add default externalClasses
+    options.externalClasses = options.externalClasses || [];
+    options.externalClasses.push('custom-class');
+    // add default behaviors
+    options.behaviors = options.behaviors || [];
+    options.behaviors.push(basic);
+    // add relations
+    const { relation } = vantOptions;
+    if (relation) {
+        options.relations = relation.relations;
+        options.behaviors.push(relation.mixin);
+    }
+    // map field to form-field behavior
+    if (vantOptions.field) {
+        options.behaviors.push('wx://form-field');
+    }
+    // add default options
+    options.options = {
+        multipleSlots: true,
+        addGlobalClass: true,
+    };
+    Component(options);
+}
+export { VantComponent };

+ 1 - 0
vant/common/index.wxss

@@ -0,0 +1 @@
+.van-ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden;text-overflow:ellipsis}.van-multi-ellipsis--l3{-webkit-line-clamp:3}.van-clearfix:after{clear:both;content:"";display:table}.van-hairline,.van-hairline--bottom,.van-hairline--left,.van-hairline--right,.van-hairline--surround,.van-hairline--top,.van-hairline--top-bottom{position:relative}.van-hairline--bottom:after,.van-hairline--left:after,.van-hairline--right:after,.van-hairline--surround:after,.van-hairline--top-bottom:after,.van-hairline--top:after,.van-hairline:after{border:0 solid #ebedf0;bottom:-50%;box-sizing:border-box;content:" ";left:-50%;pointer-events:none;position:absolute;right:-50%;top:-50%;transform:scale(.5);transform-origin:center}.van-hairline--top:after{border-top-width:1px}.van-hairline--left:after{border-left-width:1px}.van-hairline--right:after{border-right-width:1px}.van-hairline--bottom:after{border-bottom-width:1px}.van-hairline--top-bottom:after{border-width:1px 0}.van-hairline--surround:after{border-width:1px}

+ 15 - 0
vant/common/relation.d.ts

@@ -0,0 +1,15 @@
+/// <reference types="miniprogram-api-typings" />
+type TrivialInstance = WechatMiniprogram.Component.TrivialInstance;
+export declare function useParent(name: string, onEffect?: (this: TrivialInstance) => void): {
+    relations: {
+        [x: string]: WechatMiniprogram.Component.RelationOption;
+    };
+    mixin: string;
+};
+export declare function useChildren(name: string, onEffect?: (this: TrivialInstance, target: TrivialInstance) => void): {
+    relations: {
+        [x: string]: WechatMiniprogram.Component.RelationOption;
+    };
+    mixin: string;
+};
+export {};

+ 56 - 0
vant/common/relation.js

@@ -0,0 +1,56 @@
+export function useParent(name, onEffect) {
+    const path = `../${name}/index`;
+    return {
+        relations: {
+            [path]: {
+                type: 'ancestor',
+                linked() {
+                    onEffect && onEffect.call(this);
+                },
+                linkChanged() {
+                    onEffect && onEffect.call(this);
+                },
+                unlinked() {
+                    onEffect && onEffect.call(this);
+                },
+            },
+        },
+        mixin: Behavior({
+            created() {
+                Object.defineProperty(this, 'parent', {
+                    get: () => this.getRelationNodes(path)[0],
+                });
+                Object.defineProperty(this, 'index', {
+                    // @ts-ignore
+                    get: () => { var _a, _b; return (_b = (_a = this.parent) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.indexOf(this); },
+                });
+            },
+        }),
+    };
+}
+export function useChildren(name, onEffect) {
+    const path = `../${name}/index`;
+    return {
+        relations: {
+            [path]: {
+                type: 'descendant',
+                linked(target) {
+                    onEffect && onEffect.call(this, target);
+                },
+                linkChanged(target) {
+                    onEffect && onEffect.call(this, target);
+                },
+                unlinked(target) {
+                    onEffect && onEffect.call(this, target);
+                },
+            },
+        },
+        mixin: Behavior({
+            created() {
+                Object.defineProperty(this, 'children', {
+                    get: () => this.getRelationNodes(path) || [],
+                });
+            },
+        }),
+    };
+}

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

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

+ 1 - 0
vant/common/style/ellipsis.wxss

@@ -0,0 +1 @@
+.van-ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden;text-overflow:ellipsis}.van-multi-ellipsis--l3{-webkit-line-clamp:3}

+ 1 - 0
vant/common/style/hairline.wxss

@@ -0,0 +1 @@
+.van-hairline,.van-hairline--bottom,.van-hairline--left,.van-hairline--right,.van-hairline--surround,.van-hairline--top,.van-hairline--top-bottom{position:relative}.van-hairline--bottom:after,.van-hairline--left:after,.van-hairline--right:after,.van-hairline--surround:after,.van-hairline--top-bottom:after,.van-hairline--top:after,.van-hairline:after{border:0 solid #ebedf0;bottom:-50%;box-sizing:border-box;content:" ";left:-50%;pointer-events:none;position:absolute;right:-50%;top:-50%;transform:scale(.5);transform-origin:center}.van-hairline--top:after{border-top-width:1px}.van-hairline--left:after{border-left-width:1px}.van-hairline--right:after{border-right-width:1px}.van-hairline--bottom:after{border-bottom-width:1px}.van-hairline--top-bottom:after{border-width:1px 0}.van-hairline--surround:after{border-width:1px}

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


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


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


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


+ 20 - 0
vant/common/utils.d.ts

@@ -0,0 +1,20 @@
+/// <reference types="node" />
+/// <reference types="miniprogram-api-typings" />
+/// <reference types="miniprogram-api-typings" />
+/// <reference types="miniprogram-api-typings" />
+/// <reference types="miniprogram-api-typings" />
+export { isDef } from './validator';
+export { getSystemInfoSync } from './version';
+export declare function range(num: number, min: number, max: number): number;
+export declare function nextTick(cb: (...args: any[]) => void): void;
+export declare function addUnit(value?: string | number): string | undefined;
+export declare function requestAnimationFrame(cb: () => void): NodeJS.Timeout;
+export declare function pickExclude(obj: unknown, keys: string[]): {};
+export declare function getRect(context: WechatMiniprogram.Component.TrivialInstance, selector: string): Promise<WechatMiniprogram.BoundingClientRectCallbackResult>;
+export declare function getAllRect(context: WechatMiniprogram.Component.TrivialInstance, selector: string): Promise<WechatMiniprogram.BoundingClientRectCallbackResult[]>;
+export declare function groupSetData(context: WechatMiniprogram.Component.TrivialInstance, cb: () => void): void;
+export declare function toPromise(promiseLike: Promise<unknown> | unknown): Promise<unknown>;
+export declare function addNumber(num1: any, num2: any): number;
+export declare const clamp: (num: any, min: any, max: any) => number;
+export declare function getCurrentPage<T>(): T & WechatMiniprogram.OptionalInterface<WechatMiniprogram.Page.ILifetime> & WechatMiniprogram.Page.InstanceProperties & WechatMiniprogram.Page.InstanceMethods<WechatMiniprogram.IAnyObject> & WechatMiniprogram.Page.Data<WechatMiniprogram.IAnyObject> & WechatMiniprogram.IAnyObject;
+export declare const isPC: boolean;

+ 84 - 0
vant/common/utils.js

@@ -0,0 +1,84 @@
+import { isDef, isNumber, isPlainObject, isPromise } from './validator';
+import { canIUseGroupSetData, canIUseNextTick, getSystemInfoSync, } from './version';
+export { isDef } from './validator';
+export { getSystemInfoSync } from './version';
+export function range(num, min, max) {
+    return Math.min(Math.max(num, min), max);
+}
+export function nextTick(cb) {
+    if (canIUseNextTick()) {
+        wx.nextTick(cb);
+    }
+    else {
+        setTimeout(() => {
+            cb();
+        }, 1000 / 30);
+    }
+}
+export function addUnit(value) {
+    if (!isDef(value)) {
+        return undefined;
+    }
+    value = String(value);
+    return isNumber(value) ? `${value}px` : value;
+}
+export function requestAnimationFrame(cb) {
+    return setTimeout(() => {
+        cb();
+    }, 1000 / 30);
+}
+export function pickExclude(obj, keys) {
+    if (!isPlainObject(obj)) {
+        return {};
+    }
+    return Object.keys(obj).reduce((prev, key) => {
+        if (!keys.includes(key)) {
+            prev[key] = obj[key];
+        }
+        return prev;
+    }, {});
+}
+export function getRect(context, selector) {
+    return new Promise((resolve) => {
+        wx.createSelectorQuery()
+            .in(context)
+            .select(selector)
+            .boundingClientRect()
+            .exec((rect = []) => resolve(rect[0]));
+    });
+}
+export function getAllRect(context, selector) {
+    return new Promise((resolve) => {
+        wx.createSelectorQuery()
+            .in(context)
+            .selectAll(selector)
+            .boundingClientRect()
+            .exec((rect = []) => resolve(rect[0]));
+    });
+}
+export function groupSetData(context, cb) {
+    if (canIUseGroupSetData()) {
+        context.groupSetData(cb);
+    }
+    else {
+        cb();
+    }
+}
+export function toPromise(promiseLike) {
+    if (isPromise(promiseLike)) {
+        return promiseLike;
+    }
+    return Promise.resolve(promiseLike);
+}
+// 浮点数精度处理
+export function addNumber(num1, num2) {
+    const cardinal = Math.pow(10, 10);
+    return Math.round((num1 + num2) * cardinal) / cardinal;
+}
+// 限制value在[min, max]之间
+export const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
+export function getCurrentPage() {
+    const pages = getCurrentPages();
+    return pages[pages.length - 1];
+}
+export const isPC = ['mac', 'windows'].includes(getSystemInfoSync().platform);

+ 9 - 0
vant/common/validator.d.ts

@@ -0,0 +1,9 @@
+export declare function isFunction(val: unknown): val is Function;
+export declare function isPlainObject(val: unknown): val is Record<string, unknown>;
+export declare function isPromise<T = unknown>(val: unknown): val is Promise<T>;
+export declare function isDef(value: unknown): boolean;
+export declare function isObj(x: unknown): x is Record<string, unknown>;
+export declare function isNumber(value: string): boolean;
+export declare function isBoolean(value: unknown): value is boolean;
+export declare function isImageUrl(url: string): boolean;
+export declare function isVideoUrl(url: string): boolean;

+ 31 - 0
vant/common/validator.js

@@ -0,0 +1,31 @@
+// eslint-disable-next-line @typescript-eslint/ban-types
+export function isFunction(val) {
+    return typeof val === 'function';
+}
+export function isPlainObject(val) {
+    return val !== null && typeof val === 'object' && !Array.isArray(val);
+}
+export function isPromise(val) {
+    return isPlainObject(val) && isFunction(val.then) && isFunction(val.catch);
+}
+export function isDef(value) {
+    return value !== undefined && value !== null;
+}
+export function isObj(x) {
+    const type = typeof x;
+    return x !== null && (type === 'object' || type === 'function');
+}
+export function isNumber(value) {
+    return /^\d+(\.\d+)?$/.test(value);
+}
+export function isBoolean(value) {
+    return typeof value === 'boolean';
+}
+const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i;
+const VIDEO_REGEXP = /\.(mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv)/i;
+export function isImageUrl(url) {
+    return IMAGE_REGEXP.test(url);
+}
+export function isVideoUrl(url) {
+    return VIDEO_REGEXP.test(url);
+}

+ 9 - 0
vant/common/version.d.ts

@@ -0,0 +1,9 @@
+/// <reference types="miniprogram-api-typings" />
+export declare function getSystemInfoSync(): WechatMiniprogram.SystemInfo;
+export declare function canIUseModel(): boolean;
+export declare function canIUseFormFieldButton(): boolean;
+export declare function canIUseAnimate(): boolean;
+export declare function canIUseGroupSetData(): boolean;
+export declare function canIUseNextTick(): boolean;
+export declare function canIUseCanvas2d(): boolean;
+export declare function canIUseGetUserProfile(): boolean;

+ 59 - 0
vant/common/version.js

@@ -0,0 +1,59 @@
+let systemInfo;
+export function getSystemInfoSync() {
+    if (systemInfo == null) {
+        systemInfo = wx.getSystemInfoSync();
+    }
+    return systemInfo;
+}
+function compareVersion(v1, v2) {
+    v1 = v1.split('.');
+    v2 = v2.split('.');
+    const len = Math.max(v1.length, v2.length);
+    while (v1.length < len) {
+        v1.push('0');
+    }
+    while (v2.length < len) {
+        v2.push('0');
+    }
+    for (let i = 0; i < len; i++) {
+        const num1 = parseInt(v1[i], 10);
+        const num2 = parseInt(v2[i], 10);
+        if (num1 > num2) {
+            return 1;
+        }
+        if (num1 < num2) {
+            return -1;
+        }
+    }
+    return 0;
+}
+function gte(version) {
+    const system = getSystemInfoSync();
+    return compareVersion(system.SDKVersion, version) >= 0;
+}
+export function canIUseModel() {
+    return gte('2.9.3');
+}
+export function canIUseFormFieldButton() {
+    return gte('2.10.3');
+}
+export function canIUseAnimate() {
+    return gte('2.9.0');
+}
+export function canIUseGroupSetData() {
+    return gte('2.4.0');
+}
+export function canIUseNextTick() {
+    try {
+        return wx.canIUse('nextTick');
+    }
+    catch (e) {
+        return gte('2.7.1');
+    }
+}
+export function canIUseCanvas2d() {
+    return gte('2.9.0');
+}
+export function canIUseGetUserProfile() {
+    return !!wx.getUserProfile;
+}

+ 55 - 0
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;

+ 77 - 0
vant/dialog/dialog.js

@@ -0,0 +1,77 @@
+let queue = [];
+const 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: '',
+};
+let currentOptions = Object.assign({}, defaultOptions);
+function getContext() {
+    const pages = getCurrentPages();
+    return pages[pages.length - 1];
+}
+const Dialog = (options) => {
+    options = Object.assign(Object.assign({}, currentOptions), options);
+    return new Promise((resolve, reject) => {
+        const context = (typeof options.context === 'function'
+            ? options.context()
+            : options.context) || getContext();
+        const dialog = context.selectComponent(options.selector);
+        delete options.context;
+        delete options.selector;
+        if (dialog) {
+            dialog.setData(Object.assign({ callback: (action, instance) => {
+                    action === 'confirm' ? resolve(instance) : reject(instance);
+                } }, options));
+            wx.nextTick(() => {
+                dialog.setData({ show: true });
+            });
+            queue.push(dialog);
+        }
+        else {
+            console.warn('未找到 van-dialog 节点,请确认 selector 及 context 是否正确');
+        }
+    });
+};
+Dialog.alert = (options) => Dialog(options);
+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.currentOptions = currentOptions;
+Dialog.defaultOptions = defaultOptions;
+Dialog.setDefaultOptions = (options) => {
+    currentOptions = Object.assign(Object.assign({}, currentOptions), options);
+    Dialog.currentOptions = currentOptions;
+};
+Dialog.resetDefaultOptions = () => {
+    currentOptions = Object.assign({}, defaultOptions);
+    Dialog.currentOptions = currentOptions;
+};
+Dialog.resetDefaultOptions();
+export default Dialog;

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

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

+ 126 - 0
vant/dialog/index.js

@@ -0,0 +1,126 @@
+import { VantComponent } from '../common/component';
+import { button } from '../mixins/button';
+import { GRAY, RED } from '../common/color';
+import { toPromise } from '../common/utils';
+VantComponent({
+    mixins: [button],
+    classes: ['cancle-button-class', 'confirm-button-class'],
+    props: {
+        show: {
+            type: Boolean,
+            observer(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: RED,
+        },
+        cancelButtonColor: {
+            type: String,
+            value: GRAY,
+        },
+        showConfirmButton: {
+            type: Boolean,
+            value: true,
+        },
+        overlay: {
+            type: Boolean,
+            value: true,
+        },
+        transition: {
+            type: String,
+            value: 'scale',
+        },
+    },
+    data: {
+        loading: {
+            confirm: false,
+            cancel: false,
+        },
+        callback: (() => { }),
+    },
+    methods: {
+        onConfirm() {
+            this.handleAction('confirm');
+        },
+        onCancel() {
+            this.handleAction('cancel');
+        },
+        onClickOverlay() {
+            this.close('overlay');
+        },
+        close(action) {
+            this.setData({ show: false });
+            wx.nextTick(() => {
+                this.$emit('close', action);
+                const { callback } = this.data;
+                if (callback) {
+                    callback(action, this);
+                }
+            });
+        },
+        stopLoading() {
+            this.setData({
+                loading: {
+                    confirm: false,
+                    cancel: false,
+                },
+            });
+        },
+        handleAction(action) {
+            this.$emit(action, { dialog: this });
+            const { asyncClose, beforeClose } = this.data;
+            if (!asyncClose && !beforeClose) {
+                this.close(action);
+                return;
+            }
+            this.setData({
+                [`loading.${action}`]: true,
+            });
+            if (beforeClose) {
+                toPromise(beforeClose(action)).then((value) => {
+                    if (value) {
+                        this.close(action);
+                    }
+                    else {
+                        this.stopLoading();
+                    }
+                });
+            }
+        },
+    },
+});

+ 9 - 0
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"
+  }
+}

+ 122 - 0
vant/dialog/index.wxml

@@ -0,0 +1,122 @@
+<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 }}"
+  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"
+      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"
+        bind:click="onConfirm"
+        bindgetuserinfo="onGetUserInfo"
+        bindcontact="onContact"
+        bindgetphonenumber="onGetPhoneNumber"
+        binderror="onError"
+        bindlaunchapp="onLaunchApp"
+        bindopensetting="onOpenSetting"
+      >
+        {{ confirmButtonText }}
+      </van-button>
+    </block>
+  </view>
+</van-popup>

+ 1 - 0
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
vant/goods-action-button/index.d.ts

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

+ 40 - 0
vant/goods-action-button/index.js

@@ -0,0 +1,40 @@
+import { VantComponent } from '../common/component';
+import { useParent } from '../common/relation';
+import { button } from '../mixins/button';
+import { link } from '../mixins/link';
+VantComponent({
+    mixins: [link, button],
+    relation: useParent('goods-action'),
+    props: {
+        text: String,
+        color: String,
+        size: {
+            type: String,
+            value: 'normal',
+        },
+        loading: Boolean,
+        disabled: Boolean,
+        plain: Boolean,
+        type: {
+            type: String,
+            value: 'danger',
+        },
+    },
+    methods: {
+        onClick(event) {
+            this.$emit('click', event.detail);
+            this.jumpLink();
+        },
+        updateStyle() {
+            if (this.parent == null) {
+                return;
+            }
+            const { index } = this;
+            const { children = [] } = this.parent;
+            this.setData({
+                isFirst: index === 0,
+                isLast: index === children.length - 1,
+            });
+        },
+    },
+});

+ 6 - 0
vant/goods-action-button/index.json

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

+ 33 - 0
vant/goods-action-button/index.wxml

@@ -0,0 +1,33 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+<van-button
+  id="{{ id }}"
+  button-id="{{ buttonId }}"
+  lang="{{ lang }}"
+  type="{{ type }}"
+  size="{{ size }}"
+  color="{{ color }}"
+  plain="{{ plain }}"
+  loading="{{ loading }}"
+  disabled="{{ disabled }}"
+  open-type="{{ openType }}"
+  class="{{ utils.bem('goods-action-button', [type, { first: isFirst, last: isLast, plain: plain }])}}"
+  custom-class="van-goods-action-button__inner custom-class"
+  business-id="{{ businessId }}"
+  session-from="{{ sessionFrom }}"
+  app-parameter="{{ appParameter }}"
+  send-message-img="{{ sendMessageImg }}"
+  send-message-path="{{ sendMessagePath }}"
+  show-message-card="{{ showMessageCard }}"
+  send-message-title="{{ sendMessageTitle }}"
+  bind:click="onClick"
+  binderror="onError"
+  bindcontact="onContact"
+  bindopensetting="onOpenSetting"
+  bindgetuserinfo="onGetUserInfo"
+  bindagreeprivacyauthorization="onAgreePrivacyAuthorization"
+  bindgetphonenumber="onGetPhoneNumber"
+  bindlaunchapp="onLaunchApp"
+>
+  {{ text }}
+  <slot></slot>
+</van-button>

+ 1 - 0
vant/goods-action-button/index.wxss

@@ -0,0 +1 @@
+@import '../common/index.wxss';:host{flex:1}.van-goods-action-button{--button-warning-background-color:var(--goods-action-button-warning-color,linear-gradient(to right,#ffd01e,#ff8917));--button-danger-background-color:var(--goods-action-button-danger-color,linear-gradient(to right,#ff6034,#ee0a24));--button-default-height:var(--goods-action-button-height,40px);--button-line-height:var(--goods-action-button-line-height,20px);--button-plain-background-color:var(--goods-action-button-plain-color,#fff);--button-border-width:0;display:block}.van-goods-action-button--first{--button-border-radius:999px 0 0 var(--goods-action-button-border-radius,999px);margin-left:5px}.van-goods-action-button--last{--button-border-radius:0 999px var(--goods-action-button-border-radius,999px) 0;margin-right:5px}.van-goods-action-button--first.van-goods-action-button--last{--button-border-radius:var(--goods-action-button-border-radius,999px)}.van-goods-action-button--plain{--button-border-width:1px}.van-goods-action-button__inner{font-weight:var(--font-weight-bold,500)!important;width:100%}@media (max-width:321px){.van-goods-action-button{font-size:13px}}

+ 1 - 0
vant/goods-action-icon/index.d.ts

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

+ 27 - 0
vant/goods-action-icon/index.js

@@ -0,0 +1,27 @@
+import { VantComponent } from '../common/component';
+import { button } from '../mixins/button';
+import { link } from '../mixins/link';
+VantComponent({
+    classes: ['icon-class', 'text-class', 'info-class'],
+    mixins: [link, button],
+    props: {
+        text: String,
+        dot: Boolean,
+        info: String,
+        icon: String,
+        size: String,
+        color: String,
+        classPrefix: {
+            type: String,
+            value: 'van-icon',
+        },
+        disabled: Boolean,
+        loading: Boolean,
+    },
+    methods: {
+        onClick(event) {
+            this.$emit('click', event.detail);
+            this.jumpLink();
+        },
+    },
+});

+ 7 - 0
vant/goods-action-icon/index.json

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

+ 41 - 0
vant/goods-action-icon/index.wxml

@@ -0,0 +1,41 @@
+<van-button
+  square
+  id="{{ id }}"
+  size="large"
+  lang="{{ lang }}"
+  loading="{{ loading }}"
+  disabled="{{ disabled }}"
+  open-type="{{ openType }}"
+  business-id="{{ businessId }}"
+  custom-class="van-goods-action-icon"
+  session-from="{{ sessionFrom }}"
+  app-parameter="{{ appParameter }}"
+  send-message-img="{{ sendMessageImg }}"
+  send-message-path="{{ sendMessagePath }}"
+  show-message-card="{{ showMessageCard }}"
+  send-message-title="{{ sendMessageTitle }}"
+  bind:click="onClick"
+  binderror="onError"
+  bindcontact="onContact"
+  bindopensetting="onOpenSetting"
+  bindgetuserinfo="onGetUserInfo"
+  bindgetphonenumber="onGetPhoneNumber"
+  bindlaunchapp="onLaunchApp"
+>
+  <van-icon
+    wx:if="{{ icon }}"
+    name="{{ icon }}"
+    dot="{{ dot }}"
+    info="{{ info }}"
+    size="{{ size }}"
+    color="{{ color }}"
+    class-prefix="{{ classPrefix }}"
+    class="van-goods-action-icon__icon"
+    custom-class="icon-class"
+    info-class="info-class"
+  />
+  <view wx:else>
+    <slot name="icon" />
+  </view>
+  <text class="text-class">{{ text }}</text>
+</van-button>

+ 1 - 0
vant/goods-action-icon/index.wxss

@@ -0,0 +1 @@
+@import '../common/index.wxss';.van-goods-action-icon{border:none!important;color:var(--goods-action-icon-text-color,#646566)!important;display:flex!important;flex-direction:column;font-size:var(--goods-action-icon-font-size,10px)!important;height:var(--goods-action-icon-height,50px)!important;justify-content:center!important;line-height:1!important;min-width:var(--goods-action-icon-width,48px)}.van-goods-action-icon__icon{color:var(--goods-action-icon-color,#323233);display:flex;font-size:var(--goods-action-icon-size,18px);margin:0 auto 5px}

+ 1 - 0
vant/goods-action/index.d.ts

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

+ 15 - 0
vant/goods-action/index.js

@@ -0,0 +1,15 @@
+import { VantComponent } from '../common/component';
+import { useChildren } from '../common/relation';
+VantComponent({
+    relation: useChildren('goods-action-button', function () {
+        this.children.forEach((item) => {
+            item.updateStyle();
+        });
+    }),
+    props: {
+        safeAreaInsetBottom: {
+            type: Boolean,
+            value: true,
+        },
+    },
+});

+ 3 - 0
vant/goods-action/index.json

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

+ 5 - 0
vant/goods-action/index.wxml

@@ -0,0 +1,5 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+
+<view class="custom-class {{ utils.bem('goods-action', { safe: safeAreaInsetBottom }) }}">
+  <slot />
+</view>

+ 1 - 0
vant/goods-action/index.wxss

@@ -0,0 +1 @@
+@import '../common/index.wxss';.van-goods-action{align-items:center;background-color:var(--goods-action-background-color,#fff);bottom:0;box-sizing:initial;display:flex;height:var(--goods-action-height,50px);left:0;position:fixed;right:0}.van-goods-action--safe{padding-bottom:env(safe-area-inset-bottom)}

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

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

+ 21 - 0
vant/icon/index.js

@@ -0,0 +1,21 @@
+import { VantComponent } from '../common/component';
+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() {
+            this.$emit('click');
+        },
+    },
+});

+ 6 - 0
vant/icon/index.json

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

+ 20 - 0
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
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,
+};

文件差異過大導致無法顯示
+ 0 - 0
vant/icon/index.wxss


+ 1 - 0
vant/info/index.d.ts

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

+ 8 - 0
vant/info/index.js

@@ -0,0 +1,8 @@
+import { VantComponent } from '../common/component';
+VantComponent({
+    props: {
+        dot: Boolean,
+        info: null,
+        customStyle: String,
+    },
+});

+ 3 - 0
vant/info/index.json

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

+ 7 - 0
vant/info/index.wxml

@@ -0,0 +1,7 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+
+<view
+  wx:if="{{ info !== null && info !== '' || dot }}"
+  class="van-info {{ utils.bem('info', { dot }) }} custom-class"
+  style="{{ customStyle }}"
+>{{ dot ? '' : info }}</view>

+ 1 - 0
vant/info/index.wxss

@@ -0,0 +1 @@
+@import '../common/index.wxss';.van-info{align-items:center;background-color:var(--info-background-color,#ee0a24);border:var(--info-border-width,1px) solid #fff;border-radius:var(--info-size,16px);box-sizing:border-box;color:var(--info-color,#fff);display:inline-flex;font-family:var(--info-font-family,-apple-system-font,Helvetica Neue,Arial,sans-serif);font-size:var(--info-font-size,12px);font-weight:var(--info-font-weight,500);height:var(--info-size,16px);justify-content:center;min-width:var(--info-size,16px);padding:var(--info-padding,0 3px);position:absolute;right:0;top:0;transform:translate(50%,-50%);transform-origin:100%;white-space:nowrap}.van-info--dot{background-color:var(--info-dot-color,#ee0a24);border-radius:100%;height:var(--info-dot-size,8px);min-width:0;width:var(--info-dot-size,8px)}

+ 1 - 0
vant/loading/index.d.ts

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

+ 16 - 0
vant/loading/index.js

@@ -0,0 +1,16 @@
+import { VantComponent } from '../common/component';
+VantComponent({
+    props: {
+        color: String,
+        vertical: Boolean,
+        type: {
+            type: String,
+            value: 'circular',
+        },
+        size: String,
+        textSize: String,
+    },
+    data: {
+        array12: Array.from({ length: 12 }),
+    },
+});

+ 3 - 0
vant/loading/index.json

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

+ 19 - 0
vant/loading/index.wxml

@@ -0,0 +1,19 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+<wxs src="./index.wxs" module="computed" />
+
+<view class="custom-class {{ utils.bem('loading', { vertical }) }}">
+  <view
+    class="van-loading__spinner van-loading__spinner--{{ type }}"
+    style="{{ computed.spinnerStyle({ color, size }) }}"
+  >
+    <view
+      wx:if="{{ type === 'spinner' }}"
+      wx:for="{{ array12 }}"
+      wx:key="index"
+      class="van-loading__dot"
+    />
+  </view>
+  <view class="van-loading__text" style="{{ computed.textStyle({ textSize }) }}">
+    <slot />
+  </view>
+</view>

+ 22 - 0
vant/loading/index.wxs

@@ -0,0 +1,22 @@
+/* eslint-disable */
+var style = require('../wxs/style.wxs');
+var addUnit = require('../wxs/add-unit.wxs');
+
+function spinnerStyle(data) {
+  return style({
+    color: data.color,
+    width: addUnit(data.size),
+    height: addUnit(data.size),
+  });
+}
+
+function textStyle(data) {
+  return style({
+    'font-size': addUnit(data.textSize),
+  });
+}
+
+module.exports = {
+  spinnerStyle: spinnerStyle,
+  textStyle: textStyle,
+};

文件差異過大導致無法顯示
+ 0 - 0
vant/loading/index.wxss


+ 1 - 0
vant/mixins/basic.d.ts

@@ -0,0 +1 @@
+export declare const basic: string;

+ 11 - 0
vant/mixins/basic.js

@@ -0,0 +1,11 @@
+export const basic = Behavior({
+    methods: {
+        $emit(name, detail, options) {
+            this.triggerEvent(name, detail, options);
+        },
+        set(data) {
+            this.setData(data);
+            return new Promise((resolve) => wx.nextTick(resolve));
+        },
+    },
+});

+ 1 - 0
vant/mixins/button.d.ts

@@ -0,0 +1 @@
+export declare const button: string;

+ 51 - 0
vant/mixins/button.js

@@ -0,0 +1,51 @@
+import { canIUseGetUserProfile } from '../common/version';
+export const button = Behavior({
+    externalClasses: ['hover-class'],
+    properties: {
+        id: String,
+        buttonId: String,
+        lang: String,
+        businessId: Number,
+        sessionFrom: String,
+        sendMessageTitle: String,
+        sendMessagePath: String,
+        sendMessageImg: String,
+        showMessageCard: Boolean,
+        appParameter: String,
+        ariaLabel: String,
+        openType: String,
+        getUserProfileDesc: String,
+    },
+    data: {
+        canIUseGetUserProfile: canIUseGetUserProfile(),
+    },
+    methods: {
+        onGetUserInfo(event) {
+            this.triggerEvent('getuserinfo', event.detail);
+        },
+        onContact(event) {
+            this.triggerEvent('contact', event.detail);
+        },
+        onGetPhoneNumber(event) {
+            this.triggerEvent('getphonenumber', event.detail);
+        },
+        onGetRealTimePhoneNumber(event) {
+            this.triggerEvent('getrealtimephonenumber', event.detail);
+        },
+        onError(event) {
+            this.triggerEvent('error', event.detail);
+        },
+        onLaunchApp(event) {
+            this.triggerEvent('launchapp', event.detail);
+        },
+        onOpenSetting(event) {
+            this.triggerEvent('opensetting', event.detail);
+        },
+        onAgreePrivacyAuthorization(event) {
+            this.triggerEvent('agreeprivacyauthorization', event.detail);
+        },
+        onChooseAvatar(event) {
+            this.triggerEvent('chooseavatar', event.detail);
+        },
+    },
+});

+ 1 - 0
vant/mixins/link.d.ts

@@ -0,0 +1 @@
+export declare const link: string;

+ 23 - 0
vant/mixins/link.js

@@ -0,0 +1,23 @@
+export const link = Behavior({
+    properties: {
+        url: String,
+        linkType: {
+            type: String,
+            value: 'navigateTo',
+        },
+    },
+    methods: {
+        jumpLink(urlKey = 'url') {
+            const url = this.data[urlKey];
+            if (url) {
+                if (this.data.linkType === 'navigateTo' &&
+                    getCurrentPages().length > 9) {
+                    wx.redirectTo({ url });
+                }
+                else {
+                    wx[this.data.linkType]({ url });
+                }
+            }
+        },
+    },
+});

+ 6 - 0
vant/mixins/page-scroll.d.ts

@@ -0,0 +1,6 @@
+/// <reference types="miniprogram-api-typings" />
+/// <reference types="miniprogram-api-typings" />
+type IPageScrollOption = WechatMiniprogram.Page.IPageScrollOption;
+type Scroller = (this: WechatMiniprogram.Component.TrivialInstance, event?: IPageScrollOption) => void;
+export declare function pageScrollMixin(scroller: Scroller): string;
+export {};

+ 42 - 0
vant/mixins/page-scroll.js

@@ -0,0 +1,42 @@
+import { isFunction } from '../common/validator';
+import { getCurrentPage, isDef } from '../common/utils';
+function onPageScroll(event) {
+    const { vanPageScroller = [] } = getCurrentPage();
+    vanPageScroller.forEach((scroller) => {
+        if (typeof scroller === 'function') {
+            // @ts-ignore
+            scroller(event);
+        }
+    });
+}
+export function pageScrollMixin(scroller) {
+    return Behavior({
+        attached() {
+            const page = getCurrentPage();
+            if (!isDef(page)) {
+                return;
+            }
+            const _scroller = scroller.bind(this);
+            const { vanPageScroller = [] } = page;
+            if (isFunction(page.onPageScroll) && page.onPageScroll !== onPageScroll) {
+                vanPageScroller.push(page.onPageScroll.bind(page));
+            }
+            vanPageScroller.push(_scroller);
+            page.vanPageScroller = vanPageScroller;
+            page.onPageScroll = onPageScroll;
+            this._scroller = _scroller;
+        },
+        detached() {
+            const page = getCurrentPage();
+            if (!isDef(page) || !isDef(page.vanPageScroller)) {
+                return;
+            }
+            const { vanPageScroller } = page;
+            const index = vanPageScroller.findIndex((v) => v === this._scroller);
+            if (index > -1) {
+                page.vanPageScroller.splice(index, 1);
+            }
+            this._scroller = undefined;
+        },
+    });
+}

+ 1 - 0
vant/mixins/touch.d.ts

@@ -0,0 +1 @@
+export declare const touch: string;

+ 37 - 0
vant/mixins/touch.js

@@ -0,0 +1,37 @@
+// @ts-nocheck
+const MIN_DISTANCE = 10;
+function getDirection(x, y) {
+    if (x > y && x > MIN_DISTANCE) {
+        return 'horizontal';
+    }
+    if (y > x && y > MIN_DISTANCE) {
+        return 'vertical';
+    }
+    return '';
+}
+export const touch = Behavior({
+    methods: {
+        resetTouchStatus() {
+            this.direction = '';
+            this.deltaX = 0;
+            this.deltaY = 0;
+            this.offsetX = 0;
+            this.offsetY = 0;
+        },
+        touchStart(event) {
+            this.resetTouchStatus();
+            const touch = event.touches[0];
+            this.startX = touch.clientX;
+            this.startY = touch.clientY;
+        },
+        touchMove(event) {
+            const touch = event.touches[0];
+            this.deltaX = touch.clientX - this.startX;
+            this.deltaY = touch.clientY - this.startY;
+            this.offsetX = Math.abs(this.deltaX);
+            this.offsetY = Math.abs(this.deltaY);
+            this.direction =
+                this.direction || getDirection(this.offsetX, this.offsetY);
+        },
+    },
+});

+ 1 - 0
vant/mixins/transition.d.ts

@@ -0,0 +1 @@
+export declare function transition(showDefaultValue: boolean): string;

+ 118 - 0
vant/mixins/transition.js

@@ -0,0 +1,118 @@
+// @ts-nocheck
+import { requestAnimationFrame } from '../common/utils';
+import { isObj } from '../common/validator';
+const getClassNames = (name) => ({
+    enter: `van-${name}-enter van-${name}-enter-active enter-class enter-active-class`,
+    'enter-to': `van-${name}-enter-to van-${name}-enter-active enter-to-class enter-active-class`,
+    leave: `van-${name}-leave van-${name}-leave-active leave-class leave-active-class`,
+    'leave-to': `van-${name}-leave-to van-${name}-leave-active leave-to-class leave-active-class`,
+});
+export function transition(showDefaultValue) {
+    return Behavior({
+        properties: {
+            customStyle: String,
+            // @ts-ignore
+            show: {
+                type: Boolean,
+                value: showDefaultValue,
+                observer: 'observeShow',
+            },
+            // @ts-ignore
+            duration: {
+                type: null,
+                value: 300,
+                observer: 'observeDuration',
+            },
+            name: {
+                type: String,
+                value: 'fade',
+            },
+        },
+        data: {
+            type: '',
+            inited: false,
+            display: false,
+        },
+        ready() {
+            if (this.data.show === true) {
+                this.observeShow(true, false);
+            }
+        },
+        methods: {
+            observeShow(value, old) {
+                if (value === old) {
+                    return;
+                }
+                value ? this.enter() : this.leave();
+            },
+            enter() {
+                const { duration, name } = this.data;
+                const classNames = getClassNames(name);
+                const currentDuration = isObj(duration) ? duration.enter : duration;
+                if (this.status === 'enter') {
+                    return;
+                }
+                this.status = 'enter';
+                this.$emit('before-enter');
+                requestAnimationFrame(() => {
+                    if (this.status !== 'enter') {
+                        return;
+                    }
+                    this.$emit('enter');
+                    this.setData({
+                        inited: true,
+                        display: true,
+                        classes: classNames.enter,
+                        currentDuration,
+                    });
+                    requestAnimationFrame(() => {
+                        if (this.status !== 'enter') {
+                            return;
+                        }
+                        this.transitionEnded = false;
+                        this.setData({ classes: classNames['enter-to'] });
+                    });
+                });
+            },
+            leave() {
+                if (!this.data.display) {
+                    return;
+                }
+                const { duration, name } = this.data;
+                const classNames = getClassNames(name);
+                const currentDuration = isObj(duration) ? duration.leave : duration;
+                this.status = 'leave';
+                this.$emit('before-leave');
+                requestAnimationFrame(() => {
+                    if (this.status !== 'leave') {
+                        return;
+                    }
+                    this.$emit('leave');
+                    this.setData({
+                        classes: classNames.leave,
+                        currentDuration,
+                    });
+                    requestAnimationFrame(() => {
+                        if (this.status !== 'leave') {
+                            return;
+                        }
+                        this.transitionEnded = false;
+                        setTimeout(() => this.onTransitionEnd(), currentDuration);
+                        this.setData({ classes: classNames['leave-to'] });
+                    });
+                });
+            },
+            onTransitionEnd() {
+                if (this.transitionEnded) {
+                    return;
+                }
+                this.transitionEnded = true;
+                this.$emit(`after-${this.status}`);
+                const { show, display } = this.data;
+                if (!show && display) {
+                    this.setData({ display: false });
+                }
+            },
+        },
+    });
+}

+ 1 - 0
vant/overlay/index.d.ts

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

+ 30 - 0
vant/overlay/index.js

@@ -0,0 +1,30 @@
+import { VantComponent } from '../common/component';
+VantComponent({
+    props: {
+        show: Boolean,
+        customStyle: String,
+        duration: {
+            type: null,
+            value: 300,
+        },
+        zIndex: {
+            type: Number,
+            value: 1,
+        },
+        lockScroll: {
+            type: Boolean,
+            value: true,
+        },
+        rootPortal: {
+            type: Boolean,
+            value: false,
+        },
+    },
+    methods: {
+        onClick() {
+            this.$emit('click');
+        },
+        // for prevent touchmove
+        noop() { },
+    },
+});

+ 6 - 0
vant/overlay/index.json

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

+ 7 - 0
vant/overlay/index.wxml

@@ -0,0 +1,7 @@
+<import src="./overlay.wxml" />
+
+<root-portal wx:if="{{ rootPortal }}">
+  <include src="./overlay.wxml" />
+</root-portal>
+
+<include wx:else src="./overlay.wxml" />

+ 1 - 0
vant/overlay/index.wxss

@@ -0,0 +1 @@
+@import '../common/index.wxss';.van-overlay{background-color:var(--overlay-background-color,rgba(0,0,0,.7));height:100%;left:0;position:fixed;top:0;width:100%}

+ 10 - 0
vant/overlay/overlay.wxml

@@ -0,0 +1,10 @@
+<van-transition
+  show="{{ show }}"
+  custom-class="van-overlay custom-class"
+  custom-style="z-index: {{ zIndex }}; {{ customStyle }}"
+  duration="{{ duration }}"
+  bind:tap="onClick"
+  catch:touchmove="{{ lockScroll ? 'noop' : ''}}"
+>
+  <slot></slot>
+</van-transition>

+ 1 - 0
vant/popup/index.d.ts

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

+ 97 - 0
vant/popup/index.js

@@ -0,0 +1,97 @@
+import { VantComponent } from '../common/component';
+import { transition } from '../mixins/transition';
+VantComponent({
+    classes: [
+        'enter-class',
+        'enter-active-class',
+        'enter-to-class',
+        'leave-class',
+        'leave-active-class',
+        'leave-to-class',
+        'close-icon-class',
+    ],
+    mixins: [transition(false)],
+    props: {
+        round: Boolean,
+        closeable: Boolean,
+        customStyle: String,
+        overlayStyle: String,
+        transition: {
+            type: String,
+            observer: 'observeClass',
+        },
+        zIndex: {
+            type: Number,
+            value: 100,
+        },
+        overlay: {
+            type: Boolean,
+            value: true,
+        },
+        closeIcon: {
+            type: String,
+            value: 'cross',
+        },
+        closeIconPosition: {
+            type: String,
+            value: 'top-right',
+        },
+        closeOnClickOverlay: {
+            type: Boolean,
+            value: true,
+        },
+        position: {
+            type: String,
+            value: 'center',
+            observer: 'observeClass',
+        },
+        safeAreaInsetBottom: {
+            type: Boolean,
+            value: true,
+        },
+        safeAreaInsetTop: {
+            type: Boolean,
+            value: false,
+        },
+        safeAreaTabBar: {
+            type: Boolean,
+            value: false,
+        },
+        lockScroll: {
+            type: Boolean,
+            value: true,
+        },
+        rootPortal: {
+            type: Boolean,
+            value: false,
+        },
+    },
+    created() {
+        this.observeClass();
+    },
+    methods: {
+        onClickCloseIcon() {
+            this.$emit('close');
+        },
+        onClickOverlay() {
+            this.$emit('click-overlay');
+            if (this.data.closeOnClickOverlay) {
+                this.$emit('close');
+            }
+        },
+        observeClass() {
+            const { transition, position, duration } = this.data;
+            const updateData = {
+                name: transition || position,
+            };
+            if (transition === 'none') {
+                updateData.duration = 0;
+                this.originDuration = duration;
+            }
+            else if (this.originDuration != null) {
+                updateData.duration = this.originDuration;
+            }
+            this.setData(updateData);
+        },
+    },
+});

+ 7 - 0
vant/popup/index.json

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

+ 21 - 0
vant/popup/index.wxml

@@ -0,0 +1,21 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+<wxs src="./index.wxs" module="computed" />
+
+<import src="./popup.wxml" />
+
+<van-overlay
+  wx:if="{{ overlay }}"
+  show="{{ show }}"
+  z-index="{{ zIndex }}"
+  custom-style="{{ overlayStyle }}"
+  duration="{{ duration }}"
+  bind:click="onClickOverlay"
+  lock-scroll="{{ lockScroll }}"
+  root-portal="{{ rootPortal }}"
+/>
+
+<root-portal wx:if="{{ rootPortal }}">
+  <include src="./popup.wxml" />
+</root-portal>
+
+ <include wx:else src="./popup.wxml" />

+ 18 - 0
vant/popup/index.wxs

@@ -0,0 +1,18 @@
+/* eslint-disable */
+var style = require('../wxs/style.wxs');
+
+function popupStyle(data) {
+  return style([
+    {
+      'z-index': data.zIndex,
+      '-webkit-transition-duration': data.currentDuration + 'ms',
+      'transition-duration': data.currentDuration + 'ms',
+    },
+    data.display ? null : 'display: none',
+    data.customStyle,
+  ]);
+}
+
+module.exports = {
+  popupStyle: popupStyle,
+};

文件差異過大導致無法顯示
+ 0 - 0
vant/popup/index.wxss


+ 14 - 0
vant/popup/popup.wxml

@@ -0,0 +1,14 @@
+<view
+  wx:if="{{ inited }}"
+  class="custom-class {{ classes }} {{ utils.bem('popup', [position, { round, safe: safeAreaInsetBottom, safeTop: safeAreaInsetTop, safeTabBar: safeAreaTabBar }]) }}"
+  style="{{ computed.popupStyle({ zIndex, currentDuration, display, customStyle }) }}"
+  bind:transitionend="onTransitionEnd"
+>
+  <slot />
+  <van-icon
+    wx:if="{{ closeable }}"
+    name="{{ closeIcon }}"
+    class="close-icon-class van-popup__close-icon van-popup__close-icon--{{ closeIconPosition }}"
+    bind:tap="onClickCloseIcon"
+  />
+</view>

+ 1 - 0
vant/transition/index.d.ts

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

+ 13 - 0
vant/transition/index.js

@@ -0,0 +1,13 @@
+import { VantComponent } from '../common/component';
+import { transition } from '../mixins/transition';
+VantComponent({
+    classes: [
+        'enter-class',
+        'enter-active-class',
+        'enter-to-class',
+        'leave-class',
+        'leave-active-class',
+        'leave-to-class',
+    ],
+    mixins: [transition(true)],
+});

+ 3 - 0
vant/transition/index.json

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

+ 10 - 0
vant/transition/index.wxml

@@ -0,0 +1,10 @@
+<wxs src="./index.wxs" module="computed" />
+
+<view
+  wx:if="{{ inited }}"
+  class="van-transition custom-class {{ classes }}"
+  style="{{ computed.rootStyle({ currentDuration, display, customStyle }) }}"
+  bind:transitionend="onTransitionEnd"
+>
+  <slot />
+</view>

部分文件因文件數量過多而無法顯示