Browse Source

no message

linwenxin 1 năm trước cách đây
mục cha
commit
00bee12669
3 tập tin đã thay đổi với 60 bổ sung5 xóa
  1. 8 0
      src/api/common.js
  2. 37 5
      src/components/head.vue
  3. 15 0
      src/utils/lbs.js

+ 8 - 0
src/api/common.js

@@ -57,6 +57,14 @@ export function commonCompanywechatGet(params) {
   })
 }
 
+export function bigWaterGet(params) {
+  return request({
+    url: '/big/water/get',
+    method: 'get',
+    params
+  })
+}
+
 export function bigGetRegion(params) {
   return request({
     url: '/big/getRegion',

+ 37 - 5
src/components/head.vue

@@ -3,9 +3,15 @@
     <div class="dierjibie">
       <img :src="[img0, img1, img2][swindex]" alt="" srcset="" />
       <div class="asleft">
+        <div class="jajajaj" v-if="tianqi">{{
+        tianqi.result.city
+          ? `${tianqi.result.city} :${tianqi.result.weather || ''} ${tianqi.result.templow || ''
+          }℃ ~${tianqi.result.temphigh || ''}℃`
+          : ''
+      }}</div>
       </div>
       <div class="aszhongjian">
-        {{userInfo.companyWechatId ? userInfo.companyName : "售修宝运营平台"}}
+        {{ userInfo.companyWechatId ? userInfo.companyName : "售修宝运营平台" }}
       </div>
       <div class="asright">{{ timeStr }}</div>
     </div>
@@ -17,6 +23,7 @@ import { dateFormat2 } from '@/utils/util.js';
 import img0 from '@/assets/head8.png';
 import img1 from '@/assets/head1.png';
 import img2 from '@/assets/head2.png';
+import { bigWaterGet } from '@/api/common.js';
 export default {
   props: {
     swindex: {
@@ -32,6 +39,7 @@ export default {
       timeStr: '',
       timeId: null,
       info: {},
+      tianqi: null
     };
   },
   computed: {
@@ -40,6 +48,22 @@ export default {
       return JSON.parse(localStorage.getItem('greemall_user'))
     },
   },
+  watch: {
+    $IpAdd: {
+      handler(newVal, oldVal) {
+        if (newVal?.city) {
+          bigWaterGet({
+            city: newVal.city
+          }).then(res => {
+            this.tianqi = res.data
+            console.log(res.data)
+          })
+        }
+      },
+      deep: true,
+      immediate: true,
+    },
+  },
   mounted() {
     this.jishikaishi()
   },
@@ -47,17 +71,17 @@ export default {
     this.timeId && clearInterval(this.timeId);
   },
   methods: {
-    jishikaishi(){
+    jishikaishi() {
       let date = new Date();
       this.timeStr = dateFormat2('YYYY-mm-dd HH:MM:SS WWW', date);
-      this.timeId = setTimeout(this.jishikaishi,1000);
+      this.timeId = setTimeout(this.jishikaishi, 1000);
     }
   },
 };
 </script>
 
 <style scoped lang="scss">
-::v-deep .jajajaj {
+.jajajaj {
   height: 24px;
   line-height: 24px;
   font-size: 20px;
@@ -66,20 +90,24 @@ export default {
   text-align: left;
   color: #34c7ff;
 }
+
 ::v-deep .dv-scroll-board {
   background: none !important;
+
   .row,
   .row-item {
     background: none !important;
     height: 24px !important;
   }
 }
+
 .headview {
   width: 100%;
   height: 100%;
   position: relative;
   overflow: hidden;
-  .dierjibie{
+
+  .dierjibie {
     width: 100%;
     min-width: 1600px;
     height: 100%;
@@ -88,6 +116,7 @@ export default {
     left: 50%;
     transform: translateX(-50%);
   }
+
   img {
     position: absolute;
     bottom: 0;
@@ -95,6 +124,7 @@ export default {
     min-width: 1600px;
     height: 58px;
   }
+
   .aszhongjian {
     font-family: Source Han Sans CN;
     font-weight: 500;
@@ -110,6 +140,7 @@ export default {
     transform: translateX(-50%);
     text-align: center;
   }
+
   .asleft {
     height: 24px;
     overflow: hidden;
@@ -117,6 +148,7 @@ export default {
     bottom: 12px;
     left: 160px;
   }
+
   .asright {
     font-size: 20px;
     font-family: Source Han Sans CN, Source Han Sans CN-Regular;

+ 15 - 0
src/utils/lbs.js

@@ -90,6 +90,21 @@ export function getIPAdd() {
   })
 }
 
+// export function getIPAdd() {
+//   return new Promise(function (r, j) {
+//     try {
+//       axios
+//         .get('https://qifu-api.baidubce.com/ip/local/geo/v1/district')
+//         .then((res) => {
+//           r(res);
+//         })
+//         .catch(j);
+//     } catch (error) {
+//       j(error);
+//     }
+//   });
+// }
+
 // 获取当前ip
 function getIPs(callback) {
   var ip_dups = {}