抖音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.

713 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. classIfyList: [
  243. // {
  244. // text: '收银台',
  245. // icon: 'iconfont icon-shouyintai1',
  246. // id: 3
  247. // },
  248. {
  249. text: '会员核销',
  250. icon: 'iconfont icon-hexiao',
  251. id: 0
  252. },
  253. // {
  254. // text: '消费卡收款',
  255. // icon: 'iconfont icon-shouye1',
  256. // id: 1
  257. // },
  258. // {
  259. // text: '当日解单',
  260. // icon: 'iconfont icon-shoufukuan',
  261. // id: 2
  262. // },
  263. {
  264. text: '会员积分',
  265. icon: 'iconfont icon-jifen',
  266. id: 4
  267. },
  268. // {
  269. // text: '会员赠券',
  270. // icon: 'iconfont icon-quan',
  271. // id: 5
  272. // },
  273. {
  274. text: '营销结算',
  275. icon: 'iconfont icon-jiesuan',
  276. id: 6
  277. },
  278. // {
  279. // text: '商户建券',
  280. // icon: 'iconfont icon-lingquanzhongxin',
  281. // id: 7
  282. // },
  283. // {
  284. // text: '商品配送',
  285. // icon: 'iconfont icon-wuliu',
  286. // id: 8
  287. // }
  288. {
  289. text: '服务预约',
  290. icon: 'iconfont icon-lingquanzhongxin',
  291. id: 9
  292. },
  293. ],
  294. amountMoney: '',
  295. djZmoney: '',
  296. writeOffMoney: '',
  297. getFullYear: new Date().getFullYear(),
  298. getMonth: new Date().getMonth() + 1,
  299. getDate: new Date().getDate(),
  300. dateTime: '',
  301. show: null,
  302. billList: [],
  303. ifShowChart: null,
  304. ifShowChart1: null,
  305. ifShowChart2: null,
  306. ecBar: {
  307. lazyLoad: true
  308. },
  309. ecScatter: {
  310. lazyLoad: true
  311. },
  312. djArr: [],
  313. djMoney: [],
  314. count: ''
  315. },
  316. //获取商户信息
  317. getUserInfo() {
  318. return new Promise((resolve, reject) => {
  319. Http.getRequest(config.api.userDetail, app.globalData.token, '', {}, (res) => {
  320. resolve(res.data);
  321. })
  322. })
  323. },
  324. //今日交易额
  325. getUnverifiedAmountOnDate() {
  326. let {
  327. getFullYear,
  328. getMonth,
  329. getDate,
  330. amountMoney,
  331. writeOffMoney
  332. } = this.data
  333. let dateTimer = getFullYear + '-' + getMonth + '-' + getDate
  334. Http.getRequest(config.api.getUnverifiedAmountOnDate, app.globalData.token, '', {
  335. date: dateTimer
  336. }, (res) => {
  337. console.log(res)
  338. this.setData({
  339. amountMoney: res.data.amount,
  340. count: res.data.orderCount,
  341. })
  342. })
  343. },
  344. //今日核销额
  345. getVerifiedAmountOnDate() {
  346. let {
  347. getFullYear,
  348. getMonth,
  349. getDate
  350. } = this.data
  351. let dateTimer = getFullYear + '-' + getMonth + '-' + getDate
  352. Http.getRequest(config.api.getVerifiedAmountOnDate, app.globalData.token, '', {
  353. date: dateTimer
  354. }, (res) => {
  355. this.setData({
  356. writeOffMoney: res.data.amount
  357. })
  358. })
  359. },
  360. onPullDownRefresh: function () {
  361. let that = this;
  362. // that.getUnverifiedAmountOnDate()
  363. // that.getVerifiedAmountOnDate();
  364. that.getpaybill();
  365. if (that.oneComponent) {
  366. that.getrecordData();
  367. }
  368. if (that.jiaoyiComponent) {
  369. that.getTabletListOrder();
  370. }
  371. if (that.hexiaoComponent) {
  372. that.getTabletListVerify();
  373. }
  374. tt.hideNavigationBarLoading();
  375. tt.stopPullDownRefresh();
  376. },
  377. onLoad: function (options) {
  378. var that = this;
  379. // this.checkuserstatus()
  380. },
  381. onReady() {
  382. // this.oneComponent = this.selectComponent('#mychart-pament');
  383. // this.jiaoyiComponent = this.selectComponent('#mychart-jiaoyi');
  384. // this.hexiaoComponent = this.selectComponent('#mychart-hexiao');
  385. this.getrecordData();
  386. this.getTabletListOrder();
  387. this.getTabletListVerify();
  388. this.getUserInfo().then(res => {
  389. this.setData({
  390. userInfo: res,
  391. userInfoLoadIf: true
  392. })
  393. app.globalData.merchant = res;
  394. tt.setNavigationBarTitle({
  395. title: res.mall_name + "(" + res.merchant_name + ")"
  396. })
  397. })
  398. app.globalData.userInfo = this.getUserInfo;
  399. },
  400. /**
  401. * gotolook
  402. */
  403. gotobill: function (e) {
  404. console.log(e)
  405. let owe = e.currentTarget.dataset.data.owe;
  406. let status = e.currentTarget.dataset.data.status;
  407. let receivedate = e.currentTarget.dataset.data.receiveDate;
  408. let starttime = e.currentTarget.dataset.data.starttime;
  409. let endtime = e.currentTarget.dataset.data.endtime;
  410. let id = e.currentTarget.dataset.data.id;
  411. var transactionId = e.currentTarget.dataset.data.transactionId;
  412. var priceDetail = e.currentTarget.dataset.data.priceDetail;
  413. var freeze = e.currentTarget.dataset.data.freeze;
  414. let pay = e.currentTarget.dataset.data.pay ? e.currentTarget.dataset.data.pay : 0;
  415. let latePayPrice = e.currentTarget.dataset.data.latePayPrice ? e.currentTarget.dataset.data.latePayPrice : 0;
  416. let serviceChargePay = e.currentTarget.dataset.data.serviceChargePay ? e.currentTarget.dataset.data.serviceChargePay : 0;
  417. if (starttime && endtime) {
  418. var end = starttime + "至" + endtime;
  419. } else {
  420. var end = "";
  421. }
  422. if (transactionId) {
  423. var tradeTime = e.currentTarget.dataset.data.tradeTime;
  424. } else {
  425. var tradeTime = e.currentTarget.dataset.data.payDate;
  426. }
  427. console.log(e.currentTarget.dataset.data, tradeTime, 6666666)
  428. var billTypeValue = e.currentTarget.dataset.data.billTypeValue;
  429. let receivePay = e.currentTarget.dataset.data.receivePay;
  430. tt.navigateTo({
  431. 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}`,
  432. })
  433. },
  434. /**
  435. * 核销记录
  436. */
  437. // hexiaoInit: function(heXiaox, heXiaoYiy) {
  438. // this.hexiaoComponent.init((canvas, width, height) => {
  439. // const barChart = echarts.init(canvas, null, {
  440. // width: width,
  441. // height: height
  442. // });
  443. // canvas.setChart(barChart);
  444. // barChart.setOption(getScatterOption(heXiaox, heXiaoYiy));
  445. // return barChart;
  446. // });
  447. // },
  448. /**
  449. * 交易记录
  450. */
  451. // jiaoyiInit: function(jiaoYix, jiaoYiy) {
  452. // this.jiaoyiComponent.init((canvas, width, height) => {
  453. // const barChart = echarts.init(canvas, null, {
  454. // width: width,
  455. // height: height
  456. // });
  457. // canvas.setChart(barChart);
  458. // barChart.setOption(getBarOption(jiaoYix, jiaoYiy));
  459. // return barChart;
  460. // });
  461. // },
  462. // init_one: function(xdata, ydata) { //初始化第一个图表
  463. // console.log(this.oneComponent, xdata, ydata)
  464. // this.oneComponent.init((canvas, width, height) => {
  465. // const chart = echarts.init(canvas, null, {
  466. // width: width,
  467. // height: height
  468. // });
  469. // console.log(chart, xdata, ydata)
  470. // setOption(chart, xdata, ydata)
  471. // this.chart = chart;
  472. // return chart;
  473. // });
  474. // },
  475. toWriteoff(e) {
  476. console.log(e)
  477. let id = e.currentTarget.dataset.id
  478. console.log(id)
  479. if (id == 0) {
  480. tt.navigateTo({
  481. url: '/pages/scan/scan',
  482. })
  483. } else if (id == 1) {
  484. // 优惠卡收款
  485. tt.navigateTo({
  486. url: '/pages/cardReceive/cardReceive',
  487. })
  488. } else if (id == 2) {
  489. tt.navigateTo({
  490. url: '/pages/main/solution/solution',
  491. })
  492. } else if (id == 3) {
  493. tt.navigateTo({
  494. url: '/pages/payment/index',
  495. })
  496. } else if (id == 4) {
  497. tt.navigateTo({
  498. url: '/pages/creditSelect/index',
  499. })
  500. } else if (id == 5) {
  501. tt.navigateTo({
  502. url: '/pages/incouponSelect/index',
  503. })
  504. } else if (id == 6) {
  505. tt.navigateTo({
  506. url: '/pages/marktingsettlement/marktingsettlement',
  507. })
  508. } else if (id == 7) { //用户发卷
  509. tt.navigateTo({
  510. url: '/pages/sendDiscounts/sendDiscounts',
  511. })
  512. } else if (id == 8) { //商品配送
  513. tt.navigateTo({
  514. url: '/pages/delivery/delivery',
  515. })
  516. } else if (id == 9) { //服务预约
  517. tt.navigateTo({
  518. url: '/pages/Appointment/appointment',
  519. })
  520. }
  521. },
  522. toTran(e) {
  523. let type = e.currentTarget.dataset.type
  524. tt.navigateTo({
  525. url: `./transaction/transaction?type=${type}`,
  526. })
  527. },
  528. onShow() {
  529. let that = this;
  530. /**
  531. * 交易记录
  532. */
  533. if (that.oneComponent) {
  534. that.getrecordData();
  535. }
  536. if (that.jiaoyiComponent) {
  537. that.getTabletListOrder();
  538. }
  539. if (that.hexiaoComponent) {
  540. that.getTabletListVerify();
  541. }
  542. /**
  543. * 获得交易记录和核销额
  544. */
  545. that.getUnverifiedAmountOnDate();
  546. that.getVerifiedAmountOnDate();
  547. that.getpaybill();
  548. that.setData({
  549. currentIndex: 0
  550. })
  551. },
  552. getpaybill: function () {
  553. let that = this;
  554. that.getUserInfo().then(res => {
  555. Http.postRequest(config.api.listBillOweAndWaitPay, app.globalData.token, '', {
  556. merchantId: res.merchant_id,
  557. tenantId: res.tenant_id,
  558. }, (res) => {
  559. console.log(res);
  560. if (res) {
  561. res.data.map(file => {
  562. if (file.starttime && file.endtime) {
  563. file.end = file.starttime.substring(0, 7).replace(/-/g, ".") + "-" + file.endtime.substring(0, 7).replace(/-/g, ".");
  564. } else {
  565. file.end = "";
  566. file.endtime = ""
  567. }
  568. file.receiveDate = util.fmtDate(file.receiveDate);
  569. })
  570. that.setData({
  571. billList: res.data,
  572. djArr: res.data.filter(item => item.status == 2),
  573. })
  574. that.data.djMoney = that.data.djArr.map(item => parseInt(item.owe / 100))
  575. let money = 0
  576. that.data.djMoney.filter(function (item, index) {
  577. money += item;
  578. })
  579. that.setData({
  580. djZmoney: changeNum.changePeoNumber(money)
  581. })
  582. }
  583. })
  584. })
  585. },
  586. getTabletListVerify: function () {
  587. let that = this;
  588. getTabletListVerify()
  589. .then(res => {
  590. if (res.xList.length > 0 && res.amountList.length > 0) {
  591. that.setData({
  592. ifShowChart1: 'show1'
  593. })
  594. // that.hexiaoInit(res.xList, res.amountList)
  595. } else {
  596. /**
  597. * 判断是否显示数据表
  598. */
  599. that.setData({
  600. ifShowChart1: 'show'
  601. })
  602. }
  603. })
  604. },
  605. /**
  606. * 交易
  607. */
  608. getTabletListOrder: function () {
  609. let that = this;
  610. getTabletListOrder()
  611. .then(res => {
  612. console.log(res);
  613. if (res.xList.length > 0 && res.amountList.length > 0) {
  614. // that.jiaoyiInit(res.xList, res.amountList)
  615. that.setData({
  616. ifShowChart: 'show1'
  617. })
  618. } else {
  619. /**
  620. * 判断是否显示数据表
  621. */
  622. that.setData({
  623. ifShowChart: 'show'
  624. })
  625. }
  626. })
  627. },
  628. /**
  629. * 收银记录
  630. */
  631. getrecordData() {
  632. let _this = this;
  633. HttpBasics.get({
  634. url: config.api.getMicroPayAmountOnDate
  635. })
  636. .then(res => {
  637. _this.setData({
  638. recordMoney: res.data.amount
  639. })
  640. })
  641. .catch(err => {
  642. tt.showToast({
  643. title: err.message,
  644. icon: 'none',
  645. duration: 2000,
  646. mask: false
  647. });
  648. });
  649. HttpBasics.get({
  650. url: config.api.listMicropay
  651. })
  652. .then(res => {
  653. let dataX = [];
  654. let dataY = [];
  655. if (res.data && res.data.length > 0) {
  656. _this.setData({
  657. ifShowChart2: "show1"
  658. })
  659. res.data.map((item, index) => {
  660. dataX.push(item.mouthAndDate)
  661. dataY.push(Number(item.amountStr))
  662. })
  663. // _this.init_one(dataX, dataY)
  664. } else {
  665. _this.setData({
  666. ifShowChart2: "show"
  667. })
  668. }
  669. })
  670. .catch(err => {
  671. tt.showToast({
  672. title: err.message,
  673. icon: 'none',
  674. duration: 2000,
  675. mask: false
  676. });
  677. });
  678. },
  679. toTran(e) {
  680. let type = e.currentTarget.dataset.type
  681. tt.navigateTo({
  682. url: `/pages/transaction/transaction?type=${type}`,
  683. })
  684. },
  685. toRecord() {
  686. tt.navigateTo({
  687. url: `/pages/record/list/index`,
  688. })
  689. },
  690. // checkuserstatus() {
  691. // let _this = this;
  692. // HttpBasics.get({
  693. // url: config.api.checkPhoneStatus
  694. // })
  695. // .then(res => {
  696. // })
  697. // .catch(err => {
  698. // if (err.code == 11005) {
  699. // tt.redirectTo({
  700. // url: `/pages/getuserinfo/index`
  701. // })
  702. // }
  703. // });
  704. // },
  705. })