|
@@ -4,11 +4,12 @@
|
|
|
<!--vuetop-->
|
|
|
<div class="morebox1 response">
|
|
|
<div class="flex2 response flex justify-end">
|
|
|
- <div class="text3" @click="$router.push('/addcityDangerReport')">
|
|
|
+ <div class="text3" @click="$router.push( { name: 'addcityDangerReport', params: { openId: search.createdBy }})">
|
|
|
新增 <van-icon name="add" />
|
|
|
</div>
|
|
|
</div>
|
|
|
- <van-list
|
|
|
+
|
|
|
+ <van-list
|
|
|
v-model="isUpLoading"
|
|
|
:finished="upFinished"
|
|
|
:immediate-check="false"
|
|
@@ -36,56 +37,124 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import { listForAppTrouble } from "@/service/api_company.js";
|
|
|
+import { listForAppTrouble } from '@/service/api_company.js'
|
|
|
+import { Toast } from 'vant'
|
|
|
+import { getInitialCode, getUserInfo, fetchUserAccessToken } from '@/common/js/api_lingxi'
|
|
|
export default {
|
|
|
- data() {
|
|
|
- return {
|
|
|
- isUpLoading: false,
|
|
|
- isDownLoading: false,
|
|
|
- upFinished: false,
|
|
|
- reportList: [],
|
|
|
- search: {
|
|
|
- pageNum: 1,
|
|
|
- pageSize: "10",
|
|
|
- createdBy: "10008611",
|
|
|
- },
|
|
|
- };
|
|
|
- },
|
|
|
- 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: {
|
|
|
- toDetail(id) {
|
|
|
- this.$router.push("/addcityDangerReport?id=" + id);
|
|
|
- },
|
|
|
- async getList() {
|
|
|
- listForAppTrouble(this.search).then((res) => {
|
|
|
- if (res.data.rows.length) {
|
|
|
- this.isDownLoading = false;
|
|
|
- this.reportList.push(...res.data.rows);
|
|
|
- this.isUpLoading = false;
|
|
|
- if (this.reportList.length >= res.data.total) {
|
|
|
- this.upFinished = true;
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.reportList = [];
|
|
|
- this.isDownLoading = false;
|
|
|
- this.isUpLoading = false;
|
|
|
- this.upFinished = true;
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ isUpLoading: false,
|
|
|
+ isDownLoading: false,
|
|
|
+ upFinished: false,
|
|
|
+ reportList: [],
|
|
|
+ search: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: '10',
|
|
|
+ createdBy: '10008611'
|
|
|
+ },
|
|
|
+ appId: 'B1334087658781568',
|
|
|
+ requestCode: '',
|
|
|
+ userAccessToken: ''
|
|
|
}
|
|
|
- });
|
|
|
},
|
|
|
- onLoadList() {
|
|
|
- this.search.pageNum++;
|
|
|
- this.isDownLoading = false;
|
|
|
- this.getList();
|
|
|
+ mounted() {
|
|
|
+ // console.log('this.$route.params', this.$route.params, this.$route.params.openId)
|
|
|
+ // this.search.createdBy = this.$route.params.openId
|
|
|
+ // this.getList()
|
|
|
+ // alert('开始获取灵锡用户id')
|
|
|
+ this.getInitCode()
|
|
|
},
|
|
|
- },
|
|
|
-};
|
|
|
+ methods: {
|
|
|
+ async getInitCode() {
|
|
|
+ getInitialCode().then((res) => {
|
|
|
+ // alert('getInitialCode==>' + JSON.stringify(res))
|
|
|
+ this.initCode = res.data.initCode
|
|
|
+ // alert('initCode==>' + this.initCode)
|
|
|
+ this.handleAuthorization()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleAuthorization() {
|
|
|
+ // 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('用户信息1——:' + res.openId)
|
|
|
+ // eslint-disable-next-line standard/object-curly-even-spacing
|
|
|
+ // _this.$router.push({ name: urlname, params: { openId: res.openId, realName: res.realName }})
|
|
|
+ // Toast('登录成功')
|
|
|
+
|
|
|
+ _this.search.createdBy = res.openId
|
|
|
+ // 执行下一步
|
|
|
+ _this.getList()
|
|
|
+ }).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
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // ===上面是灵锡用的===========================================================================
|
|
|
+ toDetail(id) {
|
|
|
+ this.$router.push('/addcityDangerReport?id=' + id)
|
|
|
+ },
|
|
|
+ async getList() {
|
|
|
+ listForAppTrouble(this.search).then((res) => {
|
|
|
+ if (res.data.rows.length) {
|
|
|
+ this.isDownLoading = false
|
|
|
+ this.reportList.push(...res.data.rows)
|
|
|
+ this.isUpLoading = false
|
|
|
+ if (this.reportList.length >= res.data.total) {
|
|
|
+ this.upFinished = true
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.reportList = []
|
|
|
+ this.isDownLoading = false
|
|
|
+ this.isUpLoading = false
|
|
|
+ this.upFinished = true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onLoadList() {
|
|
|
+ this.search.pageNum++
|
|
|
+ this.isDownLoading = false
|
|
|
+ this.getList()
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
c
|
|
|
<style lang="scss">
|