Ver código fonte

upload

product
HolyKnightIX 1 ano atrás
pai
commit
4a08986dc0
6 arquivos alterados com 247 adições e 8 exclusões
  1. +191
    -3
      pages/coupon/confirmation/confirmation.js
  2. +22
    -0
      pages/coupon/confirmation/confirmation.ttml
  3. +27
    -0
      pages/coupon/confirmation/confirmation.ttss
  4. +4
    -2
      pages/coupon/detail/index.js
  5. +1
    -1
      pages/order/detail/index.js
  6. +2
    -2
      pages/order/detail/index.ttml

+ 191
- 3
pages/coupon/confirmation/confirmation.js Ver arquivo

@@ -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 下单


+ 22
- 0
pages/coupon/confirmation/confirmation.ttml Ver arquivo

@@ -31,4 +31,26 @@
<view class="go" bindtap="goInstructions">
<view class="goTitle">使用须知</view>
<image class="goImg" src="../../../assets/itemImg/chevron.png"></image>
</view>

<!-- 仅当可预约时 -->
<view tt:if="{{ data.type == 69 }}">
<view tt:if="{{ !merchantId }}" class="addressPickerFlex">
<text>选择可用商户:</text>
<picker style="display: inline-block;" mode="selector" value="{{index}}" range="{{mallList}}"
range-key="distanceName" disabled="{{false}}" bindchange="setMerchant">
<view class="pickerInside">
请选择
</view>
</picker>
</view>

<view tt:if="{{ merchantId }}" class="addressPicker">
<picker style="display: inline;" mode="selector" value="{{index}}" range="{{mallList}}" range-key="distanceName"
disabled="{{false}}" bindchange="setMerchant">
<text> 选择可用商户:<text class="pickerInside">{{
mallList[currentIndex].merchantName }} <text class="distanceFoot">{{
mallList[currentIndex].distance_str }}</text></text></text>
</picker>
</view>
</view>

+ 27
- 0
pages/coupon/confirmation/confirmation.ttss Ver arquivo

@@ -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;
}

+ 4
- 2
pages/coupon/detail/index.js Ver arquivo

@@ -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



+ 1
- 1
pages/order/detail/index.js Ver arquivo

@@ -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
})


+ 2
- 2
pages/order/detail/index.ttml Ver arquivo

@@ -136,8 +136,8 @@
</text>
<text tt:if="{{ isAppointment && appointmentStatus == 8 }}" class="fr" style="color: #d4a971;">服务已完成
</text>
<text tt:if="{{ isAppointment && appointmentStatus == 9 }}" class="fr" style="color: #d4a971;">已评价
</text>
<text tt:if="{{ isAppointment && appointmentStatus == 9 }}" class="fr" style="color: #d4a971;">已评价</text>
<text tt:if="{{ isAppointment && appointmentStatus == '-1' }}" class="fr" style="color: #d4a971;">完善预约信息</text>
</view>
</view>



Carregando…
Cancelar
Salvar