mod.jjr.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. /*if (navigator.userAgent.toLowerCase().match(/MicroMessenger/i) != 'micromessenger' && navigator.userAgent.toLowerCase().match(/Windows Phone/i) != 'windows phone') {
  2. window.location.href = '/';
  3. }*/
  4. function GetQueryString(name)
  5. {
  6. var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
  7. //window.location
  8. var r = location.search.substr(1).match(reg);
  9. if(r!=null)return unescape(r[2]); return null;
  10. }
  11. KISSY.use('node,io', function(S, Node, IO) {
  12. var $ = Node.all;
  13. function loadImages(sources, callback) {
  14. var count = 0,
  15. images = {},
  16. imgNum = 0;
  17. for (src in sources) {
  18. imgNum++;
  19. }
  20. for (src in sources) {
  21. images[src] = new Image();
  22. images[src].onload = function() {
  23. if (++count >= imgNum) {
  24. callback(images);
  25. }
  26. }
  27. images[src].src = sources[src];
  28. }
  29. }
  30. loadImages(['tpl/www/images/bg-loader.jpg', 'tpl/www/images/ico-logo.png', 'tpl/www/images/sales-bg-loader.jpg', 'tpl/www/images/ico-sales-logo.png', 'tpl/www/images/recommend-tips.png', 'tpl/www/images/recommend-submit.png', 'tpl/www/images/recommend-logo.png', 'tpl/www/images/icon-jjr.png', 'tpl/www/images/icon-prize.png', 'tpl/www/images/gift_11.png', 'tpl/www/images/gift_01.png'], function() {
  31. setTimeout(function() {
  32. $('.loader').addClass('fadeOut').hide();
  33. $('.user-loader').addClass('fadeOut').hide();
  34. $('.main-box').addClass('fadeIn');
  35. $('#loading-style').remove();
  36. }, 1000);
  37. });
  38. var REG = {
  39. name: /^[a-zA-Z\u4e00-\u9fa5]{2,12}$/,
  40. phone: /(^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$)|(^0{0,1}1[3|4|5|6|7|8|9][0-9]{9}$)/,
  41. wxid: /^[a-zA-Z][a-zA-Z0-9_-]{5,19}$/,
  42. number: /^[+\-]?\d+(\.\d+)?$/,
  43. idCard:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
  44. }
  45. var userStatus={0:'无效', 1: '新客户',2:'已跟进',3:'到访',4 :'认筹',5:'认购',6:'签约', 7:'回款',8: '导入客户'}
  46. //经纪人注册
  47. var submit_broker = $('#J_submitReg');
  48. var companyName = $('.company-name');
  49. var name = $('#username');
  50. var phone = $('#phone');
  51. var job = $('#job');
  52. var password=$('#password');
  53. var company = $('#company');
  54. var agree = $('#agree');
  55. var DATA = {}
  56. if (job.val() == 'ZJGS' || job.val() == 'DLGS' || job.val() == 'HZHB' || job.val() == 'HZSP') {
  57. companyName.show();
  58. } else {
  59. companyName.hide();
  60. }
  61. job.on('change', function() {
  62. if (job.val() == 'ZJGS' || job.val() == 'DLGS' || job.val() == 'HZHB' || job.val() == 'HZSP') {
  63. companyName.show();
  64. } else {
  65. companyName.hide();
  66. }
  67. });
  68. submit_broker.on('click', function() {
  69. //姓名
  70. if (name.length == 1) {
  71. var nv = S.trim(name.val());
  72. if (nv == '') {
  73. alert('姓名不能为空!');
  74. return false;
  75. } else if (name.length > 6) {
  76. alert('姓名不能超过6个字!');
  77. return false;
  78. } else if (!REG.name.test(nv)) {
  79. alert('请填写正确的姓名!');
  80. return false;
  81. }
  82. }
  83. //手机
  84. if (phone.length == 1) {
  85. var pv = S.trim(phone.val());
  86. if (pv == '') {
  87. alert('手机号不能为空!');
  88. return false;
  89. } else if (!REG.phone.test(pv)) {
  90. alert('请填写正确的手机号!');
  91. return false;
  92. }
  93. }
  94. //密码
  95. if(password.length==1){
  96. var psw=S.trim(password.val());
  97. if(psw==''){
  98. alert('密码不能为空!');
  99. return false;
  100. }else if(psw.length<6 || psw.length>8 || !REG.number.test(psw)){
  101. alert('密码必须为6到8个数字!');
  102. return false;
  103. }
  104. }
  105. //职业
  106. if (job.length == 1) {
  107. var prv = job.val();
  108. var prCompany=S.trim(company.val());
  109. if (prv == 0) {
  110. alert('请选择您的职业');
  111. return false;
  112. }else if (prv == 'ZJGS' || prv == 'DLGS' || prv == 'HZHB' || prv == 'HZSP') {
  113. if(prCompany==''){
  114. alert('公司名称不能为空!');
  115. return false;
  116. }
  117. }
  118. }
  119. //注册协议
  120. if (agree.prop('checked') == false) {
  121. alert('请同意注册协议');
  122. return false;
  123. }
  124. var urlUid=GetQueryString("uid");
  125. if(isNaN(urlUid)||urlUid==null)
  126. {
  127. urlUid=0;
  128. }
  129. IO.post('index.php?c=register&f=checkphone&phone='+pv+'',function(data) {
  130. if (data == 0) {
  131. IO.post('index.php?c=register&f=setok&name='+nv+'&phone='+pv+'&password='+psw+'&job='+prv+'&company='+prCompany+'&ruid='+urlUid,function(data) {
  132. if (data == 1) {
  133. alert("注册成功");
  134. window.location.href = './index.php?c=index';
  135. } else {
  136. alert(data);
  137. }
  138. });
  139. } else {
  140. if (data == 1) {
  141. alert('手机号为空或已被使用');
  142. } else {
  143. alert('参数有误或系统异常,请稍后重试!');
  144. }
  145. }
  146. });
  147. });
  148. //在登录页跳转到注册页
  149. var J_Gotologin = $('#J_GotoReg');
  150. J_Gotologin.on('click', function() {
  151. window.location.href = './index.php?c=register';
  152. });
  153. //经纪人登录
  154. var J_login = $('#J_login');
  155. var userpsw=$('#userpsw');
  156. J_login.on('click', function() {
  157. if (phone.length == 1) {
  158. var pv = S.trim(phone.val());
  159. if (pv == '') {
  160. alert('手机号不能为空!');
  161. return false;
  162. } else if (!REG.phone.test(pv)) {
  163. alert('请填写正确的手机号!');
  164. return false;
  165. }
  166. }
  167. //密码
  168. if(userpsw.length==1){
  169. var ups=S.trim(userpsw.val());
  170. if(ups==''){
  171. alert('密码不能为空!');
  172. return false;
  173. }else if(ups.length<6 || ups.length>8 || !REG.number.test(ups)){
  174. alert('密码必须为6到8个数字!');
  175. return false;
  176. }
  177. }
  178. IO.post('index.php?c=login&f=ok&phone='+pv+'&password='+ups+'', function(data) {
  179. if (data == 1) {
  180. window.location.href = './index.php?c=index';
  181. } else {
  182. alert(data);
  183. }
  184. });
  185. });
  186. //个人中心登录
  187. var J_login_my = $('#J_login_my');
  188. var username=$('#user-name');
  189. var userPsw=$('#user-psw');
  190. J_login_my.on('click', function() {
  191. if(username.length==1){
  192. var username=S.trim(username.val());
  193. if(username==''){
  194. alert('手机不能为空!');
  195. return false;
  196. }
  197. DATA.username=username;
  198. }
  199. //密码
  200. if(userPsw.length==1){
  201. var psw=S.trim(userPsw.val());
  202. if(psw==''){
  203. alert('密码不能为空!');
  204. return false;
  205. }else if(psw.length<6 || psw.length>8 || !REG.number.test(psw)){
  206. alert('密码必须为6到8个数字!');
  207. return false;
  208. }
  209. DATA.password=psw;
  210. }
  211. IO.post('./index.php?c=login', DATA, function(data) {
  212. if (data.status == 200) {
  213. location.href = data.url;
  214. } else {
  215. alert('密码错误');
  216. }
  217. }, 'json');
  218. });
  219. //我要推荐提交
  220. var submitRec = $('#J_submitRec');
  221. var floor = $('#floor');
  222. var selorderTime = $('#selorderTime');
  223. var selorderTime2 = $('#selorderTime2');
  224. var remark = $('#remark');
  225. submitRec.on('click', function() {
  226. //姓名
  227. if (name.length == 1) {
  228. var nv = S.trim(name.val());
  229. if (nv == '') {
  230. alert('姓名不能为空!');
  231. return false;
  232. } else if (name.length > 6) {
  233. alert('姓名不能超过6个字!');
  234. return false;
  235. } else if (!REG.name.test(nv)) {
  236. alert('请填写正确的姓名!');
  237. return false;
  238. }
  239. }
  240. //手机
  241. if (phone.length == 1) {
  242. var pv = S.trim(phone.val());
  243. if (pv == '') {
  244. alert('手机号不能为空!');
  245. return false;
  246. } else if (!REG.phone.test(pv)) {
  247. alert('请填写正确的手机号!');
  248. return false;
  249. }
  250. }
  251. //意向楼盘
  252. if (floor.length == 1) {
  253. var prv = S.trim(floor.val());
  254. if (prv == 0) {
  255. alert('请选择您的意向');
  256. return false;
  257. }
  258. }
  259. //意向楼盘
  260. if (selorderTime.length == 1) {
  261. var st = S.trim(selorderTime.val());
  262. if (st == 0) {
  263. alert('请输入预约日期');
  264. return false;
  265. }
  266. }
  267. //意向楼盘
  268. if (selorderTime2.length == 1) {
  269. var st2 = selorderTime2.val();
  270. if (st2 == 0) {
  271. alert('请选择预约时段');
  272. return false;
  273. }
  274. }
  275. if (remark.length == 1) {
  276. var pre = S.trim(remark.val());
  277. if (pre.length > 50) {
  278. alert('备注不能超过50个字');
  279. return false;
  280. }
  281. }
  282. var myDate = new Date();
  283. var strDate=myDate.getFullYear()+"-"+myDate.getMonth()+"-"+myDate.getDate();
  284. var strTime=myDate.getHours()+":"+myDate.getMinutes();
  285. //请求
  286. IO.post('index.php?c=recommend&f=save&username='+nv+'&cellphone='+pv+'&proname='+prv+'&selorderTime='+strDate+'&selorderTime2='+strTime+'&remark='+pre+'', function(data) {
  287. if (data == 1) {
  288. $('.recommend-pop').show();
  289. $('.pop-bg').show();
  290. } else {
  291. alert(data);
  292. }
  293. });
  294. });
  295. var dialogs = $('#dialog');
  296. var ad = $('.ad');
  297. dialogs.on('click', function() {
  298. ad.addClass('adshow');
  299. });
  300. ad.on('click', function() {
  301. ad.remove('adshow');
  302. });
  303. //保存银行卡信息
  304. var saveCard = $('#J_saveCard');
  305. var accountName=$('#bankAccount');
  306. var card = $('#cardCode');
  307. var bank = $('#bankName');
  308. saveCard.on('click', function() {
  309. //户名
  310. if(accountName.length==1){
  311. var account=S.trim(accountName.val());
  312. if(account==''){
  313. alert('户名不能为空!');
  314. return false;
  315. } else if (!REG.name.test(account)) {
  316. alert('请填写正确的户名!');
  317. return false;
  318. }
  319. }
  320. //银行卡号
  321. if (card.length == 1) {
  322. var num = S.trim(card.val());
  323. if (num == '') {
  324. alert('银行卡号不能为空!');
  325. return false;
  326. } else if (!REG.number.test(num)) {
  327. alert('请填写正确的银行号!');
  328. return false;
  329. }
  330. }
  331. //银行卡名称
  332. if (bank.length == 1) {
  333. var name = S.trim(bank.val());
  334. if (name == '') {
  335. alert('银行名称不能为空!');
  336. return false;
  337. }
  338. }
  339. //请求
  340. IO.post('index.php?c=usercp&f=savebank&bankAccount='+account+'&cardCode='+num+'&bankName='+name+'', function(data) {
  341. if (data == 1) {
  342. window.location.href = './index.php?c=commission';
  343. } else {
  344. alert(data);
  345. }
  346. });
  347. });
  348. //佣金提现
  349. var WJTXSave=$('#J_WJTX_save');
  350. WJTXSave.on('click',function(){
  351. var money=$('#txmoney').val();
  352. var ktxmoney=$('#ktxmoney').val();
  353. if(ktxmoney==0)
  354. {
  355. alert("您还没有可提现金额,需要努力哟!");
  356. return;
  357. }
  358. if(isNaN(money)||!REG.number.test(money))
  359. {
  360. alert("请输入正确的金额!");
  361. return;
  362. }
  363. if(parseFloat(ktxmoney)<parseFloat(money)){
  364. alert("您输入的提现金额“"+money+"”大于当前可提现金额“"+ktxmoney+"”");
  365. return;
  366. }
  367. //请求
  368. IO.post('index.php?c=commissiontx&f=checkmoney&money='+money+'',function(data) {
  369. if (data == 0) {
  370. IO.post('index.php?c=commissiontx&f=txwjok&money='+money+'',function(data){
  371. if(data==1){
  372. alert('提现申请成功!');
  373. window.location.href = './index.php?c=commission';
  374. }else{
  375. alert("提现失败:"+data);
  376. }
  377. });
  378. } else {
  379. if (data == 1) {
  380. alert('可提现金额不足');
  381. } else {
  382. alert('参数有误或系统异常,请稍后重试!'+data);
  383. }
  384. }
  385. });
  386. })
  387. //编辑个人资料
  388. var editSave=$('#J_edit_save');
  389. editSave.on('click',function(){
  390. //姓名
  391. if (name.length == 1) {
  392. var nv = S.trim(name.val());
  393. if (nv == '') {
  394. alert('姓名不能为空!');
  395. return false;
  396. } else if (name.length > 6) {
  397. alert('姓名不能超过6个字!');
  398. return false;
  399. } else if (!REG.name.test(nv)) {
  400. alert('请填写正确的姓名!');
  401. return false;
  402. }
  403. }
  404. //手机
  405. if (phone.length == 1) {
  406. var pv = S.trim(phone.val());
  407. if (pv == '') {
  408. alert('手机号不能为空!');
  409. return false;
  410. } else if (!REG.phone.test(pv)) {
  411. alert('请填写正确的手机号!');
  412. return false;
  413. }
  414. }
  415. //职业
  416. if (job.length == 1) {
  417. var prv = job.val();
  418. var prCompany=S.trim(company.val());
  419. if (prv == 0) {
  420. alert('请选择您的职业');
  421. return false;
  422. }else if (job.val() == 'ZJGS' || job.val() == 'DLGS' || job.val() == 'HZHB' || job.val() == 'HZSP') {
  423. if(prCompany==''){
  424. alert('公司名称不能为空!');
  425. return false;
  426. }
  427. }
  428. }
  429. //请求
  430. IO.post('index.php?c=usercp&f=ok&name='+nv+'&job='+prv+'&company='+prCompany+'',function(data){
  431. if(data==1){
  432. alert('修改成功!');
  433. }else{
  434. alert(data);
  435. }
  436. });
  437. })
  438. //初始化页面高度
  439. var v_h = null; //记录设备的高度
  440. function init_pageH(){
  441. var fn_h = function() {
  442. if(document.compatMode == 'BackCompat')
  443. var Node = document.body;
  444. else
  445. var Node = document.documentElement;
  446. return Math.max(Node.scrollHeight,Node.clientHeight);
  447. }
  448. var page_h = fn_h();
  449. // //设置各种模块页面的高度,扩展到整个屏幕高度
  450. $('.gift').height(page_h);
  451. $('.regift-page').height(page_h);
  452. };
  453. init_pageH();
  454. //注册有礼添加动画
  455. setTimeout(function(){
  456. $('.gift-box').addClass('animated tada');
  457. },200);
  458. setTimeout(function(){
  459. $('.gift-text').addClass('animated fadeInUp');
  460. },500);
  461. setTimeout(function(){
  462. $('.gift-open').addClass('animated fadeInDown');
  463. },600);
  464. setTimeout(function(){
  465. $('.gift-flash-1').addClass('animated flash');
  466. $('.gift-flash-2').addClass('animated flash');
  467. $('.gift-flash-3').addClass('animated flash');
  468. $('.gift-flash-4').addClass('animated flash');
  469. $('.gift-flash-5').addClass('animated flash');
  470. },1200);
  471. //打开奖品
  472. var gift=$('.gift-amount');
  473. var prize=$('.prize');
  474. gift.on('click',function(){
  475. prize.removeClass('animated zoomOut');
  476. prize.addClass('animated zoomInPrice');
  477. bg.show();
  478. })
  479. //关闭奖品
  480. var prizeClose=$('.prize-close');
  481. prizeClose.on('click',function(){
  482. prize.removeClass('animated zoomInPrice');
  483. prize.addClass('animated zoomOut');
  484. bg.hide();
  485. })
  486. //分享朋友圈提示
  487. var share=$('.J_share');
  488. share.on('click',function(){
  489. if($('.share-tips').length==0){
  490. $('body').append('<div class="share-tips"><a href="javascript:;" class="close">关闭</a><img src="/tpl/www/bg-guide.png" alt="" /></div>');
  491. }
  492. $('.share-tips').on('click',function(){
  493. $('.share-tips,.share-tips .close,.share-tips img').remove();
  494. });
  495. });
  496. //案场经理全选
  497. var checkAll=$('.checkbox-all');
  498. var checkOne=$('.checkbox-btn .regular-checkbox');
  499. checkAll.on('click',function(){
  500. var is_pitch=$(this).prop('checked');
  501. if(is_pitch){
  502. checkOne.each(function(){
  503. $(this).prop('checked',true);
  504. });
  505. }else{
  506. checkOne.each(function(){
  507. $(this).prop('checked',false);
  508. });
  509. }
  510. });
  511. //案场经理点击checkbox
  512. var clients=$('.checkbox-btn');
  513. clients.on('click',function(){
  514. checkAll.prop('checked',checkOne.length==checkOne.filter(':checked').length);
  515. });
  516. //置业顾问注销
  517. var logOut=$('.J_logout');
  518. var ok_delete=$('.J_ok_delete');
  519. var logoutBox=$('.logout-box');
  520. var logoutUrl = $('#logoutUrl').val();
  521. var uid = $('#uid').val();
  522. logOut.on('click',function(){
  523. logoutBox.show();
  524. });
  525. ok_delete.on('click',function(){
  526. IO.post(logoutUrl, {uid:uid}, function(data) {
  527. if (data.status == 200) {
  528. location.href = data.teamUrl;
  529. } else {
  530. alert("注销失败");
  531. }
  532. }, 'json');
  533. });
  534. //关闭置业顾问注销弹出层
  535. var Cons_cancel=$('.Cons_cancel');
  536. Cons_cancel.on('click',function(){
  537. logoutBox.hide();
  538. });
  539. //经纪人信息显示隐藏
  540. var jjrTitle=$('.jjr-title');
  541. var jjrHide=$('.jjr-hide');
  542. var iconDown=$('.icon-down-open-big');
  543. jjrTitle.on('click',function(){
  544. jjrHide.toggle();
  545. iconDown.toggleClass('icon-down-transform');
  546. });
  547. //案场经理修改客户状态操作
  548. var J_save_status = $('.J_save_status');
  549. var cid = $('#cid').val();
  550. var zid = $('#zid').val();
  551. var statusUrl = $('#statusUrl').val();
  552. J_save_status.on('click', function() {
  553. var now_status = $('#now_status').val();
  554. var updated_status = $('#updated_status').val();
  555. var number_status = updated_status - now_status;
  556. if (number_status == 1) {
  557. var DATA = {};
  558. DATA.customer_id = cid;
  559. DATA.zid = zid;
  560. DATA.waid = waid;
  561. if (updated_status==2) { //已跟进(有意向无意向)
  562. DATA.status = 2;
  563. DATA.intent = $('#intent').val();
  564. //请求
  565. IO.post(statusUrl, DATA, function(data) {
  566. if (data.status == 200) {
  567. $('#now_status').val(data.now_status);
  568. location.href = data.url;
  569. } else {
  570. alert('操作失败');
  571. }
  572. }, 'json');
  573. } else if (updated_status==6) {//签约
  574. DATA.intent = 1;
  575. DATA.price = $('#price').val();
  576. DATA.status = 6;
  577. IO.post(statusUrl, DATA, function(data) {
  578. if (data.status == 200) {
  579. $("#now_status").val(data.now_status);
  580. location.href = data.url;
  581. } else {
  582. alert('操作失败');
  583. }
  584. }, 'json');
  585. }else{
  586. var DATA = {};
  587. DATA.customer_id = cid;
  588. DATA.zid = zid;
  589. DATA.waid = waid;
  590. DATA.intent = 1;
  591. DATA.status = updated_status;
  592. IO.post(statusUrl, DATA, function(data) {
  593. if (data.status == 200) {
  594. $("#now_status").val(data.now_status);
  595. location.href = data.url;
  596. } else {
  597. alert('操作失败');
  598. }
  599. }, 'json');
  600. }
  601. } else {
  602. alert('请先确认上步操作')
  603. }
  604. });
  605. });
  606. function direct(url,frameid,isparent)
  607. {
  608. url = url.replace(/&amp;/g,"&");
  609. if(!isparent || isparent == "" || isparent == "undefined")
  610. {
  611. if(frameid)
  612. {
  613. window.frames[frameid].location.href = url;
  614. }
  615. else
  616. {
  617. window.location.href=url;
  618. }
  619. }
  620. else
  621. {
  622. if(!frameid || frameid == "" || frameid == "undefined")
  623. {
  624. parent.window.location.href = url;
  625. }
  626. else
  627. {
  628. window.parent.frames[frameid].location.href = url;
  629. }
  630. }
  631. }
  632. //设定多长时间运行脚本
  633. //参数 time 是时间单位是毫秒,为0时表示直接运行 大于0小于10毫秒将自动*1000
  634. //参数 js 要运行的脚本
  635. function eval_js(time,js)
  636. {
  637. time = parseFloat(time);
  638. if(time < 0.01)
  639. {
  640. eval(js);
  641. }
  642. else
  643. {
  644. if(time < 10)
  645. {
  646. time = time*1000;
  647. }
  648. window.setTimeout(js,time);
  649. }
  650. }
  651. //编码网址
  652. function url_encode(str)
  653. {
  654. return transform(str);
  655. }