diff --git a/src/api/smoke.js b/src/api/smoke.js
index 43a2bc9..44300cf 100644
--- a/src/api/smoke.js
+++ b/src/api/smoke.js
@@ -148,3 +148,7 @@ export function getSupervisorOverview() {
export function getSupervisorStatus() {
return request.request({ url: '/supervisor/status', method: 'GET', baseUrl: BASE_URL_V2 })
}
+
+export function revokeSupervisorBinding(owner_uid, supervisor_uid) {
+ return request.request({ url: '/supervisor/revoke', method: 'POST', data: { owner_uid, supervisor_uid }, baseUrl: BASE_URL_V2 })
+}
diff --git a/src/pages/supervisor/index.vue b/src/pages/supervisor/index.vue
index 1cb40f3..90b4328 100644
--- a/src/pages/supervisor/index.vue
+++ b/src/pages/supervisor/index.vue
@@ -57,6 +57,9 @@
今日:{{ statusText(item.home?.daily_status?.status) }}
+
+
+
@@ -92,9 +95,11 @@
import { ref, onMounted } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { useLogin } from '@/hooks/useLogin'
-import { createSupervisorInvite, getSupervisorOverview, getSupervisorStatus } from '@/api/smoke'
+import { useUserStore } from '@/stores/user'
+import { createSupervisorInvite, getSupervisorOverview, getSupervisorStatus, revokeSupervisorBinding } from '@/api/smoke'
const { waitForLogin } = useLogin()
+const userStore = useUserStore()
const loading = ref(false)
const inviteLoading = ref(false)
@@ -163,6 +168,40 @@ function gotoBindPage() {
uni.navigateTo({ url: '/pages/supervisor/bind' })
}
+function confirmRevoke(item) {
+ const ownerUID = item?.owner?.user_id
+ if (!ownerUID) return
+ uni.showModal({
+ title: '解除监督',
+ content: '解除后你将无法再查看对方的戒烟概览。确定要解除吗?',
+ confirmText: '解除',
+ confirmColor: '#b91c1c',
+ success: async (res) => {
+ if (!res.confirm) return
+ await doRevoke(ownerUID)
+ }
+ })
+}
+
+async function doRevoke(ownerUID) {
+ try {
+ loading.value = true
+ const myUID = Number(userStore.user?.id)
+ if (!myUID) {
+ uni.showToast({ title: '登录信息缺失', icon: 'none' })
+ return
+ }
+ await revokeSupervisorBinding(ownerUID, myUID)
+ uni.showToast({ title: '已解除', icon: 'success' })
+ await refreshAll()
+ } catch (e) {
+ console.error('revoke error:', e)
+ uni.showToast({ title: '解除失败', icon: 'none' })
+ } finally {
+ loading.value = false
+ }
+}
+
async function generateInvite() {
if (inviteLoading.value) return
inviteLoading.value = true
@@ -407,6 +446,24 @@ onShow(async () => {
color: #64748b;
}
+.row-actions {
+ margin-top: 12rpx;
+ display: flex;
+ justify-content: flex-end;
+}
+
+.mini-btn {
+ height: 56rpx;
+ line-height: 56rpx;
+ padding: 0 18rpx;
+ border-radius: 14rpx;
+ background: #ffffff;
+ border: 1rpx solid rgba(185, 28, 28, 0.28);
+ color: #b91c1c;
+ font-size: 22rpx;
+ font-weight: 700;
+}
+
.footer {
margin-top: 20rpx;
padding-bottom: 20rpx;
@@ -435,4 +492,3 @@ onShow(async () => {
border: 1rpx solid rgba(15, 118, 110, 0.25);
}
-