ticketDetail.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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. workerNotice:[
  9. ],
  10. orderDisable:true,
  11. orderDisable1:false,
  12. activeTab:1,
  13. ticketList:[],
  14. bookOrderInfo:{
  15. rebuySpeach:'',
  16. bookTradeNo:""
  17. },
  18. preResultData:{
  19. },
  20. bookTradeNo:'',
  21. comments: {
  22. ticketId:0,
  23. ticketSn:'',
  24. selected:0,//选中的星描述
  25. selectedDes:'',
  26. comment: '',
  27. stars: [{level:1,img: '/static/images/star.png',imgSelected:'/static/images/star@selected.png',checked:false,des:'非常差'},
  28. {level:2,img: '/static/images/star.png',imgSelected:'/static/images/star@selected.png',checked:false,des:'差'},
  29. {level:3,img: '/static/images/star.png',imgSelected:'/static/images/star@selected.png',checked:false,des:'一般'},
  30. {level:4,img: '/static/images/star.png',imgSelected:'/static/images/star@selected.png',checked:false,des:'满意'},
  31. {level:5,img: '/static/images/star.png',imgSelected:'/static/images/star@selected.png',checked:false,des:'非常满意'},]
  32. }
  33. },
  34. onTabChange(e) {
  35. this.setData({
  36. activeTab: e.detail.name,
  37. });
  38. if (this.data.activeTab == 1) {
  39. }else{
  40. }
  41. },
  42. getData(){
  43. wx.showLoading({
  44. title: '加载中...',
  45. });
  46. util.request(api.crmTicket, {
  47. bookTradeNo:app.globalData.bookTradeNo
  48. }, 'GET').then(res=> {
  49. wx.hideLoading();
  50. if (res.errno === 0) {
  51. console.log(res);
  52. this.setData({
  53. ticketList:res.data.ticketList,
  54. bookOrderInfo:(res.data.bookOrderInfo)[0],
  55. preResultData:res.data.preResultData
  56. });
  57. this.selectComponent('#tabs').resize();
  58. }
  59. }).catch(err=>{
  60. wx.hideLoading();
  61. });
  62. },
  63. copyNum(){
  64. let bookno=e.currentTarget.data.set.bookno;
  65. console.log(bookno);
  66. wx.setClipboardData({
  67. data: bookno,
  68. success: function (res) {
  69. wx.showToast({
  70. title: '复制成功',
  71. icon: 'none',
  72. duration: 2000
  73. });
  74. }
  75. })
  76. },
  77. callUp(e){
  78. let status=e.currentTarget.dataset.status;
  79. let phone=e.currentTarget.dataset.phone;
  80. if(status=='待上门'){
  81. wx.makePhoneCall({
  82. phoneNumber: phone
  83. });
  84. }
  85. },
  86. openMap(e){//打开地图
  87. let status=e.currentTarget.dataset.status;
  88. let address=e.currentTarget.dataset.address;
  89. if(status=='待上门'){
  90. let lnglat=e.currentTarget.dataset.lnglat.split(',');
  91. let lng='';
  92. let lat="";
  93. if (lnglat.length>0){
  94. lng=Number(lnglat[0]);
  95. lat=Number(lnglat[1]);
  96. }
  97. console.log(lng,lat);
  98. wx.openLocation({
  99. latitude: lat,
  100. longitude: lng,
  101. // name: address,
  102. address:address,
  103. scale: 28
  104. }) ;
  105. }
  106. },
  107. /**
  108. * 生命周期函数--监听页面加载
  109. */
  110. onLoad: function (options) {
  111. this.selectComponent('#tabs').resize();
  112. if(options){
  113. this.setData({
  114. bookTradeNo:options.bookTradeNo
  115. });
  116. app.globalData.bookTradeNo=options.bookTradeNo;
  117. // this.getData();
  118. }
  119. this.getTips();
  120. },
  121. getTips(){
  122. let userInfo = wx.getStorageSync('userInfo');
  123. util.request(api.getWorkerTips, {
  124. workerNo:userInfo.workerNo
  125. }, 'GET').then(res=> {
  126. if (res.errno === 0) {
  127. console.log(res);
  128. this.setData({
  129. workerNotice:res.data
  130. });
  131. }
  132. }).catch(err=>{
  133. });
  134. },
  135. onReachBottom() {
  136. // if (this.data.totalPages > this.data.page) {
  137. // this.setData({
  138. // page: this.data.page + 1
  139. // });
  140. // this.getGoodsList();
  141. // } else {
  142. // wx.showToast({
  143. // title: '没有更多商品了',
  144. // icon: 'none',
  145. // duration: 2000
  146. // });
  147. // return false;
  148. // }
  149. },
  150. /**
  151. * 生命周期函数--监听页面初次渲染完成
  152. */
  153. onReady: function () {
  154. },
  155. /**
  156. * 生命周期函数--监听页面显示
  157. */
  158. onShow: function () {
  159. this.getData();
  160. },
  161. onHide: function () {
  162. },
  163. onUnload: function () {
  164. },
  165. /**
  166. * 页面相关事件处理函数--监听用户下拉动作
  167. */
  168. onPullDownRefresh: function () {
  169. },
  170. /**
  171. * 页面上拉触底事件的处理函数
  172. */
  173. onReachBottom: function () {
  174. },
  175. /**
  176. * 用户点击右上角分享
  177. */
  178. onShareAppMessage: function () {
  179. },
  180. makeCall(e) {
  181. let mobile = e.currentTarget.dataset.mobile;
  182. wx.makePhoneCall({
  183. phoneNumber: mobile,
  184. })
  185. },
  186. goPre(e) { //去预检
  187. let id = e.currentTarget.dataset.id;
  188. let bookNo = e.currentTarget.dataset.bookno;
  189. let phone = e.currentTarget.dataset.userphone;
  190. wx.navigateTo({
  191. url: '/pages/pre/previewing/index?id=' + id+'&bookNo='+bookNo+'&phone='+phone,
  192. })
  193. },
  194. editPre(e) {
  195. let bookNo = e.currentTarget.dataset.bookno;
  196. wx.navigateTo({
  197. url: '/pages/pre/previewing/index?bookNo=' + bookNo,
  198. });
  199. },
  200. goProblemList() {
  201. // this.setData({
  202. // navigateType: 1
  203. // })
  204. wx.navigateTo({
  205. url: '/pages/problem/list/list?bookTradeNo='+this.data.bookTradeNo,
  206. })
  207. },
  208. arriveCus(){
  209. if(this.data.bookOrderInfo.status=='待上门'){
  210. wx.showModal({
  211. title: '',
  212. content: '确定已经到门?',
  213. success: res=>{
  214. if (res.confirm) {
  215. util.request(api.arrivedByMerchant, {
  216. bookTradeNo: this.data.bookTradeNo,
  217. workerNo:this.data.bookOrderInfo.workerNo
  218. }, 'GET').then(res=> {
  219. if (res.errno === 0) {
  220. wx.showToast({
  221. title: '操作成功'
  222. });
  223. this.setData({
  224. activeTab:1
  225. });
  226. this.getData();
  227. } else {
  228. util.showErrorToast(res.errmsg);
  229. }
  230. });
  231. }
  232. }
  233. });
  234. }
  235. },
  236. finishOrder(){
  237. if(this.data.bookOrderInfo.status=='待履约'||this.data.bookOrderInfo.status=='已预约'){
  238. wx.showModal({
  239. title: '',
  240. content: '确定服务完成?',
  241. success: res=>{
  242. if (res.confirm) {
  243. util.request(api.confirmBookTrade, {
  244. bookTradeNo: this.data.bookTradeNo,
  245. }, 'GET').then(res=> {
  246. if (res.errno === 0) {
  247. wx.showToast({
  248. title: '操作成功'
  249. });
  250. this.setData({
  251. activeTab:1
  252. });
  253. this.getData();
  254. } else {
  255. util.showErrorToast(res.errmsg);
  256. }
  257. });
  258. }
  259. }
  260. });
  261. }
  262. },
  263. goCancel(e) { //取消报备
  264. let that = this;
  265. let sn = e.currentTarget.dataset.sn;
  266. wx.showModal({
  267. title: '取消报备',
  268. content: '确定要取消此报备吗?',
  269. showCancel: true, //是否显示取消按钮
  270. cancelText: "否", //默认是“取消”
  271. cancelColor: 'skyblue', //取消文字的颜色
  272. confirmText: "是", //默认是“确定”
  273. confirmColor: 'skyblue', //确定文字的颜色
  274. success: function (res) {
  275. if (res.cancel) {
  276. //点击取消,默认隐藏弹框
  277. } else {
  278. //点击确定
  279. util.request(api.ProblemCancel, {
  280. 'ticketSn': sn
  281. }).then(res => {
  282. let list = that.data.ticketList
  283. list.forEach(item => {
  284. if (item.ticketSN == sn) {
  285. item.statusDesc = "作废";
  286. item.status = 3;
  287. }
  288. })
  289. that.setData({
  290. ticketList: list
  291. })
  292. wx.showToast({
  293. title: '已取消成功',
  294. duration: 3000
  295. });
  296. })
  297. }
  298. },
  299. fail: function (res) {}, //接口调用失败的回调函数
  300. complete: function (res) {}, //接口调用结束的回调函数(调用成功、失败都会执行)
  301. })
  302. },
  303. goUrge(e) { //催促办理
  304. let sn = e.currentTarget.dataset.sn;
  305. let that = this;
  306. wx.showLoading();
  307. util.request(api.ProblemUrge, {
  308. ticketSn: sn
  309. }).then(function (res) {
  310. wx.hideLoading();
  311. if (res.errno === 0) {
  312. //设置为已催办
  313. let list = that.data.ticketList;
  314. list.forEach(item => {
  315. if (item.ticketSN == sn) {
  316. item.statusDesc = "处理中-升级"
  317. }
  318. })
  319. that.setData({
  320. ticketList: list
  321. })
  322. wx.showToast({
  323. title: '已催促负责人尽快办理',
  324. icon:'none',
  325. duration: 3000
  326. });
  327. }
  328. });
  329. },
  330. goComment(e) { //去评论
  331. // wx.pageScrollTo({
  332. // scrollTop: 0
  333. // });
  334. let id = e.currentTarget.dataset.id;
  335. let sn = e.currentTarget.dataset.sn;
  336. this.setData({
  337. myqr_show: true,
  338. myqr_blur: 0,
  339. 'comments.ticketId':id,
  340. 'comments.ticketSn':sn
  341. })
  342. },
  343. clickStar(e){
  344. let level = e.currentTarget.dataset.level;
  345. console.info(level)
  346. let stars=this.data.comments.stars;
  347. let des=''
  348. stars.forEach(item=>{
  349. if(item.level<=level) {
  350. item.checked=true;
  351. des=item.des
  352. }else{
  353. item.checked=false;
  354. }
  355. })
  356. this.setData({
  357. 'comments.stars':stars,
  358. 'comments.selectedDes':des,
  359. 'comments.selected':level
  360. })
  361. },
  362. onClickHide(){
  363. },
  364. qrtouchstart: function () {
  365. this.setData({
  366. myqr_blur: 0,
  367. myqr_show: false
  368. });
  369. },
  370. bindCommentRemark(e){
  371. this.setData({
  372. 'comments.comment':e.detail.value
  373. })
  374. },
  375. goSaveCommnet(){//保存评论
  376. let that=this;
  377. if(that.data.comments.selected==0){
  378. wx.showToast({
  379. title:'请选择满意度',
  380. icon:'none',
  381. duration:2000
  382. })
  383. return;
  384. }
  385. if(that.data.comments.selected<4&&that.data.comments.comment==''){
  386. wx.showToast({
  387. title:'请填写有待提升的地方',
  388. icon:'none',
  389. duration:2000
  390. })
  391. return;
  392. }
  393. wx.showModal({
  394. title: '提示',
  395. content: '确定要评价此处理过程吗?提交后 无法修改',
  396. success: function (sm) {
  397. if (sm.confirm) {
  398. wx.showLoading();
  399. let data={
  400. ticketId:that.data.comments.ticketId,
  401. ticketSn:that.data.comments.ticketSn,
  402. comment:that.data.comments.comment,
  403. star:that.data.comments.selected
  404. }
  405. util.request(api.ProblemComment,data,"POST").then(res=>{
  406. wx.hideLoading();
  407. if(res.errno==0){
  408. let list=that.data.ticketList;
  409. list.forEach(item=>{
  410. if(item.ticketSN==that.data.comments.ticketSN){
  411. item.isCommented=true;
  412. }
  413. })
  414. let comments=that.data.comments;
  415. comments.selected=0;
  416. comments.selectedDes="";
  417. comments.comment="";
  418. comments.stars.forEach(star=>{
  419. star.checked=false;
  420. })
  421. that.setData({
  422. myqr_blur: 0,
  423. myqr_show: false,
  424. comments:comments,
  425. ticketList:list
  426. });
  427. wx.showToast({
  428. title: '评价成功',
  429. duration: 3000
  430. });
  431. }else{
  432. wx.showToast({
  433. title: res.errmsg,
  434. icon:'none',
  435. duration: 3000
  436. });
  437. }
  438. }).catch(res=>{
  439. wx.hideLoading();
  440. wx.showToast({
  441. title: res.errmsg,
  442. icon:'none',
  443. duration: 3000
  444. });
  445. });
  446. }
  447. }
  448. });
  449. },
  450. })