抖音b端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

722 lines
17 KiB

  1. const config = require('../../config/config.js')
  2. const Http = require('../../utils/http.js')
  3. const HttpBasics = require('../../utils/HttpBasics.js')
  4. const util = require('../../utils/util')
  5. const changeNum = require('../../utils/changeNum.js')
  6. import * as echarts from '../../ec-canvas/echarts';
  7. var app = getApp()
  8. function setOption(chart, xdata, ydata) {
  9. const option = {
  10. title: {
  11. padding: [10, 0, 0, 20],
  12. textStyle: {
  13. fontSize: 14,
  14. color: '#FF6A6A'
  15. },
  16. },
  17. backgroundColor: "#fff",
  18. color: ["#006EFF", "#67E0E3", "#9FE6B8"],
  19. animation: true,
  20. grid: {
  21. top: '3%',
  22. left: "5%",
  23. right: "7%",
  24. bottom: "4%",
  25. containLabel: true,
  26. },
  27. xAxis: {
  28. type: 'category',
  29. boundaryGap: false,
  30. data: xdata,
  31. splitLine: {
  32. show: false
  33. }, //去除网格线
  34. axisLine: {
  35. show: false
  36. },
  37. axisTick: {
  38. show: false
  39. }
  40. },
  41. yAxis: [{
  42. splitLine: {
  43. lineStyle: {
  44. type: 'none'
  45. }
  46. },
  47. axisLine: {
  48. show: false
  49. },
  50. axisTick: {
  51. show: false
  52. },
  53. axisLabel: {
  54. rotate: 40,
  55. formatter: function (a, b) {
  56. return a
  57. }
  58. },
  59. type: 'value',
  60. }],
  61. series: [{
  62. type: 'line',
  63. data: ydata,
  64. smooth: true, //这句就是让曲线变平滑的
  65. lineStyle: {
  66. normal: {
  67. color: '#33cdff',
  68. }
  69. },
  70. areaStyle: {
  71. normal: {
  72. color: new echarts.graphic.LinearGradient(
  73. 0, 0, 0, 1, [{
  74. offset: 0,
  75. color: '#FFF'
  76. }, {
  77. offset: 1,
  78. color: '#52A0FD'
  79. }]
  80. )
  81. }
  82. },
  83. }]
  84. };
  85. chart.setOption(option)
  86. console.log(chart)
  87. }
  88. /**
  89. * 交易记录
  90. */
  91. function getBarOption(x, y) {
  92. return {
  93. color: ['#FF6A6A'],
  94. fontSize: "14rpx",
  95. grid: {
  96. top: '3%',
  97. left: "5%",
  98. right: "7%",
  99. bottom: "4%",
  100. containLabel: true,
  101. },
  102. xAxis: {
  103. axisLine: {
  104. show: false
  105. },
  106. axisTick: {
  107. show: false
  108. },
  109. type: 'category',
  110. boundaryGap: false,
  111. data: x
  112. },
  113. yAxis: {
  114. axisLine: {
  115. show: false
  116. },
  117. axisTick: {
  118. show: false
  119. },
  120. type: 'value',
  121. splitLine: {
  122. lineStyle: {
  123. type: 'none'
  124. }
  125. },
  126. axisLabel: {
  127. rotate: 40,
  128. }
  129. },
  130. series: [{
  131. data: y,
  132. type: 'line',
  133. smooth: true,
  134. lineStyle: {
  135. normal: {
  136. color: '#FF6A6A',
  137. }
  138. },
  139. areaStyle: {}
  140. }]
  141. };
  142. };
  143. /**
  144. * 核销记录
  145. */
  146. function getScatterOption(x, y) {
  147. return {
  148. color: '#FFCE00',
  149. fontSize: "14rpx",
  150. grid: {
  151. top: '3%',
  152. left: "5%",
  153. right: "7%",
  154. bottom: "4%",
  155. containLabel: true,
  156. },
  157. xAxis: {
  158. axisLine: {
  159. show: false
  160. },
  161. axisTick: {
  162. show: false
  163. },
  164. type: 'category',
  165. boundaryGap: false,
  166. data: x
  167. },
  168. yAxis: {
  169. axisLine: {
  170. show: false
  171. },
  172. axisTick: {
  173. show: false
  174. },
  175. type: 'value',
  176. splitLine: {
  177. lineStyle: {
  178. type: 'none'
  179. }
  180. },
  181. axisLabel: {
  182. rotate: 40,
  183. }
  184. },
  185. series: [{
  186. data: y,
  187. type: 'line',
  188. smooth: true,
  189. areaStyle: {}
  190. }]
  191. };
  192. };
  193. /**
  194. * 获取交易记录
  195. */
  196. function getTabletListOrder() {
  197. let newArr = {
  198. xList: [],
  199. amountList: []
  200. }
  201. return new Promise((resolve, reject) => {
  202. Http.getRequest(config.api.dateAmountRecordListOrder, app.globalData.token, '', {}, (res) => {
  203. // 日期
  204. res.data && res.data.map(file => {
  205. newArr.xList.push(file.mouthAndDate)
  206. newArr.amountList.push(file.amountStr)
  207. })
  208. resolve(newArr);
  209. })
  210. })
  211. };
  212. /**
  213. * 获取核销记录
  214. */
  215. function getTabletListVerify() {
  216. let newArr = {
  217. xList: [],
  218. amountList: []
  219. }
  220. return new Promise((resolve, reject) => {
  221. Http.getRequest(config.api.dateAmountRecordListVerified, app.globalData.token, '', {}, (res) => {
  222. // 日期
  223. res.data && res.data.map(file => {
  224. newArr.xList.push(file.mouthAndDate)
  225. newArr.amountList.push(file.amountStr)
  226. })
  227. resolve(newArr)
  228. })
  229. })
  230. };
  231. Page({
  232. data: {
  233. token: '',
  234. currentIndex: 0,
  235. userInfo: {},
  236. recordMoney: 0,
  237. recordData: [],
  238. userInfoLoadIf: false,
  239. ec: {
  240. lazyLoad: true
  241. },
  242. classIfyList2: [{
  243. text: '服务预约',
  244. icon: 'iconfont icon-lingquanzhongxin',
  245. id: 9
  246. }],
  247. classIfyList: [
  248. // {
  249. // text: '收银台',
  250. // icon: 'iconfont icon-shouyintai1',
  251. // id: 3
  252. // },
  253. {
  254. text: '会员核销',
  255. icon: 'iconfont icon-hexiao',
  256. id: 0
  257. },
  258. // {
  259. // text: '消费卡收款',
  260. // icon: 'iconfont icon-shouye1',
  261. // id: 1
  262. // },
  263. // {
  264. // text: '当日解单',
  265. // icon: 'iconfont icon-shoufukuan',
  266. // id: 2
  267. // },
  268. {
  269. text: '会员积分',
  270. icon: 'iconfont icon-jifen',
  271. id: 4
  272. },
  273. // {
  274. // text: '会员赠券',
  275. // icon: 'iconfont icon-quan',
  276. // id: 5
  277. // },
  278. {
  279. text: '营销结算',
  280. icon: 'iconfont icon-jiesuan',
  281. id: 6
  282. },
  283. // {
  284. // text: '商户建券',
  285. // icon: 'iconfont icon-lingquanzhongxin',
  286. // id: 7
  287. // },
  288. // {
  289. // text: '商品配送',
  290. // icon: 'iconfont icon-wuliu',
  291. // id: 8
  292. // }
  293. {
  294. text: '服务预约',
  295. icon: 'iconfont icon-lingquanzhongxin',
  296. id: 9
  297. },
  298. ],
  299. amountMoney: '',
  300. djZmoney: '',
  301. writeOffMoney: '',
  302. getFullYear: new Date().getFullYear(),
  303. getMonth: new Date().getMonth() + 1,
  304. getDate: new Date().getDate(),
  305. dateTime: '',
  306. show: null,
  307. billList: [],
  308. ifShowChart: null,
  309. ifShowChart1: null,
  310. ifShowChart2: null,
  311. ecBar: {
  312. lazyLoad: true
  313. },
  314. ecScatter: {
  315. lazyLoad: true
  316. },
  317. djArr: [],
  318. djMoney: [],
  319. count: ''
  320. },
  321. //获取商户信息
  322. getUserInfo() {
  323. return new Promise((resolve, reject) => {
  324. Http.getRequest(config.api.userDetail, app.globalData.token, '', {}, (res) => {
  325. app.globalData.isAdmin = res.data.is_admin;
  326. resolve(res.data);
  327. })
  328. })
  329. },
  330. //今日交易额
  331. getUnverifiedAmountOnDate() {
  332. let {
  333. getFullYear,
  334. getMonth,
  335. getDate,
  336. amountMoney,
  337. writeOffMoney
  338. } = this.data
  339. let dateTimer = getFullYear + '-' + getMonth + '-' + getDate
  340. Http.getRequest(config.api.getUnverifiedAmountOnDate, app.globalData.token, '', {
  341. date: dateTimer
  342. }, (res) => {
  343. console.log(res)
  344. this.setData({
  345. amountMoney: res.data.amount,
  346. count: res.data.orderCount,
  347. })
  348. })
  349. },
  350. //今日核销额
  351. getVerifiedAmountOnDate() {
  352. let {
  353. getFullYear,
  354. getMonth,
  355. getDate
  356. } = this.data
  357. let dateTimer = getFullYear + '-' + getMonth + '-' + getDate
  358. Http.getRequest(config.api.getVerifiedAmountOnDate, app.globalData.token, '', {
  359. date: dateTimer
  360. }, (res) => {
  361. this.setData({
  362. writeOffMoney: res.data.amount
  363. })
  364. })
  365. },
  366. onPullDownRefresh: function () {
  367. let that = this;
  368. // that.getUnverifiedAmountOnDate()
  369. // that.getVerifiedAmountOnDate();
  370. that.getpaybill();
  371. if (that.oneComponent) {
  372. that.getrecordData();
  373. }
  374. if (that.jiaoyiComponent) {
  375. that.getTabletListOrder();
  376. }
  377. if (that.hexiaoComponent) {
  378. that.getTabletListVerify();
  379. }
  380. tt.hideNavigationBarLoading();
  381. tt.stopPullDownRefresh();
  382. },
  383. onLoad: function (options) {
  384. var that = this;
  385. // this.checkuserstatus()
  386. },
  387. onReady() {
  388. // this.oneComponent = this.selectComponent('#mychart-pament');
  389. // this.jiaoyiComponent = this.selectComponent('#mychart-jiaoyi');
  390. // this.hexiaoComponent = this.selectComponent('#mychart-hexiao');
  391. this.getrecordData();
  392. this.getTabletListOrder();
  393. this.getTabletListVerify();
  394. this.getUserInfo().then(res => {
  395. this.setData({
  396. userInfo: res,
  397. userInfoLoadIf: true
  398. })
  399. app.globalData.merchant = res;
  400. tt.setNavigationBarTitle({
  401. title: res.mall_name + "(" + res.merchant_name + ")"
  402. })
  403. })
  404. app.globalData.userInfo = this.getUserInfo;
  405. },
  406. /**
  407. * gotolook
  408. */
  409. gotobill: function (e) {
  410. console.log(e)
  411. let owe = e.currentTarget.dataset.data.owe;
  412. let status = e.currentTarget.dataset.data.status;
  413. let receivedate = e.currentTarget.dataset.data.receiveDate;
  414. let starttime = e.currentTarget.dataset.data.starttime;
  415. let endtime = e.currentTarget.dataset.data.endtime;
  416. let id = e.currentTarget.dataset.data.id;
  417. var transactionId = e.currentTarget.dataset.data.transactionId;
  418. var priceDetail = e.currentTarget.dataset.data.priceDetail;
  419. var freeze = e.currentTarget.dataset.data.freeze;
  420. let pay = e.currentTarget.dataset.data.pay ? e.currentTarget.dataset.data.pay : 0;
  421. let latePayPrice = e.currentTarget.dataset.data.latePayPrice ? e.currentTarget.dataset.data.latePayPrice : 0;
  422. let serviceChargePay = e.currentTarget.dataset.data.serviceChargePay ? e.currentTarget.dataset.data.serviceChargePay : 0;
  423. if (starttime && endtime) {
  424. var end = starttime + "至" + endtime;
  425. } else {
  426. var end = "";
  427. }
  428. if (transactionId) {
  429. var tradeTime = e.currentTarget.dataset.data.tradeTime;
  430. } else {
  431. var tradeTime = e.currentTarget.dataset.data.payDate;
  432. }
  433. console.log(e.currentTarget.dataset.data, tradeTime, 6666666)
  434. var billTypeValue = e.currentTarget.dataset.data.billTypeValue;
  435. let receivePay = e.currentTarget.dataset.data.receivePay;
  436. tt.navigateTo({
  437. url: `/pages/bill/billdetail/index?owe=${owe}&receivedate=${receivedate}&status=${status}&end=${end}&id=${id}&tradeTime=${tradeTime}&transactionId=${transactionId}&priceDetail=${priceDetail}&billTypeValue=${billTypeValue}&receivePay=${receivePay}&freeze=${freeze}&pay=${pay}&latePayPrice=${latePayPrice}&serviceChargePay=${serviceChargePay}`,
  438. })
  439. },
  440. /**
  441. * 核销记录
  442. */
  443. // hexiaoInit: function(heXiaox, heXiaoYiy) {
  444. // this.hexiaoComponent.init((canvas, width, height) => {
  445. // const barChart = echarts.init(canvas, null, {
  446. // width: width,
  447. // height: height
  448. // });
  449. // canvas.setChart(barChart);
  450. // barChart.setOption(getScatterOption(heXiaox, heXiaoYiy));
  451. // return barChart;
  452. // });
  453. // },
  454. /**
  455. * 交易记录
  456. */
  457. // jiaoyiInit: function(jiaoYix, jiaoYiy) {
  458. // this.jiaoyiComponent.init((canvas, width, height) => {
  459. // const barChart = echarts.init(canvas, null, {
  460. // width: width,
  461. // height: height
  462. // });
  463. // canvas.setChart(barChart);
  464. // barChart.setOption(getBarOption(jiaoYix, jiaoYiy));
  465. // return barChart;
  466. // });
  467. // },
  468. // init_one: function(xdata, ydata) { //初始化第一个图表
  469. // console.log(this.oneComponent, xdata, ydata)
  470. // this.oneComponent.init((canvas, width, height) => {
  471. // const chart = echarts.init(canvas, null, {
  472. // width: width,
  473. // height: height
  474. // });
  475. // console.log(chart, xdata, ydata)
  476. // setOption(chart, xdata, ydata)
  477. // this.chart = chart;
  478. // return chart;
  479. // });
  480. // },
  481. toWriteoff(e) {
  482. console.log(e)
  483. let id = e.currentTarget.dataset.id
  484. console.log(id)
  485. if (id == 0) {
  486. tt.navigateTo({
  487. url: '/pages/scan/scan',
  488. })
  489. } else if (id == 1) {
  490. // 优惠卡收款
  491. tt.navigateTo({
  492. url: '/pages/cardReceive/cardReceive',
  493. })
  494. } else if (id == 2) {
  495. tt.navigateTo({
  496. url: '/pages/main/solution/solution',
  497. })
  498. } else if (id == 3) {
  499. tt.navigateTo({
  500. url: '/pages/payment/index',
  501. })
  502. } else if (id == 4) {
  503. tt.navigateTo({
  504. url: '/pages/creditSelect/index',
  505. })
  506. } else if (id == 5) {
  507. tt.navigateTo({
  508. url: '/pages/incouponSelect/index',
  509. })
  510. } else if (id == 6) {
  511. tt.navigateTo({
  512. url: '/pages/marktingsettlement/marktingsettlement',
  513. })
  514. } else if (id == 7) { //用户发卷
  515. tt.navigateTo({
  516. url: '/pages/sendDiscounts/sendDiscounts',
  517. })
  518. } else if (id == 8) { //商品配送
  519. tt.navigateTo({
  520. url: '/pages/delivery/delivery',
  521. })
  522. } else if (id == 9) { //服务预约
  523. tt.navigateTo({
  524. url: '/pages/Appointment/appointment',
  525. })
  526. }
  527. },
  528. toTran(e) {
  529. let type = e.currentTarget.dataset.type
  530. tt.navigateTo({
  531. url: `./transaction/transaction?type=${type}`,
  532. })
  533. },
  534. onShow() {
  535. let that = this;
  536. /**
  537. * 交易记录
  538. */
  539. if (that.oneComponent) {
  540. that.getrecordData();
  541. }
  542. if (that.jiaoyiComponent) {
  543. that.getTabletListOrder();
  544. }
  545. if (that.hexiaoComponent) {
  546. that.getTabletListVerify();
  547. }
  548. /**
  549. * 获得交易记录和核销额
  550. */
  551. that.getUnverifiedAmountOnDate();
  552. that.getVerifiedAmountOnDate();
  553. that.getpaybill();
  554. that.setData({
  555. currentIndex: 0
  556. })
  557. },
  558. getpaybill: function () {
  559. let that = this;
  560. that.getUserInfo().then(res => {
  561. Http.postRequest(config.api.listBillOweAndWaitPay, app.globalData.token, '', {
  562. merchantId: res.merchant_id,
  563. tenantId: res.tenant_id,
  564. }, (res) => {
  565. console.log(res);
  566. if (res && res.data) {
  567. res.data.map(file => {
  568. if (file.starttime && file.endtime) {
  569. file.end = file.starttime.substring(0, 7).replace(/-/g, ".") + "-" + file.endtime.substring(0, 7).replace(/-/g, ".");
  570. } else {
  571. file.end = "";
  572. file.endtime = ""
  573. }
  574. file.receiveDate = util.fmtDate(file.receiveDate);
  575. })
  576. that.setData({
  577. billList: res.data,
  578. djArr: res.data.filter(item => item.status == 2),
  579. })
  580. that.data.djMoney = that.data.djArr.map(item => parseInt(item.owe / 100))
  581. let money = 0
  582. that.data.djMoney.filter(function (item, index) {
  583. money += item;
  584. })
  585. that.setData({
  586. djZmoney: changeNum.changePeoNumber(money)
  587. })
  588. }
  589. })
  590. })
  591. },
  592. getTabletListVerify: function () {
  593. let that = this;
  594. getTabletListVerify()
  595. .then(res => {
  596. if (res.xList.length > 0 && res.amountList.length > 0) {
  597. that.setData({
  598. ifShowChart1: 'show1'
  599. })
  600. // that.hexiaoInit(res.xList, res.amountList)
  601. } else {
  602. /**
  603. * 判断是否显示数据表
  604. */
  605. that.setData({
  606. ifShowChart1: 'show'
  607. })
  608. }
  609. })
  610. },
  611. /**
  612. * 交易
  613. */
  614. getTabletListOrder: function () {
  615. let that = this;
  616. getTabletListOrder()
  617. .then(res => {
  618. console.log(res);
  619. if (res.xList.length > 0 && res.amountList.length > 0) {
  620. // that.jiaoyiInit(res.xList, res.amountList)
  621. that.setData({
  622. ifShowChart: 'show1'
  623. })
  624. } else {
  625. /**
  626. * 判断是否显示数据表
  627. */
  628. that.setData({
  629. ifShowChart: 'show'
  630. })
  631. }
  632. })
  633. },
  634. /**
  635. * 收银记录
  636. */
  637. getrecordData() {
  638. let _this = this;
  639. HttpBasics.get({
  640. url: config.api.getMicroPayAmountOnDate
  641. })
  642. .then(res => {
  643. _this.setData({
  644. recordMoney: res.data.amount
  645. })
  646. })
  647. .catch(err => {
  648. tt.showToast({
  649. title: err.message,
  650. icon: 'none',
  651. duration: 2000,
  652. mask: false
  653. });
  654. });
  655. HttpBasics.get({
  656. url: config.api.listMicropay
  657. })
  658. .then(res => {
  659. let dataX = [];
  660. let dataY = [];
  661. if (res.data && res.data.length > 0) {
  662. _this.setData({
  663. ifShowChart2: "show1"
  664. })
  665. res.data.map((item, index) => {
  666. dataX.push(item.mouthAndDate)
  667. dataY.push(Number(item.amountStr))
  668. })
  669. // _this.init_one(dataX, dataY)
  670. } else {
  671. _this.setData({
  672. ifShowChart2: "show"
  673. })
  674. }
  675. })
  676. .catch(err => {
  677. tt.showToast({
  678. title: err.message,
  679. icon: 'none',
  680. duration: 2000,
  681. mask: false
  682. });
  683. });
  684. },
  685. toTran(e) {
  686. let type = e.currentTarget.dataset.type
  687. tt.navigateTo({
  688. url: `/pages/transaction/transaction?type=${type}`,
  689. })
  690. },
  691. toRecord() {
  692. tt.navigateTo({
  693. url: `/pages/record/list/index`,
  694. })
  695. },
  696. // checkuserstatus() {
  697. // let _this = this;
  698. // HttpBasics.get({
  699. // url: config.api.checkPhoneStatus
  700. // })
  701. // .then(res => {
  702. // })
  703. // .catch(err => {
  704. // if (err.code == 11005) {
  705. // tt.redirectTo({
  706. // url: `/pages/getuserinfo/index`
  707. // })
  708. // }
  709. // });
  710. // },
  711. })