serviceOrder.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  1. const app = getApp()
  2. const util = require("../../../utils/jmsUtil.js");
  3. const api = require('../../../api/jms.js');
  4. import moment from 'moment'
  5. Page({
  6. data: {
  7. timer: "",
  8. dayCalendar: {
  9. day: '',
  10. workerOrderInfoDTOList: [],
  11. workerName: '',
  12. //isCashout:false//是否可提现
  13. },
  14. currentMonth: moment(new Date()).format('YYYY-MM'),
  15. calcendarFold: true,
  16. stickShow: false,
  17. today: util.formetdate(new Date()),
  18. currentDay: util.formetdate(new Date()),
  19. isLeaveFold: true,
  20. orderDisable: true,
  21. orderDisable1: false,
  22. activeTab: 1,
  23. ticketList: [{}, {}],
  24. monthInfo: {
  25. recCode: '',
  26. fraName: '',
  27. workerName: '',
  28. isCashout: false, //是否可提现
  29. },
  30. workerDayInfoList: [],
  31. weekCalendar: [],
  32. wholeCalendar: [],
  33. myqr_show: false,
  34. myqr_url: '',
  35. myqr_blur: 0, //背景模糊值
  36. options: [{
  37. value: "rebuy",
  38. text: '复购码'
  39. },{
  40. value: "coupon",
  41. text: '优惠券'
  42. }],
  43. itemValue:''
  44. },
  45. onPageScroll(e) {
  46. // console.log(e.scrollTop);
  47. // if(e.scrollTop > 200){
  48. // this.setData({
  49. // stickShow: true
  50. // });
  51. // } else {
  52. // this.setData({
  53. // stickShow: false
  54. // });
  55. // }
  56. },
  57. leaveFold() {
  58. let fold = this.data.isLeaveFold;
  59. this.setData({
  60. isLeaveFold: !fold
  61. });
  62. },
  63. goCash() {
  64. wx.navigateTo({
  65. url: '/pages/temp/cash/index',
  66. })
  67. },
  68. copyCode(e) {
  69. let code = this.data.monthInfo.recCode;
  70. wx.setClipboardData({
  71. data: code,
  72. success: function (res) {
  73. wx.showToast({
  74. title: '复制成功',
  75. icon: 'none',
  76. duration: 2000
  77. });
  78. }
  79. })
  80. },
  81. copyNum(e) {
  82. let bookno = e.currentTarget.dataset.bookno;
  83. console.log(bookno);
  84. wx.setClipboardData({
  85. data: bookno,
  86. success: function (res) {
  87. wx.showToast({
  88. title: '复制成功',
  89. icon: 'none',
  90. duration: 2000
  91. });
  92. }
  93. })
  94. },
  95. callUp(e) {
  96. let status = e.currentTarget.dataset.status;
  97. let phone = e.currentTarget.dataset.phone;
  98. if (status == '待履约' || status == '服务中') {
  99. wx.makePhoneCall({
  100. phoneNumber: phone
  101. });
  102. }
  103. },
  104. openMap(e) { //打开地图
  105. let status = e.currentTarget.dataset.status;
  106. let address = e.currentTarget.dataset.address;
  107. if (status == '待履约' || status == '服务中') {
  108. let lnglat = e.currentTarget.dataset.lnglat.split(',');
  109. let lng = '';
  110. let lat = "";
  111. if (lnglat.length > 0) {
  112. lng = Number(lnglat[0]);
  113. lat = Number(lnglat[1]);
  114. }
  115. console.log(lng, lat);
  116. wx.openLocation({
  117. latitude: lat,
  118. longitude: lng,
  119. // name: address,
  120. address: address,
  121. scale: 28
  122. });
  123. }
  124. },
  125. goSchedule() {
  126. wx.navigateTo({
  127. url: '/pages/upgrade/scheduleCalc/scheduleCalc',
  128. })
  129. },
  130. goDetail(e) {
  131. let id = e.currentTarget.dataset.id;
  132. wx.navigateTo({
  133. url: '/pages/upgrade/ticketDetail/ticketDetail?bookTradeNo=' + id,
  134. });
  135. },
  136. evalMaster(e) {
  137. let id = e.currentTarget.dataset.id;
  138. let workerno = e.currentTarget.dataset.workerno;
  139. this.setData({
  140. evalMasterShow: true,
  141. star: 0,
  142. masterComment: '',
  143. bookTradeNo: id,
  144. workerNo: workerno
  145. });
  146. },
  147. onClickMsterOverlay() {
  148. this.setData({
  149. evalMasterShow: false,
  150. });
  151. },
  152. onClickDiscipleOverlay() {
  153. this.setData({
  154. evalDiscipleShow: false,
  155. });
  156. },
  157. onStarChange(event) {
  158. this.setData({
  159. star: event.detail,
  160. });
  161. },
  162. onRadioChange(event) {
  163. this.setData({
  164. radioDisciple: event.detail,
  165. });
  166. },
  167. bindMasterComment(e) {
  168. this.setData({
  169. masterComment: e.detail.value
  170. })
  171. },
  172. bindDiscipleComment(e) {
  173. this.setData({
  174. discipleComment: e.detail.value
  175. })
  176. },
  177. stop: function () {
  178. //阻止弹框冒泡和捕获的空事件,不要删除!!!
  179. },
  180. submitEvalMaster() {
  181. if (this.data.star == 0) {
  182. wx.showToast({
  183. title: '请选择评价星级',
  184. icon: 'none'
  185. })
  186. } else if (this.data.masterComment == '') {
  187. wx.showToast({
  188. title: '请输入跟单体会',
  189. icon: 'none'
  190. })
  191. } else {
  192. util.request(api.discipleFeedback, {
  193. feedback: this.data.discipleComment,
  194. level: this.data.star,
  195. bookTradeNo: this.data.bookTradeNo,
  196. workerNo: this.data.workerNo
  197. }, 'GET').then(res => {
  198. if (res.errno === 0) {
  199. wx.showToast({
  200. title: '评价成功',
  201. icon: 'none'
  202. })
  203. this.setData({
  204. evalMasterShow: false,
  205. });
  206. this.getDayCalendar();
  207. } else {
  208. wx.showToast({
  209. title: res.errmsg,
  210. icon: 'none'
  211. })
  212. }
  213. });
  214. }
  215. },
  216. evalDisciple(e) {
  217. let id = e.currentTarget.dataset.id;
  218. let workerno = e.currentTarget.dataset.workerno;
  219. this.setData({
  220. evalDiscipleShow: true,
  221. radioDisciple: '通过',
  222. discipleComment: '',
  223. bookTradeNo: id,
  224. workerNo: workerno
  225. });
  226. },
  227. submitEvalDisciple() {
  228. if (this.data.radioDisciple == '') {
  229. wx.showToast({
  230. title: '请选择是否通过',
  231. icon: 'none'
  232. })
  233. } else if (this.data.discipleComment == '') {
  234. wx.showToast({
  235. title: '请输入内容',
  236. icon: 'none'
  237. })
  238. } else {
  239. util.request(api.masterFeedback, {
  240. remark: this.data.discipleComment,
  241. feedback: this.data.radioDisciple,
  242. bookTradeNo: this.data.bookTradeNo,
  243. workerNo: this.data.workerNo
  244. }, 'GET').then(res => {
  245. if (res.errno === 0) {
  246. wx.showToast({
  247. title: '评价成功',
  248. icon: 'none'
  249. })
  250. this.setData({
  251. evalDiscipleShow: false,
  252. });
  253. this.getDayCalendar();
  254. } else {
  255. wx.showToast({
  256. title: res.errmsg,
  257. icon: 'none'
  258. })
  259. }
  260. });
  261. }
  262. },
  263. goProblemList(e) {
  264. // this.setData({
  265. // navigateType: 1
  266. // })
  267. console.log( e.currentTarget.dataset);
  268. let booktradeno = e.currentTarget.dataset.booktradeno;
  269. wx.navigateTo({
  270. url: '/pages/problem/list/list?bookTradeNo=' + booktradeno,
  271. })
  272. },
  273. /**
  274. * 生命周期函数--监听页面加载
  275. */
  276. onLoad: function (options) {
  277. // let current=this.data.wholeCalendar.filter(item=>{return item.day==this.data.currentDay});
  278. // if(current.length==0){
  279. // return false;
  280. // }
  281. // let week=current[0].weekOfYear;
  282. // let weekCalendar=this.data.wholeCalendar.filter(item=>{
  283. // return item.weekOfYear==week;
  284. // });
  285. // this.setData({
  286. // workerDayInfoList:weekCalendar,
  287. // weekCalendar:weekCalendar
  288. // });
  289. this.getMonthCalender(false, 'first');
  290. // this.getDayCalendar();
  291. },
  292. closeMyQr() {
  293. this.setData({
  294. myqr_show: false,
  295. myqr_blur: 0
  296. });
  297. },
  298. goSaveQrcode: function () { //保存二维码图片
  299. let that = this;
  300. console.info(that.data.myqr_url);
  301. wx.downloadFile({
  302. url: that.data.myqr_url,
  303. success: function (res) {
  304. if (res.statusCode === 200) {
  305. let img = res.tempFilePath;
  306. wx.saveImageToPhotosAlbum({
  307. filePath: img,
  308. success(res) {
  309. that.closeMyQr();
  310. wx.showModal({
  311. title: '提示',
  312. showCancel: false,
  313. content: '此单复购专属二维码图片已保存到您的相册'
  314. })
  315. },
  316. fail(res) {
  317. wx.showModal({
  318. title: '提示',
  319. showCancel: false,
  320. content: '网络或授权问题 图片保存失败 请重试'
  321. })
  322. }
  323. })
  324. } else
  325. wx.showModal({
  326. title: '提示',
  327. showCancel: false,
  328. content: '网络或授权问题 图片保存失败 请重试'
  329. })
  330. },
  331. fail(res) {
  332. wx.showModal({
  333. title: '提示',
  334. showCancel: false,
  335. content: '网络或授权问题 图片保存失败 请重试'
  336. })
  337. }
  338. })
  339. },
  340. getCouponCode(e) { //优惠券
  341. let bookno = e.currentTarget.dataset.bookno;
  342. util.request(api.getWorkerCouponCode, {
  343. bookTradeNo: bookno
  344. }, 'GET').then(res => {
  345. if (res.errno === 0) {
  346. wx.showToast({
  347. title: '获取成功',
  348. icon: 'none'
  349. })
  350. this.setData({
  351. myqr_show: true,
  352. myqr_blur: 20,
  353. myqr_url: res.data
  354. });
  355. wx.pageScrollTo({
  356. scrollTop: 0,
  357. });
  358. } else {
  359. wx.showToast({
  360. title: res.errmsg,
  361. icon: 'none'
  362. })
  363. }
  364. });
  365. },
  366. getQrCode(e) { //获取复购码
  367. let bookno = e.currentTarget.dataset.bookno;
  368. util.request(api.getWorkerQrCode, {
  369. bookTradeNo: bookno
  370. }, 'GET').then(res => {
  371. if (res.errno === 0) {
  372. wx.showToast({
  373. title: '获取成功',
  374. icon: 'none'
  375. })
  376. this.setData({
  377. myqr_show: true,
  378. myqr_blur: 20,
  379. myqr_url: res.data
  380. });
  381. wx.pageScrollTo({
  382. scrollTop: 0,
  383. });
  384. } else {
  385. wx.showToast({
  386. title: res.errmsg,
  387. icon: 'none'
  388. })
  389. }
  390. });
  391. },
  392. /**
  393. * 生命周期函数--监听页面显示
  394. */
  395. onShow: function () {
  396. this.getDayCalendar();
  397. let timer = setInterval(() => {
  398. console.log('定时刷新日历数据', new Date());
  399. this.getMonthCalender();
  400. this.getDayCalendar();
  401. }, 2 * 60 * 1000);
  402. this.setData({
  403. timer: timer
  404. });
  405. },
  406. onHide: function () {
  407. console.log('onHide');
  408. clearInterval(this.data.timer);
  409. },
  410. onUnload: function () {
  411. console.log('onunload');
  412. clearInterval(this.data.timer);
  413. },
  414. /**
  415. * 页面相关事件处理函数--监听用户下拉动作
  416. */
  417. onPullDownRefresh: function () {
  418. this.getMonthCalender();
  419. this.getDayCalendar();
  420. },
  421. getDayCalendar() {
  422. wx.showLoading({
  423. title: '加载中...',
  424. });
  425. util.request(api.dayCalender, {
  426. date: this.data.currentDay,
  427. }, 'GET').then(res => {
  428. console.log(res);
  429. wx.hideLoading();
  430. if (res.errno === 0) {
  431. this.setData({
  432. dayCalendar: res.data
  433. });
  434. }
  435. }).catch(err => {
  436. wx.hideLoading();
  437. });
  438. },
  439. getMonthCalender(flag, tag) {
  440. wx.showLoading({
  441. title: '加载中...',
  442. });
  443. util.request(api.monthCalender, {
  444. month: this.data.currentMonth,
  445. }, 'GET').then(res => {
  446. console.log(res);
  447. wx.hideLoading();
  448. if (res.errno === 0) {
  449. this.setData({
  450. monthInfo: res.data,
  451. wholeCalendar: res.data.workerDayInfoList
  452. });
  453. if (flag) {
  454. this.setData({
  455. calcendarFold: false,
  456. workerDayInfoList: this.data.wholeCalendar,
  457. });
  458. }
  459. let current = this.data.wholeCalendar.filter(item => {
  460. return item.day == this.data.currentDay
  461. });
  462. if (current.length == 0) {
  463. return false;
  464. }
  465. let week = current[0].weekOfYear;
  466. let weekCalendar = this.data.wholeCalendar.filter(item => {
  467. return item.weekOfYear == week;
  468. });
  469. this.setData({
  470. weekCalendar: weekCalendar
  471. });
  472. if (tag == 'first') {
  473. this.setData({
  474. workerDayInfoList: weekCalendar,
  475. });
  476. }
  477. if (this.data.calcendarFold) {
  478. this.setData({
  479. workerDayInfoList: weekCalendar,
  480. });
  481. } else {
  482. this.setData({
  483. workerDayInfoList: this.data.wholeCalendar,
  484. });
  485. }
  486. } else {
  487. wx.showToast({
  488. title: res.errmsg,
  489. duration: 3000,
  490. icon: 'none'
  491. });
  492. }
  493. }).catch(err => {
  494. wx.hideLoading();
  495. });
  496. },
  497. switchDay(e) {
  498. let day = e.currentTarget.dataset.day;
  499. this.setData({
  500. currentDay: day
  501. });
  502. this.getDayCalendar();
  503. },
  504. calcendarCollapse() {
  505. let calcendarFold = this.data.calcendarFold;
  506. if (calcendarFold) {
  507. this.setData({
  508. workerDayInfoList: this.data.wholeCalendar,
  509. calcendarFold: !calcendarFold
  510. });
  511. } else {
  512. this.setData({
  513. workerDayInfoList: this.data.weekCalendar,
  514. calcendarFold: !calcendarFold
  515. });
  516. }
  517. },
  518. lastMonth() {
  519. console.log(this.data);
  520. let params = util.getYearMonth(this.data.currentMonth, '-');
  521. this.setData({
  522. currentMonth: params
  523. });
  524. this.getMonthCalender(true);
  525. },
  526. nextMonth() {
  527. let params = util.getYearMonth(this.data.currentMonth, '+');
  528. console.log(params);
  529. this.setData({
  530. currentMonth: params
  531. });
  532. this.getMonthCalender(true);
  533. },
  534. goIssueTicket() {
  535. wx.navigateTo({
  536. url: '/pages/upgrade/issueTicket/issueTicket',
  537. })
  538. },
  539. arriveCus(e) {
  540. let status = e.currentTarget.dataset.status;
  541. let id = e.currentTarget.dataset.id;
  542. if (status == '待履约') {
  543. wx.showModal({
  544. title: '',
  545. content: '确定已经到门?',
  546. success: res => {
  547. if (res.confirm) {
  548. util.request(api.ClockIn, {
  549. relationTradeNo: id,
  550. }, 'POST').then(res => {
  551. if (res.errno === 0) {
  552. wx.showToast({
  553. title: '操作成功'
  554. });
  555. this.getDayCalendar();
  556. } else {
  557. wx.showToast({
  558. title: res.errmsg,
  559. icon: 'none'
  560. });
  561. // util.showErrorToast(res.errmsg);
  562. }
  563. });
  564. }
  565. }
  566. });
  567. }
  568. },
  569. finishOrder(e) {
  570. let status = e.currentTarget.dataset.status;
  571. let id = e.currentTarget.dataset.id;
  572. if (status == '服务中') {
  573. wx.showModal({
  574. title: '',
  575. content: '确定服务完成?',
  576. success: res => {
  577. if (res.confirm) {
  578. util.request(api.ServiceProvided, {
  579. relationTradeNo: id,
  580. }, 'POST').then(res => {
  581. if (res.errno === 0) {
  582. wx.showToast({
  583. title: '操作成功'
  584. });
  585. this.getDayCalendar();
  586. } else {
  587. wx.showToast({
  588. title: res.errmsg,
  589. icon: 'none'
  590. });
  591. // util.showErrorToast(res.errmsg);
  592. }
  593. });
  594. }
  595. }
  596. });
  597. }
  598. },
  599. exitLogin: function () {
  600. wx.showModal({
  601. title: '',
  602. confirmColor: '#b4282d',
  603. content: '退出登录?',
  604. success: function (res) {
  605. if (!res.confirm) {
  606. return;
  607. }
  608. // util.request(api.AuthLogout, {}, 'POST');
  609. app.globalData.hasLogin = false;
  610. wx.removeStorageSync('token');
  611. wx.removeStorageSync('userInfo');
  612. // wx.redirectTo({
  613. // url: '/pages/temp/login/login'
  614. // });
  615. wx.redirectTo({
  616. url: '/pages/index/index'
  617. });
  618. }
  619. })
  620. },
  621. supplyCode(e) {
  622. let bookno = e.currentTarget.dataset.bookno;
  623. if (bookno.startsWith('JZ')) {
  624. bookno = bookno.substr(2);
  625. }
  626. util.request(api.createMakeUpQRCode, {
  627. serviceId: bookno
  628. }, 'GET').then(res => {
  629. if (res.errno === 0) {
  630. let url = res.data;
  631. wx.previewImage({
  632. current: url, // 当前显示图片的http链接
  633. urls: [url] // 需要预览的图片http链接列表
  634. })
  635. } else {
  636. wx.showToast({
  637. title: res.errmsg,
  638. icon: 'none'
  639. })
  640. }
  641. });
  642. },
  643. supplyCode(e){
  644. let bookno = e.currentTarget.dataset.bookno;
  645. if (bookno.startsWith('JZ')) {
  646. bookno = bookno.substr(2);
  647. }
  648. app.globalData.diffId=0;
  649. wx.navigateTo({
  650. url: '/pages/serviceSupply/serviceSupply?bookno='+bookno,
  651. });
  652. },
  653. supplyRecord(e){
  654. let bookno = e.currentTarget.dataset.bookno;
  655. if (bookno.startsWith('JZ')) {
  656. bookno = bookno.substr(2);
  657. }
  658. wx.navigateTo({
  659. url: '/pages/supplyRecord/supplyRecord?bookno='+bookno,
  660. });
  661. },
  662. onReachBottom() {
  663. // if (this.data.totalPages > this.data.page) {
  664. // this.setData({
  665. // page: this.data.page + 1
  666. // });
  667. // this.getGoodsList();
  668. // } else {
  669. // wx.showToast({
  670. // title: '没有更多商品了',
  671. // icon: 'none',
  672. // duration: 2000
  673. // });
  674. // return false;
  675. // }
  676. },
  677. /**
  678. * 生命周期函数--监听页面初次渲染完成
  679. */
  680. onReady: function () {
  681. },
  682. /**
  683. * 页面上拉触底事件的处理函数
  684. */
  685. onReachBottom: function () {
  686. },
  687. /**
  688. * 用户点击右上角分享
  689. */
  690. onShareAppMessage: function () {
  691. },
  692. })