Commit cd89bfe0 by 宋冰琦

完成店铺选择排序问题

parent 467b32c6
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<image :style="{'height':'100%','width':'100%'}" :src="'../../../static/imgs/jiantouhei2.png'" /> <image :style="{'height':'100%','width':'100%'}" :src="'../../../static/imgs/jiantouhei2.png'" />
</view> </view>
</view> </view>
<div v-for="item in list" :key="item.id" @click="selectedShop(item)" class="shop_item" :class="shopId==item.id?'active':''"> <div v-for="item in finalList" :key="item.id" @click="selectedShop(item)" class="shop_item" :class="shopId==item.id?'active':''">
<div class="header"> <div class="header">
<view class="name">{{ item.name }}</view> <view class="name">{{ item.name }}</view>
<view class="adressBox"> <view class="adressBox">
...@@ -55,6 +55,24 @@ export default { ...@@ -55,6 +55,24 @@ export default {
this.list = uni.getStorageSync('shops'); this.list = uni.getStorageSync('shops');
this.areaName = uni.getStorageSync('areaName') this.areaName = uni.getStorageSync('areaName')
}, },
computed: {
finalList() {
const {list} = this
const val = list.sort((a,b)=>{
return a.realDistance-b.realDistance
})
let unshiftVal = {}
val.map((item,index)=>{
if(item.id==this.shopId){
unshiftVal = val.splice(index,1)[0]
}
})
if(JSON.stringify(unshiftVal)!='{}'){
val.unshift(unshiftVal)
}
return val
}
},
methods: { methods: {
selectedShop(item) { selectedShop(item) {
uni.setStorage({ key: 'shopData', data: item }); uni.setStorage({ key: 'shopData', data: item });
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<!-- <image class="logImg" src="/static/imgs/hooloo.png"></image> --> <!-- <image class="logImg" src="/static/imgs/hooloo.png"></image> -->
<!-- <view class="logText">未 来 咖 啡</view> --> <!-- <view class="logText">未 来 咖 啡</view> -->
</view> </view>
<image :src="'https://s3.bmp.ovh/imgs/2022/07/01/f683c3a5225011b2.gif'"/> <image :src="'https://s3.bmp.ovh/imgs/2022/07/05/1768111c5c7f5300.gif'"/>
<!-- <video class="video" autoplay muted loop :controls="false" :enable-progress-gesture="false" objectFit='cover' src="http://songclound.oss-cn-hongkong.aliyuncs.com/2022/06/27/e6582afb60924.mp4"></video> --> <!-- <video class="video" autoplay muted loop :controls="false" :enable-progress-gesture="false" objectFit='cover' src="http://songclound.oss-cn-hongkong.aliyuncs.com/2022/06/27/e6582afb60924.mp4"></video> -->
<view class="mod11"> <view class="mod11">
<view class="avatar"> <view class="avatar">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment