接口初始调通

This commit is contained in:
tcubic 2022-08-02 16:57:47 +08:00
parent d419800cdc
commit 6cc6503270
5 changed files with 119 additions and 45 deletions

View File

@ -13,12 +13,19 @@ const service = axios.create({
baseURL: process.env.VUE_APP_API,
// responseType: 'json',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'token': store.state.userAccount.token
// 'Content-Type': 'application/x-www-form-urlencoded',
'Content-Type': 'application/json;charset=UTF-8',
'i-token': store.state.userAccount.token,
},
params: {
},
});
// 添加请求拦截器
service.interceptors.request.use(function (config) {
// 在发送请求之前做些什么

View File

@ -16,20 +16,13 @@
<span class="icon"
><img src="../assets/img/laba.png" alt="" srcset=""
/></span>
<span class="num">活动已有{{ participantNum }}人参与</span>
<span class="num">活动已有{{ store.state.userAccount.participantNum }}人参与</span>
</div>
<div class="cloud_left_2"></div>
<div class="icon_left_2"></div>
<div class="cloud_right_2"></div>
<!-- 大转盘 -->
<div class="zhuanpan">
<!-- <div class="liwu">
<div>1.99</div>
<div>2.99</div>
<div>3.99</div>
<div>4.99</div>
<div>5.99</div>
</div> -->
</div>
<div class="icon_right_2"></div>
<div class="icon_right_3"></div>
@ -155,7 +148,14 @@ const activityList = reactive([
]);
//
onBeforeMount(() => {});
onBeforeMount(() => {
//
gerCardId(94207)
getInfo()
getMyPrizeRecored()
getBrithday()
getActivityNum()
});
//
onMounted(() => {});
@ -183,22 +183,11 @@ const btn = () => {
//
const drawBtn = () => {
console.log("抽奖22");
console.log("抽奖:");
getluckyBag(1)
service.get(process.env.VUE_APP_API + '/cms88/card/qrcode/',cardId=store.state.userAccount.cardId )
.then((res) => {
console.log(res);
})
// console.log("",getAuthorize(1));
// if (h5plugin.getQueryString("forceauth")) {
// console.log("yes-forceauth");
// getAuthorize(0);
// } else {
// console.log("no-forceauth");
// getAuthorize(1);
// }
};
//
@ -239,6 +228,80 @@ const getAuthorize = (scopeState) => {
// return `${process.env.VUE_APP_ZS_DOMAIN}/wxauth/official/account/authorize?redirectUrl=${out_href}&scope=${1}"`;
window.location.href = `${process.env.VUE_APP_ZS_DOMAIN}/wxauth/official/account/authorize?redirectUrl=${out_href}&scope=${scopeState}`;
};
//
const gerCardId = (carid)=>{
service
.get(process.env.VUE_APP_API + "/cms-activity/cms88/card/qrcode/"+ carid)
.then((res) => {
console.log("企微二维码:",res.data.data);
store.commit({ type: "updateeEqcodeImg", eqcodeImg: res.data.data });
});
}
//
const getInfo = ()=>{
service
.post(process.env.VUE_APP_API + "/cms-activity/cms88/nkh/info",{})
.then((res) => {
console.log("资金账号:",res);
});
}
//
const getMyPrizeRecored = ()=>{
service
.post(process.env.VUE_APP_API + "/cms-activity/cms88/prize/list",{})
.then((res) => {
console.log(res);
});
}
// isInActivityDate 0 1
const getIsAddService = ()=>{
let isInActivityDate = 0
service
.post(process.env.VUE_APP_API + "/cms-activity/cms88/qywx/isadded/"+ isInActivityDate)
.then((res) => {
console.log(res);
});
}
// type 1 2
const getluckyBag = (id)=>{
let type = id
service
.post(process.env.VUE_APP_API + "/cms-activity/cms88/redpacket/draw/"+ type,{})
.then((res) => {
console.log(res);
});
}
//
const getActivityNum = ()=>{
service
.post(process.env.VUE_APP_API + "/cms-activity/cms88/user/count/")
.then((res) => {
console.log(res.data.data);
store.commit({ type: "updateParticipantNum", participantNum: res.data.data });
});
}
//
const getBrithday = ()=>{
service
.post(process.env.VUE_APP_API + "/cms-activity/cms88/user/isin/birthday",{})
.then((res) => {
console.log(res);
});
}
</script>
<style lang="scss" scoped>

View File

@ -3,8 +3,7 @@
<div class="service_container">
<div class="service_box">
<div class="eqcode_box">
<img :src="eqcode" alt="">
<img :src="store.state.userAccount.eqcodeImg" alt="">
</div>
</div>
<div class="service_cls_btn" @click="hidePop"></div>

View File

@ -38,34 +38,30 @@ onBeforeMount(() => {
console.log("link",window.location.href);
//
// if (h5plugin.isWX()) {
// console.log('code:', h5plugin.getQueryString('code'));
if (h5plugin.isWX()) {
console.log('code:', h5plugin.getQueryString('code'));
if (h5plugin.getQueryString('code')) {
// codeopenid
authCode.value = h5plugin.getQueryString('code')
getOpenId(authCode.value)
} else {
getCode()
}
}
// if (h5plugin.getQueryString('code')) {
// // codeopenid
// authCode.value = h5plugin.getQueryString('code')
// getOpenId(authCode.value)
// } else {
// getCode()
// }
// }
// let token = h5plugin.getQueryString('token')
// openid
store.commit({ type: "updateToken", token: h5plugin.getQueryString('token') });
store.commit({ type: "updateCardId", cardId: h5plugin.getQueryString('cardId') });
store.commit({ type: "updateNkh", cardId: h5plugin.getQueryString('nkh') });
console.log("用户活动信息:", store.state.userAccount);
});
//
onMounted(() => {

View File

@ -6,8 +6,8 @@ export default createStore({
state: {
userAccount: {
xglOpenid: 'openid12138', //用户openid
token: 'token12138', //用户token
cardId: '', //carid
token: '13f88993882b4dc0832351566c11a1eb', //用户token
cardId: '94207', //carid
nkh: '', //牛卡号
isDraw: false, //是否抽过奖
isHasAccount: false, //是否存在牛卡号
@ -15,6 +15,7 @@ export default createStore({
isHasPrize: [], //是否存在奖品
participantNum: 1213821, //活动参与人数
prizeResult: 73.11, //中奖金额
eqcodeImg: '' //二维码
},
},
@ -41,6 +42,14 @@ export default createStore({
state.userAccount.nkh = val.nkh
},
updateeEqcodeImg(state,val){
state.userAccount.eqcodeImg = val.eqcodeImg
},
updateParticipantNum(state,val){
state.userAccount.participantNum = val.participantNum
},
},
// 改变方法:异步
actions: {},