tempDetail.js 16 KB

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