ticketDetail.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  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. Page({
  7. data: {
  8. lnglat:'',
  9. detailServantId:'',
  10. showjz:false,
  11. remarkTipsShow: false,
  12. issueTipsShow: false,
  13. orderInfo:{
  14. canOperateMap:{
  15. },
  16. unitIncreaseNumber:'',
  17. unitDescribe:'',
  18. },
  19. preResultData: {
  20. },
  21. ticketList: [],
  22. workerNotice: [
  23. ],
  24. orderDisable: true,
  25. orderDisable1: false,
  26. activeTab: 1,
  27. ticketPrelist:[],
  28. bookOrderInfo: {
  29. rebuySpeach: '',
  30. bookTradeNo: ""
  31. },
  32. bookTradeNo: '',
  33. comments: {
  34. ticketId: 0,
  35. ticketSn: '',
  36. selected: 0,//选中的星描述
  37. selectedDes: '',
  38. comment: '',
  39. stars: [{ level: 1, img: '/static/images/star.png', imgSelected: '/static/images/star@selected.png', checked: false, des: '非常差' },
  40. { level: 2, img: '/static/images/star.png', imgSelected: '/static/images/star@selected.png', checked: false, des: '差' },
  41. { level: 3, img: '/static/images/star.png', imgSelected: '/static/images/star@selected.png', checked: false, des: '一般' },
  42. { level: 4, img: '/static/images/star.png', imgSelected: '/static/images/star@selected.png', checked: false, des: '满意' },
  43. { level: 5, img: '/static/images/star.png', imgSelected: '/static/images/star@selected.png', checked: false, des: '非常满意' },]
  44. }
  45. },
  46. onTabChange(e) {
  47. this.setData({
  48. activeTab: e.detail.name,
  49. });
  50. if (this.data.activeTab == 1) {
  51. } else {
  52. }
  53. },
  54. getDataRefresh(){
  55. this.getData(true);
  56. },
  57. getData(flag) {
  58. wx.showLoading({
  59. title: '加载中...',
  60. });
  61. util.request(api.workerServiceOrderDetail, {
  62. detailId: app.globalData.bookTradeNo,
  63. detailServantId:this.data.detailServantId,
  64. noCache:flag?'true':''
  65. }, 'GET').then(res => {
  66. wx.hideLoading();
  67. if (res.errno === 0) {
  68. console.log(res);
  69. this.setData({
  70. orderInfo:res.data,
  71. preResultData: res.data.preResultData,
  72. ticketList:res.data.ticketList,
  73. // ticketList: res.data.ticketList,
  74. // bookOrderInfo: (res.data.bookOrderInfo)[0],
  75. ticketPrelist:res.data.ticketPrelist
  76. });
  77. this.selectComponent('#tabs').resize();
  78. if((!res.data.isRead)&&res.data.customerServiceSr){
  79. this.setData({
  80. remarkTipsShow:true
  81. });
  82. }
  83. }
  84. }).catch(err => {
  85. wx.hideLoading();
  86. });
  87. },
  88. tapCusRemark(){
  89. this.setData({
  90. remarkTipsShow:true
  91. });
  92. },
  93. readRemark(){
  94. wx.showLoading({
  95. title: '加载中...',
  96. });
  97. util.request(api.hasReadServiceRemark, {
  98. detailId: this.data.bookTradeNo
  99. }, 'GET').then(res => {
  100. wx.hideLoading();
  101. if (res.errno === 0) {
  102. this.setData({
  103. remarkTipsShow:false,
  104. });
  105. wx.showToast({
  106. title: '操作成功',
  107. icon:'none'
  108. })
  109. }
  110. }).catch(err => {
  111. wx.hideLoading();
  112. });
  113. },
  114. copyNum(e) {
  115. let content=e.currentTarget.dataset.content;
  116. wx.setClipboardData({
  117. data: content,
  118. success: function (res) {
  119. wx.showToast({
  120. title: '复制成功',
  121. icon: 'none',
  122. duration: 2000
  123. });
  124. }
  125. })
  126. },
  127. callUp(e) {
  128. let status = e.currentTarget.dataset.status;
  129. let phone = e.currentTarget.dataset.phone;
  130. if (status == '待上门') {
  131. wx.makePhoneCall({
  132. phoneNumber: phone
  133. });
  134. }
  135. },
  136. openMap() {//打开地图
  137. let address = this.data.orderInfo.addr;
  138. let lnglat = this.data.orderInfo.addrDetail.split(',');
  139. let lng = '';
  140. let lat = "";
  141. if (lnglat.length > 0) {
  142. lng = Number(lnglat[0]);
  143. lat = Number(lnglat[1]);
  144. }
  145. console.log(lng, lat);
  146. wx.openLocation({
  147. latitude: lat,
  148. longitude: lng,
  149. // name: address,
  150. address: address,
  151. scale: 28
  152. });
  153. },
  154. /**
  155. * 生命周期函数--监听页面加载
  156. */
  157. onLoad: function (options) {
  158. let that=this;
  159. wx.getLocation({
  160. type: 'wgs84',
  161. success (res) {
  162. console.log(res);
  163. that.setData({
  164. lnglat:res.longitude+','+res.latitude
  165. })
  166. // const latitude = res.latitude
  167. // const longitude = res.longitude
  168. },
  169. fail(res){
  170. wx.showToast({
  171. title: "请点击右上角打开位置授权",
  172. icon: 'none'
  173. })
  174. }
  175. })
  176. this.selectComponent('#tabs').resize();
  177. if (options) {
  178. this.setData({
  179. bookTradeNo: options.bookTradeNo,
  180. detailServantId:options.detailServantId
  181. });
  182. app.globalData.bookTradeNo = options.bookTradeNo;
  183. // this.getData();
  184. }
  185. // this.getTips();
  186. },
  187. getTips() {
  188. let userInfo = wx.getStorageSync('userInfo');
  189. util.request(api.getWorkerTips, {
  190. workerNo: userInfo.workerNo
  191. }, 'GET').then(res => {
  192. if (res.errno === 0) {
  193. console.log(res);
  194. this.setData({
  195. workerNotice: res.data
  196. });
  197. }
  198. }).catch(err => {
  199. });
  200. },
  201. onReachBottom() {
  202. // if (this.data.totalPages > this.data.page) {
  203. // this.setData({
  204. // page: this.data.page + 1
  205. // });
  206. // this.getGoodsList();
  207. // } else {
  208. // wx.showToast({
  209. // title: '没有更多商品了',
  210. // icon: 'none',
  211. // duration: 2000
  212. // });
  213. // return false;
  214. // }
  215. },
  216. /**
  217. * 生命周期函数--监听页面初次渲染完成
  218. */
  219. onReady: function () {
  220. },
  221. /**
  222. * 生命周期函数--监听页面显示
  223. */
  224. onShow: function () {
  225. let userInfo = wx.getStorageSync('userInfo');
  226. if (userInfo && userInfo.ofJz == 293) {
  227. this.setData({
  228. showjz:true
  229. })
  230. }
  231. this.getData();
  232. },
  233. onHide: function () {
  234. },
  235. onUnload: function () {
  236. },
  237. /**
  238. * 页面相关事件处理函数--监听用户下拉动作
  239. */
  240. onPullDownRefresh: function () {
  241. this.getData(true);
  242. },
  243. /**
  244. * 页面上拉触底事件的处理函数
  245. */
  246. onReachBottom: function () {
  247. },
  248. /**
  249. * 用户点击右上角分享
  250. */
  251. onShareAppMessage: function () {
  252. },
  253. goIm(){
  254. wx.navigateTo({
  255. url: '/pages/chat/im/im'
  256. });
  257. },
  258. supplyRecord(e){
  259. let bookno = e.currentTarget.dataset.bookno;
  260. if (bookno.startsWith('JZ')) {
  261. bookno = bookno.substr(2);
  262. }
  263. wx.navigateTo({
  264. url: '/pages/supplyRecord/supplyRecord?bookno='+bookno,
  265. });
  266. },
  267. getQrCode(e) { //加企微
  268. let channel = e.currentTarget.dataset.channel;
  269. let id = e.currentTarget.dataset.id;
  270. if (channel && channel == '盒马')
  271. channel = 'hm';
  272. else channel = 'p';
  273. wx.navigateTo({
  274. url: '/pages/upgrade/cp/join?channel=' + channel + '&id=' + id,
  275. })
  276. },
  277. supplyCode(e){
  278. let bookno = e.currentTarget.dataset.bookno;
  279. if (bookno.startsWith('JZ')) {
  280. bookno = bookno.substr(2);
  281. }
  282. app.globalData.diffId=0;
  283. wx.navigateTo({
  284. url: '/pages/serviceSupply/serviceSupply?bookno='+bookno,
  285. });
  286. },
  287. makeCall(e) {
  288. let mobile = e.currentTarget.dataset.mobile;
  289. wx.makePhoneCall({
  290. phoneNumber: mobile,
  291. })
  292. },
  293. goPre(e) { //去预检
  294. let id = e.currentTarget.dataset.id;
  295. let bookNo = e.currentTarget.dataset.bookno;
  296. let phone = e.currentTarget.dataset.userphone;
  297. wx.navigateTo({
  298. url: '/pages/pre/previewing/index?id=' + id + '&bookNo=' + bookNo + '&phone=' + phone,
  299. })
  300. },
  301. editPre(e) {
  302. let bookNo = e.currentTarget.dataset.bookno;
  303. wx.navigateTo({
  304. url: '/pages/pre/previewing/index?bookNo=' + bookNo,
  305. });
  306. },
  307. goProblemList() {
  308. // this.setData({
  309. // navigateType: 1
  310. // })
  311. wx.navigateTo({
  312. url: '/pages/problem/list/list?bookTradeNo=' + this.data.bookTradeNo,
  313. })
  314. },
  315. arriveCus() {
  316. if (this.data.bookOrderInfo.status == '待上门') {
  317. wx.showModal({
  318. title: '',
  319. content: '确定已经到门?',
  320. success: res => {
  321. if (res.confirm) {
  322. util.request(api.arrivedByMerchant, {
  323. bookTradeNo: this.data.bookTradeNo,
  324. workerNo: this.data.bookOrderInfo.workerNo
  325. }, 'GET').then(res => {
  326. if (res.errno === 0) {
  327. wx.showToast({
  328. title: '操作成功'
  329. });
  330. this.setData({
  331. activeTab: 1
  332. });
  333. this.getData();
  334. } else {
  335. util.showErrorToast(res.errmsg);
  336. }
  337. });
  338. }
  339. }
  340. });
  341. }
  342. },
  343. hideIssue(){
  344. this.setData({
  345. issueTipsShow:false
  346. });
  347. },
  348. goCusCheck(){
  349. wx.navigateTo({
  350. url: '/pages/new/customerCheck/customerCheck?serviceId='+this.data.bookTradeNo+'&detailServantId='+this.data.detailServantId+'&channelId='+this.data.orderInfo.channelId,
  351. })
  352. },
  353. exceotionConf(){
  354. this.arrivedByMerchant(true);
  355. },
  356. arriveCusNew() {
  357. let nowTime=(new Date()).getTime();
  358. let serTimeStr=this.data.orderInfo.bookDate+' '+this.data.orderInfo.bookTimeRange.split('-')[0];
  359. let serTime= (new Date(serTimeStr)).getTime();
  360. console.log(nowTime,serTime);
  361. if(nowTime<serTime){
  362. this.setData({
  363. issueTipsShow:true
  364. });
  365. }else{
  366. this.arrivedByMerchant()
  367. }
  368. },
  369. arrivedByMerchant(flag){
  370. // wx.showModal({
  371. // title: '',
  372. // content: '确定已经到户?',
  373. // success: res => {
  374. // if (res.confirm) {
  375. let clockInfo={
  376. detailId: this.data.orderInfo.detailId,
  377. detailServantId:this.data.orderInfo.detailServantId,
  378. isException:flag?'true':'',
  379. lnglat:this.data.lnglat,
  380. addr:this.data.orderInfo.addr,
  381. channelId:this.data.orderInfo.channelId
  382. };
  383. app.globalData.clockInfo=clockInfo;
  384. wx.navigateTo({
  385. url: '/pages/new/onDoorClock/onDoorClock'
  386. });
  387. // util.request(api.arrivedByMerchantNew,clockInfo , 'GET').then(res => {
  388. // if (res.errno === 0) {
  389. // wx.showToast({
  390. // title: '操作成功'
  391. // });
  392. // if(flag){
  393. // this.setData({
  394. // issueTipsShow:false
  395. // });
  396. // wx.navigateTo({
  397. // url: '/pages/problem/list/list?bookTradeNo=' + this.data.orderInfo.detailId,
  398. // });
  399. // return false;
  400. // }
  401. // this.setData({
  402. // activeTab: 1
  403. // });
  404. // this.getData(true);
  405. // } else {
  406. // wx.showToast({
  407. // title: res.errmsg,
  408. // icon:'none'
  409. // })
  410. // }
  411. // });
  412. // }
  413. // }
  414. // });
  415. },
  416. finishOrder() {
  417. if (this.data.bookOrderInfo.status == '待履约' || this.data.bookOrderInfo.status == '已预约') {
  418. wx.showModal({
  419. title: '',
  420. content: '确定服务完成?',
  421. success: res => {
  422. if (res.confirm) {
  423. util.request(api.confirmBookTrade, {
  424. bookTradeNo: this.data.bookTradeNo,
  425. }, 'GET').then(res => {
  426. if (res.errno === 0) {
  427. wx.showToast({
  428. title: '操作成功'
  429. });
  430. this.setData({
  431. activeTab: 1
  432. });
  433. this.getData();
  434. } else {
  435. util.showErrorToast(res.errmsg);
  436. }
  437. });
  438. }
  439. }
  440. });
  441. }
  442. },
  443. goCancel(e) { //取消报备
  444. let that = this;
  445. let sn = e.currentTarget.dataset.sn;
  446. wx.showModal({
  447. title: '取消报备',
  448. content: '确定要取消此报备吗?',
  449. showCancel: true, //是否显示取消按钮
  450. cancelText: "否", //默认是“取消”
  451. cancelColor: 'skyblue', //取消文字的颜色
  452. confirmText: "是", //默认是“确定”
  453. confirmColor: 'skyblue', //确定文字的颜色
  454. success: function (res) {
  455. if (res.cancel) {
  456. //点击取消,默认隐藏弹框
  457. } else {
  458. //点击确定
  459. util.request(api.ProblemCancel, {
  460. 'ticketSn': sn
  461. }).then(res => {
  462. let list = that.data.ticketList
  463. list.forEach(item => {
  464. if (item.ticketSN == sn) {
  465. item.statusDesc = "作废";
  466. item.status = 3;
  467. }
  468. })
  469. that.setData({
  470. ticketList: list
  471. })
  472. wx.showToast({
  473. title: '已取消成功',
  474. duration: 3000
  475. });
  476. })
  477. }
  478. },
  479. fail: function (res) { }, //接口调用失败的回调函数
  480. complete: function (res) { }, //接口调用结束的回调函数(调用成功、失败都会执行)
  481. })
  482. },
  483. goUrge(e) { //催促办理
  484. let sn = e.currentTarget.dataset.sn;
  485. let that = this;
  486. wx.showLoading();
  487. util.request(api.ProblemUrge, {
  488. ticketSn: sn
  489. }).then(function (res) {
  490. wx.hideLoading();
  491. if (res.errno === 0) {
  492. //设置为已催办
  493. let list = that.data.ticketList;
  494. list.forEach(item => {
  495. if (item.ticketSN == sn) {
  496. item.statusDesc = "处理中-升级"
  497. }
  498. })
  499. that.setData({
  500. ticketList: list
  501. })
  502. wx.showToast({
  503. title: '已催促负责人尽快办理',
  504. icon: 'none',
  505. duration: 3000
  506. });
  507. }
  508. });
  509. },
  510. goComment(e) { //去评论
  511. // wx.pageScrollTo({
  512. // scrollTop: 0
  513. // });
  514. let id = e.currentTarget.dataset.id;
  515. let sn = e.currentTarget.dataset.sn;
  516. this.setData({
  517. myqr_show: true,
  518. myqr_blur: 0,
  519. 'comments.ticketId': id,
  520. 'comments.ticketSn': sn
  521. })
  522. },
  523. clickStar(e) {
  524. let level = e.currentTarget.dataset.level;
  525. console.info(level)
  526. let stars = this.data.comments.stars;
  527. let des = ''
  528. stars.forEach(item => {
  529. if (item.level <= level) {
  530. item.checked = true;
  531. des = item.des
  532. } else {
  533. item.checked = false;
  534. }
  535. })
  536. this.setData({
  537. 'comments.stars': stars,
  538. 'comments.selectedDes': des,
  539. 'comments.selected': level
  540. })
  541. },
  542. onClickHide() {
  543. },
  544. qrtouchstart: function () {
  545. this.setData({
  546. myqr_blur: 0,
  547. myqr_show: false
  548. });
  549. },
  550. bindCommentRemark(e) {
  551. this.setData({
  552. 'comments.comment': e.detail.value
  553. })
  554. },
  555. getServantDetail(e){
  556. console.log("我的打印", e.currentTarget.dataset);
  557. let servantId=e.currentTarget.dataset.id
  558. wx.navigateTo({
  559. url: '/pages/new/servantDetail/servantDetail?servantId='+servantId,
  560. })
  561. },
  562. goSaveCommnet() {//保存评论
  563. let that = this;
  564. if (that.data.comments.selected == 0) {
  565. wx.showToast({
  566. title: '请选择满意度',
  567. icon: 'none',
  568. duration: 2000
  569. })
  570. return;
  571. }
  572. if (that.data.comments.selected < 4 && that.data.comments.comment == '') {
  573. wx.showToast({
  574. title: '请填写有待提升的地方',
  575. icon: 'none',
  576. duration: 2000
  577. })
  578. return;
  579. }
  580. wx.showModal({
  581. title: '提示',
  582. content: '确定要评价此处理过程吗?提交后 无法修改',
  583. success: function (sm) {
  584. if (sm.confirm) {
  585. wx.showLoading();
  586. let data = {
  587. ticketId: that.data.comments.ticketId,
  588. ticketSn: that.data.comments.ticketSn,
  589. comment: that.data.comments.comment,
  590. star: that.data.comments.selected
  591. }
  592. util.request(api.ProblemComment, data, "POST").then(res => {
  593. wx.hideLoading();
  594. if (res.errno == 0) {
  595. let list = that.data.ticketList;
  596. list.forEach(item => {
  597. if (item.ticketSN == that.data.comments.ticketSN) {
  598. item.isCommented = true;
  599. }
  600. })
  601. let comments = that.data.comments;
  602. comments.selected = 0;
  603. comments.selectedDes = "";
  604. comments.comment = "";
  605. comments.stars.forEach(star => {
  606. star.checked = false;
  607. })
  608. that.setData({
  609. myqr_blur: 0,
  610. myqr_show: false,
  611. comments: comments,
  612. ticketList: list
  613. });
  614. wx.showToast({
  615. title: '评价成功',
  616. duration: 3000
  617. });
  618. } else {
  619. wx.showToast({
  620. title: res.errmsg,
  621. icon: 'none',
  622. duration: 3000
  623. });
  624. }
  625. }).catch(res => {
  626. wx.hideLoading();
  627. wx.showToast({
  628. title: res.errmsg,
  629. icon: 'none',
  630. duration: 3000
  631. });
  632. });
  633. }
  634. }
  635. });
  636. },
  637. })