index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. <template>
  2. <view :style="colorStyle">
  3. <view class="promoter-list">
  4. <view class="promoterHeader bg-color">
  5. <view class="headerCon acea-row row-between-wrapper">
  6. <view>
  7. <view class="name">
  8. {{ $t(`员工人数`) }}
  9. <view class="invitation" @click="showCode">{{ $t(`邀请`) }}</view>
  10. </view>
  11. <view>
  12. <text class="num">{{ teamCount }}</text>
  13. {{ $t(`人`) }}
  14. </view>
  15. </view>
  16. <view class="iconfont icon-tuandui"></view>
  17. </view>
  18. </view>
  19. <!-- <view class='search acea-row row-between-wrapper'>
  20. <view class='input'><input placeholder='点击搜索会员名称' placeholder-class='placeholder' v-model="keyword"
  21. @confirm="submitForm" confirm-type='search' name="search"></input></view>
  22. <button class='iconfont icon-sousuo2' @click="submitForm"></button>
  23. </view> -->
  24. <view class="list">
  25. <block v-for="(item, index) in recordList" :key="index">
  26. <view class="item acea-row row-between-wrapper">
  27. <view class="picTxt acea-row row-between-wrapper">
  28. <view class="pictrue">
  29. <image :src="item.avatar"></image>
  30. </view>
  31. <view class="text">
  32. <view class="name line1">{{ item.nickname }}</view>
  33. <view>{{ $t(`加入时间`) }}: {{ item.division_change_time }}</view>
  34. <view>{{ $t(`分佣比例`) }}: {{ item.division_percent }}%</view>
  35. </view>
  36. </view>
  37. <view class="right">
  38. <view>
  39. <text class="num font-color">{{ item.childCount ? item.childCount : 0 }}</text>
  40. {{ $t(`人`) }}
  41. </view>
  42. <view>
  43. <text class="num">{{ item.orderCount ? item.orderCount : 0 }}</text>
  44. {{ $t(`单`) }}
  45. </view>
  46. <view>
  47. <text class="num">{{ item.numberCount ? item.numberCount : 0 }}</text>
  48. {{ $t(`元`) }}
  49. </view>
  50. </view>
  51. </view>
  52. <view class="item-btn">
  53. <view class="change" @click="changeData(item)">{{ $t(`修改分佣比例`) }}</view>
  54. <view class="clear" @click="clear(item, index)">{{ $t(`删除`) }}</view>
  55. </view>
  56. </block>
  57. </view>
  58. </view>
  59. <!-- #ifdef MP -->
  60. <!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
  61. <!-- #endif -->
  62. <home></home>
  63. <view class="refund-input" :class="refund_close ? 'on' : ''">
  64. <view class="input-msg">
  65. <text class="iconfont icon-guanbi5" @tap="refund_close = false"></text>
  66. <view class="refund-input-title">{{ $t(`修改分佣比例`) }}</view>
  67. <view class="refund-input-sty">
  68. <input type="number" v-model="agent_percent" :placeholder="$t(`请输入百分比`)" />
  69. </view>
  70. <view class="refund-bth">
  71. <!-- <view class="close-refund" @click="refund_close = false">取消</view> -->
  72. <view class="submit-refund" @click="refundSubmit()">{{ $t(`提交`) }}</view>
  73. </view>
  74. </view>
  75. </view>
  76. <view class="mask invoice-mask" v-if="refund_close" @click="refund_close = false"></view>
  77. <view class="mask invoice-mask" v-if="codeModal" @click="codeModal = false"></view>
  78. <view class="poster-pop" v-if="codeModal">
  79. <image src="/static/images/poster-close.png" class="close" @click="posterImageClose"></image>
  80. <!-- #ifdef MP -->
  81. <image :src="codeSrc"></image>
  82. <!-- #endif -->
  83. <!-- #ifndef MP -->
  84. <zb-code
  85. ref="qrcode"
  86. :show="codeModal"
  87. :cid="cid"
  88. :val="val"
  89. :size="size"
  90. :unit="unit"
  91. :background="background"
  92. :foreground="foreground"
  93. :pdground="pdground"
  94. :icon="icon"
  95. :iconSize="iconsize"
  96. :onval="onval"
  97. :loadMake="loadMake"
  98. @result="qrR"
  99. />
  100. <!-- #endif -->
  101. <!-- #ifndef H5 -->
  102. <view class="save-poster" @click="savePosterPath">{{ $t(`保存到手机`) }}</view>
  103. <!-- #endif -->
  104. <!-- #ifdef H5 -->
  105. <view class="keep">{{ $t(`长按图片可以保存到手机`) }}</view>
  106. <!-- #endif -->
  107. </view>
  108. </view>
  109. </template>
  110. <script>
  111. import { clerkPeople, setClerkPercent, delClerkPercent } from '@/api/user.js';
  112. import { toLogin } from '@/libs/login.js';
  113. import { mapGetters } from 'vuex';
  114. // #ifdef MP
  115. import authorize from '@/components/Authorize';
  116. // #endif
  117. import home from '@/components/home';
  118. import colors from '@/mixins/color.js';
  119. import zbCode from '@/components/zb-code/zb-code.vue';
  120. import { HTTP_REQUEST_URL } from '@/config/app.js';
  121. let app = getApp();
  122. export default {
  123. components: {
  124. // #ifdef MP
  125. authorize,
  126. // #endif
  127. home,
  128. zbCode
  129. },
  130. mixins: [colors],
  131. data() {
  132. return {
  133. total: 0,
  134. totalLevel: 0,
  135. agent_percent: null,
  136. teamCount: 0,
  137. page: 1,
  138. limit: 20,
  139. keyword: '',
  140. sort: '',
  141. grade: 0,
  142. uid: 0,
  143. status: false,
  144. recordList: [],
  145. refund_close: false,
  146. isAuto: false, //没有授权的不会自动授权
  147. isShowAuth: false, //是否隐藏授权
  148. //二维码参数
  149. codeShow: false,
  150. cid: '1',
  151. ifShow: true,
  152. val: HTTP_REQUEST_URL + '/pages/index/index?agent_id=' + this.$store.state.app.uid, // 要生成的二维码值
  153. size: 430, // 二维码大小
  154. unit: 'upx', // 单位
  155. background: '#FFF', // 背景色
  156. foreground: '#000', // 前景色
  157. pdground: '#000', // 角标色
  158. icon: '', // 二维码图标
  159. iconsize: 70, // 二维码图标大小
  160. lv: 3, // 二维码容错级别 , 一般不用设置,默认就行
  161. onval: true, // val值变化时自动重新生成二维码
  162. loadMake: true, // 组件加载完成后自动生成二维码
  163. src: '', // 二维码生成后的图片地址或base64
  164. codeSrc: '',
  165. codeModal: false
  166. };
  167. },
  168. computed: mapGetters(['isLogin']),
  169. onLoad() {
  170. if (this.isLogin) {
  171. this.userSpreadNewList();
  172. } else {
  173. toLogin();
  174. }
  175. },
  176. onShow: function () {
  177. if (this.is_show) this.userSpreadNewList();
  178. // this.getUrlCode()
  179. },
  180. onHide: function () {
  181. this.is_show = true;
  182. },
  183. methods: {
  184. qrR(res) {
  185. this.codeSrc = res;
  186. },
  187. showCode() {
  188. this.codeModal = true;
  189. },
  190. posterImageClose() {
  191. this.codeModal = false;
  192. },
  193. onLoadFun: function (e) {
  194. this.userSpreadNewList();
  195. },
  196. // 授权关闭
  197. authColse: function (e) {
  198. this.isShowAuth = e;
  199. },
  200. setSort: function (sort) {
  201. let that = this;
  202. that.sort = sort;
  203. that.page = 1;
  204. that.limit = 20;
  205. that.status = false;
  206. that.$set(that, 'recordList', []);
  207. that.userSpreadNewList();
  208. },
  209. // setKeyword: function(e) {
  210. // this.keyword = e.detail.value;
  211. // },
  212. submitForm: function () {
  213. this.page = 1;
  214. this.limit = 20;
  215. this.status = false;
  216. this.$set(this, 'recordList', []);
  217. this.userSpreadNewList();
  218. },
  219. clear(data, index) {
  220. let that = this;
  221. uni.showModal({
  222. title: that.$t(`删除员工`),
  223. content: that.$t(`确定删除该员工?`),
  224. success: (res) => {
  225. if (res.confirm) {
  226. delClerkPercent(data.uid)
  227. .then((res) => {
  228. that.recordList.splice(index, 1);
  229. that.$set(that, 'recordList', that.recordList);
  230. // that.userSpreadNewList();
  231. that.teamCount -= 1;
  232. return that.$util.Tips({
  233. title: that.$t(`删除成功`),
  234. icon: 'success'
  235. });
  236. })
  237. .catch((err) => {
  238. return that.$util.Tips({
  239. title: err
  240. });
  241. });
  242. } else if (res.cancel) {
  243. return that.$util.Tips({
  244. title: that.$t(`已取消`)
  245. });
  246. }
  247. }
  248. });
  249. },
  250. changeData(data) {
  251. this.refund_close = true;
  252. this.uid = data.uid;
  253. },
  254. refundSubmit() {
  255. if (this.agent_percent < 0) {
  256. return this.$util.Tips({
  257. title: this.$t(`请输入比例`)
  258. });
  259. }
  260. setClerkPercent({
  261. agent_percent: this.agent_percent,
  262. uid: this.uid
  263. })
  264. .then((res) => {
  265. this.$util.Tips(
  266. {
  267. title: res.msg,
  268. icon: 'success'
  269. },
  270. () => {
  271. this.refund_close = false;
  272. this.page = 1;
  273. this.limit = 20;
  274. this.keyword = '';
  275. this.sort = '';
  276. this.status = false;
  277. this.agent_percent = null;
  278. this.$set(this, 'recordList', []);
  279. this.userSpreadNewList();
  280. }
  281. );
  282. })
  283. .catch((err) => {
  284. this.$util.Tips({
  285. title: err
  286. });
  287. });
  288. },
  289. setType: function (grade) {
  290. if (this.grade != grade) {
  291. this.grade = grade;
  292. this.page = 1;
  293. this.limit = 20;
  294. this.keyword = '';
  295. this.sort = '';
  296. this.status = false;
  297. this.$set(this, 'recordList', []);
  298. this.userSpreadNewList();
  299. }
  300. },
  301. userSpreadNewList: function () {
  302. let that = this;
  303. let page = that.page;
  304. let limit = that.limit;
  305. let status = that.status;
  306. let keyword = that.keyword;
  307. let sort = that.sort;
  308. let grade = that.grade;
  309. let recordList = that.recordList;
  310. let recordListNew = [];
  311. if (status == true) return;
  312. clerkPeople({
  313. page: page,
  314. limit: limit,
  315. keyword: keyword,
  316. grade: grade,
  317. sort: sort
  318. }).then((res) => {
  319. let len = res.data.list.length;
  320. let recordListData = res.data.list;
  321. recordListNew = recordList.concat(recordListData);
  322. that.total = res.data.total;
  323. that.totalLevel = res.data.totalLevel;
  324. that.teamCount = res.data.count;
  325. that.codeSrc = res.data.codeUrl;
  326. that.status = limit > len;
  327. that.page = page + 1;
  328. that.$set(that, 'recordList', recordListNew);
  329. });
  330. },
  331. downloadFilestoreImage(url) {
  332. return new Promise((resolve, reject) => {
  333. let that = this;
  334. uni.downloadFile({
  335. url: url,
  336. success: function (res) {
  337. resolve(res.tempFilePath);
  338. },
  339. fail: function () {
  340. return that.$util.Tips({
  341. title: ''
  342. });
  343. }
  344. });
  345. });
  346. },
  347. savePosterPath() {
  348. let that = this;
  349. that.downloadFilestoreImage(that.codeSrc).then((url) => {
  350. uni.getSetting({
  351. success(res) {
  352. if (!res.authSetting['scope.writePhotosAlbum']) {
  353. uni.authorize({
  354. scope: 'scope.writePhotosAlbum',
  355. success() {
  356. uni.saveImageToPhotosAlbum({
  357. filePath: url,
  358. success: function (res) {
  359. that.posterImageClose();
  360. that.$util.Tips({
  361. title: that.$t(`保存成功`),
  362. icon: 'success'
  363. });
  364. },
  365. fail: function (res) {
  366. that.$util.Tips({
  367. title: that.$t(`保存失败`)
  368. });
  369. }
  370. });
  371. }
  372. });
  373. } else {
  374. uni.saveImageToPhotosAlbum({
  375. filePath: url,
  376. success: function (res) {
  377. that.posterImageClose();
  378. that.$util.Tips({
  379. title: that.$t(`保存成功`),
  380. icon: 'success'
  381. });
  382. },
  383. fail: function (res) {
  384. that.$util.Tips({
  385. title: that.$t(`保存失败`)
  386. });
  387. }
  388. });
  389. }
  390. }
  391. });
  392. });
  393. }
  394. },
  395. onReachBottom: function () {
  396. this.userSpreadNewList();
  397. }
  398. };
  399. </script>
  400. <style scoped lang="scss">
  401. .invoice-mask {
  402. background-color: #ccc;
  403. opacity: 0.7;
  404. }
  405. .promoter-list .nav {
  406. background-color: #fff;
  407. height: 86rpx;
  408. line-height: 86rpx;
  409. font-size: 28rpx;
  410. color: #282828;
  411. border-bottom: 1rpx solid #eee;
  412. }
  413. .promoter-list .nav .item.on {
  414. border-bottom: 5rpx solid #e93323;
  415. color: #e93323;
  416. }
  417. .promoter-list .search {
  418. width: 100%;
  419. background-color: #fff;
  420. height: 86rpx;
  421. padding-left: 30rpx;
  422. box-sizing: border-box;
  423. }
  424. .promoter-list .search .input {
  425. width: 610rpx;
  426. height: 60rpx;
  427. border-radius: 50rpx;
  428. background-color: #f5f5f5;
  429. text-align: center;
  430. position: relative;
  431. }
  432. .promoter-list .name {
  433. display: flex;
  434. .invitation {
  435. background-color: #fff;
  436. border-radius: 6rpx;
  437. padding: 0rpx 10rpx;
  438. margin-left: 20rpx;
  439. color: #d13d25;
  440. }
  441. }
  442. .promoter-list .search .input input {
  443. height: 100%;
  444. font-size: 26rpx;
  445. width: 610rpx;
  446. text-align: center;
  447. }
  448. .promoter-list .search .input .placeholder {
  449. color: #bbb;
  450. }
  451. .promoter-list .search .input .iconfont {
  452. position: absolute;
  453. right: 28rpx;
  454. color: #999;
  455. font-size: 28rpx;
  456. top: 50%;
  457. transform: translateY(-50%);
  458. }
  459. .promoter-list .search .iconfont {
  460. font-size: 45rpx;
  461. color: #515151;
  462. width: 110rpx;
  463. height: 60rpx;
  464. line-height: 60rpx;
  465. }
  466. .promoter-list .list {
  467. margin-top: 12rpx;
  468. }
  469. .promoter-list .list .sortNav {
  470. background-color: #fff;
  471. height: 76rpx;
  472. border-bottom: 1rpx solid #eee;
  473. color: #333;
  474. font-size: 28rpx;
  475. }
  476. .promoter-list .list .sortNav .sortItem {
  477. text-align: center;
  478. flex: 1;
  479. }
  480. .promoter-list .list .sortNav .sortItem image {
  481. width: 24rpx;
  482. height: 24rpx;
  483. margin-left: 6rpx;
  484. vertical-align: -3rpx;
  485. }
  486. .promoter-list .list .item {
  487. background-color: #fff;
  488. border-bottom: 1rpx solid #eee;
  489. height: 152rpx;
  490. padding: 0 30rpx 0 20rpx;
  491. font-size: 24rpx;
  492. color: #666;
  493. }
  494. .item-btn {
  495. display: flex;
  496. align-items: center;
  497. justify-content: flex-end;
  498. background-color: #fff;
  499. }
  500. .clear,
  501. .change {
  502. padding: 5rpx 15rpx;
  503. margin: 10rpx;
  504. border-radius: 6rpx;
  505. }
  506. .clear {
  507. background-color: #ccc;
  508. color: #fff;
  509. }
  510. .change {
  511. background-color: #de4d36;
  512. color: #fff;
  513. }
  514. .promoter-list .list .item .picTxt {
  515. width: 440rpx;
  516. }
  517. .promoter-list .list .item .picTxt .pictrue {
  518. width: 106rpx;
  519. height: 106rpx;
  520. border-radius: 50%;
  521. }
  522. .promoter-list .list .item .picTxt .pictrue image {
  523. width: 100%;
  524. height: 100%;
  525. border-radius: 50%;
  526. border: 3rpx solid #fff;
  527. box-shadow: 0 0 10rpx #aaa;
  528. box-sizing: border-box;
  529. }
  530. .promoter-list .list .item .picTxt .text {
  531. width: 304rpx;
  532. font-size: 24rpx;
  533. color: #666;
  534. }
  535. .promoter-list .list .item .picTxt .text .name {
  536. font-size: 28rpx;
  537. color: #333;
  538. margin-bottom: 13rpx;
  539. }
  540. .promoter-list .list .item .right {
  541. width: 240rpx;
  542. text-align: right;
  543. font-size: 22rpx;
  544. color: #333;
  545. }
  546. .promoter-list .list .item .right .num {
  547. margin-right: 7rpx;
  548. }
  549. .refund-input {
  550. position: fixed;
  551. bottom: 0;
  552. left: 0;
  553. width: 100%;
  554. border-radius: 16rpx 16rpx 0 0;
  555. background-color: #fff;
  556. z-index: 99;
  557. padding: 40rpx 0 70rpx 0;
  558. transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9);
  559. transform: translate3d(0, 100%, 0);
  560. .refund-input-title {
  561. font-size: 32rpx;
  562. margin-bottom: 60rpx;
  563. color: #282828;
  564. }
  565. .refund-input-sty {
  566. border: 1px solid #ddd;
  567. padding: 20rpx 20rpx;
  568. border-radius: 40rpx;
  569. width: 100%;
  570. margin: 20rpx 65rpx;
  571. }
  572. .input-msg {
  573. display: flex;
  574. flex-direction: column;
  575. justify-content: center;
  576. align-items: center;
  577. position: relative;
  578. margin: 0 65rpx;
  579. .iconfont {
  580. position: absolute;
  581. font-size: 32rpx;
  582. color: #282828;
  583. top: 8rpx;
  584. right: -30rpx;
  585. }
  586. }
  587. .refund-bth {
  588. display: flex;
  589. margin: 0 65rpx;
  590. margin-top: 20rpx;
  591. justify-content: space-around;
  592. width: 100%;
  593. .close-refund {
  594. padding: 24rpx 80rpx;
  595. border-radius: 80rpx;
  596. color: #fff;
  597. background-color: #ccc;
  598. }
  599. .submit-refund {
  600. width: 100%;
  601. padding: 24rpx 0rpx;
  602. text-align: center;
  603. border-radius: 80rpx;
  604. color: #fff;
  605. background-color: #f62c2c;
  606. }
  607. }
  608. }
  609. .refund-input.on {
  610. transform: translate3d(0, 0, 0);
  611. }
  612. .poster-pop {
  613. width: 450rpx;
  614. height: 450rpx;
  615. position: fixed;
  616. padding: 10rpx;
  617. background-color: #fff;
  618. left: 50%;
  619. transform: translateX(-50%);
  620. z-index: 399;
  621. top: 50%;
  622. margin-top: -357rpx;
  623. }
  624. .poster-pop image {
  625. width: 100%;
  626. height: 100%;
  627. display: block;
  628. }
  629. .poster-pop .close {
  630. width: 46rpx;
  631. height: 75rpx;
  632. position: fixed;
  633. right: 0;
  634. top: -73rpx;
  635. display: block;
  636. }
  637. .poster-pop .save-poster {
  638. background-color: #df2d0a;
  639. font-size: :22rpx;
  640. color: #fff;
  641. text-align: center;
  642. height: 76rpx;
  643. line-height: 76rpx;
  644. width: 450rpx;
  645. margin-left: -10rpx;
  646. }
  647. .poster-pop .keep {
  648. color: #fff;
  649. text-align: center;
  650. font-size: 25rpx;
  651. margin-top: 30rpx;
  652. }
  653. </style>