Commit fae1fade authored by leiqingsong's avatar leiqingsong

活动模块前端细节处理1

parent 7e806b05
...@@ -69,9 +69,13 @@ export function getAllCouponsByOyStallCode(id) { ...@@ -69,9 +69,13 @@ export function getAllCouponsByOyStallCode(id) {
}) })
} }
export function getUserBaseInfo(code) { /**
* 现有开展活动
*/
export function getCurrentActive() {
return request({ return request({
url: `activity/getUserInfo?code=${code}`, url: `activity/underway`,
method: 'get' method: 'get'
}) })
} }
export function CoutDown(Endtime) {
let leftTime = (new Date(Endtime)) - new Date(); //计算剩余的毫秒数
let days = parseInt(leftTime / 1000 / 60 / 60 / 24, 10); //计算剩余的天数
let hours = parseInt(leftTime / 1000 / 60 / 60 % 24, 10); //计算剩余的小时
let minutes = parseInt(leftTime / 1000 / 60 % 60, 10);//计算剩余的分钟
let seconds = parseInt(leftTime / 1000 % 60, 10);//计算剩余的秒数
days = checkTime(days);
hours = checkTime(hours);
minutes = checkTime(minutes);
seconds = checkTime(seconds);
if (days >= 0 || hours >= 0 || minutes >= 0 || seconds >= 0) {
document.getElementById("timer").innerHTML = days + "天" + hours + "小时" + minutes + "分" + seconds + "秒";
}
if (days <= 0 && hours <= 0 && minutes <= 0 && seconds <= 0) {
window.clearInterval(_ordertimer);
_ordertimer = null;
}
function checkTime(i) { //将0-9的数字前面加上0,例1变为01
if (i < 10) {
i = "0" + i;
}
return i;
}
}
\ No newline at end of file
<template> <template>
<div id="active-detail"> <div id="active-detail">
<img class="bg" src="../../../public/img/activeDetail_bg.jpg" alt="bg" /> <img class="bg" src="../../../public/img/activeDetail_bg.jpg" alt="bg" />
<template v-if="type === 'coupon'"> <template v-if="active_type === 'coupon'">
<div class="coupon"> <div class="coupon">
<div class="user-icon">用户头像</div> <div class="user-icon">用户头像</div>
<p class="slogan">送你限量优惠券,手慢无~</p> <p class="slogan">送你限量优惠券,手慢无~</p>
...@@ -22,12 +22,13 @@ ...@@ -22,12 +22,13 @@
<div class="btn">立即领取</div> <div class="btn">立即领取</div>
</div> </div>
</template> </template>
<template v-if="type === 'wheel'"> <template v-if="active_type === 'wheel'">
<div class="wheel-container"> <div class="wheel-container">
<p class="title">{{ activityName }}</p> <p class="title">{{ activityName }}</p>
<div class="wheel"> <div class="wheel">
<div class="wheel-point" @click="Start_Game"></div> <div class="wheel-point" @click="Start_Game"></div>
<img src="../../../public/img/wheel.png" alt="wheel" /> <img src="../../../public/img/wheel.png" alt="wheel" />
<div class="circle"></div>
<div <div
class="wheel-bg" class="wheel-bg"
:class="{freeze: freeze}" :class="{freeze: freeze}"
...@@ -41,7 +42,7 @@ ...@@ -41,7 +42,7 @@
> >
<div class="prize-name">{{ item.name }}</div> <div class="prize-name">{{ item.name }}</div>
<div class="prize-icon"> <div class="prize-icon">
<img :src="item.icon" /> <img src="/img/counter.png" />
</div> </div>
</div> </div>
</div> </div>
...@@ -59,7 +60,7 @@ ...@@ -59,7 +60,7 @@
</div> </div>
<div class="time-line"> <div class="time-line">
距离结束仅剩 距离结束仅剩
<span>16天10:45:38</span> <span id="timer"></span>
</div> </div>
<div class="description"> <div class="description">
<div class="t">活动介绍</div> <div class="t">活动介绍</div>
...@@ -67,12 +68,16 @@ ...@@ -67,12 +68,16 @@
</div> </div>
</div> </div>
</template> </template>
<div class="btn-share" :style="type === 'coupon'? 'bottom: 0': ''" @click="handleShare">立即分享</div> <div
class="btn-share"
:style="active_type === 'coupon'? 'bottom: 0': ''"
@click="handleShare"
>立即分享</div>
<van-overlay :show="showAward" @click="showAward = false"> <van-overlay :show="showAward" @click="showAward = false">
<div class="wrapper" @click.stop> <div class="wrapper" @click.stop>
<div v-if="isAward" class="block"> <div v-if="isAward" class="block">
<p style="font-size: 20px;font-weight: bold;">OLAY全场通用抵扣券</p> <p style="font-size: 20px;font-weight: bold;">OLAY全场通用抵扣券</p>
<p style="font-size: 20px;font-weight: bold;">一等奖</p> <p style="font-size: 20px;font-weight: bold;">{{ awardGood.prizeName }}</p>
<p style="font-size: 20px;font-weight: bold;">恭喜您中奖!</p> <p style="font-size: 20px;font-weight: bold;">恭喜您中奖!</p>
<van-button style="background: #f00;color: #fff;" @click="handleGet">领取奖品</van-button> <van-button style="background: #f00;color: #fff;" @click="handleGet">领取奖品</van-button>
<van-button style="border-color: #7f7777;" @click="showAward = false">继续抽奖</van-button> <van-button style="border-color: #7f7777;" @click="showAward = false">继续抽奖</van-button>
...@@ -83,7 +88,6 @@ ...@@ -83,7 +88,6 @@
</div> </div>
</div> </div>
</van-overlay> </van-overlay>
<wx-auth :show-auth="showAuthDialog" @confirm="handleCheckAuth"></wx-auth> <wx-auth :show-auth="showAuthDialog" @confirm="handleCheckAuth"></wx-auth>
</div> </div>
</template> </template>
...@@ -92,11 +96,14 @@ ...@@ -92,11 +96,14 @@
import axios from "axios"; import axios from "axios";
import wxAuth from "@/components/wxAuth"; import wxAuth from "@/components/wxAuth";
import * as APi_Active from "@/api/active"; import * as APi_Active from "@/api/active";
import { CoutDown } from "@/utils/Foundation";
export default { export default {
name: "active-detail", name: "active-detail",
components: { wxAuth }, components: { wxAuth },
data() { data() {
return { return {
timer: null,
timeLine: "1586628005000",
isAward: false, isAward: false,
showAward: false, showAward: false,
userBaseInfo: "", userBaseInfo: "",
...@@ -110,7 +117,7 @@ export default { ...@@ -110,7 +117,7 @@ export default {
userId: "", userId: "",
code: "", code: "",
active_id: "", active_id: "",
type: "coupon", active_type: "coupon",
freeze: false, freeze: false,
rolling: false, rolling: false,
wheelDeg: 0, wheelDeg: 0,
...@@ -149,40 +156,41 @@ export default { ...@@ -149,40 +156,41 @@ export default {
], ],
activityName: "", activityName: "",
prizeDesc: "", prizeDesc: "",
des: "" des: "",
awardGood: {
prizeName: ""
}
}; };
}, },
async created() { async created() {
console.log("活动详情1"); console.log("活动详情1");
this.currentUrl = location.href; this.currentUrl = location.href;
this.active_id = this.$route.query.id; this.active_id = this.$route.query.id;
this.type = this.$route.query.type; this.active_type = this.$route.query.active_type;
console.log("query", this.$route.query); console.log("query", this.$route.query);
// 验证用户是否登录 // 验证用户是否登录
if (!sessionStorage.getItem("userId")) { if (!sessionStorage.getItem("userId")) {
// 1.获取code // 1.获取code
if (this.$route.query.code === undefined) { if (this.$route.query.unionid === undefined) {
this.showAuthDialog = true; // this.showAuthDialog = true;
// this.getUnionid();
} else { } else {
this.userBaseInfo = await this.getUserBaseInfo(this.$route.query.code);
console.log("userbaseInfo", this.userBaseInfo);
if (this.userBaseInfo.unionid) {
let params = { let params = {
number: 7, number: 7,
unionId: this.userBaseInfo.unionid unionId: this.$route.query.unionid
}; };
APi_Active.isMember(params).then(res => { APi_Active.isMember(params).then(res => {
this.isMember = res.data.vipId !== ""; this.isMember = res.data.vipId !== "";
this.userBaseInfo.phone = res.data.mobile ? res.data.mobile : ""; this.userBaseInfo.mobile = res.data.mobile;
this.userBaseInfo.name = res.data.name;
}); });
} else {
console.log("没有unionid");
this.isMember = false;
}
} }
} }
}, },
mounted() { mounted() {
this.timer = setInterval(() => {
CoutDown('2020-5-13 2:5:47');
}, 1000);
this.getAgentAuth(); this.getAgentAuth();
this.GET_DetailById(this.active_id); this.GET_DetailById(this.active_id);
}, },
...@@ -205,7 +213,9 @@ export default { ...@@ -205,7 +213,9 @@ export default {
// 领取 // 领取
handleGet() { handleGet() {
this.showAward = false; this.showAward = false;
this.$toast('领取成功!奖品已经发送到您的会员账户,请进入欧亚小程序查看。') this.$toast(
"领取成功!奖品已经发送到您的会员账户,请进入欧亚小程序查看。"
);
}, },
GET_DetailById(id) { GET_DetailById(id) {
APi_Active.getActiveDetailById(id).then(res => { APi_Active.getActiveDetailById(id).then(res => {
...@@ -213,64 +223,18 @@ export default { ...@@ -213,64 +223,18 @@ export default {
this.activityName = res.data.activityName; this.activityName = res.data.activityName;
this.des = res.data.des; this.des = res.data.des;
this.prizeDesc = res.data.prizeDesc; this.prizeDesc = res.data.prizeDesc;
// this.prizeListOrigin = res.data.list;
}); });
}, },
handleCheckAuth() { handleCheckAuth() {
this.showAuthDialog = false; this.showAuthDialog = false;
this.getAuthCode(); this.getUnionid();
},
async getUserBaseInfo(code) {
const res = await APi_Active.getUserBaseInfo(code);
return res;
},
// 获取code
getAuthCode() {
// alert('获取code')
const basicInfo = {
head: "https://open.weixin.qq.com/connect/oauth2/authorize?",
appId: "ww4df265003b43fa0d",
redirectUrI: encodeURIComponent(
`oysales.oywanhao.com:8087/activeDetail?id=${this.active_id}&type=${this.type}`
),
responseType: "code",
scope: "snsapi_base",
state: "ztest",
tail: "#wechat_redirect"
};
let url =
basicInfo.head +
"appid=" +
basicInfo.appId +
"&redirect_uri=" +
basicInfo.redirectUrI +
"&response_type=" +
basicInfo.responseType +
"&scope=" +
basicInfo.scope +
"&state=" +
basicInfo.state +
basicInfo.tail;
window.location.href = url;
}, },
getUnionid() { getUnionid() {
// window.location.href = 'http://wxmc.oysd.cn/GetWXUserInfo.aspx' let redirect_uri = encodeURIComponent(
// 获取用户 unionid、openid `oysales.oywanhao.com:8087/activeDetail?id=${this.active_id}&active_type=${this.active_type}`
// http://wxmc.oysd.cn/GetWXUserInfo.aspx );
// axios({ window.location.href = `http://wxsyls.oysd.cn/getwxuserinfo.aspx?jump=${redirect_uri}`;
// url: `http://wxmc.oysd.cn/GetWXUserInfo.aspx`,
// method: 'get'
// }).then(res => {
// console.log(res);
// this.unionid = res.msg.unionid;
// this.openid = res.msg.openid;
// let params = {
// number: 7,
// unionId: this.unionid
// }
// APi_Active.isMember(params).then(res => {
// this.isMember = res.data.vipId !== '';
// })
// })
}, },
Start_Game() { Start_Game() {
if (!this.isMember) { if (!this.isMember) {
...@@ -281,23 +245,26 @@ export default { ...@@ -281,23 +245,26 @@ export default {
} }
let params = { let params = {
activityId: this.active_id, activityId: this.active_id,
openId: this.userBaseInfo.openId, openId: this.$route.query.openId,
phone: this.userBaseInfo.phone, phone: this.userBaseInfo.phone,
unionId: this.userBaseInfo.unionId, unionId: this.$route.query.unionId,
// userId: userName: this.userBaseInfo.name
userName: this.getUserBaseInfo.nickname
}; };
APi_Active.play(params) APi_Active.play(params)
.then(res => { .then(res => {
this.rolling = true; this.rolling = true;
const { wheelDeg, prizeList } = this; const { wheelDeg, prizeList } = this;
const random = parseInt(6 * Math.random(0, 5)); // const random = parseInt(6 * Math.random(0, 5));
const random = prizeList
.map(item => item.id)
.indexOf(res.data.prizeId);
this.wheelDeg = this.wheelDeg =
wheelDeg - wheelDeg -
(wheelDeg % 360) + (wheelDeg % 360) +
6 * 360 - 6 * 360 -
(360 / prizeList.length) * random; (360 / prizeList.length) * random;
setTimeout(() => { setTimeout(() => {
this.awardGood = prizeList[random] || "";
this.rolling = false; this.rolling = false;
this.showAward = true; this.showAward = true;
this.isAward = res.data.prizeName !== "谢谢惠顾"; this.isAward = res.data.prizeName !== "谢谢惠顾";
...@@ -309,14 +276,12 @@ export default { ...@@ -309,14 +276,12 @@ export default {
}, },
// 分享 // 分享
handleShare() { handleShare() {
console.log("立即分享"); let url = `http://oysales.oywanhao.com:8087/activeDetail?id=${this.active_id}&active_type=${this.active_type}`;
let url = `http://oysales.oywanhao.com:8087/activeDetail?id=${this.active_id}&type=${this.type}`;
console.log("url", url);
wx.invoke( wx.invoke(
"shareToExternalContact", "shareToExternalContact",
{ {
title: "大转盘", // 分享标题 title: `${this.activityName}`, // 分享标题
desc: "抽奖活动", // 分享描述 desc: `${this.des}`, // 分享描述
link: url, // 分享链接 link: url, // 分享链接
imgUrl: "" // 分享封面 imgUrl: "" // 分享封面
}, },
...@@ -329,6 +294,9 @@ export default { ...@@ -329,6 +294,9 @@ export default {
} }
); );
} }
},
destroyed() {
clearInterval(this.timer)
} }
}; };
</script> </script>
......
...@@ -2,20 +2,41 @@ ...@@ -2,20 +2,41 @@
<div class="container"> <div class="container">
<div class="title"> <div class="title">
<span>大转盘抽奖</span> <span>大转盘抽奖</span>
<span class="fr">查看更多<span class="icon">></span></span>
</div> </div>
<div class="active"> <div class="active">
<div class="list" v-for="item in activeList" :key="item.id" @click="toDetail(item.id, item.activityType)"> <template v-for="(item, index) in activeList">
<div class="left"></div> <div
v-if="index < wheelActive_limit"
class="list"
:key="item.id"
@click="toDetail(item.id, item.activityType)"
>
<div class="left">
<img :src="item.logo" alt="logo" style="width:100%;height:100%;" />
</div>
<div class="right"> <div class="right">
<h3>{{ item.activityName }}</h3> <h3>{{ item.activityName }}</h3>
<p>{{ item.des }}</p> <p>{{ item.des }}</p>
</div> </div>
</div> </div>
</template>
<span
class="more"
v-if="activeList.length && !activeList_finished"
@click="handleWheelActiveMore"
>
查看更多
<span class="icon">></span>
</span>
</div> </div>
<div v-if="couponList.length > 0" class="fg">送券活动</div> <div v-if="couponList.length > 0" class="fg">送券活动</div>
<div class="active"> <div class="active">
<div class="list" v-for="item in couponList" :key="item.id" @click="toDetail(item.id, item.activityType)"> <div
class="list"
v-for="item in couponList"
:key="item.id"
@click="toDetail(item.id, item.activityType)"
>
<div class="left"></div> <div class="left"></div>
<div class="right"> <div class="right">
<h3>{{ item.activityName }}</h3> <h3>{{ item.activityName }}</h3>
...@@ -27,70 +48,84 @@ ...@@ -27,70 +48,84 @@
</template> </template>
<script> <script>
import * as API_Active from '@/api/active'; import * as API_Active from "@/api/active";
export default { export default {
data() { data() {
return { return {
wheelActive_limit: 3,
activeList_finished: false,
activeList: [ activeList: [
{ {
id: 1, id: 1,
activityType: 'coupon', activityType: "coupon",
activityName: '砍价', activityName: "砍价",
des: '由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状。' des: "由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状。"
}, },
{ {
id: 2, id: 2,
activityType: 'wheel', activityType: "wheel",
activityName: '集赞', activityName: "集赞",
des: '由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状。' des: "由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状。"
} }
], ],
couponList: [ couponList: [
{ {
id: 1, id: 1,
activityType: 'coupon', activityType: "coupon",
activityName: '砍价', activityName: "砍价",
des: '由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状。' des: "由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状。"
}, },
{ {
id: 2, id: 2,
activityType: 'wheel', activityType: "wheel",
activityName: '集赞', activityName: "集赞",
des: '由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状。' des: "由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状。"
} }
], ],
params: { params: {
pageNo: 1, pageNo: 1,
pageSize: 10 pageSize: 10
} }
} };
}, },
mounted() { mounted() {
this.getActiveList(this.params); this.getActiveList(this.params);
}, },
methods: { methods: {
handleWheelActiveMore() {
this.wheelActive_limit += 3;
if (this.wheelActive_limit === this.activeList.length - 3) {
this.activeList_finished = true;
return;
}
},
// 获取 活动列表 // 获取 活动列表
getActiveList(params) { getActiveList(params) {
API_Active.getActiveList(params).then(res => { API_Active.getActiveList(params).then(res => {
console.log('获取到数据'); console.log("获取到数据");
this.activeList = res.data.list; this.activeList = res.data.list;
}) });
}, },
// 跳转到 活动详情 // 跳转到 活动详情
toDetail(active_id, type) { toDetail(active_id, type) {
this.$router.push({ this.$router.push({
path: '/activeDetail', path: "/activeDetail",
query: { query: {
id: active_id, id: active_id,
type: type active_type: type
} }
}) });
} }
} }
}; };
</script> </script>
<style scoped> <style scoped>
.more {
float: right;
margin-bottom: 5px;
font-size: 12px;
}
.container { .container {
height: auto; height: auto;
background-color: rgba(248, 248, 248, 1); background-color: rgba(248, 248, 248, 1);
...@@ -122,7 +157,7 @@ export default { ...@@ -122,7 +157,7 @@ export default {
.active { .active {
background-color: #fff; background-color: #fff;
padding: 12px 12px 0 12px; padding: 12px 12px 0 12px;
box-shadow:0px 2px 4px 0px rgba(221,221,221,1); box-shadow: 0px 2px 4px 0px rgba(221, 221, 221, 1);
} }
.list { .list {
height: 94px; height: 94px;
...@@ -130,19 +165,20 @@ export default { ...@@ -130,19 +165,20 @@ export default {
background-color: #fff; background-color: #fff;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
border-bottom: 1px solid rgba(238,238,238,1); border-bottom: 1px solid rgba(238, 238, 238, 1);
margin-bottom: 14px; margin-bottom: 14px;
} }
.list3 { .list3 {
border-bottom: none; border-bottom: none;
margin-bottom: 0; margin-bottom: 0;
} }
.left,.right { .left,
.right {
height: 80px; height: 80px;
} }
.left { .left {
width: 80px; width: 80px;
background:rgba(248,248,248,1); background: rgba(248, 248, 248, 1);
} }
.right { .right {
width: 76%; width: 76%;
...@@ -151,12 +187,12 @@ export default { ...@@ -151,12 +187,12 @@ export default {
} }
h3 { h3 {
font-size: 14px; font-size: 14px;
font-weight:bold; font-weight: bold;
color:rgba(45,71,106,1); color: rgba(45, 71, 106, 1);
} }
p { p {
margin-top: 10px; margin-top: 10px;
font-size:12px; font-size: 12px;
color:rgba(45,71,106,0.8); color: rgba(45, 71, 106, 0.8);
} }
</style> </style>
<template>
<div id="more">
</div>
</template>
<script>
export default {
name: 'more',
components: {},
data() {
return {
}
}
}
</script>
<style lang="scss">
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment