You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
import Taro from "@tarojs/taro" ;
export const goOpenSetting = ( ) => {
//去设置页的弹框
return new Promise ( ( reslove , reject ) => {
Taro . showModal ( {
title : "提示" ,
content : "请点击授权地址" ,
success ( res ) {
if ( res . confirm ) {
Taro . openSetting ( ) ;
}
} ,
} ) ;
} ) ;
} ;
export const goOpenSettingPhotos = ( ) => {
//去设置页的弹框
return new Promise ( ( reslove , reject ) => {
Taro . showModal ( {
title : "提示" ,
content : "请点击打开权限" ,
success ( res ) {
if ( res . confirm ) {
Taro . openSetting ( ) ;
}
} ,
} ) ;
} ) ;
} ;
export const authorize = ( scope ) => {
return new Promise ( ( reslove , reject ) => {
Taro . authorize ( {
scope : scope ,
success ( res ) {
console . log ( "authorize授权状态" ) ;
reslove ( res ) ;
} ,
fail ( err ) {
reject ( err ) ;
} ,
} ) ;
} ) ;
} ;
export const back = ( delta ) => {
Taro . navigateBack ( {
delta ,
} ) ;
} ;
export const msg = ( title , mask , icon ) => {
Taro . showToast ( {
title ,
mask ,
icon : icon || "none" ,
duration : 2000 ,
} ) ;
} ;
export const go = ( url ) => {
Taro . navigateTo ( {
url ,
} ) ;
} ;
export const loading = ( title ) => {
Taro . showToast ( {
title ,
mask : true ,
icon : "loading" ,
} ) ;
} ;
// 加载中, 显示隐藏搭配使用, 不能和toast一起用
export const showLoading = ( title ) => {
Taro . showLoading ( {
title ,
mask : true ,
} ) ;
} ;
export const hideLoading = ( title ) => {
Taro . hideLoading ( ) ;
} ;
export const showModal = ( data ) => {
const {
t1 = "提示" ,
t2 = "" ,
btn1show = true ,
btn1text = "取消" ,
btn2text = "确定" ,
inputshow = false ,
inputtext = "请输入" ,
} = data ;
return new Promise ( ( reslove , reject ) => {
Taro . showModal ( {
title : t1 ,
content : t2 ,
showCancel : btn1show ,
cancelText : btn1text ,
confirmText : btn2text ,
editable : inputshow ,
placeholderText : inputtext ,
success ( res ) {
if ( res . confirm || res . content ) {
reslove ( res ) ;
} else {
reject ( res ) ;
}
} ,
} ) ;
} ) ;
} ;
export const requestPayment = ( data ) => {
//拉起微信支付
return new Promise ( ( reslove , reject ) => {
Taro . requestPayment ( {
timeStamp : data . timeStamp ,
nonceStr : data . nonceStr ,
package : data . package ,
signType : data . signType ,
paySign : data . paySign ,
success ( res ) {
reslove ( res ) ;
} ,
fail ( res ) {
reject ( res ) ;
} ,
complete ( ) {
Taro . hideLoading ( ) ;
} ,
} ) ;
} ) ;
} ;