123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753 |
- const app = getApp()
- const util = require("../../../utils/jmsUtil.js");
- const api = require('../../../api/jms.js');
- import moment from 'moment'
- Page({
- data: {
- timer: "",
- dayCalendar: {
- day: '',
- workerOrderInfoDTOList: [],
- workerName: '',
- //isCashout:false//是否可提现
- },
- currentMonth: moment(new Date()).format('YYYY-MM'),
- calcendarFold: true,
- stickShow: false,
- today: util.formetdate(new Date()),
- currentDay: util.formetdate(new Date()),
- isLeaveFold: true,
- orderDisable: true,
- orderDisable1: false,
- activeTab: 1,
- ticketList: [{}, {}],
- monthInfo: {
- recCode: '',
- fraName: '',
- workerName: '',
- isCashout: false, //是否可提现
- },
- workerDayInfoList: [],
- weekCalendar: [],
- wholeCalendar: [],
- myqr_show: false,
- myqr_url: '',
- myqr_blur: 0, //背景模糊值
- options: [{
- value: "rebuy",
- text: '复购码'
- },{
- value: "coupon",
- text: '优惠券'
- }],
- itemValue:''
- },
- onPageScroll(e) {
- // console.log(e.scrollTop);
- // if(e.scrollTop > 200){
- // this.setData({
- // stickShow: true
- // });
- // } else {
- // this.setData({
- // stickShow: false
- // });
- // }
- },
- leaveFold() {
- let fold = this.data.isLeaveFold;
- this.setData({
- isLeaveFold: !fold
- });
- },
- goCash() {
- wx.navigateTo({
- url: '/pages/temp/cash/index',
- })
- },
- copyCode(e) {
- let code = this.data.monthInfo.recCode;
- wx.setClipboardData({
- data: code,
- success: function (res) {
- wx.showToast({
- title: '复制成功',
- icon: 'none',
- duration: 2000
- });
- }
- })
- },
- copyNum(e) {
- let bookno = e.currentTarget.dataset.bookno;
- console.log(bookno);
- wx.setClipboardData({
- data: bookno,
- success: function (res) {
- wx.showToast({
- title: '复制成功',
- icon: 'none',
- duration: 2000
- });
- }
- })
- },
- callUp(e) {
- let status = e.currentTarget.dataset.status;
- let phone = e.currentTarget.dataset.phone;
- if (status == '待履约' || status == '服务中') {
- wx.makePhoneCall({
- phoneNumber: phone
- });
- }
- },
- openMap(e) { //打开地图
- let status = e.currentTarget.dataset.status;
- let address = e.currentTarget.dataset.address;
- if (status == '待履约' || status == '服务中') {
- let lnglat = e.currentTarget.dataset.lnglat.split(',');
- let lng = '';
- let lat = "";
- if (lnglat.length > 0) {
- lng = Number(lnglat[0]);
- lat = Number(lnglat[1]);
- }
- console.log(lng, lat);
- wx.openLocation({
- latitude: lat,
- longitude: lng,
- // name: address,
- address: address,
- scale: 28
- });
- }
- },
- goSchedule() {
- wx.navigateTo({
- url: '/pages/upgrade/scheduleCalc/scheduleCalc',
- })
- },
- goDetail(e) {
- let id = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: '/pages/upgrade/ticketDetail/ticketDetail?bookTradeNo=' + id,
- });
- },
- evalMaster(e) {
- let id = e.currentTarget.dataset.id;
- let workerno = e.currentTarget.dataset.workerno;
- this.setData({
- evalMasterShow: true,
- star: 0,
- masterComment: '',
- bookTradeNo: id,
- workerNo: workerno
- });
- },
- onClickMsterOverlay() {
- this.setData({
- evalMasterShow: false,
- });
- },
- onClickDiscipleOverlay() {
- this.setData({
- evalDiscipleShow: false,
- });
- },
- onStarChange(event) {
- this.setData({
- star: event.detail,
- });
- },
- onRadioChange(event) {
- this.setData({
- radioDisciple: event.detail,
- });
- },
- bindMasterComment(e) {
- this.setData({
- masterComment: e.detail.value
- })
- },
- bindDiscipleComment(e) {
- this.setData({
- discipleComment: e.detail.value
- })
- },
- stop: function () {
- //阻止弹框冒泡和捕获的空事件,不要删除!!!
- },
- submitEvalMaster() {
- if (this.data.star == 0) {
- wx.showToast({
- title: '请选择评价星级',
- icon: 'none'
- })
- } else if (this.data.masterComment == '') {
- wx.showToast({
- title: '请输入跟单体会',
- icon: 'none'
- })
- } else {
- util.request(api.discipleFeedback, {
- feedback: this.data.discipleComment,
- level: this.data.star,
- bookTradeNo: this.data.bookTradeNo,
- workerNo: this.data.workerNo
- }, 'GET').then(res => {
- if (res.errno === 0) {
- wx.showToast({
- title: '评价成功',
- icon: 'none'
- })
- this.setData({
- evalMasterShow: false,
- });
- this.getDayCalendar();
- } else {
- wx.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- });
- }
- },
- evalDisciple(e) {
- let id = e.currentTarget.dataset.id;
- let workerno = e.currentTarget.dataset.workerno;
- this.setData({
- evalDiscipleShow: true,
- radioDisciple: '通过',
- discipleComment: '',
- bookTradeNo: id,
- workerNo: workerno
- });
- },
- submitEvalDisciple() {
- if (this.data.radioDisciple == '') {
- wx.showToast({
- title: '请选择是否通过',
- icon: 'none'
- })
- } else if (this.data.discipleComment == '') {
- wx.showToast({
- title: '请输入内容',
- icon: 'none'
- })
- } else {
- util.request(api.masterFeedback, {
- remark: this.data.discipleComment,
- feedback: this.data.radioDisciple,
- bookTradeNo: this.data.bookTradeNo,
- workerNo: this.data.workerNo
- }, 'GET').then(res => {
- if (res.errno === 0) {
- wx.showToast({
- title: '评价成功',
- icon: 'none'
- })
- this.setData({
- evalDiscipleShow: false,
- });
- this.getDayCalendar();
- } else {
- wx.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- });
- }
- },
- goProblemList(e) {
- // this.setData({
- // navigateType: 1
- // })
- console.log( e.currentTarget.dataset);
- let booktradeno = e.currentTarget.dataset.booktradeno;
- wx.navigateTo({
- url: '/pages/problem/list/list?bookTradeNo=' + booktradeno,
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- // let current=this.data.wholeCalendar.filter(item=>{return item.day==this.data.currentDay});
- // if(current.length==0){
- // return false;
- // }
- // let week=current[0].weekOfYear;
- // let weekCalendar=this.data.wholeCalendar.filter(item=>{
- // return item.weekOfYear==week;
- // });
- // this.setData({
- // workerDayInfoList:weekCalendar,
- // weekCalendar:weekCalendar
- // });
- this.getMonthCalender(false, 'first');
- // this.getDayCalendar();
- },
- closeMyQr() {
- this.setData({
- myqr_show: false,
- myqr_blur: 0
- });
- },
- goSaveQrcode: function () { //保存二维码图片
- let that = this;
- console.info(that.data.myqr_url);
- wx.downloadFile({
- url: that.data.myqr_url,
- success: function (res) {
- if (res.statusCode === 200) {
- let img = res.tempFilePath;
- wx.saveImageToPhotosAlbum({
- filePath: img,
- success(res) {
- that.closeMyQr();
- wx.showModal({
- title: '提示',
- showCancel: false,
- content: '此单复购专属二维码图片已保存到您的相册'
- })
- },
- fail(res) {
- wx.showModal({
- title: '提示',
- showCancel: false,
- content: '网络或授权问题 图片保存失败 请重试'
- })
- }
- })
- } else
- wx.showModal({
- title: '提示',
- showCancel: false,
- content: '网络或授权问题 图片保存失败 请重试'
- })
- },
- fail(res) {
- wx.showModal({
- title: '提示',
- showCancel: false,
- content: '网络或授权问题 图片保存失败 请重试'
- })
- }
- })
- },
- getCouponCode(e) { //优惠券
- let bookno = e.currentTarget.dataset.bookno;
- util.request(api.getWorkerCouponCode, {
- bookTradeNo: bookno
- }, 'GET').then(res => {
- if (res.errno === 0) {
- wx.showToast({
- title: '获取成功',
- icon: 'none'
- })
- this.setData({
- myqr_show: true,
- myqr_blur: 20,
- myqr_url: res.data
- });
- wx.pageScrollTo({
- scrollTop: 0,
- });
- } else {
- wx.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- });
- },
- getQrCode(e) { //获取复购码
- let bookno = e.currentTarget.dataset.bookno;
- util.request(api.getWorkerQrCode, {
- bookTradeNo: bookno
- }, 'GET').then(res => {
- if (res.errno === 0) {
- wx.showToast({
- title: '获取成功',
- icon: 'none'
- })
- this.setData({
- myqr_show: true,
- myqr_blur: 20,
- myqr_url: res.data
- });
- wx.pageScrollTo({
- scrollTop: 0,
- });
- } else {
- wx.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- });
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.getDayCalendar();
- let timer = setInterval(() => {
- console.log('定时刷新日历数据', new Date());
- this.getMonthCalender();
- this.getDayCalendar();
- }, 2 * 60 * 1000);
- this.setData({
- timer: timer
- });
- },
- onHide: function () {
- console.log('onHide');
- clearInterval(this.data.timer);
- },
- onUnload: function () {
- console.log('onunload');
- clearInterval(this.data.timer);
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- this.getMonthCalender();
- this.getDayCalendar();
- },
- getDayCalendar() {
- wx.showLoading({
- title: '加载中...',
- });
- util.request(api.dayCalender, {
- date: this.data.currentDay,
- }, 'GET').then(res => {
- console.log(res);
- wx.hideLoading();
- if (res.errno === 0) {
- this.setData({
- dayCalendar: res.data
- });
- }
- }).catch(err => {
- wx.hideLoading();
- });
- },
- getMonthCalender(flag, tag) {
- wx.showLoading({
- title: '加载中...',
- });
- util.request(api.monthCalender, {
- month: this.data.currentMonth,
- }, 'GET').then(res => {
- console.log(res);
- wx.hideLoading();
- if (res.errno === 0) {
- this.setData({
- monthInfo: res.data,
- wholeCalendar: res.data.workerDayInfoList
- });
- if (flag) {
- this.setData({
- calcendarFold: false,
- workerDayInfoList: this.data.wholeCalendar,
- });
- }
- let current = this.data.wholeCalendar.filter(item => {
- return item.day == this.data.currentDay
- });
- if (current.length == 0) {
- return false;
- }
- let week = current[0].weekOfYear;
- let weekCalendar = this.data.wholeCalendar.filter(item => {
- return item.weekOfYear == week;
- });
- this.setData({
- weekCalendar: weekCalendar
- });
- if (tag == 'first') {
- this.setData({
- workerDayInfoList: weekCalendar,
- });
- }
- if (this.data.calcendarFold) {
- this.setData({
- workerDayInfoList: weekCalendar,
- });
- } else {
- this.setData({
- workerDayInfoList: this.data.wholeCalendar,
- });
- }
- } else {
- wx.showToast({
- title: res.errmsg,
- duration: 3000,
- icon: 'none'
- });
- }
- }).catch(err => {
- wx.hideLoading();
- });
- },
- switchDay(e) {
- let day = e.currentTarget.dataset.day;
- this.setData({
- currentDay: day
- });
- this.getDayCalendar();
- },
- calcendarCollapse() {
- let calcendarFold = this.data.calcendarFold;
- if (calcendarFold) {
- this.setData({
- workerDayInfoList: this.data.wholeCalendar,
- calcendarFold: !calcendarFold
- });
- } else {
- this.setData({
- workerDayInfoList: this.data.weekCalendar,
- calcendarFold: !calcendarFold
- });
- }
- },
- lastMonth() {
- console.log(this.data);
- let params = util.getYearMonth(this.data.currentMonth, '-');
- this.setData({
- currentMonth: params
- });
- this.getMonthCalender(true);
- },
- nextMonth() {
- let params = util.getYearMonth(this.data.currentMonth, '+');
- console.log(params);
- this.setData({
- currentMonth: params
- });
- this.getMonthCalender(true);
- },
- goIssueTicket() {
- wx.navigateTo({
- url: '/pages/upgrade/issueTicket/issueTicket',
- })
- },
- arriveCus(e) {
- let status = e.currentTarget.dataset.status;
- let id = e.currentTarget.dataset.id;
- if (status == '待履约') {
- wx.showModal({
- title: '',
- content: '确定已经到门?',
- success: res => {
- if (res.confirm) {
- util.request(api.ClockIn, {
- relationTradeNo: id,
- }, 'POST').then(res => {
- if (res.errno === 0) {
- wx.showToast({
- title: '操作成功'
- });
- this.getDayCalendar();
- } else {
- wx.showToast({
- title: res.errmsg,
- icon: 'none'
- });
- // util.showErrorToast(res.errmsg);
- }
- });
- }
- }
- });
- }
- },
- finishOrder(e) {
- let status = e.currentTarget.dataset.status;
- let id = e.currentTarget.dataset.id;
- if (status == '服务中') {
- wx.showModal({
- title: '',
- content: '确定服务完成?',
- success: res => {
- if (res.confirm) {
- util.request(api.ServiceProvided, {
- relationTradeNo: id,
- }, 'POST').then(res => {
- if (res.errno === 0) {
- wx.showToast({
- title: '操作成功'
- });
- this.getDayCalendar();
- } else {
- wx.showToast({
- title: res.errmsg,
- icon: 'none'
- });
- // util.showErrorToast(res.errmsg);
- }
- });
- }
- }
- });
- }
- },
- exitLogin: function () {
- wx.showModal({
- title: '',
- confirmColor: '#b4282d',
- content: '退出登录?',
- success: function (res) {
- if (!res.confirm) {
- return;
- }
- // util.request(api.AuthLogout, {}, 'POST');
- app.globalData.hasLogin = false;
- wx.removeStorageSync('token');
- wx.removeStorageSync('userInfo');
- // wx.redirectTo({
- // url: '/pages/temp/login/login'
- // });
- wx.redirectTo({
- url: '/pages/index/index'
- });
- }
- })
- },
- supplyCode(e) {
- let bookno = e.currentTarget.dataset.bookno;
- if (bookno.startsWith('JZ')) {
- bookno = bookno.substr(2);
- }
- util.request(api.createMakeUpQRCode, {
- serviceId: bookno
- }, 'GET').then(res => {
- if (res.errno === 0) {
- let url = res.data;
- wx.previewImage({
- current: url, // 当前显示图片的http链接
- urls: [url] // 需要预览的图片http链接列表
- })
- } else {
- wx.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- });
- },
- supplyCode(e){
- let bookno = e.currentTarget.dataset.bookno;
- if (bookno.startsWith('JZ')) {
- bookno = bookno.substr(2);
- }
- app.globalData.diffId=0;
- wx.navigateTo({
- url: '/pages/serviceSupply/serviceSupply?bookno='+bookno,
- });
- },
- supplyRecord(e){
- let bookno = e.currentTarget.dataset.bookno;
- if (bookno.startsWith('JZ')) {
- bookno = bookno.substr(2);
- }
- wx.navigateTo({
- url: '/pages/supplyRecord/supplyRecord?bookno='+bookno,
- });
- },
- onReachBottom() {
- // if (this.data.totalPages > this.data.page) {
- // this.setData({
- // page: this.data.page + 1
- // });
- // this.getGoodsList();
- // } else {
- // wx.showToast({
- // title: '没有更多商品了',
- // icon: 'none',
- // duration: 2000
- // });
- // return false;
- // }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- })
|