serviceOrder.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. const app = getApp()
  2. const util = require("../../../utils/util");
  3. const api = require('../../../api/api.js');
  4. const user = require('../../../utils/user.js');
  5. // const update = require('../../../api/update.js');
  6. import moment from 'moment'
  7. Page({
  8. data: {
  9. timer: "",
  10. dayCalendar: {
  11. bookTradeNo: '',
  12. workerNo: '',
  13. star: 0,
  14. evalMasterShow: false,
  15. masterComment: '',
  16. evalDiscipleShow: false,
  17. discipleComment: '',
  18. radioDisciple: '通过',
  19. askForLeaveDTOS: [],
  20. workerOrderInfoDTOList: [],
  21. leaveNum: '',
  22. finishWorkerOrder: '',
  23. questionNum: '',
  24. looseOrder: '',
  25. looseOrderCount: '',
  26. cycleOrder: '',
  27. cycleOrderCount: '',
  28. rebuyNum: '',
  29. looseRebuyNum: '',
  30. cycleRebuyNum: '',
  31. },
  32. currentMonth: moment(new Date()).format('YYYY-MM'),
  33. calcendarFold: true,
  34. stickShow: false,
  35. today: util.formetdate(new Date()),
  36. currentDay: util.formetdate(new Date()),
  37. isLeaveFold: true,
  38. orderDisable: true,
  39. orderDisable1: false,
  40. activeTab: 1,
  41. ticketList: [{}, {}],
  42. monthInfo: {
  43. finishWorkerOrder: 0,
  44. orderBonus: 0,
  45. questionNum: 0,
  46. looseOrder: 0,
  47. cycleOrder: 0,
  48. rebuyBonus: 0,
  49. looseRebuyNum: 0,
  50. cycleRebuyNum: 0,
  51. },
  52. workerDayInfoList: [],
  53. weekCalendar: [],
  54. wholeCalendar: [],
  55. },
  56. onPageScroll(e) {
  57. // console.log(e.scrollTop);
  58. // if(e.scrollTop > 200){
  59. // this.setData({
  60. // stickShow: true
  61. // });
  62. // } else {
  63. // this.setData({
  64. // stickShow: false
  65. // });
  66. // }
  67. },
  68. leaveFold() {
  69. let fold = this.data.isLeaveFold;
  70. this.setData({
  71. isLeaveFold: !fold
  72. });
  73. },
  74. copyNum(e) {
  75. let bookno = e.currentTarget.dataset.bookno;
  76. console.log(bookno);
  77. wx.setClipboardData({
  78. data: bookno,
  79. success: function (res) {
  80. wx.showToast({
  81. title: '复制成功',
  82. icon: 'none',
  83. duration: 2000
  84. });
  85. }
  86. })
  87. },
  88. callUp(e) {
  89. let status = e.currentTarget.dataset.status;
  90. let phone = e.currentTarget.dataset.phone;
  91. if (status == '待上门' || status == '待履约' || status == '已预约') {
  92. wx.makePhoneCall({
  93. phoneNumber: phone
  94. });
  95. }
  96. },
  97. getQrCode(e) { //加企微
  98. let channel = e.currentTarget.dataset.channel;
  99. let id = e.currentTarget.dataset.id;
  100. if (channel && channel == '盒马')
  101. channel = 'hm';
  102. else channel = 'p';
  103. wx.navigateTo({
  104. url: '/pages/upgrade/cp/join?channel=' + channel + '&id=' + id,
  105. })
  106. },
  107. openMap(e) { //打开地图
  108. let status = e.currentTarget.dataset.status;
  109. let address = e.currentTarget.dataset.address;
  110. if (status == '待上门' || status == '待履约' || status == '已预约') {
  111. let lnglat = e.currentTarget.dataset.lnglat.split(',');
  112. let lng = '';
  113. let lat = "";
  114. if (lnglat.length > 0) {
  115. lng = Number(lnglat[0]);
  116. lat = Number(lnglat[1]);
  117. }
  118. console.log(lng, lat);
  119. wx.openLocation({
  120. latitude: lat,
  121. longitude: lng,
  122. // name: address,
  123. address: address,
  124. scale: 28
  125. });
  126. }
  127. },
  128. goSchedule() {
  129. wx.navigateTo({
  130. url: '/pages/upgrade/scheduleCalc/scheduleCalc',
  131. })
  132. },
  133. goDetail(e) {
  134. let id = e.currentTarget.dataset.id;
  135. wx.navigateTo({
  136. url: '/pages/upgrade/ticketDetail/ticketDetail?bookTradeNo=' + id,
  137. });
  138. },
  139. evalMaster(e) {
  140. let id = e.currentTarget.dataset.id;
  141. let workerno = e.currentTarget.dataset.workerno;
  142. this.setData({
  143. evalMasterShow: true,
  144. star: 0,
  145. masterComment: '',
  146. bookTradeNo: id,
  147. workerNo: workerno
  148. });
  149. },
  150. onClickMsterOverlay() {
  151. this.setData({
  152. evalMasterShow: false,
  153. });
  154. },
  155. onClickDiscipleOverlay() {
  156. this.setData({
  157. evalDiscipleShow: false,
  158. });
  159. },
  160. onStarChange(event) {
  161. this.setData({
  162. star: event.detail,
  163. });
  164. },
  165. onRadioChange(event) {
  166. this.setData({
  167. radioDisciple: event.detail,
  168. });
  169. },
  170. bindMasterComment(e) {
  171. this.setData({
  172. masterComment: e.detail.value
  173. })
  174. },
  175. bindDiscipleComment(e) {
  176. this.setData({
  177. discipleComment: e.detail.value
  178. })
  179. },
  180. stop: function () {
  181. //阻止弹框冒泡和捕获的空事件,不要删除!!!
  182. },
  183. submitEvalMaster() {
  184. if (this.data.star == 0) {
  185. wx.showToast({
  186. title: '请选择评价星级',
  187. icon: 'none'
  188. })
  189. } else if (this.data.masterComment == '') {
  190. wx.showToast({
  191. title: '请输入跟单体会',
  192. icon: 'none'
  193. })
  194. } else {
  195. util.request(api.discipleFeedback, {
  196. feedback: this.data.discipleComment,
  197. level: this.data.star,
  198. bookTradeNo: this.data.bookTradeNo,
  199. workerNo: this.data.workerNo
  200. }, 'GET').then(res => {
  201. if (res.errno === 0) {
  202. wx.showToast({
  203. title: '评价成功',
  204. icon: 'none'
  205. })
  206. this.setData({
  207. evalMasterShow: false,
  208. });
  209. this.getDayCalendar();
  210. } else {
  211. wx.showToast({
  212. title: res.errmsg,
  213. icon: 'none'
  214. })
  215. }
  216. });
  217. }
  218. },
  219. evalDisciple(e) {
  220. let id = e.currentTarget.dataset.id;
  221. let workerno = e.currentTarget.dataset.workerno;
  222. this.setData({
  223. evalDiscipleShow: true,
  224. radioDisciple: '通过',
  225. discipleComment: '',
  226. bookTradeNo: id,
  227. workerNo: workerno
  228. });
  229. },
  230. submitEvalDisciple() {
  231. if (this.data.radioDisciple == '') {
  232. wx.showToast({
  233. title: '请选择是否通过',
  234. icon: 'none'
  235. })
  236. } else if (this.data.discipleComment == '') {
  237. wx.showToast({
  238. title: '请输入内容',
  239. icon: 'none'
  240. })
  241. } else {
  242. util.request(api.masterFeedback, {
  243. remark: this.data.discipleComment,
  244. feedback: this.data.radioDisciple,
  245. bookTradeNo: this.data.bookTradeNo,
  246. workerNo: this.data.workerNo
  247. }, 'GET').then(res => {
  248. if (res.errno === 0) {
  249. wx.showToast({
  250. title: '评价成功',
  251. icon: 'none'
  252. })
  253. this.setData({
  254. evalDiscipleShow: false,
  255. });
  256. this.getDayCalendar();
  257. } else {
  258. wx.showToast({
  259. title: res.errmsg,
  260. icon: 'none'
  261. })
  262. }
  263. });
  264. }
  265. },
  266. goProblemList(e) {
  267. // this.setData({
  268. // navigateType: 1
  269. // })
  270. let id = e.currentTarget.dataset.id;
  271. wx.navigateTo({
  272. url: '/pages/problem/list/list?bookTradeNo=' + id,
  273. })
  274. },
  275. /**
  276. * 生命周期函数--监听页面加载
  277. */
  278. onLoad: function (options) {
  279. // let current=this.data.wholeCalendar.filter(item=>{return item.day==this.data.currentDay});
  280. // if(current.length==0){
  281. // return false;
  282. // }
  283. // let week=current[0].weekOfYear;
  284. // let weekCalendar=this.data.wholeCalendar.filter(item=>{
  285. // return item.weekOfYear==week;
  286. // });
  287. // this.setData({
  288. // workerDayInfoList:weekCalendar,
  289. // weekCalendar:weekCalendar
  290. // });
  291. this.getMonthCalender(false, 'first');
  292. // this.getDayCalendar();
  293. },
  294. /**
  295. * 生命周期函数--监听页面显示
  296. */
  297. onShow: function () {
  298. this.getDayCalendar();
  299. let timer = setInterval(() => {
  300. console.log('定时刷新日历数据', new Date());
  301. this.getMonthCalender();
  302. this.getDayCalendar();
  303. }, 1 * 60 * 1000);
  304. this.setData({
  305. timer: timer
  306. });
  307. },
  308. onHide: function () {
  309. console.log('onHide');
  310. clearInterval(this.data.timer);
  311. },
  312. onUnload: function () {
  313. console.log('onunload');
  314. clearInterval(this.data.timer);
  315. },
  316. /**
  317. * 页面相关事件处理函数--监听用户下拉动作
  318. */
  319. onPullDownRefresh: function () {
  320. this.getMonthCalender();
  321. this.getDayCalendar();
  322. },
  323. getDayCalendar() {
  324. wx.showLoading({
  325. title: '加载中...',
  326. });
  327. util.request(api.dayCalender, {
  328. date: this.data.currentDay,
  329. }, 'GET').then(res => {
  330. wx.hideLoading();
  331. if (res.errno === 0) {
  332. console.log(res);
  333. this.setData({
  334. dayCalendar: res.data
  335. });
  336. }
  337. }).catch(err => {
  338. wx.hideLoading();
  339. });
  340. },
  341. getMonthCalender(flag, tag) {
  342. wx.showLoading({
  343. title: '加载中...',
  344. });
  345. util.request(api.monthCalender, {
  346. month: this.data.currentMonth,
  347. }, 'GET').then(res => {
  348. wx.hideLoading();
  349. if (res.errno === 0) {
  350. console.log(res);
  351. this.setData({
  352. monthInfo: res.data,
  353. wholeCalendar: res.data.workerDayInfoList
  354. });
  355. if (flag) {
  356. this.setData({
  357. calcendarFold: false,
  358. workerDayInfoList: this.data.wholeCalendar,
  359. });
  360. }
  361. let current = this.data.wholeCalendar.filter(item => {
  362. return item.day == this.data.currentDay
  363. });
  364. if (current.length == 0) {
  365. return false;
  366. }
  367. let week = current[0].weekOfYear;
  368. let weekCalendar = this.data.wholeCalendar.filter(item => {
  369. return item.weekOfYear == week;
  370. });
  371. this.setData({
  372. weekCalendar: weekCalendar
  373. });
  374. if (tag == 'first') {
  375. this.setData({
  376. workerDayInfoList: weekCalendar,
  377. });
  378. }
  379. if (this.data.calcendarFold) {
  380. this.setData({
  381. workerDayInfoList: weekCalendar,
  382. });
  383. } else {
  384. this.setData({
  385. workerDayInfoList: this.data.wholeCalendar,
  386. });
  387. }
  388. } else {
  389. wx.showToast({
  390. title: res.errmsg,
  391. duration: 3000,
  392. icon: 'none'
  393. });
  394. }
  395. }).catch(err => {
  396. wx.hideLoading();
  397. });
  398. },
  399. switchDay(e) {
  400. let day = e.currentTarget.dataset.day;
  401. this.setData({
  402. currentDay: day
  403. });
  404. this.getDayCalendar();
  405. },
  406. calcendarCollapse() {
  407. let calcendarFold = this.data.calcendarFold;
  408. if (calcendarFold) {
  409. this.setData({
  410. workerDayInfoList: this.data.wholeCalendar,
  411. calcendarFold: !calcendarFold
  412. });
  413. } else {
  414. this.setData({
  415. workerDayInfoList: this.data.weekCalendar,
  416. calcendarFold: !calcendarFold
  417. });
  418. }
  419. },
  420. lastMonth() {
  421. console.log(this.data);
  422. let params = util.getYearMonth(this.data.currentMonth, '-');
  423. this.setData({
  424. currentMonth: params
  425. });
  426. this.getMonthCalender(true);
  427. },
  428. nextMonth() {
  429. let params = util.getYearMonth(this.data.currentMonth, '+');
  430. console.log(params);
  431. this.setData({
  432. currentMonth: params
  433. });
  434. this.getMonthCalender(true);
  435. },
  436. goIssueTicket() {
  437. wx.navigateTo({
  438. url: '/pages/upgrade/issueTicket/issueTicket',
  439. })
  440. },
  441. supplyCode(e) {
  442. let bookno = e.currentTarget.dataset.bookno;
  443. if (bookno.startsWith('JZ')) {
  444. bookno = bookno.substr(2);
  445. }
  446. util.request(api.createMakeUpQRCode, {
  447. serviceId: bookno
  448. }, 'GET').then(res => {
  449. if (res.errno === 0) {
  450. let url = res.data;
  451. wx.previewImage({
  452. current: url, // 当前显示图片的http链接
  453. urls: [url] // 需要预览的图片http链接列表
  454. })
  455. } else {
  456. wx.showToast({
  457. title: res.errmsg,
  458. icon: 'none'
  459. })
  460. }
  461. });
  462. },
  463. supplyCode(e){
  464. let bookno = e.currentTarget.dataset.bookno;
  465. if (bookno.startsWith('JZ')) {
  466. bookno = bookno.substr(2);
  467. }
  468. app.globalData.diffId=0;
  469. wx.navigateTo({
  470. url: '/pages/serviceSupply/serviceSupply?bookno='+bookno,
  471. });
  472. },
  473. supplyRecord(e){
  474. let bookno = e.currentTarget.dataset.bookno;
  475. if (bookno.startsWith('JZ')) {
  476. bookno = bookno.substr(2);
  477. }
  478. wx.navigateTo({
  479. url: '/pages/supplyRecord/supplyRecord?bookno='+bookno,
  480. });
  481. },
  482. onReachBottom() {
  483. // if (this.data.totalPages > this.data.page) {
  484. // this.setData({
  485. // page: this.data.page + 1
  486. // });
  487. // this.getGoodsList();
  488. // } else {
  489. // wx.showToast({
  490. // title: '没有更多商品了',
  491. // icon: 'none',
  492. // duration: 2000
  493. // });
  494. // return false;
  495. // }
  496. },
  497. /**
  498. * 生命周期函数--监听页面初次渲染完成
  499. */
  500. onReady: function () {
  501. },
  502. /**
  503. * 页面上拉触底事件的处理函数
  504. */
  505. onReachBottom: function () {
  506. },
  507. /**
  508. * 用户点击右上角分享
  509. */
  510. onShareAppMessage: function () {
  511. },
  512. })