2021-04-13 | UNLOCK | 更新时间:2021-4-13 10:26

uni-app 开发中遇到的问题

导航上字体图标的引入

1:先下载字体文件 https://fontawesome.dashgame.com/

2:在pages.json文件中引入

"app-plus": {
  "titleNView": {
    "buttons": [{
      "text": "\uf011",    // 以 \u 开头,后接字体图标的后四位
      "fontSrc": "/static/fonts/fontawesome-webfont.ttf",
      "fontSize": "22px",
      "color": "#FFFFFF"
    }]
  }
}

生成 Android 自有证书

1:查看本地是否安装JAVA环境;如下图

java -version

Bubbling

如未安装,需要安装jdk环境且配置环境变量

2:使用java 生成证书

keytool -genkey -alias 证书别名 -keyalg RSA -validity 天数 -keystore 秘钥库名称

例如;

keytool -genkey -alias storage -keyalg RSA -validity 20000 -keystore D:\storage.keystore

PDA手持扫描器,扫描转跳下一个input及计数

思路:通过uniapp-input组件的 @input事件会被扫描器输入触发,之后通过js失去焦点,在通过refs获取下一个input输入框获取焦点;在到达最后一个input后再失去焦点,在每次input失去焦点的时候通过触发@blur 计数;

<template>
  <view class="container">
    <view class="field" ref="domes">
      <view class="field_item">
        <view class="field_label">姓名:</view>
        <view class="field_con">
          <input v-model="arr[0]" :focus="focus[0]" v-show="showPen(focus[0],arr[0])" ref="text1"  @input="changes(old,0,$event,'text1')" @focus="textFocus(focus,0)" @blur="textblur(focus,0)" class="field_input" type="text" placeholder="请扫码">
          <p v-show="!focus[0]" @click="$set(focus,0,true)">{{arr[0]}}</p>
        </view>
      </view>
      <view class="field_item">
        <view class="field_label">姓名:</view>
        <view class="field_con">
          <input v-model="arr[1]" :focus="focus[1]" v-show="showPen(focus[1],arr[1])" ref="text2" @input="changes(old,1,$event,'text2')" @focus="textFocus(focus,1)" @blur="textblur(focus,1)" class="field_input" type="text" placeholder="请扫码">
          <p v-show="!focus[1]" @click="$set(focus,1,true)">{{arr[1]}}</p>
        </view>
      </view>
    </view>
    
  </view>
</template>

<script>
import music from '../../common/utils.js'

export default {

  data() {
    return {
      demo:'',
      goTo:false,// 是否可以转跳;
      timeFun:"", //定时器函数
      demo:['text1','text2'],
      focus:[true],
      old:[],
      arr:[],
      arr1:"",
      formData: {
        quantity:this.num,
      },
    }
  },
  computed:{
    number:function(){
      let num=0
      this.arr.forEach(function(data){
        let value=data.trim()
        if(value){num++}
      })

      return num
    }
  },
  methods: {
    setVal(obj,i,val){ //
      this.$set(obj,i,val)
    },
    showPen(focus,text=""){
      let val=text.trim()
      if(focus||!val){
        return true
      }else{
        return false
      }
    },
    textblur(focus,n){
      this.$set(focus,n,false)
    },
    textFocus(focus,n){
      this.$set(focus,n,true)
    },
    changes:function(old,k,event,text){
      let isDelete=false //是否删除
      var value = event.target.value;
      if(old[k]){
        if(value.length>old[k].length){
          isDelete=false
        }else{
          isDelete=true
        }
      }else{
        isDelete=true
      }
      old[k]=value

      const array=this.demo
      let index=array.indexOf(text)
      if(index>=0 && index<array.length){
        if(index==array.length-1){
          clearTimeout(this.timeFun)
          if(!isDelete){
            this.timeFun=setTimeout(()=>{
              this.$set(this.focus,index,false)
              music.play_dede()
            },1500)
          }
        }else{
          clearTimeout(this.timeFun)
          if(!isDelete){
            this.timeFun=setTimeout(()=>{
              this.$set(this.focus,index,false)
              this.$set(this.focus,index+1,true)
              console.log(index,this.focus)
            },1500)
          }
        }
      }
    },
    changeNum:function(value){
      this.formData.quantity = value;
    },
  }
}
</script>

<style lang="scss">
.container{
  padding-bottom: 90rpx;
}
.field_img{
  width: 100%;
  height: 90px;;
}
.icon-saoma{
  position: absolute;
  top: 0;
  right: 0;
  width: 50rpx;
  line-height: 50rpx;
  font-size: 40rpx;
  font-weight: bold;
}
</style>
APP