|
@@ -1,84 +1,152 @@
|
|
|
<template>
|
|
|
-<div>
|
|
|
- <div class="center" style="position: absolute;top: 10%;left: 50%;transform: translateX(-50%);text-align: center;">
|
|
|
- <van-loading size="24px" style="margin-bottom: .3rem;">请在微信端授权后再使用完整服务...</van-loading>
|
|
|
- <van-button type="primary" @click="init">授权获取完整服务</van-button>
|
|
|
+ <div class="page">
|
|
|
+ <template v-if="isWx">
|
|
|
+ <div class="wxTop">
|
|
|
+ <van-image class="logo" :src="logo" type="contain" />
|
|
|
+ </div>
|
|
|
+ <div class="center">
|
|
|
+ <p>申请获取以下权限</p>
|
|
|
+ <span>获取您的公开信息(昵称、头像等)</span>
|
|
|
+ <button class="btn" @click="init"
|
|
|
+ >微信授权</button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <div class="center" style="width: 80%;position: absolute;top: 10%;left: 50%;transform: translateX(-50%);">
|
|
|
+ <van-loading size="24px" style="margin-bottom: 0.3rem;display: flex;flex-direction: column;justify-content: center;align-items: center;">请在微信端授权后再使用完整服务...</van-loading>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
</div>
|
|
|
-
|
|
|
-</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import {
|
|
|
- getWxApiToken,
|
|
|
- getUSerInfo,
|
|
|
- getCourseCodeDetail
|
|
|
-} from "../api";
|
|
|
+import { getWxApiToken, getUSerInfo, getCourseCodeDetail } from "../api";
|
|
|
import { isWxEnv } from "../utils";
|
|
|
-import {mapState,mapGetters} from 'vuex'
|
|
|
+import { mapState, mapGetters } from "vuex";
|
|
|
export default {
|
|
|
- name: '',
|
|
|
+ name: "",
|
|
|
components: {},
|
|
|
- props: [],
|
|
|
- data () {
|
|
|
+ props: [],
|
|
|
+ data() {
|
|
|
return {
|
|
|
- pid:null,
|
|
|
- code:null,
|
|
|
- }
|
|
|
+ isWx:false,
|
|
|
+ pid: null,
|
|
|
+ code: null,
|
|
|
+ logo: require("../../../../static/images/course_logo.png")
|
|
|
+ };
|
|
|
},
|
|
|
- created () {
|
|
|
- this.init()
|
|
|
+ created() {
|
|
|
+ this.init();
|
|
|
},
|
|
|
- computed:{
|
|
|
- ...mapGetters(['wxid'])
|
|
|
+ computed: {
|
|
|
+ ...mapGetters(["wxid"])
|
|
|
},
|
|
|
- methods: {
|
|
|
+ methods: {
|
|
|
// 根据wxid获取微信个人数据
|
|
|
getUerInfo(wxid) {
|
|
|
+ console.log('测试用,正式删除')
|
|
|
getWxApiToken(wxid).then(token => {
|
|
|
getUSerInfo(token).then(res => {
|
|
|
this.user_info = JSON.parse(localStorage.getItem("wx_user_info"));
|
|
|
- if (this.$route.query && this.$route.query.pid&&!this.user_info.marketable) {
|
|
|
+ if (
|
|
|
+ this.$route.query &&
|
|
|
+ this.$route.query.pid &&
|
|
|
+ !this.user_info.marketable
|
|
|
+ ) {
|
|
|
localStorage.setItem("pid", this.$route.query.pid);
|
|
|
this.$router.replace(`/courseLogin?pid=${this.$route.query.pid}`);
|
|
|
- }else if(this.$route.query && this.$route.query.code){
|
|
|
- let codeArr = this.$route.query.code.split('-')
|
|
|
- this.$router.replace(`/course/courseDeail/${codeArr[1]}?code=${codeArr[0]}`);
|
|
|
- // getCourseCodeDetail(this.$route.query.code).then(res=>{
|
|
|
- // if(res != null){
|
|
|
- // this.$router.replace(`/course/courseDeail/${res.subjectId}?code=${this.$route.query.code}`);
|
|
|
- // }else{
|
|
|
- // this.$toast.fail("课程码无效")
|
|
|
- // this.$router.replace(`/courseHome`);
|
|
|
- // }
|
|
|
- // })
|
|
|
- }else{
|
|
|
+ } else if (this.$route.query && this.$route.query.code) {
|
|
|
+ let codeArr = this.$route.query.code.split("-");
|
|
|
+ this.$router.replace(
|
|
|
+ `/course/courseDeail/${codeArr[1]}?code=${codeArr[0]}`
|
|
|
+ );
|
|
|
+ } else {
|
|
|
this.$router.replace(`/courseHome`);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
// 微信环境判断
|
|
|
- wxAuth(type,data){
|
|
|
- isWxEnv(type,data).then(()=>{
|
|
|
- this.$router.replace(`/courseHome`);
|
|
|
- }).catch(()=>{
|
|
|
- this.getUerInfo(this.wxid)
|
|
|
- })
|
|
|
+ wxAuth(type, data) {
|
|
|
+ isWxEnv(type, data)
|
|
|
+ .then(() => {
|
|
|
+ this.isWx = true;
|
|
|
+ this.$router.replace(`/courseHome`);
|
|
|
+ })
|
|
|
+ .catch((e) => {
|
|
|
+ if(e == 1){
|
|
|
+ this.isWx = true;
|
|
|
+ }else{
|
|
|
+ this.isWx = false;
|
|
|
+ // this.getUerInfo(this.wxid);
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
//初始化判断
|
|
|
- init(){
|
|
|
- if(this.$route.query && this.$route.query.pid){
|
|
|
- this.wxAuth('pid',this.$route.query.pid)
|
|
|
- }else if(this.$route.query && this.$route.query.code){
|
|
|
- this.wxAuth('code',this.$route.query.code)
|
|
|
- }else{
|
|
|
- this.wxAuth()
|
|
|
+ init() {
|
|
|
+ if (this.$route.query && this.$route.query.pid) {
|
|
|
+ this.wxAuth("pid", this.$route.query.pid);
|
|
|
+ } else if (this.$route.query && this.$route.query.code) {
|
|
|
+ this.wxAuth("code", this.$route.query.code);
|
|
|
+ } else {
|
|
|
+ this.wxAuth();
|
|
|
}
|
|
|
+ // this.$dialog
|
|
|
+ // .confirm({
|
|
|
+ // title: "提示",
|
|
|
+ // message: "本程序需要提供您的用户信息"
|
|
|
+ // })
|
|
|
+ // .then(() => {
|
|
|
+
|
|
|
+ // })
|
|
|
+ // .catch(() => {});
|
|
|
}
|
|
|
- },
|
|
|
-}
|
|
|
+ }
|
|
|
+};
|
|
|
</script>
|
|
|
-<style scoped lang='scss'>
|
|
|
-
|
|
|
+<style scoped lang="scss">
|
|
|
+*{
|
|
|
+ margin: 0;
|
|
|
+ padding: 0;
|
|
|
+}
|
|
|
+.page {
|
|
|
+ box-sizing: border-box;
|
|
|
+ padding: 0 0.4rem;
|
|
|
+ .wxTop {
|
|
|
+ padding: 1rem 0;
|
|
|
+ border-bottom: 1px solid #ddd;
|
|
|
+ .logo {
|
|
|
+ border-radius: 0.2rem;
|
|
|
+ overflow: hidden;
|
|
|
+ display: block;
|
|
|
+ width: 50%;
|
|
|
+ margin: 0 auto;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .center {
|
|
|
+ padding-top: .5rem;
|
|
|
+ p{
|
|
|
+ font-size: .28rem;
|
|
|
+ margin-bottom: .3rem
|
|
|
+ }
|
|
|
+ span{
|
|
|
+ font-size: .26rem;
|
|
|
+ color: #888;
|
|
|
+ display: block;
|
|
|
+ margin-bottom: 0.5rem;
|
|
|
+ }
|
|
|
+ .btn{
|
|
|
+ margin: 0 auto;
|
|
|
+ width: 90%;
|
|
|
+ display: block;
|
|
|
+ border-radius: 0.4rem;
|
|
|
+ background-color: #26A2FF;
|
|
|
+ color: #fff;
|
|
|
+ font-size: .32rem;
|
|
|
+ line-height: .8rem;
|
|
|
+ border: 0;
|
|
|
+ outline: none;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|