punch-out.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <template>
  2. <view class="">
  3. <!-- 休息日 -->
  4. <u-empty v-if="status==0" margin-top="300" icon-size="300" text="今天不上班,要好好休息哟~" src="/punch/static/icon/rest.png" ></u-empty>
  5. <!-- 工作日-未打卡 -->
  6. <view class="card" v-else-if="status==1">
  7. <view class="location" @click="chooseLocation">
  8. <map :enable-scroll="false" class="map" :enable-zoom="false"></map>
  9. <view class="label" style="position: relative;">
  10. <u-icon name="map-fill" size="80" color="#5064eb"></u-icon>
  11. <view class="text-bold text-cut-1 margin-top-10">{{vuex_location.address}}</view>
  12. <view v-if="$isEmpty(remark) && $isEmpty(imgList)" @click.stop="remarkShow=true" class="add-remark">添加备注...</view>
  13. <view @click.stop="remarkShow=true" class="remark-content" v-else>
  14. <view class="content text-cut-1">
  15. <text class="text-cut-1">{{remark}}</text>
  16. </view>
  17. <image :src="imgList[0]" mode=""></image>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="" style="position: fixed;bottom: 20%;left: 50%;margin-left: -130rpx;">
  22. <view @click="punch" class="btn-open">
  23. <text>{{time}}</text>
  24. <text>第一次人脸打卡</text>
  25. </view>
  26. </view>
  27. <u-popup mode="center" borderRadius="10" v-model="remarkShow" height="52%" width="80%">
  28. <view style="padding: 15rpx 15rpx 30rpx;height: 100%;" class="flex flex-direction justify-between">
  29. <view class="" style="border: 1rpx solid #d0d0d0;">
  30. <view class="padding-30">
  31. <u-input :clearable="false" height="200" v-model="remark" placeholder="请添加备注" type="textarea" borderColor="#dedede"/>
  32. </view>
  33. <view class="cu-form-group">
  34. <view class="grid col-4 grid-square flex-sub">
  35. <view class="bg-img" v-for="(item,index) in imgList" :key="index" @click="viewImage" :data-url="imgList[index]">
  36. <image :src="imgList[index]" mode="aspectFill"></image>
  37. <view class="cu-tag bg-red" @tap.stop="delImg" :data-index="index">
  38. <text class='cuIcon-close' ></text>
  39. </view>
  40. </view>
  41. <view style="background-color: #f2f2f2;" @tap="chooseImage" v-if="imgList.length<4 || $isEmpty(imgList)">
  42. <view class="flex justify-center align-center" style="padding-top: 30rpx;">
  43. <u-icon name="camera-fill" size="55" color="#d9d9d9"></u-icon>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view @click="remarkShow=false" class="cu-btn round base-bg-color" style="width: 100%;height: 85rpx;">
  50. 确认
  51. </view>
  52. </view>
  53. </u-popup>
  54. </view>
  55. <!-- 工作日-去打卡 -->
  56. <view class="form" v-else-if="status==2">
  57. <view class="face">
  58. <image src="http://n.sinaimg.cn/front/724/w1078h1246/20190406/YVxr-hvhrcxm4045228.jpg" mode="scaleToFill"></image>
  59. <view >
  60. <text>人脸照片</text>
  61. </view>
  62. </view>
  63. <view class="desc">
  64. <view class="item">
  65. <text>时间</text>
  66. <text>16:03</text>
  67. </view>
  68. <view class="item">
  69. <text>位置</text>
  70. <text>保利世界贸易中心</text>
  71. </view>
  72. <view class="item">
  73. <text>备注</text>
  74. <view class="">
  75. <text>我是备注</text>
  76. </view>
  77. </view>
  78. </view>
  79. <view class="submit">
  80. <view class="cu-btn base-bg-color round" style="width: 100%;padding: 40rpx;">
  81. 确认打卡
  82. </view>
  83. </view>
  84. </view>
  85. <view class="result" v-else-if="status==3">
  86. <image src="../../static/icon/success.png" mode=""></image>
  87. <text class="tips">外出打卡成功</text>
  88. <view class="desc">
  89. <view class="item">
  90. <text>时间</text>
  91. <text>16:03</text>
  92. </view>
  93. <view class="item">
  94. <text>位置</text>
  95. <text>保利世界贸易中心</text>
  96. </view>
  97. <view class="item">
  98. <text>备注</text>
  99. <text>我是备注</text>
  100. </view>
  101. </view>
  102. </view>
  103. </view>
  104. </template>
  105. <script>
  106. export default {
  107. data() {
  108. return {
  109. remark:'',
  110. imgList:[],
  111. face:'',
  112. remarkShow:false,
  113. time:'',
  114. latitude: 39.909,
  115. longitude: 116.39742,
  116. }
  117. },
  118. props:{
  119. faceImg:String
  120. },
  121. created() {
  122. this.getNowTime()
  123. },
  124. computed:{
  125. status:{
  126. get(){
  127. //0休息日,1工作日-未打卡 2工作日-去打卡 3工作日-打卡成功
  128. return 3
  129. }
  130. }
  131. },
  132. methods:{
  133. getNowTime(){
  134. let that=this
  135. setInterval(()=>{
  136. that.time=that.$dateTime.format(new Date(),'MM:SS')
  137. },1000)
  138. },
  139. chooseLocation(){
  140. let that=this
  141. uni.chooseLocation({
  142. success: function (res) {
  143. console.log('位置名称:' + res.name);
  144. console.log('详细地址:' + res.address);
  145. console.log('纬度:' + res.latitude);
  146. console.log('经度:' + res.longitude);
  147. let distance= that.$util.calculateDistance(res.latitude,res.longitude,
  148. that.vuex_location.latitude,that.vuex_location.longitude)
  149. console.log(distance);
  150. if (distance>500) {
  151. that.$dialog.showModal('只可选500米范围内的地点',false)
  152. }
  153. }
  154. });
  155. },
  156. //添加备注
  157. chooseImage(){
  158. this.$mpi.chooseImage().then(res=>{
  159. this.imgList.push(res[0])
  160. })
  161. },
  162. viewImage(e) {
  163. uni.previewImage({
  164. urls: this.remark.imgList,
  165. current: e.currentTarget.dataset.url
  166. });
  167. },
  168. delImg(e) {
  169. this.$dialog.showModal('确定删除?').then(res=>{
  170. this.remark.imgList.splice(e.currentTarget.dataset.index, 1)
  171. })
  172. },
  173. //打卡
  174. punch(){
  175. uni.navigateTo({
  176. url:"/pages/my-camera/my-camera"
  177. })
  178. }
  179. }
  180. }
  181. </script>
  182. <style lang="scss">
  183. page{
  184. background-color: #FFFFFF;
  185. }
  186. .card{
  187. display: flex;
  188. flex-direction: column;
  189. align-items: center;
  190. height: 100%;
  191. width: 100%;
  192. .location{
  193. font-size: 38rpx;
  194. color: #0d6d3a;
  195. text-align: center;
  196. .map{
  197. width: 100vw;
  198. height: 500rpx;
  199. opacity: 0.2;
  200. }
  201. .label{
  202. margin-top: -300rpx;
  203. image{
  204. width: 80rpx;
  205. height: 80rpx;
  206. }
  207. .add-remark{
  208. font-weight: 800;
  209. padding-top: 60rpx;
  210. color: #4a70c8;
  211. font-size: 28rpx;
  212. }
  213. .remark-content{
  214. display: flex;
  215. justify-content: space-between;
  216. background-color: #FFFFFF;
  217. color: #666666;
  218. width: 90%;
  219. margin: 0 auto;
  220. margin-top: 60rpx;
  221. padding: 15rpx;font-size: 30rpx;
  222. border: 1rpx solid #e7e7e7;
  223. border-radius: 4rpx;
  224. .content{
  225. width: 85%;
  226. display: flex;
  227. justify-content: flex-start;
  228. align-items: center;
  229. }
  230. image{
  231. width: 75rpx;
  232. height: 75rpx;
  233. }
  234. }
  235. }
  236. }
  237. .btn-open{
  238. border: 18rpx solid $base-color;
  239. text-align: center;
  240. display: flex;
  241. flex-direction: column;
  242. justify-content: center;
  243. align-items: center;
  244. border-radius: 50%;
  245. height: 260rpx;
  246. width: 260rpx;
  247. text:first-child{
  248. color: #000000;
  249. font-size: 56rpx;
  250. }
  251. text:last-child{
  252. padding-top: 10rpx;
  253. font-size: 26rpx;
  254. }
  255. }
  256. }
  257. .empty{
  258. width: 100%;
  259. padding-top: 300rpx;
  260. background-color: #FFFFFF;
  261. }
  262. .form{
  263. position: relative;
  264. width: 100%;
  265. height: 75vh;
  266. display: flex;
  267. flex-direction: column;
  268. justify-content: center;
  269. align-items: center;
  270. padding-bottom: 80rpx;
  271. .face{
  272. image{
  273. border-radius: 10rpx;
  274. height: 260rpx;
  275. width: 240rpx;
  276. }
  277. view{
  278. padding-top: 10rpx;
  279. text-align: center;
  280. color: $base-color;
  281. }
  282. }
  283. .desc{
  284. border-top: 1rpx solid $dt-border-color-sm;
  285. margin-top: 100rpx;
  286. padding: 10rpx;
  287. width: 70%;
  288. .item{
  289. display: flex;
  290. justify-content: space-between;
  291. padding: 30rpx 0;
  292. text:first-child{
  293. color: #8c8d8d;
  294. }
  295. }
  296. }
  297. .submit{
  298. position: absolute;
  299. bottom: 0;
  300. left: 10%;
  301. right: 10%;
  302. margin: auto;
  303. }
  304. }
  305. .result{
  306. display: flex;
  307. flex-direction: column;
  308. align-items: center;
  309. padding-top: 180rpx;
  310. image{
  311. width: 180rpx;
  312. height: 180rpx;
  313. }
  314. .tips{
  315. padding-top: 50rpx;
  316. font-size: 36rpx;
  317. color: #18b566;
  318. font-weight: 800;
  319. }
  320. .desc{
  321. border-top: 1rpx solid $dt-border-color-sm;
  322. margin-top: 100rpx;
  323. padding: 10rpx;
  324. width: 70%;
  325. .item{
  326. display: flex;
  327. justify-content: space-between;
  328. padding: 30rpx 0;
  329. text:first-child{
  330. color: #8c8d8d;
  331. }
  332. }
  333. }
  334. }
  335. </style>