瀏覽代碼

notification

nieyuge 3 年之前
父節點
當前提交
b57b36652a
共有 1 個文件被更改,包括 29 次插入2 次删除
  1. 29 2
      src/view/iframe/red-packet/luck-draw.vue

+ 29 - 2
src/view/iframe/red-packet/luck-draw.vue

@@ -319,7 +319,7 @@
                 <get-more :style_type="2"></get-more>
                 <div class="notification_switch">
                     <span>Announcement Notification</span>
-                    <a-switch v-model:checked="state.notification_switch" />
+                    <a-switch v-model:checked="state.notification_switch" @change="changeNotification" />
                 </div>
             </div>
 
@@ -409,7 +409,7 @@ export default {
 }
 </script>
 <script setup>
-import { onMounted, reactive, ref } from "vue";
+import { onMounted, onBeforeMount, reactive, ref } from "vue";
 import { getPostDetail, getRedPacket, finishRedPacket, oneKeyLike, oneKeyReTweet, oneKeyFollow, getTaskDetail, getReceivedList, addFinishEvent } from '@/http/redPacket.js'
 import { getQueryString, guid, getBit } from '@/uilts/help.js'
 import { message } from 'ant-design-vue';
@@ -420,6 +420,7 @@ import Report from "@/log-center/log"
 import { srcPublishSuccess } from '@/http/publishApi'
 import { discordAuthUrl, checkGuildJoined } from '@/http/discordApi'
 import { discordAuthRedirectUri, faceShareRedirectUrl } from '@/http/configAPI'
+import { getSetting, putSetting } from '@/http/user'
 import { getFrontConfig } from "@/http/account";
 import GlobalTip from '@/view/components/global-tip.vue'
 var moment = require('moment');
@@ -651,6 +652,23 @@ function onTweetReplyClick(params) {
     window.parent.postMessage({ actionType: "IFRAME_RED_PACKET_ON_TWEET_REPLY_CLICK", data: replyData }, "*");
 }
 
+function changeNotification(checked) {
+    let noticeSwitch = checked ? 1 : 0;
+    // set
+    putSetting({
+        params: { noticeSwitch }
+    }).then(res => {
+        let { code, data } = res;
+        if (code === 0) {
+            state.notification_switch = checked
+        } else {
+            state.notification_switch = !checked
+        }
+    }).catch(() => {
+        state.notification_switch = !checked
+    })
+}
+
 async function clickReply(params) {
     let _userInfo = await checkIsLogin()
     if (!_userInfo) {
@@ -1276,6 +1294,15 @@ const showLoadResult = () => {
     state.close_status = '等待结果'
 }
 
+onBeforeMount(() => {
+    getSetting({}).then((res) => {
+        let { code, data } = res;
+        if (code === 0) {
+            state.notification_switch = data.noticeSwitch === 1 ? true : false;
+        }
+    });
+})
+
 onMounted(() => {
     state.process_mode = process.env.NODE_ENV
     state.postId = getQueryString('postId')