action.js 1.2 KB
Newer Older
DCloud_JSON's avatar
DCloud_JSON 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
const db = uniCloud.database();
export default async function({
	subType,
	confirm,
	cancel,
	item
},callback) {
	console.log({
		subType,
		confirm,
		cancel,
		item
	})
	switch (subType) {
		case 'uni-im-friend-invite':
			uni.showLoading({
				mask:false
			})
			return db.collection("uni-im-friend-invite")
					.doc(item.payload.data._id)
					.update({
						state:confirm?100:-100
					})
					.then((res) => {
						uni.hideLoading()
						callback()
					}).catch((err) => {
						console.log(err);
						uni.showModal({
							content: err.message || '请求服务失败',
							showCancel: false
						})
					})
			break;
		case 'uni-im-group-join-request':
			uni.showLoading({
				mask:false
			})
			let res = await db.collection('uni-im-group-join')
							.where({
								_id:item.payload.data.doc_id
							})
							.update({
								state:confirm?100:-100
							})
							.then((res) => {
								callback()
							}).catch((err) => {
								console.log(err);
								uni.showModal({
									content: err.message || '请求服务失败',
									showCancel: false
								})
							})
DCloud_JSON's avatar
3.4.31  
DCloud_JSON 已提交
55 56 57
              .finally(() => {
                uni.hideLoading()
              })
DCloud_JSON's avatar
DCloud_JSON 已提交
58 59 60 61 62 63
			break;
		default:
			console.log({subType})
			break;
	}
}