Parcourir la source

阻止联系人

tags/AL.0.8.0_20240113_base
yuan il y a 1 an
Parent
révision
fdd5932a26
2 fichiers modifiés avec 46 ajouts et 9 suppressions
  1. +32
    -7
      src/pages/contact-edit/index.vue
  2. +14
    -2
      src/stores/contact-item.ts

+ 32
- 7
src/pages/contact-edit/index.vue Voir le fichier

@@ -12,6 +12,7 @@ const contact = useContactItemStore()
const contacts = useContactsStore()
contact.setContact(contactData)
const showDeleteConfirmMenu = ref(false)
const showBlockConfirmMenu = ref(false)

const goBack = () => {
Router.back()
@@ -50,7 +51,31 @@ const onSaveClicked = () => {
}
const onDeleteVisitor = () => {
showDeleteConfirmMenu.value = true
//
}

const onBlockVisitor = () => {
showBlockConfirmMenu.value = true
}
const onBlockConfirm = (item) => {
console.log(item)
Taro.showLoading({
title: 'loading',
})

contact.setBlockStatus(!contactData.isBlock).then(r => {
contacts.loadContactsFromServer().then( contactsResult => {
contactData.isBlock = !contactData.isBlock
Taro.hideLoading()
})
}).catch(error => {
Taro.hideLoading()
Taro.showToast({
title: '网络异常,请稍候重试',
icon: 'none',
duration: 2000
})
console.log("error", error)
})
}
const onDeleteConfirm = (item) => {
console.log(item)
@@ -73,6 +98,7 @@ const onDeleteConfirm = (item) => {
console.log("error", error)
})
}

</script>

<template>
@@ -111,7 +137,8 @@ const onDeleteConfirm = (item) => {
</nut-cell>

<view class="p-3">
<nut-button block color="red" plain>加入黑名单</nut-button>
<nut-button v-if="contactData.isBlock" block color="red" plain @tap="onBlockConfirm">取消阻止此联系人</nut-button>
<nut-button v-else block color="red" plain @tap="onBlockVisitor">阻止此联系人</nut-button>
</view>

<view class="p-3 pb-5">
@@ -120,12 +147,10 @@ const onDeleteConfirm = (item) => {
</view>
</view>

<nut-action-sheet v-model:visible="showDeleteConfirmMenu" :menu-items="[{name: '确认删除'}]" cancel-txt="取消" @choose="onDeleteConfirm">
<nut-action-sheet v-model:visible="showDeleteConfirmMenu" title="此联系人将从公司联系人中删除,并不可恢复。" :menu-items="[{name: '删除'}]" cancel-txt="取消" @choose="onDeleteConfirm">
</nut-action-sheet>
<nut-action-sheet v-model:visible="showBlockConfirmMenu" title="此联系人到访时将会发出警告通知。" :menu-items="[{name: '阻止联系人'}]" cancel-txt="取消" @choose="onBlockConfirm">
</nut-action-sheet>






</template>

+ 14
- 2
src/stores/contact-item.ts Voir le fichier

@@ -70,6 +70,15 @@ export const useContactItemStore = defineStore('contact-item', () => {
}
`

const CHANGE_BLOCK_STATUS = gql`
mutation UpdateVisitor($id: Long!, $isBlock: Boolean ) {
updateVisitor( input: {
id: $id,
isBlock: $isBlock
} )
}
`

function createVisitor() {
const name = contact.value.name
const nickName = contact.value.nickName
@@ -128,8 +137,11 @@ export const useContactItemStore = defineStore('contact-item', () => {
.catch(e=> reject(e))
}
})
}


function setBlockStatus(isBlock: Boolean) {
const id = contact.value.id
return GQLRequest.query(CHANGE_BLOCK_STATUS, { id, isBlock })
}

function deleteVisitor() {
@@ -161,5 +173,5 @@ export const useContactItemStore = defineStore('contact-item', () => {
}


return { contact, setContact, createVisitor, updateVisitor, deleteVisitor, getEmptyContactData, setNewAvatar}
return { contact, setContact, createVisitor, updateVisitor, deleteVisitor, getEmptyContactData, setNewAvatar, setBlockStatus }
})

Chargement…
Annuler
Enregistrer