fxl 1 kuukausi sitten
vanhempi
commit
270640f6b9

+ 28 - 19
pages/index/index.vue

@@ -47,19 +47,18 @@
 		  </view>
 		  
 		  <NumbersChoose class="phonenumber-choose-component"
-		    :visible="isChooseNumberVisible[item.id] || false"
-		    :title="item.displayName"
-		    @update:visible="(visible) => this.$set(isChooseNumberVisible, item.id, visible)"
-		  >
-		    <template #default>
-		  	    <scrollable-box  class="numbers">
+			:visible="isChooseNumberVisible[item.id] || false"
+			:title="item.displayName"
+			@update:visible="(visible) => this.$set(isChooseNumberVisible, item.id, visible)">
+			<template #default>
+				<div class="scrollable-box">
 					<view v-for="(number, index) in item.phoneNumbers" :key="index" @click="CallPhone(item,number.value)">
-					    <text class="choose-phonenumber" >				
+						<text class="choose-phonenumber">
 						  {{formatPhoneNumber1(number.value) }}
 						</text>	
 					</view>
-				</scrollable-box>
-		    </template>
+				</div>
+			</template>
 		  </NumbersChoose>
 		  <!-- :style="{backgroundColor:isActive ? 'grey' :'white'}"
 		  @touchedstart="handleTouchedStart"
@@ -179,16 +178,20 @@
 		      }
 		    },
 			formatPhoneNumber1(value) {
-			  // 移除所有非数字字符
-			  value = value.replace(/\D/g, '');
+			    // 移除所有非数字字符
+			    value = value.replace(/\D/g, '');
 			
-			  if (value.length === 11) {
-			    // 如果长度为11,在第4位和第7位插入空格,并在第7位后添加换行符
-			    return value.replace(/(\d{3})(\d{4})(\d{4})/, '$1\n$2 $3');
-			  } else {
-			    // 如果长度不为11,每4个字符插入一个空格,并在第7位后添加换行符
-			    return value.replace(/(\d{4})(\d{3})/, '$1\n$2').replace(/(\d{4})(?=\d)/g, '$1 ');
-			  }
+			    if (value.length === 11) {
+			        // 如果长度为11,在第三位后插入换行符,并在第七位添加空格
+			        return value.replace(/(\d{3})(\d{4})(\d{4})/, '$1\n$2 $3');
+			    } else if (value.length > 11) {
+			        // 如果长度大于11,在第三位后插入换行符,并在第七位添加空格,11位之后显示省略号
+			        return value.replace(/(\d{3})(\d{4})(\d{4})/, '$1\n$2 $3') + '...';
+			    } else {
+			        // 如果长度不为11且小于11位,每4个字符插入一个空格,并在第7位后添加换行符
+			        // 这个分支可能不需要,因为根据前面的条件,号码长度应该至少为11位
+			        return value.replace(/(\d{4})(\d{3})/, '$1\n$2').replace(/(\d{4})(?=\d)/g, '$1 ');
+			    }
 			},
   			truncate(value) {
 		      if (value.length > 9) {
@@ -624,7 +627,13 @@
 	margin-top: 10px;
 	margin-bottom: 10px;
 	
-}	
+}
+	
+.scrollable-box {
+    height: 700rpx; /* 或者你希望的高度 */
+    overflow-y: auto; /* 当内容超出时显示垂直滚动条 */
+    scrollbar-width: thin; /* 可选,设置滚动条的宽度 */
+}
 
 .choose-phonenumber{
 	display: flex;

+ 50 - 59
unpackage/dist/dev/app-plus/app-service.js

@@ -85444,13 +85444,13 @@ if (uni.restoreGlobal) {
     },
     methods: {
       showChooseNumber(item, phoneNumber) {
-        formatAppLog("log", "at pages/index/index.vue:143", "showChooseNumber called");
-        formatAppLog("log", "at pages/index/index.vue:144", new Error().stack);
+        formatAppLog("log", "at pages/index/index.vue:142", "showChooseNumber called");
+        formatAppLog("log", "at pages/index/index.vue:143", new Error().stack);
         if (item.phoneNumbers.length > 1) {
           this.$set(this.isChooseNumberVisible, item.id, true);
-          formatAppLog("log", "at pages/index/index.vue:147", "isChooseNumberVisible", this.isChooseNumberVisible);
+          formatAppLog("log", "at pages/index/index.vue:146", "isChooseNumberVisible", this.isChooseNumberVisible);
         } else {
-          formatAppLog("log", "at pages/index/index.vue:150", "这里对方只有一个电话号码");
+          formatAppLog("log", "at pages/index/index.vue:149", "这里对方只有一个电话号码");
           this.CallPhone(item, phoneNumber);
         }
       },
@@ -85464,7 +85464,7 @@ if (uni.restoreGlobal) {
         this.isActive = false;
       },
       toNum(e) {
-        formatAppLog("log", "at pages/index/index.vue:165", "num", e);
+        formatAppLog("log", "at pages/index/index.vue:164", "num", e);
         this.num = e;
       },
       // 格式化电话号码
@@ -85480,6 +85480,8 @@ if (uni.restoreGlobal) {
         value = value.replace(/\D/g, "");
         if (value.length === 11) {
           return value.replace(/(\d{3})(\d{4})(\d{4})/, "$1\n$2 $3");
+        } else if (value.length > 11) {
+          return value.replace(/(\d{3})(\d{4})(\d{4})/, "$1\n$2 $3") + "...";
         } else {
           return value.replace(/(\d{4})(\d{3})/, "$1\n$2").replace(/(\d{4})(?=\d)/g, "$1 ");
         }
@@ -85493,33 +85495,33 @@ if (uni.restoreGlobal) {
       },
       init() {
         FvvUniTTS$1.init((callback) => {
-          formatAppLog("log", "at pages/index/index.vue:207", callback);
+          formatAppLog("log", "at pages/index/index.vue:210", callback);
         }, "com.iflytek.speechcloud");
         FvvUniTTS$1.onStart((res) => {
-          formatAppLog("log", "at pages/index/index.vue:211", "onStart:" + res);
+          formatAppLog("log", "at pages/index/index.vue:214", "onStart:" + res);
         });
         FvvUniTTS$1.onDone((res) => {
-          formatAppLog("log", "at pages/index/index.vue:215", "onDone:" + res);
+          formatAppLog("log", "at pages/index/index.vue:218", "onDone:" + res);
         });
         FvvUniTTS$1.onError((res) => {
-          formatAppLog("log", "at pages/index/index.vue:219", "onError:" + res);
+          formatAppLog("log", "at pages/index/index.vue:222", "onError:" + res);
         });
         FvvUniTTS$1.getInstallTTS((res) => {
-          formatAppLog("log", "at pages/index/index.vue:222", res + "11");
+          formatAppLog("log", "at pages/index/index.vue:225", res + "11");
         });
       },
       play(e) {
-        formatAppLog("log", "at pages/index/index.vue:226", "xinxi", e);
+        formatAppLog("log", "at pages/index/index.vue:229", "xinxi", e);
         FvvUniTTS$1.speak({
           text: e,
           id: 2
         });
         FvvUniTTS$1.getInstallTTS((res) => {
-          formatAppLog("log", "at pages/index/index.vue:233", res + "11");
+          formatAppLog("log", "at pages/index/index.vue:236", res + "11");
         });
       },
       setLanguage() {
-        formatAppLog("log", "at pages/index/index.vue:237", "set lang : " + FvvUniTTS$1.setLanguage("CHINESE"));
+        formatAppLog("log", "at pages/index/index.vue:240", "set lang : " + FvvUniTTS$1.setLanguage("CHINESE"));
       },
       setEngines() {
         let setEngine = "com.iflytek.speechcloud";
@@ -85527,12 +85529,12 @@ if (uni.restoreGlobal) {
           if (res == null || res.length <= 0) {
             return;
           }
-          formatAppLog("log", "at pages/index/index.vue:247", res);
+          formatAppLog("log", "at pages/index/index.vue:250", res);
           if (JSON.stringify(res).indexOf(setEngine) < 0) {
-            formatAppLog("log", "at pages/index/index.vue:249", "未安装该语音引擎");
+            formatAppLog("log", "at pages/index/index.vue:252", "未安装该语音引擎");
             return;
           }
-          formatAppLog("log", "at pages/index/index.vue:252", "set engine : " + FvvUniTTS$1.setEngine(setEngine));
+          formatAppLog("log", "at pages/index/index.vue:255", "set engine : " + FvvUniTTS$1.setEngine(setEngine));
           FvvUniTTS$1.speak({
             text: "设置成功",
             id: 2
@@ -85574,7 +85576,7 @@ if (uni.restoreGlobal) {
         plus.contacts.getAddressBook(plus.contacts.ADDRESSBOOK_PHONE, function(addressbook) {
           addressbook.find(["displayName", "phoneNumbers"], function(contacts) {
             that.list = contacts;
-            formatAppLog("log", "at pages/index/index.vue:300", that.list);
+            formatAppLog("log", "at pages/index/index.vue:303", that.list);
             that.list.sort(function(a, b) {
               const isChinese = (str) => /^[\u4e00-\u9fa5]+$/.test(str);
               const isEnglish = (str) => /^[A-Za-z]+$/.test(str);
@@ -85599,9 +85601,9 @@ if (uni.restoreGlobal) {
                 return firstCharA.localeCompare(firstCharB);
               }
             });
-            formatAppLog("log", "at pages/index/index.vue:341", "list", that.list);
+            formatAppLog("log", "at pages/index/index.vue:344", "list", that.list);
             that.filteredContacts = that.list;
-            formatAppLog("error", "at pages/index/index.vue:343", "更新过滤后的联系人列表", that.filteredContacts);
+            formatAppLog("error", "at pages/index/index.vue:346", "更新过滤后的联系人列表", that.filteredContacts);
           }, function() {
             uni.showToast({
               title: "获取联系人失败",
@@ -85621,7 +85623,7 @@ if (uni.restoreGlobal) {
         Object.keys(this.isChooseNumberVisible).forEach((key) => {
           this.$set(this.isChooseNumberVisible, key, false);
         });
-        formatAppLog("log", "at pages/index/index.vue:363", "ischooseNumber", this.isChooseNumberVisible);
+        formatAppLog("log", "at pages/index/index.vue:366", "ischooseNumber", this.isChooseNumberVisible);
         plus.device.dial(e, false);
         Object.keys(this.isChooseNumberVisible).forEach((key) => {
           this.$set(this.isChooseNumberVisible, key, false);
@@ -85629,9 +85631,9 @@ if (uni.restoreGlobal) {
       },
       filterContacts() {
         const searchText = this.searchText.toLowerCase();
-        formatAppLog("log", "at pages/index/index.vue:373", "输入内容", searchText);
+        formatAppLog("log", "at pages/index/index.vue:376", "输入内容", searchText);
         if (!searchText) {
-          formatAppLog("log", "at pages/index/index.vue:376", "kong");
+          formatAppLog("log", "at pages/index/index.vue:379", "kong");
           this.filteredContacts = this.list;
         } else {
           this.filteredContacts = this.list.filter((contact) => {
@@ -85647,19 +85649,19 @@ if (uni.restoreGlobal) {
       },
       //进行页面跳转到联系人详情
       goToDetails(item) {
-        formatAppLog("error", "at pages/index/index.vue:402", "item", item);
+        formatAppLog("error", "at pages/index/index.vue:405", "item", item);
         const phoneNumbers = item.phoneNumbers;
         const phoneNumbersString = JSON.stringify(phoneNumbers);
         const phoenNumberCount = item.phoneNumbers.length;
-        formatAppLog("error", "at pages/index/index.vue:406", "phonenumber", phoneNumbers);
-        formatAppLog("error", "at pages/index/index.vue:407", "phoenNumberCount", phoenNumberCount);
+        formatAppLog("error", "at pages/index/index.vue:409", "phonenumber", phoneNumbers);
+        formatAppLog("error", "at pages/index/index.vue:410", "phoenNumberCount", phoenNumberCount);
         uni.navigateTo({
           url: `/pages/ContactDetails/ContactDetails?name=${encodeURIComponent(item.displayName)}&phoneNumbers=${encodeURIComponent(phoneNumbersString)}&count=${phoenNumberCount}`
         });
       },
       getM() {
         const storedSwitchStatus = uni.getStorageSync("voiceBroadcastSwitch");
-        formatAppLog("log", "at pages/index/index.vue:415", "读取的本地存储状态1:", storedSwitchStatus);
+        formatAppLog("log", "at pages/index/index.vue:418", "读取的本地存储状态1:", storedSwitchStatus);
         if (typeof storedSwitchStatus === "boolean") {
           this.switchStatus = storedSwitchStatus;
         }
@@ -85670,7 +85672,6 @@ if (uni.restoreGlobal) {
     }
   };
   function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
-    const _component_scrollable_box = vue.resolveComponent("scrollable-box");
     const _component_NumbersChoose = vue.resolveComponent("NumbersChoose");
     return vue.openBlock(), vue.createElementBlock("view", { class: "content" }, [
       $data.searchActive ? (vue.openBlock(), vue.createElementBlock("view", {
@@ -85787,38 +85788,28 @@ if (uni.restoreGlobal) {
                   "onUpdate:visible": (visible) => this.$set($data.isChooseNumberVisible, item.id, visible)
                 }, {
                   default: vue.withCtx(() => [
-                    vue.createVNode(
-                      _component_scrollable_box,
-                      { class: "numbers" },
-                      {
-                        default: vue.withCtx(() => [
-                          (vue.openBlock(true), vue.createElementBlock(
-                            vue.Fragment,
-                            null,
-                            vue.renderList(item.phoneNumbers, (number, index) => {
-                              return vue.openBlock(), vue.createElementBlock("view", {
-                                key: index,
-                                onClick: ($event) => $options.CallPhone(item, number.value)
-                              }, [
-                                vue.createElementVNode(
-                                  "text",
-                                  { class: "choose-phonenumber" },
-                                  vue.toDisplayString($options.formatPhoneNumber1(number.value)),
-                                  1
-                                  /* TEXT */
-                                )
-                              ], 8, ["onClick"]);
-                            }),
-                            128
-                            /* KEYED_FRAGMENT */
-                          ))
-                        ]),
-                        _: 2
-                        /* DYNAMIC */
-                      },
-                      1024
-                      /* DYNAMIC_SLOTS */
-                    )
+                    vue.createElementVNode("div", { class: "scrollable-box" }, [
+                      (vue.openBlock(true), vue.createElementBlock(
+                        vue.Fragment,
+                        null,
+                        vue.renderList(item.phoneNumbers, (number, index) => {
+                          return vue.openBlock(), vue.createElementBlock("view", {
+                            key: index,
+                            onClick: ($event) => $options.CallPhone(item, number.value)
+                          }, [
+                            vue.createElementVNode(
+                              "text",
+                              { class: "choose-phonenumber" },
+                              vue.toDisplayString($options.formatPhoneNumber1(number.value)),
+                              1
+                              /* TEXT */
+                            )
+                          ], 8, ["onClick"]);
+                        }),
+                        128
+                        /* KEYED_FRAGMENT */
+                      ))
+                    ])
                   ]),
                   _: 2
                   /* DYNAMIC */

+ 5 - 0
unpackage/dist/dev/app-plus/pages/index/index.css

@@ -310,6 +310,11 @@
 	margin-top: 10px;
 	margin-bottom: 10px;
 }
+.scrollable-box {
+    height: 21.875rem; /* 或者你希望的高度 */
+    overflow-y: auto; /* 当内容超出时显示垂直滚动条 */
+    scrollbar-width: thin; /* 可选,设置滚动条的宽度 */
+}
 .choose-phonenumber{
 	display: flex;
 	text-align: center;