import sj_show_modal from './index.js';

const g_show_modal = {
	install: function(Vue) {
		// #ifdef APP-PLUS
		Vue.prototype.$showModal=function(op={}){
			return	new Promise((resolve, reject)=>{
			    let ssm=new sj_show_modal({
					...op,
					$event:function(e){
						if(e.res){
							resolve(e);
						}else{
							reject(e);
						}
					 }
				})
				ssm.show();
				Vue.prototype.$hide=function(){
					ssm.hide();
				}
			})
		}
		// #endif
		
		//不是APP 还是用原来的 
		// #ifndef APP-PLUS
		Vue.prototype.$showModal = function(op={}){
			return	new Promise((resolve, reject)=>{
				uni.showModal({
				    title: op.title,
				    content: op.concent,
					confirmText:op.confirmVal,
					cancelText:op.cancelVal,
				    success:  (res)=> {
				        if (res.confirm) {
							resolve();
				        } else if (res.cancel) {
							reject();
				        }
				    }
				});
			})
		}
		// #endif
		
	}
};


export default g_show_modal
