member.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. <?php
  2. use common\services\xhCouponService;
  3. use common\services\xhUserService;
  4. use common\services\xhUserAssetService;
  5. use common\components\stringUtil;
  6. ?>
  7. <?php
  8. use backend\widgets\TabWidget;
  9. echo TabWidget::widget(['list' => $this->context->menuList, 'currentMenu' => $this->context->id]);
  10. ?>
  11. <div class="panel panel-default">
  12. <?php
  13. use backend\widgets\SubTabWidget;
  14. echo SubTabWidget::widget(['list' => $this->context->subMenuList, 'currentMenu' => $this->context->action->id]);
  15. ?>
  16. <div class="panel-body">
  17. <div class="dataTables_wrapper form-inline dt-bootstrap no-footer">
  18. <div class="row">
  19. <form action="" method="GET">
  20. <div class="col-xs-6" style="width:90%;">
  21. <div class="dataTables_length">
  22. <label>昵称/手机号:<input type="search" value="<?php if (isset($_GET['content'])) {
  23. echo $_GET['content'];
  24. } ?>" class="form-control" name="content" placeholder=""></label>
  25. <input class="btn btn-secondary btn-single" type="submit" name="" value="搜索"/>
  26. </div>
  27. </div>
  28. </form>
  29. </div>
  30. <div class="table-responsive">
  31. <table class="table table-bordered table-striped table-hover table-condensed">
  32. <thead>
  33. <tr class="active">
  34. <th class="no-sorting hidden-xs"><input name="selectAll" type="checkbox"></th>
  35. <th class="hidden-xs">ID</th>
  36. <th class="hidden-xs">头像</th>
  37. <th>来源&nbsp;&nbsp;昵称</th>
  38. <th class="hidden-xs">手机号</th>
  39. <th class="hidden-xs">标签</th>
  40. <th class="hidden-xs">等级</th>
  41. <th class="hidden-xs">粉丝</th>
  42. <th class="hidden-xs">余额</th>
  43. <th class="hidden-xs">积分</th>
  44. <th>操作</th>
  45. </tr>
  46. </thead>
  47. <tbody class="middle-align">
  48. <?php foreach ($models as $key => $val) { ?>
  49. <tr>
  50. <td class="hidden-xs"><input name="uId" value="<?= $val['id'] ?>" type="checkbox"></td>
  51. <td class="hidden-xs"><?= $val['id'] ?></td>
  52. <td class="hidden-xs">
  53. <a href="/user/detail?id=<?= $val['id'] ?>" title="<?= $val['userName'] ?>">
  54. <img src="<?php if (!empty($val['avatar'])) {
  55. $avatar = xhUserService::getAvatarList($val['avatar']);
  56. echo Yii::$app->params['imgUrl'] . $avatar['small'];
  57. } else {
  58. echo Yii::$app->params['imgUrl'] .'/unknowavatar.png';
  59. } ?>"
  60. style="width:20px;border-radius:10px;"/>
  61. </a>
  62. </td>
  63. <td>
  64. <?php $rand = rand(0,2);if($rand == 0){ ?>
  65. <img src="/images/source_wx.jpg" width="15" />&nbsp;&nbsp;
  66. <?php } if($rand == 1){ ?>
  67. <img src="/images/source_xcx.jpg" width="15" />&nbsp;&nbsp;
  68. <?php } if($rand == 2){ ?>
  69. <img src="/images/source_zfb.jpg" width="15" />&nbsp;&nbsp;
  70. <?php } ?>
  71. <a class="add-under-line" href="/user/detail?id=<?= $val['id'] ?>"
  72. title="<?= $val['userName'] ?>"><?php echo stringUtil::subStringUtf8($val['userName'], 10, '..'); ?></a>
  73. </td>
  74. <td class="hidden-xs">
  75. <?= $val['mobile'] ?>
  76. </td>
  77. <td class="hidden-xs">
  78. <?php
  79. $cacheTag = isset($val['tag']) ? $val['tag'] : '';
  80. if (!empty($cacheTag)) {
  81. $cacheTagList = explode(',', $cacheTag);
  82. foreach ($cacheTagList as $cacheKey => $cacheVal) {
  83. if (isset($merchantTag[$cacheVal])) {
  84. echo '<a href="javascript:void(0)" title="' . $merchantTag[$cacheVal] . '">' . stringUtil::subStringUtf8($merchantTag[$cacheVal], 3, '…') . '</a><br />';
  85. }
  86. }
  87. }
  88. $userAsset = xhUserAssetService::getByUserId($val['id']);
  89. $coupon = xhCouponService::getUserCoupon($val['id']);
  90. $couponJson = json_encode($coupon);
  91. ?>
  92. </td>
  93. <td class="hidden-xs">
  94. <?php if (!empty($userAsset['memberLevel'])) { ?>
  95. <?php if (empty($val['subscribe'])) { ?>
  96. <a href="javascript:void(0)" data-toggle="tooltip" data-placement="bottom"
  97. title="" data-original-title="客户需关注公众号并申请会员卡,才能查看等级"
  98. style="color:#68b828;cursor:pointer;text-decoration:none;"
  99. <i="" class="fa-question-circle"></a>
  100. <?php } else { ?>
  101. <?php if (empty($val['mobile'])) { ?>
  102. <a href="javascript:void(0)" data-toggle="tooltip" data-placement="bottom"
  103. title="" data-original-title="客户需申请会员卡才能查看等级"
  104. style="color:#68b828;cursor:pointer;text-decoration:none;"
  105. <i="" class="fa-question-circle"></a>
  106. <?php } else { ?>
  107. <?php
  108. $level = $userAsset['memberLevel'];
  109. $discount = $memberIntegral[$level]['discount'];
  110. echo $userAsset['memberLevel'] . '/' . $discount . '折';
  111. ?>
  112. <?php } ?>
  113. <?php } ?>
  114. <?php } ?>
  115. </td>
  116. <td class="hidden-xs"><?php if ($val['subscribe'] == 1) echo '<a href="javascript:void(0)" style="color:#68b828;cursor:text" <i class="fa fa-check"></i></a>'; ?></td>
  117. <td class="hidden-xs"><?php if (!empty($userAsset['balance']) && $userAsset['balance'] != 0.00) { ?>
  118. <a
  119. style="background-color: #68b828;color:white;padding:2px;border-radius:5px;text-decoration:none;color:#ffffff;"
  120. href="/capital/user?id=<?= $val['id'] ?>"><?= $userAsset['balance'] ?></a><?php } ?>
  121. </td>
  122. <td class="hidden-xs">
  123. <?php if (!empty($userAsset['integral'])) { ?>
  124. <?php if (empty($val['subscribe'])) { ?>
  125. <a href="javascript:void(0)" data-toggle="tooltip" data-placement="bottom"
  126. title="" data-original-title="客户需关注公众号并申请会员卡,才能查看积分"
  127. style="color:#68b828;cursor:pointer;text-decoration:none;"
  128. <i="" class="fa-question-circle"></a>
  129. <?php } else { ?>
  130. <?php if (empty($val['mobile'])) { ?>
  131. <a href="javascript:void(0)" data-toggle="tooltip" data-placement="bottom"
  132. title="" data-original-title="客户需申请会员卡才能查看积分"
  133. style="color:#68b828;cursor:pointer;text-decoration:none;"
  134. <i="" class="fa-question-circle"></a>
  135. <?php } else { ?>
  136. <a style="background-color: #68b828;color:white;padding:2px;border-radius:5px;text-decoration:none;color:#ffffff;"
  137. href="/integral/user?id=<?= $val['id'] ?>"><?= $userAsset['integral'] ?></a>
  138. <?php } ?>
  139. <?php } ?>
  140. <?php } ?>
  141. </td>
  142. <td>
  143. <?php if ($val['subscribe'] == 1) { ?>
  144. <?php if (!empty($merchantExtend['recharge'])) { ?>
  145. <?php } ?>
  146. <?php if (!empty($merchantExtend['init'])) { ?>
  147. <?php } ?>
  148. <?php } ?>
  149. </td>
  150. </tr>
  151. <?php } ?>
  152. </tbody>
  153. </table>
  154. </div>
  155. <div class="row">
  156. <div>
  157. <div class="dataTables_paginate paging_simple_numbers"
  158. style="float:right;padding-top:0px;margin-right:15px;">
  159. <?= $pages ?>
  160. </div>
  161. </div>
  162. </div>
  163. </div>
  164. </div>
  165. </div>
  166. <!-- footer -->
  167. <?php
  168. use backend\widgets\FooterWidget;
  169. ?>
  170. <?= FooterWidget::widget() ?>
  171. <!-- footer -->
  172. <!-- modal 升级会员确认提醒框 -->
  173. <div class="modal fade" id="memberModal">
  174. <div class="modal-dialog" style="height:300px;">
  175. <div class="modal-content">
  176. <div class="modal-header">
  177. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  178. <h4 class="modal-title">消息提示</h4>
  179. </div>
  180. <div class="modal-body">
  181. <div class="row">
  182. <div class="col-md-6">
  183. <div class="form-group">
  184. <label for="field-1" class="control-label">确认将 <span></span>会员等级设置为</label>
  185. <select class="form-control" name="memberLevel">
  186. <?php foreach ($memberIntegral as $key => $val) { ?>
  187. <?php echo '<option value="' . $val['level'] . '">' . $val['level'] . '级 ' . $val['discount'] . '折</option>'; ?>
  188. <?php } ?>
  189. </select>
  190. </div>
  191. </div>
  192. </div>
  193. <input type="hidden" name="requestUrl" value=""/>
  194. <div class="row">
  195. <div class="col-md-6">
  196. <div class="form-group">
  197. <label for="field-1" class="control-label">请输入确认密码:</label>
  198. <input type="password" class="form-control" name="confirmPassword" placeholder="" value="">
  199. </div>
  200. </div>
  201. </div>
  202. </div>
  203. <div class="modal-footer">
  204. <button type="button" class="btn btn-info" name="memberConfirmButton">确认</button>
  205. <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
  206. </div>
  207. </div>
  208. </div>
  209. </div>
  210. <script>
  211. $(function () {
  212. //升级为会员 取消会员操作
  213. jQuery("a[name=memberButton]").click(function () {
  214. var url = $(this).attr('data-url');
  215. var name = $(this).attr('data-name');
  216. $("#memberModal .modal-body span").text(name);
  217. $("#memberModal .modal-body input[name=requestUrl]").val(url);
  218. jQuery('#memberModal').modal('show', {backdrop: 'fade'});
  219. });
  220. //确认升级会员
  221. jQuery("button[name=memberConfirmButton]").click(function () {
  222. var url = $("#memberModal .modal-body input[name=requestUrl]").val();
  223. var confirmPassword = $("#memberModal .modal-body input[name=confirmPassword]").val();
  224. var memberLevel = $("select[name=memberLevel]").find("option:selected").val();
  225. $.ajax({
  226. type: "GET",
  227. url: url + "&confirmPassword=" + confirmPassword + "&memberLevel=" + memberLevel,
  228. async: false,
  229. dataType: 'json',
  230. success: function (data) {
  231. if (data.code == 'A0001') {
  232. setTimeout(function () {
  233. window.location.reload();
  234. }, 2000);
  235. }
  236. xhPopMsg(data.msg, 2000);
  237. }
  238. });
  239. });
  240. });
  241. </script>
  242. <!-- modal 充值 -->
  243. <div class="modal fade" id="rechargeModal">
  244. <div class="modal-dialog" style="height:450px;">
  245. <div class="modal-content">
  246. <div class="modal-header">
  247. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  248. <h4 class="modal-title">操作提示</h4>
  249. </div>
  250. <div class="modal-body">
  251. <div class="row">
  252. <div class="col-md-6">
  253. <div class="form-group">
  254. <label for="field-1" class="control-label"><span></span> 帐户充值:</label>
  255. <input type="tel" class="form-control" placeholder="" name="rechargeAmount" value=""
  256. style="width:70%;display:inline-block;"> 元
  257. <input type="hidden" name="requestUrl" value=""/>
  258. <input type="hidden" name="userName" value=""/>
  259. </div>
  260. </div>
  261. </div>
  262. <div class="row">
  263. <div class="col-md-6">
  264. <div class="form-group">
  265. <label for="field-1" class="control-label">请输入确认密码:</label>
  266. <input type="password" class="form-control" name="rechargePassword" placeholder="" value="">
  267. </div>
  268. </div>
  269. </div>
  270. <div class="row">
  271. <div class="col-md-6">
  272. <div class="checkbox">
  273. <label>
  274. <input name="confirmToRecharge" type="checkbox">确认为<span></span>充值 <em
  275. style="font-style: normal;">0</em> 元
  276. </label>
  277. </div>
  278. </div>
  279. </div>
  280. </div>
  281. <div class="modal-footer">
  282. <button type="button" class="btn btn-info" name="rechargeConfirmButton">确认</button>
  283. <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
  284. </div>
  285. </div>
  286. </div>
  287. </div>
  288. <script>
  289. $(function () {
  290. //充值操作
  291. jQuery("a[name=rechargeButton]").click(function () {
  292. var url = $(this).attr('data-url');
  293. var userName = $(this).attr('data-userName');
  294. $("#rechargeModal .modal-body span").text(userName);
  295. $("#rechargeModal .modal-body input[name=userName]").val(userName);
  296. $("#rechargeModal .modal-body input[name=requestUrl]").val(url);
  297. $("#rechargeModal .modal-body input[name=rechargeAmount]").val('');
  298. $("#rechargeModal .modal-body input[name=rechargePassword]").val('');
  299. $("#rechargeModal .modal-body em").html('0');
  300. $("input[name=confirmToRecharge]").prop("checked", false);
  301. jQuery('#rechargeModal').modal('show');
  302. });
  303. //确认充值
  304. jQuery("button[name=rechargeConfirmButton]").click(function () {
  305. var url = $("#rechargeModal .modal-body input[name=requestUrl]").val();
  306. var userName = $("#rechargeModal .modal-body input[name=userName]").val();
  307. var rechargeAmount = $("#rechargeModal .modal-body input[name=rechargeAmount]").val();
  308. var rechargePassword = $("#rechargeModal .modal-body input[name=rechargePassword]").val();
  309. if (isNaN(rechargeAmount)) {
  310. xhPopMsg('充值金额填写有误', 1300);
  311. return;
  312. }
  313. if (rechargeAmount <= 0) {
  314. xhPopMsg('金额不能小于0', 1300);
  315. return;
  316. }
  317. if (rechargePassword.length <= 0) {
  318. xhPopMsg('请输入确认密码', 1300);
  319. return;
  320. }
  321. if ($("input[name=confirmToRecharge]").prop("checked") == false) {
  322. xhPopMsg('请勾选确认充值项', 1300);
  323. return;
  324. }
  325. if ($("button[name=rechargeConfirmButton]").attr('submitStatus') == 'yes') {
  326. xhPopMsg('请稍候…', 1000);
  327. return;
  328. }
  329. $("button[name=rechargeConfirmButton]").attr('submitStatus', 'yes');
  330. setTimeout(function () {
  331. $("button[name=rechargeConfirmButton]").attr('submitStatus', 'no');
  332. }, 8000);
  333. $.ajax({
  334. type: "GET",
  335. url: url + '&rechargeAmount=' + rechargeAmount + '&rechargePassword=' + rechargePassword,
  336. async: false,
  337. dataType: 'json',
  338. success: function (data) {
  339. if (data.code == 'A0001') {
  340. setTimeout(function () {
  341. window.location.reload();
  342. }, 2000);
  343. }
  344. xhPopMsg(data.msg, 1300);
  345. }
  346. });
  347. });
  348. //充值时输入金额反应
  349. $("#rechargeModal .modal-body input[name=rechargeAmount]").keyup(function () {
  350. var val = $(this).val();
  351. if (isNaN(val) == false) {
  352. $("#rechargeModal .modal-body em").html(val);
  353. }
  354. });
  355. });
  356. </script>
  357. <script>
  358. //全选 全不选
  359. $(":checkbox[name=selectAll]").click(function () {
  360. var status = $(this).prop("checked");
  361. if (status == true) {
  362. $(":checkbox[name=uId]").prop("checked", true);
  363. } else {
  364. $(":checkbox[name=uId]").prop("checked", false);
  365. }
  366. });
  367. </script>
  368. <!-- 添加标签 -->
  369. <div class="modal fade" id="userTagModal">
  370. <div class="modal-dialog" style="height:450px;">
  371. <div class="modal-content">
  372. <div class="modal-header">
  373. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  374. <h4 class="modal-title">请选择你要添加的标签</h4>
  375. </div>
  376. <div class="modal-body">
  377. <input type="hidden" name="requestUrl" value="/user/batch-add-user-tag"/>
  378. <?php if (!empty($merchantTag)) { ?>
  379. <?php foreach ($merchantTag as $key => $val) { ?>
  380. <div class="row">
  381. <div class="col-md-6">
  382. <div class="checkbox">
  383. <label>
  384. <input name="theTag" value="<?= $key ?>" type="radio"> <?= $val ?>
  385. </label>
  386. </div>
  387. </div>
  388. </div>
  389. <?php }
  390. } ?>
  391. </div>
  392. <div class="modal-footer">
  393. <button type="button" class="btn btn-info" name="userTagConfirmButton">确认</button>
  394. <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
  395. </div>
  396. </div>
  397. </div>
  398. </div>
  399. <script>
  400. var shopProvince = "<?=$merchant['shopProvince'] ?>";
  401. var shopCity = "<?=$merchant['shopCity'] ?>";
  402. $("button[name=multipConfirm]").click(function () {
  403. var ids = new Array();
  404. $(":checkbox[name=uId]:checked").each(function () {
  405. var theId = $(this).val();
  406. ids.push(theId);
  407. });
  408. if (ids.length <= 0) {
  409. xhPopMsg('请选择你要操作的用户', 1300);
  410. return;
  411. }
  412. var option = $("select[name=doOption]").val();
  413. option = parseInt(option);
  414. switch (option) {
  415. case 0:
  416. //批量添加标签
  417. jQuery('#userTagModal').modal('show');
  418. break;
  419. case 1:
  420. xhPopMsg('此功能开发中…', 1300);
  421. break;
  422. }
  423. });
  424. //确认添加标签
  425. jQuery("button[name=userTagConfirmButton]").click(function () {
  426. var tagId = $("#userTagModal .modal-body :input[name=theTag]:checked").val();
  427. var url = $("#userTagModal .modal-body input[name=requestUrl]").val();
  428. var ids = new Array();
  429. $(":checkbox[name=uId]:checked").each(function () {
  430. var theId = $(this).val();
  431. ids.push(theId);
  432. });
  433. if (ids.length <= 0) {
  434. xhPopMsg('请选择用户', 1300);
  435. return;
  436. }
  437. var userIdStr = ids.join(',');
  438. $.ajax({
  439. type: "GET",
  440. url: url + '?tagId=' + tagId + '&userIdStr=' + userIdStr,
  441. async: false,
  442. dataType: 'json',
  443. success: function (data) {
  444. xhPopMsg(data.msg, 1300);
  445. if (data.code == 'A0001') {
  446. setTimeout(function () {
  447. window.location.reload();
  448. }, 1000);
  449. }
  450. }
  451. });
  452. });
  453. </script>