el-upload - :before-upload 中 使用接口方法

beforeAvatarUpload (file) {
      let that = this
      return new Promise((resolve, reject) => {
        // 图片不能大于500k
        const isLt500K = file.size / 1024 / 1024 < 5
        let arr = file.name.split('.')
        let type = arr[arr.length - 1]
        let testmsg = /^(jpeg|png|jpg)$/.test(type)
        let name = file.name
        let nameArr = name.split('.')
        let url = '/person/validateIdNo'
        let param = {
          idNo: nameArr[0] || ''
        }
        // eslint-disable-next-line no-unused-vars
        let isName = false
        AxiosApi(url, {}, 'GET', param).then(res => {
          if (res.status === 200) {
            isName = true
            if (!testmsg) {
              that.addVis = false
              MsgShow('error', '请上传jpeg、jpg、png格式的图片!', 2000)
            }
            if (!isLt500K) {
              this.addVis = false
              MsgShow('error', '上传图片大小不能超过5MB!', 3000)
            }
            this.$forceUpdate()
            if (testmsg && isLt500K) {
              resolve()
            } else {
              // eslint-disable-next-line prefer-promise-reject-errors
              reject()
            }
          } else {
            that.addVis = false
            MsgShow('error', '照片名称需要使用用户的正确格式的证件号码 !', 2000)
            this.$forceUpdate()
            // eslint-disable-next-line prefer-promise-reject-errors
            reject()
          }
        })
      })
    },

Apache服务器配置跨域:通过设置反向代理进行跨域


    ServerAdmin webmaster@example.com
    DocumentRoot \"/www/wwwroot/test.com\"
    ServerAlias test.com
    #errorDocument 404 /404.html
    ErrorLog \"/www/wwwlogs/test.com-error_log\"
    CustomLog \"/www/wwwlogs/test.com-access_log\" combined
    #start
    ProxyRequests Off
    ProxyPass /api http://api.com/api
    #end

No input file specified.

默认的.htaccess里面的规则:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
“No input file specified.”,是没有得到有效的文件路径造成的。
修改伪静态规则,如下:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
有没有发现不同?
其实就是在正则结果“/$1”前面多加了一个“?”号,问题也就随之解决了。

vue - 求两个日期之间的相差数

// 获取与毫秒数的转化比例(相差天数:1,相差小时数:2,相差分钟数:3,相差秒数:4)
getDifferScale(value) {
    var format
    // 获取转化比(天数跟毫秒数的比例)
    if (value === 1) {
        format = parseFloat(24 * 60 * 60 * 1000)
    } else if (value === 2) { // 获取转化比(小时数跟毫秒数的比例)
        format = parseFloat(60 * 60 * 1000)
    } else if (value === 3) { // 获取转化比(分钟数跟毫秒数的比例)
        format = parseFloat(60 * 1000)
    } else if (value === 4) { // 获取转化比(秒数跟毫秒数的比例)
        format = parseFloat(1000)
    }
    return format
},
// firstDate: 2021-08-11 00:00:00
// 获取两个日期的相差日期数(differ 相差天数:1、相差小时数:2、相差分钟数:3、相差秒数:4)
getDifferDate(firstDate, secondDate, differ) {
    // 1)将两个日期字符串转化为日期对象
    let startDate = new Date(firstDate) let endDate = new Date(secondDate)
    // 2)计算两个日期相差的毫秒数
    let msecNum = endDate.getTime() - startDate.getTime()
    // 3)计算两个日期相差的天数
    return Math.floor(msecNum / this.getDifferScale(differ))
}

vue - web 调用摄像头进行拍照

List.vue

<template>
  <!--人像采集-->
  <div class="typt-list-container">
    <div>人像采集</div>
    <img v-if="image" :src="image" class="border" style="width: 200px;height: 200px;"/>
    <el-button @click="openCamera">打开摄像头</el-button>
    <el-dialog :visible.sync="cameraVisible"
               class="passport-imgDialog"
               :before-close="closeCamera"
               width="800px"
               :show-close="true"
               style="padding: 0;"
               title="人像采集"
               :close-on-click-modal="false">
      <div style="height: 400px;text-align: center;" v-if="cameraHack">
        <Photograph :image="image"
                    :statusInfo="statusInfo"
                    @getPhoto="getPhoto"></Photograph>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import gateCamera from '../../../assets/acms/mixins/gateCamera/index.js'
import Photograph from '../../../components/acms/Photograph'
import { MsgShow } from '../../../assets/acms/js/Message'
export default {
  components: {
    Photograph
  },
  mixins: [gateCamera],
  data () {
    return {
      cameraVisible: false,
      cameraHack: false,
      image: '', // 传递图像数据
      statusInfo: { // 状态显示
        status: '', // loading | fail
        msg: ''
      }
    }
  },
  props: ['params', 'modifyData', 'pageData', 'searchData'],
  mounted () {
  },
  methods: {
    // 获取拍照图像
    getPhoto ({ formdata, base64 }) {
      MsgShow('success', '获取中......', 2000)
      // 上传中
      this.statusInfo.status = 'loading'
      this.statusInfo.msg = '上传中'
      // 上传成功
      setTimeout(() => {
        MsgShow('success', '人像采集成功', 2000)
        this.statusInfo.status = ''
        this.statusInfo.msg = ''
        this.image = base64
        this.closeCamera()
      }, 2000)
    },
    // 打开摄像头
    openCamera () {
      this.cameraHack = false
      this.cameraVisible = false
      this.$nextTick(() => {
        this.cameraHack = true
        this.cameraVisible = true
      })
    },
    // 关闭拍照弹窗
    closeCamera () {
      this.cameraHack = false
      this.cameraVisible = false
    }
  }
}
</script>

  翻  牌  子