punchLocation.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <view class="container">
  3. <view class="placeholder"></view>
  4. <!-- 头部添加打卡时间区域 -->
  5. <view class="add">
  6. <view class="icon" @click="handleAdd"><img src="../../static/imgs/add.png" /></view>
  7. <view class="title" @click="handleAdd">添加打卡位置</view>
  8. <view class="none"></view>
  9. </view>
  10. <!-- 打卡时间列表 -->
  11. <view class="list">
  12. <uni-swipe-action>
  13. <!-- 每一个时间段区域 -->
  14. <uni-swipe-action-item :auto-close="true" :right-options="options" @click="onClick(index)" v-for="(item, index) in list" :key="index">
  15. <view class="box">
  16. <view class="icon"><img src="../../static/imgs/location2.png" /></view>
  17. <view class="place">
  18. <view class="top">{{ item.name }}</view>
  19. <view class="center">地址:{{ item.name }}</view>
  20. <view class="bottom">范围:{{ item.radius }}米</view>
  21. </view>
  22. <view class="right"><img src="../../static/imgs/right.png" /></view>
  23. </view>
  24. </uni-swipe-action-item>
  25. </uni-swipe-action>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. // 地点数组
  34. list: [],
  35. // 左滑选项配置
  36. options: [
  37. {
  38. text: '删除',
  39. style: {
  40. backgroundColor: '#D43030'
  41. }
  42. }
  43. ]
  44. }
  45. },
  46. onLoad(options) {
  47. if (options.locations) {
  48. this.list = JSON.parse(options.locations)
  49. uni.setStorageSync('chooseList', this.list)
  50. }
  51. },
  52. onShow() {
  53. uni.removeStorageSync('flag_place')
  54. let arr = uni.getStorageSync('chooseList')
  55. if (arr) {
  56. this.list = arr
  57. }
  58. if (arr.lenght == 0) {
  59. uni.setStorageSync('flag_place', true)
  60. }
  61. },
  62. methods: {
  63. // 点击添加打卡位置回调
  64. handleAdd() {
  65. // 获取用户位置权限
  66. // uni.authorize({
  67. // scope: 'scope.userLocation',
  68. // success: () => {
  69. // uni.navigateTo({
  70. // url: `/pages/addLocation/addLocation`
  71. // })
  72. // },
  73. // fail() {
  74. // uni.showModal({
  75. // title: '提示',
  76. // content: '请先开启定位权限,否则将无法使用定位功能',
  77. // cancelText: '不授权',
  78. // confirmText: '授权',
  79. // success: function(res) {
  80. // if (res.confirm) {
  81. // uni.openSetting({
  82. // success(res) {}
  83. // })
  84. // }
  85. // }
  86. // })
  87. // }
  88. // })
  89. uni.navigateTo({
  90. url: `/pages/addLocation/addLocation`
  91. })
  92. },
  93. // 点击右侧删除按钮回调
  94. onClick(index) {
  95. uni.showModal({
  96. title: '提示',
  97. content: '确定删除该打卡位置吗?',
  98. success: res => {
  99. if (res.confirm) {
  100. uni.showToast({
  101. title: '删除成功',
  102. icon: 'success'
  103. })
  104. this.list.splice(index, 1)
  105. if (this.list.length == 0) {
  106. uni.setStorageSync('flag_place', true)
  107. }
  108. uni.setStorageSync('chooseList', this.list)
  109. }
  110. }
  111. })
  112. }
  113. }
  114. }
  115. </script>
  116. <style lang="scss" scoped>
  117. .container {
  118. min-width: 100vw;
  119. min-height: 100vh;
  120. background-color: #f2f2f2;
  121. .placeholder {
  122. height: 20rpx;
  123. }
  124. .add {
  125. display: flex;
  126. margin: 0 auto;
  127. width: 690rpx;
  128. height: 87rpx;
  129. line-height: 87rpx;
  130. border-radius: 14rpx;
  131. background-color: #fff;
  132. .icon {
  133. flex: 1;
  134. display: flex;
  135. justify-content: center;
  136. align-items: center;
  137. img {
  138. width: 36rpx;
  139. height: 36rpx;
  140. }
  141. }
  142. .title {
  143. flex: 3;
  144. font-size: 30rpx;
  145. color: #0082fc;
  146. }
  147. .none {
  148. flex: 5;
  149. }
  150. }
  151. .list {
  152. margin-top: 20rpx;
  153. padding-bottom: 30rpx;
  154. .box {
  155. display: flex;
  156. align-items: center;
  157. margin: 0 auto;
  158. margin-bottom: 20rpx;
  159. width: 690rpx;
  160. height: 137rpx;
  161. border-radius: 14rpx;
  162. background-color: #fff;
  163. .icon {
  164. margin-top: 10rpx;
  165. width: 75rpx;
  166. text-align: center;
  167. img {
  168. width: 40rpx;
  169. height: 40rpx;
  170. }
  171. }
  172. .place {
  173. width: 540rpx;
  174. .top {
  175. font-size: 32rpx;
  176. overflow: hidden;
  177. white-space: nowrap;
  178. text-overflow: ellipsis;
  179. }
  180. .center {
  181. font-size: 24rpx;
  182. color: #999999;
  183. overflow: hidden;
  184. white-space: nowrap;
  185. text-overflow: ellipsis;
  186. }
  187. .bottom {
  188. font-size: 24rpx;
  189. color: #999999;
  190. overflow: hidden;
  191. white-space: nowrap;
  192. text-overflow: ellipsis;
  193. }
  194. }
  195. .right {
  196. width: 75rpx;
  197. text-align: center;
  198. img {
  199. width: 15rpx;
  200. height: 28rpx;
  201. }
  202. }
  203. }
  204. }
  205. }
  206. // 解决左滑区域突出问题
  207. ::v-deep .uni-swipe_button-group {
  208. margin-bottom: 20rpx;
  209. }
  210. </style>