wangxy 2 hónapja
szülő
commit
ad25d34d5e
1 módosított fájl, 51 hozzáadás és 30 törlés
  1. 51 30
      utils/common.js

+ 51 - 30
utils/common.js

@@ -1,40 +1,40 @@
 /**
-* 显示消息提示框
-* @param content 提示的标题
-*/
+ * 显示消息提示框
+ * @param content 提示的标题
+ */
 export function toast(content) {
-  uni.showToast({
-    icon: 'none',
-    title: content
-  })
+	uni.showToast({
+		icon: 'none',
+		title: content
+	})
 }
 
 /**
-* 显示模态弹窗
-* @param content 提示的标题
-*/
+ * 显示模态弹窗
+ * @param content 提示的标题
+ */
 export function showConfirm(content) {
-  return new Promise((resolve, reject) => {
-    uni.showModal({
-      title: '提示',
-      content: content,
-      cancelText: '取消',
-      confirmText: '确定',
-      success: function(res) {
-        resolve(res)
-      }
-    })
-  })
+	return new Promise((resolve, reject) => {
+		uni.showModal({
+			title: '提示',
+			content: content,
+			cancelText: '取消',
+			confirmText: '确定',
+			success: function(res) {
+				resolve(res)
+			}
+		})
+	})
 }
 
 /**
-* 参数处理
-* @param params 参数
-*/
+ * 参数处理
+ * @param params 参数
+ */
 export function tansParams(params) {
-  let result = ''
-  // FIXME   拼接参数 
-  return result
+	let result = ''
+	// FIXME   拼接参数 
+	return result
 }
 
 export function getStaticUrl(url) {
@@ -42,11 +42,32 @@ export function getStaticUrl(url) {
 	// #ifdef H5
 	result = `/mdist/${url}`
 	// #endif
-	
+
 	// #ifdef APP-PLUS
 	result = url
 	// #endif
-	
+
 	return result;
 }
-	
+
+
+/************* 将时间格式化成 年月+日 ***********/
+export function formatDateToYearMonthDay(dateStr) {
+	let date = new Date(dateStr);
+	let dataStr1 =
+		`${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}`
+	const yearMonth = dataStr1.substring(0, 7); // "2025-06"
+	const day = dataStr1.substring(8); // "01"
+	return [yearMonth, day]
+}
+
+export function getStringByHtml3(html) {
+	return html ? html.replace(/<img [^.]*">/g, '')
+		.replace(/<(style|script|iframe)[^>]*?>[\s\S]+?<\/\1\s*>/gi, '')
+		.replace(/<[^>]+?>/g, '')
+		.replace(/\s+/g, ' ')
+		.replace(/ /g, ' ')
+		.replace(/>/g, ' ')
+		.replace(/<?img[^>]*>/g, '')
+		.replace(/<video[^>]*>.*?<\/video>/gi, '') : '';
+}