Commit 4ba29899 authored by 李俊赕's avatar 李俊赕

二维码扫描组件

parent 780a01e6
......@@ -3,27 +3,20 @@
<view class="u-flex">
请输入:<u-input class="u-flex-1" v-model="dataValue" @input="valueChange" type="text" />
</view>
<view class="u-flex" @click="getScan('')">
<view class="u-flex" @click="scanCode">
<view class="txt u-flex-1">扫描二维码(仅挚达充电桩可扫描)</view>
<u-icon name="arrow-right" color="#666" size="28"></u-icon>
</view>
<!-- <view class="list u-flex u-row-between">
<text class="required" v-if="item.required">*</text>
<view class="u-m-r-20">{{item.fieldsTitle}}</view>
<view class="u-flex-1">{{valueTxt || ''}}</view>
<u-button type="primary" size="mini" @click="$u.debounce(getLocation,1000)">默认按钮</u-button>
</view> -->
</view>
</template>
<script>
import objMixin from './objMixin'
import stringMixin from './stringMixin'
export default {
name: 'XhScan',
components: {},
mixins: [objMixin],
mixins: [stringMixin],
props: {},
filters:{},
data() {
......@@ -42,33 +35,23 @@
watch: {},
mounted() {},
methods: {
getScan(type){
scanCode(type){
const self = this
// qrCode 二维码;barCode 条形码
let scanType = type && [type] || ['qrCode']
uni.scanCode({
scanType: ['barCode'],
// scanType: scanType,
success: function (res) {
console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result);
self.dataValue = res.result
self.valueChange(res.result)
// console.log('条码类型:' + res.scanType);
// console.log('条码内容:' + res.result);
}
});
},
getLocation() {
let self = this
const dataValue = this.dataValue || []
const waterInfo = this.waterInfo
uni.getLocation({
type: 'gcj02',
success: function(res) {
dataValue.push(res.longitude)
dataValue.push(res.latitude)
self.dataValue = dataValue
self.setValue(dataValue)
},
fail(err) {}
});
},
setValue(txt) {
this.valueChange(this.dataValue)
}
// setValue(txt) {
// this.valueChange(this.dataValue)
// }
}
}
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment