addLocation.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. rangeList:['300米', '400米', '500米'],
  77. }
  78. },
  79. methods: {
  80. // 点击选择打卡范围回调
  81. changeRange() {
  82. uni.showActionSheet({
  83. itemList: this.rangeList,
  84. success: (res) => {
  85. console.log(res);
  86. console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
  87. console.log(this.rangeList[res.tapIndex]);
  88. },
  89. fail: (res) => {
  90. console.log(res.errMsg);
  91. }
  92. });
  93. },
  94. // 搜索框失焦回调
  95. blur(res) {
  96. uni.showToast({
  97. title: '搜索:' + res.value,
  98. icon: 'none'
  99. })
  100. },
  101. // 搜索框输入时的回调
  102. input(res) {
  103. console.log('----input:', res)
  104. },
  105. // 清除搜索框内容时的回调
  106. clear(res) {
  107. uni.showToast({
  108. title: 'clear事件,清除值为:' + res.value,
  109. icon: 'none'
  110. })
  111. },
  112. }
  113. }
  114. </script>
  115. <style lang="scss" scoped>
  116. .container {
  117. .map {
  118. position: relative;
  119. width: 100vw;
  120. height: 100vh;
  121. }
  122. .search {
  123. position: fixed;
  124. top: 30rpx;
  125. left: 30rpx;
  126. width: 690rpx;
  127. height: 80rpx;
  128. border-radius: 152rpx;
  129. background-color: #fff;
  130. }
  131. .list {
  132. position: fixed;
  133. left: 30rpx;
  134. bottom: 100rpx;
  135. padding: 0 30rpx;
  136. box-sizing: border-box;
  137. width: 690rpx;
  138. height: 435rpx;
  139. border-radius: 18rpx 18rpx 0 0;
  140. background-color: #fff;
  141. overflow-y: auto;
  142. .box {
  143. display: flex;
  144. align-items: center;
  145. width: 630rpx;
  146. height: 104rpx;
  147. border-bottom: 1rpx solid #E6E6E6;
  148. .icon {
  149. margin-top: 10rpx;
  150. flex: 1;
  151. text-align: center;
  152. img {
  153. width: 40rpx;
  154. height: 40rpx;
  155. }
  156. }
  157. .place {
  158. flex: 7;
  159. .top {
  160. font-size: 32rpx;
  161. overflow: hidden;
  162. white-space: nowrap;
  163. text-overflow: ellipsis;
  164. }
  165. .bottom {
  166. font-size: 24rpx;
  167. color: #999999;
  168. overflow: hidden;
  169. white-space: nowrap;
  170. text-overflow: ellipsis;
  171. }
  172. }
  173. }
  174. }
  175. .range {
  176. position: fixed;
  177. left: 0;
  178. bottom: 0;
  179. display: flex;
  180. // flex-direction: column;
  181. align-items: center;
  182. width: 750rpx;
  183. height: 100rpx;
  184. box-shadow: 1px -4px 10px 0px rgba(0, 0, 0, 0.2);
  185. background-color: #fff;
  186. .key {
  187. flex: 4;
  188. margin-left: 30rpx;
  189. font-size: 28rpx;
  190. }
  191. .value {
  192. flex: 1;
  193. font-size: 28rpx;
  194. color: #A6A6A6;
  195. img {
  196. margin-left: 15rpx;
  197. width: 20rpx;
  198. height: 25rpx;
  199. }
  200. }
  201. }
  202. }
  203. // 解决输入框不居中问题
  204. ::v-deep .uni-searchbar {
  205. padding: 10rpx;
  206. }
  207. ::v-deep .uni-searchbar__box {
  208. padding: 0;
  209. height: 60rpx;
  210. }
  211. </style>