123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- <template>
- <view>
- <headContent>
- <template #left>
- <view class="head-revers-back iconfont" @click.stop="reversBackBtn()"></view>
- </template>
- <template #content>
- <view class="haed-title">
- 国家/地区
- </view>
- </template>
- </headContent>
- <!-- :style="{'top': searchHeight + 'px'}" -->
- <view class="search-box">
-
- </view>
- <view class="scroll-box" :style="{'height':scrollViewHeight + 'px'}">
- <scroll-view scroll-y="true" class="scroll-Y" scroll-with-animation :scroll-into-view="scrollIntoView">
- <view v-if="Areahot && Areahot.length > 0">
- <text class="search-letter">热门国家</text>
- <view class="area-list">
- <view class="area-item" v-for="(item , index) in Areahot" :key="`hot_${index}`"
- @click.stop="activeArea(item)">
- <text>{{item.name}}</text>
- <text>+{{item.area_code}}</text>
- </view>
- </view>
- </view>
- <block v-for="(val , key , index) in AreaList">
- <view :id="key" v-if="val && val.length > 0">
- <text class="search-letter">{{ key }}</text>
- <view class="area-list">
- <view class="area-item" v-for="(item , i) in val" :key="`area_${index}_${i}`"
- @click.stop="activeArea(item)">
- <text>{{item.name}}</text>
- <text>+{{item.area_code}}</text>
- </view>
- </view>
- </view>
- </block>
- </scroll-view>
- <view class="letter-tag">
- <block v-for="(val , key , index) in AreaList">
- <text @click.stop="scrollIntoView = key"
- :class="['tag-item' , scrollIntoView === key ? 'area-key' : '']"
- v-if="val && val.length > 0">{{ key }}</text>
- </block>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- reverseBack
- } from "@/utils/common.js"
- import {
- mapGetters
- } from 'vuex'
- import {
- Api_getAreaCode
- } from "@/api/index.js"
- export default {
- data() {
- return {
- scrollIntoView: 'A',
- scrollViewHeight: 0,
- AreaList: [],
- Areahot:[]
- };
- },
- computed: {
- ...mapGetters([
- 'statusBarHeight',
- 'headHeight'
- ])
- },
- created() {
- const app = uni.getWindowInfo()
- let pageHeight = app.windowHeight || app.screenHeight
- this.scrollViewHeight = pageHeight - uni.upx2px(this.headHeight.split('rpx')[0]) - this.statusBarHeight - uni
- .upx2px(100)
- console.log('app = ', this.scrollViewHeight)
- this.getAreaCode()
- },
- methods: {
- activeArea(item) {
- const pages = getCurrentPages()
- if (pages && pages.length >= 2) {
- const page = pages[pages.length - 2];
- page.$vm.setAreaCode(item);
- uni.navigateBack()
- } else {
- uni.reLaunch({
- url: '/pages/index/index'
- })
- }
- },
- reversBackBtn() {
- reverseBack()
- },
- getAreaCode() {
- Api_getAreaCode().then(res => {
- this.areaRank(res)
- }).catch(err => {
- })
- },
- areaRank(areaList = []) {
- const hot = []
- const letters = {
- 'A': [],
- 'B': [],
- 'C': [],
- 'D': [],
- 'E': [],
- 'F': [],
- 'G': [],
- 'H': [],
- 'I': [],
- 'J': [],
- 'K': [],
- 'L': [],
- 'M': [],
- 'N': [],
- 'O': [],
- 'P': [],
- 'Q': [],
- 'R': [],
- 'S': [],
- 'T': [],
- 'U': [],
- 'V': [],
- 'W': [],
- 'X': [],
- 'Y': [],
- 'Z': [],
- '#': []
- }
- if (areaList && areaList.length > 0) {
- areaList.forEach(el => {
-
-
- if (el.groupby) {
- // let initialLetter = el.name.slice(0, 1)
- letters[el.groupby].push(el)
- } else {
- letters['#'].push(el)
- }
- if(el.order === 1){
- hot.push(el)
- }
- })
- };
- this.AreaList = letters
- this.Areahot = hot
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- @import "~./common.scss";
- .search-box {
- width: 100%;
- height: 100rpx;
- }
- .search-shadow {
- width: 100%;
- height: 100rpx;
- }
- .search-letter {
- display: inline-block;
- width: 100%;
- height: 80rpx;
- background-color: $page-bg;
- padding: 0 $pages-padding;
- line-height: 80rpx;
- font-size: 28rpx;
- color: #c1c1c1;
- }
- .area-list {
- width: 100%;
- padding: 0 $pages-padding;
- .area-item {
- width: 100%;
- height: 100rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- border-bottom: 1rpx solid $border-color;
- font-size: 28rpx;
- padding-right: 30rpx;
- &:last-child {
- border-bottom: none;
- }
- }
- }
- .scroll-box {
- width: 100%;
- position: relative;
- .letter-tag {
- position: absolute;
- right: 0;
- top: 50%;
- padding: 0 10rpx 0 20rpx;
- transform: translateY(-50%);
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- .tag-item {
- padding: 10rpx;
- font-size: 22rpx;
- // width: 20rpx;
- }
- .area-key {
- background-color: #c1c1c1;
- border-radius: 50%;
- }
- }
- }
- .scroll-Y {
- width: 100%;
- height: 100%;
- }
- </style>
|