allAreatwo.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <view class="allArea">
  3. <view class="area1">
  4. <text class="arear-text" @click="Area">{{list[curVal].text}}</text>
  5. <image src="../../static/down.png" mode=""></image>
  6. </view>
  7. <!-- <view :animation="animationData" class="arear-list" v-show="isShow">
  8. <view class="arear-child-list" v-for="(items,index1) in list" :key='index1' @click="pop(index1)">
  9. {{items.text}}
  10. </view>
  11. </view> -->
  12. </view>
  13. </template>
  14. <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
  15. </script>
  16. <script>
  17. export default {
  18. data() {
  19. return {
  20. screenHeight: "",
  21. isShow: false,
  22. animationData: {},
  23. count: "", //点击事件次数
  24. curVal: '', //骑行区与第一个下标
  25. curId: "", //骑行区域id
  26. list: [{"areaID":1,"text":'郑州龙子湖'}],
  27. }
  28. },
  29. props: [
  30. 'mess',
  31. 'curVal1'
  32. ],
  33. // props:['curVal1','mess'],
  34. watch: {
  35. mess(newValue, oldValue) {
  36. this.list = newValue
  37. console.log(newValuel, "这是父组件传过来的值")
  38. },
  39. curVal1(newValue, oldValue) {
  40. this.curVal = newValue
  41. }
  42. },
  43. onShow() {
  44. console.log('这是子组件')
  45. },
  46. beforeCreate() {
  47. console.log('子组件beforeCreate')
  48. this.list = uni.getStorageSync('allArea');
  49. this.curVal = uni.getStorageSync('curVal') ? uni.getStorageSync('curVal') : 0;
  50. console.log(this.list)
  51. },
  52. methods: {
  53. //弹框事件
  54. Area: function(e) {
  55. var list1 = uni.getStorageSync('allArea')
  56. var arr = []
  57. for (let i = 0, len = list1.length; i < len; i++) {
  58. arr = arr.concat(list1[i].text)
  59. console.log(arr)
  60. }
  61. console.log( uni.getStorageSync('allArea'),"99999")
  62. var area= uni.getStorageSync('allArea')
  63. uni.showActionSheet({
  64. itemList: arr,
  65. success: function(res) {
  66. var list=uni.getStorageSync('allArea')
  67. let index=res.tapIndex
  68. this.curVal = index
  69. this.curId=list[index].areaID
  70. uni.setStorageSync('curVal', index)
  71. uni.setStorageSync('curId', list[index].areaID)
  72. console.log(this.curId,"index");
  73. this.$emit('getChild',this.list[index])
  74. // console.log(list[index].areaID,"66666");
  75. // this.curVal = e
  76. // this.curId = this.list[e].areaID
  77. // uni.setStorageSync('curVal', e)
  78. // uni.setStorageSync('curId', this.list[e].areaID)
  79. // this.$emit('getChild',this.list[e])
  80. // console.log(e, "骑行区")
  81. // console.log(this.curVal, "这是骑行区if")
  82. },
  83. fail: function(res) {}
  84. })
  85. // this.curVal = uni.getStorageSync('curVal') ? uni.getStorageSync('curVal') : 0
  86. // console.log(uni.getStorageSync('curVal') ? uni.getStorageSync('curVal') : 0, '这是下标')
  87. // this.isShow = !this.isShow
  88. // console.log(this.isShow, "这是骑行区与123456")
  89. // console.log(this.list)
  90. // var that = this
  91. // // this.$emit('getChild', this.isShow)
  92. // setTimeout(function() {
  93. // var query = uni.createSelectorQuery();
  94. // query.select('.arear-list').boundingClientRect();
  95. // query.exec(function(res) {
  96. // console.log(res[0].height, "55555555")
  97. // let height = res[0].height
  98. // that.$emit('getChild', height)
  99. // // this.$emit('getChild', this.isShow)
  100. // })
  101. // }, 500)
  102. // let height = uni.createSelectorQuery().select('arear-list')
  103. // height.fields({
  104. // size: true
  105. // }, data => {
  106. // console.log(data.height,"55555555")
  107. // })
  108. // console.log(height, "zheshizujianggaodu ")
  109. },
  110. // pop: function(e) {
  111. // this.isShow = !this.isShow
  112. // this.curVal = e
  113. // this.curId = this.list[e].areaID
  114. // uni.setStorageSync('curVal', e)
  115. // uni.setStorageSync('curId', this.list[e].areaID)
  116. // this.$emit('getChild',this.list[e])
  117. // console.log(e, "骑行区")
  118. // console.log(this.curVal, "这是骑行区if")
  119. // },
  120. //返回上一页
  121. back: function() {
  122. uni.navigateBack({
  123. delta: 1
  124. })
  125. },
  126. }
  127. }
  128. </script>
  129. <style>
  130. .allArea {
  131. display: inline-block;
  132. position: fixed;
  133. padding-top: var(--status-bar-height);
  134. padding-bottom: 28upx;
  135. padding-left: 35upx;
  136. height: 45upx;
  137. margin-bottom: 20rpx;
  138. z-index: 1000;
  139. width: 100%;
  140. background: white;
  141. }
  142. .allArea image{
  143. display: inline-block;
  144. vertical-align: middle;
  145. margin-left: 20upx;
  146. height: 40upx;
  147. width: 40upx;
  148. }
  149. .iconfont {
  150. display: inline-block;
  151. height: 100%;
  152. font-size: 34rpx;
  153. width: 50rpx;
  154. text-align: center;
  155. padding: 14rpx 0;
  156. }
  157. .status_bar {
  158. height: var(--status-bar-height);
  159. width: 100%;
  160. }
  161. .area1 {
  162. display: inline-block;
  163. vertical-align: middle;
  164. /* background-color: #007AFF; */
  165. }
  166. .iconfont {
  167. display: inline-block;
  168. height: 100%;
  169. font-size: 34rpx;
  170. width: 50rpx;
  171. text-align: center;
  172. padding: 14rpx 0;
  173. }
  174. .backIcon {
  175. display: inline-block;
  176. vertical-align: bottom;
  177. }
  178. .backIcon image {
  179. margin-left: 20rpx;
  180. margin-right: 20rpx;
  181. height: 40rpx;
  182. width: 50rpx;
  183. }
  184. .area1 {
  185. position: absolute;
  186. font-size: 32rpx;
  187. width: 100%;
  188. }
  189. .arear-list {
  190. position: absolute;
  191. z-index: 1000;
  192. left: 0;
  193. top: 130rpx;
  194. width: 90%;
  195. /* height: 600upx; */
  196. background-color: #FFFFFF;
  197. margin-left: 20rpx;
  198. padding: 0 20rpx;
  199. }
  200. .arear-child-list {
  201. padding: 20rpx 0;
  202. font-size: 30rpx;
  203. /* height: 200upx; */
  204. border-bottom: solid 1rpx #e6e6e6;
  205. }
  206. </style>