123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351 |
- const util = require("../../utils/util");
- const api = require('../../api/api.js');
- var app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- list: [],
- showType: 0,
- page: 1,
- limit: 10,
- totalPages: 1,
- myqr_show: false, //我的分享二维码
- myqr_url: null,
- myqr_blur: 0, //背景模糊值
- navigateType: 0, //0 进入详情页 1问题报备 1需要刷新页面
- comments: {
- ticketId:0,
- ticketSn:'',
- selected:0,//选中的星描述
- selectedDes:'',
- comment: '',
- stars: [{level:1,img: '/static/images/star.png',imgSelected:'/static/images/star@selected.png',checked:false,des:'非常差'},
- {level:2,img: '/static/images/star.png',imgSelected:'/static/images/star@selected.png',checked:false,des:'差'},
- {level:3,img: '/static/images/star.png',imgSelected:'/static/images/star@selected.png',checked:false,des:'一般'},
- {level:4,img: '/static/images/star.png',imgSelected:'/static/images/star@selected.png',checked:false,des:'满意'},
- {level:5,img: '/static/images/star.png',imgSelected:'/static/images/star@selected.png',checked:false,des:'非常满意'},]
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- },
- clickStar(e){
- let level = e.currentTarget.dataset.level;
- console.info(level)
- let stars=this.data.comments.stars;
- let des=''
- stars.forEach(item=>{
- if(item.level<=level) {
- item.checked=true;
- des=item.des
- }else{
- item.checked=false;
- }
- })
- this.setData({
- 'comments.stars':stars,
- 'comments.selectedDes':des,
- 'comments.selected':level
- })
- },
- goSaveCommnet(){//保存评论
- let that=this;
- if(that.data.comments.selected==0){
- wx.showToast({
- title:'请选择满意度',
- duration:2000
- })
- return;
- }
- if(that.data.comments.selected<4&&that.data.comments.comment==''){
- wx.showToast({
- title:'请填写有待提升的地方',
- duration:2000
- })
- return;
- }
- wx.showModal({
- title: '提示',
- content: '确定要评价此处理过程吗?提交后 无法修改',
- success: function (sm) {
- if (sm.confirm) {
- wx.showLoading();
- let data={
- ticketId:that.data.comments.ticketId,
- ticketSn:that.data.comments.ticketSn,
- comment:that.data.comments.comment,
- star:that.data.comments.selected
- }
- util.request(api.ProblemComment,data,"POST").then(res=>{
- wx.hideLoading();
- let list=that.data.list;
- list.forEach(item=>{
- if(item.ticketId==that.data.comments.ticketId){
- item.isCommented=true;
- }
- })
- let comments=that.data.comments;
- comments.selected=0;
- comments.selectedDes="";
- comments.comment="";
- comments.stars.forEach(star=>{
- star.checked=false;
- })
- that.setData({
- myqr_blur: 0,
- myqr_show: false,
- comments:comments,
- list:list
- })
- wx.showToast({
- title: '评价成功',
- duration: 3000
- }).catch(res=>{
- wx.hideLoading();
- wx.showToast({
- title: res.errmsg,
- duration: 3000
- });
- });
- })
- }
- }
- })
- },
- goComment(e) { //去评论
- // wx.pageScrollTo({
- // scrollTop: 0
- // });
- let id = e.currentTarget.dataset.id;
- let sn = e.currentTarget.dataset.sn;
- this.setData({
- myqr_show: true,
- myqr_blur: 0,
- 'comments.ticketId':id,
- 'comments.ticketSn':sn
- })
- },
- qrtouchstart: function () {
- this.setData({
- myqr_blur: 0,
- myqr_show: false
- });
- },
- bindCommentRemark(e){
- this.setData({
- 'comments.comment':e.detail.value
- })
- },
- goProblemList() {
- this.setData({
- navigateType: 1
- })
- wx.navigateTo({
- url: '/pages/problem/list/list',
- })
- },
- goUrge(e) { //催促办理
- let sn = e.currentTarget.dataset.sn;
- let that = this;
- wx.showLoading();
- util.request(api.ProblemUrge, {
- ticketSn: sn
- }).then(function (res) {
- wx.hideLoading();
- if (res.errno === 0) {
- //设置为已催办
- let list = that.data.list;
- list.forEach(item => {
- if (item.ticketSn == sn) {
- item.status = "处理中-升级"
- }
- })
- that.setData({
- list: list
- })
- wx.showToast({
- title: '已催促负责人尽快办理',
- duration: 3000
- });
- }
- });
- },
- goDetail(e) {
- this.setData({
- navigateType: 0
- })
- let sn = e.currentTarget.dataset.sn;
- wx.navigateTo({
- url: '/pages/problem/action/action?ticketSn=' + sn,
- })
- },
- goCancel(e) { //取消报备
- let that = this;
- let sn = e.currentTarget.dataset.sn;
- wx.showModal({
- title: '取消报备',
- content: '确定要取消此报备吗?',
- showCancel: true, //是否显示取消按钮
- cancelText: "否", //默认是“取消”
- cancelColor: 'skyblue', //取消文字的颜色
- confirmText: "是", //默认是“确定”
- confirmColor: 'skyblue', //确定文字的颜色
- success: function (res) {
- if (res.cancel) {
- //点击取消,默认隐藏弹框
- } else {
- //点击确定
- util.request(api.ProblemCancel, {
- 'ticketSn': sn
- }).then(res => {
- let list = that.data.list;
- list.forEach(item => {
- if (item.ticketSn == sn) {
- item.status = "作废";
- item.statusId = 3;
- }
- })
- that.setData({
- list: list
- })
- wx.showToast({
- title: '已取消成功',
- duration: 3000
- });
- })
- }
- },
- fail: function (res) {}, //接口调用失败的回调函数
- complete: function (res) {}, //接口调用结束的回调函数(调用成功、失败都会执行)
- })
- },
- goQuickList() {
- this.setData({
- navigateType: 1
- })
- wx.navigateTo({
- url: '/pages/problem/quick/quick',
- })
- },
- getProblemList() {
- let that = this;
- wx.showLoading();
- util.request(api.ProblemList, {
- showType: that.data.showType,
- page: that.data.page,
- limit: that.data.limit
- }).then(function (res) {
- wx.hideLoading();
- if (res.errno === 0) {
- console.log(res.data);
- that.setData({
- list: that.data.list.concat(res.data.list),
- totalPages: res.data.pages
- });
- }
- });
- },
- switchTab: function (event) {
- let showType = event.currentTarget.dataset.index;
- console.log(showType);
- wx.setStorageSync('tab', showType);
- this.setData({
- list: [],
- showType: showType,
- page: 1,
- limit: 10,
- totalPages: 1
- });
- this.getProblemList();
- },
- onReachBottom() {
- if (this.data.totalPages > this.data.page) {
- this.setData({
- page: this.data.page + 1
- });
- this.getProblemList();
- } else {
- wx.showToast({
- title: '没有更多报备了',
- icon: 'none',
- duration: 2000
- });
- return false;
- }
- },
- makeCall(e) {
- let mobile = e.currentTarget.dataset.mobile;
- wx.makePhoneCall({
- phoneNumber: mobile,
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- if (app.globalData.hasLogin == false) {
- wx.navigateTo({
- url: '/pages/index/index',
- })
- return;
- }
- if (this.data.navigateType == 0 && this.data.list.length > 0) return;
- this.setData({
- list: [],
- showType: this.data.showType,
- page: 1,
- limit: 10,
- totalPages: 1,
- today: util.formatDate(new Date()),
- });
- this.getProblemList();
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|