my-customer.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. ComponentHelper::loadComponentView('com-export-window');
  4. ?>
  5. <style>
  6. .default-avatar{
  7. width: 50px;
  8. height: 50px;
  9. border-radius: 50%;
  10. float: left;
  11. margin-right: 8px;
  12. }
  13. </style>
  14. <div id="my_customer" v-cloak>
  15. <div class="user_info">
  16. <div class="user_detail" v-if="userInfo">
  17. <el-image style="height:50px;width:50px;border-radius: 50%;margin-right: 20px;" :src="userInfo.avatar_url? userInfo.avatar_url:'/resources/img/common/default-avatar.png'" lazy></el-image>
  18. <div>
  19. <div class="user_name">
  20. {{userInfo.nickname}}
  21. </div>
  22. <div class="info">
  23. <div>
  24. <span>手机号:</span>
  25. <span class="text">{{userInfo.mobile || '无'}}</span>
  26. </div>
  27. <div>
  28. <span>注册时间:</span>
  29. <span class="text">{{ userInfo.created_at }}</span>
  30. </div>
  31. <div>
  32. <span>推荐人:</span>
  33. <span class="text">{{ userInfo.parent_id == 0 ? '平台' : userInfo.p_nickname }}</span>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. <div class="user_total">
  39. <div class="module" >
  40. <div>团队人数</div>
  41. <div class="module_value">{{userInfo.team_num ? userInfo.team_num : 0}}</div>
  42. </div>
  43. <div class="module" >
  44. <div>团队购买数量</div>
  45. <div class="module_value">{{userInfo.pay_goods_num ? userInfo.pay_goods_num : 0}}</div>
  46. </div>
  47. <div class="module" >
  48. <div>好友人数</div>
  49. <div class="module_value">{{userInfo.first_num ? userInfo.first_num : 0}}</div>
  50. </div>
  51. <div class="module" >
  52. <div>粉丝人数</div>
  53. <div class="module_value">{{userInfo.second_num ? userInfo.second_num : 0}}</div>
  54. </div>
  55. <div class="module" >
  56. <div>累计消费金额</div>
  57. <div class="module_value">{{userInfo.pay_money ? userInfo.pay_money : 0.00}}</div>
  58. </div>
  59. <div class="module" >
  60. <div>累计收益</div>
  61. <div class="module_value">{{userInfo.commission ? userInfo.commission : 0.00}}</div>
  62. </div>
  63. <div class="module" >
  64. <div>待结算</div>
  65. <div class="module_value">{{userInfo.not_income ? userInfo.not_income : 0.00}}</div>
  66. </div>
  67. </div>
  68. </div>
  69. <el-card class="box-card">
  70. <template>
  71. <el-tabs v-model="activeName" @tab-click="handleClick">
  72. <el-tab-pane label="直推客户" name="1"></el-tab-pane>
  73. <el-tab-pane label="间推客户" name="2"></el-tab-pane>
  74. <el-tab-pane label="我的团队" name="3"></el-tab-pane>
  75. <el-tab-pane label="推荐人" name="4"></el-tab-pane>
  76. <el-tab-pane label="我的收益" name="5"></el-tab-pane>
  77. </el-tabs>
  78. </template>
  79. <div class="tab_search" v-if="activeName=='1' || activeName=='2' || activeName=='3' || activeName=='4'" >
  80. <div class="search_form">
  81. <el-select style="width: 150px;margin-right: 10px;" v-model="search_type" @change="selectKeyword" placeholder="请选择搜索类型">
  82. <el-option label="会员ID" value="1"></el-option>
  83. <el-option label="会员名称" value="2"></el-option>
  84. <el-option label="手机号码" value="3"></el-option>
  85. <el-option label="会员等级" value="4"></el-option>
  86. </el-select>
  87. <el-select style="margin-right: 10px; width: 300px; " v-model="keyword" v-if="search_type == 4" clearable>
  88. <el-option v-for="(item, index) in levelList"
  89. :key="item.level"
  90. :label="item.name"
  91. :value="item.level"
  92. ></el-option>
  93. </el-select>
  94. <el-input style="margin-right: 10px; width: 300px; " v-model="keyword" v-else></el-input>
  95. <el-button type="primary" @click="searchInfo">搜索</el-button>
  96. <el-button type="primary" v-if="activeName=='3'" @click="dialogVisible = true">导出</el-button>
  97. </div>
  98. </div>
  99. <div class="tab_search" v-if="activeName=='5'" >
  100. <div class="search_form">
  101. <el-select style="width: 200px;margin-right: 10px;" v-model="from_type" @change="selectFromType" placeholder="请选择搜索类型">
  102. <el-option label="佣金类型" value=""></el-option>
  103. <el-option :label="item" :value="index" v-for="(item, index) in capitalList" :key="index"></el-option>
  104. </el-select>
  105. <el-button type="primary" @click="searchInfo">搜索</el-button>
  106. </div>
  107. </div>
  108. </el-card>
  109. <el-table :data="userList" stripe style="width: 100%" v-loading="listLoading" v-if="is_team">
  110. <el-table-column prop="id" label="会员ID" min-width="100" align="center"></el-table-column>
  111. <el-table-column key='3' label="会员名称" width="240" >
  112. <template slot-scope="scope">
  113. <div class="table-info-img-text">
  114. <el-image class="table-info-img circle" :src="scope.row.avatar_url">
  115. <div slot="error" class="image-slot">
  116. <com-image src="/resources/img/common/default-avatar.png"></com-image>
  117. </div>
  118. </el-image>
  119. <div class="table-info-text">
  120. <div>{{scope.row.nickname}}</div>
  121. <div>{{scope.row.mobile}}</div>
  122. </div>
  123. </div>
  124. </template>
  125. </el-table-column>
  126. <el-table-column label="会员等级" align="center">
  127. <template slot-scope="scope">
  128. {{ scope.row.level_text }}
  129. </template>
  130. </el-table-column>
  131. <el-table-column label="推荐人" width="240" v-if="activeName == '3' || activeName == '2'">
  132. <template slot-scope="scope">
  133. <div class="table-info-img-text">
  134. <el-image class="table-info-img circle" :src="scope.row.p_avatar_url">
  135. <div slot="error" class="image-slot">
  136. <com-image src="/resources/img/common/default-avatar.png"></com-image>
  137. </div>
  138. </el-image>
  139. <div class="table-info-text">
  140. <div>{{scope.row.p_nickname}}</div>
  141. <div>ID:{{scope.row.p_id}}</div>
  142. </div>
  143. </div>
  144. </template>
  145. </el-table-column>
  146. <el-table-column v-if="activeName != '4'" label="绑定时间" min-width="100" align="center">
  147. <template slot-scope="scope">
  148. <div>{{scope.row.bind_time | dateTimeFormat("Y-m-d H:i:s")}}</div>
  149. </template>
  150. </el-table-column>
  151. <el-table-column prop="pay_money" label="成交金额" min-width="100" align="center">
  152. <template slot-scope="scope">
  153. {{scope.row.pay_money}}
  154. </template>
  155. </el-table-column>
  156. <el-table-column prop="pay_num" label="成交订单数" min-width="100" align="center">
  157. <template slot-scope="scope">
  158. {{scope.row.pay_num}}
  159. </template>
  160. </el-table-column>
  161. <el-table-column prop="pay_goods_num" label="购买数量" min-width="100" align="center">
  162. <template slot-scope="scope">
  163. {{scope.row.pay_goods_num}}
  164. </template>
  165. </el-table-column>
  166. <el-table-column label="操作" min-width="100" v-if="is_team">
  167. <template v-if="is_team" slot-scope="scope">
  168. <el-button type="text" size="small" @click="$navigate({
  169. r: 'team-data/default/order',
  170. user_id: scope.row.id
  171. })">订单数据</el-button>
  172. <el-button type="text" size="small" @click="gotoUserDetail(scope.row.id)">详情</el-button>
  173. <el-button type="text" size="small" @click="gotoBy(scope.row.id)">我的客户</el-button>
  174. </template>
  175. </el-table-column>
  176. </el-table>
  177. <el-table :data="commissionList" stripe style="width: 100%" v-loading="listLoading" v-if="is_commission">
  178. <el-table-column prop="id" label="编号" min-width="100" align="center"></el-table-column>
  179. <el-table-column prop="change_num" label="变动金额" min-width="100" align="center">
  180. <template slot-scope="scope">
  181. <div style="font-size: 18px;" :style="{color: scope.row.change_type == 'add' ? '#68CF3D' : scope.row.change_type == 'sub' ? '#F6AA5A' : ''}">
  182. {{scope.row.change_type == 'add' ? '+' : scope.row.change_type == 'sub' ? '-' : ''}}
  183. {{scope.row.change_num}}
  184. </div>
  185. </template>
  186. </el-table-column>
  187. <el-table-column prop="current_num" label="佣金类型" min-width="200" align="center">
  188. <template slot-scope="scope">
  189. {{capitalList[scope.row.capital_type] ? capitalList[scope.row.capital_type] : ''}}
  190. </template>
  191. </el-table-column>
  192. <el-table-column prop="current_num" label="变动前金额" min-width="200" align="center">
  193. <template slot-scope="scope">
  194. {{scope.row.current_num}}
  195. </template>
  196. </el-table-column>
  197. <el-table-column prop="current_num" label="变动后金额" min-width="150" align="center">
  198. <template slot-scope="scope">
  199. <!-- <div v-if="scope.row.change_type == 'add'">{{scope.row.current_num + scope.row.change_num}}</div> -->
  200. <!-- <div v-if="scope.row.change_type == 'sub'">{{scope.row.current_num - scope.row.change_num}}</div> -->
  201. <div v-if="scope.row.change_type == 'add'">{{formatData(scope.row.current_num,scope.row.change_num,'add')}}</div>
  202. <div v-if="scope.row.change_type == 'sub'">{{formatData(scope.row.current_num,scope.row.change_num,'sub')}}</div>
  203. </template>
  204. </el-table-column>
  205. <el-table-column prop="desc" label="备注" min-width="100" align="center">
  206. <template slot-scope="scope">
  207. {{scope.row.desc}}
  208. </template>
  209. </el-table-column>
  210. <el-table-column prop="created_at" label="时间" min-width="100" align="center">
  211. <template slot-scope="scope">
  212. {{scope.row.created_at| dateTimeFormat("Y-m-d H:i:s")}}
  213. </template>
  214. </el-table-column>
  215. </el-table>
  216. <div style="text-align: right;margin: 20px 0;">
  217. <el-pagination
  218. @current-change="pagination"
  219. background layout="prev, pager, next"
  220. :page-count="pageCount"
  221. :current-page="currentPage"
  222. ></el-pagination>
  223. </div>
  224. <!-- 导出窗口 -->
  225. <com-export-window
  226. :default-check="true"
  227. :visible="dialogVisible"
  228. :export-list="exportList"
  229. export-key="value"
  230. export-value="title"
  231. @closed="dialogVisible = false"
  232. action-url="team-data/default/export"
  233. :params="{
  234. user_id: userInfo.id,
  235. status: activeName,
  236. keyword: keyword,
  237. search_type: search_type
  238. }"
  239. ></com-export-window>
  240. </div>
  241. <script>
  242. // getQuery('order_id'),
  243. const app = new Vue({
  244. el: '#my_customer',
  245. data() {
  246. return {
  247. userInfo: <?= $user_info?>,
  248. activeName: '1',
  249. tabArr: [],
  250. userList: [],
  251. commissionList: [],
  252. capitalList: [],
  253. listLoading: false,
  254. isType: -1,
  255. keyword: '',
  256. search_type: '',
  257. pageCount: 1,
  258. currentPage: 1,
  259. page: 1,
  260. id: '',
  261. from_type:'',
  262. is_team: true,
  263. is_commission: false,
  264. exportList: [],
  265. dialogVisible: false,
  266. levelList: [],
  267. }
  268. },
  269. mounted(){
  270. this.user_id = getQuery('user_id');
  271. console.info(getQuery('user_id'));
  272. /* this.$navigate({
  273. // r: this.getOrderListUrl,
  274. r: 'mall/order/index',
  275. }) */
  276. this.getList();
  277. this.getLevel()
  278. },
  279. methods: {
  280. getList(){
  281. this.listLoading = true;
  282. this.is_team = true;
  283. this.is_commission = false;
  284. request({
  285. params: {
  286. r: 'team-data/default/my-customer',
  287. user_id: this.userInfo.id,
  288. status: this.activeName,
  289. keyword: this.keyword,
  290. search_type: this.search_type,
  291. page: this.page
  292. },
  293. method: 'get',
  294. }).then(res => {
  295. this.listLoading = false;
  296. if(res.data.code == 0){
  297. this.userList = res.data.data.list;
  298. this.pageCount = res.data.data.page_count;
  299. this.exportList = res.data.data.export
  300. console.log(this.userList);
  301. }else {
  302. this.listLoading = false;
  303. this.$message.error(e.data.msg);
  304. }
  305. }).catch(err => {
  306. this.$message.error(err.data.msg);
  307. })
  308. },
  309. getLevel() {
  310. request({
  311. params: {
  312. r: 'mall/user-level/list'
  313. },
  314. method: 'get',
  315. }).then(e => {
  316. if (e.data.code == 0) {
  317. this.levelList = e.data.data
  318. }
  319. })
  320. },
  321. handleClick(tab, event){
  322. this.commissionList = [];
  323. this.userList = [];
  324. this.pageCount = 1;
  325. this.page = 1;
  326. this.from_type = '';
  327. if (tab.name == 5) {
  328. this.listLoading = true;
  329. this.is_commission = true;
  330. this.is_team = false;
  331. this.getCommission();
  332. } else {
  333. this.activeName = tab.name;
  334. this.keyword = '';
  335. this.search_type = '';
  336. this.getList();
  337. }
  338. },
  339. getCommission() {
  340. this.listLoading = true;
  341. this.is_commission = true;
  342. this.is_team = false;
  343. request({
  344. params: {
  345. r: 'team-data/default/my-commission',
  346. user_id: this.userInfo.id,
  347. id: this.id,
  348. capital_type: this.from_type,
  349. page: this.page
  350. },
  351. method: 'get',
  352. }).then(res => {
  353. this.listLoading = false;
  354. if(res.data.code == 0){
  355. this.commissionList = res.data.data.list;
  356. this.capitalList = res.data.data.capital_type;
  357. this.pageCount = res.data.data.page_count;
  358. }else {
  359. this.listLoading = false;
  360. this.$message.error(e.data.msg);
  361. }
  362. }).catch(err => {
  363. this.listLoading = false;
  364. this.$message.error(err.data.msg);
  365. })
  366. },
  367. selectKeyword(select){
  368. this.search_type = select;
  369. this.keyword = undefined
  370. },
  371. searchInfo(){
  372. if ((this.search_type=='' || this.keyword === undefined || this.keyword==='') && this.from_type=='') {
  373. this.$message.error('请选择搜索项');
  374. return false;
  375. }
  376. this.commissionList = [];
  377. this.userList = [];
  378. this.pageCount = 1;
  379. this.page = 1;
  380. if (this.activeName == 5) {
  381. this.getCommission();
  382. } else {
  383. this.getList();
  384. }
  385. },
  386. pagination(currentPage){
  387. this.page = currentPage;
  388. if (this.activeName == 5) {
  389. this.getCommission()
  390. } else {
  391. this.getList();
  392. }
  393. },
  394. selectFromType(from_type) {
  395. this.capital_type = from_type;
  396. },
  397. gotoUserDetail(id){
  398. this.$navigate({
  399. r: 'mall/user/user-detail',
  400. id: id
  401. })
  402. },
  403. gotoBy(id){
  404. this.$navigate({
  405. r: 'team-data/default/my-customer',
  406. user_id: id
  407. })
  408. },
  409. formatData(arg1,arg2,change_type){
  410. switch (change_type){
  411. case 'add':
  412. return (arg1+arg2).toFixed(2);
  413. case 'sub':
  414. return (arg1-arg2).toFixed(2);
  415. default:
  416. return 0;
  417. }
  418. },
  419. }
  420. })
  421. </script>
  422. <style>
  423. .user_info{
  424. background: #FFF;
  425. padding: 20px;
  426. margin-bottom: 10px;
  427. }
  428. .user_detail{
  429. display: flex;
  430. align-items: center;
  431. margin-bottom: 40px;
  432. }
  433. .user_detail .info{
  434. display: flex;
  435. font-size: 12px;
  436. color: #939393;
  437. }
  438. .user_detail .info .text{
  439. color: #000;
  440. margin-right: 40px;
  441. }
  442. .user_detail .user_name{
  443. font-size: 15px;
  444. margin-bottom: 10px;
  445. }
  446. .user_total{
  447. background: #F2F2F2;
  448. display: flex;
  449. padding: 20px 30px;
  450. }
  451. .user_total .module{
  452. flex: 1;
  453. color: #919191;
  454. }
  455. .module_value{
  456. font-size: 25px;
  457. color: #000;
  458. margin-top: 8px;
  459. }
  460. .tab_module{
  461. background: #FFF;
  462. padding: 10px 20px;
  463. }
  464. .tab_search{
  465. display: flex;
  466. }
  467. .search_but{
  468. display: flex;
  469. flex: 1;
  470. color: #797979;
  471. align-items: center;
  472. }
  473. .search_but div{
  474. border: 1px solid #E6E6E6;
  475. padding: 5px 20px;
  476. margin-right: 30px;
  477. border-radius: 30px;
  478. height: 30px;
  479. }
  480. .search_but div:hover{
  481. cursor:pointer
  482. }
  483. .search_but_sel{
  484. color: #FFF;
  485. background: #2E8FF4;
  486. }
  487. .search_form{
  488. display:flex;
  489. }
  490. </style>