You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
187 lines
7.8 KiB
187 lines
7.8 KiB
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const common_assets = require("../../common/assets.js");
|
|
const store_modules_car = require("../../store/modules/car.js");
|
|
const pages_index_comp_allCity = require("./comp/allCity.js");
|
|
const config_site_config = require("../../config/site.config.js");
|
|
const config_api = require("../../config/api.js");
|
|
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
if (!Array) {
|
|
const _easycom_up_navbar2 = common_vendor.resolveComponent("up-navbar");
|
|
const _easycom_up_icon2 = common_vendor.resolveComponent("up-icon");
|
|
const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
|
|
const _easycom_oneBtn2 = common_vendor.resolveComponent("oneBtn");
|
|
(_easycom_up_navbar2 + _easycom_up_icon2 + _easycom_u_icon2 + _easycom_oneBtn2)();
|
|
}
|
|
const _easycom_up_navbar = () => "../../uni_modules/uview-plus/components/u-navbar/u-navbar.js";
|
|
const _easycom_up_icon = () => "../../uni_modules/uview-plus/components/u-icon/u-icon.js";
|
|
const _easycom_u_icon = () => "../../uni_modules/uview-plus/components/u-icon/u-icon.js";
|
|
const _easycom_oneBtn = () => "../../components/oneBtn/oneBtn.js";
|
|
if (!Math) {
|
|
(_easycom_up_navbar + _easycom_up_icon + _easycom_u_icon + _easycom_oneBtn)();
|
|
}
|
|
const _sfc_main = {
|
|
__name: "index",
|
|
setup(__props) {
|
|
let usecarStore = store_modules_car.carStore();
|
|
let {
|
|
mapKey
|
|
} = config_site_config.obj;
|
|
const rightClick = () => {
|
|
console.log("rightClick");
|
|
};
|
|
const tabData = common_vendor.ref([
|
|
{ name: "小车", type: "C1/C2/C3", style: "width: 114rpx;height: 61rpx;", icon: new URL("@/static/images/car4.png", typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.src || new URL("pages/index/index.js", document.baseURI).href).href, id: "1" },
|
|
{ name: "货车", type: "A2/B2", style: "width: 106rpx;height: 68rpx;", icon: new URL("@/static/images/car2.png", typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.src || new URL("pages/index/index.js", document.baseURI).href).href, id: "1" },
|
|
{ name: "客车", type: "A1/B1/A3", style: "width: 106rpx;height: 68rpx;", icon: new URL("@/static/images/car1.png", typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.src || new URL("pages/index/index.js", document.baseURI).href).href, id: "1" },
|
|
{ name: "摩托车", type: "D/E/F", style: "width: 102rpx;height: 73rpx;", icon: new URL("@/static/images/car3.png", typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.src || new URL("pages/index/index.js", document.baseURI).href).href, id: "1" }
|
|
]);
|
|
const currentCar = common_vendor.ref("");
|
|
function chooseCar(item) {
|
|
currentCar.value = item;
|
|
usecarStore.setCar("carType", item.carType);
|
|
usecarStore.setCar("carTypeName", item.title);
|
|
}
|
|
function oneBtnClick() {
|
|
common_vendor.index.navigateTo({
|
|
url: "/pages/exercises/theoryStudy/theoryStudy"
|
|
});
|
|
}
|
|
common_vendor.onLoad(async (option) => {
|
|
let phone = option.phone ? option.phone : "18267103167";
|
|
let type = option.type ? option.type : "1";
|
|
console.log("自私");
|
|
await loginFn(phone, type);
|
|
questbanktypeFn();
|
|
});
|
|
async function loginFn(phone, type) {
|
|
console.log("会执行吗??");
|
|
const res = await config_api.loginApi({
|
|
"username": phone,
|
|
type
|
|
});
|
|
console.log(res);
|
|
res.data.phone = phone;
|
|
res.data.type = type;
|
|
common_vendor.index.setStorageSync("loginInfo", res.data);
|
|
}
|
|
async function questbanktypeFn() {
|
|
const { data: res } = await config_api.questbanktypeApi();
|
|
let arr = res.map((item) => {
|
|
item.descriptionArr = item.description.split(":");
|
|
return item;
|
|
});
|
|
tabData.value = arr;
|
|
currentCar.value = res[0];
|
|
}
|
|
common_vendor.onPullDownRefresh(() => {
|
|
questbanktypeFn().then(() => {
|
|
common_vendor.index.stopPullDownRefresh();
|
|
}).catch(() => {
|
|
common_vendor.index.stopPullDownRefresh();
|
|
});
|
|
});
|
|
let citys = [];
|
|
function initcity() {
|
|
let cityArr = pages_index_comp_allCity.allCity.map((arr) => {
|
|
return arr.cityInfoList.map((item) => {
|
|
let obj = {
|
|
cityName: item.cityName,
|
|
pinYin: item.cityPinyin,
|
|
py: item.cityAcronym.toLocaleLowerCase(),
|
|
code: item.cityCode,
|
|
cityInitial: item.cityInitial
|
|
};
|
|
return obj;
|
|
});
|
|
});
|
|
citys = cityArr.flat();
|
|
console.log(citys);
|
|
}
|
|
initcity();
|
|
function getWarpweft() {
|
|
common_vendor.index.getLocation({
|
|
type: "wgs84",
|
|
success: function(res) {
|
|
console.log("当前位置的经度:" + res.longitude);
|
|
console.log("当前位置的纬度:" + res.latitude);
|
|
let url = "https://apis.map.qq.com/ws/geocoder/v1/";
|
|
common_vendor.o$1(url, {
|
|
key: mapKey,
|
|
location: res.latitude + "," + res.longitude,
|
|
output: "jsonp"
|
|
}).then((res2) => {
|
|
console.log("jsonp", res2.result.address_component);
|
|
let {
|
|
province,
|
|
city,
|
|
district
|
|
} = res2.result.address_component;
|
|
console.log(province, city, district);
|
|
let currentCity = citys.find((item) => item.cityName == city);
|
|
if (!currentCity) {
|
|
return common_vendor.index.$u.toast("获取定位失败,请手动选择城市");
|
|
}
|
|
usecarStore.setCar("city", currentCity.code);
|
|
usecarStore.setCar("cityName", currentCity.cityName);
|
|
console.log(currentCity, "当前城市");
|
|
}).catch(() => {
|
|
common_vendor.index.$u.toast("获取定位失败,请手动选择城市");
|
|
});
|
|
},
|
|
fail() {
|
|
common_vendor.index.$u.toast("获取定位失败,请手动选择城市");
|
|
}
|
|
});
|
|
}
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: common_vendor.o(rightClick),
|
|
b: common_vendor.p({
|
|
title: "选择类型",
|
|
autoBack: true
|
|
}),
|
|
c: common_vendor.p({
|
|
name: "map",
|
|
size: "20"
|
|
}),
|
|
d: common_vendor.unref(usecarStore).carInfo.cityName
|
|
}, common_vendor.unref(usecarStore).carInfo.cityName ? {
|
|
e: common_vendor.t(common_vendor.unref(usecarStore).carInfo.cityName)
|
|
} : {}, {
|
|
f: common_vendor.o(getWarpweft),
|
|
g: common_vendor.p({
|
|
name: "arrow-right",
|
|
color: "#1989FA",
|
|
size: "14"
|
|
}),
|
|
h: common_vendor.o(($event) => _ctx.$goPage("/pages/index/comp/city")),
|
|
i: common_vendor.f(tabData.value, (item, index, i0) => {
|
|
return common_vendor.e({
|
|
a: item.id == currentCar.value.id
|
|
}, item.id == currentCar.value.id ? {
|
|
b: common_assets._imports_0
|
|
} : {}, {
|
|
c: item.cover,
|
|
d: common_vendor.t(item.title),
|
|
e: common_vendor.f(item.descriptionArr, (item2, index2, i1) => {
|
|
return {
|
|
a: common_vendor.t(item2),
|
|
b: index2
|
|
};
|
|
}),
|
|
f: index,
|
|
g: common_vendor.o(($event) => chooseCar(item), index),
|
|
h: item.id == currentCar.value.id ? 1 : ""
|
|
});
|
|
}),
|
|
j: common_vendor.o(oneBtnClick),
|
|
k: common_vendor.p({
|
|
text: "确 定"
|
|
})
|
|
});
|
|
};
|
|
}
|
|
};
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1cf27b2a"]]);
|
|
wx.createPage(MiniProgramPage);
|