智慧保安互联网APP
shuishen
2021-08-13 eaa83986e35d478bdfef55b49941fc6b4b86d95e
store/actions.js
@@ -1,5 +1,41 @@
import md5 from 'js-md5'
import axios from 'axios'
const geolocation = new qq.maps.Geolocation("T7RBZ-62U3X-RSQ4P-ZZVCB-WE7JT-HRBOG", "mapqq");
const getLocationData = (userId) => {
   var positionNum = 0;
   var options = {
      timeout: 8000
   };
   function showPosition(position) {
      var adCode = position.adCode; //邮政编码
      var nation = position.nation; //中国
      var city = position.city; //城市
      var addr = position.addr; //详细地址
      axios.post("http://223.82.109.183:2080/api/liveLocation/saveLiveLocationAndLocus", {
         type: 1,
         workerId: userId,
         longitude: position.lng,
         latitude: position.lat,
         location: addr == '' ? position.province + position.city : position.province + position.city +
            addr
      }).then((res) => {
      })
   };
   function showErr() {
      //TODO 如果出错了调用此方法
   };
   geolocation.getLocation(showPosition, showErr, options);
};
const actions = {
   loging(store, data) {
      var user = [{
@@ -63,12 +99,19 @@
               data.accounts = data.name;
               data.pass = data.pass;
               // data.userPhon = res.user_id;
               setInterval(function() {
                     getLocationData(res.data.user_id);
                  },
                  30000)
               uni.request({
                  url: "http://223.82.109.183:2080/api/blade-system/dept/detail?id=" + res.data.dept_id,
                  url: "http://223.82.109.183:2080/api/blade-system/dept/detail?id=" + res
                     .data.dept_id,
                  method: "get",
                  data: {
                  },
                  success: (result) => {
                     data.deptName = result.data.data.deptName
@@ -77,8 +120,8 @@
                     uni.$u.func.login(res.data)
                  }
               });
            }
         },
         fail: (res) => {