王浩宇 2 years ago
parent
commit
2dad5c87fb
  1. 3
      common/url.js
  2. 2
      pages.json
  3. 2
      pages/customer/customer.vue
  4. 148
      pages/general/general.vue

3
common/url.js

@ -1,5 +1,6 @@
let data = { let data = {
url:'http://192.168.31.15:9090', // url:'http://192.168.31.15:9090',
url:'https://iot-applet.xfzn365.com',
applet:"https://wx.xfzn365.com/applet-api/static/xjiot", applet:"https://wx.xfzn365.com/applet-api/static/xjiot",
} }
module.exports = { module.exports = {

2
pages.json

@ -6,7 +6,7 @@
{ {
"path": "pages/login/index", "path": "pages/login/index",
"style": { "style": {
"navigationBarTitleText": "uni-app" "navigationBarTitleText": ""
} }
}, { }, {
"path": "pages/customer/customer", "path": "pages/customer/customer",

2
pages/customer/customer.vue

@ -40,8 +40,8 @@
} }
}, },
onLoad() { onLoad() {
this.loadData()
this.pageInfo.unitId = uni.getStorageSync("dept_id") this.pageInfo.unitId = uni.getStorageSync("dept_id")
this.loadData()
}, },
methods: { methods: {
loadData(){ loadData(){

148
pages/general/general.vue

@ -3,12 +3,17 @@
<view style="background-color: #F3F3F3;min-height: 100vh;"> <view style="background-color: #F3F3F3;min-height: 100vh;">
<u-sticky> <u-sticky>
<view style="background-color: #3A71FF;height: 90px;"> <view style="background-color: #3A71FF;height: 90px;">
<image :src="applet+'/close.png'" style="width: 35px;height: 35px;margin-top: 40px;margin-left: 10px;" @tap="close"></image> <image :src="applet+'/close.png'" style="width: 35px;height: 35px;margin-top: 40px;margin-left: 10px;"
<view style="text-align: center;color: #fff;position: absolute;top: 49px;left: 40%;font-size: 17px;" >值班打卡</view> @tap="close"></image>
<view style="text-align: center;color: #fff;position: absolute;top: 49px;left: 40%;font-size: 17px;">
值班打卡</view>
</view> </view>
</u-sticky> </u-sticky>
<view style="margin: 10px auto;border: 1px #b7b7b7 dashed;width: 80%;border-radius: 6px;padding: 10px;background-color: #eaeaea;"> <view
<view style="margin-bottom: 10px;text-align: center;">打卡时间范围</view><view v-for="item in ruleList" style="font-size: 12px;text-align: center;margin-top: 10px;">{{item.startTime}} ~ {{item.endTime}}</view> style="margin: 10px auto;border: 1px #b7b7b7 dashed;width: 80%;border-radius: 6px;padding: 10px;background-color: #eaeaea;">
<view style="margin-bottom: 10px;text-align: center;">打卡时间范围</view>
<view v-for="item in ruleList" style="font-size: 12px;text-align: center;margin-top: 10px;">
{{item.startTime}} ~ {{item.endTime}}</view>
</view> </view>
<view style="margin-top: 30px;" @click="clickSign"> <view style="margin-top: 30px;" @click="clickSign">
<view class="module CBlue"> <view class="module CBlue">
@ -18,7 +23,10 @@
<view style="margin: 10px 0;text-align: center;font-size: 12px;">提示打卡需要您上传中控室的自拍照片</view> <view style="margin: 10px 0;text-align: center;font-size: 12px;">提示打卡需要您上传中控室的自拍照片</view>
</view> </view>
<view style="text-align: center;font-size: 12px;margin-top: 20px;"> <view style="text-align: center;font-size: 12px;margin-top: 20px;">
<view v-for="item in ingDate" style="margin-top: 5px;"><image :src="applet+'/success.png'" style="width: 14px;height: 14px;margin-right: 5px;"></image>{{item.time}}已打卡</view> <view v-for="item in ingDate" style="margin-top: 5px;">
<image :src="applet+'/success.png'" style="width: 14px;height: 14px;margin-right: 5px;"></image>
{{item.time}}已打卡
</view>
</view> </view>
<view style="padding: 10px 10px;"> <view style="padding: 10px 10px;">
<view> <view>
@ -28,8 +36,13 @@
<u-card class="custom-card" v-for="(val,index) in list" @click="previewOpen(val.picUrl)" <u-card class="custom-card" v-for="(val,index) in list" @click="previewOpen(val.picUrl)"
:show-foot="false" :show-head="false"> :show-foot="false" :show-head="false">
<view slot="body" class="u-body-item" style="display: flex;flex-wrap:nowrap;"> <view slot="body" class="u-body-item" style="display: flex;flex-wrap:nowrap;">
<view><image :src="val.picUrl" mode="aspectFill" style="width: 60px;height: 80px;"></image></view> <view>
<view style="margin-left: 20px;line-height: 28px;margin-top: 11px;"><view>打卡时间:</view><view>{{val.time}}</view></view> <image :src="val.picUrl" mode="aspectFill" style="width: 60px;height: 80px;"></image>
</view>
<view style="margin-left: 20px;line-height: 28px;margin-top: 11px;">
<view>打卡时间:</view>
<view>{{val.time}}</view>
</view>
</view> </view>
</u-card> </u-card>
</uni-list> </uni-list>
@ -39,29 +52,31 @@
</template> </template>
<script> <script>
import { formatterDateTime } from "@/common/utils.js" import {
import config from "../../uni_modules/uview-ui/libs/config/config" formatterDateTime
} from "@/common/utils.js"
import config from "../../uni_modules/uview-ui/libs/config/config"
var interval = null var interval = null
export default { export default {
data() { data() {
return { return {
pageInfo:{ pageInfo: {
page:1, page: 1,
limit:20, limit: 20,
userId:uni.getStorageSync("user_id"), userId: uni.getStorageSync("user_id"),
unitId:uni.getStorageSync("dept_id") unitId: uni.getStorageSync("dept_id")
}, },
applet:this.$url.data.applet, applet: this.$url.data.applet,
time: formatterDateTime(new Date(), 'h:min:s'), time: formatterDateTime(new Date(), 'h:min:s'),
date:formatterDateTime(new Date(), 'Y-M-D'), date: formatterDateTime(new Date(), 'Y-M-D'),
lnt:'', lnt: '',
ingDate:[], ingDate: [],
list:[], list: [],
//ruleList:[{startTime:'2023-07-20 08:00:00',endTime:'2023-07-20 16:00:00'},{startTime:'2023-07-20 08:00:00',endTime:'2023-07-20 16:00:00'},{startTime:'2023-07-20 08:00:00',endTime:'2023-07-20 16:00:00'}] //ruleList:[{startTime:'2023-07-20 08:00:00',endTime:'2023-07-20 16:00:00'},{startTime:'2023-07-20 08:00:00',endTime:'2023-07-20 16:00:00'},{startTime:'2023-07-20 08:00:00',endTime:'2023-07-20 16:00:00'}]
ruleList:[], ruleList: [],
serverTime:'', serverTime: '',
form:{}, form: {},
taskId:'' taskId: ''
} }
}, },
onLoad() { onLoad() {
@ -77,18 +92,25 @@ import config from "../../uni_modules/uview-ui/libs/config/config"
this.getTime() this.getTime()
}, },
methods: { methods: {
initRuleList(){ initRuleList() {
this.$http.get("/fire-customer/sign/getRuleByUnitIdAndDate",{unitId:uni.getStorageSync("dept_id"),date:this.date},{}).then(res =>{ this.$http.get("/fire-customer/sign/getRuleByUnitIdAndDate", {
unitId: uni.getStorageSync("dept_id"),
date: this.date
}, {}).then(res => {
this.ruleList = res.data this.ruleList = res.data
}) })
}, },
getRecordByToday(){ getRecordByToday() {
// //
this.$http.get("/fire-customer/sign/getRecordByUserIdAndDate",{userId:uni.getStorageSync("user_id"),unitId:uni.getStorageSync("dept_id"),date:this.date},{}).then(res =>{ this.$http.get("/fire-customer/sign/getRecordByUserIdAndDate", {
userId: uni.getStorageSync("user_id"),
unitId: uni.getStorageSync("dept_id"),
date: this.date
}, {}).then(res => {
this.ingDate = res.data this.ingDate = res.data
this.ingDate.forEach(ingDate =>{ this.ingDate.forEach(ingDate => {
this.ruleList.forEach((rule,index)=>{ this.ruleList.forEach((rule, index) => {
if(ingDate.taskId == rule.id){ if (ingDate.taskId == rule.id) {
// this.ruleList[index].bb = true // this.ruleList[index].bb = true
rule.bb = true rule.bb = true
} }
@ -96,66 +118,66 @@ import config from "../../uni_modules/uview-ui/libs/config/config"
}) })
}) })
}, },
loadData(){ loadData() {
this.$http.get("/fire-customer/sign/record/user/page",this.pageInfo,{}).then(res =>{ this.$http.get("/fire-customer/sign/record/user/page", this.pageInfo, {}).then(res => {
this.list = this.list.concat(res.data.records) this.list = this.list.concat(res.data.records)
}) })
}, },
clickSign(){ clickSign() {
this.$http.get("/fire-customer/sign/getServerTime",{},{}).then(res =>{ this.$http.get("/fire-customer/sign/getServerTime", {}, {}).then(res => {
this.serverTime = res.data this.serverTime = res.data
let n = new Date(res.data).getTime() let n = new Date(res.data).getTime()
let bl = false let bl = false
try { try {
this.ruleList.forEach((rule) =>{ this.ruleList.forEach((rule) => {
let s = new Date(rule.startTime).getTime() let s = new Date(rule.startTime).getTime()
let e = new Date(rule.endTime).getTime() let e = new Date(rule.endTime).getTime()
if(s <= n && n<= e){ if (s <= n && n <= e) {
if(rule.bb){ if (rule.bb) {
uni.showToast({ uni.showToast({
icon:'none', icon: 'none',
title:'该时间段已打卡,请勿重复打卡' title: '该时间段已打卡,请勿重复打卡'
}) })
bl = true bl = true
return false return false
} }
rule.bb = true //rule.bb = true
this.taskId = rule.id this.taskId = rule.id
bl = true bl = true
this.getDw() this.getDw()
throw new Error("停止循环"); throw new Error("停止循环");
} }
}) })
} catch(e){ } catch (e) {
throw e; throw e;
} }
if(!bl){ if (!bl) {
uni.showToast({ uni.showToast({
icon:"none", icon: "none",
title:"不在打卡时间范围!请到点打卡!" title: "不在打卡时间范围!请到点打卡!"
}) })
return false return false
} }
}) })
}, },
getDw(){ getDw() {
this.getLocation() this.getLocation()
this.getCam() this.getCam()
}, },
getCam(){ getCam() {
uni.chooseMedia({ uni.chooseMedia({
count:1, count: 1,
mediaType:['image'], mediaType: ['image'],
sourceType:['camera'], sourceType: ['camera'],
camera:'front', camera: 'front',
success:(e)=>{ success: (e) => {
uni.showLoading({ uni.showLoading({
title: "上传图片...", title: "上传图片...",
mask: true mask: true
}) })
let te = e.tempFiles[0].tempFilePath let te = e.tempFiles[0].tempFilePath
//"{"code":200,"success":true,"data":"https://keningfile.oss-cn-shenzhen.aliyuncs.com/knFire/image/20230724/20230724180751_446.jpg","msg":""}" //"{"code":200,"success":true,"data":"https://keningfile.oss-cn-shenzhen.aliyuncs.com/knFire/image/20230724/20230724180751_446.jpg","msg":""}"
this.$http.upload('/fire-customer/knAliOss/uploadVadioFile',te,{}).then(res=>{ this.$http.upload('/fire-customer/knAliOss/uploadVadioFile', te, {}).then(res => {
let ddd = JSON.parse(res.data) let ddd = JSON.parse(res.data)
this.form.picUrl = ddd.data this.form.picUrl = ddd.data
this.form.locate = this.lnt this.form.locate = this.lnt
@ -164,18 +186,19 @@ import config from "../../uni_modules/uview-ui/libs/config/config"
this.form.unitId = uni.getStorageSync("dept_id") this.form.unitId = uni.getStorageSync("dept_id")
this.form.date = this.date this.form.date = this.date
this.form.taskId = this.taskId this.form.taskId = this.taskId
this.$http.post('/fire-customer/sign/addRecord',this.form,{}).then(res =>{ this.$http.post('/fire-customer/sign/addRecord', this.form, {}).then(
res => {
uni.hideLoading() uni.hideLoading()
this.getRecordByToday() this.getRecordByToday()
this.pageInfo.page = 1; this.pageInfo.page = 1;
this.list = []; this.list = [];
this.loadData(); this.loadData();
}) })
}).catch(e=>{ }).catch(e => {
uni.hideLoading() uni.hideLoading()
uni.showToast({ uni.showToast({
icon:'error', icon: 'error',
title:'请重试..' title: '请重试..'
}) })
}) })
@ -186,26 +209,26 @@ import config from "../../uni_modules/uview-ui/libs/config/config"
uni.getLocation({ uni.getLocation({
type: 'gcj02', //uni.openLocation type: 'gcj02', //uni.openLocation
geocode: true, geocode: true,
success:(res)=> { success: (res) => {
this.lnt = res.longitude + ',' + res.latitude; this.lnt = res.longitude + ',' + res.latitude;
} }
}) })
}, },
getTime() { getTime() {
interval = setInterval(()=> { interval = setInterval(() => {
this.time = formatterDateTime(new Date(), 'h:min:s') this.time = formatterDateTime(new Date(), 'h:min:s')
}, 1000) }, 1000)
}, },
previewOpen(e) { previewOpen(e) {
uni.previewImage({ uni.previewImage({
urls:[e] urls: [e]
}) })
}, },
close(){ close() {
clearInterval(interval) clearInterval(interval)
uni.removeStorageSync("token") uni.removeStorageSync("token")
uni.redirectTo({ uni.redirectTo({
url:'/pages/login/index' url: '/pages/login/index'
}) })
} }
@ -231,7 +254,7 @@ import config from "../../uni_modules/uview-ui/libs/config/config"
<style scoped lang="scss"> <style scoped lang="scss">
.CBlue { .CBlue {
background-image: linear-gradient(#7cc9ff,#1771d7); background-image: linear-gradient(#7cc9ff, #1771d7);
box-shadow: 0 8px 8px #b0d2f3; box-shadow: 0 8px 8px #b0d2f3;
} }
@ -265,6 +288,7 @@ import config from "../../uni_modules/uview-ui/libs/config/config"
} }
} }
} }
.u-body-title { .u-body-title {
font-size: 32rpx; font-size: 32rpx;
color: #333; color: #333;

Loading…
Cancel
Save