diff --git a/view/molistar/modules/inform/index.html b/view/molistar/modules/inform/index.html index 3a45e30..f5b9e71 100644 --- a/view/molistar/modules/inform/index.html +++ b/view/molistar/modules/inform/index.html @@ -99,7 +99,7 @@ - + \ No newline at end of file diff --git a/view/molistar/modules/inform/js/index.js b/view/molistar/modules/inform/js/index.js index 9b00524..8314837 100644 --- a/view/molistar/modules/inform/js/index.js +++ b/view/molistar/modules/inform/js/index.js @@ -1,254 +1,34 @@ -var info = {}; +let browser = checkVersion() +let env = EnvCheck(); +var api = getUrlPrefix(); +var locateObj = getQueryString(); var imgArr = 0; var target = ""; //被举报人id var resson_title = ""; //举报内容 var source = ""; //举报来源 var langReplace; var localLang; -// var flush = "https://api.kawayisound.xyz/modules/inform/index.html"; -if (EnvCheck() == 'test') { - var vConsole = new VConsole(); - // flush = "http://apibeta.kawayisound.xyz/modules/inform/index.html" +if (env == 'test') { + new VConsole(); } $(function () { - var browser = checkVersion(); - var api = getUrlPrefix(); - var locateObj = getQueryString(); + // 初始化函數 getInfoFromClient() fuzzyMatchUpdateQueryStringParameterFun(); // 判断语言 - var main = { - init: function () { - setTimeout(function () { - langReplace = window.lang.replace; - localLang = window.lang; - translateFun(); - main.requestUidFromNative(); //获取uid - main.eventRegister(); //绑定事件 - setTimeout(function () { - $('#body').show(); - }, 300) - }, 100) - }, - requestUidFromNative: function () { - if (browser.app) { - if (browser.ios) { - var allcookies = document.cookie; - var $uid = allcookies.match(/\d+/); - info.uid = $uid[0] - // window.webkit.messageHandlers.getUid.postMessage(null); - } else if (browser.android) { - if (androidJsObj && typeof androidJsObj === 'object') { - info.uid = parseInt(window.androidJsObj.getUid()); - } - } - } else { - info.uid = 901189; - } - - target = locateObj.reportUid; //获取别举报人id - if (locateObj.source) { - source = locateObj.source.toUpperCase(); - } - console.log(source) - }, - // $(this).addClass('active').siblings('.tab').removeClass('active'); - eventRegister: function () { - $('.update_evidence').on('change', '.update-img', function () { - var formData = new FormData(); - formData.append('uid', info.uid); - formData.append('file', $(this).get(0).files[0]) - var _that = $(this); - $('.load-img').show().find('.toast').html(langReplace(localLang.demoModule.text16)); - $.ajax({ - url: api + '/live/upload', - type: 'post', - processData: false, - contentType: false, - data: formData, - success: function (res) { - var flag = 0; - _that.siblings('img').attr('src', res.data); - _that.parent().addClass('has-data') - _that.hide(); - $('.load-img').find('.toast').html(langReplace(localLang.demoModule.text17)); - setTimeout(function () { - $('.load-img').hide() - }, 1000) - imgArr++ - if (imgArr > 0) { - $('.inform-button').addClass('active'); - } else { - $('.inform-button').removeClass('active') - } - }, - error: function (err) { - console.log(err) - $('.load-img').find('.toast').html(langReplace(localLang.demoModule.text18)); - setTimeout(function () { - $('.load-img').hide() - }, 1000) - } - }) - }); - $('.update_evidence').on('change', '.reupdate-img', function () { - - var formData = new FormData(); - formData.append('uid', info.uid); - formData.append('file', $(this).get(0).files[0]) - var _that = $(this); - $('.load-img').show().find('.toast').html(langReplace(localLang.demoModule.text16)); - $.ajax({ - url: api + '/live/upload', - type: 'post', - processData: false, - contentType: false, - data: formData, - success: function (res) { - console.log(res); - _that.parent().siblings('img').attr('src', res.data); - _that.parent().parent().addClass('has-data'); - $('.load-img').find('.toast').html(langReplace(localLang.demoModule.text17)); - setTimeout(function () { - $('.load-img').hide() - }, 1000) - imgArr++; - if (imgArr > 0) { - $('.inform-button').addClass('active'); - } else { - $('.inform-button').removeClass('active') - } - }, - error: function (err) { - console.log(err) - $('.load-img').find('.toast').html(langReplace(localLang.demoModule.text18)); - setTimeout(function () { - $('.load-img').hide() - }, 1000) - } - }) - }); - //单选 - $('.radio-box').on('click', function () { - $(this).find('.radio').addClass('active').parent().siblings('.radio-box').find('.radio').removeClass('active'); - var id = $(this).find('.radio').data('id'); - if (id == 8) { - $('.inform-textarea').show(); - } else { - $('.inform-textarea').hide(); - } - console.log($(this).find('.radio').data('id')) - }) - - //提交 - $('.inform-button').on('click', function () { - if ($('.inform-button').hasClass("button-active")) { - console.log("+9++++9+") - return; - } - if (!$(this).hasClass('active')) { - return; - } - - - var imgStr = '' - for (var i = 0; i < $('.update_evidence').length; i++) { - if ($('.update_evidence').eq(i).find('img').attr('src').match('images/report_uploading_img.png')) { - continue; - } - - if (i < $('.update_evidence').length) { - imgStr += ',' + $('.update_evidence').eq(i).find('img').attr('src'); - } - } - if (imgStr.indexOf(',') == 0) { - imgStr = imgStr.substr(1, imgStr.length); - } - - console.log(imgStr) - - //获取选中的下标 - var index = $('.radio').filter('.active'); - var id = index.data('id'); - if (id == 8) { - resson_title = $('.textarea-box').val(); - } else { - resson_title = index.next().html(); - } - console.log("----------------------") - console.log(info.uid) - console.log(target) - console.log(resson_title) - console.log("----------------------") - //举报内容不能为空 - if (resson_title == "") { - $('.show-message').html(langReplace(localLang.demoModule.text19)).show(); - setTimeout(function () { - $('.show-message').hide(); - }, 1000) - } else if (info.uid != "" && target != "") { - $.ajax({ - type: 'POST', - url: api + '/impeach/impeachSomeone', - data: { - uid: info.uid, - targetUid: target, - reason: resson_title, - imgUrl: imgStr, - source: source - }, - success: function (res) { - if (res.code == 200) { - $('.success-winsdow').css("display", "flex"); - setTimeout(function () { - $('.success-winsdow').css("display", "none"); - // window.location.href = flush - }, 1000) - $('.inform-button').addClass("button-active").html(langReplace(localLang.demoModule.text20)) - } - } - }); - } else { - console.log("id不能为空") - } - - }) - - // 监听上传图片的input值变化 - // $('.update-img').prev().on('change', function() { - // console.log($(this).val()) - // if ($(this).val()) { - // imgArr++ - // } - // if (imgArr > 0) { - // $('.inform-button').addClass('active'); - // } else { - // $('.inform-button').removeClass('active') - // } - // }) - // $('.reupdate-img').prev().on('change', function() { - // if ($(this).val()) { - // imgArr++ - // } - // if (imgArr > 0) { - // $('.inform-button').addClass('active'); - // } else { - // $('.inform-button').removeClass('active') - // } - // }) - } - } - main.init(); - + setTimeout(function () { + langReplace = window.lang.replace; + localLang = window.lang; + translateFun(); + eventRegister(); + setTimeout(function () { + $('#body').show(); + }, 300) + }, 300) }) - -function getMessage(key, value) { - info[key] = value; -} - function translateFun() { var langReplace = window.lang.replace; var localLang = window.lang; - $('#text10').attr('placeholder',langReplace(localLang.demoModule.text10)); + $('#text10').attr('placeholder', langReplace(localLang.demoModule.text10)); $('#title').html(langReplace(localLang.demoModule.title)); $('#text1').html(langReplace(localLang.demoModule.text1)); $('#text2').html(langReplace(localLang.demoModule.text2)); @@ -264,4 +44,191 @@ function translateFun() { $('#text11').html(langReplace(localLang.demoModule.text13)); $('#text14').html(langReplace(localLang.demoModule.text14)); $('#text15').html(langReplace(localLang.demoModule.text15)); -} \ No newline at end of file +} +function eventRegister() { + $('.update_evidence').on('change', '.update-img', function () { + var formData = new FormData(); + formData.append('uid', pubInfo.uid); + formData.append('file', $(this).get(0).files[0]) + var _that = $(this); + $('.load-img').show().find('.toast').html(langReplace(localLang.demoModule.text16)); + $.ajax({ + url: api + '/live/upload', + type: 'post', + processData: false, + contentType: false, + data: formData, + success: function (res) { + var flag = 0; + _that.siblings('img').attr('src', res.data); + _that.parent().addClass('has-data') + _that.hide(); + $('.load-img').find('.toast').html(langReplace(localLang.demoModule.text17)); + setTimeout(function () { + $('.load-img').hide() + }, 1000) + imgArr++ + if (imgArr > 0) { + $('.inform-button').addClass('active'); + } else { + $('.inform-button').removeClass('active') + } + }, + error: function (err) { + console.log(err) + $('.load-img').find('.toast').html(langReplace(localLang.demoModule.text18)); + setTimeout(function () { + $('.load-img').hide() + }, 1000) + } + }) + }); + $('.update_evidence').on('change', '.reupdate-img', function () { + + var formData = new FormData(); + formData.append('uid', pubInfo.uid); + formData.append('file', $(this).get(0).files[0]) + var _that = $(this); + $('.load-img').show().find('.toast').html(langReplace(localLang.demoModule.text16)); + $.ajax({ + url: api + '/live/upload', + type: 'post', + processData: false, + contentType: false, + data: formData, + success: function (res) { + console.log(res); + _that.parent().siblings('img').attr('src', res.data); + _that.parent().parent().addClass('has-data'); + $('.load-img').find('.toast').html(langReplace(localLang.demoModule.text17)); + setTimeout(function () { + $('.load-img').hide() + }, 1000) + imgArr++; + if (imgArr > 0) { + $('.inform-button').addClass('active'); + } else { + $('.inform-button').removeClass('active') + } + }, + error: function (err) { + console.log(err) + $('.load-img').find('.toast').html(langReplace(localLang.demoModule.text18)); + setTimeout(function () { + $('.load-img').hide() + }, 1000) + } + }) + }); + //单选 + $('.radio-box').on('click', function () { + $(this).find('.radio').addClass('active').parent().siblings('.radio-box').find('.radio').removeClass('active'); + var id = $(this).find('.radio').data('id'); + if (id == 8) { + $('.inform-textarea').show(); + } else { + $('.inform-textarea').hide(); + } + console.log($(this).find('.radio').data('id')) + }) + + //提交 + $('.inform-button').on('click', function () { + if ($('.inform-button').hasClass("button-active")) { + console.log("+9++++9+") + return; + } + if (!$(this).hasClass('active')) { + return; + } + + + var imgStr = '' + for (var i = 0; i < $('.update_evidence').length; i++) { + if ($('.update_evidence').eq(i).find('img').attr('src').match('images/report_uploading_img.png')) { + continue; + } + + if (i < $('.update_evidence').length) { + imgStr += ',' + $('.update_evidence').eq(i).find('img').attr('src'); + } + } + if (imgStr.indexOf(',') == 0) { + imgStr = imgStr.substr(1, imgStr.length); + } + + console.log(imgStr) + + //获取选中的下标 + var index = $('.radio').filter('.active'); + var id = index.data('id'); + if (id == 8) { + resson_title = $('.textarea-box').val(); + } else { + resson_title = index.next().html(); + } + console.log("----------------------") + console.log(pubInfo.uid) + console.log(target) + console.log(resson_title) + console.log("----------------------") + //举报内容不能为空 + if (resson_title == "") { + $('.show-message').html(langReplace(localLang.demoModule.text19)).show(); + setTimeout(function () { + $('.show-message').hide(); + }, 1000) + } else if (pubInfo.uid != "" && target != "") { + $.ajax({ + type: 'POST', + url: api + '/impeach/impeachSomeone', + data: { + uid: pubInfo.uid, + targetUid: target, + reason: resson_title, + imgUrl: imgStr, + source: source + }, + success: function (res) { + if (res.code == 200) { + $('.success-winsdow').css("display", "flex"); + setTimeout(function () { + $('.success-winsdow').css("display", "none"); + // window.location.href = flush + }, 1000) + $('.inform-button').addClass("button-active").html(langReplace(localLang.demoModule.text20)) + } + } + }); + } else { + console.log("id不能为空") + } + + }) + + // 监听上传图片的input值变化 + // $('.update-img').prev().on('change', function() { + // console.log($(this).val()) + // if ($(this).val()) { + // imgArr++ + // } + // if (imgArr > 0) { + // $('.inform-button').addClass('active'); + // } else { + // $('.inform-button').removeClass('active') + // } + // }) + // $('.reupdate-img').prev().on('change', function() { + // if ($(this).val()) { + // imgArr++ + // } + // if (imgArr > 0) { + // $('.inform-button').addClass('active'); + // } else { + // $('.inform-button').removeClass('active') + // } + // }) +} +// function getMessage(key, value) { +// pubInfo[key] = value; +// } \ No newline at end of file