punchLocation.vue 4.0 KB

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