Init project

This commit is contained in:
lifizer
2023-09-20 21:49:33 +08:00
parent 85a5989c96
commit c9ceac9f37
710 changed files with 125705 additions and 0 deletions
+368
View File
@@ -0,0 +1,368 @@
<template>
<view class="chose-city">
<view class="header">
<view class="search-box flex jc-between ai-center">
<input type="text" v-model="keyword" placeholder="搜索城市" placeholder-style="color:#999" @confirm="search">
<image class="icon" :src="webUrl+'/20220903142935869059.png'" mode="scaleToFill" @click="search"></image>
</view>
</view>
<view class="aside">
<view class="item flex jc-center ai-center" :class="index === navActive ? 'on' : ''"
v-for="(item, index) in listGroup" :key="index" @click="asideTap(index)">
<view class="name">{{ item.label }}</view>
</view>
</view>
<view class="content">
<mescroll-body ref="mescrollRef" top="16rpx" bottom="0" class='cotent-scroll' :up="upOption" :down="downOption"
@up="upCallback" @down="downCallback" @init="mescrollInit" @emptyclick="emptyClick">
<view class="fixed-box">
<view class="line-location flex ai-center" v-if="location">
<image :src="webUrl+'/20220903142929759087.png'" mode="scaleToFill"></image>
<text class="bold" @click="select(location)">当前定位{{ location }}</text>
</view>
<image class="banner" :src="banner.icon" mode="scaleToFill" v-if="banner"
@click="$global.commonJump(banner.url)"/>
<view class="top-box" v-if="listTop.length">
<view class="tips">特别推荐</view>
<view class="top-list custom-list flex ai-center">
<view class="item" v-for="(item,index) in listTop" :key="index" @click="select(item)">
<view class="has-goods" v-if="type===0 && item.hasData===0">暂无特产</view>
<view class="has-goods" v-if="type>0 && type<6&& item.hasShop===0">暂无店铺</view>
<image :src="item.icon" mode="scaleToFill"></image>
<view class="one-t">{{ item.cityName }}</view>
</view>
</view>
</view>
</view>
<view class="province-name">{{ provinceName }}</view>
<view class="group-list custom-list flex flex-wrap">
<view class="item" v-for="(item, index) in listCity" :key="index" @click="select(item)">
<view class="has-goods" v-if="type===0 && item.hasData===0">暂无特产</view>
<view class="has-goods" v-if="type>0 && type<6&& item.hasShop===0">暂无店铺</view>
<view class="has-goods" v-if="type===6&& item.hasData===0">暂无景点</view>
<image :src="item.icon" mode="scaleToFill"></image>
<view class="one-t">{{ item.cityName }}</view>
</view>
</view>
</mescroll-body>
</view>
</view>
</template>
<script>
import MescrollMixins from "@/mixins/mescroll-mixins.js";
import {fetchCity} from "@/api/wenwan";
import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue";
import {getCurAddress, getLocation} from "@/utils/common.js";
export default {
name: "choseCity",
components: {
MescrollBody
},
props: {},
mixins: [
MescrollMixins({
getPageData(mescroll) {
// 此时mescroll会携带page的参数:
// let pageNum = mescroll.num; // 页码, 默认从1开始
// let pageSize = mescroll.size; // 页长, 默认每页10条
mescroll.endSuccess(10);
}
})
],
data() {
return {
upOption: {
noMoreSize: 10, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
auto: false,
empty: {
tip: '暂无城市' // 提示
// btnText:'点击刷新'
}
},
downOption: {
auto: true
},
webUrl: this.$VUE_APP_RESOURCES_URL,
listGroup: [],
listTop: [],
provinceName: "",
listCity: [],
navActive: 0,
keyword: "",
type: null,
location: "",
banner: {}
};
},
onLoad(options) {
this.type = Number(options.type);
this.location = options.city;
if (this.location === undefined) {
this.getMapData();
}
this.init();
},
methods: {
async getMapData() {
const map = await getLocation();
const {latitude, longitude} = map[1];
const address = await getCurAddress(latitude, longitude);
this.location = address[1].data.result.ad_info.city;
},
init() {
fetchCity(this.type).then(res => {
if (res.success) {
this.listGroup = res.data.group;
// this.listTop = res.data.tops;
if (this.listGroup.length > 0) {
this.listTop = this.listGroup[0].top;
this.listCity = this.listGroup[0].city;
this.provinceName = this.listGroup[0].label;
this.banner = {
icon: this.listGroup[0].icon,
url: this.listGroup[0].uniappUrl
}
}
}
})
},
asideTap(index) {
this.navActive = index;
this.listTop = this.listGroup[index].top;
this.listCity = this.listGroup[index].city;
this.provinceName = this.listGroup[index].label;
this.banner = {
icon: this.listGroup[index].icon,
url: this.listGroup[index].uniappUrl
}
//触发加载请求
this.mescroll.scrollTo(0, 0);
this.mescroll && this.mescroll.resetUpScroll(false);
},
emptyClick: function () {
//触发加载请求
this.mescroll && this.mescroll.triggerDownScroll()
},
search() {
this.listGroup.findIndex((group, index) => {
let result;
group.city.forEach(item => {
result = item.cityName.indexOf(this.keyword, 0);
if (result !== -1) {
this.asideTap(index);
return null;
}
})
if (result !== -1) {
return result
}
})
},
select(item) {
if (this.type === 0 && item.hasData === 0) return;
uni.setStorageSync("cityName", item.cityName)
switch (this.type) {
case 0:
uni.navigateTo({
url: `/pkg_product/views/nativeList?cityId=${item.cityId}`
})
break;
case 1:
uni.navigateTo({
url: `/wenwan/views/storeList?cityId=${item.cityId}`
})
break;
case 6:
uni.navigateTo({
url: `/pkg_product/views/scenicSpot?cityId=${item.cityId}`
})
break;
default:
uni.navigateBack()
break;
}
}
}
};
</script>
<style scoped lang="less">
.chose-city {
height: 100%;
background: #fff;
color: #033333;
.banner {
width: 520rpx;
height: 200rpx;
vertical-align: middle;
margin: 16rpx auto 0;
border-radius: 8rpx;
}
.custom-list {
.item {
width: 160rpx;
margin-right: 20rpx;
font-size: 24rpx;
image {
width: 160rpx;
height: 160rpx;
border-radius: 8rpx;
vertical-align: middle;
}
.one-t {
margin-top: 14rpx;
line-height: 34rpx;
}
}
}
.header {
position: fixed;
top: 0;
left: 0;
width: 100%;
padding: 16rpx 32rpx 28rpx;
box-sizing: border-box;
background: #fff;
border-bottom: 2rpx solid #E9E9E9;
z-index: 9;
.search-box {
width: 686rpx;
height: 64rpx;
padding: 0 24rpx 0 32rpx;
box-sizing: border-box;
background: #F7F7F7;
border-radius: 32rpx;
input {
width: 560rpx;
font-size: 22rpx;
}
.icon {
width: 40rpx;
height: 40rpx;
}
}
}
.aside {
position: fixed;
width: 161rpx;
left: 0;
top: 110rpx;
bottom: 0 !important;
box-sizing: border-box;
border-right: 2rpx solid #E9E9E9;
background: #fff;
overflow-y: auto;
overflow-x: hidden;
overflow-scrolling: touch;
.item {
width: 100%;
height: 96rpx;
border-bottom: 2rpx solid #E9E9E9;
.name {
font-size: 28rpx;
text-align: center;
}
}
.item.on {
border-left: 6rpx solid #FD574B;
.name {
color: #FD574B;
font-weight: bold;
}
}
}
.aside::-webkit-scrollbar {
width: 0 !important
}
.content {
margin-left: 161rpx;
margin-top: 110rpx;
.fixed-box {
padding: 32rpx 0 44rpx 38rpx;
.line-location {
font-size: 28rpx;
image {
width: 36rpx;
height: 36rpx;
margin-right: 4rpx;
}
}
.top-box {
.tips {
margin: 36rpx 0 20rpx;
font-size: 28rpx;
line-height: 40px;
color: #666666;
}
.top-list {
overflow-x: auto;
}
.top-list::-webkit-scrollbar {
width: 0 !important
}
}
}
.province-name {
margin: 0 38rpx 24rpx;
font-size: 28rpx;
line-height: 40rpx;
color: #666666;
}
.group-list {
padding-left: 38rpx;
}
.item {
position: relative;
margin-bottom: 28rpx;
.has-goods {
position: absolute;
right: 0;
top: 0;
padding: 7rpx 8rpx;
border-radius: 0 8px 0 8px;
background: #f66;
color: #fff;
font-size: 24rpx;
line-height: 1;
}
}
}
}
</style>