punchLocation.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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(item.id)"
  18. v-for="item in list" :key="item.id">
  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.title}}
  26. </view>
  27. <view class="center">
  28. 地址:{{item.address}}
  29. </view>
  30. <view class="bottom">
  31. 范围:{{item.scope}}米
  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. // {
  49. // id: 1,
  50. // title: "操场",
  51. // place: "江西省南昌市经开区广兰大道899号",
  52. // scope: "300米"
  53. // },
  54. // {
  55. // id: 2,
  56. // title: "操场",
  57. // place: "江西省南昌市经开区广兰大道899号",
  58. // scope: "400米"
  59. // },
  60. // {
  61. // id: 3,
  62. // title: "操场",
  63. // place: "江西省南昌市经开区广兰大道899号",
  64. // scope: "500米"
  65. // }
  66. ],
  67. options: [{
  68. text: '删除',
  69. style: {
  70. backgroundColor: '#D43030'
  71. }
  72. }],
  73. }
  74. },
  75. onLoad(options) {
  76. if (options.temList) {
  77. this.list = JSON.parse(options.temList)
  78. }
  79. },
  80. methods: {
  81. handleAdd() {
  82. // 获取用户位置权限
  83. uni.authorize({
  84. scope: 'scope.userLocation',
  85. success() {
  86. uni.navigateTo({
  87. url: "/pages/addLocation/addLocation"
  88. })
  89. },
  90. fail() {
  91. uni.showModal({
  92. title: '提示',
  93. content: '请先开启定位权限,否则将无法使用定位功能',
  94. cancelText: '不授权',
  95. confirmText: '授权',
  96. success: function(res) {
  97. if (res.confirm) {
  98. uni.openSetting({
  99. success(res) {}
  100. })
  101. } else if (res.cancel) {}
  102. }
  103. });
  104. }
  105. })
  106. },
  107. // 点击右侧删除按钮回调
  108. onClick(id) {
  109. console.log(id);
  110. uni.showModal({
  111. title: '提示',
  112. content: '确定删除该打卡位置吗?',
  113. success: function(res) {
  114. if (res.confirm) {
  115. console.log('用户点击确定');
  116. uni.showToast({
  117. title: "删除成功",
  118. icon: 'success'
  119. })
  120. } else if (res.cancel) {
  121. console.log('用户点击取消');
  122. }
  123. }
  124. });
  125. },
  126. }
  127. }
  128. </script>
  129. <style lang="scss" scoped>
  130. .container {
  131. padding-top: 20rpx;
  132. .add {
  133. display: flex;
  134. margin: 0 auto;
  135. width: 690rpx;
  136. height: 87rpx;
  137. line-height: 87rpx;
  138. border-radius: 14rpx;
  139. background-color: #fff;
  140. .icon {
  141. flex: 1;
  142. display: flex;
  143. justify-content: center;
  144. align-items: center;
  145. img {
  146. width: 36rpx;
  147. height: 36rpx;
  148. }
  149. }
  150. .title {
  151. flex: 3;
  152. font-size: 30rpx;
  153. color: #0082FC;
  154. }
  155. .none {
  156. flex: 5;
  157. }
  158. }
  159. .list {
  160. margin-top: 20rpx;
  161. padding-bottom: 30rpx;
  162. .box {
  163. display: flex;
  164. align-items: center;
  165. margin: 0 auto;
  166. margin-bottom: 20rpx;
  167. width: 690rpx;
  168. height: 137rpx;
  169. border-radius: 14rpx;
  170. background-color: #fff;
  171. .icon {
  172. margin-top: 10rpx;
  173. width: 75rpx;
  174. text-align: center;
  175. img {
  176. width: 40rpx;
  177. height: 40rpx;
  178. }
  179. }
  180. .place {
  181. width: 540rpx;
  182. .top {
  183. font-size: 32rpx;
  184. overflow: hidden;
  185. white-space: nowrap;
  186. text-overflow: ellipsis;
  187. }
  188. .center {
  189. font-size: 24rpx;
  190. color: #999999;
  191. overflow: hidden;
  192. white-space: nowrap;
  193. text-overflow: ellipsis;
  194. }
  195. .bottom {
  196. font-size: 24rpx;
  197. color: #999999;
  198. overflow: hidden;
  199. white-space: nowrap;
  200. text-overflow: ellipsis;
  201. }
  202. }
  203. .right {
  204. width: 75rpx;
  205. text-align: center;
  206. img {
  207. width: 15rpx;
  208. height: 28rpx;
  209. }
  210. }
  211. }
  212. }
  213. }
  214. // 解决左滑区域突出问题
  215. ::v-deep .uni-swipe_button-group {
  216. margin-bottom: 20rpx;
  217. }
  218. </style>