
/**
* 显示消息提示框
* @param content 提示的标题
*/
export function toast(content:string):void {
  uni.showToast({
    icon: 'none',
    title: content
  })
}

/**
* 显示模态弹窗
* @param content 提示的标题
*/
export function showConfirm(content:string):Promise<UniShowModalResult> {
  return new Promise((resolve) => {
    uni.showModal({
      title: '提示',
      content: content,
      cancelText: '取消',
      confirmText: '确定',
      success: function(res) {
		resolve(res)
      }
    })
  })
}

/**
* 参数处理
* @param params 参数
*/
export function tansParams(params:UTSJSONObject):string {
  let result:string = ''
  // #ifdef WEB
  let paramKeys=Object.keys(params)
  // #endif
  // #ifndef WEB
  let paramKeys=UTSJSONObject.keys(params)
  // #endif
  for (const propName in paramKeys) {
    let value:any|null= params[propName] 
    var part:string = encodeURIComponent(propName) + "="
    if (value !== null && value !== "" && typeof (value) !== "undefined") {
      if (typeof value === 'object') {
		  // #ifdef WEB
		  let valueKeys=Object.keys(value)
		  // #endif
		  // #ifndef WEB
		 let valueJson:UTSJSONObject|null=params.getJSON(propName)
		  let valueKeys=valueJson===null?[]:UTSJSONObject.keys(valueJson)
		  // #endif
        for (const key in valueKeys) {
			// #ifdef WEB
			let newValue=value[key]
			// #endif
			// #ifndef WEB
			 let newValue=valueJson?.getString(key)
			// #endif
          if (newValue !== null && newValue !== "" && typeof (newValue) !== 'undefined') {
            let params:string = propName + '[' + key + ']'
            var subPart:string = encodeURIComponent(params) + "="
            result += subPart + encodeURIComponent(newValue) + "&"
          }
        }
      } else {
		  // #ifdef APP-ANDROID
		  value=value as string
		  // #endif
        result += part + encodeURIComponent(value) + "&"
      }
    }
  }
  return result
}