ticketDetail.js 11 KB

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