addLocation.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <view class="container">
  3. <!-- 地图区域 -->
  4. <view class="map">
  5. <map style="width: 100%; height: 100%;" :latitude="latitude" :longitude="longitude" :scale="18"
  6. :markers="covers">
  7. </map>
  8. </view>
  9. <!-- 顶部搜索框区域 -->
  10. <view class="search">
  11. <uni-search-bar placeholder="请输入搜索内容" cancelButton="none" v-model="searchValue" @input="input"
  12. @clear="clear" @blur="blur">
  13. </uni-search-bar>
  14. </view>
  15. <!-- 位置列表区域 -->
  16. <view class="list">
  17. <!-- 每一个位置区域 -->
  18. <view class="box" v-for="item in list" :key="item.id">
  19. <view class="icon">
  20. <img src="../../static/location2.png">
  21. </view>
  22. <view class="place">
  23. <view class="top">
  24. {{item.title}}
  25. </view>
  26. <view class="bottom">
  27. 地点:{{item.place}}
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <!-- 打卡范围区域 -->
  33. <view class="range">
  34. <view class="key">
  35. 打卡范围:
  36. </view>
  37. <view class="value" @click="changeRange">
  38. <text>300米</text>
  39. <img src="../../static/right.png">
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. export default {
  46. data() {
  47. return {
  48. latitude: 39.909,
  49. longitude: 116.39742,
  50. covers: [{
  51. id: 1,
  52. latitude: 39.909,
  53. longitude: 116.39742,
  54. iconPath: '../../static/location.png',
  55. width: 20,
  56. height: 20
  57. }],
  58. imgUrl: "",
  59. searchValue: "",
  60. list: [{
  61. id: 1,
  62. title: "南昌交通学院",
  63. place: "江西省南昌市经开区广兰大道899号"
  64. },
  65. {
  66. id: 2,
  67. title: "华东理工学院",
  68. place: "江西省南昌市经开区广兰大道899号"
  69. },
  70. {
  71. id: 3,
  72. title: "江西财经大学",
  73. place: "江西省南昌市经开区广兰大道899号"
  74. }
  75. ]
  76. }
  77. },
  78. methods: {
  79. // 点击选择打卡范围回调
  80. changeRange() {
  81. uni.showActionSheet({
  82. itemList: ['300米', '400米', '500米'],
  83. success: (res) => {
  84. console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
  85. },
  86. fail: (res) => {
  87. console.log(res.errMsg);
  88. }
  89. });
  90. },
  91. // 搜索框失焦回调
  92. blur(res) {
  93. uni.showToast({
  94. title: '搜索:' + res.value,
  95. icon: 'none'
  96. })
  97. },
  98. // 搜索框输入时的回调
  99. input(res) {
  100. console.log('----input:', res)
  101. },
  102. // 清除搜索框内容时的回调
  103. clear(res) {
  104. uni.showToast({
  105. title: 'clear事件,清除值为:' + res.value,
  106. icon: 'none'
  107. })
  108. },
  109. }
  110. }
  111. </script>
  112. <style lang="scss" scoped>
  113. .container {
  114. .map {
  115. position: relative;
  116. width: 100vw;
  117. height: 100vh;
  118. }
  119. .search {
  120. position: fixed;
  121. top: 30rpx;
  122. left: 30rpx;
  123. width: 690rpx;
  124. height: 80rpx;
  125. border-radius: 152rpx;
  126. background-color: #fff;
  127. }
  128. .list {
  129. position: fixed;
  130. left: 30rpx;
  131. bottom: 100rpx;
  132. padding: 0 30rpx;
  133. box-sizing: border-box;
  134. width: 690rpx;
  135. height: 435rpx;
  136. border-radius: 18rpx 18rpx 0 0;
  137. background-color: #fff;
  138. overflow-y: auto;
  139. .box {
  140. display: flex;
  141. align-items: center;
  142. width: 630rpx;
  143. height: 104rpx;
  144. border-bottom: 1rpx solid #E6E6E6;
  145. .icon {
  146. margin-top: 10rpx;
  147. flex: 1;
  148. text-align: center;
  149. img {
  150. width: 40rpx;
  151. height: 40rpx;
  152. }
  153. }
  154. .place {
  155. flex: 7;
  156. .top {
  157. font-size: 32rpx;
  158. overflow: hidden;
  159. white-space: nowrap;
  160. text-overflow: ellipsis;
  161. }
  162. .bottom {
  163. font-size: 24rpx;
  164. color: #999999;
  165. overflow: hidden;
  166. white-space: nowrap;
  167. text-overflow: ellipsis;
  168. }
  169. }
  170. }
  171. }
  172. .range {
  173. position: fixed;
  174. left: 0;
  175. bottom: 0;
  176. display: flex;
  177. // flex-direction: column;
  178. align-items: center;
  179. width: 750rpx;
  180. height: 100rpx;
  181. box-shadow: 1px -4px 10px 0px rgba(0, 0, 0, 0.2);
  182. background-color: #fff;
  183. .key {
  184. flex: 4;
  185. margin-left: 30rpx;
  186. font-size: 28rpx;
  187. }
  188. .value {
  189. flex: 1;
  190. font-size: 28rpx;
  191. color: #A6A6A6;
  192. img {
  193. margin-left: 15rpx;
  194. width: 20rpx;
  195. height: 25rpx;
  196. }
  197. }
  198. }
  199. }
  200. // 解决输入框不居中问题
  201. ::v-deep .uni-searchbar {
  202. padding: 10rpx;
  203. }
  204. ::v-deep .uni-searchbar__box {
  205. padding: 0;
  206. height: 60rpx;
  207. }
  208. </style>