抖音B端厂库
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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