From 07925905f1a596e20e980de6d42db217abb753b0 Mon Sep 17 00:00:00 2001
From: cuiqian2004 <cuiqian2004@163.com>
Date: 星期五, 12 十二月 2025 18:06:11 +0800
Subject: [PATCH] plugin
---
js/Page.js | 89 ++++++++++++++++++++++++++++++--------------
1 files changed, 61 insertions(+), 28 deletions(-)
diff --git a/js/Page.js b/js/Page.js
index a2debda..11e11d3 100644
--- a/js/Page.js
+++ b/js/Page.js
@@ -1,4 +1,3 @@
-
/* export function setData(dataset) {
for (let field in dataset) {
// 閫氳繃姝e垯琛ㄨ揪寮� 鏌ユ壘璺緞鏁版嵁
@@ -16,13 +15,13 @@
*/
//import WXBizDataCrypt from "./WXBizDataCrypt.js"
//var WXBizDataCrypt = require('./WXBizDataCrypt')
-export function showModal(message,title='鎻愮ず',iscancel=true) {
+export function showModal(message, title = '鎻愮ず', iscancel = true) {
return new Promise((resolve) => {
uni.showModal({
title: title,
content: message,
showCancel: iscancel,
- success: function (res) {
+ success: function(res) {
if (res.confirm) {
resolve(true)
} else if (res.cancel) {
@@ -30,52 +29,53 @@
}
}
});
- })
-}
-
-export function showToast(title,icon){
- uni.showToast({
- title: title,
- icon: icon?icon:'none'
})
}
-export function showLoading(title){
-
+
+export function showToast(title,duration="short") {
+ // uni.showToast({
+ // title: title,
+ // icon: icon?icon:'none'
+ // })
+ plus.nativeUI.toast(title, {duration});
+}
+export function showLoading(title) {
+
// #ifdef MP-WEIXIN
- uni.showLoading({
- title:title,
- mask:true
- })
+ uni.showLoading({
+ title: title,
+ mask: true
+ })
// #endif
// #ifndef MP-WEIXIN
- uni.showLoading({
- title:title
- })
+ uni.showLoading({
+ title: title
+ })
// #endif
}
-export function hideLoading(){
-
+export function hideLoading() {
+
uni.hideLoading()
}
-
+
//鏍规嵁field鑾峰彇鏁版嵁
-export function getData(thiz,field){
+export function getData(thiz, field) {
// 閫氳繃姝e垯琛ㄨ揪寮� 鏌ユ壘璺緞鏁版嵁
const regex = /([\w$]+)|\[(:\d)\]/g
const patten = field.match(regex)
let result = thiz // 鎸囧悜璋冪敤鐨勬暟鎹�濡俤ata
// 閬嶅巻璺緞 閫愮骇鏌ユ壘 鏈�悗涓�骇鐢ㄤ簬鐩存帴璧嬪�
for (let i = 0; i < patten.length - 1; i++) {
- let key = patten[i]
- result = result[key]
+ let key = patten[i]
+ result = result[key]
}
return result[patten[patten.length - 1]]
}
//椤甸潰鐐瑰嚮鏃跺鍙傛暟杩涜浜嗚浆涔夛紝瑕佽繘琛屽弽杞箟
-export function getOption(option){
- if(option !== null && typeof option === 'object'){
+export function getOption(option) {
+ if (option !== null && typeof option === 'object') {
for (let key in option) {
option[key] = decodeURIComponent(option[key])
}
@@ -83,4 +83,37 @@
return option
}
-
\ No newline at end of file
+export function showInfo(ex){
+ if( !ex)
+ return
+ let tip =ex
+ console.log(ex);
+ if( typeof ex !== "string" )
+ {
+ let exStr = JSON.stringify(ex)
+ if (exStr == "{}")
+ exStr = ex
+ tip = typeof ex.errMsg == "string" ? ex.errMsg :typeof ex.message == "string" ? ex.message: exStr
+ }
+ plus.nativeUI.toast(`<div>${tip}</div>` , {verticalAlign:"center",type:"richtext",duration:"short"});
+}
+
+export function showError(ex,title=""){
+ if( !ex)
+ return
+ let tip =ex
+ console.log(ex);
+ if( typeof ex !== "string" )
+ {
+ let exStr = JSON.stringify(ex)
+ if (exStr == "{}")
+ exStr = ex
+ tip = typeof ex.errMsg == "string" ? ex.errMsg :typeof ex.message == "string" ? ex.message: exStr
+ }
+ plus.nativeUI.alert(tip,title);
+ // uni.showModal({
+ // title: title ||"",
+ // content: tip,,
+ // showCancel: false
+ // });
+}
\ No newline at end of file
--
Gitblit v1.9.1