| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- // pages/clock/clock.js
- import {
- getCenterInfo
- } from '../../services/index.js'
- import {
- imgServerUrl
- } from '../../config/config.js'
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- approveStatus: false,
- imgServerUrl,
- time: '42.0',
- money: '170.94',
- navigation: [
- {
- image: '/images/clock/clock-tongji.png',
- text: '统计'
- },
- {
- image: '/images/clock/clock-rule-icon.png',
- text: '规则'
- },
- {
- image: '/images/clock/clock-kefu.png',
- text: '客服'
- },
- ],
- status: 0,
- statusImage: `${imgServerUrl}/images/clock/clock-beyond.png`,
- statusIcon: `${imgServerUrl}/images/clock/clock-waring.png`,
- statusMessage: `请进入企业后再进行打卡`,
- },
- getLocation() {
- wx.getLocation({
- success: data => {
- console.log(data)
- this.setData({
- statusImage: `${imgServerUrl}/images/clock/clock-in.png`,
- statusIcon: `${imgServerUrl}/images/clock/clock-can.png`,
- status: 1
- })
- },
- fail: res => {
- console.log(res)
- }
- })
- },
- location() {
- wx.getSetting({
- success: res => {
- if (res.authSetting['scope.userLocation']) {
- this.getLocation()
- } else {
- wx.authorize({
- scope: 'scope.userLocation',
- success: () => {
- this.getLocation()
- },
- fail: () => {
- wx.showModal({
- content: '无法使用打卡功能',
- confirmText: '去授权',
- title: '位置信息未授权',
- success: (result) => {
- if (result.confirm) {
- wx.openSetting({})
- } else {
- this.setData({
- status: 0
- })
- }
- },
- })
- }
- })
- }
- }
- })
- },
- click() {
- switch (this.data.status) {
- case 0:
- wx.showModal({
- title: '提示',
- content: '超出范围,请刷新页面获取当前位置',
- showCancel: false,
- })
- break;
- case 1:
- this.setData({
- statusImage: `${imgServerUrl}/images/clock/clock-out-disabled.png`,
- statusIcon: `${imgServerUrl}/images/clock/clock-waring.png`,
- statusMessage: `上班X小时候才能进行下班打卡`,
- status: 2
- })
- setTimeout(() => {
- this.setData({
- statusImage: `${imgServerUrl}/images/clock/clock-out.png`,
- statusIcon: `${imgServerUrl}/images/clock/clock-can.png`,
- statusMessage: `已进入考勤打卡范围`,
- status: 3
- })
- }, 2000)
- wx.navigateTo({
- url: './clock-success/clock-success?status=3'
- })
- break;
- case 2:
- wx.showModal({
- title: '提示',
- content: '未到下班时间,请刷新页面获取最新状态',
- showCancel: false,
- })
- break;
- case 3:
- this.setData({
- statusImage: `${imgServerUrl}/images/clock/clock-done.png`,
- statusMessage: `今日打卡已完成`,
- status: 4
- })
- wx.navigateTo({
- url: './clock-success/clock-success?status=4'
- })
- break;
- default:
- break;
- }
- },
- navigator(e) {
- const { index } = e.currentTarget.dataset
- if (index === 0) {
- wx.navigateTo({
- url: './clock-tongji/index',
- })
- }
- if (index === 1) {
- wx.navigateTo({
- url: './clock-rule/clock-rule',
- })
- }
- if (index === 2) {
- wx.makePhoneCall({
- phoneNumber: '4006920099',
- })
- }
- },
- load() {
- getCenterInfo().then(data => {
- let {
- approveStatus
- } = data.data
- this.setData({
- approveStatus, // 认证状态(0:未认证 1:等待认证 2:未通过 3:已认证) ,
- })
- })
- this.location()
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.load()
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- this.load()
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|