zt hace 10 meses
padre
commit
92a24c3784

+ 8 - 0
public/index.html

@@ -33,6 +33,10 @@
   <script src="https://cdn.staticfile.net/moment.js/2.20.1/moment.min.js"></script>
   <script src="https://cdn.staticfile.net/moment.js/2.20.1/locale/zh-cn.js"></script>
   <script src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script> -->
+<!--  // 灵锡用============================================================================-->
+  <script src="https://cdn-prod.internetofcity.cn/jssdk/jlingxi-1.0.9.min.js"></script>
+<!--  <script src="https://cdn.bootcss.com/vConsole/3.3.4/vconsole.min.js"></script>-->
+<!--  // 灵锡用============================================================================-->
   <!-- built files will be auto injected -->
 <!--  ======================================================================-->
   <script src="<%= BASE_URL %>vue.min.js"></script>
@@ -46,6 +50,10 @@
   <script src="<%= BASE_URL %>zh-cn.js"></script>
   <script src="<%= BASE_URL %>jweixin-1.4.0.js"></script>
   <script>
+      // 灵锡用============================================================================
+      // init vConsole
+      // var vConsole = new VConsole();
+      // 灵锡用============================================================================
     window.onload = function () {
       // let urlType = getUrlParameter(location.href, "urlType");
       // if (urlType) {

+ 41 - 0
src/common/js/api_lingxi.js

@@ -0,0 +1,41 @@
+import { request } from '../../service/request'
+// import constant from '@/common/js/constant'
+
+// const baseUri = constant.BASE_URI
+const auth = '/wx/LingXiConnectController'
+// alert('api_lingxi.js==>baseUri:' + baseUri)
+
+// 获取初始码
+export function getInitialCode(data) {
+    return request({
+        url: auth + '/initCode',
+        method: 'post',
+        data: data
+    })
+}
+// 获取用户信息
+export function getUserInfo(data) {
+    return request({
+        url: auth + '/fetchUserInfo',
+        method: 'post',
+        data: data
+    })
+}
+export function fetchUserAccessToken(data) {
+    return request({
+        url: auth + '/fetchUserAccessToken',
+        method: 'post',
+        data: data
+    })
+}
+
+
+
+// // 获取地址经纬度
+// export function getLonAndLat(data) {
+//     return request({
+//         url: baseUri + auth + '/getLonAndLat',
+//         method: 'post',
+//         data: data
+//     })
+// }

+ 2 - 2
src/common/js/constant.js

@@ -1,8 +1,8 @@
 // 系统常量
 // h5Server
 // const BASE_URI = '/h5Server'
-// const BASE_URI = 'http://lifeline.idea-sf.com/lifelineApi'
-const BASE_URI = 'http://2.22.195.139:8080/api'
+const BASE_URI = 'http://lifeline.idea-sf.com/lifelineApi'
+// const BASE_URI = 'http://2.22.195.139:8080/api'
 
 
 export default {

+ 6 - 2
src/pages/cityDangerReport/index.vue

@@ -52,7 +52,11 @@ export default {
     };
   },
   mounted() {
-    this.getList();
+      console.log('this.$route.params',this.$route.params,this.$route.params.openId)
+      // alert('openId'+this.$route.params.openId)
+      this.search.createdBy=this.$route.params.openId
+      // alert('this.search.createdBy'+this.search.createdBy)
+      this.getList();
   },
   methods: {
     toDetail(id) {
@@ -145,4 +149,4 @@ c
 .text8 {
   color: rgba(45, 140, 240, 1);
 }
-</style>
+</style>

+ 230 - 0
src/pages/cityDangerReport/indexBefore.vue

@@ -0,0 +1,230 @@
+<template>
+<!--    前置数据-->
+  <div>
+
+  </div>
+</template>
+<script>
+import { Toast } from 'vant'
+import { getInitialCode, getUserInfo, fetchUserAccessToken } from '@/common/js/api_lingxi'
+// import constant from '@/common/js/constant'
+export default {
+    data() {
+        return {
+            appId: 'B1334087658781568',
+            requestCode: '',
+            userAccessToken: ''
+        }
+    },
+    mounted() {
+        // alert('开始获取灵锡用户id,并进行跳转')
+        this.getIdToUrl('cityDangerReport')
+    },
+    methods: {
+        // '开始获取灵锡用户id,并进行跳转'
+        getIdToUrl(urlname) {
+            this.getInitCode(urlname)
+
+            // let user_id = ''
+            // this.$router.push({ name: urlname, params: { openId: 'xxxx' , realName: '2222222'}})
+            // this.handleAuthorization().then(e => {
+            //     user_id = e
+            //     // eslint-disable-next-line standard/object-curly-even-spacing
+            //
+            // })
+        },
+        async getInitCode(urlname) {
+            getInitialCode().then((res) => {
+                // alert('getInitialCode==>' + JSON.stringify(res))
+                this.initCode = res.data.initCode
+                // alert('initCode==>' + this.initCode)
+                this.handleAuthorization(urlname)
+            })
+        },
+        handleAuthorization(urlname) {
+            // // alert(this.initCode)
+            const _this = this
+            ls.ready(function() {
+                ls.userAuth({
+                    appId: _this.appId // 从开放平台申请到的 appId
+                }, function(res) {
+                    // alert('res:' + JSON.stringify(res))
+                    if (res.code === 200) {
+                        // // alert('requestCode:' + res.data.requestCode)
+                        const reqData = {
+                            requestCode: res.data.requestCode
+                        }
+                        fetchUserAccessToken(reqData).then(res => {
+                            // alert('获取用户访问令牌——:' + res)
+                            getUserInfo({ userAccessToken: res }).then((res) => {
+                                // alert('用户信息——:' + JSON.stringify(res))
+                                // alert('用户信息2——:' + res.openId)
+                                // eslint-disable-next-line standard/object-curly-even-spacing
+                                _this.$router.push({ name: urlname, params: { openId: res.openId, realName: res.realName }})
+
+                                // Toast('登录成功')
+                                // if (res.data.user.isInit === '1') {
+                                //     _this.$router.push({ path: '/residentHome' })
+                                // } else {
+                                //     _this.$router.push({ path: '/resident/mine/personalInfo' })
+                                // }
+                            }).catch(e => {
+                                Toast(e)
+                            })
+                        })
+                    } else if (res.code === 9005) {
+                        // 认证失败或登录失败
+                        // console.log('认证失败或登录失败')
+                        // alert('认证失败或登录失败')
+                        // 如果在此处调用ls.close()关闭页面,需要延迟0.5秒执行,否则ls.close()会无效。
+                    } else {
+                        // 其余情况
+                        // alert('userAuth error')
+                        // 如果在此处调用ls.close()关闭页面,需要延迟0.5秒执行,否则ls.close()会无效。
+                    }
+                })
+            })
+
+            // 失败回调
+            ls.error(function(res) {
+                // 错误处理
+                // alert('失败回调')
+            })
+
+            ls.config({
+                debug: false, // 开发时建议把调试模式开启
+                appId: this.appId, // 从开放平台申请到的 appId
+                initCode: this.initCode // 从业务方自己后台请求到 initCode
+            })
+        }
+        // // 授权并获取用户信息
+        // async handleAuthorization() {
+        //     // alert('start')
+        //     this.userAccessToken = ''
+        //     // 应该由服务端发起请求
+        //     var rt = await this.fetchInitCode({})
+        //     // alert('rt' + rt)
+        //     rt = JSON.parse(rt)
+        //     var data = rt.data
+        //     // alert('ls' + ls)
+        //     // alert('到这里了0')
+        //
+        //     // 成功回调
+        //     ls.ready(function() {
+        //         // alert('到这里了1')
+        //         // 自定义逻辑,如:
+        //         // 1.调用 JSSDK 里提供的交互方法
+        //         // 2.如需获取用户信息,需要在此处调用 ls.userAuth(Objectobject)方法获取requestCode。
+        //         //  userAuth根据appid会自动判断是否需要登录、认证和授权。
+        //         ls.userAuth({
+        //             appId: this.appId // 从开放平台申请到的 appId
+        //         }, function(res) {
+        //             // alert('到这里了1res' + res)
+        //             if (res.code === 200) {
+        //                 this.requestCode = res.data.requestCode // 获取到requestcode
+        //                 // 获取用户信息
+        //                 return this.getUserInfo()
+        //             } else if (res.code === 9005) {
+        //                 // 认证失败或登录失败
+        //                 // alert('认证失败或登录失败')
+        //                 // // alert('认证失败或登录失败')
+        //                 // 如果在此处调用ls.close()关闭页面,需要延迟0.5秒执行,否则ls.close()会无效。
+        //             } else {
+        //                 // 其余情况
+        //                 // alert('userAuth error')
+        //                 // // alert('userAuth error')
+        //                 // 如果在此处调用ls.close()关闭页面,需要延迟0.5秒执行,否则ls.close()会无效。
+        //             }
+        //         })
+        //     })
+        //
+        //     // alert('到这里了5')
+        //     ls.error(function(e) {
+        //         // alert(e)
+        //     })
+        //     // alert('到这里了6')
+        //     // 确保ready方法初始化以后调用config方法
+        //     ls.config({
+        //         debug: true, // 开发时建议把调试模式开启
+        //         appId: this.appId,
+        //         initCode: data.initCode
+        //     })
+        //     // alert('到这里了end')
+        //     // // alert('end')
+        // },
+        // // 获取用户信息
+        // async  getUserInfo() {
+        //     const requestCode = this.requestCode
+        //     let userAccessToken = this.userAccessToken
+        //     // alert('getUserInfo:' + requestCode, userAccessToken)
+        //
+        //     if (!userAccessToken && !requestCode) {
+        //         // alert('请先授权')
+        //         return
+        //     }
+        //
+        //     // 授权过了无需再重复获取userAccessToken
+        //     if (!userAccessToken) {
+        //         // 获取用户访问令牌 userAccessToken
+        //         const userAccess = await this.fetchUserAccessToken(requestCode)
+        //         userAccessToken = userAccess.data.userAccessToken
+        //         this.userAccessToken = userAccessToken
+        //     }
+        //
+        //     // 获取用户信息 userInfo
+        //     const user = await this.fetchUserInfo(userAccessToken)
+        //
+        //     const userInfo = user.data
+        //     // alert('用户信息' + userInfo)
+        //     // alert('用户信息' + userInfo)
+        //     return userInfo
+        // },
+        // // 使用ajax的方法
+        // httpPostLocaltion(url, data) {
+        //     // alert('请求' + url)
+        //     return new Promise((resolve, reject) => {
+        //         const xhr = new XMLHttpRequest()
+        //         xhr.open('post', url, true)
+        //         xhr.onreadystatechange = function() {
+        //             if (xhr.readyState === 4) {
+        //                 // console.log('获取数据1', xhr.response);
+        //                 if (xhr.status === 200) {
+        //                     // // alert(xhr.responseText);
+        //                     // return xhr.response
+        //                     resolve(xhr.response)
+        //                 } else {
+        //                     reject(new Error('异常失败' + xhr.status))
+        //                 }
+        //             }
+        //         }
+        //         // const data = {
+        //         // name:'zt'
+        //         // }
+        //         xhr.send(JSON.stringify(data))
+        //     })
+        //     // // 注意,设置请求头的信息必须写在下面,否则会报错
+        //     // // 设置以json传参
+        //     // xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
+        //     // 解决跨域问题
+        //     // xhr.setRequestHeader("Access-Control-Allow-Origin", "*");
+        //     // // 设置请求体携带的参数
+        // },
+        // // 获取初始码
+        // fetchInitCode(option) {
+        //     return this.httpPostLocaltion(constant.BASE_URI + '/wx/LingXiConnectController/initCode', option)
+        // },
+        // // 获取AccessToken
+        // fetchUserAccessToken(requestCode) {
+        //     // // alert(111)
+        //     return this.httpPostLocaltion(constant.BASE_URI + '/wx/LingXiConnectController/fetchUserAccessToken', { requestCode: requestCode })
+        // },
+        // fetchUserInfo(userAccessToken) {
+        //     return this.httpPostLocaltion(constant.BASE_URI + '/wx/LingXiConnectController/fetchUserInfo', { userAccessToken: userAccessToken })
+        // }
+    }
+}
+</script>
+
+<style scoped lang="scss">
+
+</style>

+ 5 - 0
src/pages/citySafeNotic/index.vue

@@ -58,6 +58,11 @@ export default {
         }
     },
     mounted() {
+        console.log('this.$route.params',this.$route.params,this.$route.params.openId)
+        alert('openId'+this.$route.params.openId)
+        this.search.createdBy=this.$route.params.openId
+        // alert('this.search.createdBy'+this.search.createdBy)
+
         this.getList()
     },
     methods: {

+ 230 - 0
src/pages/citySafeNotic/indexBefore.vue

@@ -0,0 +1,230 @@
+<template>
+<!--    前置数据-->
+  <div>
+
+  </div>
+</template>
+<script>
+import { Toast } from 'vant'
+import { getInitialCode, getUserInfo, fetchUserAccessToken } from '@/common/js/api_lingxi'
+// import constant from '@/common/js/constant'
+export default {
+    data() {
+        return {
+            appId: 'B1334087658781568',
+            requestCode: '',
+            userAccessToken: ''
+        }
+    },
+    mounted() {
+        // alert('开始获取灵锡用户id,并进行跳转')
+        this.getIdToUrl('citySafeNotic')
+    },
+    methods: {
+        // '开始获取灵锡用户id,并进行跳转'
+        getIdToUrl(urlname) {
+            this.getInitCode(urlname)
+
+            // let user_id = ''
+            // this.$router.push({ name: urlname, params: { openId: 'xxxx' , realName: '2222222'}})
+            // this.handleAuthorization().then(e => {
+            //     user_id = e
+            //     // eslint-disable-next-line standard/object-curly-even-spacing
+            //
+            // })
+        },
+        async getInitCode(urlname) {
+            getInitialCode().then((res) => {
+                // alert('getInitialCode==>' + JSON.stringify(res))
+                this.initCode = res.data.initCode
+                // alert('initCode==>' + this.initCode)
+                this.handleAuthorization(urlname)
+            })
+        },
+        handleAuthorization(urlname) {
+            // // alert(this.initCode)
+            const _this = this
+            ls.ready(function() {
+                ls.userAuth({
+                    appId: _this.appId // 从开放平台申请到的 appId
+                }, function(res) {
+                    // alert('res:' + JSON.stringify(res))
+                    if (res.code === 200) {
+                        // // alert('requestCode:' + res.data.requestCode)
+                        const reqData = {
+                            requestCode: res.data.requestCode
+                        }
+                        fetchUserAccessToken(reqData).then(res => {
+                            // alert('获取用户访问令牌——:' + res)
+                            getUserInfo({ userAccessToken: res }).then((res) => {
+                                // alert('用户信息——:' + JSON.stringify(res))
+                                // alert('用户信息2——:' + res.openId)
+                                // eslint-disable-next-line standard/object-curly-even-spacing
+                                _this.$router.push({ name: urlname, params: { openId: res.openId, realName: res.realName }})
+
+                                // Toast('登录成功')
+                                // if (res.data.user.isInit === '1') {
+                                //     _this.$router.push({ path: '/residentHome' })
+                                // } else {
+                                //     _this.$router.push({ path: '/resident/mine/personalInfo' })
+                                // }
+                            }).catch(e => {
+                                Toast(e)
+                            })
+                        })
+                    } else if (res.code === 9005) {
+                        // 认证失败或登录失败
+                        // console.log('认证失败或登录失败')
+                        // alert('认证失败或登录失败')
+                        // 如果在此处调用ls.close()关闭页面,需要延迟0.5秒执行,否则ls.close()会无效。
+                    } else {
+                        // 其余情况
+                        // alert('userAuth error')
+                        // 如果在此处调用ls.close()关闭页面,需要延迟0.5秒执行,否则ls.close()会无效。
+                    }
+                })
+            })
+
+            // 失败回调
+            ls.error(function(res) {
+                // 错误处理
+                // alert('失败回调')
+            })
+
+            ls.config({
+                debug: false, // 开发时建议把调试模式开启
+                appId: this.appId, // 从开放平台申请到的 appId
+                initCode: this.initCode // 从业务方自己后台请求到 initCode
+            })
+        }
+        // // 授权并获取用户信息
+        // async handleAuthorization() {
+        //     // alert('start')
+        //     this.userAccessToken = ''
+        //     // 应该由服务端发起请求
+        //     var rt = await this.fetchInitCode({})
+        //     // alert('rt' + rt)
+        //     rt = JSON.parse(rt)
+        //     var data = rt.data
+        //     // alert('ls' + ls)
+        //     // alert('到这里了0')
+        //
+        //     // 成功回调
+        //     ls.ready(function() {
+        //         // alert('到这里了1')
+        //         // 自定义逻辑,如:
+        //         // 1.调用 JSSDK 里提供的交互方法
+        //         // 2.如需获取用户信息,需要在此处调用 ls.userAuth(Objectobject)方法获取requestCode。
+        //         //  userAuth根据appid会自动判断是否需要登录、认证和授权。
+        //         ls.userAuth({
+        //             appId: this.appId // 从开放平台申请到的 appId
+        //         }, function(res) {
+        //             // alert('到这里了1res' + res)
+        //             if (res.code === 200) {
+        //                 this.requestCode = res.data.requestCode // 获取到requestcode
+        //                 // 获取用户信息
+        //                 return this.getUserInfo()
+        //             } else if (res.code === 9005) {
+        //                 // 认证失败或登录失败
+        //                 // alert('认证失败或登录失败')
+        //                 // // alert('认证失败或登录失败')
+        //                 // 如果在此处调用ls.close()关闭页面,需要延迟0.5秒执行,否则ls.close()会无效。
+        //             } else {
+        //                 // 其余情况
+        //                 // alert('userAuth error')
+        //                 // // alert('userAuth error')
+        //                 // 如果在此处调用ls.close()关闭页面,需要延迟0.5秒执行,否则ls.close()会无效。
+        //             }
+        //         })
+        //     })
+        //
+        //     // alert('到这里了5')
+        //     ls.error(function(e) {
+        //         // alert(e)
+        //     })
+        //     // alert('到这里了6')
+        //     // 确保ready方法初始化以后调用config方法
+        //     ls.config({
+        //         debug: true, // 开发时建议把调试模式开启
+        //         appId: this.appId,
+        //         initCode: data.initCode
+        //     })
+        //     // alert('到这里了end')
+        //     // // alert('end')
+        // },
+        // // 获取用户信息
+        // async  getUserInfo() {
+        //     const requestCode = this.requestCode
+        //     let userAccessToken = this.userAccessToken
+        //     // alert('getUserInfo:' + requestCode, userAccessToken)
+        //
+        //     if (!userAccessToken && !requestCode) {
+        //         // alert('请先授权')
+        //         return
+        //     }
+        //
+        //     // 授权过了无需再重复获取userAccessToken
+        //     if (!userAccessToken) {
+        //         // 获取用户访问令牌 userAccessToken
+        //         const userAccess = await this.fetchUserAccessToken(requestCode)
+        //         userAccessToken = userAccess.data.userAccessToken
+        //         this.userAccessToken = userAccessToken
+        //     }
+        //
+        //     // 获取用户信息 userInfo
+        //     const user = await this.fetchUserInfo(userAccessToken)
+        //
+        //     const userInfo = user.data
+        //     // alert('用户信息' + userInfo)
+        //     // alert('用户信息' + userInfo)
+        //     return userInfo
+        // },
+        // // 使用ajax的方法
+        // httpPostLocaltion(url, data) {
+        //     // alert('请求' + url)
+        //     return new Promise((resolve, reject) => {
+        //         const xhr = new XMLHttpRequest()
+        //         xhr.open('post', url, true)
+        //         xhr.onreadystatechange = function() {
+        //             if (xhr.readyState === 4) {
+        //                 // console.log('获取数据1', xhr.response);
+        //                 if (xhr.status === 200) {
+        //                     // // alert(xhr.responseText);
+        //                     // return xhr.response
+        //                     resolve(xhr.response)
+        //                 } else {
+        //                     reject(new Error('异常失败' + xhr.status))
+        //                 }
+        //             }
+        //         }
+        //         // const data = {
+        //         // name:'zt'
+        //         // }
+        //         xhr.send(JSON.stringify(data))
+        //     })
+        //     // // 注意,设置请求头的信息必须写在下面,否则会报错
+        //     // // 设置以json传参
+        //     // xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
+        //     // 解决跨域问题
+        //     // xhr.setRequestHeader("Access-Control-Allow-Origin", "*");
+        //     // // 设置请求体携带的参数
+        // },
+        // // 获取初始码
+        // fetchInitCode(option) {
+        //     return this.httpPostLocaltion(constant.BASE_URI + '/wx/LingXiConnectController/initCode', option)
+        // },
+        // // 获取AccessToken
+        // fetchUserAccessToken(requestCode) {
+        //     // // alert(111)
+        //     return this.httpPostLocaltion(constant.BASE_URI + '/wx/LingXiConnectController/fetchUserAccessToken', { requestCode: requestCode })
+        // },
+        // fetchUserInfo(userAccessToken) {
+        //     return this.httpPostLocaltion(constant.BASE_URI + '/wx/LingXiConnectController/fetchUserInfo', { userAccessToken: userAccessToken })
+        // }
+    }
+}
+</script>
+
+<style scoped lang="scss">
+
+</style>

+ 21 - 4
src/router/index.js

@@ -6,10 +6,26 @@ import auth from '../service/auth'
 Vue.use(Router)
 
 const router = new Router({
-    // mode: "history",
-    mode: 'hash',
+    mode: 'history',
+    // mode: 'hash',
     base: process.env.BASE_URL,
     routes: [
+        {
+            path: '/citySafeNoticBefore',
+            name: 'citySafeNoticBefore',
+            meta: {
+                title: '城市安全通知公告'
+            },
+            component: () => import('@/pages/citySafeNotic/indexBefore.vue')
+        },
+        {
+            path: '/cityDangerReportBefore',
+            name: 'cityDangerReportBefore',
+            meta: {
+                title: '城市隐患上报前置'
+            },
+            component: () => import('@/pages/cityDangerReport/indexBefore.vue')
+        },
         {
             path: '/login',
             name: 'login',
@@ -34,6 +50,7 @@ const router = new Router({
             },
             component: () => import('@/pages/citySafeNotic/index.vue')
         },
+
         {
             path: '/cityDangerReport',
             name: 'cityDangerReport',
@@ -501,7 +518,7 @@ const router = new Router({
 // });
 
 // 路由守卫 拦截
-const whiteList = ['vistiorRegistration', 'login', 'register', 'QRcode', 'todo', 'webView', 'registerbycpyinfo', 'cityDangerReport', `addcityDangerReport`,'citySafeNotic'] // 路由守卫白名单
+const whiteList = ['cityDangerReportBefore','vistiorRegistration', 'login', 'register', 'QRcode', 'todo', 'webView', 'registerbycpyinfo', 'cityDangerReport', `addcityDangerReport`,'citySafeNotic'] // 路由守卫白名单
 
 router.beforeEach((to, from, next) => {
     /* 路由发生变化修改页面title */
@@ -517,7 +534,7 @@ router.beforeEach((to, from, next) => {
             next()
         } else {
             next({
-                path: '/login',
+                path: '/cityDangerReportBefore',
                 query: to.query
             })
         }

+ 1 - 0
vue.config.js

@@ -31,6 +31,7 @@ module.exports = {
         proxy: {
             // 配置跨域
             "/h5Server": {
+                // target: `http://localhost:9001`,
                 target: `http://lifeline.idea-sf.com/lifelineApi`,
                 ws: true,
                 changOrigin: true, // 允许跨域