distributionCenter.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. <template>
  2. <view class="page">
  3. <!-- 佣金总计 -->
  4. <view class="commissionTotal">
  5. <view class="user-info dis a-c j-s ">
  6. <view class="dis a-c">
  7. <image src="/static/image/avatar.png" mode=""></image>
  8. <text class="name">某某某</text>
  9. </view>
  10. <text class="time">2025年12月1日加入</text>
  11. </view>
  12. <view class="totals dis j-s">
  13. <view class="item dis f-c a-c">
  14. <text>¥<text class="sum">{{distributionInfo.totalAmount || 0 }}</text> </text>
  15. <text>累计佣金</text>
  16. </view>
  17. <view class="item dis f-c a-c ">
  18. <text>¥<text class="sum">{{distributionInfo.pendingAmount || 0 }}</text> </text>
  19. <text>待结算</text>
  20. </view>
  21. <view class="item dis f-c a-c">
  22. <text>¥<text class="sum">{{distributionInfo.returnAmount || 0 }}</text> </text>
  23. <text>退回佣金</text>
  24. </view>
  25. </view>
  26. </view>
  27. <!-- 分类统计 -->
  28. <view class="categoryStatistics mt-2 dis a-c j-s">
  29. <view class="item" @click="toPage('distributeTeam')">
  30. <view class="title dis a-c j-c ">
  31. 团队管理
  32. </view>
  33. <view class="content dis a-c f-c">
  34. <view class=" totalCount dis a-c ">
  35. <text class="sum">{{distributionInfo.teamNum || 0}}</text>
  36. <text class="unit">人</text>
  37. </view>
  38. <view class="today dis a-c mt-1 ">
  39. <text>今日新增</text>
  40. <image src="/static/image/income.png" mode=""></image>
  41. <text class="sum">{{distributionInfo.todayNewNum || 0}}</text>
  42. <text class="unit">人</text>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="item" @click="toPage('distributionOrders')">
  47. <view class="title dis a-c j-c " style="background: #F6FBE5;">
  48. 分销订单
  49. </view>
  50. <view class="content dis a-c f-c">
  51. <view class=" totalCount dis a-c ">
  52. <text class="sum">{{distributionInfo.distributionOrderNum || 0}}</text>
  53. <text class="unit">笔 </text>
  54. </view>
  55. <view class="today dis a-c mt-1 ">
  56. <text>今日新增</text>
  57. <image src="/static/image/income.png" mode=""></image>
  58. <text class="sum">{{distributionInfo.todayDistributionOrderNum || 0}}</text>
  59. <text class="unit">笔</text>
  60. </view>
  61. </view>
  62. </view>
  63. <view class="item" @click="toPage('distributionOrders')">
  64. <view class="title dis a-c j-c ">
  65. 保费
  66. </view>
  67. <view class="content dis a-c f-c">
  68. <view class=" totalCount dis a-c ">
  69. <text class="sum">{{distributionInfo.totalPremium / 10000 || 0}}</text>
  70. <text class="unit">万</text>
  71. </view>
  72. <view class="today dis a-c mt-1 ">
  73. <text>今日新增</text>
  74. <image src="/static/image/income.png" mode=""></image>
  75. <text class="sum">{{distributionInfo.todayPremium / 10000 || 0}}</text>
  76. <text class="unit">万</text>
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. <!-- 佣金收益 等级划分 -->
  82. <view class="commissionEarnings mt-2 dis j-s a-c " @click="orderDetails(1)">
  83. <!-- 今日收益 -->
  84. <view class="today-earnings dis f-c ">
  85. <view class="dis a-c">
  86. <image src="/static/image/tool/level1.png" mode=""></image>
  87. <text class="title">一级佣金收益</text>
  88. </view>
  89. <view class="dis a-c mt-1">
  90. <text class="today">今日</text>
  91. <text class="sum">+{{distributionInfo.todayFirstLevelCommission || 0}}</text>
  92. </view>
  93. </view>
  94. <!-- 总收益 -->
  95. <view class="total-earnings dis a-c ">
  96. <text class="mr-2">¥{{distributionInfo.firstLevelCommission || 0}}</text>
  97. <u-icon name="arrow-right" color="#666666" size="16" bold></u-icon>
  98. </view>
  99. </view>
  100. <view class="commissionEarnings mt-2 dis j-s a-c " @click="orderDetails(2)">
  101. <!-- 今日收益 -->
  102. <view class="today-earnings dis f-c ">
  103. <view class="dis a-c">
  104. <image src="/static/image/tool/level2.png" mode=""></image>
  105. <text class="title">二级佣金收益</text>
  106. </view>
  107. <view class="dis a-c mt-1">
  108. <text class="today">今日</text>
  109. <text class="sum">+{{distributionInfo.todaySecondLevelCommission || 0}}</text>
  110. </view>
  111. </view>
  112. <!-- 总收益 -->
  113. <view class="total-earnings dis a-c ">
  114. <text class="mr-2">¥{{distributionInfo.secondLevelCommission || 0}}</text>
  115. <u-icon name="arrow-right" color="#666666" size="16" bold></u-icon>
  116. </view>
  117. </view>
  118. <view class="commissionEarnings mt-2 dis j-s a-c " @click="orderDetails(3)">
  119. <!-- 今日收益 -->
  120. <view class="today-earnings dis f-c ">
  121. <view class="dis a-c">
  122. <image src="/static/image/tool/level3.png" mode=""></image>
  123. <text class="title">三级佣金收益</text>
  124. </view>
  125. <view class="dis a-c mt-1">
  126. <text class="today">今日</text>
  127. <text class="sum">+{{distributionInfo.todayThirdLevelCommission || 0}}</text>
  128. </view>
  129. </view>
  130. <!-- 总收益 -->
  131. <view class="total-earnings dis a-c ">
  132. <text class="mr-2">¥{{distributionInfo.thirdLevelCommission || 0 }}</text>
  133. <u-icon name="arrow-right" color="#666666" size="16" bold></u-icon>
  134. </view>
  135. </view>
  136. <!-- 邀请入口 -->
  137. <view class="inviteEntrance mt-2">
  138. <image src="/static/image/my/inviteEntrance.png" mode=""
  139. @click="showLargeImage('/static/image/my/inviteDistribution.png')"></image>
  140. </view>
  141. <!-- 大图预览弹窗 -->
  142. <u-overlay :show="showLargeImageShow" @click="showLargeImageShow = false" :opacity="0.6" class="u-overlay">
  143. <view class="close-btn dis a-c j-c" @click="showLargeImageShow = false">×</view>
  144. <view class="panelcanvas " id="panelcanvas">
  145. <view class="posterview dis f-c" @tap.stop>
  146. <image class="promoImage" :src="sctiveimg" mode=""></image>
  147. <view class="userinfo dis a-c j-s">
  148. <view class="dis a-c">
  149. <image class="avatar" src="/static/image/avatar.png" mode=""></image>
  150. <text class="ml-3">扫码成为分销员</text>
  151. </view>
  152. <image :src="qrcodeImg" class="qrcodeImg" mode="widthFix" lazy-load></image>
  153. </view>
  154. </view>
  155. </view>
  156. <!-- 分享操作栏 -->
  157. <view class="share-prop" @tap.stop>
  158. <view class="header-title dis a-c j-c">分享到</view>
  159. <view class="foo-btn dis a-c j-s">
  160. <view class="interact-item dis f-c a-c" @click="saveImage">
  161. <image src="/static/icon/tool/saveImg.png" mode=""></image>
  162. <text>保存到相册</text>
  163. </view>
  164. <view class="interact-item dis f-c a-c" @click="sendPayCode">
  165. <image src="/static/icon/tool/wx.png" mode=""></image>
  166. <text>微信</text>
  167. </view>
  168. <view class="interact-item dis f-c a-c" @click="shareMoments">
  169. <image src="/static/icon/tool/friendsCircleLogo.png" mode=""></image>
  170. <text>朋友圈</text>
  171. </view>
  172. </view>
  173. </view>
  174. </u-overlay>
  175. </view>
  176. </template>
  177. <script>
  178. import QR from "@/common/wxqrcode.js"
  179. import {
  180. pathToBase64,
  181. base64ToPath
  182. } from '@/common/pdf.js'
  183. import {
  184. turnBase64Image
  185. } from '@/plugins/utils.js';
  186. import {
  187. mapState,
  188. mapMutations
  189. } from "vuex"
  190. export default {
  191. data() {
  192. return {
  193. showLargeImageShow: false, //大图预览弹窗
  194. sctiveimg: "", // 放大显示的图片
  195. shareImage: "", //分享图片
  196. qrcodeImg: "", //二维码图片
  197. imageCache: {}, // 缓存已转换的Base64图片
  198. distributionInfo: {},
  199. Info: {}
  200. }
  201. },
  202. onShow() {
  203. },
  204. onLoad() {
  205. this.getUserInfo() //获取用户信息
  206. this.getDistribution();
  207. this.qrcodeImg = QR.createQrCodeImg(this.$base.h5BaseUrl + `/#/pages/registr/h5Registr?systemCode=${this
  208. .system_code}&page=分销员注册&info=${JSON.stringify({
  209. name: this.Info.name,
  210. infoId: this.Info.infoId,
  211. id: this.Info.id,
  212. headSculpture: this.Info.headSculpture,
  213. deptName: this.Info.deptName,
  214. })}`, {
  215. size: parseInt(300), //二维码大小
  216. })
  217. },
  218. computed: {
  219. ...mapState(['userInfo', 'system_code'])
  220. },
  221. methods: {
  222. async getUserInfo() {
  223. let res = await this.$http.get('/appUser/userInfoGet'); //获取人员信息
  224. if (res.code == '200') {
  225. this.Info = res.data
  226. }
  227. },
  228. aaaa() {
  229. uni.navigateTo({
  230. url: `/pages/registr/h5Registr?systemCode=${this.system_code}&page=分销员注册`
  231. })
  232. },
  233. async orderDetails(value) {
  234. uni.navigateTo({
  235. url: `/pages/tool/distributionOrders?level=` + value,
  236. })
  237. },
  238. //数据格式化
  239. numberFormat(value) {
  240. return (value).toLocaleString('en-US');
  241. },
  242. async getDistribution() {
  243. let res = await this.$http.post('/sysDistributionSetting/distributionCenter');
  244. if (res.code == 200) {
  245. this.distributionInfo = res.data;
  246. }
  247. },
  248. // 显示大图(带缓存优化)
  249. async showLargeImage(item) {
  250. try {
  251. if (!this.imageCache[item]) {
  252. this.imageCache[item] = await turnBase64Image(item);
  253. }
  254. this.sctiveimg = this.imageCache[item];
  255. this.showLargeImageShow = true;
  256. setTimeout(() => {
  257. this.canvasImage.generateImage()
  258. }, 1000);
  259. } catch (error) {
  260. console.error("图片转换失败:", error);
  261. uni.showToast({
  262. title: "图片加载失败",
  263. icon: "none"
  264. });
  265. }
  266. },
  267. //分销页面跳转
  268. toPage(pageName) {
  269. uni.navigateTo({
  270. url: `/pages/tool/${pageName}`
  271. })
  272. },
  273. //发送到微信
  274. sendPayCode() {
  275. if (this.shareImage) {
  276. uni.share({
  277. provider: "weixin",
  278. scene: "WXSceneSession",
  279. type: 2,
  280. imageUrl: this.shareImage
  281. })
  282. }
  283. },
  284. //发送到朋友圈
  285. shareMoments() {
  286. if (this.shareImage) {
  287. uni.share({
  288. provider: "weixin",
  289. scene: "WXSceneTimeline",
  290. type: 2,
  291. imageUrl: this.shareImage
  292. })
  293. }
  294. },
  295. //保存图片
  296. saveImage() {
  297. base64ToPath(this.shareImage)
  298. .then(path => {
  299. uni.saveImageToPhotosAlbum({ //保存图片到系统相册。
  300. filePath: path, //图片文件路径
  301. success: function() {
  302. uni.showToast({
  303. title: '已保存到相册',
  304. icon: 'none',
  305. });
  306. },
  307. fail: function(e) {
  308. uni.showToast({
  309. title: '图片保存失败',
  310. icon: 'none',
  311. });
  312. }
  313. });
  314. })
  315. },
  316. //页面截图转路径
  317. receiveRenderData(val) {
  318. this.shareImage = val.replace(/[\r\n]/g, ''); // 去除base64位中的空格
  319. },
  320. showLoading() {
  321. uni.showLoading({
  322. title: '正在生成图片'
  323. });
  324. },
  325. hideLoading() {
  326. uni.hideLoading();
  327. },
  328. }
  329. }
  330. </script>
  331. <script module="canvasImage" lang="renderjs">
  332. import html2canvas from 'html2canvas'
  333. export default {
  334. data() {
  335. return {
  336. }
  337. },
  338. mounted() {
  339. },
  340. methods: {
  341. generateImage() {
  342. setTimeout(() => {
  343. this.$ownerInstance.callMethod('showLoading')
  344. const dom = document.getElementById('panelcanvas') // 需要生成图片内容的 dom 节点
  345. html2canvas(dom, {
  346. width: dom.clientWidth, //dom 原始宽度
  347. height: dom.clientHeight,
  348. scrollY: 0, // html2canvas默认绘制视图内的页面,需要把scrollY,scrollX设置为0
  349. scrollX: 0,
  350. useCORS: true, //支持跨域
  351. // allowTaint: false,
  352. scale: 2, // 设置生成图片的像素比例,默认是1,如果生成的图片模糊的话可以开启该配置项
  353. }).then((canvas) => {
  354. console.log(canvas);
  355. // 生成成功
  356. this.$ownerInstance.callMethod('hideLoading')
  357. this.$ownerInstance.callMethod('receiveRenderData', canvas.toDataURL('image/png'))
  358. }).catch(err => {
  359. // 生成失败 弹出提示弹窗
  360. this.$ownerInstance.callMethod('_errAlert', `【生成图片失败,请重试】${err}`)
  361. })
  362. }, 300)
  363. }
  364. },
  365. }
  366. </script>
  367. <style lang="scss" scoped>
  368. .page {
  369. background-color: #f8f8f8;
  370. padding: 20rpx 30rpx;
  371. box-sizing: border-box;
  372. height: calc(100vh - 88rpx);
  373. }
  374. .commissionTotal {
  375. padding: 10rpx 6rpx 6rpx;
  376. box-sizing: border-box;
  377. background: #FDEA48;
  378. border-radius: 20rpx 20rpx 20rpx 20rpx;
  379. .user-info {
  380. padding: 0 14rpx;
  381. box-sizing: border-box;
  382. image {
  383. width: 54rpx;
  384. height: 54rpx;
  385. }
  386. .name {
  387. font-size: 32rpx;
  388. color: #1f1f1f;
  389. font-weight: bold;
  390. margin-left: 16rpx;
  391. }
  392. .time {
  393. font-size: 22rpx;
  394. color: #999;
  395. }
  396. }
  397. .totals {
  398. margin-top: 8rpx;
  399. padding: 20rpx 24rpx;
  400. box-sizing: border-box;
  401. background: linear-gradient(88deg, #FFFFFF 0%, rgba(255, 255, 255, 0.9) 100%);
  402. border-radius: 16rpx 16rpx 16rpx 16rpx;
  403. display: grid;
  404. grid-template-columns: repeat(3, 1fr);
  405. grid-template-rows: auto;
  406. column-gap: 70rpx;
  407. .item {
  408. >:first-child {
  409. font-size: 24rpx;
  410. color: #333;
  411. font-weight: bold;
  412. .sum {
  413. font-size: 36rpx;
  414. }
  415. }
  416. >:last-child {
  417. font-size: 24rpx;
  418. color: #999;
  419. }
  420. }
  421. }
  422. }
  423. .categoryStatistics {
  424. width: 100%;
  425. .item {
  426. width: 29%;
  427. padding: 2rpx;
  428. box-sizing: border-box;
  429. background: #fff;
  430. border-radius: 20rpx 20rpx 20rpx 20rpx;
  431. .title {
  432. height: 50rpx;
  433. background: #FFF6EB;
  434. border-radius: 20rpx 20rpx 0rpx 0rpx;
  435. border: 2rpx solid #FFFFFF;
  436. font-size: 24rpx;
  437. color: #834A11;
  438. }
  439. .content {
  440. padding: 10rpx 0 20rpx;
  441. box-sizing: border-box;
  442. .totalCount {
  443. .sum {
  444. font-size: 36rpx;
  445. color: #333;
  446. font-weight: bold;
  447. line-height: 1;
  448. }
  449. .unit {
  450. font-size: 24rpx;
  451. color: #999;
  452. margin-left: 4rpx;
  453. }
  454. }
  455. .today {
  456. font-size: 22rpx;
  457. color: #999;
  458. .sum {
  459. color: #333;
  460. }
  461. image {
  462. width: 24rpx;
  463. height: 24rpx;
  464. margin: 0 2rpx;
  465. }
  466. }
  467. }
  468. }
  469. .item:last-child {
  470. width: 36%;
  471. .title {
  472. background: #EBFBF7;
  473. }
  474. }
  475. }
  476. //佣金收益
  477. .commissionEarnings {
  478. background: #FFFFFF;
  479. border-radius: 20rpx 20rpx 20rpx 20rpx;
  480. padding: 30rpx;
  481. box-sizing: border-box;
  482. .today-earnings {
  483. image {
  484. width: 40rpx;
  485. height: 36rpx;
  486. }
  487. .title {
  488. font-size: 30rpx;
  489. color: #333;
  490. font-weight: bold;
  491. margin-left: 4rpx;
  492. }
  493. .today {
  494. font-size: 26rpx;
  495. color: #999;
  496. }
  497. .sum {
  498. font-size: 26rpx;
  499. color: #FF4545;
  500. }
  501. }
  502. .total-earnings {
  503. text {
  504. font-size: 36rpx;
  505. color: #333;
  506. font-weight: bold;
  507. }
  508. }
  509. }
  510. //分销入口
  511. .inviteEntrance {
  512. image {
  513. width: 100%;
  514. height: 146rpx;
  515. border-radius: 20rpx;
  516. }
  517. }
  518. //海报弹窗样式
  519. /* 分享操作栏 */
  520. .share-prop {
  521. position: absolute;
  522. bottom: 0;
  523. left: 0;
  524. width: 100%;
  525. background-color: #fff;
  526. border-radius: 20rpx 20rpx 0 0;
  527. .header-title {
  528. padding: 24rpx;
  529. font-size: 36rpx;
  530. color: #333;
  531. font-weight: bold;
  532. border-bottom: 1rpx solid #eee;
  533. }
  534. .foo-btn {
  535. padding: 30rpx 128rpx;
  536. .interact-item {
  537. image {
  538. width: 88rpx;
  539. height: 88rpx;
  540. margin-bottom: 10rpx;
  541. }
  542. text {
  543. font-size: 24rpx;
  544. color: #333;
  545. }
  546. }
  547. }
  548. }
  549. // 右上角关闭按钮
  550. .close-btn {
  551. position: absolute;
  552. width: 50rpx;
  553. height: 50rpx;
  554. right: 20rpx;
  555. top: 20rpx;
  556. font-size: 36rpx;
  557. line-height: 0.8;
  558. font-weight: bold;
  559. z-index: 10;
  560. background-color: #fff;
  561. border-radius: 50%;
  562. }
  563. /* 大图预览弹窗 */
  564. .posterview {
  565. margin: 20% 80rpx 0;
  566. background-color: #fff;
  567. border-radius: 10rpx;
  568. position: relative;
  569. .promoImage {
  570. width: 100%;
  571. height: 860rpx;
  572. border-radius: 10rpx 10rpx 0 0;
  573. }
  574. .userinfo {
  575. padding: 25rpx 40rpx;
  576. .avatar {
  577. width: 76rpx;
  578. height: 76rpx;
  579. }
  580. .qrcodeImg {
  581. width: 100rpx;
  582. height: 100rpx;
  583. }
  584. text {
  585. font-size: 28rpx;
  586. color: #333;
  587. }
  588. .panelcanvas {
  589. position: relative;
  590. }
  591. }
  592. }
  593. </style>