123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367 |
- const app = getApp()
- const util = require("../../../utils/util");
- const api = require('../../../api/api.js');
- const user = require('../../../utils/user.js');
- import moment from 'moment'
- Page({
- data: {
- certificateName:'',
- certificateNo:'',
- healthType:'1',
- startDate: '',
- endDate: '',
- issuanceDate:'',
- max: 1,
- fileList: [],
- date: moment(new Date()).format('YYYY-MM-DD'),
- currentDate: new Date().getTime(),
- minDate: new Date('2022-01-01').getTime(),
- pickerShow:false,
- type:'',
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.getHealthInfo();
- },
- onRadioChange (e){
- this.setData({
- healthType:e.detail
- });
- },
- onNameChange (e){
- this.setData({
- certificateName:e.detail
- });
- },
- onNoChange (e){
- this.setData({
- certificateNo:e.detail
- });
- },
- getHealthInfo(){
- let userInfo = wx.getStorageSync('userInfo');
- util.request(api.getHealthCert, {
- workerNo:userInfo.workerNo
- }, 'GET').then(res=> {
- if (res.errno === 0) {
- if(res.data.healthState!='未上传'){
- this.setData({
- certificateName:res.data.healthInfo.certificateName,
- certificateNo:res.data.healthInfo.certificateNo,
- issuanceDate:moment(res.data.healthInfo.issuanceDate).format('YYYY-MM-DD'),
- startDate:moment(res.data.healthInfo.expirationDateStart).format('YYYY-MM-DD'),
- endDate:moment(res.data.healthInfo.expirationDateEnd).format('YYYY-MM-DD'),
-
- });
- if(res.data.healthInfo.certificateFileUrl==''){
- this.setData({
- fileList:[]
- });
- }else{
- let list=res.data.healthInfo.certificateFileUrl.split(',');
- let imglist=[];
- list.forEach(item=>{
- let obj={url:item};
- imglist.push(obj);
- });
- this.setData({
- fileList:imglist
- });
- }
- }
-
-
- }
- }).catch(err=>{
- });
- },
- goDetail() {
- wx.navigateTo({
- url: '/pages/upgrade/xnbInfo/xnbInfo',
- })
- },
- issuancePicker(){
- this.setData({
- pickerShow:true,
- type:'issuance'
- });
- },
- startPicker(){
- this.setData({
- pickerShow:true,
- type:'start'
- });
- },
- endPicker(){
- this.setData({
- pickerShow:true,
- type:'end'
- });
- },
- onCancel(){
- this.setData({
- pickerShow:false
- })
- },
- onConfirm(e){
- console.log(e);
- let date=moment(e.detail).format('YYYY-MM-DD');
- if(this.data.type=='start'){
- this.setData({
- startDate:date,
- pickerShow:false
- });
- }else if(this.data.type=='end'){
- this.setData({
- endDate:date,
- pickerShow:false
- });
- }else{
- this.setData({
- issuanceDate:date,
- pickerShow:false
- });
- }
-
- },
- getDetail() {
- util.request(api.getDetail, {
- id: this.data.id
- }, 'GET').then(res => {
- if (res.errno === 0) {
- this.setData({
- isFinish: res.data.feedbackComment == '' ? false : true,
- feedbackInfo: res.data,
- content: res.data.feedbackComment
- });
- if (this.data.isFinish) {
- let imgs = res.data.feedbackImgs;
- if (imgs == '') {
- this.setData({
- uploadShow: false,
- });
- } else {
- let list = imgs.split(',');
- let current = [];
- list.forEach(item => {
- let obj = {
- url: item
- };
- current.push(obj);
- });
- this.setData({
- fileList: current,
- max: current.length,
- });
- }
- }
- }
- });
- },
- deleteImage(event) {
- const { fileList = [] } = this.data;
- fileList.splice(event.detail.index, 1)
- this.setData({
- fileList: fileList
- })
- let urls = [];
- fileList.forEach(function (e) {
- urls.push(e.url);
- })
- this.setData({
- "pictures": urls
- })
- },
- afterRead(event) {
- console.log(event);
- const { file } = event.detail
- let that = this;
- const uploadTask = wx.uploadFile({
- url: api.StorageUpload(),
- filePath: file.url,
- name: 'file',
- success: function (res) {
- console.log(res);
- var _res = JSON.parse(res.data);
- if (_res.errno === 0) {
- var url = _res.data.fileUrl;
- const { fileList = [] } = that.data;
- fileList.push({ ...file, url: url });
- that.setData({
- fileList: fileList
- })
- }
- },
- fail: function (e) {
- wx.showModal({
- title: '错误',
- content: '上传失败',
- showCancel: false
- })
- },
- })
- },
- submit() {
- if (
- this.data.certificateName == ''
- ) {
- wx.showToast({
- title: '请输入证件名称',
- icon: 'none'
- });
- }else if (
- this.data.certificateNo == ''
- ) {
- wx.showToast({
- title: '请输入证件编号',
- icon: 'none'
- });
- }else if (this.data.fileList.length == 0) {
- wx.showToast({
- title: '请上传健康证照片',
- icon: 'none'
- });
- } else if (
- this.data.issuanceDate == ''
- ) {
- wx.showToast({
- title: '请选择发证日期',
- icon: 'none'
- });
- }else if (
- this.data.startDate == ''
- ) {
- wx.showToast({
- title: '请选择开始时间',
- icon: 'none'
- });
- } else if (
- this.data.endDate == ''
- ) {
- wx.showToast({
- title: '请选择结束时间',
- icon: 'none'
- });
- } else {
- let imgs = [];
- this.data.fileList.forEach(item => {
- imgs.push(item.url)
- });
- let userInfo = wx.getStorageSync('userInfo');
- util.request(api.addWorkerCertificate, {
- workerNo:userInfo.workerNo,
- expirationDateStart:this.data.startDate,
- expirationDateEnd:this.data.endDate,
- issuanceDate:this.data.issuanceDate,
- certificateFileUrl:imgs.join(','),
- certificateName:this.data.certificateName,
- certificateNo:this.data.certificateNo,
- }, 'POST').then(res => {
- if (res.errno === 0) {
- // wx.showToast({
- // title: '提交成功',
- // icon:'none'
- // });
- wx.showModal({
- title: '提醒',
- content: '提交成功',
- showCancel: false, //是否显示取消按钮
- success: function (res) {
- wx.navigateBack({
- delta: 1,
- });
- }
- })
- }else{
- wx.showToast({
- title: res.errmsg,
- icon:'none'
- })
- }
- });
- }
- },
- 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 () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- onHide: function () {
- },
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- })
|