allArea.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <view class="allArea">
  3. <view class="backIcon" @click="back">
  4. <image src="http://resource.weilaibike.com/yunwei/leftArrow.png"></image>
  5. </view>
  6. <view class="area">
  7. <text class="arear-text" @click="Area">{{list[curVal].text}}</text>
  8. </view>
  9. <view :animation="animationData" class="arear-list" v-show="isShow">
  10. <view class="arear-child-list" v-for="(items,index1) in list" :key='index1' @click="pop(index1)">
  11. {{items.text}}
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
  17. </script>
  18. <script>
  19. export default {
  20. data() {
  21. return {
  22. screenHeight: "",
  23. isShow: false,
  24. list: uni.getStorageSync('allArea'),
  25. animationData: {},
  26. count: "", //点击事件次数
  27. curVal: uni.getStorageSync('curVal') ? uni.getStorageSync('curVal') : 0, //骑行区与第一个下标
  28. curId: "", //骑行区域id
  29. }
  30. },
  31. onShow(){
  32. console.log('这是子组件')
  33. },
  34. methods: {
  35. Area: function(e) {
  36. // // this.curVal = uni.getStorageSync('curVal') ? uni.getStorageSync('curVal') : 0
  37. // console.log(uni.getStorageSync('curVal') ? uni.getStorageSync('curVal') : 0, '这是下标')
  38. // this.isShow = !this.isShow
  39. // console.log(this.isShow, "这是骑行区与")
  40. // console.log(this.list)
  41. var list1 = uni.getStorageSync('allArea')
  42. var arr = []
  43. for (let i = 0, len = list1.length; i < len; i++) {
  44. arr = arr.concat(list1[i].text)
  45. console.log(arr)
  46. }
  47. console.log( uni.getStorageSync('allArea'),"99999")
  48. var area= uni.getStorageSync('allArea')
  49. uni.showActionSheet({
  50. itemList: arr,
  51. success: function(res) {
  52. var list=uni.getStorageSync('allArea')
  53. let index=res.tapIndex
  54. this.curVal = index
  55. this.curId=list[index].areaID
  56. uni.setStorageSync('curVal', index)
  57. uni.setStorageSync('curId', list[index].areaID)
  58. console.log(this.curId,"index");
  59. this.$emit('getChild',this.list[index])
  60. // console.log(list[index].areaID,"66666");
  61. // this.curVal = e
  62. // this.curId = this.list[e].areaID
  63. // uni.setStorageSync('curVal', e)
  64. // uni.setStorageSync('curId', this.list[e].areaID)
  65. // this.$emit('getChild',this.list[e])
  66. // console.log(e, "骑行区")
  67. // console.log(this.curVal, "这是骑行区if")
  68. },
  69. fail: function(res) {}
  70. })
  71. },
  72. pop: function(e) {
  73. this.isShow = !this.isShow
  74. this.curVal = e
  75. this.curId = this.list[e].areaID
  76. uni.setStorageSync('curVal', e)
  77. uni.setStorageSync('curId', this.list[e].areaID)
  78. this.$emit('getChild', this.list[e])
  79. console.log(e, "骑行区")
  80. console.log(this.curVal, "这是骑行区if")
  81. },
  82. // show: function() {
  83. // setTimeout(function() {
  84. // this.list = uni.getStorageSync('allArea')
  85. // this.curVal = uni.getStorageSync('curVal') ? uni.getStorageSync('curVal') : 0
  86. // }, 2000)
  87. // },
  88. //返回上一页
  89. back: function() {
  90. uni.navigateBack({
  91. delta: 1
  92. })
  93. },
  94. }
  95. }
  96. </script>
  97. <style>
  98. .allArea {
  99. display: inline-block;
  100. position: fixed;
  101. padding-top: var(--status-bar-height);
  102. background-color: #ffffff;
  103. /* padding: 28rpx 0; */
  104. padding-bottom: 28rpx;
  105. z-index: 1000;
  106. width: 100%;
  107. border-bottom: 2upx solid #C5C5C5;
  108. }
  109. .iconfont {
  110. display: inline-block;
  111. height: 100%;
  112. font-size: 34rpx;
  113. width: 50rpx;
  114. text-align: center;
  115. padding: 14rpx 0;
  116. }
  117. .status_bar {
  118. height: var(--status-bar-height);
  119. width: 100%;
  120. }
  121. .area {
  122. display: inline-block;
  123. vertical-align: middle;
  124. }
  125. .iconfont {
  126. display: inline-block;
  127. height: 100%;
  128. font-size: 34rpx;
  129. width: 50rpx;
  130. text-align: center;
  131. padding: 14rpx 0;
  132. }
  133. .backIcon {
  134. display: inline-block;
  135. vertical-align: bottom;
  136. }
  137. .backIcon image {
  138. margin-left: 20rpx;
  139. margin-right: 20rpx;
  140. height: 40rpx;
  141. width: 50rpx;
  142. }
  143. .area {
  144. position: absolute;
  145. background-color: #FFFFFF;
  146. font-size: 32rpx;
  147. width: 100%;
  148. }
  149. .arear-list {
  150. position: absolute;
  151. z-index: -1;
  152. left: 0;
  153. top: 130rpx;
  154. width: 90%;
  155. background-color: #FFFFFF;
  156. margin-left: 20rpx;
  157. padding: 0 20rpx;
  158. }
  159. .arear-child-list {
  160. padding: 20rpx 0;
  161. font-size: 30rpx;
  162. border-bottom: solid 1rpx #e6e6e6;
  163. }
  164. </style>