361 lines
11 KiB
JavaScript
361 lines
11 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../../common/vendor.js");
|
|
const common_assets = require("../../../common/assets.js");
|
|
const utils_tools = require("../../../utils/tools.js");
|
|
const utils_api = require("../../../utils/api.js");
|
|
if (!Array) {
|
|
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
|
|
const _easycom_uni_list_item2 = common_vendor.resolveComponent("uni-list-item");
|
|
const _easycom_uni_list2 = common_vendor.resolveComponent("uni-list");
|
|
const _easycom_uni_card2 = common_vendor.resolveComponent("uni-card");
|
|
(_easycom_uni_icons2 + _easycom_uni_list_item2 + _easycom_uni_list2 + _easycom_uni_card2)();
|
|
}
|
|
const _easycom_uni_icons = () => "../../../node-modules/@dcloudio/uni-ui/lib/uni-icons/uni-icons.js";
|
|
const _easycom_uni_list_item = () => "../../../node-modules/@dcloudio/uni-ui/lib/uni-list-item/uni-list-item.js";
|
|
const _easycom_uni_list = () => "../../../node-modules/@dcloudio/uni-ui/lib/uni-list/uni-list.js";
|
|
const _easycom_uni_card = () => "../../../node-modules/@dcloudio/uni-ui/lib/uni-card/uni-card.js";
|
|
if (!Math) {
|
|
(_easycom_uni_icons + _easycom_uni_list_item + _easycom_uni_list + _easycom_uni_card)();
|
|
}
|
|
const _sfc_main = {
|
|
__name: "home",
|
|
setup(__props) {
|
|
const location = common_vendor.ref({
|
|
longitude: "",
|
|
latitude: ""
|
|
});
|
|
const scale = common_vendor.ref(15);
|
|
const markers = common_vendor.ref([]);
|
|
const polygons = common_vendor.ref([]);
|
|
const polylines = common_vendor.ref([]);
|
|
const circles = common_vendor.ref([]);
|
|
const oUser = common_vendor.index.getStorageSync("wechat_user");
|
|
const showMess = common_vendor.ref(common_vendor.index.getStorageSync("kbike-mess"));
|
|
const hasOrder = common_vendor.ref(false);
|
|
const showOrder = common_vendor.ref(false);
|
|
const order = common_vendor.ref({
|
|
bikecode: "123456",
|
|
money: "2.5",
|
|
time: "22.58min",
|
|
mileage: "5.6km"
|
|
});
|
|
let orderData = {
|
|
bikeCode: null,
|
|
status: null,
|
|
createdAt: null,
|
|
orderId: null
|
|
};
|
|
let orderTimer = null;
|
|
const orderState = common_vendor.ref(0);
|
|
let arrBikeData = [];
|
|
function getLoalcationData() {
|
|
common_vendor.index.getLocation({
|
|
type: "gcj02",
|
|
geocode: true,
|
|
success(res) {
|
|
location.value = {
|
|
longitude: 103.975457,
|
|
latitude: 30.633199
|
|
};
|
|
const params = { longitude: 103.975457, latitude: 30.633199 };
|
|
utils_api.callOrdereApi("userOrders/bikeList", params, "post").then((res2) => {
|
|
common_vendor.index.__f__("log", "at pages/user/home/home.vue:177", "11111111111111111", "userOrders/bikeList", res2);
|
|
const { code, data, message } = res2;
|
|
if (code != 200) {
|
|
utils_tools.showModelMessage(message);
|
|
return;
|
|
}
|
|
arrBikeData = data || [];
|
|
const arrData = markers.value || [];
|
|
debugger;
|
|
arrBikeData.map((item) => {
|
|
const { longitude, latitude } = item;
|
|
let index = common_vendor.lodashExports.findIndex(arrData, { longitude, latitude });
|
|
index == index == -1 ? arrData.length : index;
|
|
arrData[index] = addMarker(index, item[1], item[0], "mapbike.png", true);
|
|
});
|
|
markers.value = arrData;
|
|
common_vendor.index.__f__("log", "at pages/user/home/home.vue:193", "555555555555555555555555555", arrData);
|
|
});
|
|
},
|
|
fail(res) {
|
|
}
|
|
});
|
|
}
|
|
function clickMess() {
|
|
common_vendor.index.setStorageSync("kbike-mess", 1);
|
|
showMess.value = 1;
|
|
}
|
|
function refresh() {
|
|
getLoalcationData();
|
|
}
|
|
function reportFault() {
|
|
if (!oUser) {
|
|
tologin();
|
|
return;
|
|
}
|
|
utils_tools.showModelMessage("该功能暂未实现!");
|
|
}
|
|
function getSite() {
|
|
utils_tools.showModelMessage("该功能暂未实现!");
|
|
}
|
|
function getMine() {
|
|
if (!oUser) {
|
|
tologin();
|
|
return;
|
|
}
|
|
utils_tools.showModelMessage("该功能暂未实现!");
|
|
}
|
|
function scanBike() {
|
|
if (!oUser) {
|
|
tologin();
|
|
return;
|
|
}
|
|
common_vendor.index.navigateTo({
|
|
url: "/pages/user/scan/scancode?type=ride"
|
|
});
|
|
}
|
|
function addMarker(id, longitude, latitude, icon, joinCluster) {
|
|
return {
|
|
id,
|
|
latitude,
|
|
longitude,
|
|
width: 30,
|
|
height: 30,
|
|
zIndex: "100",
|
|
iconPath: "/static/userui/home/" + icon,
|
|
joinCluster: joinCluster ? true : false
|
|
};
|
|
}
|
|
function addLine(scolor, arrPoints) {
|
|
return {
|
|
points: arrPoints,
|
|
color: scolor,
|
|
width: 3
|
|
};
|
|
}
|
|
function showOrderInfo() {
|
|
showOrder.value = true;
|
|
}
|
|
function getOrder() {
|
|
const {
|
|
userId
|
|
} = oUser;
|
|
utils_api.callOrdereApi("userOrders/checkHistoryOrder", {
|
|
userId
|
|
}, "get").then((res) => {
|
|
common_vendor.index.__f__("log", "at pages/user/home/home.vue:327", "111111111111111", "getOrder", res);
|
|
const {
|
|
code,
|
|
data,
|
|
message
|
|
} = res;
|
|
if (code != 200) {
|
|
utils_tools.showModelMessage(message);
|
|
return;
|
|
}
|
|
if (!data) {
|
|
completeRiding();
|
|
return;
|
|
}
|
|
const {
|
|
bikeCode,
|
|
status,
|
|
createdAt,
|
|
orderId,
|
|
tempLock,
|
|
ridePoint,
|
|
returnPoint
|
|
} = data;
|
|
orderState.value = tempLock ? 1 : 0;
|
|
orderData = data;
|
|
if (status == 2) {
|
|
completeRiding();
|
|
return;
|
|
} else if (status != 0) {
|
|
completeRiding();
|
|
return;
|
|
}
|
|
showOrder.value = true;
|
|
if (!orderTimer) {
|
|
common_vendor.index.__f__("log", "at pages/user/home/home.vue:364", "5555555555555555555555555555555");
|
|
orderTimer = setInterval(getTracking, 1e4);
|
|
}
|
|
});
|
|
}
|
|
function getTracking() {
|
|
const {
|
|
bikeCode,
|
|
createdAt,
|
|
ridePoint,
|
|
returnPoint
|
|
} = orderData;
|
|
const params = {
|
|
ebikeCode: bikeCode,
|
|
//startTime: createdAt
|
|
startTime: "2025-04-02 09:00:00"
|
|
};
|
|
utils_api.callOperateApi("ebikeTracking/query", params, "post").then((res) => {
|
|
const {
|
|
code,
|
|
data,
|
|
message
|
|
} = res;
|
|
if (code != 200) {
|
|
return;
|
|
}
|
|
const arrPoints = !data ? [] : data.map((item) => {
|
|
const {
|
|
lngGCJ02,
|
|
latGCJ02
|
|
} = item;
|
|
return {
|
|
longitude: lngGCJ02,
|
|
latitude: latGCJ02
|
|
};
|
|
});
|
|
const lng = startPoint[0];
|
|
const lat = startPoint[1];
|
|
const start = {
|
|
longitude: lng,
|
|
latitude: lat
|
|
};
|
|
arrPoints.splice(0, 0, start);
|
|
const arrMakers = markers.value || [];
|
|
const id = 1e7;
|
|
let index = common_vendor.lodashExports.findIndex(arrMakers, { id });
|
|
index = index == -1 ? arrMakers.length : index;
|
|
arrMakers[index] = addMarker(id, lng, lat, "mapstart.png");
|
|
markers.value = arrMakers[index];
|
|
polylines.value = [addLine("#168DED", arrPoints)];
|
|
});
|
|
}
|
|
function completeRiding() {
|
|
if (!orderTimer)
|
|
return;
|
|
clearInterval(orderTimer);
|
|
orderTimer = null;
|
|
showOrder.value = false;
|
|
hasOrder.value = false;
|
|
orderState.value = 0;
|
|
}
|
|
function tologin() {
|
|
common_vendor.index.navigateTo({
|
|
url: "/pages/user/login/wx_login"
|
|
});
|
|
}
|
|
function lockRiding() {
|
|
utils_tools.showModelMessage("该功能暂未实现!");
|
|
orderState.value = 1;
|
|
}
|
|
function endRiding() {
|
|
utils_tools.showModelMessage("该功能暂未实现!");
|
|
const { userId } = oUser;
|
|
const {
|
|
bikeCode
|
|
} = orderData;
|
|
const params = { userId, bikeCode };
|
|
utils_api.callOrdereApi("userOrders/doneRide", params, "post").then((res) => {
|
|
const { code, data, message } = res;
|
|
common_vendor.index.__f__("log", "at pages/user/home/home.vue:455", "111111111111111111111111", "endRiding", res);
|
|
if (code != 200) {
|
|
utils_tools.showModelMessage(message);
|
|
return;
|
|
}
|
|
completeRiding();
|
|
});
|
|
}
|
|
function continueRiding() {
|
|
utils_tools.showModelMessage("该功能暂未实现!");
|
|
orderState.value = 0;
|
|
}
|
|
getLoalcationData();
|
|
common_vendor.onMounted(() => {
|
|
const instance = common_vendor.getCurrentInstance();
|
|
common_vendor.index.createMapContext("mapRef", {
|
|
this: instance.proxy
|
|
});
|
|
const {
|
|
userId
|
|
} = oUser;
|
|
if (userId) {
|
|
getOrder();
|
|
}
|
|
});
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: location.value.longitude,
|
|
b: location.value.latitude,
|
|
c: markers.value,
|
|
d: scale.value,
|
|
e: polygons.value,
|
|
f: polylines.value,
|
|
g: circles.value,
|
|
h: common_assets._imports_0$2,
|
|
i: common_vendor.o(refresh),
|
|
j: common_assets._imports_1,
|
|
k: common_vendor.o(reportFault),
|
|
l: common_assets._imports_2,
|
|
m: common_vendor.o(getSite),
|
|
n: common_assets._imports_3,
|
|
o: common_vendor.o(getMine),
|
|
p: hasOrder.value
|
|
}, hasOrder.value ? {
|
|
q: common_assets._imports_4,
|
|
r: common_vendor.o(showOrderInfo)
|
|
} : {}, {
|
|
s: common_vendor.p({
|
|
type: "scan",
|
|
color: "white",
|
|
size: 25
|
|
}),
|
|
t: common_vendor.n((hasOrder.value ? "divScanBtnDis " : "") + "divScanBtn"),
|
|
v: common_vendor.o(scanBike),
|
|
w: showOrder.value
|
|
}, showOrder.value ? common_vendor.e({
|
|
x: common_assets._imports_5,
|
|
y: common_vendor.t(order.value.money),
|
|
z: common_vendor.t(order.value.bikecode),
|
|
A: common_assets._imports_6,
|
|
B: common_vendor.t(order.value.time),
|
|
C: common_assets._imports_7,
|
|
D: common_vendor.t(order.value.mileage),
|
|
E: orderState.value == 0
|
|
}, orderState.value == 0 ? {
|
|
F: common_assets._imports_8,
|
|
G: common_vendor.o(lockRiding)
|
|
} : {}, {
|
|
H: orderState.value == 1
|
|
}, orderState.value == 1 ? {
|
|
I: common_assets._imports_9,
|
|
J: common_vendor.o(continueRiding)
|
|
} : {}, {
|
|
K: common_assets._imports_10,
|
|
L: common_vendor.o(endRiding)
|
|
}) : {}, {
|
|
M: showMess.value != 1
|
|
}, showMess.value != 1 ? {
|
|
N: common_vendor.p({
|
|
thumb: "/static/userui/home/map1.png",
|
|
["thumb-size"]: "lg"
|
|
}),
|
|
O: common_vendor.p({
|
|
thumb: "/static/userui/home/map2.png",
|
|
["thumb-size"]: "lg"
|
|
}),
|
|
P: common_vendor.p({
|
|
thumb: "/static/userui/home/map3.png",
|
|
["thumb-size"]: "lg"
|
|
}),
|
|
Q: common_vendor.p({
|
|
border: true
|
|
}),
|
|
R: common_vendor.o(clickMess)
|
|
} : {});
|
|
};
|
|
}
|
|
};
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-a2230ba1"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages/user/home/home.js.map
|