123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <template>
- <view class="phone-area">
- <view class="content">
- <view class="list-item" v-for="(item, index) in list" v-if="item.list.length" :key="index"
- :id="'item' + item.name">
- <!-- <view class="name">{{ item.name }}</view> -->
- <view class="item" v-for="(codeItem, codeIndex) in item.list" :key="codeIndex"
- @tap="chooseCode(codeItem.name, codeItem.code,codeItem.reg,codeItem.phoneReg)">
- <text>{{ codeItem.name }}</text>
- <text class="code">{{ codeItem.code }}</text>
- </view>
- </view>
- <!-- <view class="chooseIndex" @touchstart="tMove" @touchmove.stop="tMove" @touchend="tEnd">
- <view class="chooseIndex-item" v-for="(item, index) in list" :key="index" :id="'indexes-' + item.name">
- {{ item.name }}
- </view>
- </view> -->
- <view v-if="isShowChar" class="showChar">{{ showChar }}</view>
- </view>
- </view>
- </template>
- <script>
- import areaList from '@/common/util/phone-area.js'
- export default {
- data() {
- return {
- title: '选择国家/地区',
- scrollviewHeight: 0,
- list: areaList,
- itemName: '',
- chooseBar: {},
- isShowChar: false,
- showChar: ''
- }
- },
- methods: {
- tMove(e) { // chooseBar touch 事件开始
- this.isShowChar = true
- if (e.touches[0].clientY >= this.chooseBar.top && e.touches[0].clientY <= this.chooseBar.bottom) {
- this.itemName = this.showChar = this.list[Math.floor(((e.touches[0].clientY - this.chooseBar.top) /
- this.chooseBar.height) * 26)].name
- }
- },
- tEnd() { // chooseBar touch 事件结束
- this.isShowChar = false;
- },
- chooseCode(name, code, reg, phoneReg) { // 选择代码
- // uni.$emit('CHOOSEPHONECODE', name, code === 86 ? code + '' : '+' + code)
- uni.$emit('CHOOSEPHONECODE', name, '+' + code, reg, phoneReg)
- uni.navigateBack()
- }
- }
- }
- </script>
- <style lang="scss">
- .phone-area {
- @include page();
- .content {
- background: #FFFFFF;
- .list-item {
- .name {
- @include flex();
- height: 48rpx;
- font-size: 32rpx;
- padding: 0 30rpx;
- position: sticky;
- box-sizing: border-box;
- background: $app-base-bg;
- justify-content: flex-start;
- }
- .item {
- @include flex();
- height: 88rpx;
- box-sizing: border-box;
- padding: 0 100rpx 0 30rpx;
- justify-content: space-between;
- border-bottom: 1rpx solid $app-base-bg;
- .code {
- color: #42b983;
- padding: 10rpx 20rpx;
- border-radius: 8rpx;
- border: 1rpx solid #1AAD19;
- }
- }
- }
- .chooseIndex {
- @include flex(column);
- top: 50%;
- right: 30rpx;
- width: 30rpx;
- height: 780rpx;
- position: fixed;
- background: #FFFFFF;
- border-radius: 8rpx;
- transform: translateY(-50%);
- box-shadow: 0rpx 0rpx 1rpx 1rpx #666666;
- .chooseIndex-item {
- @include flex();
- width: 30rpx;
- height: 30rpx;
- border-radius: 50%;
- }
- }
- .showChar {
- @include flex();
- top: 50%;
- left: 50%;
- z-index: 1;
- width: 123rpx;
- height: 123rpx;
- color: #FFFFFF;
- position: fixed;
- font-size: 88rpx;
- border-radius: 50%;
- background: rgba(0, 0, 0, .3);
- transform: translate(-50%, -50%);
- }
- }
- }
- </style>
|