|
@@ -0,0 +1,114 @@
|
|
|
|
|
+<route lang="json5">
|
|
|
|
|
+{
|
|
|
|
|
+ style: {
|
|
|
|
|
+ navigationBarTitleText: '设置',
|
|
|
|
|
+ },
|
|
|
|
|
+}
|
|
|
|
|
+</route>
|
|
|
|
|
+
|
|
|
|
|
+<template>
|
|
|
|
|
+ <view class="min-h-screen bg-gray-100">
|
|
|
|
|
+ <!-- 设置列表 -->
|
|
|
|
|
+ <view class="px-4 py-4">
|
|
|
|
|
+ <!-- 消息通知设置 -->
|
|
|
|
|
+ <view class="bg-white rounded-lg mb-4">
|
|
|
|
|
+ <view class="px-4 py-3 border-b border-gray-100">
|
|
|
|
|
+ <text class="text-lg font-medium text-gray-800">消息通知</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 审核消息订阅 -->
|
|
|
|
|
+ <view class="px-4 py-4 flex items-center justify-between">
|
|
|
|
|
+ <view class="flex-1">
|
|
|
|
|
+ <text class="text-base text-gray-800">审核消息订阅</text>
|
|
|
|
|
+ <view class="mt-1">
|
|
|
|
|
+ <text class="text-sm text-gray-500">接收优惠券审核状态变更通知</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <wd-switch
|
|
|
|
|
+ v-model="auditMessageSubscription"
|
|
|
|
|
+ :disabled="!hasAuditAuth"
|
|
|
|
|
+ @change="handleAuditMessageChange"
|
|
|
|
|
+ />
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<script lang="ts" setup>
|
|
|
|
|
+import { computed, onMounted, ref } from 'vue'
|
|
|
|
|
+import { useSettingsStore } from '@/store/settings'
|
|
|
|
|
+import { useUserStore } from '@/store/user'
|
|
|
|
|
+
|
|
|
|
|
+const settingsStore = useSettingsStore()
|
|
|
|
|
+const userStore = useUserStore()
|
|
|
|
|
+
|
|
|
|
|
+// 审核消息订阅状态
|
|
|
|
|
+const auditMessageSubscription = ref(false)
|
|
|
|
|
+
|
|
|
|
|
+// 计算属性:是否有审核权限
|
|
|
|
|
+const hasAuditAuth = computed(() => userStore.audit_auth)
|
|
|
|
|
+
|
|
|
|
|
+// 获取审核消息订阅状态
|
|
|
|
|
+const getAuditSubscriptionStatus = async () => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const result = await settingsStore.getAuditMessageSubscription()
|
|
|
|
|
+ // 如果返回的列表中有数据,就表示已订阅
|
|
|
|
|
+ auditMessageSubscription.value = !!(
|
|
|
|
|
+ result &&
|
|
|
|
|
+ result.Data &&
|
|
|
|
|
+ Array.isArray(result.Data) &&
|
|
|
|
|
+ result.Data.length > 0
|
|
|
|
|
+ )
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('获取审核消息订阅状态失败:', error)
|
|
|
|
|
+ auditMessageSubscription.value = false
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 审核消息订阅开关变更
|
|
|
|
|
+const handleAuditMessageChange = async ({ value }: { value: boolean }) => {
|
|
|
|
|
+ // 检查审核权限
|
|
|
|
|
+ if (!hasAuditAuth.value) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '您没有审核权限,无法修改此设置',
|
|
|
|
|
+ icon: 'none',
|
|
|
|
|
+ })
|
|
|
|
|
+ // 恢复原值
|
|
|
|
|
+ auditMessageSubscription.value = !value
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 调用提交订阅接口,传入固定的模板ID和状态
|
|
|
|
|
+ const params = {
|
|
|
|
|
+ wxsubscribetemplateid: 'oi3JmzaEbkAXubBsPPMDE8Grjfj9Tf0VP7rttWAgPlA', // 固定值
|
|
|
|
|
+ status: value ? 1 : 2, // 1为订阅,2为取消订阅
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ await settingsStore.submitAuditMessageSubscription(params)
|
|
|
|
|
+
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: value ? '已开启审核消息订阅' : '已关闭审核消息订阅',
|
|
|
|
|
+ icon: 'none',
|
|
|
|
|
+ })
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ // console.error('更新审核消息订阅状态失败:', error)
|
|
|
|
|
+ // uni.showToast({
|
|
|
|
|
+ // title: '操作失败,请稍后重试',
|
|
|
|
|
+ // icon: 'none',
|
|
|
|
|
+ // })
|
|
|
|
|
+ // 恢复原值
|
|
|
|
|
+ auditMessageSubscription.value = !value
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 页面加载时获取订阅状态
|
|
|
|
|
+onMounted(() => {
|
|
|
|
|
+ getAuditSubscriptionStatus()
|
|
|
|
|
+})
|
|
|
|
|
+</script>
|
|
|
|
|
+
|
|
|
|
|
+<style lang="scss" scoped>
|
|
|
|
|
+// 自定义样式
|
|
|
|
|
+</style>
|