123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 |
- const app = getApp()
- const util = require("../../../utils/util");
- const api = require('../../../api/api.js');
- const user = require('../../../utils/user.js');
- Page({
- data: {
- servant: {
- gohome: '0',
- walk: '1',
- walkDate: '', //可接单时间
- address: '',
- goHomeDate: '', //返乡时间
- goBackDate: '', //返程时间
- date: [ {
- date: '2月6日',
- lunar: '廿七',
- type: [{
- title: '全天',
- checked: true
- }, {
- title: '白班',
- checked: false
- }, {
- title: '休息',
- checked: false
- }]
- }, {
- date: '2月7日',
- lunar: '廿八',
- type: [{
- title: '全天',
- checked: true
- }, {
- title: '白班',
- checked: false
- }, {
- title: '休息',
- checked: false
- }]
- }, {
- date: '2月8日',
- lunar: '廿九',
- type: [{
- title: '全天',
- checked: true
- }, {
- title: '白班',
- checked: false
- }, {
- title: '休息',
- checked: false
- }]
- }, {
- date: '2月9日',
- lunar: '除夕',
- type: [{
- title: '全天',
- checked: true
- }, {
- title: '白班',
- checked: false
- }, {
- title: '休息',
- checked: false
- }]
- }, {
- date: '2月10日',
- lunar: '春节',
- type: [{
- title: '全天',
- checked: true
- }, {
- title: '白班',
- checked: false
- }, {
- title: '休息',
- checked: false
- }]
- }, {
- date: '2月11日',
- lunar: '初二',
- type: [{
- title: '全天',
- checked: true
- }, {
- title: '白班',
- checked: false
- }, {
- title: '休息',
- checked: false
- }]
- },{
- date: '2月12日',
- lunar: '初三',
- type: [{
- title: '全天',
- checked: true
- }, {
- title: '白班',
- checked: false
- }, {
- title: '休息',
- checked: false
- }]
- },{
- date: '2月13日',
- lunar: '初四',
- type: [{
- title: '全天',
- checked: true
- }, {
- title: '白班',
- checked: false
- }, {
- title: '休息',
- checked: false
- }]
- },{
- date: '2月14日',
- lunar: '初五',
- type: [{
- title: '全天',
- checked: true
- }, {
- title: '白班',
- checked: false
- }, {
- title: '休息',
- checked: false
- }]
- },{
- date: '2月15日',
- lunar: '初六',
- type: [{
- title: '全天',
- checked: true
- }, {
- title: '白班',
- checked: false
- }, {
- title: '休息',
- checked: false
- }]
- },{
- date: '2月16日',
- lunar: '初七',
- type: [{
- title: '全天',
- checked: true
- }, {
- title: '白班',
- checked: false
- }, {
- title: '休息',
- checked: false
- }]
- },
-
-
- ],
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- let userInfo = wx.getStorageSync('userInfo');
- if (userInfo) {} else {
- wx.navigateTo({
- url: '/pages/index/index',
- })
- }
- },
- saveNewYearReport() {
- let that = this;
- if (this.valid() == false) return;
- console.info(that.data.servant)
- wx.showModal({
- title: '提示',
- content: '请核对提交内容,确定提交吗?提交后无法修改',
- success: function (sm) {
- if (sm.confirm) {
- wx.showLoading({
- title: '提交中',
- });
- util.request(api.NewYearReport, that.data.servant, "POST").then(res => {
- wx.hideLoading();
- wx.showToast({
- title: '报备成功',
- duration: 2000
- });
- setTimeout(
- function () {
- wx.switchTab({
- url: '/pages/upgrade/my/my',
- })
- }, 3000
- );
- }).catch(res => {
- wx.hideLoading();
- wx.showToast({
- title: res.data.data,
- duration: 3000
- });
- })
- }
- }
- });
- },
- valid() {
- if (this.data.servant.gohome == '1' && (this.data.servant.address == '' || this.data.servant.goHomeDate == '' || this.data.servant.goBackDate == '' || this.data.servant.walkDate == "")) {
- wx.showToast({
- title: '请填写返乡居住地及时间',
- duration: 3000
- });
- return false;
- }
- if (this.data.servant.gohome == '1' && this.data.servant.goBackDate < this.data.servant.goHomeDate) {
- wx.showToast({
- title: '【返城】时间不能小于【返乡】时间',
- duration: 3000
- });
- return false;
- }
- return true;
- },
- radioChangeGoHome(e) {
- this.setData({
- 'servant.gohome': e.detail.value
- })
- if (e.detail.value) {
- this.setData({
- 'servant.walk': 1
- })
- }
- console.info(this.data.servant)
- },
- radioChangeWalk(e) {
- this.setData({
- 'servant.walk': e.detail.value
- })
- console.info(this.data.servant)
- },
- bindAddress(e) {
- this.setData({
- 'servant.address': e.detail.value
- })
- },
- bindGoHomeChange(e) {
- this.setData({
- 'servant.goHomeDate': e.detail.value
- })
- },
- bindGoBackChange(e) {
- this.setData({
- 'servant.goBackDate': e.detail.value
- })
- },
- bindWalkDateChange(e) {
- this.setData({
- 'servant.walkDate': e.detail.value
- })
- //小于选择的接单日期,全部设置为休息
- // var dates = this.data.servant.date;
- // var selected = this.data.servant.walkDate.substring(5).replace("-", "月") + "日";
- // if (selected.substring(0, 1) == "0")
- // selected = selected.substring(1, 5);
- // //console.info(selected)
- // dates.forEach(item => {
- // if (item.date <= selected)
- // item.type[2].checked = true;
- // })
- // this.setData({
- // 'servant.date': dates
- // });
- },
- radioDateChange(e) {
- let date = e.currentTarget.dataset.id;
- let title = e.detail.value;
- var dates = this.data.servant.date;
- dates.forEach(item => {
- if (item.date == date) {
- item.type.forEach(t => {
- t.checked = (t.title == title);
- })
- }
- });
- this.setData({
- 'servant.date': dates
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {},
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|