59 lines
1.7 KiB
JavaScript
59 lines
1.7 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const _sfc_main = {
|
|
__name: "ScanCarPage",
|
|
setup(__props) {
|
|
const carInfo = common_vendor.ref(null);
|
|
const scanQRCode = () => {
|
|
common_vendor.index.scanCode({
|
|
success: (res) => {
|
|
const carId = res.result;
|
|
getCarInfo(carId);
|
|
},
|
|
fail: () => {
|
|
common_vendor.index.showToast({
|
|
title: "扫码失败,请重试",
|
|
icon: "none"
|
|
});
|
|
}
|
|
});
|
|
};
|
|
const getCarInfo = (carId) => {
|
|
common_vendor.index.request({
|
|
url: `https://example.com/api/car/${carId}`,
|
|
// 假设的API接口
|
|
method: "GET",
|
|
success: (response) => {
|
|
if (response.statusCode === 200) {
|
|
carInfo.value = response.data;
|
|
} else {
|
|
common_vendor.index.showToast({
|
|
title: "获取车辆信息失败",
|
|
icon: "none"
|
|
});
|
|
}
|
|
},
|
|
fail: () => {
|
|
common_vendor.index.showToast({
|
|
title: "请求失败,请检查网络",
|
|
icon: "none"
|
|
});
|
|
}
|
|
});
|
|
};
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: common_vendor.o(scanQRCode),
|
|
b: carInfo.value
|
|
}, carInfo.value ? {
|
|
c: common_vendor.t(carInfo.value.licensePlate),
|
|
d: common_vendor.t(carInfo.value.ownerName),
|
|
e: common_vendor.t(carInfo.value.status)
|
|
} : {});
|
|
};
|
|
}
|
|
};
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-845e3c3f"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/user/ScanCarPage.js.map
|