现阶段剩转盘抽奖逻辑
This commit is contained in:
@@ -8,17 +8,52 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, onBeforeMount, watch, ref, reactive } from "vue";
|
||||
import { wxShare } from "@/utils/wxshare.js";
|
||||
import h5plugin from "@/utils/plugin.js";
|
||||
import { onBeforeMount, onMounted, defineEmits, defineProps, reactive, ref, toRefs, getCurrentInstance, computed } from 'vue'
|
||||
import gsap from "gsap";
|
||||
import axios from 'axios'
|
||||
import { Toast, Dialog } from 'vant';
|
||||
import { useStore } from "vuex";
|
||||
import { get_authorize, get_jssdk } from '@/api/authorize-api'
|
||||
import service from "@/api/httpServe"
|
||||
import qs from 'qs'
|
||||
import h5plugin from '@/utils/plugin'
|
||||
import Index from "@/components/Index"
|
||||
|
||||
|
||||
// 初始化
|
||||
const emit = defineEmits(["indexPage"]); // 声明触发事件,对应父组件上面的方法
|
||||
const props = defineProps({ sendMessage: Object }); // 获取props
|
||||
const store = useStore() //初始化vuex
|
||||
const { proxy } = getCurrentInstance(); //初始化全局方法:plugin工具箱
|
||||
|
||||
|
||||
|
||||
// 变量定义
|
||||
const authData = ref('')
|
||||
const authCode = ref('')
|
||||
|
||||
|
||||
// 页面未挂载
|
||||
onBeforeMount(() => { });
|
||||
onBeforeMount(() => {
|
||||
console.log("用户活动信息:", store.state.userAccount);
|
||||
|
||||
// 微信环境授权
|
||||
// if (h5plugin.isWX()) {
|
||||
// console.log('code:', h5plugin.getQueryString('code'));
|
||||
|
||||
// if (h5plugin.getQueryString('code')) {
|
||||
// // 存在code的话去换取openid
|
||||
// authCode.value = h5plugin.getQueryString('code')
|
||||
// getOpenId(authCode.value)
|
||||
// } else {
|
||||
// getCode()
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
// 页面挂载
|
||||
onMounted(() => { });
|
||||
@@ -29,6 +64,40 @@ const indexPage = (actions) => {
|
||||
console.log("来自index组件:", actions);
|
||||
}
|
||||
|
||||
|
||||
// 授权获取code
|
||||
const getCode = () => {
|
||||
let redirect_uri = window.location.href;
|
||||
service.post(process.env.VUE_APP_API + '/zsApi/xfhdAuthorize', qs.stringify({
|
||||
redirect_uri: redirect_uri
|
||||
|
||||
})).then((res) => {
|
||||
let code = res.data.data
|
||||
authCode.value = res.data.data
|
||||
window.location.href = res.data.data
|
||||
})
|
||||
}
|
||||
|
||||
// 授权获取openid
|
||||
const getOpenId = (code) => {
|
||||
|
||||
service.post(process.env.VUE_APP_API + '/zsApi/oauthInfo', qs.stringify({
|
||||
code: code
|
||||
})).then((res) => {
|
||||
|
||||
if (res.data.code == 0) {
|
||||
console.log("后端返回的openid:", res.data);
|
||||
// 更新openid
|
||||
store.commit({ type: 'updateXGLOpenid', openid: res.data.data })
|
||||
console.log("用户活动信息:", store.state.userAccount);
|
||||
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -6,6 +6,7 @@ import Vue from 'vue'
|
||||
import store from '@/store'
|
||||
import "amfe-flexible"
|
||||
import h5plugin from '@/utils/plugin'
|
||||
import VueLuckyCanvas from '@lucky-canvas/vue'
|
||||
|
||||
|
||||
import VConsole from 'vconsole'
|
||||
@@ -26,6 +27,7 @@ console.log("环境:", process.env.NODE_ENV)
|
||||
|
||||
|
||||
// app.use(router)
|
||||
app.use(VueLuckyCanvas)
|
||||
app.use(store)
|
||||
app.mount('#app')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user