From d0fae46441093892d33de3e030991e271f4f7ded Mon Sep 17 00:00:00 2001
From: "3321822538@qq.com" <3321822538@qq.com>
Date: Mon, 27 May 2024 18:03:57 +0800
Subject: [PATCH] =?UTF-8?q?=E5=88=B0=E8=AE=A1=E7=AE=97=E9=87=91=E9=A2=9D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
page_user/about.vue | 2 +-
page_user/ditu.vue | 146 +++++++++++++++---
pages/index/index.vue | 251 +++++++++++++++++++++++++++----
pages/myorder/index.vue | 37 ++++-
pages/myorder/returned/index.vue | 57 +++++--
pages/nearbystores/index.vue | 124 ++++++++++++++-
6 files changed, 545 insertions(+), 72 deletions(-)
diff --git a/page_user/about.vue b/page_user/about.vue
index abbecf8..972a29d 100644
--- a/page_user/about.vue
+++ b/page_user/about.vue
@@ -7,7 +7,7 @@
{{obj.title}}
-
+
diff --git a/page_user/ditu.vue b/page_user/ditu.vue
index d7aff03..8524bbc 100644
--- a/page_user/ditu.vue
+++ b/page_user/ditu.vue
@@ -2,7 +2,8 @@
-
+
+ {{zujieobj.priceStandard.feePrice}}元/小时
+ {{zujieobj.priceStandard.feePrice}}元/半小时
+ ,前{{zujieobj.priceStandard.feeFreeTime}}分钟免费,不足一小时按一小时计费,日封顶{{zujieobj.priceStandard.feePrice * 24}}元,总封顶{{zujieobj.priceStandard.feeMaxPrice}}元
租借信息
- 租借时间 2024-04-08 15:05:21
+ 租借时间 {{zujieobj.startRentTime}}
- 租借方式 微信免押
+ 租借方式 普通租赁 免押金租赁
- 租借地点 福建省宁德市福鼎市秦晖路附近久久红农家乐 (朝阳路店)
+ 租借地点 {{zujieobj.startStoreAddress}}
- 归还时间 -
+ 归还时间 {{zujieobj.endRentTime == null ? '-' : zujieobj.endRentTime}}
- 归还地点 -
+ 归还地点
+ {{zujieobj.endStoreAddress == null ? '-' : zujieobj.endStoreAddress}}
- 租借电池 JXDD21387489
+ 租借电池 {{zujieobj.deviceSn}}
- 订单编号 S1269876456368798741201 订单编号 {{zujieobj.orderNo}} 复制
@@ -122,15 +127,186 @@
longitude: '', // 初始经度
covers: [], // 覆盖物数组
jinweidu: '',
- zujieflag:false
+ zujieflag: false,
+ listmap: [],
+ mapScale: 15,
+ datetime: 0,
+ dingobj: '',
+ mapContext: null,
+ mapScaleInterval: null,
+ zujieobj: {},
+ zujiemoney: '',
+ timer: null,
};
},
+ onReady() {
+ this.mapContext = uni.createMapContext('map', this);
+ this.mapScaleInterval = setInterval(this.updateMarkers, 1000);
+ },
+ beforeDestroy() {
+ if (this.mapScaleInterval) {
+ clearInterval(this.mapScaleInterval);
+ this.mapScaleInterval = null;
+ }
+ },
onShow() {
this.jmlogin()
this.getuser()
+ this.getorder()
+ this.startTimer()
+ },
+ onHide() {
+ // 在页面隐藏时清除定时器
+ this.clearTimer()
+ },
+ onUnload() {
+ this.clearTimer()
},
methods: {
- btnzujie(){
+ startTimer() {
+ // 如果之前已经存在定时器,先清除它
+ this.clearTimer();
+ this.timer = setInterval(() => {
+ this.getorder()
+ }, 60000);
+ },
+ clearTimer() {
+ // 清除定时器
+ if (this.timer) {
+ clearInterval(this.timer);
+ this.timer = null;
+ }
+ },
+ // 查询当前是否有进行中订单
+ getorder() {
+ this.$u.get('/app/order/rent/using').then(res => {
+ if (res.code == 200) {
+ if (res.data) {
+ this.zujieflag = true
+ this.zujieobj = res.data
+ if (this.zujieobj.endRentTime == null) {
+ var targetDate = new Date(this.zujieobj.startRentTime);
+ var currentDate = new Date();
+ var diff = targetDate - currentDate;
+ var absDiff = Math.abs(diff);
+ var hours = Math.floor(absDiff / (1000 * 60 * 60));
+ var minutes = Math.floor((absDiff % (1000 * 60 * 60)) / (1000 * 60));
+ let formattedMinutes = minutes < 10 ? '0' + minutes : minutes;
+ this.zujieobj.remainingTime = hours + '小时' + formattedMinutes + '分钟';
+ if (this.zujieobj.priceStandard.feeMode == 2) {
+ if (minutes >= this.zujieobj.priceStandard.feeFreeTime) {
+ this.zujiemoney = (hours + 1) * this.zujieobj.priceStandard.feePrice
+ } else {
+ this.zujiemoney = hours * this.zujieobj.priceStandard.feePrice
+ }
+ }else if(this.zujieobj.priceStandard.feeMode == 1){
+ if (minutes >= this.zujieobj.priceStandard.feeFreeTime) {
+ this.zujiemoney = (hours * 2 + 1) * this.zujieobj.priceStandard.feePrice
+ if(minutes >= 30){
+ this.zujiemoney = (hours * 2 + 2) * this.zujieobj.priceStandard.feePrice
+ }
+ } else {
+ this.zujiemoney = hours * 2 * this.zujieobj.priceStandard.feePrice
+ }
+ }
+ } else {
+ var targetDate = new Date(this.zujieobj.endRentTime);
+ var currentDate = new Date();
+ var diff = targetDate - currentDate;
+ var absDiff = Math.abs(diff);
+ var hours = Math.floor(absDiff / (1000 * 60 * 60));
+ var minutes = Math.floor((absDiff % (1000 * 60 * 60)) / (1000 * 60));
+ let formattedMinutes = minutes < 10 ? '0' + minutes : minutes;
+ this.zujieobj.remainingTime = hours + '小时' + formattedMinutes + '分钟';
+ if (this.zujieobj.priceStandard.feeMode == 2) {
+ if (minutes >= this.zujieobj.priceStandard.feeFreeTime) {
+ this.zujiemoney = (hours + 1) * this.zujieobj.priceStandard.feePrice
+ } else {
+ this.zujiemoney = hours * this.zujieobj.priceStandard.feePrice
+ }
+ }else if(this.zujieobj.priceStandard.feeMode == 1){
+ if (minutes >= this.zujieobj.priceStandard.feeFreeTime) {
+ this.zujiemoney = (hours * 2 + 1) * 2 * this.zujieobj.priceStandard.feePrice
+ if(minutes >= 30){
+ this.zujiemoney = (hours * 2 + 2) * this.zujieobj.priceStandard.feePrice
+ }
+ } else {
+ this.zujiemoney = hours * 2 * this.zujieobj.priceStandard.feePrice
+ }
+ }
+ }
+ }
+ }
+ })
+ },
+
+ updateMarkers() {
+ this.mapContext.getScale({
+ success: (res) => {
+ this.covers = []; // 清空之前的覆盖物
+ if (res.scale <= 14) {
+ this.addMarkersWithoutLabels();
+ } else {
+ this.addMarkersWithLabels();
+ }
+ },
+ fail: (error) => {
+ console.error('获取地图缩放级别失败:', error);
+ // 额外的错误处理逻辑...
+ },
+ });
+ },
+ addMarkersWithoutLabels() {
+ this.listmap.forEach((item) => {
+ const shopCover = {
+ id: parseFloat(item.storeId),
+ latitude: item.lat,
+ longitude: item.lng,
+ width: 25,
+ height: 30,
+ iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uI3B6yPwtiUBD3vafLtw',
+ };
+ this.covers.push(shopCover);
+ });
+ },
+ addMarkersWithLabels() {
+ this.listmap.forEach((item) => {
+ const shopCover = {
+ id: parseFloat(item.storeId),
+ latitude: item.lat,
+ longitude: item.lng,
+ width: 25,
+ height: 30,
+ iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uI3B6yPwtiUBD3vafLtw',
+ label: {
+ content: item.name,
+ anchorX: this.calculateAnchorX(item.name),
+ fontWeight: 700,
+ color: '#25D088',
+ textShadow: '2px 2px 0px #000, -2px -2px 0px #000, 2px -2px 0px #000, -2px 2px 0px #000',
+ rotate: 20
+ }
+ }
+ this.covers.push(shopCover);
+ });
+ },
+ calculateAnchorX(name) {
+ let chineseLength = 0;
+ let englishLength = 0;
+ for (let i = 0; i < name.length; i++) {
+ const charCode = name.charCodeAt(i);
+ if (charCode >= 0x4e00 && charCode <= 0x9fa5) {
+ chineseLength++;
+ } else if (/[a-zA-Z]/.test(name[i])) {
+ englishLength = englishLength + 0.3;
+ // console.log(englishLength);
+ }
+ }
+ const totalLength = chineseLength + englishLength * 2;
+ return -totalLength * 6.5
+ },
+
+ btnzujie() {
this.zujieflag = false
},
scanQRCode() {
@@ -167,8 +343,12 @@
getuser() {
this.$u.get('/app/user/userInfo').then(res => {
if (res.code == 200) {
- uni.setStorageSync('userdata', res.data)
- // console.log(uni.getStorageSync('userdata'));
+ if (uni.setStorageSync('userdata')) {
+ uni.removeStorageSync('userdata')
+ uni.setStorageSync('userdata', res.data)
+ } else {
+ uni.setStorageSync('userdata', res.data)
+ }
}
})
},
@@ -192,17 +372,6 @@
})
}
},
- btnnav(num) {
- if (num == 1) {
-
- } else if (num == 2) {
-
- } else if (num == 3) {
-
- } else if (num == 4) {
-
- }
- },
getMyLocation() {
uni.getLocation({
@@ -216,6 +385,7 @@
this.$u.get("/app/store/listNearBy?center=" + this.jinweidu + '&radius=' + 1000).then(
res => {
if (res.code == 200) {
+ this.listmap = res.data
res.data.forEach(item => {
const shopCover = {
id: parseFloat(item.storeId),
@@ -226,8 +396,29 @@
iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uI3B6yPwtiUBD3vafLtw',
label: {
content: item.name,
- // anchorX:-20,
- textAlign: 'center'
+ anchorX: (() => {
+ if (item.name.length <= 2) {
+ return -12
+ } else if (item.name.length <= 3) {
+ return -20
+ } else if (item.name.length <= 4) {
+ return -25
+ } else if (item.name.length <= 5) {
+ return -30
+ } else if (item.name.length <= 6) {
+ return -35
+ } else if (item.name.length <= 8) {
+ return -40
+ } else if (item.name.length <=
+ 10) {
+ return -45
+ } else {
+ return -item.name.length * 5
+ }
+ })(),
+ fontWeight: 700,
+ color: '#25D088',
+ textShadow: '2px 2px 0px white, -2px -2px 0px white, 2px -2px 0px white, -2px 2px 0px white',
}
};
this.covers.push(shopCover);
@@ -258,7 +449,7 @@
uni.setStorageSync('token', res.token);
taht.getMyLocation()
}
- });
+ })
}
},
})
diff --git a/pages/myorder/index.vue b/pages/myorder/index.vue
index c7ef81e..cd45982 100644
--- a/pages/myorder/index.vue
+++ b/pages/myorder/index.vue
@@ -27,7 +27,7 @@
租转卖
- 订单金额 {{item.money == null ? '-' : item.money}}
+ 订单金额 {{item.money == null ? (zujiemoney > item.priceStandard.feeMaxPrice ? item.priceStandard.feeMaxPrice : zujiemoney) : item.money}}元
租借时间 {{item.startRentTime}}
@@ -55,7 +55,8 @@
type: '',
bgc: {
background: '#25CE88'
- }
+ },
+ zujiemoney:''
}
},
onLoad() {
@@ -84,6 +85,22 @@
let formattedMinutes = minutes < 10 ? '0' + minutes : minutes;
// 直接拼接字符串,不要插入 '-'
order.remainingTime = hours + '时' + formattedMinutes + '分钟';
+ if (order.priceStandard.feeMode == 2) {
+ if (minutes >= order.priceStandard.feeFreeTime) {
+ this.zujiemoney = (hours + 1) * order.priceStandard.feePrice
+ } else {
+ this.zujiemoney = hours * order.priceStandard.feePrice
+ }
+ }else if(order.priceStandard.feeMode == 1){
+ if (minutes >= order.priceStandard.feeFreeTime) {
+ this.zujiemoney = (hours * 2 + 1) * order.priceStandard.feePrice
+ if(minutes >= 30){
+ this.zujiemoney = (hours * 2 + 2) * order.priceStandard.feePrice
+ }
+ } else {
+ this.zujiemoney = hours * 2 * order.priceStandard.feePrice
+ }
+ }
}else{
var targetDate = new Date(order.endRentTime);
var currentDate = new Date();
@@ -93,6 +110,22 @@
var minutes = Math.floor((absDiff % (1000 * 60 * 60)) / (1000 * 60));
let formattedMinutes = minutes < 10 ? '0' + minutes : minutes;
order.remainingTime = hours + '时' + formattedMinutes + '分钟';
+ if (order.priceStandard.feeMode == 2) {
+ if (minutes >= order.priceStandard.feeFreeTime) {
+ this.zujiemoney = (hours + 1) * order.priceStandard.feePrice
+ } else {
+ this.zujiemoney = hours * order.priceStandard.feePrice
+ }
+ }else if(order.priceStandard.feeMode == 1){
+ if (minutes >= order.priceStandard.feeFreeTime) {
+ this.zujiemoney = (hours * 2 + 1) * order.priceStandard.feePrice
+ if(minutes >= 30){
+ this.zujiemoney = (hours * 2 + 2) * order.priceStandard.feePrice
+ }
+ } else {
+ this.zujiemoney = hours * 2 * order.priceStandard.feePrice
+ }
+ }
}
});
diff --git a/pages/myorder/returned/index.vue b/pages/myorder/returned/index.vue
index 0fb0636..4d152d6 100644
--- a/pages/myorder/returned/index.vue
+++ b/pages/myorder/returned/index.vue
@@ -4,7 +4,7 @@
- {{listobj.remainingTime}} ¥{{listobj.money}}
+ {{listobj.remainingTime}} ¥{{listobj.money == null ? (zujiemoney > fee.feeMaxPrice ? fee.feeMaxPrice : zujiemoney) : listobj.money}}
使用时长 订单金额
@@ -15,7 +15,11 @@
价格明细
- 收费标准 {{fee.feePrice}}元/小时,前{{fee.feeFreeTime}}分钟免费,日封顶{{fee.feePrice * 24}}元
+ 收费标准
+
+ {{fee.feePrice}}元/小时
+ {{fee.feePrice}}元/半小时
+ ,前{{fee.feeFreeTime}}分钟免费,日封顶{{fee.feePrice * 24}}元,总封顶{{fee.feeMaxPrice}}元
租借方式
@@ -26,10 +30,10 @@
使用时长 {{listobj.remainingTime}}
- 付款金额 ¥{{listobj.payMoney}}
+ 付款金额 ¥{{ listobj.payMoney == null ? (zujiemoney > fee.feeMaxPrice ? fee.feeMaxPrice : zujiemoney) : listobj.payMoney}}
- 订单金额 ¥{{listobj.money}}
+ 订单金额 ¥{{listobj.money == null ? (zujiemoney > fee.feeMaxPrice ? fee.feeMaxPrice : zujiemoney) : listobj.money}}
@@ -56,16 +60,16 @@
(朝阳路店)
-->
- 归还时间 {{listobj.endRentTime}}
+ 归还时间 {{listobj.endRentTime == null ? '-' : listobj.endRentTime}}
- 归还店铺 {{listobj.endStoreName}}
+ 归还店铺 {{listobj.endStoreName == null ? '-' : listobj.endStoreName}}
- 归还设备 {{listobj.endCabinetSn}}
+ 归还设备 {{listobj.endCabinetSn == null ? '-' : listobj.endCabinetSn}}
- 归还地点 {{listobj.endStoreAddress}}
+ 归还地点 {{listobj.endStoreAddress == null ? '-' : listobj.endStoreAddress}}