123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- <template>
- <view>
- <uni-nav-bar fixed="true" height="80px" dark color="#ffffff" backgroundColor="#1989fa" shadow left-icon="back"
- title="巡检中" @clickLeft="GoBack()"/>
- <view class="uni-flex uni-row" style="background-color: #666;color:#fff;margin-bottom:20px;padding:10px">
- <view class="flex-item;">
- <uni-icons style="position:relative;top:20px" type="person" size="40" color="#fff"></uni-icons>
- <text style="font-size:20px;line-height:20px;padding-left: 15px;;">正在巡检 {{routename}}</text>
- </view>
- <view class="flex-item" style="padding-left:60px;font-size:18px;">{{this.plantime}}</view>
- </view>
- <button style="height:40px;line-height:40px;border-radius:4px;background-color:#1989fa;color:#fff;border:#1989fa;margin:20px;" class="button" type="info" @click="NfcScan()">NFC感应</button>
- <uni-list>
- <uni-list-item direction="row" v-for="item in listdata" :key="item.autoid" :title="item.pointname" :note="item.hname" thumb="/static/img/route.png"
- thumb-size="lg" :rightText="item.status" @click="GoRouteViews(item)" link>
- </uni-list-item>
- </uni-list>
- </view>
- </template>
- <script>
- import NFC from "../../static/js/nfc.js"
- export default {
- data() {
- return {
- planCode:'',
- planDate:'',
- plantime:'',
- routename:'',
- nfcId:'',
- pointArr:[],
- listdata: []
- };
- },
- created(){
- this.planCode =decodeURIComponent(this.getUrlParam('plancode'))
- this.planDate =decodeURIComponent(this.getUrlParam('plandate'))
- this.plantime =decodeURIComponent(this.getUrlParam('plantime'))
- console.log(this.planCode+"==="+this.planDate+"===="+this.plantime)
- this.getRouteList()
- },
-
- methods:{
- getRouteList() {
- var data = {
- planCode: this.planCode,
- planDate: this.planDate,
- planTime: this.plantime
- }
-
- this.$api.GetRouteList(data).then(res=>{
- if (res.isSuccess && res.data !=undefined && res.data.length>0) {
- this.listdata = res.data // 将接口返回赋值data定义的数组
- this.routename = res.data[0].routename
- //巡更点加入数组 用于nfc感应验证
- this.listdata.forEach(e => {
- this.pointArr.push(e.pointcode)
- })
- }else{
- this.listdata =[]
- uni.showToast({
- icon: 'none',
- title: "没有查询到记录~"
- });
- }
- })
- },
- async NfcScan(){
- // 这里用异步获取读取到的NFC数据
- this.nfcId =await NFC.listenNFCStatus()
- if(!this.nfcId) return
- if (this.pointArr.indexOf(this.nfcId) === -1) {
- uni.showToast({
- icon: 'none',
- title: '未找到对应巡检点!',
- duration: 2000
- });
- } else {
- uni.showToast({
- icon: 'none',
- title: '识别成功! 编号:'+this.nfcId,
- duration: 2000
- });
-
- this.postNfcData()
- }
-
- },
-
- postNfcData(){
- if(this.$store.state.data.staffCode == undefined){
- uni.showToast({
- icon: 'none',
- title: "token过期请重新登录~",
- duration:1500
- });
- setTimeout(function() {
- uni.navigateTo({
- url:'../index/login'
- })
- }, 1500);
- return
- }
-
- var data= {
- userId: this.$store.state.data.staffCode,
- pointCode: this.nfcId
- }
- this.$api.NfcScan(data).then(res=>{
- if(!res.isSuccess){
- uni.showToast({
- icon: 'none',
- title: res.errMsg
- });
- return
- }
-
- this.getRouteList()
-
- })
-
- },
- GoRouteViews (item) {
- if(item.status=='未巡检'){
- uni.showToast({
- icon: 'none',
- title: 'NFC感应后才可点击'
- });
- return
- }
- uni.navigateTo({
- url:'/pages/inspection/Detail?pkcode='+encodeURIComponent(item.autoid)
-
- });
- },
- GoBack(){
- uni.navigateTo({
- url:"/pages/inspection/Plan"
- })
- },
- getUrlParam(_key){
- var pages = getCurrentPages() //获取加载的页面
- var currentPage = pages[pages.length - 1] //获取当前页面的对象
- var url = currentPage.route //当前页面url
- var options = currentPage.options //如果要获取url中所带的参数可以查看options
- return options[_key];
- },
-
-
- },
- }
- </script>
- <style>
- </style>
|