小程序新請(qǐng)假界面
效果:
.wxml:
新請(qǐng)假 請(qǐng)假結(jié)果 上傳圖片: + 添加圖片 \r\n\r\n\r\n\r\n\r\n\r\n年級(jí): \r\n\r\n\r\n\r\n\r\n\r\n班級(jí): \r\n\r\n\r\n\r\n\r\n\r\n學(xué)號(hào): 請(qǐng)假天數(shù): 開(kāi)始時(shí)間: {{date}} 結(jié)束時(shí)間: {{date1}} 請(qǐng)假類型: 請(qǐng)假理由: 達(dá)叔小生
.wxss:
Page { background-color: #f1f1f1; } .head_item { width: 374rpx; text-align: center; font-size: 34rpx; color: #999; letter-spacing: 0; } .head_itemActive { color: #30d1ff; } .ring { width: 2rpx; height: 100%; background-color: rgba(204, 204, 204, 1); } .head { width: 100%; height: 100rpx; background-color: rgba(255, 255, 255, 1); border-bottom: 1rpx solid rgba(204, 204, 204, 1); display: flex; align-items: center; justify-content: space-between; position: fixed; top: 0; z-index: 10; } .main { position: absolute; width: 100%; height: 100%; display: block; box-sizing: border-box; padding-top: 100rpx; top: 0; } .show { display: block; text-align: center; } .hidden { display: none; text-align: center; } /* 新請(qǐng)假 */ .uploader { position: relative; width: 168rpx; height: 168rpx; background: #f0f0f2; border-radius: 10rpx; } .uploaderpic { width: 168rpx; height: 168rpx; margin-top: 10rpx; border-radius: 10rpx; } .add-icon { position: absolute; font-size: 105rpx; top: -23rpx; left: 50rpx; color: #a3a3a3; } .title { position: absolute; bottom: 30rpx; left: 32rpx; color: #a3a3a3; font-size: 28rpx; } .upload-img { width: 95%; height: 95%; border-radius: 10rpx; } .bg { margin: 40rpx; background-color: #fff; border: 2rpx dotted #ccc; border-radius: 15rpx; height: 100%; } .item { display: flex; flex-direction: row; font-size: 30rpx; margin: 25rpx; align-items: center; } .btn { background-color: #79caff; color: #fff; width: 120rpx; font-size: 30rpx; margin-top: 30rpx; } .bk { border-radius: 10rpx; border: 2rpx solid #ccc; padding: 10rpx; width: 65%; }
.js
var dateTimePicker = require('../../utils/dateTimePicker.js'); var util = require('../../utils/util.js'); Page({ // 頁(yè)面的初始數(shù)據(jù) data: { date: '', date1: '', selected: true, selected1: false, articles: [], upload: true, files: [], sum: 0, }, // 上傳圖片 previewImage: function() { wx.chooseImage({ count: 1, sizeType: ['compressed'], // 可以指定是原圖還是壓縮圖 sourceType: ['album', 'camera'], // 可以指定來(lái)源是相冊(cè)還是相機(jī),默認(rèn)二者都有 success: (res) => { console.log(res) // 打印輸出返回值 let files = this.data.files files.push(res.tempFilePaths[0]) // 把圖片地址push到數(shù)組中 let sum = this.data.sum sum++ // 開(kāi)始計(jì)數(shù) this.setData({ sum: sum }) if (this.data.sum == 1) { this.setData({ upload: false }) } // tempFilePath可以作為img標(biāo)簽的src屬性顯示圖片 this.setData({ files: files }); } }) }, // 刪除圖片 delete: function(e) { let index = e.currentTarget.dataset.index let files = this.data.files files.splice(index, 1) this.setData({ files: files }) if (this.data.files.length == 0) { this.setData({ upload: true, sum: 0 }) } }, // 保存 formSubmit: function(e) { var that = this; console.log('form發(fā)生了submit事件,攜帶數(shù)據(jù)為:', e.detail.value); let data = e.detail.value; if (that.data.files[0] !== null) { data.certificate = that.data.files[0]; } console.log(data); wx.request({ url: '####', method: 'POST', data: JSON.stringify(data), header: { 'Authorization': 'Bearer' + wx.getStorageSync('token'), }, success(res) { console.log("綁定", res); wx.showModal({ title: '提示', content: res.data.msg, showCancel: false, success: function(res) { if (res.confirm) { console.log('用戶點(diǎn)擊確定'); } } }) }, fail: function(fail) { wx.showModal({ title: '提示', content: '輸入有誤,請(qǐng)重新輸入', showCancel: false, success: function(res) { if (res.confirm) { console.log('用戶點(diǎn)擊確定'); } } }) } }) }, // 時(shí)間 changeDate(e) { this.setData({ date: e.detail.value, }); }, changeDate1(e) { this.setData({ date1: e.detail.value, }); }, // 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面加載 onLoad: function(options) { // 獲取當(dāng)天時(shí)間 var that = this; var time = util.formatTime(new Date()).substring(0, 10); console.log(time) that.setData({ date: time, date1: time, }); // 獲取完整的年月日 時(shí)分秒,以及默認(rèn)顯示的數(shù)組 var obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear); var obj1 = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear); // 精確到分的處理,將數(shù)組的秒去掉 var lastArray = obj1.dateTimeArray.pop(); var lastTime = obj1.dateTime.pop(); }, selected: function(e) { this.setData({ selected1: false, selected: true }) }, selected1: function(e) { this.setData({ selected: false, selected1: true }) }, // 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面初次渲染完成 onReady: function() { }, // 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面顯示 onShow: function() { }, // 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面隱藏 onHide: function() { }, // 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面卸載 onUnload: function() { }, })
.json
{ "navigationBarTitleText": "請(qǐng)假" }
往后余生,唯獨(dú)有你
簡(jiǎn)書(shū)作者:達(dá)叔小生
90后帥氣小伙,良好的開(kāi)發(fā)習(xí)慣;獨(dú)立思考的能力;主動(dòng)并且善于溝通
簡(jiǎn)書(shū)博客: https://www.jianshu.com/u/c785ece603d1
- 下面我將繼續(xù)對(duì) 其他知識(shí) 深入講解 ,有興趣可以繼續(xù)關(guān)注
- 小禮物走一走 or 點(diǎn)贊
以上就是本文的全部?jī)?nèi)容,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來(lái)一定的幫助,也希望大家多多支持 我們
聲明:所有內(nèi)容來(lái)自互聯(lián)網(wǎng)搜索結(jié)果,不保證100%準(zhǔn)確性,僅供參考。如若本站內(nèi)容侵犯了原著者的合法權(quán)益,可聯(lián)系我們進(jìn)行處理。