Procházet zdrojové kódy

Merge branch 'master' of https://git.hap-job.com/SamLu/Mina into master

heikabujianai před 5 roky
rodič
revize
4f45bba27b

+ 10 - 10
pages/clock/clock-rule/clock-rule.js

@@ -2,7 +2,7 @@
 import {
   imgServerUrl
 } from '../../../config/config.js'
-const WxParse = require('../../../plugins/wxParse/wxParse.js');
+// const WxParse = require('../../../plugins/wxParse/wxParse.js');
 
 Page({
 
@@ -31,15 +31,15 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
-    WxParse.wxParse('rule', 'html', `
-    这里是周结打卡细则:
-    1,这里是规则明细;
-    1,这里是规则明细;
-    1,这里是规则明细;
-    1,这里是规则明细;
-    1,这里是规则明细;
-    1,这里是规则明细;
-    1,这里是规则明细;`, this, 5);
+    // WxParse.wxParse('rule', 'html', `
+    // 这里是周结打卡细则:
+    // 1,这里是规则明细;
+    // 1,这里是规则明细;
+    // 1,这里是规则明细;
+    // 1,这里是规则明细;
+    // 1,这里是规则明细;
+    // 1,这里是规则明细;
+    // 1,这里是规则明细;`, this, 5);
   },
 
   /**

+ 4 - 4
pages/clock/clock-rule/clock-rule.wxml

@@ -1,6 +1,6 @@
 <!--pages/clock/clock-rule/clock-rule.wxml-->
-<import src="../../../plugins/wxParse/wxParse.wxml" />
-<image src='{{imgServerUrl}}/images/clock/clock-rule.png'></image>
-<view class="content">
+<!-- <import src="../../../plugins/wxParse/wxParse.wxml" /> -->
+<image src='{{imgServerUrl}}/images/clock/clock-rule.png' mode="widthFix"></image>
+<!-- <view class="content">
   <template is="wxParse" data="{{wxParseData:rule.nodes}}" />
-</view>
+</view> -->

+ 6 - 5
pages/clock/clock-rule/clock-rule.wxss

@@ -1,17 +1,18 @@
 /* pages/clock/clock-rule/clock-rule.wxss */
 page {
-  background-color: #f5f5f5;
+  /* background-color: #f5f5f5; */
+  font-size: 0;
 }
 
 image {
   width: 100%;
-  height: 440rpx;
-  margin: 22rpx 0;
+  /* height: 440rpx;
+  margin: 22rpx 0; */
 }
 
-.content {
+/* .content {
   width: 100%;
   box-sizing: border-box;
   background-color: #fff;
   padding: 30rpx;
-}
+} */

+ 2 - 2
pages/clock/clock-tongji/index.js

@@ -105,8 +105,8 @@ Page({
     })
   },
   day(e) {
-    let { year, month, day } = e.detail
-    const search_date = [year, month, day].map(val => {
+    let { year, month, date } = e.detail
+    const search_date = [year, month, date].map(val => {
       const number = val.toString()
       return number[1] ? number : '0' + number
     }).join('-')

+ 1 - 0
pages/clock/clock-tongji/list.js

@@ -14,6 +14,7 @@ Page({
    */
   data: {
     avatar: wx.getStorageSync('userInfo').avatarUrl,
+    name: wx.getStorageSync('userInfo').nickName,
     imgServerUrl,
     mouthNext: `${imgServerUrl}/images/clock/clock-arrow-righr-disabled.png`,
     mouthLast: `${imgServerUrl}/images/clock/clock-arrow-left.png`,

+ 1 - 1
pages/clock/clock-tongji/list.wxml

@@ -9,7 +9,7 @@
       <image class="avatar-icon" src="{{imgServerUrl}}/images/clock/clock-approving-icon.png" wx:else></image>
     </view>
     <view class="header-info">
-      <view>铁锤</view>
+      <view>{{name}}</view>
       <view class="approveStatus {{approveStatus === 3 ? '' : 'approveStatus-color'}}">
         {{approveStatus === 3 ? '开心工作认证用户' : '认证信息审核中'}}</view>
     </view>

+ 38 - 10
pages/clock/clock.js

@@ -6,6 +6,7 @@ import {
 import {
   imgServerUrl
 } from '../../config/config.js'
+import { transformFromWGSToGCJ } from '../../utils/util'
 Page({
 
   /**
@@ -13,6 +14,7 @@ Page({
    */
   data: {
     approveStatus: false,
+    showCover: true,
     imgServerUrl,
     navigation: [
       {
@@ -37,17 +39,22 @@ Page({
     todayMoney: 0,
     sumDuration: 0,
     sumMoney: 0,
-    wsPunchClockId: null
+    wsPunchClockId: ''
+  },
+  toRule() {
+    wx.navigateTo({
+      url: './clock-rule/clock-rule',
+    })
   },
   getLocation() {
     return new Promise(reslove => {
       wx.getLocation({
-        type: 'gcj02 ',
         success: data => {
-          reslove(data)
+          const { latitude, longitude } = transformFromWGSToGCJ(data.latitude, data.longitude)
+          reslove(Object.assign(data, { latitude, longitude }))
         },
         fail: res => {
-          console.log(res)
+          reslove(res)
         }
       })
     })
@@ -57,7 +64,19 @@ Page({
       wx.getSetting({
         success: async res => {
           if (res.authSetting['scope.userLocation']) {
-            reslove(await this.getLocation())
+            const data = await this.getLocation()
+            const info = wx.getSystemInfoSync()
+            if (data.errMsg.indexOf('system permission denied') !== -1 || info.locationEnabled === false) {
+              wx.showModal({
+                content: '无法使用打卡功能',
+                title: '微信未开启系统定位功能',
+                showCancel: false,
+              })
+              reject()
+            } else {
+              console.log(data)
+              reslove(data)
+            }
           } else {
             wx.authorize({
               scope: 'scope.userLocation',
@@ -119,7 +138,7 @@ Page({
     }
   },
   clock(longitude, latitude) {
-    savePunchClock({ longitude, latitude, clockType: this.data.clockType }).then(data => {
+    savePunchClock({ longitude, latitude, clockType: this.data.clockType, wsPunchClockId: this.data.wsPunchClockId }).then(data => {
       wx.showToast({
         title: '打卡成功',
         success: () => {
@@ -149,15 +168,24 @@ Page({
       })
     }
     if (index === 2) {
-      wx.makePhoneCall({
-        phoneNumber: '4006920099',
-      })
+      this.changeCoverStatus()
     }
   },
+  callKefu() {
+    wx.makePhoneCall({
+      phoneNumber: '4006920099',
+    })
+  },
+  changeCoverStatus() {
+    this.setData({
+      showCover: !this.data.showCover
+    })
+  },
   async load() {
     const data = await this.location()
+    console.log(data)
     punchClockNeedInfo({ longitude: data.longitude, latitude: data.latitude }).then(data => {
-    // punchClockNeedInfo({ longitude: 120.353312, latitude: 31.535582 }).then(data => {
+      // punchClockNeedInfo({ longitude: 120.353312, latitude: 31.535582 }).then(data => {
       let {
         authenticationStatus,
         startPunch,

+ 21 - 10
pages/clock/clock.wxml

@@ -1,7 +1,7 @@
 <!--pages/clock/clock.wxml-->
 <wxs src="./clock.wxs" module="clock"></wxs>
 <view class="container">
-  <view class="no-authentication" wx:if="{{approveStatus === 0}}">
+  <view class="no-authentication" wx:if="{{approveStatus === 2}}">
     <view class="header">
       <image src="{{imgServerUrl}}/images/clock/clock-bg.png" class="no-authentication-bg" mode="widthFixed"></image>
     </view>
@@ -20,9 +20,9 @@
         前往认证
       </navigator>
     </view>
-    <image src="{{imgServerUrl}}/images/clock/clock-video.png" class="video"></image>
+    <image bindtap="toRule" src="{{imgServerUrl}}/images/clock/clock-video.png" class="video"></image>
   </view>
-  <view class="no-pass" wx:elif="{{approveStatus === 2}}">
+  <view class="no-pass" wx:elif="{{approveStatus === 0}}">
     <view class="header">
       <image src="{{imgServerUrl}}/images/clock/clock-bg.png" class="no-pass-bg" mode="widthFixed"></image>
     </view>
@@ -36,7 +36,7 @@
         前往认证
       </navigator>
     </view>
-    <image src="{{imgServerUrl}}/images/clock/clock-video.png" class="video"></image>
+    <image  bindtap="toRule" src="{{imgServerUrl}}/images/clock/clock-video.png" class="video"></image>
   </view>
   <view class="pass" wx:else>
     <view class="pass-header">
@@ -72,16 +72,16 @@
           <text>上班打卡</text>
           <view class="clock-time">
             <image src="{{imgServerUrl}}/images/clock/clock-success-icon.png" wx:if="{{startPunch !== '未完成' }}"></image>
-            <text class="status-text"  wx:if="{{startPunch !== '未完成' }}">{{clock.formateHS(startPunch)}} 已打卡</text>
+            <text class="status-text" wx:if="{{startPunch !== '未完成' }}">{{clock.formateHS(startPunch)}} 已打卡</text>
             <text class="status-text" wx:else>{{startPunch}}</text>
           </view>
         </view>
         <view class="clock-out">
           <text>上班打卡</text>
           <view class="clock-time">
-            <image src="{{imgServerUrl}}/images/clock/clock-success-icon.png"  wx:if="{{endPunch !== '未完成' }}"></image>
-            <text class="status-text"  wx:if="{{endPunch !== '未完成' }}">{{clock.formateHS(endPunch)}} 已打卡</text>
-            <text class="status-text"  wx:else>{{endPunch}}</text>
+            <image src="{{imgServerUrl}}/images/clock/clock-success-icon.png" wx:if="{{endPunch !== '未完成' }}"></image>
+            <text class="status-text" wx:if="{{endPunch !== '未完成' }}">{{clock.formateHS(endPunch)}} 已打卡</text>
+            <text class="status-text" wx:else>{{endPunch}}</text>
           </view>
         </view>
       </view>
@@ -107,11 +107,22 @@
       <view class="prepayable">
         <text>当日可预支工资:</text>
         <view>
-          <text class="prepayable-number">37.0</text>
+          <text class="prepayable-number">{{clock.toFixed(todayMoney)}}</text>
           <text class="prepayable-unit">元</text>
         </view>
       </view>
     </view>
-    <image src="{{imgServerUrl}}/images/clock/clock-video-home.png" class="video"></image>
+    <image bindtap="toRule" src="{{imgServerUrl}}/images/clock/clock-video.png" class="video"></image>
+  </view>
+</view>
+<view class="cover" hidden="{{showCover}}" bindtap="changeCoverStatus">
+  <view class="cover-kefu">
+    <view class="cover-kefu-title">开心工作客服电话</view>
+    <view class="cover-kefu-number">400-692-0099</view>
+    <view class="cover-kefu-tips">在线时间:每天8:00-21:00</view>
+    <view class="cover-kefu-button" bindtap="callKefu">
+      <image src="{{imgServerUrl}}/images/clock/clock-phone-call.png"></image>
+      <text>一键拨号</text>
+    </view>
   </view>
 </view>

+ 71 - 6
pages/clock/clock.wxss

@@ -9,6 +9,7 @@ page {
   width: 710rpx;
   height: 268rpx;
   margin: 20rpx;
+  box-shadow: 0rpx 10rpx 10rpx 0rpx rgba(0, 0, 0, 0.06);
 }
 
 .no-pass,
@@ -245,11 +246,14 @@ page {
 .image {
   height: 260rpx;
   width: 260rpx;
+  display: flex;
+  align-items: center;
+  justify-content: center;
 }
 
 .image image {
-  height: 100%;
-  width: 100%;
+  height: 260rpx;
+  width: 260rpx;
 }
 
 .clock-status {
@@ -311,8 +315,69 @@ page {
   height: 894rpx;
 }
 
-.video {
-  height: 248rpx;
-  width: 690rpx;
-  margin: 0 auto;
+.cover {
+  position: fixed;
+  left: 0;
+  top: 0;
+  height: 100%;
+  width: 100%;
+  background: rgba(0, 0, 0, 0.6);
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+
+.cover-kefu {
+  width: 600rpx;
+  height: 504rpx;
+  background: #FFFFFF;
+  border-radius: 30rpx;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  flex-direction: column;
+}
+
+.cover-kefu-title {
+  font-size: 34rpx;
+  font-family: PingFangSC-Medium, PingFang SC;
+  font-weight: 500;
+  color: #333333;
+}
+
+.cover-kefu-number {
+  font-size: 48rpx;
+  font-family: PingFangSC-Medium, PingFang SC;
+  font-weight: 500;
+  color: #333333;
+  margin-top: 30rpx;
+  margin-bottom: 20rpx;
+}
+
+.cover-kefu-tips {
+  font-size: 28rpx;
+  font-family: PingFangSC-Regular, PingFang SC;
+  font-weight: 400;
+  color: #666666;
+}
+
+.cover-kefu-button {
+  width: 392rpx;
+  height: 88rpx;
+  font-size: 34rpx;
+  font-family: PingFangSC-Medium, PingFang SC;
+  font-weight: 500;
+  color: #FFFFFF;
+  background: #007AFF;
+  border-radius: 44rpx;
+  margin-top: 72rpx;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+
+.cover-kefu-button image {
+  width: 36rpx;
+  height: 35rpx;
+  margin-right: 20rpx;
 }

+ 15 - 15
utils/http.js

@@ -2,12 +2,13 @@ var config = require('../config/config.js')
 import {
   showToast
 } from '../utils/tips.js'
+import { Loading } from './loading'
+const _loading = new Loading();
 const noRelaunch = [
   'pages/interview-registration/index'
 ]
 //model状态
 let model = true;
-let loading = true;
 //服务器地址
 const apiUrl = config.apiUrl;
 /**
@@ -40,17 +41,16 @@ const getData = (data) => {
  * 封装http 请求方法
  */
 const http = (params) => {
+  _loading.showLoading({
+    mask: true,
+    title: '加载中...',
+    success: () => {
+      console.log('loding start')
+    }
+  })
   //返回promise 对象
   return new Promise((resolve, reject) => {
-    if (loading) {
-      loading = false;
-      wx.showLoading({
-        title: 'loading',
-        mask: true
-      });
-    }
     const pages = getCurrentPages();
-
     wx.request({
       url: apiUrl + params.url, //服务器url+参数中携带的接口具体地址
       data: getData(params.data || {}), //请求参数
@@ -61,11 +61,11 @@ const http = (params) => {
       dataType: params.dataType, //返回的数据格式,默认为JSON,特殊格式可以在调用的时候传入参数
       responseType: params.responseType, //响应的数据类型
       success: function (res) {
-        wx.hideLoading({
+        _loading.hideLoading({
           success: () => {
-            loading = true
+            console.log('loding end')
           }
-        });
+        })
         if (res.statusCode == 200) {
           var errorCode = res.data.errcode
           if (errorCode == 0) {
@@ -189,11 +189,11 @@ const http = (params) => {
         }
       },
       fail: function (e) {
-        wx.hideLoading({
+        _loading.hideLoading({
           success: () => {
-            loading = true
+            console.log('loding end')
           }
-        });
+        })
         wx.showToast({
           icon: "none",
           title: "网络异常",

+ 25 - 0
utils/loading.js

@@ -0,0 +1,25 @@
+class Loading {
+	constructor() {
+		this.load_arr = []
+	}
+	showLoading(options) {
+		if (!this.load_arr.length) {
+			options ? wx.showLoading({
+				...options
+			}) : wx.showLoading()
+		}
+		this.load_arr.push(true)
+	}
+	hideLoading(options) {
+		this.load_arr.pop();
+		if (!this.load_arr.length) {
+			options ? wx.hideLoading({
+				...options
+			}) : wx.hideLoading()
+		}
+	}
+}
+
+module.exports = {
+	Loading: Loading
+}

+ 60 - 1
utils/util.js

@@ -73,6 +73,64 @@ function testPhone(data) {
   const phone_zz = /^1[3-9]\d{9}$/;
   return phone_zz.test(data)
 }
+/**
+ *  判断经纬度是否超出中国境内
+ */
+function isLocationOutOfChina(latitude, longitude) {
+  if (longitude < 72.004 || longitude > 137.8347 || latitude < 0.8293 || latitude > 55.8271)
+    return true;
+  return false;
+}
+
+function transformLatWithXY(x, y) {
+  var pi = 3.14159265358979324;
+  var lat = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));
+  lat += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
+  lat += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0;
+  lat += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0;
+  return lat;
+}
+
+function transformLonWithXY(x, y) {
+  var pi = 3.14159265358979324;
+  var lon = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x));
+  lon += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
+  lon += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0;
+  lon += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0 * pi)) * 2.0 / 3.0;
+  return lon;
+}
+
+function isContains(point, p1, p2) {
+  return (point.latitude >= Math.min(p1.latitude, p2.latitude) && point.latitude <= Math.max(p1.latitude, p2.latitude)) && (point.longitude >= Math.min(p1.longitude, p2.longitude) && point.longitude <= Math.max(p1.longitude, p2.longitude));
+}
+
+/** 
+ * 将WGS-84(国际标准)转为GCJ-02(火星坐标): 
+ */ 
+function transformFromWGSToGCJ(latitude, longitude) { 
+  var lat = ""; 
+  var lon = ""; 
+  var ee = 0.00669342162296594323; 
+  var a = 6378245.0; 
+  var pi = 3.14159265358979324; 
+    if (isLocationOutOfChina(latitude, longitude)) { 
+  lat = latitude; 
+  lon = longitude; 
+  } 
+  else { 
+  var adjustLat = transformLatWithXY(longitude - 105.0, latitude - 35.0); 
+  var adjustLon = transformLonWithXY(longitude - 105.0, latitude - 35.0); 
+  var radLat = latitude / 180.0 * pi; 
+  var magic = Math.sin(radLat); 
+  magic = 1 - ee * magic * magic; 
+  var sqrtMagic = Math.sqrt(magic); 
+  adjustLat = (adjustLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi); 
+  adjustLon = (adjustLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi); 
+  latitude = latitude + adjustLat; 
+  longitude = longitude + adjustLon; 
+  } 
+  return { latitude: latitude, longitude: longitude }; 
+    }
 module.exports = {
   formatTime: formatTime,
   formatNumber,
@@ -80,5 +138,6 @@ module.exports = {
   argusToTimestamp,
   formateYM,
   formatetime,
-  testPhone
+  testPhone,
+  transformFromWGSToGCJ
 }