TG.WXCRM.V4/WEB/Views/Csvr/CustomerUC/CustomerAddWWUserUC.cshtml

207 lines
8.8 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@using WX.CRM.Model.Entity
@using WX.CRM.Common
@{
Layout = null;
}
<div class="group content_title_width">
<span class="csicon QWIcon"></span>
<span>企业微信</span>
</div>
<div class="content_div">
<table class="layui-table content_width" id="t1">
<thead>
<tr>
<td>客户ID</td>
<td>客户名称</td>
<td>客户备注</td>
<td>备注号码</td>
<td>员工企微ID</td>
<td>员工企微名称</td>
<td>事业部</td>
<td>员工</td>
<td>绑定时间</td>
@if (ViewBag.UnBindWxExt)
{
<td>操作</td>
}
@*<td>销售线索</td>*@
</tr>
</thead>
<tbody></tbody>
</table>
<div style="padding-left:15px;padding-bottom:15px;">
<input disabled value="" type="text" style="width:150px;" id="wwUserName" />
<input type="button" class="layui-btn layui-btn-sm layui-bg-cyan" onclick="ChooseCustomerWw()" value="选择企业微信" />
<input type="button" class="layui-btn layui-btn-sm layui-btn-normal" onclick="BindWwExtUser()" value="关联" />
</div>
</div>
<script type="text/javascript">
$(function () {
try {
var extUser = '@Html.Raw(System.Web.HttpUtility.JavaScriptStringEncode(@ViewBag.extUserInfo))'.replace(/\r\n/g, "").replace(/\n/g, "").replace(/\r/g, " ").replace(/\t/g, " ").replace("\\\\","");
//console.log(extUser);
if (extUser != "") {
var html = "";
var obj2 = jQuery.parseJSON(extUser);
$(obj2).each(function (aa, obj) {
var ww_customer = obj.external_contact;
var ww_user = obj.follow_user;
var corpid = obj.corpid;
var unBindWx = '@Html.Raw(ViewBag.UnBindWxExt)';
var mergeroot = '@Html.Raw(ViewBag.MergeRoot)';
$(ww_user).each(function (i, j) {
html += "<tr>";
html += "<td>" + ww_customer.external_userid + "</td>";
html += "<td>" + ww_customer.name + "</td>";
html += "<td>" + j.remark + "</td>";
html += "<td>" + j.remark_mobiles + "</td>";
html += "<td>" + j.userid + "</td>";
html += "<td>" + j.uname + "</td>";
html += "<td>" + j.deptname + "</td>";
html += "<td>" + j.saleeid + "</td>";
html += "<td>" + j.bindtime + "</td>";
if (unBindWx != "False") {
html += "<td><input type='button' class='layui-btn layui-btn-sm layui-btn-normal' onclick=\"UnBindWwExtUser('" + ww_customer.external_userid + "','" + corpid +"')\" value='解绑' />";
if (mergeroot) {
html += "<input type='button' class='layui-btn layui-btn-sm layui-btn-normal' onclick=\"MergeSoftUser('" + ww_customer.external_userid + "','" + corpid + "')\" value='合并软件名' /></td>";
} else {
html += "</td>";
}
} else if (mergeroot) {
html += "<td><input type='button' class='layui-btn layui-btn-sm layui-btn-normal' onclick=\"MergeSoftUser('" + ww_customer.external_userid + "','" + corpid+"')\" value='合并软件名' /></td>";
}
html += "</tr > ";
});
});
$("#t1 tbody").append(html);
}
} catch (err) {
console.log(err);
}
});
function SaleLineShow(corpid, userid) {
$("#modalwindow").html(GetIframeHtml("http://sc.soft.dn8188.com/dev.html?appid=" + corpid + "_1&appuserid=" + userid + "&guid=" + GetGuid()));
$("#modalwindow").window({ title: '销售线索', width: 480, height: 560, iconCls: 'icon-add' }).window('open');
}
function ChooseCustomerWw() {
var wwmessageurl = "@Html.Raw(ViewBag.WwMessage_Url)";
var companycode = "@Html.Raw(ViewBag.companycode)";
if (wwmessageurl.indexOf("$") > -1) {
wwmessageurl = wwmessageurl.split("$")[0];
}
if (wwmessageurl.indexOf("|") > -1) {//分内外网
var ssw = window.location.href;
if (ssw.indexOf("192.168.") > -1 || ssw.indexOf("localhost") > -1) {//内网无疑
wwmessageurl = wwmessageurl.split('|')[0];
} else {
wwmessageurl = wwmessageurl.split('|')[1];
}
}
$("#modalwindow").html(GetIframeHtml(wwmessageurl + "/Admin/OutHHuser/Choose"));
$("#modalwindow").window({ title: '选择付费企业微信', width: 900, height: 500, iconCls: 'icon-add' }).window('open');
//$("#modalwindow").html(GetIframeHtml("/WeiXin/SzzyOrder/WwExtuser"));
//$("#modalwindow").window({ title: '选择付费企业微信', width: 650, height: 500, iconCls: 'icon-add' }).window('open');
}
function SelectCustomerWw(userName) {
$('#wwUserName').val(userName);
//$('#wx_SzzyOrder_EXTERNAL_USERID').val(userName);
}
function BindWwExtUser() {
var username = document.getElementById("wwUserName").value;
var resId = "@ViewBag.ResId";
$.r_ajax({
url: "/Csvr/CustomerUC/BindWwExtUser",
type: "Post",
data: { resId: resId, userId: username},
dataType: "json",
loading: true,
success: function (data) {
if (data.result) {
window.frameReturnByMes("关联成功!");
window.location.reload();
//window.location.reload();
}
else {
//alert("关联失败,请重试!");
window.frameReturnByMes(data.message);
}
}
});
}
function UnBindWwExtUser(userid, appid) {
$.messager.confirm('提示', '确定解绑企微?', function (r) {
if (r) {
var resId = "@ViewBag.ResId";
$.r_ajax({
url: "/Csvr/CustomerUC/UnBindWwExtUser",
type: "Post",
data: { resId: resId, userId: userid, appid: appid },
dataType: "json",
loading: true,
success: function (data) {
if (data.result) {
window.frameReturnByMes("解绑成功!");
window.location.reload();
}
else {
//alert("关联失败,请重试!");
window.frameReturnByMes(data.message);
}
}
});
}
});
}
function MergeSoftUser(userid, appid) {
debugger
$.messager.confirm('提示', '确定合并软件用户名?', function (r) {
if (r) {
var resId = "@ViewBag.ResId";
$.r_ajax({
url: "/Csvr/CustomerUC/MergeSoftUser",
type: "Post",
data: { resId: resId, userId: userid, appid: appid },
dataType: "json",
loading: true,
success: function (data) {
if (data.result) {
window.frameReturnByMes("合并成功!");
window.location.reload();
}
else {
//alert("关联失败,请重试!");
window.frameReturnByMes(data.message);
}
}
});
}
});
}
function timestampToTime(timestamp) {
//时间戳为10位需*1000时间戳为13位的话不需乘1000
var date = new Date(timestamp * 1000);
Y = date.getFullYear() + '-';
M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
D = date.getDate() + ' ';
h = date.getHours() + ':';
m = date.getMinutes() + ':';
s = date.getSeconds();
return Y + M + D + h + m + s;
}
</script>
<script>
window.addEventListener("message", receiveMessage, false);
function receiveMessage(event) {
console.log("收到消息了,该死的");
console.log(event.data);
var mydata = event.data;
if (mydata.type == "choose") {
$('#wwUserName').val(mydata.extuserid);
}
frameReturnByClose();
}
</script>