提交 0c5454f5 编写于 作者: d-u-a's avatar d-u-a

update: unicloud-db add|remove|update 方法新增可选参数 needConfirm,needLoading,loadingTitle

上级 edf77078
......@@ -272,9 +272,16 @@ export default {
toastTitle,
success,
fail,
complete
complete,
needConfirm = true,
needLoading = true,
loadingTitle = ''
} = {}) {
uni.showLoading()
if (needLoading) {
uni.showLoading({
title: loadingTitle
})
}
/* eslint-disable no-undef */
let db = uniCloud.database()
if (action) {
......@@ -290,12 +297,16 @@ export default {
}
}).catch((err) => {
fail && fail(err)
uni.showModal({
content: err.message,
showCancel: false
})
if (needConfirm) {
uni.showModal({
content: err.message,
showCancel: false
})
}
}).finally(() => {
uni.hideLoading()
if (needLoading) {
uni.hideLoading()
}
complete && complete()
})
},
......@@ -305,11 +316,18 @@ export default {
fail,
complete,
confirmTitle,
confirmContent
confirmContent,
needConfirm = true,
needLoading = true,
loadingTitle = ''
} = {}) {
if (!id || !id.length) {
return
}
if (!needConfirm) {
this._execRemove(id, action, success, fail, complete, needConfirm, needLoading, loadingTitle)
return
}
uni.showModal({
title: confirmTitle || t('uniCloud.component.remove.showModal.title'),
content: confirmContent || t('uniCloud.component.remove.showModal.content'),
......@@ -318,7 +336,7 @@ export default {
if (!res.confirm) {
return
}
this._execRemove(id, action, success, fail, complete)
this._execRemove(id, action, success, fail, complete, needConfirm, needLoading, loadingTitle)
}
})
},
......@@ -328,9 +346,16 @@ export default {
toastTitle,
success,
fail,
complete
complete,
needConfirm = true,
needLoading = true,
loadingTitle = ''
} = {}) {
uni.showLoading()
if (needLoading) {
uni.showLoading({
title: loadingTitle
})
}
/* eslint-disable no-undef */
let db = uniCloud.database()
if (action) {
......@@ -346,12 +371,16 @@ export default {
}
}).catch((err) => {
fail && fail(err)
uni.showModal({
content: err.message,
showCancel: false
})
if (needConfirm) {
uni.showModal({
content: err.message,
showCancel: false
})
}
}).finally(() => {
uni.hideLoading()
if (needLoading) {
uni.hideLoading()
}
complete && complete()
})
},
......@@ -465,7 +494,7 @@ export default {
return db
},
_execRemove (id, action, success, fail, complete) {
_execRemove (id, action, success, fail, complete, needConfirm, needLoading, loadingTitle) {
if (!this.collection || !id) {
return
}
......@@ -475,9 +504,12 @@ export default {
return
}
uni.showLoading({
mask: true
})
if (needLoading) {
uni.showLoading({
mask: true,
title: loadingTitle
})
}
/* eslint-disable no-undef */
const db = uniCloud.database()
......@@ -499,12 +531,16 @@ export default {
}
}).catch((err) => {
fail && fail(err)
uni.showModal({
content: err.message,
showCancel: false
})
if (needConfirm) {
uni.showModal({
content: err.message,
showCancel: false
})
}
}).finally(() => {
uni.hideLoading()
if (needLoading) {
uni.hideLoading()
}
complete && complete()
})
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册