js.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. $(function() {
  2. $(".filterSearch").change(function() {
  3. var cururl = window.location.href;
  4. var fliter = $(this).attr("name").toString();
  5. var fliterval = $(this).val();
  6. var separator = cururl.indexOf('?') !== -1 ? "&": "?";
  7. var re = new RegExp("([?&])");
  8. var urlarr;
  9. var newurl = "";
  10. if (cururl.indexOf(fliter) > 0) {
  11. urlarr = cururl.split(re);
  12. for (i = 0; i < urlarr.length; i++) {
  13. urlarr[i] = urlarr[i].indexOf(fliter) ? urlarr[i] : fliter + "=" + fliterval;
  14. urlarr[i] = urlarr[i].indexOf("Page") ? urlarr[i] : "Page=1";
  15. newurl = newurl + urlarr[i];
  16. }
  17. } else {
  18. newurl = cururl + separator + fliter + "=" + fliterval;
  19. }
  20. window.location.href = newurl;
  21. })
  22. $(".subnav").click(function() {
  23. $(this).find(".list-wraper").slideDown();
  24. $(this).siblings().find(".list-wraper").slideUp();
  25. })
  26. $(".slidepanel").click(function() {
  27. if ($(this).hasClass("open")) {
  28. $(this).removeClass("open");
  29. } else {
  30. $(this).addClass("open");
  31. }
  32. $(this).parent().next(".notepanel").slideToggle();
  33. })
  34. $(".tag").click(function(event) {
  35. var t = $(this).text();
  36. $("<span>" + t + "</span>").appendTo(".taglist");
  37. });
  38. $("#tapinput").keydown(function(event) {
  39. var t = $(this).val();
  40. if (event.keyCode == 13) {
  41. if (t == "") {
  42. alert("标签内容不能为空");
  43. } else {
  44. $("<span>" + t + "</span>").appendTo(".taglist");
  45. $("#tapinput").val("");
  46. }
  47. }
  48. });
  49. $("#fliterCountry").on("change",function(){
  50. $(".selectProduct").show();
  51. })
  52. $("#fliterproduct").on("change",function(){
  53. var product = $(this).val();
  54. var country=$("#fliterCountry").val();
  55. $.ajax({
  56. type: "GET",
  57. url: "quantitySearch.php",
  58. dataType: "html",
  59. contentType: "application/json;charset=utf-8",
  60. data: {
  61. "productId": product,
  62. "country":country
  63. },
  64. success: function(e) {
  65. $("#pricecontrol").html(e);
  66. }
  67. })
  68. })
  69. $(".taglist span").live('click',
  70. function() {
  71. $(this).remove();
  72. })
  73. $(".mytag span").click(function() {
  74. var $thistag = $(this);
  75. var cid = $(this).parent().data("id");
  76. var eid = $(this).parent().data("em");
  77. var tagvalue = $thistag.text();
  78. $.ajax({
  79. url: "bindTag.php",
  80. beforeSend: function() {
  81. if ($thistag.hasClass("active")) {
  82. $thistag.removeClass("active");
  83. } else {
  84. $thistag.addClass("active");
  85. }
  86. },
  87. data: {
  88. cid: cid,
  89. tagvalue: escape(tagvalue),
  90. eid: eid
  91. },
  92. success: function() {}
  93. });
  94. })
  95. $(".taghead").click(function() {
  96. $(this).attr("contenteditable", "true");
  97. });
  98. $(".taghead").focusout(function() {
  99. $this = $(this);
  100. $this.attr("contenteditable", "false");
  101. var originaltag = $this.data("originaltag");
  102. var newtag = $this.text();
  103. $.ajax({
  104. url: "editTag.php",
  105. beforeSend: function() {
  106. r = confirm("是否编辑标签");
  107. if (newtag == "") {
  108. alert("标签不能为空");
  109. return false;
  110. }
  111. if (r == false) {
  112. $this.text(originaltag);
  113. return false;
  114. }
  115. },
  116. data: {
  117. originaltag: escape(originaltag),
  118. newtag: escape(newtag)
  119. },
  120. success: function() {
  121. window.location.href = "/tag.php?tagName=" + newtag;
  122. }
  123. });
  124. })
  125. $(".colormark").click(function() {
  126. $(this).find(".colorlist").slideDown(300);
  127. })
  128. $(".colorlist li").click(function() {
  129. var $this = $(this);
  130. var colorid = $this.val();
  131. var cid = $this.parent().data("id");
  132. $(this).closest(".tline").removeClass().addClass("tline color" + colorid);
  133. $.ajax({
  134. url: "colorTag.php",
  135. data: {
  136. colorid: colorid,
  137. cid: cid
  138. },
  139. success: function() {
  140. $this.parent().slideUp(300);
  141. }
  142. });
  143. event.stopPropagation();
  144. })
  145. $(".claim").click(function() {
  146. var $this = $(this);
  147. var cid = $this.data("id");
  148. $.ajax({
  149. url: "claimCustomer.php",
  150. data: {
  151. cid: cid
  152. },
  153. success: function(data) {
  154. if (data == 1) {
  155. alert("认领成功");
  156. window.location.reload();
  157. } else {
  158. alert("每天只能认领5个客户");
  159. }
  160. }
  161. });
  162. })
  163. $(".syncphone").click(function() {
  164. var var1 = $("#cs_whatsapp").val();
  165. $("#cs_tel").val(var1);
  166. })
  167. })
  168. function chkboxall(t0, t1) {
  169. ischk = t0.checked;
  170. for (var i = 0; i < $("input[type=checkbox][name=" + t1 + "]").size(); i++) {
  171. $("input[type=checkbox][name=" + t1 + "]").eq(i).attr("checked", ischk);
  172. }
  173. }
  174. function postchk(t) {
  175. var $form = document.getElementById('form1'),
  176. chkact = parseInt(document.getElementById("chkact").value),
  177. ischk = false;
  178. for (var i = 0; i < $form.elements.length; i++) {
  179. if ($form.elements[i].name == "chkbox" && $form.elements[i].checked == true) {
  180. ischk = true;
  181. }
  182. }
  183. if (!ischk) {
  184. alert('请至少选择一条数据');
  185. return false;
  186. }
  187. switch (t) {
  188. case 1:
  189. switch (chkact) {
  190. case 2:
  191. if (confirm('更改客户状态为【无响应】吗?')) $form.submit();
  192. break;
  193. case 1:
  194. if (confirm('更改客户状态为【已成交】吗?')) $form.submit();
  195. break;
  196. case 0:
  197. if (confirm('更改客户状态为【未成交】吗?')) $form.submit();
  198. break;
  199. default:
  200. if (confirm('确认要修改吗?')) $form.submit();
  201. }
  202. break;
  203. case 2:
  204. switch (chkact) {
  205. case 1:
  206. if (confirm('确认要设置所选状态为【正常】吗?')) $form.submit();
  207. break;
  208. case 0:
  209. if (confirm('确认要设置所选状态为【隐藏】吗?')) $form.submit();
  210. break;
  211. default:
  212. if (confirm('确认要删除吗?\n删除后不可恢复')) $form.submit();
  213. }
  214. break;
  215. case 3:
  216. switch (chkact) {
  217. case 1:
  218. if (confirm('确认要设置所选状态为【已读】吗?')) $form.submit();
  219. break;
  220. case 0:
  221. if (confirm('确认要设置所选状态为【未读】吗?')) $form.submit();
  222. break;
  223. default:
  224. if (confirm('确认修改吗?')) $form.submit();
  225. }
  226. break;
  227. default:
  228. return false;
  229. }
  230. return false;
  231. }
  232. function subform() {
  233. $("#form1").submit();
  234. }
  235. function checkInput() {
  236. var clientCode = $("#cs_code").val();
  237. var clientCompany = $("#cs_company").val();
  238. var clientPhone = $("#cs_tel").val();
  239. var clientWechat = $("#cs_wechat").val();
  240. var clientWhatsapp = $("#cs_whatsapp").val();
  241. var clientEmail = $("#cs_email").val();
  242. var clientFrom = $("#cs_from").val();
  243. var clientCountry = $("#cs_country").val();
  244. var clientLindedin = $("#cs_linkedin").val();
  245. var clientFacebook = $("#cs_facebook").val();
  246. var clientAlibaba = $("#cs_alibaba").val();
  247. var clientDeal = $("#cs_deal").val();
  248. var arr = [];
  249. var $taglist = $(".taglist span");
  250. if (clientCode == "" || clientCode == null) {
  251. alert("客户代码不能为空!");
  252. $("#cs_code").focus();
  253. return false;
  254. }
  255. if (clientCountry == 0) {
  256. alert("这是哪个国家的客户?");
  257. return false;
  258. }
  259. if (clientFrom == "0") {
  260. alert("请填写客户来源!");
  261. return false;
  262. }
  263. if (clientPhone.length == 0 && clientWechat.length == 0 && clientWhatsapp.length == 0 && clientEmail.length == 0 && clientLindedin.length == 0 && clientFacebook.length == 0 && clientAlibaba.length == 0) {
  264. alert("联系方式不能全部为空!");
  265. return false;
  266. }
  267. $("input#mytag").val($(".taglist").html());
  268. alert('提交成功');
  269. }
  270. function checkpwd() {
  271. var pwdo = $("#em_password").val();
  272. var pwd = $("#pwd").val();
  273. var pwdre = $("#pwdre").val();
  274. if (pwd !== pwdre) {
  275. alert("密码输入不一致");
  276. return false;
  277. }
  278. }