Bläddra i källkod

feature vantweapp加入空状态和进度组件,修复小问题

tiedan 4 år sedan
förälder
incheckning
ca57e4315e

+ 2 - 0
app.json

@@ -49,6 +49,8 @@
     "navigationBarTitleText": "自定义导航栏"
   },
   "usingComponents": {
+    "van-progress": "/miniprogram_npm/vant-weapp/progress/index",
+    "van-empty": "/miniprogram_npm/vant-weapp/empty/index",
     "van-button": "/miniprogram_npm/vant-weapp/button/index",
     "van-divider": "/miniprogram_npm/vant-weapp/divider/index",
     "van-row": "/miniprogram_npm/vant-weapp/row/index",

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

@@ -0,0 +1,23 @@
+'use strict';
+Object.defineProperty(exports, '__esModule', { value: true });
+var component_1 = require('../common/component');
+var PRESETS = ['error', 'search', 'default', 'network'];
+component_1.VantComponent({
+  props: {
+    description: String,
+    image: {
+      type: String,
+      value: 'default',
+    },
+  },
+  created: function () {
+    if (PRESETS.indexOf(this.data.image) !== -1) {
+      this.setData({
+        imageUrl:
+          'https://img.yzcdn.cn/vant/empty-image-' + this.data.image + '.png',
+      });
+    } else {
+      this.setData({ imageUrl: this.data.image });
+    }
+  },
+});

+ 4 - 0
miniprogram_npm/vant-weapp/empty/index.json

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

+ 21 - 0
miniprogram_npm/vant-weapp/empty/index.wxml

@@ -0,0 +1,21 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+
+<view class="custom-class van-empty">
+  <view class="van-empty__image">
+    <slot name="image"></slot>
+  </view>
+  <view class="van-empty__image">
+    <image wx:if="{{ imageUrl }}" class="van-empty__image__img" src="{{ imageUrl }}" />
+  </view>
+
+  <view class="van-empty__description">
+    <slot name="description"></slot>
+  </view>
+  <view class="van-empty__description">
+    {{ description }}
+  </view>
+
+  <view class="van-empty__bottom">
+    <slot></slot>
+  </view>
+</view>

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 0
miniprogram_npm/vant-weapp/empty/index.wxss


+ 29 - 0
miniprogram_npm/vant-weapp/progress/index.js

@@ -0,0 +1,29 @@
+'use strict';
+Object.defineProperty(exports, '__esModule', { value: true });
+var component_1 = require('../common/component');
+var color_1 = require('../common/color');
+component_1.VantComponent({
+  props: {
+    inactive: Boolean,
+    percentage: Number,
+    pivotText: String,
+    pivotColor: String,
+    trackColor: String,
+    showPivot: {
+      type: Boolean,
+      value: true,
+    },
+    color: {
+      type: String,
+      value: color_1.BLUE,
+    },
+    textColor: {
+      type: String,
+      value: '#fff',
+    },
+    strokeWidth: {
+      type: null,
+      value: 4,
+    },
+  },
+});

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

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

+ 20 - 0
miniprogram_npm/vant-weapp/progress/index.wxml

@@ -0,0 +1,20 @@
+<wxs src="../wxs/utils.wxs" module="utils" />
+<wxs src="./index.wxs" module="getters" />
+
+<view
+  class="van-progress custom-class"
+  style="height: {{ utils.addUnit(strokeWidth) }}; {{ trackColor ? 'background: ' + trackColor : '' }}"
+>
+  <view
+    class="van-progress__portion"
+    style="width: {{ percentage }}%; background: {{ inactive ? '#cacaca' : color }}"
+  >
+    <view
+      wx:if="{{ showPivot && getters.text(pivotText, percentage) }}"
+      style="color: {{ textColor }}; background: {{ pivotColor ? pivotColor : inactive ? '#cacaca' : color }}"
+      class="van-progress__pivot"
+    >
+      {{ getters.text(pivotText, percentage) }}
+    </view>
+  </view>
+</view>

+ 5 - 0
miniprogram_npm/vant-weapp/progress/index.wxs

@@ -0,0 +1,5 @@
+module.exports = {
+  text: function(pivotText, percentage) {
+    return pivotText || percentage + '%';
+  }
+};

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 0
miniprogram_npm/vant-weapp/progress/index.wxss


+ 1 - 3
pages/index/index.wxml

@@ -1,8 +1,6 @@
 <view class="container">
     <van-notice-bar wx:if="{{noticeVis}}" left-icon="volume-o" mode="link" text="{{notice}}" bindtap="toNotice" style="padding-bottom:10rpx;" />
-		<van-button style="{{ buttonStyle }}">
-  默认按钮
-</van-button>
+	
 	<view class="banner">
 		<swiper class='u-wrp-bnr' indicator-dots="true" interval='5000' duration='1000'>
 			<block wx:for="{{bnrUrl}}" wx:for-index="index" wx:key="idx">

+ 0 - 1
pages/index/index.wxss

@@ -4,7 +4,6 @@
   height: 240rpx;
   position: relative;
 }
-
 .u-wrp-bnr {
   width: 100%;
   height: 240rpx;