72 lines
2.1 KiB
JavaScript
72 lines
2.1 KiB
JavaScript
|
|
"use strict";
|
||
|
|
const common_vendor = require("../../common/vendor.js");
|
||
|
|
const utils_tools = require("../../utils/tools.js");
|
||
|
|
if (!Array) {
|
||
|
|
const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
|
||
|
|
_easycom_uni_easyinput2();
|
||
|
|
}
|
||
|
|
const _easycom_uni_easyinput = () => "../../node-modules/@dcloudio/uni-ui/lib/uni-easyinput/uni-easyinput.js";
|
||
|
|
if (!Math) {
|
||
|
|
_easycom_uni_easyinput();
|
||
|
|
}
|
||
|
|
const _sfc_main = {
|
||
|
|
__name: "bikeCodeScan",
|
||
|
|
props: ["codeValue"],
|
||
|
|
emits: ["scan-change"],
|
||
|
|
setup(__props, { expose: __expose, emit: __emit }) {
|
||
|
|
const inputCodeValue = common_vendor.ref("");
|
||
|
|
const {
|
||
|
|
codeValue
|
||
|
|
} = __props;
|
||
|
|
inputCodeValue.value = codeValue;
|
||
|
|
const emit = __emit;
|
||
|
|
const onScan = () => {
|
||
|
|
common_vendor.index.scanCode({
|
||
|
|
onlyFromCamera: true,
|
||
|
|
//只能扫码
|
||
|
|
scanType: ["qrCode"],
|
||
|
|
success: function(res) {
|
||
|
|
const {
|
||
|
|
result
|
||
|
|
} = res;
|
||
|
|
if (!result || result.indexOf("number") == -1) {
|
||
|
|
utils_tools.showModelMessage("无效的车辆二维码");
|
||
|
|
inputCodeValue.value = "";
|
||
|
|
emit("scan-change", "");
|
||
|
|
} else {
|
||
|
|
const params = utils_tools.getUrlParams(result);
|
||
|
|
inputCodeValue.value = params["number"];
|
||
|
|
emit("scan-change", params["number"]);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
};
|
||
|
|
const onInput = (value) => {
|
||
|
|
if (value.detail.value == "")
|
||
|
|
return;
|
||
|
|
inputCodeValue.value = value.detail.value;
|
||
|
|
emit("scan-change", value.detail.value);
|
||
|
|
};
|
||
|
|
const onSetValue = (value) => {
|
||
|
|
inputCodeValue.value = value;
|
||
|
|
};
|
||
|
|
__expose({
|
||
|
|
onSetValue
|
||
|
|
});
|
||
|
|
return (_ctx, _cache) => {
|
||
|
|
return {
|
||
|
|
a: common_vendor.o(onInput),
|
||
|
|
b: common_vendor.o(onScan),
|
||
|
|
c: common_vendor.o(($event) => inputCodeValue.value = $event),
|
||
|
|
d: common_vendor.p({
|
||
|
|
placeholder: "请扫描或输入车辆编号",
|
||
|
|
suffixIcon: "scan",
|
||
|
|
modelValue: inputCodeValue.value
|
||
|
|
})
|
||
|
|
};
|
||
|
|
};
|
||
|
|
}
|
||
|
|
};
|
||
|
|
wx.createComponent(_sfc_main);
|
||
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/components/bikeCodeScan/bikeCodeScan.js.map
|