index.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. const util = require("../../utils/util");
  2. const api = require('../../api/api.js');
  3. var app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. list: [],
  10. showType: 0,
  11. page: 1,
  12. limit: 10,
  13. totalPages: 1,
  14. myqr_show: false, //我的分享二维码
  15. myqr_url: null,
  16. myqr_blur: 0, //背景模糊值
  17. navigateType: 0, //0 进入详情页 1问题报备 1需要刷新页面
  18. comments: {
  19. ticketId:0,
  20. ticketSn:'',
  21. selected:0,//选中的星描述
  22. selectedDes:'',
  23. comment: '',
  24. stars: [{level:1,img: '/static/images/star.png',imgSelected:'/static/images/star@selected.png',checked:false,des:'非常差'},
  25. {level:2,img: '/static/images/star.png',imgSelected:'/static/images/star@selected.png',checked:false,des:'差'},
  26. {level:3,img: '/static/images/star.png',imgSelected:'/static/images/star@selected.png',checked:false,des:'一般'},
  27. {level:4,img: '/static/images/star.png',imgSelected:'/static/images/star@selected.png',checked:false,des:'满意'},
  28. {level:5,img: '/static/images/star.png',imgSelected:'/static/images/star@selected.png',checked:false,des:'非常满意'},]
  29. }
  30. },
  31. /**
  32. * 生命周期函数--监听页面加载
  33. */
  34. onLoad: function (options) {
  35. },
  36. clickStar(e){
  37. let level = e.currentTarget.dataset.level;
  38. console.info(level)
  39. let stars=this.data.comments.stars;
  40. let des=''
  41. stars.forEach(item=>{
  42. if(item.level<=level) {
  43. item.checked=true;
  44. des=item.des
  45. }else{
  46. item.checked=false;
  47. }
  48. })
  49. this.setData({
  50. 'comments.stars':stars,
  51. 'comments.selectedDes':des,
  52. 'comments.selected':level
  53. })
  54. },
  55. goSaveCommnet(){//保存评论
  56. let that=this;
  57. if(that.data.comments.selected==0){
  58. wx.showToast({
  59. title:'请选择满意度',
  60. duration:2000
  61. })
  62. return;
  63. }
  64. if(that.data.comments.selected<4&&that.data.comments.comment==''){
  65. wx.showToast({
  66. title:'请填写有待提升的地方',
  67. duration:2000
  68. })
  69. return;
  70. }
  71. wx.showModal({
  72. title: '提示',
  73. content: '确定要评价此处理过程吗?提交后 无法修改',
  74. success: function (sm) {
  75. if (sm.confirm) {
  76. wx.showLoading();
  77. let data={
  78. ticketId:that.data.comments.ticketId,
  79. ticketSn:that.data.comments.ticketSn,
  80. comment:that.data.comments.comment,
  81. star:that.data.comments.selected
  82. }
  83. util.request(api.ProblemComment,data,"POST").then(res=>{
  84. wx.hideLoading();
  85. let list=that.data.list;
  86. list.forEach(item=>{
  87. if(item.ticketId==that.data.comments.ticketId){
  88. item.isCommented=true;
  89. }
  90. })
  91. let comments=that.data.comments;
  92. comments.selected=0;
  93. comments.selectedDes="";
  94. comments.comment="";
  95. comments.stars.forEach(star=>{
  96. star.checked=false;
  97. })
  98. that.setData({
  99. myqr_blur: 0,
  100. myqr_show: false,
  101. comments:comments,
  102. list:list
  103. })
  104. wx.showToast({
  105. title: '评价成功',
  106. duration: 3000
  107. }).catch(res=>{
  108. wx.hideLoading();
  109. wx.showToast({
  110. title: res.errmsg,
  111. duration: 3000
  112. });
  113. });
  114. })
  115. }
  116. }
  117. })
  118. },
  119. goComment(e) { //去评论
  120. // wx.pageScrollTo({
  121. // scrollTop: 0
  122. // });
  123. let id = e.currentTarget.dataset.id;
  124. let sn = e.currentTarget.dataset.sn;
  125. this.setData({
  126. myqr_show: true,
  127. myqr_blur: 0,
  128. 'comments.ticketId':id,
  129. 'comments.ticketSn':sn
  130. })
  131. },
  132. qrtouchstart: function () {
  133. this.setData({
  134. myqr_blur: 0,
  135. myqr_show: false
  136. });
  137. },
  138. bindCommentRemark(e){
  139. this.setData({
  140. 'comments.comment':e.detail.value
  141. })
  142. },
  143. goProblemList() {
  144. this.setData({
  145. navigateType: 1
  146. })
  147. wx.navigateTo({
  148. url: '/pages/problem/list/list',
  149. })
  150. },
  151. goUrge(e) { //催促办理
  152. let sn = e.currentTarget.dataset.sn;
  153. let that = this;
  154. wx.showLoading();
  155. util.request(api.ProblemUrge, {
  156. ticketSn: sn
  157. }).then(function (res) {
  158. wx.hideLoading();
  159. if (res.errno === 0) {
  160. //设置为已催办
  161. let list = that.data.list;
  162. list.forEach(item => {
  163. if (item.ticketSn == sn) {
  164. item.status = "处理中-升级"
  165. }
  166. })
  167. that.setData({
  168. list: list
  169. })
  170. wx.showToast({
  171. title: '已催促负责人尽快办理',
  172. duration: 3000
  173. });
  174. }
  175. });
  176. },
  177. goDetail(e) {
  178. this.setData({
  179. navigateType: 0
  180. })
  181. let sn = e.currentTarget.dataset.sn;
  182. wx.navigateTo({
  183. url: '/pages/problem/action/action?ticketSn=' + sn,
  184. })
  185. },
  186. goCancel(e) { //取消报备
  187. let that = this;
  188. let sn = e.currentTarget.dataset.sn;
  189. wx.showModal({
  190. title: '取消报备',
  191. content: '确定要取消此报备吗?',
  192. showCancel: true, //是否显示取消按钮
  193. cancelText: "否", //默认是“取消”
  194. cancelColor: 'skyblue', //取消文字的颜色
  195. confirmText: "是", //默认是“确定”
  196. confirmColor: 'skyblue', //确定文字的颜色
  197. success: function (res) {
  198. if (res.cancel) {
  199. //点击取消,默认隐藏弹框
  200. } else {
  201. //点击确定
  202. util.request(api.ProblemCancel, {
  203. 'ticketSn': sn
  204. }).then(res => {
  205. let list = that.data.list;
  206. list.forEach(item => {
  207. if (item.ticketSn == sn) {
  208. item.status = "作废";
  209. item.statusId = 3;
  210. }
  211. })
  212. that.setData({
  213. list: list
  214. })
  215. wx.showToast({
  216. title: '已取消成功',
  217. duration: 3000
  218. });
  219. })
  220. }
  221. },
  222. fail: function (res) {}, //接口调用失败的回调函数
  223. complete: function (res) {}, //接口调用结束的回调函数(调用成功、失败都会执行)
  224. })
  225. },
  226. goQuickList() {
  227. this.setData({
  228. navigateType: 1
  229. })
  230. wx.navigateTo({
  231. url: '/pages/problem/quick/quick',
  232. })
  233. },
  234. getProblemList() {
  235. let that = this;
  236. wx.showLoading();
  237. util.request(api.ProblemList, {
  238. showType: that.data.showType,
  239. page: that.data.page,
  240. limit: that.data.limit
  241. }).then(function (res) {
  242. wx.hideLoading();
  243. if (res.errno === 0) {
  244. console.log(res.data);
  245. that.setData({
  246. list: that.data.list.concat(res.data.list),
  247. totalPages: res.data.pages
  248. });
  249. }
  250. });
  251. },
  252. switchTab: function (event) {
  253. let showType = event.currentTarget.dataset.index;
  254. console.log(showType);
  255. wx.setStorageSync('tab', showType);
  256. this.setData({
  257. list: [],
  258. showType: showType,
  259. page: 1,
  260. limit: 10,
  261. totalPages: 1
  262. });
  263. this.getProblemList();
  264. },
  265. onReachBottom() {
  266. if (this.data.totalPages > this.data.page) {
  267. this.setData({
  268. page: this.data.page + 1
  269. });
  270. this.getProblemList();
  271. } else {
  272. wx.showToast({
  273. title: '没有更多报备了',
  274. icon: 'none',
  275. duration: 2000
  276. });
  277. return false;
  278. }
  279. },
  280. makeCall(e) {
  281. let mobile = e.currentTarget.dataset.mobile;
  282. wx.makePhoneCall({
  283. phoneNumber: mobile,
  284. })
  285. },
  286. /**
  287. * 生命周期函数--监听页面初次渲染完成
  288. */
  289. onReady: function () {
  290. },
  291. /**
  292. * 生命周期函数--监听页面显示
  293. */
  294. onShow: function () {
  295. if (app.globalData.hasLogin == false) {
  296. wx.navigateTo({
  297. url: '/pages/index/index',
  298. })
  299. return;
  300. }
  301. if (this.data.navigateType == 0 && this.data.list.length > 0) return;
  302. this.setData({
  303. list: [],
  304. showType: this.data.showType,
  305. page: 1,
  306. limit: 10,
  307. totalPages: 1,
  308. today: util.formatDate(new Date()),
  309. });
  310. this.getProblemList();
  311. },
  312. /**
  313. * 生命周期函数--监听页面隐藏
  314. */
  315. onHide: function () {
  316. },
  317. /**
  318. * 生命周期函数--监听页面卸载
  319. */
  320. onUnload: function () {
  321. },
  322. /**
  323. * 页面相关事件处理函数--监听用户下拉动作
  324. */
  325. onPullDownRefresh: function () {
  326. },
  327. /**
  328. * 用户点击右上角分享
  329. */
  330. onShareAppMessage: function () {
  331. }
  332. })