Files
qlg.frontend/js/cancellation.js
2020-09-19 11:54:52 +08:00

135 lines
3.6 KiB
JavaScript

mui.plusReady(function(){
var wait = 120;
function time() {
if(wait == 0) {
$('#mobileCode').removeAttr("disabled");
$('#mobileCode').val("重新发送");
wait = 120;
} else {
$('#mobileCode').attr("disabled", true);
$('#mobileCode').val("重新发送(" + wait + ")");
wait--;
setTimeout(function() {
time();
},
1000)
}
}
$(".photos").on("tap", 'img', function() {
var _input = $(this).parent().parent().parent().prev()[0];
UP.init(_input.id, "test", this.id)
openCamera()
})
var token = localStorage.getItem('token');
mui.ajax(qlgUrl('app/users/editPhone'), {
headers: {
"HYH-Token": token
},
data: {},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
var data = toJson(data);
if (data.status == 1) {
data = data.data;
if (data.userPhone) {
$('#userPhone').val(data.userPhone);
}
}
},
})
mui('.row').on('tap', '#mobileCode', function() {
var that = $(this);
that.attr("disabled", true);
mui.ajax(hyhUrl('app/users/unregister_get_sms_code'), { 
data: {},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒
success: function(data) {
var data = toJson(data);
//服务器返回响应,根据响应结果,分析是否登录成功;
if(data.status == 1) {
time();
} else {
alert(data.msg)
}
that.removeAttr('disabled');
},
error: function(xhr, type, errorThrown) {
//异常处理;
// alert(type)
// alert(type);      
}
}); 
})
mui('.down').on('tap', '#true', function() {
var phoneCode = $('#phoneCode').val();
var op_content = $('#reason').val();
var op_user = $('#userName').val();
var handholdId = $("#handholdId").val();
var that = $(this);
if(phoneCode == '') {
alert('验证码不能为空!');
return;
} else if(phoneCode.length < 4) {
alert('验证码格式不正确!');
return;
}
if (op_user == '') {
alert('操作用户不能为空!');
return;
}
$.ajax({
url: qlgUrl('app/users/unregister'),
method: 'POST',
data: {
op_user: op_user,
op_content: op_content,
code: phoneCode,
op_pic: handholdId,
},
dataType: 'json',
success(res) {
if (res.status == 1) {
mui.alert(res.msg, '提示')
mui.ajax(qlgUrl('app/users/logout'), {
headers: {
"HYH-Token": token
},
data: {},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
// //console.log(data.data.goodsFavoritesNum)
localStorage.removeItem("token");
localStorage.removeItem("userId");
localStorage.removeItem("userName");
mui.fire(plus.webview.getWebviewById('templete/my.html'), 'refresh');
mui.fire(plus.webview.getWebviewById('templete/shoppingcart_warp.html'), 'refresh');
mui.fire(self.parent, 'refresh');
mui.back();
var data = toJson(data, 1);
},
error: function(xhr, type, errorThrown) { //异常处理;
mui.alert("请手动重新登陆");
}
});
} else {
mui.alert(res.msg);
}
},
error(err) {
mui.alert('请求异常', '提示')
}
})
})
})