MrShi
2025-08-19 f2ac76666299407545fb733f0d21f6e8cfe538a3
h5/pages/index/index.vue
@@ -1,5 +1,5 @@
<template>
   <view class="index">
   <view class="index" v-if="userInfo">
      <view class="index_t">
         <text>办公室安全上报</text>
         <image src="/static/img_egg@2x.png" mode="widthFix"></image>
@@ -31,18 +31,20 @@
</template>
<script>
   import { mapState } from 'vuex'
   import {
      mapState
   } from 'vuex'
   export default {
      computed: {
         ...mapState(['userInfo'])
      },
      data() {
         return {
            title: 'Hello'
            serverIds: []
         }
      },
      onLoad() {
         this.init()
      },
      methods: {
         jump(type) {
@@ -63,6 +65,152 @@
                  })
                  break;
            }
         },
         async init() {
            // ShiXuHui GuoJiWenWu
            // if (!this.$store.state.userInfo) {
            //    let res = await this.$u.api.login({ code: 'GuoJiWenWu' })
            //    if (res.code === 200) {
            //       this.$store.commit('setUserInfo', res.data)
            //    }
            // }
            // return
            let code = this.getQueryVariable('code')
            if (code) {
               if (!uni.getStorageSync('code')) {
                  uni.setStorageSync('code', code);
                  let res = await this.$u.api.login({ code: code })
                  if (res.code === 200) {
                     this.$store.commit('setUserInfo', res.data)
                     // this.initRegister()
                     // 判断是否跳转详情
                     let url = window.location.href
                     if (url.indexOf('state=') !== -1 && url.indexOf('#') !== -1) {
                        let value = url.substring(url.indexOf('state=') + 6, url.indexOf('#')).split('_')
                        console.log(value)
                        if (value[0] !== '' && value[0] != 'p') {
                           if (value[0] == 0) {
                              uni.navigateTo({
                                 url: `/pages/details_she/details_she?id=${value[1]}`
                              })
                           } else if (value[0] == 1) {
                              uni.navigateTo({
                                 url: `/pages/details_dca/details_dca?id=${value[1]}&isShow=true`
                              })
                           } else if (value[0] == 3) {
                              uni.navigateTo({
                                 url: `/pages/workOrder_she/workOrder_she?id=${value[1]}`
                              })
                           }
                        } else if (value[0] !== '' && value[0] == 'p') {
                           uni.navigateTo({
                              url: value[1]
                           })
                        }
                     }
                  }
               } else if (uni.getStorageSync('code') !== code) {
                  uni.setStorageSync('code', code);
                  let res = await this.$u.api.login({ code: code })
                  if (res.code === 200) {
                     this.$store.commit('setUserInfo', res.data)
                     // this.initRegister()
                     // 判断是否跳转详情
                     let url = window.location.href
                     if (url.indexOf('state=') !== -1 && url.indexOf('#') !== -1) {
                        let value = url.substring(url.indexOf('state=') + 6, url.indexOf('#')).split('_')
                        console.log(value)
                        if (value[0] !== '' && value[0] != 'p') {
                           if (value[0] == 0) {
                              uni.navigateTo({
                                 url: `/pages/details_she/details_she?id=${value[1]}`
                              })
                           } else if (value[0] == 1) {
                              uni.navigateTo({
                                 url: `/pages/details_dca/details_dca?id=${value[1]}&isShow=true`
                              })
                           } else if (value[0] == 3) {
                              uni.navigateTo({
                                 url: `/pages/workOrder_she/workOrder_she?id=${value[1]}`
                              })
                           }
                        } else if (value[0] !== '' && value[0] == 'p') {
                           uni.navigateTo({
                              url: value[1]
                           })
                        }
                     }
                  }
               } else {
                  // test.doumee.cn
                  // dmtest.ahapp.net
                  let loc_href = encodeURIComponent("https://lkshereporting.unilever-china.com/lianhelihua_web/")
                  let corpId = 'ww08b163f924524474';
                  let agentId = '1000165';
                  let wxUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${corpId}&redirect_uri=${loc_href}&response_type=code&scope=snsapi_base&state=#wechat_redirect`
                  location.href = wxUrl;
               }
            } else {
               let loc_href = encodeURIComponent("https://lkshereporting.unilever-china.com/lianhelihua_web/")
               let corpId = 'ww08b163f924524474';
               let agentId = '1000165';
               let wxUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${corpId}&redirect_uri=${loc_href}&response_type=code&scope=snsapi_base&state=#wechat_redirect`
               location.href = wxUrl;
            }
         },
         // 获取url参数
         getQueryVariable(variable) {
            var query = window.location.search.substring(1);
            var vars = query.split("&");
            for (var i = 0; i < vars.length; i++) {
               var pair = vars[i].split("=");
               if (pair[0] == variable) {
                  return pair[1];
               }
            }
            return (false);
         },
         async initRegister() {
            let fullURL = window.location.href.substring(0, window.location.href.lastIndexOf('#'))
            console.log(fullURL)
            let resData = await this.$u.api.getQwSignature({ url: fullURL })
            if (resData.code === 200) {
               this.$ww.register({
                  corpId: 'ww08b163f924524474',
                  agentId: '1000165',
                  jsApiList: [
                     'initOpenData',
                     'selectEnterpriseContact',
                     'chooseImage',
                     'uploadImage'
                  ],
                  getConfigSignature: (url) => {
                     console.log(this.$ww.getSignature(resData.data.ticket))
                     return this.$ww.getSignature(resData.data.ticket)
                  }
               })
               console.log(this.$ww)
               this.$ww.initOpenData({
                  success: (res) => {
                     console.log('success', res)
                  },
                  fail: (err) => {
                     console.log('fail', err)
                  }
               })
            }
         }
      }
   }
@@ -74,33 +222,39 @@
      padding: 30rpx;
      box-sizing: border-box;
      height: calc(100vh - 44px - 50px);
      background: linear-gradient( 180deg, #B5D2FF 0%, #FFFFFF 100%);
      background: linear-gradient(180deg, #B5D2FF 0%, #FFFFFF 100%);
      .index_t {
         width: 100%;
         height: 196rpx;
         display: flex;
         align-items: center;
         justify-content: space-between;
         text {
            font-weight: 900;
            font-size: 52rpx;
            color: #222222;
         }
         image {
            width: 290rpx;
            height: 100%;
         }
      }
      .index_list {
         width: 100%;
         display: flex;
         flex-direction: column;
         margin-top: 12rpx;
         .index_list_item {
            width: 100%;
            height: 200rpx;
            margin-bottom: 30rpx;
            position: relative;
            .index_list_item_info {
               width: 100%;
               height: 100%;
@@ -111,20 +265,23 @@
               flex-direction: column;
               position: relative;
               z-index: 99;
               text {
                  &:nth-child(1) {
                     font-weight: bold;
                     font-size: 34rpx;
                     color: #FFFFFF;
                  }
                  &:nth-child(2) {
                     font-weight: 400;
                     font-size: 26rpx;
                     color: rgba(255,255,255,0.6);
                     color: rgba(255, 255, 255, 0.6);
                     margin-top: 10rpx;
                  }
               }
            }
            image {
               width: 100%;
               height: 100%;
@@ -135,4 +292,4 @@
         }
      }
   }
</style>
</style>