index.php 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951
  1. <style>
  2. #more_module {
  3. width: 300px;
  4. }
  5. .module_link {
  6. float: left;
  7. width: 140px;
  8. padding: 3px 5px;
  9. }
  10. .module_total {
  11. color: green;
  12. }
  13. .easyui-textbox {
  14. }
  15. </style>
  16. <div id="main">
  17. <div region="west" id="west_panel" border="false">
  18. <table id="dg_content"></table>
  19. <div id="tb_content">
  20. <div class="tb_line">
  21. <input id="ss" />
  22. </div>
  23. <div style="margin: 3px 2px;padding:5px;border: 1px solid #95B8E7;display:none;">
  24. <!-- <a href="#" class='easyui-linkbutton' plain="true" iconCls="icon-add" onclick="add_content();return false;">新增用户</a>-->
  25. </div>
  26. </div>
  27. </div>
  28. <!---->
  29. <div id="acc_container" class="accordion" region="center">
  30. <div region="center" title="用户信息" data-options="iconCls:'icon-save',selected:true">
  31. <div class="easyui-layout detail_layout">
  32. <div data-options="region:'center'" class="detail_center">
  33. <div class="detail_main">
  34. <form id="content_form" method="post">
  35. <ul>
  36. <li class="f_item">
  37. <div class="box">
  38. <div class="f_label">
  39. <span>ID: </span>
  40. </div>
  41. <div class="box_flex f_content">
  42. <input type="hidden" name="id" id="user_id" value='' />
  43. <span id="id_str"></span>
  44. </div>
  45. </div>
  46. </li>
  47. <li class="f_item" id="content_area">
  48. <div class="box">
  49. <div class="f_label">
  50. <span>注册时间: </span>
  51. </div>
  52. <div class="box_flex f_content">
  53. <span id="register_time_str"></span>
  54. </div>
  55. </div>
  56. </li>
  57. <li class="f_item">
  58. <div class="box">
  59. <div class="f_label">
  60. <span>城市信息: </span>
  61. </div>
  62. <div class="box_flex f_content">
  63. <input type="text" name="city_info" id="city_info_add" placeholder="如:湖北省,武汉市" style="width: 250px;"/>
  64. </div>
  65. </div>
  66. </li>
  67. <li class="f_item">
  68. <div class="box">
  69. <div class="f_label">
  70. <span>头像: </span>
  71. </div>
  72. <div class="box_flex f_content">
  73. <div id="avatar_info"></div>
  74. </div>
  75. </div>
  76. </li>
  77. <li class="f_item">
  78. <div class="box">
  79. <div class="f_label">
  80. <span>openid: </span>
  81. </div>
  82. <div class="box_flex f_content">
  83. <span id="openid"></span>
  84. </div>
  85. </div>
  86. </li>
  87. <li class="f_item">
  88. <div class="box">
  89. <div class="f_label">
  90. <span>经纬度: </span>
  91. </div>
  92. <div class="box_flex f_content">
  93. <input type="text" id="view_latitude" style="width: 80px;" readonly/>
  94. <input type="text" id="view_longitude" style="width: 80px;" readonly/><a href="javascript:void();" id="view_select_position">查看坐标</a>
  95. </div>
  96. </div>
  97. </li>
  98. <li class="f_item">
  99. <div class="box">
  100. <div class="f_label">
  101. </div>
  102. <div class="box_flex f_content">
  103. <span id="action_info" style="color:green;"></span>
  104. </div>
  105. </div>
  106. </li>
  107. </ul>
  108. </form>
  109. </div>
  110. </div>
  111. <div data-options="region:'south'" class="detail_south">
  112. <div class="detail_toolbar">
  113. <a href="#" class="easyui-linkbutton set_button" iconCls="icon-save" onclick="save_content();return false;">保存</a>
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. <div region="center" title="用户订单" data-options="iconCls:'icon-save'" style="overflow:auto;padding:10px;">
  119. <div class="detail_layout">
  120. <div data-options="region:'center'" class="detail_center">
  121. <table id="order_dg"></table>
  122. </div>
  123. </div>
  124. </div>
  125. <div region="center" title="用户可用代金券" data-options="iconCls:'icon-save'" style="overflow:auto;padding:10px;">
  126. <div class="detail_layout">
  127. <div data-options="region:'center'" class="detail_center">
  128. <div class="detail_main"> 
  129. <table id="coupon_dg"></table>
  130. <!-- <div style="margin-top: 30px;">
  131. <span>用户订单统计</span>
  132. <span id="content_order_count"></span>
  133. </div> -->
  134. </div>
  135. </div>
  136. <div data-options="region:'south'" class="detail_south">
  137. </div>
  138. </div>
  139. </div>
  140. <div region="center" title="后台发送优惠券" data-options="iconCls:'icon-save'" style="overflow:auto;padding:10px;">
  141. <div class="detail_layout">
  142. <div data-options="region:'center'" class="detail_center">
  143. <div class="detail_main">
  144. <form id="sendCoupon_form" method="post">
  145. <ul>
  146. <li class="f_item">
  147. <div class="box">
  148. <div class="f_label">
  149. <span>ID: </span>
  150. </div>
  151. <div class="box_flex f_content">
  152. <span id="coupon_user_str"></span>
  153. <input type="hidden" name="user_id" id="coupon_user_id" />
  154. </div>
  155. </div>
  156. </li>
  157. <li class="f_item">
  158. <div class="box">
  159. <div class="f_label">
  160. <span>优惠券ID: </span>
  161. </div>
  162. <div class="box_flex f_content">
  163. <input name="coupon_id" id="coupon_id" style="width:250px;"/>
  164. </div>
  165. </div>
  166. </li>
  167. <li class="f_item">
  168. <div class="box">
  169. <div class="f_label">
  170. <span>开始时间: </span>
  171. </div>
  172. <div class="box_flex f_content">
  173. <input name="start_time" id="coupon_start_time" class="easyui-datebox" style="width:250px;"/>
  174. </div>
  175. </div>
  176. </li>
  177. <li class="f_item">
  178. <div class="box">
  179. <div class="f_label">
  180. <span>结束时间: </span>
  181. </div>
  182. <div class="box_flex f_content">
  183. <input name="end_time" id="coupon_end_time" class="easyui-datebox" style="width:250px;"/>
  184. </div>
  185. </div>
  186. </li>
  187. <li class="f_item">
  188. <div class="box">
  189. <div class="f_label">
  190. <span>发送短信: </span>
  191. </div>
  192. <div class="box_flex f_content">
  193. <input name="need_sms" id="need_sms" type="checkbox" value="1" onclick="needMessage();"/>
  194. </div>
  195. </div>
  196. </li>
  197. <li class="f_item" id="coupon_copy_item" >
  198. <div class="box">
  199. <div class="f_label">
  200. <span>默认文案: </span>
  201. </div>
  202. <div class="box_flex f_content">
  203. <textarea name="copy" id="coupon_copy" style="width:250px;height:120px;"></textarea>
  204. </div>
  205. </div>
  206. </li>
  207. </ul>
  208. </form>
  209. </div>
  210. </div>
  211. <div data-options="region:'south'" class="detail_south">
  212. <div class="detail_toolbar">
  213. <a href="javascript:void(0);" class="easyui-linkbutton set_button" iconCls="icon-save" onclick="sendCoupon();return false;">发送</a>
  214. </div>
  215. </div>
  216. <div data-options="region:'south'" class="detail_south">
  217. </div>
  218. </div>
  219. </div>
  220. <div region="center" title="修改余额" data-options="iconCls:'icon-save'" style="overflow:auto;padding:10px;">
  221. <div class="detail_layout">
  222. <div data-options="region:'center'" class="detail_center">
  223. <div class="detail_main">
  224. <form id="sendBalance_form" method="post">
  225. <ul>
  226. <li class="f_item">
  227. <div class="box">
  228. <div class="f_label">
  229. <span>ID: </span>
  230. </div>
  231. <div class="box_flex f_content">
  232. <span id="balance_id_str"></span>
  233. <input type="hidden" name="id" id="balance_user_id" />
  234. </div>
  235. </div>
  236. </li>
  237. <li class="f_item">
  238. <div class="box">
  239. <div class="f_label">
  240. <span>金额: </span>
  241. </div>
  242. <div class="box_flex f_content">
  243. <input name="amount" id="amount" placeholder="如100或者-100" style="width:250px;"/>
  244. </div>
  245. </div>
  246. </li>
  247. <li class="f_item">
  248. <div class="box">
  249. <div class="f_label">
  250. <span>类型: </span>
  251. </div>
  252. <div class="box_flex f_content">
  253. <input type="radio" name="type" value="admin_recharge">后台充值
  254. <input type="radio" name="type" value="order">下订单
  255. <input type="radio" name="type" value="send">赠送
  256. <input type="radio" name="type" value="other">其他
  257. </div>
  258. </div>
  259. </li>
  260. <li class="f_item">
  261. <div class="box">
  262. <div class="f_label">
  263. <span>备注: </span>
  264. </div>
  265. <div class="box_flex f_content">
  266. <textarea name="memo" id="memo" style="width:250px;height:120px;"></textarea>
  267. </div>
  268. </div>
  269. </li>
  270. </ul>
  271. </form>
  272. </div>
  273. </div>
  274. <div data-options="region:'south'" class="detail_south">
  275. <div class="detail_toolbar">
  276. <a href="javascript:void(0);" class="easyui-linkbutton set_button" iconCls="icon-save" onclick="saveBalance();return false;">保存</a>
  277. </div>
  278. </div>
  279. <div data-options="region:'south'" class="detail_south">
  280. </div>
  281. </div>
  282. </div>
  283. <div region="center" title="余额记录" data-options="iconCls:'icon-save'" style="overflow:auto;padding:10px;">
  284. <div class="detail_layout">
  285. <div data-options="region:'center'" class="detail_center">
  286. <table id="balance_dg"></table>
  287. </div>
  288. </div>
  289. </div>
  290. </div>
  291. </div>
  292. <!--新增用户结束 -->
  293. <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/qiniu_upload_single.js?v=20200907"></script>
  294. <script type="text/javascript">
  295. var jq_dg_content = $('#dg_content');
  296. var w_width = $(window).width();
  297. var w_height = $(window).height();
  298. var jq_content_form = $('#content_form');
  299. var jq_action_info = $('#action_info');
  300. var jq_add_dialog = $('#add_dialog');
  301. var jq_add_form = $('#add_form');
  302. var jq_balance_form = $('#balance_form');
  303. var jq_avatar = $('#avatar_info');
  304. var jq_ss = $('#ss');
  305. var jq_acc = $('#acc_container');
  306. var module_router = site_root + '/index.php?r=rUser';
  307. var type = <?php echo json_encode($type); ?>;
  308. var jq_sendCoupon_form = $('#sendCoupon_form');
  309. var jq_sendBalance_form = $('#sendBalance_form');
  310. var price = '';
  311. var endtime = '';
  312. var jq_order_dg = $('#order_dg');
  313. var jq_balance_dg = $('#balance_dg');
  314. console.log(window.location.href);
  315. $(function(){
  316. $('#view_select_position').click(function(){
  317. $.fn.position_selector('init',{
  318. width:$(window).width()-300,//弹框显示宽度
  319. height:$(window).height()-100,//弹框显示高度
  320. zoom:18, //缩放级别
  321. locat:'上海',//默认城市
  322. can_edit:true,
  323. lat:$('#view_latitude').val(),
  324. lng:$('#view_longitude').val(),
  325. func_callback:function(){return false;},//选择成功之后的回调函数
  326. element_id:'map_container'//弹窗ID
  327. });return false;
  328. });
  329. var p_width = parseInt(w_width / 2);
  330. if (p_width < 550){
  331. p_width = 550;
  332. }
  333. var d_width = p_width - 10;
  334. $('#west_panel').css({width : p_width});
  335. $('#main').css({width: w_width - 25, height: w_height - 18}).layout();
  336. jq_acc.accordion({
  337. height: w_height - 18,
  338. onSelect:function(title){
  339. // alert("fdafdsa");
  340. }
  341. });
  342. jq_ss.searchbox({
  343. width: 120,
  344. searcher:function(value){
  345. search_content();
  346. },
  347. prompt: '请输入关键字'
  348. });
  349. jq_add_dialog.dialog({
  350. title: '创建用户',
  351. width: 500,
  352. height: 500,
  353. closed: true,
  354. modal: true,
  355. buttons:[{
  356. text: '确认',
  357. iconCls: 'icon-ok',
  358. handler: function(){
  359. $.messager.progress();
  360. jq_add_form.submit();
  361. }
  362. },{
  363. text: '取消',
  364. iconCls: 'icon-cancel',
  365. handler: function(){
  366. jq_add_dialog.dialog('close');
  367. }
  368. }],
  369. onOpen:function(){
  370. $('#avatar').parent().children('img').remove();
  371. jq_add_form.form('clear');
  372. $.fn.qiniu_upload_single('init',{
  373. bucket:'avatars',
  374. success_callback:function(result){
  375. var img_url = result.url;
  376. $('#avatar').parent().children('img').remove();
  377. $('#avatar').val(img_url).after('<img src="'+img_url+'" style="max-width: 200px;" />');
  378. },
  379. fail_callback:function(){
  380. $.messager.alert('提示', '上传失败,请稍后再试', 'warning');
  381. return false;
  382. }
  383. });
  384. }
  385. });
  386. jq_add_form.form({
  387. url: module_router + '/add',
  388. onSubmit: function(param){
  389. if(checkPass($('#add_password').val())<3){
  390. $.messager.show({
  391. title: '提示',
  392. msg: '密码太简单了,必须是大写字母、小写字母、数字、特殊字符中任意三个组合,且长度大于8',
  393. timeout: 3500,
  394. showType: 'slide'
  395. });
  396. $.messager.progress('close');
  397. return false ;
  398. }
  399. var isValid = $(this).form('validate');
  400. if (!isValid){
  401. $.messager.progress('close');
  402. }
  403. return isValid;
  404. },
  405. success: function(res){
  406. $.messager.progress('close');
  407. var res = JSON.parse(res);
  408. if (res.success){
  409. $.messager.show({
  410. title: '提示',
  411. msg: '添加成功',
  412. timeout: 3500,
  413. showType: 'slide'
  414. });
  415. jq_add_dialog.dialog('close');
  416. jq_dg_content.datagrid('reload');
  417. }else{
  418. $.messager.show({
  419. title: '提示',
  420. msg: res.message,
  421. timeout: 3500,
  422. showType: 'slide'
  423. });
  424. }
  425. }
  426. });
  427. jq_dg_content.datagrid({
  428. url: site_root + '/index.php?r=rUser/list',
  429. title: '用户列表',
  430. width: d_width,
  431. height: w_height - 18,
  432. fitColumns: true,
  433. autoRowHeight: true,
  434. striped: true,
  435. toolbar: '#tb_content',
  436. singleSelect: true,
  437. selectOnCheck: false,
  438. checkOnSelect: false,
  439. pagination: true,
  440. pageList: [20],
  441. pageSize: 20,
  442. nowrap: false,
  443. idField: 'id',
  444. sortName: 'register_time',
  445. sortOrder: 'desc',
  446. queryParams: get_param_obj(),
  447. frozenColumns:[[
  448. {field:'ck',checkbox:true}
  449. ]],
  450. columns:[[
  451. {field:'user_name', title:'用户名', width:45,
  452. formatter:function(value,row){
  453. if(row.is_fake_user){
  454. value = '<span style="color:red;">'+value+'</span>';
  455. }
  456. if (row.certify_status) {
  457. value = '<span class="l-btn-icon icon-v" style="position:relative;"></span>'+value;
  458. }
  459. return value.replace(/[\u202e,\u202d]/," ");
  460. }
  461. },
  462. {field:'balance', title:'余额', width:45,sortable:true},
  463. {field:'order_count', title:'总单数', width:45,sortable:true},
  464. {field:'city_info', title:'城市', width:50, sortable: false,
  465. formatter: function(value, row){
  466. return formatCity(value);
  467. }
  468. },
  469. {field:'register_time', title:'注册时间', width:60, sortable: true,
  470. formatter: function(value, row){
  471. return row.register_time_str;
  472. }
  473. }
  474. ]],
  475. onSelect: function(index, row){
  476. endtime = '';
  477. price = '';
  478. var data = $.extend({}, row);
  479. jq_content_form.form('load', data);
  480. console.log(data);
  481. $('#id_str').html(data.id);
  482. $('#balance_id_str').html(data.id);
  483. $('#register_time_str').html(format_time_stamp(data.register_time,true));
  484. $('#openid').html(data.openid);
  485. $('#channel').html(data.channel);
  486. $('#register_time').html(format_time_stamp(data.register_time,true));
  487. $('#view_latitude').val(data.latitude);
  488. $('#view_longitude').val(data.longitude);
  489. jq_sendCoupon_form.form('clear');
  490. jq_sendBalance_form.form('clear');
  491. $('#balance_user_id').val(data.id);
  492. $('#coupon_user_id').val(data.id);
  493. $('#coupon_user_str').html(data.id);
  494. $('#coupon_copy_item').hide();
  495. $('#city_info_add').val(formatCity(data.city_info));
  496. if(row.is_fake_user){
  497. $('#city_info_add').removeAttr("readonly");
  498. }else{
  499. $('#city_info_add').attr("readonly","readonly");
  500. }
  501. $('#coupon_dg').datagrid({
  502. url: site_root + '/index.php?r=rUser/getCoupons&user_id=' + data.id,
  503. columns:[[
  504. {field:'name',title:'优惠券名称',width:150},
  505. {field:'end_time_str',title:'过期时间',width:150},
  506. {field:'value',title:'面额',width:100},
  507. {field:'min_price',title:'最低消费',width:100},
  508. {field:'type_str',title:'服务项目',width:120},
  509. {field:'unuseable_reason',title:'优惠券状态',width:130},
  510. ]]
  511. });
  512. jq_balance_dg.datagrid({
  513. url: site_root + '/index.php?r=rUser/balanceLog',
  514. fitColumns: true,
  515. pagination: true,
  516. pageList: [20, 30, 50],
  517. pageSize: 20,
  518. singleSelect: true,
  519. queryParams: {
  520. id: data.id
  521. },
  522. columns: [[
  523. {field: 'time_str', title: '时间', width: 60},
  524. {field: 'type_str', title: '类型', width: 50,},
  525. {field: 'action_user', title: '操作者', width: 100,},
  526. {field:'amount', title:'数量', width:40},
  527. {field:'memo', title:'说明', width:200}
  528. ]]
  529. });
  530. jq_order_dg.datagrid({
  531. url: site_root + '/index.php?r=rOrder/list',
  532. fitColumns: true,
  533. pagination: true,
  534. pageList: [20, 30, 50],
  535. pageSize: 20,
  536. singleSelect: true,
  537. queryParams: {
  538. search: data.id
  539. },
  540. columns: [[
  541. {field: 'products_str', title: '服务', width: 40,
  542. formatter: function(value, row) {
  543. return value;
  544. }
  545. },
  546. {field: 'order_time_str', title: '下单时间', width: 100,
  547. formatter: function(value, row) {
  548. return '<a href="javascript:;" onclick="parent.load_url(\'<?=Yii::app()->request->baseUrl;?>/index.php?r=rOrder&id='+row.id+'\');">'+value+'</a>';
  549. }
  550. },
  551. {field: 'booking_time', title: '预约时间', width: 100,
  552. formatter: function(value, row) {
  553. var now = new Date(value * 1000);
  554. var month = now.getMonth() + 1;
  555. var date = now.getDate();
  556. var hour = now.getHours();
  557. return month+'月'+date+'日 '+hour + ':00';
  558. }
  559. },
  560. {field:'af_sum_price', title:'总额', width:40},
  561. {field:'sum_price', title:'折后', width:40},
  562. {field: 'status_str', title: '订单状态', width: 40},
  563. {field:'counts', title:'数量', width:20,sortable:false},
  564. {field:'score', title:'评价',width:20,
  565. formatter:function(value, row) {
  566. if (value == 100) {
  567. return '无';
  568. } else {
  569. return '<a href="javascript:;" onclick="parent.load_url(\'<?php echo Yii::app()->request->baseUrl; ?>/index.php?r=comment&id='+row.commentId+'\');">'+ value +'</a>';
  570. }
  571. }
  572. }
  573. ]]
  574. });
  575. jq_avatar.empty();
  576. if(data.avatar != '') {
  577. jq_avatar.append('<img src="' + data.avatar + '" width="64" height="64" />');
  578. } else {
  579. jq_avatar.html('无头像');
  580. }
  581. if (data['action_user'] != ''){
  582. jq_action_info.html('信息已被编辑: ' + data['action_user'] + ' ' + data['action_time']);
  583. } else {
  584. jq_action_info.html('');
  585. }
  586. },
  587. onLoadSuccess: function(){
  588. $(this).datagrid('clearChecked');
  589. jq_content_form.form('clear');
  590. jq_sendCoupon_form.form('clear');
  591. jq_sendBalance_form.form('clear');
  592. $('#register_time_str').html('');
  593. $('#coupon_copy_item').hide();
  594. $('#id_str').html('');
  595. $('#visit_str').html('');
  596. $('#channel').html('');
  597. $('#register_time').html('');
  598. $('#view_latitude').val('');
  599. $('#view_longitude').val('');
  600. $('#balance_user_id').val('');
  601. $('#balance_id_str').html('');
  602. $('#coupon_user_id').val('');
  603. $('#coupon_user_str').html('');
  604. $('#coupon_id').val('');
  605. $('#coupon_name').val('');
  606. jq_avatar.empty();
  607. jq_action_info.html('');
  608. $('#city_info_add').val('');
  609. }
  610. });
  611. jq_content_form.form({
  612. url: site_root + '/index.php?r=rUser/update',
  613. onSubmit: function(param){
  614. if ($('#user_id').val() <= 0){
  615. return false;
  616. }
  617. var isValid = $(this).form('validate');
  618. if (!isValid){
  619. $.messager.progress('close');
  620. }
  621. return isValid;
  622. },
  623. success: function(res){
  624. $.messager.progress('close');
  625. var res = JSON.parse(res);
  626. if (res.success){
  627. jq_dg_content.datagrid('clearSelections');
  628. jq_dg_content.datagrid('reload');
  629. $.messager.show({
  630. title: '提示',
  631. msg: '保存成功',
  632. timeout: 3500,
  633. showType: 'slide'
  634. });
  635. }else{
  636. $.messager.show({
  637. title: '提示',
  638. msg: res.message,
  639. timeout: 3500,
  640. showType: 'slide'
  641. });
  642. }
  643. }
  644. });
  645. //修改余额
  646. jq_sendBalance_form.form({
  647. url: site_root + '/index.php?r=rUser/changeBalance',
  648. onSubmit: function(param){
  649. if (!$('#balance_user_id').val()){
  650. return false;
  651. }
  652. var isValid = $(this).form('validate');
  653. if (!isValid){
  654. $.messager.progress('close');
  655. }
  656. return isValid;
  657. },
  658. success: function(res){
  659. $.messager.progress('close');
  660. var res = JSON.parse(res);
  661. console.log(res);
  662. if (res.success){
  663. $.messager.show({
  664. title: '提示',
  665. msg: '保存成功',
  666. timeout: 3500,
  667. showType: 'slide'
  668. });
  669. $('#user_balance').val('');
  670. $('#user_reason').val('');
  671. jq_dg_content.datagrid('clearSelections');
  672. jq_dg_content.datagrid('reload');
  673. }else{
  674. $.messager.show({
  675. title: '提示',
  676. msg: res.message,
  677. timeout: 3500,
  678. showType: 'slide'
  679. });
  680. }
  681. }
  682. });
  683. // 发送优惠券
  684. jq_sendCoupon_form.form({
  685. url: site_root + '/index.php?r=rUser/sendCoupon',
  686. onSubmit: function(param) {
  687. if (!$('#coupon_id').val()) {
  688. $.messager.progress('close');
  689. $.messager.alert('错误', '请选择优惠券');
  690. return false;
  691. }
  692. if (!$('#coupon_user_id').val()) {
  693. $.messager.progress('close');
  694. $.messager.alert('错误', '请选择用户');
  695. return false;
  696. }
  697. var isValid = $(this).form('validate');
  698. if (!isValid) {
  699. $.messager.progress('close');
  700. }
  701. return isValid;
  702. },
  703. success: function(res){
  704. $.messager.progress('close');
  705. var res = JSON.parse(res);
  706. if (res.success){
  707. $.messager.show({
  708. title: '提示',
  709. msg: '保存成功',
  710. timeout: 3500,
  711. showType: 'slide'
  712. });
  713. jq_dg_content.datagrid('clearSelections');
  714. jq_dg_content.datagrid('reload');
  715. }else{
  716. $.messager.show({
  717. title: '提示',
  718. msg: res.message,
  719. timeout: 3500,
  720. showType: 'slide'
  721. });
  722. }
  723. }
  724. });
  725. // 选择优惠券
  726. // $('#select_coupon').coolautosuggest({
  727. // url: 'index.php?r=coupon/selectCoupon&coupon=',
  728. // showDescription: true,
  729. // onSelected: function(result) {
  730. // $('#coupon_id').val(result.cid);
  731. // }
  732. // });
  733. $('#coupon_end_time').datebox({
  734. onSelect: function(date) {
  735. if ($('#coupon_copy').val() == '' && $('#coupon_id').val() != '') {
  736. getCoupon();
  737. }
  738. endtime = $(this).datebox('getValue') + '到期,请尽快使用噢!';
  739. if (price != '') {
  740. var copy = price + endtime;
  741. $('#coupon_copy').val(copy);
  742. }
  743. }
  744. });
  745. $('#coupon_id').keyup(function(event) {
  746. val = $(this).val();
  747. if (val.length == 24) {
  748. getCoupon();
  749. }
  750. });
  751. })
  752. function search_content(){
  753. var search = jq_ss.searchbox('getValue');
  754. jq_dg_content.datagrid({
  755. pageNum: 1,
  756. queryParams: {
  757. search: search,
  758. }
  759. });
  760. }
  761. function save_content(){
  762. var a_id = $('#user_id').val();
  763. if (!a_id){
  764. return false;
  765. }
  766. $.messager.progress();
  767. jq_content_form.submit();
  768. }
  769. //修改余额
  770. function saveBalance(){
  771. var a_id = $('#balance_user_id').val();
  772. if (!a_id){
  773. $.messager.alert('提示', "请先选择一个用户");
  774. return false;
  775. }
  776. $.messager.progress();
  777. jq_sendBalance_form.submit();
  778. }
  779. function add_content(){
  780. jq_add_dialog.dialog('open');
  781. }
  782. function formatCity(value){
  783. var _city = "";
  784. if(value.province){
  785. _city += value.province;
  786. }
  787. if(value.city){
  788. if(value.province){
  789. _city += ','+value.city;
  790. }else{
  791. _city += value.city;
  792. }
  793. }
  794. if(value.area){
  795. _city += ','+value.area;
  796. }
  797. return _city;
  798. }
  799. //密码复杂度验证
  800. //1、长度大于8
  801. //2、密码必须是字母大写,字母大、小写,数字,特殊字符中任意三个组合。
  802. function checkPass(pass){
  803. if(pass.length < 8){
  804. return 0;
  805. }
  806. var ls = 0;
  807. if(pass.match(/([a-z])+/)){
  808. ls++;
  809. }
  810. if(pass.match(/([0-9])+/)){
  811. ls++;
  812. }
  813. if(pass.match(/([A-Z])+/)){
  814. ls++;
  815. }
  816. if(pass.match(/[^a-zA-Z0-9]+/)){
  817. ls++;
  818. }
  819. return ls;
  820. }
  821. function sendCoupon() {
  822. $.messager.progress();
  823. jq_sendCoupon_form.submit();
  824. }
  825. function getCoupon() {
  826. $.post(
  827. '/index.php?r=coupon/getCouponInfo',
  828. {
  829. coupon_id : $('#coupon_id').val()
  830. },
  831. function (data) {
  832. couponInfo = $.parseJSON(data);
  833. console.log(couponInfo);
  834. if (!couponInfo.success) {
  835. $.messager.alert('错误', couponInfo.message);
  836. return false;
  837. }
  838. price = '恭喜你获得一张价值'+couponInfo.content['value']+'元的家政上门服务优惠券。';
  839. var copy = endtime == '' ? price : price + endtime;
  840. $('#coupon_copy').val(copy);
  841. }
  842. );
  843. }
  844. function needMessage() {
  845. if ($('#need_sms').is(':checked') || $('#need_zpush').is(':checked')) {
  846. if ($('#coupon_copy').val() == '' && $('#coupon_id').val() != '') {
  847. getCoupon();
  848. }
  849. $('#coupon_copy_item').show();
  850. } else {
  851. $('#coupon_copy_item').hide();
  852. }
  853. }
  854. function formatCity(value){
  855. var _city = "";
  856. if(value.province){
  857. _city += value.province;
  858. }
  859. if(value.city){
  860. _city += ','+value.city;
  861. }
  862. if(value.area){
  863. _city += ','+value.area;
  864. }
  865. return _city;
  866. }
  867. </script>