Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
data-table
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2023-03-03 21:16:24 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6575d57151954e3ff8d21d16fa0295f00a4cfc63
6575d571
1 parent
44886d37
✨ feat: 单行输入控件新增扫描功能
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
18 deletions
src/components/TextField/index.vue
src/components/TextField/index.vue
View file @
6575d57
<!--
* @Date: 2022-08-29 14:31:20
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-03-03
15:10:05
* @LastEditTime: 2023-03-03
21:15:22
* @FilePath: /data-table/src/components/TextField/index.vue
* @Description: 单行文本输入框
* @Description: 单行文本输入框
(微信扫描功能)
-->
<template>
<div v-if="HideShow" class="text-field-page">
...
...
@@ -11,13 +11,13 @@
<span v-if="item.component_props.required"> *</span>
{{ item.component_props.label }}
</div>
<div v-if="item.component_props.note" v-html="item.component_props.note"
style="font-size: 0.9rem; margin-left: 1rem; color: gray; padding-bottom: 0.5rem; padding-top: 0.25rem; white-space: pre-wrap;" />
<div class="note-wrapper" v-if="item.component_props.note" v-html="item.component_props.note" />
<van-field v-model="item.value" :name="item.name" :type="item.type"
:placeholder="item.component_props.placeholder ? item.component_props.placeholder : '请输入'" :rules="item.rules"
:required="item.required" :readonly="item.component_props.readonly" :disabled="item.component_props.disabled"
:input-align="item.component_props.align" :right-icon="test === 'camera' ? 'scan' : ''"
@click-right-icon="clickRightIcon" />
:required="item.required"
:readonly="item.component_props.readonly || item.component_props.is_edit_camera_scan_result"
:disabled="item.component_props.disabled" :input-align="item.component_props.align"
:right-icon="item.component_props.is_camera_scan ? 'scan' : ''" @click-right-icon="clickRightIcon" />
</div>
</template>
...
...
@@ -26,9 +26,6 @@ import { useRoute } from "vue-router";
import { showSuccessToast, showFailToast } from 'vant';
// 初始化WX环境
import wx from 'weixin-js-sdk'
import { wxJsAPI } from '@/api/wx/config'
import { apiList } from '@/api/wx/jsApiList.js'
import { wxInfo, getUrlParams, stringifyQuery } from "@/utils/tools";
const props = defineProps({
item: Object,
...
...
@@ -39,16 +36,16 @@ const HideShow = computed(() => {
})
const $route = useRoute();
//
TODO: 等待真实数据进行判断,默认条形码识别
const
test = $route.query.test
;
const scan_type_code = ref(2);
//
默认识别类型
const
scan_type_code = ref('ALL_CODE')
;
// 微信二维码扫描功能判断
const scanType = (scan_type_code) => {
switch (scan_type_code) {
case
0
:
case
'ALL_CODE'
:
return ["qrCode", "barCode"]
case
1
:
case
'QR_CODE'
:
return ["qrCode"]
case
2
:
case
'BAR_CODE'
:
return ["barCode"]
}
}
...
...
@@ -56,12 +53,12 @@ const scanType = (scan_type_code) => {
// 预览模式
const model = $route.query.model;
const clickRightIcon = async () => {
// 预览模式屏蔽微信
授权
// 预览模式屏蔽微信
功能
if (model === 'preview') return false;
wx.ready(() => {
wx.scanQRCode({
needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
scanType: scanType(
scan_type_code.valu
e), // 可以指定扫二维码还是一维码,默认二者都有
scanType: scanType(
item.props.camera_scan_typ
e), // 可以指定扫二维码还是一维码,默认二者都有
success: function (res) {
if (res.errMsg === 'scanQRCode:ok') {
let code = res.resultStr;
...
...
@@ -94,6 +91,15 @@ const clickRightIcon = async () => {
span {
color: red;
}
.note-wrapper {
font-size: 0.9rem;
margin-left: 1rem;
color: gray;
padding-bottom: 0.5rem;
padding-top: 0.25rem;
white-space: pre-wrap;
}
}
}
...
...
Please
register
or
login
to post a comment