123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- const app = getApp()
- const util = require("../../../utils/util");
- const api = require('../../../api/api.js');
- // const update = require('../../../api/update.js');
- const user = require('../../../utils/user.js');
- import moment from 'moment'
- Page({
- data: {
- labelName:[],
- homeInfo:{
- onPositionYear:'',
- salary:'',
- total:'',
- unReadSize:"",
- workerInfo:{},
- workerNotice:[],
- stationAdminName:'',
- stationAdminTel:''
- },
- salary:{
- salary:'',
- total:''
- },
- hasLogin:true,
- currentDate:moment(new Date()).format('YYYY-MM-DD'),
- currentWeek:'',
- myRebuyInfo:{
- looseOrderRebuy:0,
- looseOrder:0,
- cycleOrderRebuy:0,
- cycleOrder:0,
- looseOrderRebuyRate:0,
- cycleOrderRebuyRate:0
- },
- animate:false,
- msgList:[
- {
- text:'工单1:产生【差评】工单,请及时关注!'
- },
- {
- text:'工单2:产生【差评】工单,请及时关注!'
- },
-
- {
- text:'工单3:产生【差评】工单,请及时关注!'
- }
- ]
-
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- // setInterval(this.messageScroll,2000);
- // let week=util.getWeek(this.data.currentDate);
- // this.setData({
- // currentWeek:week
- // });
- // this.getRebuyInfo();
- // this.isNewYearReport();
- // this.getHomeInfo()
- },
- isNewYearReport() { //是否新年报备
- util.request(api.NewYearReported).then(res => {
- if (res.data) {
- wx.showModal({
- title: '返乡调查',
- content: '新年返乡调查已开始,是否现在去报备?',
- success: function (sm) {
- if (sm.confirm) {
- wx.navigateTo({
- url: '/pages/servant/gohome/report',
- })
- }
- }
- });
- }
- })
- },
- lastWeek(){
- let current=moment(new Date((new Date(this.data.currentDate)).getTime()-7*24*60*60*1000)).format('YYYY-MM-DD');
- console.log(current);
- let week=util.getWeek(current);
- this.setData({
- currentDate:current,
- currentWeek:week
- });
- this.getRebuyInfo();
- },
- nextWeek(){
- let current=moment(new Date((new Date(this.data.currentDate)).getTime()+7*24*60*60*1000)).format('YYYY-MM-DD');
- console.log(current);
- let week=util.getWeek(current);
- this.setData({
- currentDate:current,
- currentWeek:week
- });
- this.getRebuyInfo();
- },
- getRebuyInfo(){
- util.request(api.myRebuyInfo, {
- date: this.data.currentDate,
-
- }, 'GET').then(res=> {
- if (res.errno === 0) {
- this.setData({
- myRebuyInfo:res.data
- });
- }
-
- });
- },
- messageScroll(){
- this.setData({
- animate:true
- });
- setTimeout(()=>{
- let list=this.data.msgList;
- list.push(list[0]);
- this.setData({
- msgList:list
- });
- list.shift();
- this.setData({
- msgList:list,
- animate:false
- });
- },3000);
- },
- makeCall(e){
- let mobile = e.currentTarget.dataset.mobile;
- wx.makePhoneCall({
- phoneNumber: mobile,
- })
- },
- 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.navigateTo({
- url: '/pages/index/index'
- });
- }
- })
- },
- getHomeInfo(){
- util.request(api.homeInfo, {}, 'GET').then(res=> {
- console.log(res);
- if (res.errno === 0) {
- console.log(res.data.workerInfo.labelNames);
- console.log(res.data.workerInfo.labelNames.split(','));
- this.setData({
- homeInfo:res.data,
- labelName:res.data.workerInfo.labelNames==""?[]:res.data.workerInfo.labelNames.split(','),
- 'homeInfo.unReadSize':res.data.unReadSize>99?99:res.data.unReadSize
- });
- }
-
- });
- },
- goLeave(){//请假
- wx.navigateTo({
- url: '/pages/servant/leave/leave',
- });
- // wx.showModal({
- // title: '提醒',
- // content: '暂未开通,敬请期待',
- // showCancel: false
- // });
- },
- goHouse(){
-
- wx.showModal({
- title: '提醒',
- content: '暂未开通,敬请期待',
- showCancel: false
- })
- },
- getPerfect(){
- wx.navigateTo({
- url: '/pages/servant/perfect/perfectWorkerInfo'
- })
- },
- goBookIndex(e) {
- if (this.data.hasLogin) {
- let tab = e.currentTarget.dataset.index
- let route = e.currentTarget.dataset.route
- try {
- wx.setStorageSync('tab', tab);
- } catch (e) {
- }
- wx.navigateTo({
- url: route,
-
- })
- } else {
- wx.navigateTo({
- url: "/pages/index/index"
- });
- };
- },
- goNucleicList() {
- wx.navigateTo({
- url: '/pages/servant/nucleic/list'
- });
- },
- goMessage(){
- wx.navigateTo({
- url: '/pages/upgrade/messageList/messageList'
- })
- },
- goSalaryDetail(e) { //查询工资明细
- // const {
- // year,
- // month
- // } = calendar.getCurrentYM();
- // let m = '11';
- // if (m < 10) m = '0' + String(m);
- // let year='2022-';
- let month=moment(new Date()).format('YYYY-MM');
-
- let type = e.currentTarget.dataset.type;
- let total = (type == 1 ? this.data.homeInfo.salary : this.data.homeInfo.total);
- //servantType 表示服务者身份99是临时服务者 明细页可以显示提现按钮
- wx.navigateTo({
- url: '/pages/servant/salary/detail/detail?month=' + month + '&total=' + total + '&type=' + type+'&servantType='+''+'&blance='+this.data.homeInfo.salary
- });
- },
- goNucleicList() {
- wx.navigateTo({
- url: '/pages/servant/nucleic/list'
- })
- },
- copyNum(){
-
- wx.setClipboardData({
- data: this.data.homeInfo.workerShareCode,
- success: function (res) {
- console.log(res);
- wx.showToast({
- title: '复制成功',
- icon: 'none',
- duration: 2000
- });
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- // setInterval(this.messageScroll,2000);
- let week=util.getWeek(this.data.currentDate);
- this.setData({
- currentWeek:week
- });
- this.getRebuyInfo();
- this.isNewYearReport();
- this.getHomeInfo()
-
- },
-
- onHide: function () {
- },
- onUnload: function () {
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
-
- })
|