GlobalRoaming.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view>
  3. <u-navbar :back-text="i18n('Back')" title-width="300" :title="$i18n.locale=='zh'?'选择手机号归属地':'Select MobilePhoneNumber home'"></u-navbar>
  4. <u-index-list :scrollTop="scrollTop" :sticky="true" @select="select1">
  5. <view v-for="(value,key,index) in indexList" :key="index">
  6. <u-index-anchor :index="key" />
  7. <view class="list-cell" v-for="(item,i) in value" @click="navTo(item)">
  8. <text class="list-cell-value" v-if="$i18n.locale=='zh'">{{item.cnValue}}</text>
  9. <text class="list-cell-value" v-else>{{item.enValue}}</text>
  10. <text class="list-cell-id">{{item.id}}</text>
  11. </view>
  12. </view>
  13. </u-index-list>
  14. </view>
  15. </template>
  16. <script>
  17. import country from "@/assets/js/counytryCode.js";
  18. export default {
  19. data() {
  20. return {
  21. scrollTop: 0,
  22. indexList: {
  23. "A": [],
  24. "B": [],
  25. "C": [],
  26. "D": [],
  27. "E": [],
  28. "F": [],
  29. "G": [],
  30. "H": [],
  31. "I": [],
  32. "J": [],
  33. "K": [],
  34. "L": [],
  35. "M": [],
  36. "N": [],
  37. "O": [],
  38. "P": [],
  39. "Q": [],
  40. "R": [],
  41. "S": [],
  42. "T": [],
  43. "U": [],
  44. "V": [],
  45. "W": [],
  46. "X": [],
  47. "Y": [],
  48. "Z": []
  49. },
  50. tel: '',
  51. searchVal: '',
  52. select: "0086",
  53. isInputSearch: false, //是否是输入搜索
  54. getSearchs: "",
  55. countrys: [],
  56. countryEmpty: false, // 是否没有匹配项
  57. currentIndex: '1',
  58. regLogStyle: ''
  59. }
  60. },
  61. watch: {
  62. },
  63. onShow() {
  64. // this.countrys = this.getLetters();
  65. this.getLetters();
  66. },
  67. onLoad(options) {
  68. this.regLogStyle = options.regLogStyle; //regLogStyle为0-注册,regLogStyle为1-登录
  69. console.log(this.regLogStyle)
  70. },
  71. onPageScroll(e) {
  72. this.scrollTop = e.scrollTop;
  73. },
  74. // mounted() {
  75. // this.getLetters();
  76. // },
  77. methods: {
  78. select1(index) {
  79. console.log(index)
  80. },
  81. i18n(data) {
  82. return this.$t('common.' + data);
  83. },
  84. navTo(data) {
  85. console.log(data)
  86. if (this.regLogStyle) {
  87. if (this.regLogStyle == '1') {
  88. this.$mRouter.push({
  89. route: `/pages/public/login?data=` + encodeURIComponent(JSON.stringify(data))
  90. });
  91. } else if (this.regLogStyle == '0') {
  92. this.$mRouter.push({
  93. route: `/pages/public/register?data=` + encodeURIComponent(JSON.stringify(data))
  94. });
  95. } else if (this.regLogStyle == '2') {
  96. this.$mRouter.push({
  97. route: `/pages/profile/profileSetUp/BindMobileNumber?data=` + encodeURIComponent(JSON.stringify(data))
  98. });
  99. } else if (this.regLogStyle == '3') {
  100. this.$mRouter.push({
  101. route: `/pages/profile/profileSetUp/changeNewMobileNumber?data=` + encodeURIComponent(JSON.stringify(data))
  102. });
  103. } else if (this.regLogStyle == '4') {
  104. this.$mRouter.push({
  105. route: `/pages/public/password?data=` + encodeURIComponent(JSON.stringify(data))
  106. });
  107. } else if (this.regLogStyle == '5') {
  108. // this.$mRouter.push({
  109. // route: `/pages/public/password?data=` + encodeURIComponent(JSON.stringify(data))
  110. // });
  111. uni.$emit("moblieAreCode", data);
  112. uni.navigateBack()
  113. }
  114. } else {
  115. // this.$emit("getAreCode", data); //自定义事件 传递值“子向父组件传值”
  116. }
  117. },
  118. // 获取索引字母
  119. getLetters() {
  120. let arr = [];
  121. let letter;
  122. let countryList = [];
  123. if (this.$i18n.locale == "zh") {
  124. country.sort((a, b) => {
  125. return a.pinyin.charCodeAt(0) - b.pinyin.charCodeAt(0);
  126. });
  127. country.forEach((item, i) => {
  128. letter = item.pinyin.slice(0, 1).toUpperCase();
  129. this.indexList[letter].push(item);
  130. });
  131. console.log("0000000", this.indexList)
  132. } else {
  133. country.sort((a, b) => {
  134. return a.enValue.charCodeAt(0) - b.enValue.charCodeAt(0);
  135. });
  136. country.forEach((item, i) => {
  137. letter = item.enValue.slice(0, 1);
  138. this.indexList[letter].push(item);
  139. });
  140. }
  141. return arr.sort();
  142. },
  143. }
  144. }
  145. </script>
  146. <style lang="scss" scoped>
  147. .list-cell {
  148. display: flex;
  149. box-sizing: border-box;
  150. width: 100%;
  151. padding: 10px 24rpx;
  152. overflow: hidden;
  153. color: #252526;
  154. font-size: 14px;
  155. line-height: 60upx;
  156. background-color: #fff;
  157. // position: relative;
  158. .list-cell-value {
  159. // position: absolute;
  160. margin-left: 10upx;
  161. }
  162. justify-content: space-between;
  163. .list-cell-id {
  164. // position: absolute;
  165. margin-right: 100upx;
  166. }
  167. }
  168. </style>