zj
2024-06-03 96140d8eb2531144828dffe2ad8c19d0d9431009
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<template>
  <div id="c2c_settings" class="w-full h-full">
    <div class="flex flex-col w-full h-full">
      <order-nav :title="$t('通知设置')"/>
      <div class="flex-1 overflow-auto">
        <settings-item :options="options.order" @changeSwitch="changeSwitch">
          <template>
            <h2 class="mb-10 font-24 font-400">{{$t('订单')}}</h2>
            <p class="font-20">{{$t('接收新订单和订单状态变化的消息,请至少开启1项通知。')}}</p>
          </template>
        </settings-item>
        <settings-item class="mt-44" :options="options.appeal" @changeSwitch="changeSwitch">
          <template>
            <h2 class="mb-10 font-24 font-400">{{$t('申诉')}}</h2>
            <p class="font-20">{{$t('接收新申诉和申诉状态变化的消息,请至少开启1项通知。')}}</p>
          </template>
        </settings-item>
<!--        <settings-item class="mt-44" :options="options.chat" @changeSwitch="changeSwitch">-->
<!--          <template>-->
<!--            <h2 class="mb-10 font-24 font-400">{{$t('聊天')}}</h2>-->
<!--            <p class="font-20">{{$t('接收聊天消息,请开启此项通知')}}</p>-->
<!--          </template>-->
<!--        </settings-item>-->
<!--        <settings-item class="mt-44" :options="options.safe" @changeSwitch="changeSwitch">-->
<!--          <template>-->
<!--            <h2 class="mb-10 font-24 font-400">{{$t('安全')}}</h2>-->
<!--            <p class="font-20">{{$t('接收安全与隐私提示等消息,邮件和短信无法手动关闭。')}}</p>-->
<!--          </template>-->
<!--        </settings-item>-->
      </div>
    </div>
  </div>
</template>
 
<script>
import OrderNav from "@/components/order-nav/OrderNav";
import SettingsItem from "@/page/c2cUser/components/SettingsItem";
import otcApi from "@/API/otc.js";
 
export default {
  name: "c2cNoticeSettings",
  data() {
    return {
      options: {
        // 订单
        order: [
          {title: this.$t('邮件'), checked: true,type:'mail'},
          { title: this.$t('短信'), checked: false, type: 'sms' },
          // { title: this.$t('APP通知'), checked: false, type: 'app' },
        ],
        // 申诉
        appeal: [
          { title:this.$t('邮件') , checked: false, type: 'mail' },
          { title:this.$t('短信') , checked: false, type: 'sms' },
          // { title: this.$t('APP通知'), checked: false, type: 'app' },
        ],
        // // 聊天
        // chat: [
        //   { title: this.$t('APP通知'), checked: false, type: 'app' },
        // ],
        // // 安全
        // safe: [
        //   { title: this.$t('邮件'), checked: true, disabled: true, type: 'mail' },
        //   { title: this.$t('短信'), checked: true, disabled: true, type: 'sms' },
        //   { title: this.$t('APP通知'), checked: false, type: 'app' },
        // ]
      },
      ctc_user:{},
      order_mail_obj:{},
      order_sms_obj:{},
      order_app_obj:{},
      appeal_mail_obj:{},
      appeal_sms_obj:{},
      appeal_app_obj:{},
      safe_mail_obj:{},
      safe_sms_obj:{},
      safe_app_obj:{},
    }
  },
  components: {
    OrderNav,
    SettingsItem,
  },
  mounted(){
    let ctc_user = this.$route.query.ctc_user
    this.ctc_user = JSON.parse(ctc_user)
    this.init()
  },
  methods:{
    init(){
      this.options.order.forEach(item=>{
        if (item.type=='mail'){
          item.checked = Boolean(this.ctc_user.orderMailNoticeOpen)
        } else if (item.type =='sms'){
          item.checked = Boolean(this.ctc_user.orderSmsNoticeOpen)
        }else if(item.type=='app'){
          item.checked = Boolean(this.ctc_user.orderAppNoticeOpen)
        }
      })
      this.options.appeal.forEach(item => {
        if (item.type == 'mail') {
          item.checked = Boolean(this.ctc_user.appealMailNoticeOpen)
        } else if (item.type == 'sms') {
          item.checked = Boolean(this.ctc_user.appealSmsNoticeOpen)
        } else if (item.type == 'app') {
          item.checked = Boolean(this.ctc_user.appealAppNoticeOpen)
        }
      })
      // this.options.chat.forEach(item => {
      //   if (item.type == 'app') {
      //     item.checked = Boolean(this.ctc_user.chat_app_notice_open)
      //   }
      // })
      //
      // this.options.appeal.forEach(item => {
      //   if (item.type == 'app') {
      //     item.checked = Boolean(this.ctc_user.securityAppNoticeOpen)
      //   }
      // })
    },
    ctcUserSet(){
      otcApi.ctcUserSet({
        order_mail_notice_open: Number(this.order_mail_obj.checked),
        order_sms_notice_open:  Number(this.order_sms_obj.checked),
        order_app_notice_open:  Number(this.order_app_obj.checked),
        appeal_mail_notice_open:  Number(this.appeal_mail_obj.checked),
        appeal_sms_notice_open:  Number(this.appeal_sms_obj.checked),
        appeal_app_notice_open:  Number(this.appeal_app_obj.checked),
        chat_app_notice_open:  Number(this.chat_app_obj.checked),
        security_mail_notice_open:  Number(this.safe_mail_obj.checked),
        security_sms_notice_open:  Number(this.safe_sms_obj.checked),
        security_app_notice_open:  Number(this.safe_app_obj.checked),
      }).then(res => {
        console.log(res)
      }).catch(err=>{
 
      })
    },
    changeSwitch() {
      this.order_mail_obj = this.options.order.find(item => item.type =='mail')
      this.order_sms_obj = this.options.order.find(item => item.type =='sms')
      this.order_app_obj = this.options.order.find(item => item.type =='app')
      this.appeal_mail_obj = this.options.appeal.find(item => item.type == 'mail')
      this.appeal_sms_obj = this.options.appeal.find(item => item.type == 'sms')
      this.appeal_app_obj = this.options.appeal.find(item => item.type == 'app')
      this.chat_app_obj = this.options.chat.find(item => item.type == 'app')
      this.safe_mail_obj = this.options.safe.find(item => item.type == 'mail')
      this.safe_sms_obj = this.options.safe.find(item => item.type == 'sms')
      this.safe_app_obj = this.options.safe.find(item => item.type == 'app')
      this.ctcUserSet()
    }
  }
}
</script>
 
<style scoped>
 
</style>