orderBoard.js 19 KB

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