236 lines
7.4 KiB
JavaScript
236 lines
7.4 KiB
JavaScript
var info = {};
|
|
var imgArr = 0;
|
|
var target = ""; //被举报人id
|
|
var resson_title = ""; //举报内容
|
|
var source = ""; //举报来源
|
|
// 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"
|
|
}
|
|
$(function () {
|
|
var browser = checkVersion();
|
|
var api = getUrlPrefix();
|
|
var locateObj = getQueryString();
|
|
|
|
var main = {
|
|
init: function () {
|
|
this.requestUidFromNative(); //获取uid
|
|
this.eventRegister(); //绑定事件
|
|
},
|
|
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('上传图片中');
|
|
$.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('上传成功');
|
|
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('上传失败,请重新上传');
|
|
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('上传图片中');
|
|
$.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('上传成功');
|
|
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('上传失败,请重新上传');
|
|
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('请输入举报内容').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("已提交")
|
|
}
|
|
}
|
|
});
|
|
} 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();
|
|
|
|
})
|
|
|
|
function getMessage(key, value) {
|
|
info[key] = value;
|
|
}
|