|
@@ -49,6 +49,7 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
+import { Toast } from "vant";
|
|
import { getCodeAPI } from "@/api/interact.js";
|
|
import { getCodeAPI } from "@/api/interact.js";
|
|
export default {
|
|
export default {
|
|
components: {},
|
|
components: {},
|
|
@@ -79,25 +80,29 @@ export default {
|
|
computed: {},
|
|
computed: {},
|
|
watch: {},
|
|
watch: {},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ // 封装获取用户code的方法
|
|
|
|
+ getUserCode() {
|
|
|
|
+ //此处的ID是在文档的开发-基本配置里面
|
|
|
|
+ let appid = "wx3255043d1b21a4f7";
|
|
|
|
+ // let url = "http://192.168.20.48:8080/#/layout/interact";
|
|
|
|
+ let url = "https://tp.wuhu.12301china.com/vote";
|
|
|
|
+ window.location.href =
|
|
|
|
+ "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" +
|
|
|
|
+ appid +
|
|
|
|
+ "&redirect_uri=" +
|
|
|
|
+ encodeURIComponent(url) +
|
|
|
|
+ "&response_type=code&scope=snsapi_userinfo&state=bc17befd6d5060f16de95e38f6eaf69c&connect_redirect=1#wechat_redirect";
|
|
|
|
+ },
|
|
// 点击+号
|
|
// 点击+号
|
|
async addInteract() {
|
|
async addInteract() {
|
|
- // this.$router.push("/layout/interact/issue");
|
|
|
|
- let code = this.getQueryCode();
|
|
|
|
- if (code) {
|
|
|
|
- let res = await getCodeAPI(code);
|
|
|
|
- console.log("-----", res);
|
|
|
|
- } else {
|
|
|
|
- //此处的ID是在文档的开发-基本配置里面
|
|
|
|
- let appid = "wx3255043d1b21a4f7";
|
|
|
|
- // let url = "http://192.168.20.48:8080/#/layout/interact";
|
|
|
|
- let url = "https://tp.wuhu.12301china.com/vote";
|
|
|
|
- window.location.href =
|
|
|
|
- "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" +
|
|
|
|
- appid +
|
|
|
|
- "&redirect_uri=" +
|
|
|
|
- encodeURIComponent(url) +
|
|
|
|
- "&response_type=code&scope=snsapi_userinfo&state=bc17befd6d5060f16de95e38f6eaf69c&connect_redirect=1#wechat_redirect";
|
|
|
|
- }
|
|
|
|
|
|
+ let userInfo = localStorage.getItem("YFYC_userInfo");
|
|
|
|
+ let nowTime = Date.now();
|
|
|
|
+ if (userInfo) {
|
|
|
|
+ let data = JSON.parse(userInfo);
|
|
|
|
+ // 超过了6个小时
|
|
|
|
+ if (nowTime - data.time >= 1000 * 60 * 60 * 6) this.getUserCode();
|
|
|
|
+ else this.$router.push("/layout/interact/issue");
|
|
|
|
+ } else this.getUserCode();
|
|
},
|
|
},
|
|
searchFu() {
|
|
searchFu() {
|
|
this.getList();
|
|
this.getList();
|
|
@@ -113,12 +118,24 @@ export default {
|
|
return this.$route.query.code ? this.$route.query.code : "";
|
|
return this.$route.query.code ? this.$route.query.code : "";
|
|
},
|
|
},
|
|
},
|
|
},
|
|
- created() {
|
|
|
|
|
|
+ async created() {
|
|
document.querySelector("#app").style.maxWidth = "500px";
|
|
document.querySelector("#app").style.maxWidth = "500px";
|
|
|
|
|
|
this.getList();
|
|
this.getList();
|
|
|
|
+
|
|
let code = this.getQueryCode();
|
|
let code = this.getQueryCode();
|
|
- console.log("---------", code);
|
|
|
|
|
|
+ if (code) {
|
|
|
|
+ let res = await getCodeAPI(code);
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
+ localStorage.setItem("YFYC_token", res.data.token);
|
|
|
|
+ localStorage.setItem(
|
|
|
|
+ "YFYC_userInfo",
|
|
|
|
+ JSON.stringify({ ...res.data.wxUser, time: Date.now() })
|
|
|
|
+ );
|
|
|
|
+ } else {
|
|
|
|
+ Toast.fail("登录失败,请联系管理人员");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
},
|
|
},
|
|
mounted() {},
|
|
mounted() {},
|
|
beforeCreate() {}, //生命周期 - 创建之前
|
|
beforeCreate() {}, //生命周期 - 创建之前
|
|
@@ -133,12 +150,17 @@ export default {
|
|
<style lang='less' scoped>
|
|
<style lang='less' scoped>
|
|
.My {
|
|
.My {
|
|
width: 100%;
|
|
width: 100%;
|
|
- height: calc(100% - 80px);
|
|
|
|
|
|
+ height: calc(100% - 130px);
|
|
overflow-y: auto;
|
|
overflow-y: auto;
|
|
padding: 20px 15px;
|
|
padding: 20px 15px;
|
|
position: relative;
|
|
position: relative;
|
|
.issue {
|
|
.issue {
|
|
- margin: 20px 0;
|
|
|
|
|
|
+ position: fixed;
|
|
|
|
+ z-index: 10;
|
|
|
|
+ bottom: 80px;
|
|
|
|
+ left: 50%;
|
|
|
|
+ transform: translateX(-50%);
|
|
|
|
+ height: 40px;
|
|
text-align: center;
|
|
text-align: center;
|
|
& > img {
|
|
& > img {
|
|
width: 40px;
|
|
width: 40px;
|