| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- const app = getApp();
- const verify = require("../../../common/js/verify.js");
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- shift: '',
- time: '09:00',
- date: '',
- startDate: '',
- image: '',
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- const now = new Date();
- const date = `${now.getFullYear()}-${String(now.getMonth()+1).padStart(2,'0')}-${String(now.getDate()).padStart(2,'0')}`;
- this.setData({
- date: date,
- startDate: date
- });
- },
- TimeChange(e) {
- this.setData({
- time: e.detail.value
- });
- },
- DateChange(e) {
- this.setData({
- date: e.detail.value
- });
- },
- vmodel(e) {
- this.setData({
- [e.currentTarget.dataset.value]: e.detail.value
- })
- },
- ChooseImage() {
- let that = this;
- wx.chooseMedia({
- count: 1,
- success: (res) => {
- app.upload(res.tempFiles[0].tempFilePath, function (res) {
- that.setData({image: res});
- });
- },
- fail: () => {
- app.msg('请检查相册权限是否开启');
- }
- });
- },
- DelImg(e) {
- this.setData({image:''});
- },
- ViewImage(e) {
- wx.previewImage({
- urls: [this.data.image],
- });
- },
- submit() {
- let self = this;
- if (verify.isEmpty(this.data.shift) && verify.isEmpty(this.data.image)) {
- app.msg('班次/出发时间和车票图片至少要填一样');
- return false;
- }
- app.post('talent/appointment/book', {
- shift: this.data.shift,
- date: this.data.date,
- time: this.data.time,
- image: this.data.image
- }, function (res) {
- self.toList();
- });
- },
- toList() {
- wx.redirectTo({
- url: '/pages/talent/appointment/list',
- })
- }
- })
|