Ver a proveniência

upload

soldDate
HolyKnightIX há 1 ano
ascendente
cometimento
97dc1cea33
6 ficheiros alterados com 93 adições e 52 eliminações
  1. +1
    -1
      app.js
  2. +69
    -45
      index/index.js
  3. +19
    -2
      index/index.ttml
  4. +2
    -2
      pages/couponorder/detail/index.ttml
  5. +1
    -1
      pages/couponorder/index/index.js
  6. +1
    -1
      pages/order/index/index.js

+ 1
- 1
app.js Ver ficheiro

@@ -24,7 +24,7 @@ App({
},
onLaunch: function () {
let that = this
tt.setStorageSync('locationFlag', true);
try {
var res = tt.getSystemInfoSync();
that.statusBarHeight = res.statusBarHeight


+ 69
- 45
index/index.js Ver ficheiro

@@ -118,7 +118,7 @@ Page({
shopList: [],
mallTenantId: tt.getStorageSync('mallTenantId') || '',
index: tt.getStorageSync('mallIndex') || 0,
locateData: {}
locateData: {},
},

getCongig() { //获取小程序是否开通授权手机号
@@ -143,7 +143,7 @@ Page({

getsubMallList() {
Http.get({
url: '/mall/subMall?isAll=1',
url: '/mall/subMall?isAll=0',
}).then(res => {
tt.setStorageSync('shopList', JSON.stringify(res.data));
this.setData({
@@ -161,7 +161,8 @@ Page({
},

bindPickerChange(e, indexIn, id) {
const index = indexIn || e.detail.value
const index = e ? e.detail.value : indexIn

const mallTenantId = id || this.data.shopList[index].tenantId
tt.setStorageSync('mallTenantId', mallTenantId)
tt.setStorageSync('mallIndex', index)
@@ -571,7 +572,6 @@ Page({
* 生命周期函数--监听页面初次渲染完成
*/
onLoad: function (options) {

let that = this;
let optionss;

@@ -607,6 +607,7 @@ Page({
// isHighAccuracy: true,
success: function (res) {
console.log(res, 'getLocation')

const locateData = {
latitude: res.latitude,
longitude: res.longitude,
@@ -623,57 +624,78 @@ Page({
city: res.city
}
}).then(res => {
this.getsubMallList()
console.log(res, 9999)
// 获取到的用户的坐标
const latitudeNow = that.data.locateData.latitude
const longitudeNow = that.data.locateData.longitude

const mallLocationArr = []

const shopList = JSON.parse(tt.getStorageSync('shopList'));

shopList.forEach((item, index) => {
const obj = {
latitude: item.latitude,
longitude: item.longitude,
mallTenantId: item.tenantId,
index: index
}
mallLocationArr.push(obj)
})

console.log(mallLocationArr, 'mallLocationArr');

const tempArr = shopList
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].name + ' ' + distanceData.distance_str
tempArr[index].distance = distanceData.distance
bloobArr.push(distanceData.distance)
})
that.setData({
shopList: tempArr
})

// 通过排序获取最近广场
const nearestDistance = that.bloob(bloobArr)[0]
const nearestArr = that.data.shopList.filter((item, index) => {
// 切换至最近的广场
const locationFlag = tt.getStorageSync('locationFlag');
if ((item.distance == nearestDistance)) {
that.bindPickerChange('', index, item.tenantId)
tt.setStorageSync('locationFlag', false);
return true
} else {
return false
}
})
console.log(nearestArr[0], 'nearestArr');

})
}
},
fail: error => {
console.log(error);
},
complete: finish => {
// 获取到的用户的坐标
const latitudeNow = that.data.locateData.latitude
const longitudeNow = that.data.locateData.longitude

const mallLocationArr = []

const shopList = JSON.parse(tt.getStorageSync('shopList'));

let obj = {}
shopList.forEach((item, index) => {
const obj = {
latitude: item.latitude,
longitude: item.longitude,
mallTenantId: item.tenantId,
index: index
if (item.defaultSign == 1) {
const tempObj = {
index: index,
tenantId: item.tenantId
}
obj = tempObj
return
}
mallLocationArr.push(obj)
})
console.log(obj, 'obj');
that.bindPickerChange('', obj.index, obj.tenantId)
},
complete: finish => {

console.log(mallLocationArr, 'mallLocationArr');

const tempArr = shopList
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].distance = distanceData.distance
bloobArr.push(distanceData.distance)
})
that.setData({
shopList: tempArr
})
const nearestDistance = that.bloob(bloobArr)[0]
const nearestArr = that.data.shopList.filter((item, index) => {
if (item.distance == nearestDistance) {
that.bindPickerChange('', index, item.tenantId)
return true
} else {
return false
}
})
console.log(nearestArr[0], 'nearestArr');
}
})

@@ -702,6 +724,8 @@ Page({

if (parseInt(distance) >= 1) {
distance_str = distance.toFixed(2) + "km";
} else if (!arseInt(distance)) {
return false
} else {
distance_str = (distance * 1000).toFixed(2) + "m";
}


+ 19
- 2
index/index.ttml Ver ficheiro

@@ -17,14 +17,31 @@
</view> -->
</view>

<view class="pickerMall" tt:if="{{shopList.length>1}}">
<!-- 距离信息的广场列表 -->
<view class="pickerMall" tt:if="{{shopList.length>1 && shopList[0].distanceName}}">
<picker mode="selector" bindchange="bindPickerChange" value="{{index}}" range="{{shopList}}"
range-key="distanceName" disabled="{{false}}">
<view>
<view>
<image src="../assets/images/location.png" class="location"></image>
<text class="mallName">{{ shopList[index].name }}</text>
<text tt:if="{{shopList[index].distance_str}}" class="distance_str">距您{{
shopList[index].distance_str}}</text>
<image src="../assets/itemImg/arrow-right-l.png" class="right"></image>
</view>
</view>
</picker>
</view>

<!-- 仅广场列表不包括距离信息 -->
<view class="pickerMall" tt:if="{{shopList.length>1 && !shopList[0].distanceName}}">
<picker mode="selector" bindchange="bindPickerChange" value="{{index}}" range="{{shopList}}" range-key="name"
disabled="{{false}}">
<view>
<view>
<image src="../assets/images/location.png" class="location"></image>
<text class="mallName">{{ shopList[index].name }}</text>
<text class="distance_str" wx:if="{{shopList[index].distance_str}}}">距您{{
<text tt:if="{{shopList[index].distance_str}}" class="distance_str">距您{{
shopList[index].distance_str}}</text>
<image src="../assets/itemImg/arrow-right-l.png" class="right"></image>
</view>


+ 2
- 2
pages/couponorder/detail/index.ttml Ver ficheiro

@@ -65,9 +65,9 @@
</view>
<view class="notes">
<view class="notesText">购买须知</view>
<text class="introduce" tt:if="{{curHtml==''}}"> {{data.remark}}</text>
<text class="introduce" tt:if="{{data.remark}}"> {{data.remark}}</text>
<!-- <text class="notesText" tt:if="{{curHtml==""}}">{{detailObj.remark}}</text> -->
<rich-text class="rich_text" tt:if="{{curHtml!=''}}" nodes="{{curHtml}}"></rich-text>
<rich-text class="rich_text" tt:if="{{curHtml!='' && !data.remark}}" nodes="{{curHtml}}"></rich-text>
</view>
</view>
</view>

+ 1
- 1
pages/couponorder/index/index.js Ver ficheiro

@@ -141,7 +141,7 @@ Page({
onLoad: function (options) {
this.mallSync()
Http.get({
url: '/mall/subMall?isAll=1',
url: '/mall/subMall?isAll=0',
}).then(res => {
this.setData({
shopList: res.data,


+ 1
- 1
pages/order/index/index.js Ver ficheiro

@@ -106,7 +106,7 @@ Page({

onLoad(e) {
Http.get({
url: '/mall/subMall?isAll=1',
url: '/mall/subMall?isAll=0',
}).then(res => {
this.setData({
shopList: res.data,


Carregando…
Cancelar
Guardar