From 4a08986dc09e2a8f11fd8f6f4bdb4cf5179c78df Mon Sep 17 00:00:00 2001
From: YWQ HK IX <568170040@qq.com>
Date: Thu, 29 Jun 2023 00:41:45 +0800
Subject: [PATCH] upload
---
pages/coupon/confirmation/confirmation.js | 194 +++++++++++++++++++-
pages/coupon/confirmation/confirmation.ttml | 22 +++
pages/coupon/confirmation/confirmation.ttss | 27 +++
pages/coupon/detail/index.js | 6 +-
pages/order/detail/index.js | 2 +-
pages/order/detail/index.ttml | 4 +-
6 files changed, 247 insertions(+), 8 deletions(-)
diff --git a/pages/coupon/confirmation/confirmation.js b/pages/coupon/confirmation/confirmation.js
index ed3b5e0..4b89768 100644
--- a/pages/coupon/confirmation/confirmation.js
+++ b/pages/coupon/confirmation/confirmation.js
@@ -16,7 +16,12 @@ Page({
mallTenantId: '',
imId: "",
goodId: "",
- IMorderId: ""
+ IMorderId: "",
+ merchantId: "",
+ currentIndex: "",
+ mallList: [],
+ latitude: "",
+ longitude: ""
},
onLoad: function (options) {
console.log(options, 'options!!!!!!!');
@@ -32,6 +37,8 @@ Page({
}
console.log(this.data.mallTenantId, 'mallTenantId');
+ this.getCouponMerchant(options.merOrderId)
+
tt.showLoading({
title: "加载中..."
});
@@ -54,12 +61,22 @@ Page({
}
}
}
-
},
imCallback(e) {
console.log("跳转IM客服成功", e);
},
+
+ setMerchant(e) {
+ console.log(e.detail.value, 'e');
+ const index = e.detail.value
+ this.setData({
+ currentIndex: index,
+ merchantId: this.data.mallList[index].id
+ })
+ console.log(this.data.currentIndex, this.data.merchantId);
+ },
+
onimError(e) {
console.log("拉起IM客服失败", e.detail);
},
@@ -85,7 +102,7 @@ Page({
}
}).then(res => {
console.log(res, 'getIm');
- const imId = res.data.imId || ''
+ const imId = res.data.imId ? res.data.imId : ""
that.setData({
imId: imId
})
@@ -94,6 +111,167 @@ Page({
})
},
+ getCouponMerchant(couponChannelId) { //获取适用门店
+ const that = this
+ Http.get({
+ url: config.api.couponMerchant,
+ data: {
+ couponChannelId,
+ mallTenantId: that.data.mallTenantId || ''
+ }
+ }).then(res => {
+ const keys = Object.keys(res.data)
+ const mallList = []
+ let i = 0
+ keys.forEach(item => {
+ const arr = item.split('|')
+ const obj = {
+ tenantId: arr[0],
+ mallName: arr[1],
+ merchantVoList: res.data[item],
+ expand: false
+ }
+ if (i == 0) {
+ obj.expand = true
+ }
+ mallList.push(obj)
+ i++
+ })
+ that.setData({
+ mallList: mallList[0].merchantVoList
+ })
+ console.log(that.data.mallList, 'mallList');
+ that.getLocation()
+ })
+ },
+
+ /**
+ * 获得经纬度
+ */
+ getLocation() {
+ console.log('getLocation');
+ let that = this;
+ tt.getLocation({
+ type: "wgs84",
+ // isHighAccuracy: true,
+ success: function (res) {
+ console.log(res, 'getLocation')
+ that.setData({
+ latitude: res.latitude,
+ longitude: res.longitude,
+ })
+ const latitudeNow = res.latitude
+ const longitudeNow = res.longitude
+
+ const mallLocationArr = []
+ const mallList = that.data.mallList
+ mallList.forEach((item, index) => {
+ const obj = {
+ latitude: item.latitude || false,
+ longitude: item.longitude || false,
+ id: item.id,
+ index: index
+ }
+ mallLocationArr.push(obj)
+ })
+ console.log(mallLocationArr, 'mallLocationArr');
+
+ const tempArr = mallList
+ const bloobArr = []
+
+ mallLocationArr.forEach((item, index) => {
+ const distanceData = that.getDistances(latitudeNow, longitudeNow, item.latitude, item.longitude)
+ tempArr[index].distance_str = distanceData.distance_str
+ tempArr[index].distanceName = tempArr[index].merchantName + ' ' + distanceData.distance_str
+ tempArr[index].distance = distanceData.distance
+ bloobArr.push(tempArr[index])
+ })
+
+ const finalSortMallList = that.bloob(bloobArr)
+ console.log(finalSortMallList, 'finalSortMallList');
+ that.setData({
+ mallList: finalSortMallList
+ })
+ },
+ // 拒绝提供定位权限
+ fail: error => {
+ console.log(error, 'error');
+ const mallList = that.data.mallList
+ mallList.forEach(item => {
+ item.distanceName = item.merchantName
+ })
+
+ that.setData({
+ mallList
+ })
+
+ },
+ complete: finish => {
+
+ }
+ })
+ },
+
+ /**
+ * @description:根据经纬度计算距离
+ * @param {*} locationInfo (lat1, lng1, lat2, lng2)
+ * @return: distanceObj: { distance , distance_str }
+ */
+ getDistances(lat1, lng1, lat2, lng2) {
+
+ if (lat2 || lng2) {
+ function rad(num) {
+ return num * Math.PI / 180.0;
+ }
+ var radLat1 = rad(lat1);
+ var radLat2 = rad(lat2);
+ var a = radLat1 - radLat2;
+ var b = rad(lng1) - rad(lng2);
+ var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
+ Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
+ s = s * 6378.137;
+ s = Math.round(s * 10000) / 10000;
+
+ var distance = s;
+ var distance_str = "";
+
+ if (parseInt(distance) >= 1) {
+ distance_str = distance.toFixed(2) + "km";
+ } else if (!arseInt(distance)) {
+ return false
+ } else {
+ distance_str = (distance * 1000).toFixed(2) + "m";
+ }
+
+ let objData = {
+ distance: distance,
+ distance_str: distance_str
+ }
+ return objData
+ } else {
+ let objData = {
+ distance: Infinity,
+ distance_str: ''
+ }
+ return objData
+ }
+
+ },
+
+ bloob(arr) {
+ const tempArr = arr
+ for (let i = 0; i < tempArr.length - 1; i++) {
+ for (let j = 0; j < tempArr.length - 1 - i; j++) {
+ if (tempArr[j].distance > tempArr[j + 1].distance) {
+ let temp = tempArr[j];
+ tempArr[j] = tempArr[j + 1];
+ tempArr[j + 1] = temp;
+ }
+ }
+ }
+ return tempArr
+ },
+
getSupId(id) {
Http.get({
url: config.api.getSpuid,
@@ -461,6 +639,13 @@ Page({
*/
orderFunc(discount) {
if (this.data.showbutton) return;
+ if (!this.data.merchantId) {
+ tt.showToast({
+ title: '请选择可用商户!',
+ icon: 'fail'
+ });
+ return
+ };
let that = this;
tt.showLoading({
@@ -527,6 +712,9 @@ Page({
} else {
url = config.api.orderSave
data.mallTenantId = that.data.mallTenantId || ''
+ if (that.data.data.type == 69) {
+ data.fixMerchantId = that.data.merchantId
+ }
}
/**
* orderSave 下单
diff --git a/pages/coupon/confirmation/confirmation.ttml b/pages/coupon/confirmation/confirmation.ttml
index 22063c9..316f27b 100644
--- a/pages/coupon/confirmation/confirmation.ttml
+++ b/pages/coupon/confirmation/confirmation.ttml
@@ -31,4 +31,26 @@
使用须知
+
+
+
+
+
+ 选择可用商户:
+
+
+ 请选择
+
+
+
+
+
+
+ 选择可用商户:{{
+ mallList[currentIndex].merchantName }}
+
+
\ No newline at end of file
diff --git a/pages/coupon/confirmation/confirmation.ttss b/pages/coupon/confirmation/confirmation.ttss
index 06a62f4..54250a4 100644
--- a/pages/coupon/confirmation/confirmation.ttss
+++ b/pages/coupon/confirmation/confirmation.ttss
@@ -144,4 +144,31 @@
width: 20rpx;
height: 40rpx;
margin: 40rpx 20rpx;
+}
+
+.addressPicker {
+ font-size: 30rpx;
+ background-color: #fff;
+ border-radius: 20rpx;
+ padding: 30rpx;
+ margin: 10rpx auto;
+}
+
+.addressPickerFlex {
+ display: flex;
+ justify-content: space-between;
+ font-size: 30rpx;
+ background-color: #fff;
+ border-radius: 20rpx;
+ padding: 30rpx;
+ margin: 10rpx auto;
+}
+
+.pickerInside {
+ color: #8a8a8a;
+}
+
+.distanceFoot {
+ font-size: 25rpx;
+ color: #3c89ff;
}
\ No newline at end of file
diff --git a/pages/coupon/detail/index.js b/pages/coupon/detail/index.js
index 79c8c58..c110210 100644
--- a/pages/coupon/detail/index.js
+++ b/pages/coupon/detail/index.js
@@ -449,8 +449,9 @@ Page({
},
gotopay: function (e) {
+ const merOrderId = this.data.couponChannelId
tt.navigateTo({
- url: `/pages/coupon/confirmation/confirmation?couponChannelId=${this.data.couponChannelId}&mallTenantId=${this.data.mallTenantId}`,
+ url: `/pages/coupon/confirmation/confirmation?couponChannelId=${this.data.couponChannelId}&mallTenantId=${this.data.mallTenantId}&merOrderId=${merOrderId}`,
})
return
},
@@ -1038,8 +1039,9 @@ Page({
* 发起支付
*/
orderFunc(discount) {
+ const merOrderId = this.data.couponChannelId
tt.navigateTo({
- url: `/pages/coupon/confirmation/confirmation?couponChannelId=${this.data.couponChannelId}`,
+ url: `/pages/coupon/confirmation/confirmation?couponChannelId=${this.data.couponChannelId}&mallTenantId=${this.data.mallTenantId}&merOrderId=${merOrderId}`,
})
// return
diff --git a/pages/order/detail/index.js b/pages/order/detail/index.js
index fb6e6b0..2bda62f 100644
--- a/pages/order/detail/index.js
+++ b/pages/order/detail/index.js
@@ -282,7 +282,7 @@ Page({
}
}).then(res => {
console.log(res, 'getIm');
- const imId = res.data.imId || ''
+ const imId = res.data.imId ? res.data.imId : ""
that.setData({
imId: imId
})
diff --git a/pages/order/detail/index.ttml b/pages/order/detail/index.ttml
index 6479499..50f4cf6 100644
--- a/pages/order/detail/index.ttml
+++ b/pages/order/detail/index.ttml
@@ -136,8 +136,8 @@
服务已完成
- 已评价
-
+ 已评价
+ 完善预约信息