123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- const util = require("../../../utils/util");
- const api = require('../../../api/api.js');
- var app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- list: [],
- showType: 0,
- page: 1,
- limit: 10,
- totalPages: 0,
- myqr_show: false, //显示追加信息框
- myqr_blur: 1, //背景模糊值
- content: '',
- ticketSn: '', //当前处理的工单
- action: '' //操作工单动作 是处理 还是完结
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.getList();
- },
- ticketHandle() {
- if (this.data.action == "handle")
- this.saveHandle();
- else this.saveCompleted();
- },
- saveHandle() { //工单处理
- let that = this
- if (!that.data.content) {
- wx.showToast({
- title: '请输入处理内容',
- duration: 3000
- });
- return;
- }
- wx.showLoading();
- util.request(api.TicketHandle, {
- ticketSn: that.data.ticketSn,
- content: that.data.content
- }).then(function (res) {
- wx.hideLoading();
- that.handleFilter();
- if (res.errno === 0) {
- that.setData({
- content: '',
- myqr_blur: 1,
- myqr_show: false
- })
- wx.showToast({
- title: '处理成功',
- duration: 3000
- });
- } else {
- util.showErrorToast(res.errmsg);
- }
- });
- },
- saveCompleted(e) {
- let that = this
- if (!that.data.content) {
- wx.showToast({
- title: '请输入处理内容',
- duration: 3000
- });
- return;
- }
- wx.showLoading();
- util.request(api.TicketCompleted, {
- ticketSn: that.data.ticketSn,
- content: that.data.content
- }).then(function (res) {
- wx.hideLoading();
- that.handleFilter();
- if (res.errno === 0) {
- that.setData({
- content: '',
- myqr_blur: 1,
- myqr_show: false
- })
- wx.showToast({
- title: '工单完结',
- duration: 3000
- });
- } else {
- util.showErrorToast(res.errmsg);
- }
- });
- },
- handleFilter(){
- var showType=this.data.showType;
- this.setData({
- list: [],
- showType: showType,
- page: 1,
- limit: 10,
- totalPages: 1
- });
- this.getList();
- },
- switchTab(e) {
- let showType = e.currentTarget.dataset.index;
- this.setData({
- list: [],
- showType: showType,
- page: 1,
- limit: 10,
- totalPages: 1
- });
- this.getList();
- },
- goHandle(e) {
- wx.pageScrollTo({
- scrollTop: 0
- });
- this.setData({
- myqr_show: true,
- myqr_blur: 1,
- ticketSn: e.currentTarget.dataset.sn,
- content: '',
- action: 'handle'
- })
- },
- goCompleted(e) {
- wx.pageScrollTo({
- scrollTop: 0
- });
- this.setData({
- myqr_show: true,
- myqr_blur: 1,
- ticketSn: e.currentTarget.dataset.sn,
- content: '',
- action: 'completed'
- })
- },
- qrtouchstart: function () {
- this.setData({
- myqr_blur: 1,
- myqr_show: false,
- });
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- bindContent(e) {
- this.setData({
- content: e.detail.value
- })
- },
- getList() {
- let that = this;
- wx.showLoading();
- util.request(api.TicketList, {
- 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
- });
- }
- });
- },
- onReachBottom() {
- if (this.data.totalPages > this.data.page) {
- this.setData({
- page: this.data.page + 1
- });
- this.getList();
- } else {
- wx.showToast({
- title: '没有更多工单了',
- icon: 'none',
- duration: 2000
- });
- return false;
- }
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {},
- viewTicket(e) {
- wx.navigateTo({
- url: '/pages/servant/crm/ticketAction?ticketSn=' + e.currentTarget.dataset.sn
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|