ソースを参照

fix: 删除组件内的多余的文件 (#1878)

* fix: 修复 ImagePreview 在Taro编译成H5后报错的问题

* fix: 地址关闭时, Close 事件触发两次问题解决

* feat: 组件DatePicker 添加双向绑定

* docs: 组件Picker文档修改

* feat: 组件Picker与DatePicker新增属性safe-area-inset-bottom

* feat: imagepreview

* fix: 组件imagepreview点击视频遮罩关闭(#1729)

* fix: 解决 Picker 在微信小程序中无法使用问题 (#1774)

* fix: 修改 Picker 组件 v-model 失效问题

* fix: 组件NoticeBar修改height之后,垂直轮播会卡顿

* fix: 删除Datepicker Demo演示多余内容

* fix: 组件Picker在JD小程序上适配

* fix: 组件Address京东小程序适配

* feat: 京东小程序适配

* fix: 删除空格

* feat: 删除console

* fix: 京东小程序imagepreview适配

* fix: 修复 imagepreview 动态设置 initNo 显示不正确问题

* fix: 组件 InfiniteLoading 某些情况下会错误触发下拉刷新#1819

* fix: 删除pullrefresh

* feat: 组件 imagepreview瘦身

* feat: 组件Picker 瘦身

* fix: address线上问题修改

* fix: 完善imagepreview

* feat: 公共函数提取

* feat: 函数式改用 createComponent

* feat: 地址修改

* fix: 删除多余文件
yangxiaolu1993 3 年 前
コミット
a93fd403ee

+ 14 - 8
src/packages/__VUE/address/demo.vue

@@ -103,7 +103,7 @@
 
 <script lang="ts">
 import { createComponent } from '@/packages/utils/create';
-import { reactive, ref, toRefs } from 'vue';
+import { onMounted, reactive, ref, toRefs } from 'vue';
 import { useTranslate } from '@/sites/assets/util/useTranslate';
 const { createDemo, translate } = createComponent('address');
 
@@ -168,13 +168,7 @@ export default createDemo({
   setup() {
     initTranslate();
     const address = reactive({
-      province: [
-        { id: 1, name: '北京', title: 'B' },
-        { id: 2, name: '广西', title: 'G' },
-        { id: 3, name: '江西', title: 'J' },
-        { id: 4, name: '四川', title: 'S' },
-        { id: 5, name: '浙江', title: 'Z' }
-      ],
+      province: [],
       city: [
         { id: 7, name: '朝阳区', title: 'C' },
         { id: 8, name: '崇文区', title: 'C' },
@@ -191,6 +185,18 @@ export default createDemo({
       town: []
     });
 
+    onMounted(() => {
+      setTimeout(() => {
+        address.province = [
+          { id: 1, name: '北京', title: 'B' },
+          { id: 2, name: '广西', title: 'G' },
+          { id: 3, name: '江西', title: 'J' },
+          { id: 4, name: '四川', title: 'S' },
+          { id: 5, name: '浙江', title: 'Z' }
+        ];
+      }, 1000);
+    });
+
     const placeholder = ref(['请选择省', '请选择市', '请选择县']);
     const value = ref([1, 7, 3]);
     const value2 = ref([1, 7, 3]);

+ 2 - 2
src/packages/__VUE/address/index.scss

@@ -9,7 +9,7 @@
     }
 
     .custom-address {
-      .region-tab {
+      .nut-address-region-tab {
         color: $dark-color;
       }
       .region-con {
@@ -63,7 +63,7 @@
   // 请选择
   .custom-address {
     display: block;
-    .region-tab {
+    .nut-address-region-tab {
       position: relative;
       margin-top: 32px;
       padding: 0 20px;

+ 26 - 53
src/packages/__VUE/address/index.vue

@@ -34,11 +34,10 @@
       </view>
 
       <!-- 请选择 -->
-      <view class="custom-address" v-if="privateType == 'custom'">
-        <view class="region-tab" ref="tabRegion">
+      <view class="custom-address" v-if="['custom', 'custom2'].includes(privateType)">
+        <view class="nut-address-region-tab" ref="tabRegion">
           <view
-            class="tab-item"
-            :class="[index == tabIndex ? 'active' : '']"
+            :class="['tab-item', index == tabIndex ? 'active' : '']"
             v-for="(item, key, index) in selectedRegion"
             :key="index"
             @click="changeRegionTab(item, key, index)"
@@ -49,7 +48,7 @@
           <view class="region-tab-line" ref="regionLine" :style="{ left: lineDistance + 'px' }"></view>
         </view>
 
-        <view class="region-con">
+        <view class="region-con" v-if="privateType == 'custom'">
           <ul class="region-group">
             <li
               v-for="(item, index) in regionList[tabName[tabIndex]]"
@@ -72,23 +71,8 @@
             </li>
           </ul>
         </view>
-      </view>
 
-      <!-- 请选择 -->
-      <view class="custom-address" v-else-if="privateType == 'custom2'">
-        <view class="region-tab" ref="tabRegion">
-          <view
-            class="tab-item"
-            :class="[index == tabIndex ? 'active' : '']"
-            v-for="(item, key, index) in selectedRegion"
-            :key="index"
-            @click="changeRegionTab(item, key, index)"
-          >
-            <view>{{ getTabName(item, index) }}</view>
-          </view>
-          <view class="region-tab-line" ref="regionLine" :style="{ left: lineDistance + 'px' }"></view>
-        </view>
-        <view class="elevator-group">
+        <view class="elevator-group" v-else>
           <nut-elevator
             :height="height"
             :index-list="regionList[tabName[tabIndex]]"
@@ -142,6 +126,7 @@
 <script lang="ts">
 import { reactive, ref, toRefs, watch, nextTick, computed, Ref, onMounted } from 'vue';
 import { createComponent } from '@/packages/utils/create';
+import { isArray, isString, TypeOfFun } from '@/packages/utils/util';
 import { popupProps } from '../popup/props';
 const { componentName, create, translate } = createComponent('address');
 interface RegionData {
@@ -250,12 +235,12 @@ export default create({
     const privateType = ref(props.type);
     const tabIndex = ref(0);
     const tabName = ref(['province', 'city', 'country', 'town']);
-    const tabNameDefault = ref(['']);
+    const tabNameDefault = ref(new Array(4).fill(translate('select')));
 
     const isCustom2 = computed(() => props.type === 'custom2');
 
     const transformData = (data: RegionData[]) => {
-      if (!Array.isArray(data)) throw new TypeError('params muse be array.');
+      if (!isArray(data)) throw new TypeError('params muse be array.');
 
       if (!data.length) return [];
 
@@ -310,10 +295,6 @@ export default create({
 
     const lineDistance = ref(20);
 
-    onMounted(() => {
-      customPlaceholder();
-    });
-
     // 设置选中省市县
     const initCustomSelected = () => {
       if (props.modelValue.length > 0) {
@@ -341,18 +322,13 @@ export default create({
     };
     // 自定义‘请选择’文案
     const customPlaceholder = () => {
-      let selectStr = translate('select');
-      let typeD = Object.prototype.toString.call(props.columnsPlaceholder || selectStr);
-      if (typeD == '[object String]') {
-        tabNameDefault.value = new Array(4).fill(props.columnsPlaceholder || selectStr);
-      } else if (typeD == '[object Array]') {
-        tabNameDefault.value = new Array(4).fill('');
-        tabNameDefault.value.forEach((val, index) => {
-          if (props.columnsPlaceholder[index]) {
-            tabNameDefault.value[index] = props.columnsPlaceholder[index];
-          } else {
-            tabNameDefault.value[index] = selectStr;
-          }
+      const { columnsPlaceholder } = props;
+      if (!columnsPlaceholder) return;
+      if (isString(columnsPlaceholder)) {
+        tabNameDefault.value = new Array(4).fill(columnsPlaceholder);
+      } else if (isArray(columnsPlaceholder) && columnsPlaceholder.length < 5) {
+        columnsPlaceholder.forEach((val, index) => {
+          tabNameDefault.value[index] = val;
         });
       }
     };
@@ -401,9 +377,6 @@ export default create({
       };
 
       (selectedRegion as any)[tabName.value[tabIndex.value]] = item;
-      // for (let i = tabIndex.value; i < tabIndex.value - 1; i++) {
-      //   (selectedRegion as any)[tabName.value[i + 1]] = {};
-      // }
 
       for (let i = tabIndex.value; i < 4; i++) {
         (selectedRegion as any)[tabName.value[i + 1]] = {};
@@ -462,7 +435,6 @@ export default create({
 
     // 关闭
     const close = () => {
-      console.log('关闭', closeWay.value, showPopup.value);
       const resCopy = Object.assign(
         {
           addressIdStr: '',
@@ -523,6 +495,10 @@ export default create({
       nextAreaList(item);
     };
 
+    const updateRegion = (type: string, value: any) => {
+      regionList[type] = isCustom2.value ? transformData(value) : value;
+    };
+
     watch(
       () => props.visible,
       (value) => {
@@ -533,10 +509,8 @@ export default create({
     watch(
       () => showPopup.value,
       (value) => {
-        console.log('监听 showpopup', showPopup.value);
-        if (value == false) {
-          // close();
-        } else {
+        if (value) {
+          customPlaceholder();
           initCustomSelected();
         }
       }
@@ -545,33 +519,32 @@ export default create({
     watch(
       () => props.province,
       (value) => {
-        regionList.province = isCustom2.value ? transformData(value) : value;
+        updateRegion('province', value);
       }
     );
     watch(
       () => props.city,
       (value) => {
-        regionList.city = isCustom2.value ? transformData(value) : value;
+        updateRegion('city', value);
       }
     );
     watch(
       () => props.country,
       (value) => {
-        regionList.country = isCustom2.value ? transformData(value) : value;
+        updateRegion('country', value);
       }
     );
     watch(
       () => props.town,
       (value) => {
-        regionList.town = isCustom2.value ? transformData(value) : value;
+        updateRegion('town', value);
       }
     );
 
     watch(
       () => props.existAddress,
       (value) => {
-        //  existAddress.value = value;
-        value.forEach((item, index) => {
+        value.forEach((item) => {
           if ((item as AddressList).selectedAddress) {
             selectedExistAddress = item as {};
           }

ファイルの差分が大きいため隠しています
+ 0 - 1807
src/packages/__VUE/category/categoryData.json


ファイルの差分が大きいため隠しています
+ 0 - 1807
src/packages/__VUE/category/data.js


ファイルの差分が大きいため隠しています
+ 0 - 1
src/packages/__VUE/comment/comment_data.json


+ 2 - 2
src/packages/__VUE/countdown/index.taro.vue

@@ -11,7 +11,8 @@
 <script lang="ts">
 import { toRefs, computed, watch, reactive, onBeforeMount, onMounted } from 'vue';
 import { createComponent } from '@/packages/utils/create';
-import { padZero, getTimeStamp } from './util';
+import { getTimeStamp } from './util';
+import { padZero } from '@/packages/utils/util';
 const { componentName, create, translate } = createComponent('countdown');
 
 export default create({
@@ -262,7 +263,6 @@ export default create({
       ...toRefs(props),
       slots,
       classes,
-      getTimeStamp,
       start,
       pause,
       renderTime,

+ 2 - 2
src/packages/__VUE/countdown/index.vue

@@ -11,7 +11,8 @@
 <script lang="ts">
 import { toRefs, computed, watch, reactive, onBeforeMount, onMounted } from 'vue';
 import { createComponent } from '@/packages/utils/create';
-import { padZero, getTimeStamp } from './util';
+import { getTimeStamp } from './util';
+import { padZero } from '@/packages/utils/util';
 const { componentName, create, translate } = createComponent('countdown');
 export default create({
   props: {
@@ -261,7 +262,6 @@ export default create({
       ...toRefs(props),
       slots,
       classes,
-      getTimeStamp,
       start,
       pause,
       renderTime,

+ 0 - 8
src/packages/__VUE/countdown/util.ts

@@ -1,11 +1,3 @@
-export const padZero = (num: number | string, length = 2) => {
-  num += '';
-  while ((num as string).length < length) {
-    num = '0' + num;
-  }
-  return num.toString();
-};
-
 // 时间戳转换 或 获取当前时间的时间戳
 export const getTimeStamp = (timeStr?: string | number) => {
   if (!timeStr) return Date.now();

+ 2 - 2
src/packages/__VUE/datepicker/index.taro.vue

@@ -27,12 +27,12 @@ import type { PropType } from 'vue';
 import nutPicker from '../picker/index.taro.vue';
 import { popupProps } from '../popup/props';
 import { createComponent } from '@/packages/utils/create';
-import { padZero } from './utils';
+import { padZero, isDate as isDateU } from '@/packages/utils/util';
 const { componentName, create } = createComponent('datepicker');
 
 const currentYear = new Date().getFullYear();
 function isDate(val: Date): val is Date {
-  return Object.prototype.toString.call(val) === '[object Date]' && !isNaN(val.getTime());
+  return isDateU(val) && !isNaN(val.getTime());
 }
 
 const zhCNType: {

+ 2 - 2
src/packages/__VUE/datepicker/index.vue

@@ -28,12 +28,12 @@ import Picker from '../picker/index.vue';
 import { popupProps } from '../popup/props';
 import { PickerOption } from '../picker/types';
 import { createComponent } from '@/packages/utils/create';
-import { padZero } from './utils';
+import { padZero, isDate as isDateU } from '@/packages/utils/util';
 const { componentName, create, translate } = createComponent('datepicker');
 
 const currentYear = new Date().getFullYear();
 function isDate(val: Date): val is Date {
-  return Object.prototype.toString.call(val) === '[object Date]' && !isNaN(val.getTime());
+  return isDateU(val) && !isNaN(val.getTime());
 }
 
 const zhCNType: {

+ 0 - 9
src/packages/__VUE/datepicker/utils.ts

@@ -1,9 +0,0 @@
-export function padZero(num: number | string, targetLength = 2): string {
-  let str = num + '';
-
-  while (str.length < targetLength) {
-    str = '0' + str;
-  }
-
-  return str;
-}

+ 3 - 2
src/packages/__VUE/indicator/index.taro.vue

@@ -2,7 +2,7 @@
   <view :class="classes">
     <template v-for="item in size" :key="item">
       <view v-if="item === current" :class="`${componentName}--number`">
-        {{ fillZero && item < 10 ? `0${item}` : item }}
+        {{ (fillZero && padZero(item)) || item }}
       </view>
       <view v-else :class="`${componentName}--dot`"></view>
     </template>
@@ -13,6 +13,7 @@ import Taro from '@tarojs/taro';
 
 import { toRefs, computed } from 'vue';
 import { createComponent } from '@/packages/utils/create';
+import { padZero } from '@/packages/utils/util';
 const { componentName, create } = createComponent('indicator');
 
 export default create({
@@ -52,7 +53,7 @@ export default create({
       };
     });
 
-    return { classes, componentName };
+    return { classes, componentName, padZero };
   }
 });
 </script>

+ 3 - 2
src/packages/__VUE/indicator/index.vue

@@ -2,7 +2,7 @@
   <view :class="classes">
     <template v-for="item in size" :key="item">
       <view v-if="item === current" :class="`${componentName}--number`">
-        {{ fillZero && item < 10 ? `0${item}` : item }}
+        {{ (fillZero && padZero(item)) || item }}
       </view>
       <view v-else :class="`${componentName}--dot`"></view>
     </template>
@@ -11,6 +11,7 @@
 <script lang="ts">
 import { toRefs, computed } from 'vue';
 import { createComponent } from '@/packages/utils/create';
+import { padZero } from '@/packages/utils/util';
 const { componentName, create } = createComponent('indicator');
 
 export default create({
@@ -50,7 +51,7 @@ export default create({
       };
     });
 
-    return { classes, componentName };
+    return { classes, componentName, padZero };
   }
 });
 </script>

+ 0 - 102
src/packages/__VUE/sku/data.ts

@@ -1,102 +0,0 @@
-export const Sku = [
-  {
-    id: 1,
-    name: '颜色',
-    list: [
-      {
-        name: '亮黑色',
-        id: 100016015112,
-        active: true,
-        disable: false
-      },
-      {
-        name: '釉白色',
-        id: 100016015142,
-        active: false,
-        disable: false
-      },
-      {
-        name: '秘银色',
-        id: 100016015078,
-        active: false,
-        disable: false
-      },
-      {
-        name: '夏日胡杨',
-        id: 100009064831,
-        active: false,
-        disable: false
-      },
-      {
-        name: '秋日胡杨',
-        id: 100009064830,
-        active: false,
-        disable: false
-      }
-    ]
-  },
-  {
-    id: 2,
-    name: '版本',
-    list: [
-      {
-        name: '8GB+128GB',
-        id: 100016015102,
-        active: true,
-        disable: false
-      },
-      {
-        name: '8GB+256GB',
-        id: 100016015122,
-        active: false,
-        disable: false
-      }
-    ]
-  },
-  {
-    id: 3,
-    name: '版本',
-    list: [
-      {
-        name: '4G(有充版)',
-        id: 100016015103,
-        active: true,
-        disable: false
-      },
-      {
-        name: '5G(有充版)',
-        id: 100016015123,
-        active: false,
-        disable: false
-      },
-      {
-        name: '5G(无充版)',
-        id: 100016015104,
-        active: true,
-        disable: true
-      },
-      {
-        name: '5G(无充)质保换新版',
-        id: 100016015125,
-        active: false,
-        disable: false
-      }
-    ]
-  }
-];
-
-export const Goods = {
-  skuId: '100016015112',
-  price: '4599.00',
-  imagePath:
-    '//m.360buyimg.com/mobilecms/s750x750_jfs/t1/210630/17/8651/208682/618a5bd6Eddc8ea0e/b5e55e1a03bc0126.jpg!q80.dpg.webp'
-};
-
-export const imagePathMap = {
-  100016015112:
-    '//m.360buyimg.com/mobilecms/s750x750_jfs/t1/210630/17/8651/208682/618a5bd6Eddc8ea0e/b5e55e1a03bc0126.jpg!q80.dpg.web',
-  100016015142: '//img14.360buyimg.com/n4/jfs/t1/216079/14/3895/201095/618a5c0cEe0b9e2ba/cf5b98fb6128a09e.jpg',
-  100016015078: '//img14.360buyimg.com/n4/jfs/t1/215845/12/3788/221990/618a5c4dEc71cb4c7/7bd6eb8d17830991.jpg',
-  100009064831: '//img14.360buyimg.com/n4/jfs/t1/203247/8/14659/237368/618a5c87Ecc968774/b0bb25331e5e2d1a.jpg',
-  100009064830: '//img14.360buyimg.com/n4/jfs/t1/160950/40/25098/234168/618a5cb9E65ba975e/7f8f93ea7767a51b.jpg'
-};

+ 8 - 0
src/packages/utils/util.ts

@@ -130,3 +130,11 @@ export function preventDefault(event: Event, isStopPropagation?: boolean) {
     event.stopPropagation();
   }
 }
+
+export const padZero = (num: number | string, length = 2): string => {
+  num += '';
+  while ((num as string).length < length) {
+    num = '0' + num;
+  }
+  return num.toString();
+};