王飞
2025-03-07 c5e49c10499435802a6551b98772f95660c6f85a
pages/index/person.vue
@@ -15,12 +15,13 @@
            </view>
            <view class="userinfo-value-box">
               <view class="user-nickname">{{ vuex_is_login ? vuex_user :'昵称' }}</view>
               <view class="user-nickname">{{ vuex_is_login ? company :'昵称' }}</view>
               <view class="user-nickname">{{ vuex_is_login ? company :'公司' }}</view>
               <!-- <view class="user-company">{{ vuex_is_login ? usercode :'暂未登录' }}</view> -->
            </view>
         </view>
         <view style="margin:0 15px;margin-top:20px;">
            <u-notice-bar v-if="text1.length!=0" mode="closable" direction="row" step  :text="text1">{{text1}}</u-notice-bar>
         <view style="margin:0 15px;margin-top:20px;">
            <u-notice-bar v-if="text1.length!=0" mode="closable" direction="row" step
               :text="text1">{{text1}}</u-notice-bar>
            <u-cell-group>
               <u-cell size="large" icon="level" title="当前版本" :value="appversion" isLink @click="update">
               </u-cell>
@@ -38,6 +39,8 @@
                  <u-switch slot="value" v-model="isoffline" @change="changelixian"></u-switch></u-cell>
               <u-cell size="large" icon="../../static/my/3wei.png" title="显示3维">
                  <u-switch slot="value" v-model="is3wei" @change="change3wei"></u-switch></u-cell>
                  <u-cell size="large" icon="../../static/my/ceju.png" title="寻物防丢">
                     <u-switch slot="value" v-model="isceju" @change="changeceju"></u-switch></u-cell>
            </u-cell-group>
            <image v-if="imageSrc" :src="imageSrc" mode="aspectFit"></image>
         </view>
@@ -47,7 +50,7 @@
            <u-icon name="close" style="position: absolute;right: 10px;top:10px" @click="closemodal"></u-icon>
            <uni-data-select style="position: absolute;   width: 85%;" placeholder="选择柜子" v-model="value"
               :localdata="guizi" @change="change"></uni-data-select>
            <uni-grid style="margin-top: 50px;margin-bottom: 120px;" v-if="isguizi" :column="3" :highlight="true">
            <uni-grid style="margin-top: 50px;" v-if="isguizi" :column="3" :highlight="true">
               <view v-for="(locker,index) in lockers" :key="index">
                  <uni-grid-item v-for="(item, index) in locker" :index="index" :key="index"
                     style="height: 20px; padding:0">
@@ -57,7 +60,7 @@
                  </uni-grid-item>
               </view>
            </uni-grid>
             <view v-else style="background-color: #ffffff; margin-top: 30px;margin-bottom: 30px;"></view>
            <view v-else style="background-color: #ffffff; margin-top: 30px;margin-bottom: 30px;"></view>
            <!--<u--form style="width: 80%; position: absolute;bottom: 60px;" labelPosition="left" :model="model2"
               :rules="rules2" ref="uForm">
               <u-form-item required label="手机号:" prop="userInfo.phone" borderBottom ref="item1" labelWidth="60px">
@@ -137,13 +140,15 @@
      <u-modal :show="show" :title="title" @cancel="cancel" @confirm="confirm" ref="uModal" :showCancelButton="true"
         :content='content'></u-modal>
      <successCom ref="refSuccess"></successCom>
      <!-- <bleCom></bleCom> -->
   </view>
</template>
<script>
   // const content = require('./content')
   const http = uni.$u.http
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
   var url = http.config.baseURL.split(":")[0] + ":" + http.config.baseURL.split(":")[1]
   import successCom from '@/components/success.vue'
   import {
@@ -151,6 +156,7 @@
      get_time_cha_s
   } from '@/js/tools.js'
   import store from '@/store/index.js'
   import bleCom from './ble.vue';
   import linkCom from '@/components/linkBox.vue'
   import {
      updateBaseURL
@@ -177,6 +183,7 @@
   export default {
      mixins: [pagesPerson, minLogin],
      components: {
         bleCom,
         successCom,
         linkCom
      },
@@ -186,7 +193,7 @@
            tag: '',
            value: 0,
            guizi: [],
            appversion: 'v1.0.7',
            appversion: 'v1.1.0',
            downloadUrl: '',
            text1: [],
            isguizi: false,
@@ -532,15 +539,16 @@
      },
      mounted() {
         this.lunbo()
         findFakagui().then((res) => {
            if (res.code == 0) {
               this.guizi = res.data.map(item => ({
                  value: item.deviceid,
                  text: item.cabinetname
               }));
            }
         })
         if (this.vuex_is_login) {
            findFakagui().then((res) => {
               if (res.code == 0) {
                  this.guizi = res.data.map(item => ({
                     value: item.deviceid,
                     text: item.cabinetname
                  }));
               }
            })
         }
         setTimeout(() => {
            this.paddingTop = this.vuex_padding_top
            this.paddingTop += 5
@@ -548,16 +556,23 @@
      },
      methods: {
         lunbo() {
            findTbUpapp().then((res) => {
               if (res.code == 0) {
                  if (this.appversion != res.data.version) {
                     for (var i = 0; i < res.data.info.split(",").length; i++) {
                        this.text1.push(res.data.info.split(",")[i])
            // const params = {
            //    name: '定位app',
            //    // deviceid: this.value,
            // }
            if (this.vuex_is_login) {
               findTbUpapp().then((res) => {
                  console.log(res);
                  if (res.code == 0) {
                     if (this.appversion != res.data.version) {
                        for (var i = 0; i < res.data.info.split(",").length; i++) {
                           this.text1.push(res.data.info.split(",")[i])
                        }
                        this.downloadUrl = res.data.address
                     }
                     this.downloadUrl = res.data.address
                  }
               }
            })
               })
            }
         },
         change(e) {
            if (this.value != 0) {
@@ -565,49 +580,49 @@
               const params = {
                  deviceid: this.value,
               }
               findFakaji(params).then((res) => {
               if (this.vuex_is_login) {
                  findFakaji(params).then((res) => {
                  if (res.data != 0) {
                     for (var j = 0; j < 3; j++) {
                        let num = 0
                        let total = 20
                        for (let i = num; i < total; i++) {
                           if (this.lockers[j][i].num === parseInt(res.data[j * 20 + i].slotnumber)) {
                              //       // 设置borderColor属性
                              if (res.data[j * 20 + i].allowtakecard == 'true') {
                                 this.lockers[j][i].borderColor = '#00ff00';
                                 this.lockers[j][i].checked = true
                                 this.kalist.push(res.data[j * 20 + i].slotnumber)
                              } else {
                                 this.lockers[j][i].borderColor = '#a3a3a3';
                                 this.lockers[j][i].checked = false
                     if (res.data != 0) {
                        for (var j = 0; j < 3; j++) {
                           let num = 0
                           let total = 20
                           for (let i = num; i < total; i++) {
                              if (this.lockers[j][i].num === parseInt(res.data[j * 20 + i].slotnumber)) {
                                 //       // 设置borderColor属性
                                 if (res.data[j * 20 + i].allowtakecard == 'true') {
                                    this.lockers[j][i].borderColor = '#00ff00';
                                    this.lockers[j][i].checked = true
                                    this.kalist.push(res.data[j * 20 + i].slotnumber)
                                 } else {
                                    this.lockers[j][i].borderColor = '#a3a3a3';
                                    this.lockers[j][i].checked = false
                                 }
                              }
                           }
                           if (i == total - 1) {
                              break;
                              if (i == total - 1) {
                                 break;
                              }
                           }
                        }
                     }
                  }
               })
                  })
               }
            } else {
               this.isguizi = false
               this.this.kalist = []
            }
         },
         update() {
            if (this.info == '') {
            if (this.info == undefined) {
               this.$refs.refSuccess.showBox({
                  type: 'error',
                  txt: '未检测到新版本'
               });
            } else {
               console.log("更新版本========》》》》》》》》");
               // const downloadUrl = 'http://39.106.210.13:8081/version/latest.apk'; // 替换为实际的下载链接
               console.log(this.downloadUrl);
               uni.showLoading({
                  title: '正在下载'
               });
               uni.downloadFile({
                  url: this.downloadUrl,
                  header: {
@@ -620,11 +635,8 @@
                        uni.openDocument({
                           filePath: res.tempFilePath,
                           showMenu: true,
                           success: () => {
                              console.log('文件打开成功');
                           },
                           success: () => {},
                           fail: (err) => {
                              console.error('文件打开失败', err);
                              uni.showToast({
                                 title: '文件打开失败',
                                 icon: 'none'
@@ -659,7 +671,6 @@
            this.model2.userInfo.yzm = ''
         },
         check1(rowIndex) {
            console.log("取卡===》》》》》》");
            // 遍历每个子数组
            if (this.rowindex != 0) {
               for (let i = 0; i < this.lockers.length; i++) { //3
@@ -686,12 +697,13 @@
               slotnumber: this.rowindex,
               deviceid: this.value,
            }
            findFakaTag(params).then((res) => {
               this.tag = res.data.tagid
            })
            if (this.vuex_is_login) {
               findFakaTag(params).then((res) => {
                  this.tag = res.data.tagid
               })
            }
         },
         faka() {
            console.log("发卡====》》》》》》》》》");
            this.showfaka = true
         },
@@ -738,7 +750,6 @@
                  // },
                  timeout: 5000, //设置超时时间,默认5秒
                  success: (rep) => { //具体捕获请看自己接口返回的形式
                     console.log(rep);
                     if (rep.data > 0) {
                        for (var i = 0; i < this.kalist.length; i++) {
@@ -746,23 +757,22 @@
                              slotnumber: this.kalist[i],
                              deviceid: this.value,
                           }
                           undateFaka(params).then((res) => {
                              console.log(res);
                              if (res.data > 0) {
                                 this.$refs.refSuccess.showBox({
                                    type: 'success',
                                    txt: "取卡成功!"
                                 });
                              }
                           })
                           if (this.vuex_is_login) {
                              undateFaka(params).then((res) => {
                                 if (res.data > 0) {
                                    this.$refs.refSuccess.showBox({
                                       type: 'success',
                                       txt: "取卡成功!"
                                    });
                                 }
                              })
                           }
                        }
                     }
                  },
                  fail(error) {
                     console.log(error);
                     // uni.hideLoading();
                     // uni.$u.toast('网络不通');
                     // reject(error)
@@ -805,12 +815,6 @@
               data.tagid = this.tag
               // data.slotnumber = cabinet.slotNumber;
               //                   const deviceid = cabinet.deviceId;
               //                   const tagname = sessionStorage.getItem("username");
               //                   const tagid = cabinet.tagid;
               console.log(data);
               var method = 'POST'
               var contentType = 'application/x-www-form-urlencoded'
               uni.request({
@@ -826,22 +830,21 @@
                  // },
                  timeout: 5000, //设置超时时间,默认5秒
                  success: (rep) => { //具体捕获请看自己接口返回的形式 
                     console.log(rep);
                     if (rep.data > 0) {
                        const params = {
                           slotnumber: this.rowindex,
                           deviceid: this.value,
                        }
                        undateFaka(params).then((res) => {
                           console.log(res);
                           if (res.data > 0) {
                              this.$refs.refSuccess.showBox({
                                 type: 'success',
                                 txt: "取卡成功!"
                              });
                           }
                        })
                        if (this.vuex_is_login) {
                           undateFaka(params).then((res) => {
                              if (res.data > 0) {
                                 this.$refs.refSuccess.showBox({
                                    type: 'success',
                                    txt: "取卡成功!"
                                 });
                              }
                           })
                        }
                     }
                  },
                  fail(error) {},
@@ -852,9 +855,7 @@
            }
         },
         groupChange(n) {
            console.log('groupChange', n);
         },
         groupChange(n) {},
         radioChange(n) {
            if (n == "固定卡") {
               this.tagshow = true
@@ -885,18 +886,19 @@
                  title: '正在获取验证码'
               })
               this.yzm = this.generateRandomCode();
               console.log(this.yzm);
               const params = {
                  phone: this.model2.userInfo.phone,
                  randomNumber: this.yzm,
               }
               sms(params).then((res) => {
                  uni.hideLoading();
                  // 这里此提示会被this.start()方法中的提示覆盖
                  uni.$u.toast('验证码已发送');
                  // 通知验证码组件内部开始倒计时
                  this.$refs.uCode.start();
               })
               if (this.vuex_is_login) {
                  sms(params).then((res) => {
                     uni.hideLoading();
                     // 这里此提示会被this.start()方法中的提示覆盖
                     uni.$u.toast('验证码已发送');
                     // 通知验证码组件内部开始倒计时
                     this.$refs.uCode.start();
                  })
               }
            } else {
               uni.$u.toast('倒计时结束后再发送');
            }
@@ -913,19 +915,20 @@
                  title: '正在获取验证码'
               })
               this.yzm = this.generateRandomCode();
               console.log(this.yzm);
               const params = {
                  phone: this.model1.userInfo.phone,
                  randomNumber: this.yzm,
               }
               sms(params).then((res) => {
                  uni.hideLoading();
                  // 这里此提示会被this.start()方法中的提示覆盖
                  uni.$u.toast('验证码已发送');
                  // 通知验证码组件内部开始倒计时
                  this.$refs.uCode.start();
               if (this.vuex_is_login) {
                  sms(params).then((res) => {
                     uni.hideLoading();
                     // 这里此提示会被this.start()方法中的提示覆盖
                     uni.$u.toast('验证码已发送');
                     // 通知验证码组件内部开始倒计时
                     this.$refs.uCode.start();
               })
                  })
               }
            } else {
               uni.$u.toast('倒计时结束后再发送');
            }
@@ -954,23 +957,55 @@
               value: e
            })
         },
         change3wei(e) {
            store.commit('$tStore', {
               name: 'is3wei',
               value: e
            })
         },
         changeceju(e) {
            console.log(e);
            // checkUpdate()
            if (e==true) {
               uni.reLaunch({
                  url: '/pages/index/ble'
               });
            }else{
               // closeBle() { //关闭蓝牙
                  uni.closeBLEConnection({
                     deviceId: this.GET_CONNECT_DEVICEId,
                     success(res) {
                        store.commit('$tStore', {
                           name: 'GET_CONNECT_DEVICEId',
                           value: ""
                        })
                        store.commit('$tStore', {
                           name: 'GET_BLE_DATA',
                           value: '请先连接蓝牙'
                        })
                        store.commit('$tStore', {
                           name: 'isceju',
                           value: false
                        })
                     }
                  })
               // },
            }
         },
         
         
         cancelinfo() {
            this.showinfo = false
            this.fileList1=[]
            this.model1.userInfo.phone=''
            this.model1.userInfo.name=''
            this.model1.userInfo.images=''
            this.model1.userInfo.tagId=''
            this.model1.userInfo.yzm=''
            this.fileList1 = []
            this.model1.userInfo.phone = ''
            this.model1.userInfo.name = ''
            this.model1.userInfo.images = ''
            this.model1.userInfo.tagId = ''
            this.model1.userInfo.yzm = ''
         },
         confirminfo() {
            this.$refs.uForm.validate().then(res => {
@@ -982,7 +1017,6 @@
                  baoliu38: this.model1.userInfo.images,
                  ptagid: this.model1.userInfo.tagId,
               }
               console.log(params);
               var method = 'POST'
               var contentType = 'application/x-www-form-urlencoded'
               uni.request({
@@ -999,13 +1033,12 @@
                  // },
                  timeout: 5000, //设置超时时间,默认5秒
                  success: (rep) => { //具体捕获请看自己接口返回的形式
                     console.log(rep);
                     if (rep.data > 0) {
                        this.model1.userInfo.phone=''
                        this.model1.userInfo.name=''
                        this.model1.userInfo.images=''
                        this.model1.userInfo.tagId=''
                        this.model1.userInfo.yzm=''
                        this.model1.userInfo.phone = ''
                        this.model1.userInfo.name = ''
                        this.model1.userInfo.images = ''
                        this.model1.userInfo.tagId = ''
                        this.model1.userInfo.yzm = ''
                        this.fileList1 = []
                     }
                  },
@@ -1014,9 +1047,6 @@
                     uni.hideLoading();
                  }
               });
               // updateTagApi(params).then((res) => {
               //    console.log(res);
               // })
               this.showinfo = false
            }).catch(errors => {
               uni.$u.toast('校验失败', errors)
@@ -1075,25 +1105,27 @@
         submitForm() {
            // 更新 baseURL
            updateBaseURL("http://" + this.form.url + ':' + this.form.port); // 调用 updateBaseURL 函数
            earlyWarning().then((res) => {
               if (res.code == 0) {
                  this.$refs.refSuccess.showBox({
                     type: 'success',
                     txt: "切换数据源成功!"
                  });
                  this.showpopup = false
                  this.form.port = ''
                  this.form.url = ''
               } else {
                  this.$refs.refSuccess.showBox({
                     type: 'error',
                     txt: res.data
                  });
                  this.showpopup = false
                  this.form.port = ''
                  this.form.url = ''
               }
            })
            if (this.vuex_is_login) {
               earlyWarning().then((res) => {
                  if (res.code == 0) {
                     this.$refs.refSuccess.showBox({
                        type: 'success',
                        txt: "切换数据源成功!"
                     });
                     this.showpopup = false
                     this.form.port = ''
                     this.form.url = ''
                  } else {
                     this.$refs.refSuccess.showBox({
                        type: 'error',
                        txt: res.data
                     });
                     this.showpopup = false
                     this.form.port = ''
                     this.form.url = ''
                  }
               })
            }
         },
         camera() {
            this.showinfo = true
@@ -1140,12 +1172,8 @@
            plus.push.createMessage(content, payload, options);
            uni.getPushClientId({
               success: (res) => {
                  console.log(res.cid);
               },
               fail(err) {
                  console.log(err)
               }
               success: (res) => {},
               fail(err) {}
            });
         },
         cancel() {