123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442 |
- <template>
- <view class="page">
- <scroll-view class="scrollList" scroll-y :scroll-into-view="scrollViewId" :style="{height:winHeight+'px'}">
- <view class="search-bar">
- <view class="search-bar-form">
- <view class="search-bar-box">
- <!-- <icon class="icon-search-in-box" type="search" size="16"></icon> -->
- <input confirm-type="search" class="search-bar-input" placeholder="输入城市名称或首字母查询" placeholder-class="phcolor"/>
- </view>
- <label class="search-bar-label" v-if="!inputShowed" @tap="showInput">
- <!-- <icon class="icon-search" type="search" size="16"></icon> -->
- <view class="search-bar-text">输入家族ID查询</view>
- </label>
- <view style="font-weight: 400;font-size: 30rpx;color: rgb(199, 69, 71);position: absolute;right: 20rpx;top: 10rpx;z-index: 2;" @tap="maps">
- <tui-icon name="position" color="#C74547" :size="18"></tui-icon>
- 地图
- </view>
- </view>
- </view>
- <view v-if="!inputVal">
- <view class="tui-list city-list">
- <block v-for="(list,index) in lists" :key="index" v-if="list.data[0]">
- <view class="tui-list-cell-divider" :id="index === 0 ? 'suoyin' : list.letter">
- {{list.letter}}
- </view>
- <view class="tui-flex">
- <view class="tui-center tui-col-4">家族ID</view>
- <view class="tui-center tui-col-4">所在地</view>
- <view class="tui-center tui-col-4">族长</view>
- <view class="tui-center tui-col-4">操作</view>
- </view>
- <view v-for="(item,index2) in list.data" :key="index2"
- :data-name="item.id" :hover-stay-time='150'>
- <view class="tui-flex" :class="[list.data.length-1==index?'last':'']">
- <view class="tui-center tui-col-4">{{item.surname}}{{item.id}}</view>
- <view class="tui-center tui-col-4">{{item.address}}</view>
- <view class="tui-center tui-col-4">{{item.patriarch}}</view>
- <view class="tui-center tui-col-4"><tui-button margin="20rpx 0 " plain width="100rpx" height="50rpx" :size="24" @tap="details">加入</tui-button></view>
- </view>
- </view>
- </block>
- </view>
- </view>
- </scroll-view>
- <view class="tui-indexed-list-bar" :style="{height:indexBarHeight+'px'}" @touchstart="touchStart" @touchmove.stop="touchMove"
- @touchend.stop="touchEnd" @touchcancel.stop="touchCancel" v-if="!inputVal">
- <text v-for="(items,index) in lists" :key="index" class="tui-indexed-list-text" :style="{height:indexBarItemHeight+'px'}">
- {{index==0?"索引":items.letter}}
- </text>
- </view>
- <view class="tui-indexed-list-alert" v-if="touchmove && lists[touchmoveIndex].letter">
- {{lists[touchmoveIndex].letter}}
- </view>
- </view>
- </template>
- <script>
- import tuiIcon from "@/components/thorui/tui-icon/tui-icon"
- import tuiButton from "@/components/thorui/tui-button/tui-button"
- const cityData = require('@/utils/family.js')
- export default {
- components: {
- tuiIcon,
- tuiButton
- },
- data() {
- return {
- lists: [],
- touchmove: false, // 是否在索引表上滑动
- touchmoveIndex: -1,
- titleHeight: 0, // 索引二字距离窗口顶部的高度
- indexBarHeight: 0, // 索引表高度
- indexBarItemHeight: 0, // 索引表子项的高度
- scrollViewId: '', // scroll-view滚动到的子元素的id
- winHeight: 0,
- inputShowed: false, // 输入框是否显示
- inputVal: '', // 搜索框输入的内容
- searchResult: [], // 搜索城市的结果
- localCity: ''
- }
- },
- onLoad: function(options) {
- const that = this;
- that.localCity = options.currentCity || "深圳";
- setTimeout(() => {
- uni.getSystemInfo({
- success: function(res) {
- let winHeight = res.windowHeight
- let barHeight = winHeight - uni.upx2px(204);
- that.winHeight = winHeight;
- that.indexBarHeight = barHeight;
- that.indexBarItemHeight = barHeight / 25;
- that.titleHeight = uni.upx2px(132);
- that.lists = cityData.list
- }
- })
- }, 50)
- },
- methods: {
- details: function() {
- uni.navigateTo({
- url: './details'
- });
- },
- maps: function() {
- uni.navigateTo({
- url: './maps'
- });
- },
- showInput() {
- this.inputShowed = true
- },
- clearInput() {
- this.inputVal = "";
- this.inputShowed = false;
- this.searchResult = [];
- uni.hideKeyboard() //强行隐藏键盘
- },
- inputTyping(e) {
- this.inputVal = e.detail.value;
- this.searchCity()
- },
- // 搜索城市
- searchCity() {
- let result = []
- cityData.list.forEach((item1, index1) => {
- item1.data.forEach((item2, index2) => {
- if (item2.id.indexOf(this.inputVal.toLocaleUpperCase()) !== -1) {
- result.push(item2.id+item2.surname+item2.address)
- }
- })
- })
- this.searchResult = result
- },
- touchStart(e) {
- this.touchmove = true
- let pageY = e.touches[0].pageY
- let index = Math.floor((pageY - this.titleHeight) / this.indexBarItemHeight)
- let item = this.lists[index === 0 ? 1 : index]
- if (item) {
- this.scrollViewId = item.letter;
- this.touchmoveIndex = index;
- }
- },
- touchMove(e) {
- let pageY = e.touches[0].pageY;
- let index = Math.floor((pageY - this.titleHeight) / this.indexBarItemHeight)
- let item = this.lists[index === 0 ? 1 : index]
- if (item) {
- this.scrollViewId = item.letter;
- this.touchmoveIndex = index
- }
- },
- touchEnd() {
- this.touchmove = false;
- this.touchmoveIndex = -1;
- },
- touchCancel() {
- this.touchmove = false;
- this.touchmoveIndex = -1;
- }
- }
- }
- </script>
- <style>
- @import '../../../static/style/thorui.css';
- page {
- height: 100%;
- overflow: hidden;
- }
- .page {
- height: 100%;
- width: 100%;
- overflow: hidden;
- }
- .scrollList {
- flex: 1;
- }
-
- .tui-flex{
- margin: 20rpx 0;
- }
- .search-bar {
- display: flex;
- align-items: center;
- position: relative;
- padding: 27rpx 30rpx 35rpx;
- background-color: #fff;
- }
- .search-bar-form {
- flex: 1;
- position: relative;
- border-radius: 32rpx;
- background: #f2f5f7;
- }
- .search-bar-box {
- display: flex;
- align-items: center;
- position: relative;
- padding-left: 20rpx;
- padding-right: 20rpx;
- height: 64rpx;
- z-index: 1;
- }
- .search-bar-input {
- line-height: normal;
- width: 100%;
- padding-left: 20rpx;
- font-size: 30rpx;
- color: #333;
- }
- .phcolor {
- font-size: 30rpx;
- }
- .icon-clear {
- height: 38rpx;
- }
- .icon-clear .tui-icon-class {
- display: block
- }
-
- .search-bar-label {
- height: 64rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- position: absolute;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- z-index: 2;
- border-radius: 32rpx;
- color: #ccc;
- background: #f2f5f7;
- }
- .icon-search {
- position: relative;
- height: 26rpx;
- margin-right: 20rpx;
- font-size: inherit;
- }
- .search-bar-text {
- font-size: 30rpx;
- line-height: 32rpx;
- }
- .cancel-btn {
- padding-left: 30rpx;
- }
- .search-result::before {
- display: none;
- }
- .search-result::after {
- display: none;
- }
- .tui-list-cell {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- width: 100%;
- }
- .tui-list-cell-hover {
- background-color: #eee !important;
- }
- .tui-list-cell-navigate {
- width: 100%;
- position: relative;
- padding: 30rpx 0 30rpx 30rpx;
- font-size: 28rpx;
- color: #333;
- }
- .tui-list-cell-navigate::after {
- content: '';
- position: absolute;
- border-bottom: 1rpx solid #eaeef1;
- -webkit-transform: scaleY(0.5);
- transform: scaleY(0.5);
- bottom: 0;
- right: 0;
- left: 30rpx;
- }
- .current-city {
- padding: 0 30rpx 30rpx;
- background: #fff;
- }
- .tui-icon-class {
- margin-right: 10rpx;
- }
- .current-city .title {
- font-size: 24rpx;
- line-height: 24rpx;
- color: #999;
- }
- .city-name {
- display: inline;
- align-items: center;
- margin-top: 17rpx;
- font-size: 30rpx;
- font-weight: bold;
- line-height: 30rpx;
- color: #333;
- }
- .hot-city .title {
- height: 48rpx !important;
- padding-left: 30rpx;
- font-size: 24rpx !important;
- line-height: 48rpx !important;
- color: #999;
- background: #f2f5f7 !important;
- }
- .city-names {
- display: flex;
- flex-wrap: wrap;
- justify-content: space-between;
- align-content: space-between;
- width: 630rpx;
- padding: 12rpx 90rpx 26rpx 30rpx;
- background: #fff;
- }
- .city-name-item {
- display: flex;
- justify-content: center;
- align-items: center;
- width: 140rpx;
- height: 56rpx;
- margin-top: 16rpx;
- /* border: solid 1rpx #ccc; */
- border-radius: 28rpx;
- font-size: 28rpx;
- color: #333;
- position: relative;
- }
- .city-name-item::before {
- content: "";
- position: absolute;
- width: 200%;
- height: 200%;
- -webkit-transform-origin: 0 0;
- transform-origin: 0 0;
- -webkit-transform: scale(0.5, 0.5);
- transform: scale(0.5, 0.5);
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- left: 0;
- top: 0;
- border-radius: 56rpx;
- border: 1px solid #ccc;
- }
- .tap-city {
- color: #fff;
- background: #aa0000;
- /* border: solid 1rpx #5677fc; */
- }
- .tui-list {
- background-color: #fff;
- position: relative;
- width: 100%;
- display: flex;
- flex-direction: column;
- padding-bottom: env(safe-area-inset-bottom);
- }
- .tui-list-cell-divider {
- height: 48rpx;
- padding-left: 30rpx;
- font-size: 24rpx;
- color: #999;
- background: #f2f5f7;
- padding: 0 30rpx;
- display: flex;
- align-items: center;
- }
- .tui-indexed-list-bar {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: flex-start;
- z-index: 9999;
- position: absolute;
- top: 132rpx;
- right: 0;
- padding-right: 10rpx;
- width: 44rpx;
- }
- .tui-indexed-list-text {
- font-size: 22rpx;
- white-space: nowrap;
- }
- .tui-indexed-list-bar.active {
- background-color: rgb(200, 200, 200);
- }
- .tui-indexed-list-alert {
- position: absolute;
- z-index: 20;
- width: 160rpx;
- height: 160rpx;
- left: 50%;
- top: 50%;
- margin-left: -80rpx;
- margin-top: -80rpx;
- border-radius: 80rpx;
- text-align: center;
- line-height: 160rpx;
- font-size: 70rpx;
- color: #fff;
- background-color: rgba(0, 0, 0, 0.5);
- }
- </style>
|