| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- var content = {
- 'cn':{
- item1:'退订',
- btn:'确定',
- item2:'您正在进行退订操作',
- item3:'退订后,您将不再收到电子邮件提醒。',
- item4:'如果您有时间,请告诉我们您退订的原因:',
- item5:"我不想再收到这些邮件了",
- item6:"我从来没有注册过这个邮件列表",
- item7:"这些邮件不合适",
- item8:"这些邮件是垃圾邮件,应该上报",
- item9:"其他(请填写原因)",
- success:'成功',
- },
- 'en':{
- item1:'Unsubscribe',
- btn:'Confirm',
- item2:'Your unsubscribe is in progress',
- item3:'After unsubscribing, you will no longer receive email reminders.',
- item4:'If you have a moment, please tell us the reason for your unsubscribe:',
- item5:"I no longer want to receive these emails",
- item6:"I never signed up for this mailing list",
- item7:"The emails are inappropriate",
- item8:"The emails are spam and should be reported",
- item9:"Others (fill in reason below)",
- success:'success',
- }
- };
- let config = {
- Pattern: {
- Password: /^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?!.*([~!@&%$^\\(\\)#_]).*\\1.*\\1.*\\1)[A-Za-z0-9~!@&%$^\\(\\)#_]{8,16}$/,
- }
- };
- let vm = new Vue({
- el: "#unsubscribe",
- data(){
- return{
- ho:'',
- //多语言
- langList: {
- en: "ENGLISH",
- cn: "中文简体"
- },
- language: "en",
- lang:{},
- params: {
- reasons:[],
- reasonsOther:'',
- unsubscribe:'',
- },
- rules: {
- password: [
- {
- validator: (rule, value, callback) => {
- if (config.Pattern.Password.test(value)) {
- callback();
- } else {
- callback(new Error(this.lang.item2));
- }
- },
- trigger: "blur"
- }
- ],
- password1: [
- {
- validator: (rule, value, callback) => {
- if (value === '') {
- callback(new Error(this.lang.item4));
- } else if (value !== this.params.password) {
- callback(new Error(this.lang.item5));
- } else {
- callback();
- }
- },
- trigger: "blur"
- }
- ]
- }
- }
- },
- computed: {
- AccessToken(){
- return{
- 'Access-Token': window.location.search.split('?token=')[1]
- }
- }
- },
- methods: {
- // 语言切换函数
- chooseLang (key) {
- this.lang = content[key];
- this.language = key;
- },
- // 发送
- send: async function () {
- this.$refs["params"].validate(async valid => {
- if (valid) {
- let reason = '';
- this.params.reasons.forEach(item=>{
- if (item && item != '其他(请填写原因)' && item != 'Others (fill in reason below)') {
- reason = reason + item + ';'
- }
- });
- if (this.params.reasonsOther) {
- reason = reason + this.params.reasonsOther;
- }
- let unsubscribe = '';
- unsubscribe = this.params.unsubscribe.replace(/%25/g,'%').replace(/%2B/g,'\+').replace(/%20/g,' ').replace(/%2F/g,'\/').replace(/%3F/g,'\?');
- let hostParts = window.location.host.split('.');
- let tld = hostParts.slice(2).join('.') || 'com';
- axios.post('https://secure.' + this.ho + '.' + tld + '/email/unsubscribe/add', {
- unsubscribe:unsubscribe,
- reason:reason
- //参数
- }).then(res => {//请求成功后的处理函数
- if (res.data.code == 200) {
- this.$message({
- message: this.lang.success,
- type: 'success'
- });
- setTimeout(() => {
- window.location.href = 'https://secure.' + this.ho + '.' + tld
- }, 2000);
- } else {
- this.$message.error(res.data.msg);
- }
- }).catch(err => { //请求失败后的处理函数
- })
- } else {
- return false;
- }
- });
- },
- },
- mounted() {
- this.ho = window.location.host.split('.')[1];
- this.params.unsubscribe = window.location.search.split('?unsubscribe=')[1];
-
- var jsSrc =(navigator.language || navigator.browserLanguage).toLowerCase();
- if(jsSrc.indexOf('zh') >= 0){
- this.language = 'cn'
- this.lang = content['cn'];
- }else{
- this.language = 'en'
- this.lang = content['en'];
- }
- }
- });
|