video_app/pages/task/index.vue

735 lines
19 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!-- 任务中心 -->
<template>
<view class="container">
<!-- <u-navbar :background="background" :is-back="false" :title="title" :border-bottom="false"></u-navbar> -->
<view class="task_bg u-absolute">
<image class="task_bg" src="../../static/images/me/task_bg.png"></image>
</view>
<view class="navTitle">
<view></view>
<view class="title">任务大厅</view>
<image @click="goNav({ jumpType: 1, buttonUrl: '/pages/me/index' })" class="navTitleIcon"
src="../../static/images/my.png"></image>
</view>
<view class="icon u-relative padding">
<image class="task_icon1 u-relative" src="../../static/images/me/task_icon1.png"></image>
<view class="icon_title u-font-32 text-bold u-relative">新人好礼送不停</view>
<image class="task_icon2 u-relative" src="../../static/images/me/task_icon2.png"></image>
</view>
<view class="content signIn margin-lr bg-white u-relative" style="margin-bottom: 32rpx;">
<view class="">
<image src="../../static/dwbimgs/renwubg.png"
style="width: 100%;height: 78rpx;position: absolute;left: 0;top: 0;z-index:1" mode=""></image>
<view style="z-index: 9999;position: absolute;text-align: center;width: 98%;">已连续签到 <text class="num"
style="color: #EC6F48;margin: 0 10rpx;">{{ signDays }}</text> </view>
</view>
<!-- <view class="signInList flex justify-between">
<text class="line"></text>
<view class="signIn-Item"
:class="{active: item.showText == '待签到'||item.showText == '未签到'||item.showText == '已签到'}"
v-for="(item,index) in signInList" :key="index">
<image class="signIn_icon" v-if="item.showText == '未签到'" src="../../static/images/signIn_icon2.png"
mode="" />
<image class="signIn_icon" v-if="item.showText == '已签到'" src="../../static/images/signIn_icon3.png"
mode="" />
<image class="signIn_icon" v-if="item.showText != '未签到'&&item.showText != '已签到'"
src="../../static/images/signIn_icon1.png" mode="" />
<view class="radius"></view>
<view class="_label">{{item.showText}}</view>
</view>
</view> -->
<view style="margin-top: 100rpx; display: flex;align-items: center; justify-content: space-between;">
<view class="" v-for="item in signInList" :key="item.id" style="position: relative;"
:style="filterDate(item) == '已签到' ? 'color:#EFA765' : 'color:#999'">
{{ filterDate(item) }}
<view
style="margin-top: 20rpx;;width: 80rpx;height: 94rpx;background: linear-gradient( 180deg, #FFF7E3 0%, #FFFFFF 100%);border-radius: 14rpx 14rpx 0rpx 0rpx;"
:style="filterDate(item) == '已签到' ? 'color:#999' : 'color:#EFA765'">
{{ item.signDay.substr(5, 8) }}
</view>
<image v-if="item.status == 0" src="../../static/dwbimgs/xing (1).png"
style="width: 52rpx;height: 48rpx;position: absolute;top: 100rpx;left: 14rpx;" mode=""></image>
<image v-else src="../../static/dwbimgs/xing (2).png"
style="width: 52rpx;height: 48rpx;position: absolute;top: 100rpx;left: 14rpx;" mode="">
</image>
</view>
</view>
<!-- <view class="tishi">连续签到7天即可获得7元奖励</view> -->
<!-- <view class="signInBtn" @click="goNav({jumpType: 0, id:15, buttonTitle: '去领取'})">
<view>{{signInBtn}}</view>
<view class="signInBtnBg"></view>
</view> -->
</view>
<view class="content margin-lr padding bg-white u-relative" v-if="list.length">
<view class="cell flex justify-between" v-for="(item, index) in list" :key="index" v-if="item.shows">
<view class="cell_left flex">
<view class="cell_title flex">
<view class="u-font-28 text-bold title"
:style="{ alignSelf: item.rewardImg ? 'center' : 'flex-start' }">{{ item.title }}</view>
<u-image v-if="item.rewardImg" class="cell_icon" :src="item.rewardImg"></u-image>
<view class="u-font-24 tip">{{ item.rewardDetail }}</view>
</view>
<view class="subhead u-font-24">{{ item.detail }}</view>
</view>
<view class="cell_right flex">
<view v-if="item.disabled" class="btn u-font-24 text-bold"
:style="{ backgroundColor: item.buttonBgColor, color: item.buttonFontColor }"
@click="goNav(item)">
{{ item.type == 1 ? item.buttonTitle : item.number ? `${item.discNumber}/${item.number}` : (
item.discNumber <= 0 ? item.buttonTitle : `剩余${item.discNumber}次`) }}
</view>
<view v-else class="btn u-font-24 text-bold disabled">
{{ item.type == 1 ? item.buttonTitle : item.number ? `${item.discNumber}/${item.number}`
: (item.discNumber <= 0 ? item.buttonTitle : `剩余${item.discNumber}次`) }}
</view>
<!-- <view v-else class="btn u-font-24 text-bold" @click="goNav(item)">{{ item.buttonTitle }}</view> -->
<view v-if="item.buttonUnderContent && item.buttonUnderUrl" class="u-font-22 tip"
@click="goNav({ id: item.id, buttonUrl: item.buttonUnderUrl, jumpType: 1, title: item.title, disabled: item.disabled, discNumber: item.discNumber })">
{{ item.buttonUnderContent }}
</view>
</view>
</view>
</view>
<!-- 激励视频广告 -->
<ad-rewarded-video v-if="adRewardedVideo" ref="adRewardedVideo" adpid="1531580352" :loadnext="true"
v-slot:default="{ loading, error }" :url-callback="urlCallback" @load="onadload" @close="onadclose"
@error="onaderror">
<view class="ad-error" v-if="error">{{ error }}</view>
</ad-rewarded-video>
</view>
</template>
<script>
import {
data
} from '../../tuniao-ui/libs/mixin/mixin'
export default {
data() {
return {
title: '',
background: {
backgroundImage: 'linear-gradient(to right, #FFE5EA 0%, #E4F5FB 49%, #FFF0EE 100%)'
},
list: [],
checked: false,
signDays: 0,
signInList: [],
signInBtn: '点击签到',
isShowMoneyPay: true,
adRewardedVideo: true,
adRewardedVideoloadNum: 0,
urlCallback: null,
}
},
onLoad() {
this.mul(1, 5)
this.formatDecimal(1, 5)
this.div(1, 5)
},
onShow() {
this.getTaskdata()
this.getsignIn()
this.$Request.getT("/app/common/type/919", {}).then(res => {
if (res.code == 0) {
const sysInfo = uni.getSystemInfoSync();
let isIos = sysInfo.platform == 'ios'
this.isShowMoneyPay = !(res.data.value == '1' && isIos)
}
});
this.$nextTick(() => {
this.adRewardedVideoloadNum = 0
this.$refs.adRewardedVideo.load();
})
},
methods: {
onadload(e) {
this.adRewardedVideo = true;
console.log('广告数据加载成功');
},
/**
* 广告加载失败回调
* @param {Object} e
*/
onaderror(e) {
if (this.adRewardedVideoloadNum >= 3) {
this.adRewardedVideo = false;
return
}
this.adRewardedVideoloadNum++
setTimeout(() => {
this.$refs.adRewardedVideo.load();
}, 1000); // 10
console.log("广告加载失败")
},
/**
* 广告播放成功回调
* @param {Object} e
*/
async onadclose(e) {
const detail = e.detail
if (detail && detail.isEnded) {
// 正常播放结束
// /sqx_fast/app/ad/state
let res = await this.$Request.getT('app/ad/state', {
extraKey: this.urlCallback.extra
})
this.$Request.getT('/app/common/type/921').then(res => {
if (res.code == 0) {
console.log(res)
uni.showToast({
title: '获得' + res.data.value + '分钟免费时长',
icon: 'none'
})
}
})
} else {
// 播放中途退出
}
},
//乘法函数,用来得到精确的乘法结果
//说明javascript的乘法结果会有误差在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
//调用mul(arg1,arg2)
//返回值arg1乘以arg2的精确结果
filterDate(d) {
// 获取当前时间
// 循环比较,返回字段
if (d.status == 1) {
return '已签到'
} else {
return '待签到'
// let time1 = d.signDay
// let date1 = new Date(time1);
// let date2 = new Date().getTime() + 8 * 60 * 60;
// if (date1.getTime() < date2) {
// return '未签到'
// } else if (date1.getTime() > date2) {
// return '待签到'
// }
}
},
mul(arg1, arg2) {
var m = 0,
s1 = arg1.toString(),
s2 = arg2.toString();
try {
m += s1.split(".")[1].length;
} catch (e) {
m = 0;
}
try {
m += s2.split(".")[1].length;
} catch (e) {
m = m || 0;
}
return (
(Number(s1.replace(".", "")) * Number(s2.replace(".", ""))) /
Math.pow(10, m)
);
}, //除法函数,用来得到精确的除法结果
//说明javascript的除法结果会有误差在两个浮点数相除的时候会比较明显。这个函数返回较为精确的除法结果。
//调用div(arg1,arg2)
//返回值arg1除以arg2的精确结果
sub(arg1, arg2) {
var r1, r2, m, n;
try {
r1 = arg1.toString().split(".")[1].length;
} catch (e) {
r1 = 0;
}
try {
r2 = arg2.toString().split(".")[1].length;
} catch (e) {
r2 = 0;
}
m = Math.pow(10, Math.max(r1, r2));
//动态控制精度长度
n = r1 >= r2 ? r1 : r2;
return ((arg1 * m - arg2 * m) / m).toFixed(n);
},
add(arg1, arg2) {
var r1, r2, m, n;
try {
r1 = arg1.toString().split(".")[1].length;
} catch (e) {
r1 = 0;
}
try {
r2 = arg2.toString().split(".")[1].length;
} catch (e) {
r2 = 0;
}
m = Math.pow(10, Math.max(r1, r2));
n = r1 >= r2 ? r1 : r2;
return ((arg1 * m + arg2 * m) / m).toFixed(n);
},
div(arg1, arg2) {
var t1 = 0,
t2 = 0,
r1,
r2;
try {
t1 = arg1.toString().split(".")[1].length;
} catch (e) {
t1 = 0;
}
try {
t2 = arg2.toString().split(".")[1].length;
} catch (e) {
t2 = 0;
}
r1 = Number(arg1.toString().replace(".", ""));
r2 = Number(arg2.toString().replace(".", ""));
},
/**
* 保留小数n位不进行四舍五入
* num你传递过来的数字,
* decimal你保留的几位,默认保留小数后两位
* isInt 是否保留0。如12.20 是否保留0
*/
formatDecimal(num, decimal = 2, isInt = false) {
num = num.toFixed(3).toString();
const index = num.indexOf(".");
if (index !== -1) {
num = num.substring(0, decimal + index + 1);
} else {
num = num.substring(0);
}
//截取后保留两位小数
if (isInt) {
return parseFloat(num);
} else {
return parseFloat(num).toFixed(decimal);
}
},
//乘法函数,用来得到精确的乘法结果
//说明javascript的乘法结果会有误差在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
//调用mul(arg1,arg2)
//返回值arg1乘以arg2的精确结果
getsignIn() {
this.$Request.getT('/app/userSignRecord/getUserSignData', {}).then(res => {
if (res.code == 0) {
this.signInList = res.data.recordList
this.signDays = res.data.signDays
// this.signInList.map((item, index) => {
// if (item.showText == '待签到' && index > 0) {
// this.signInBtn = this.signInList[index - 1].status == 0 ? '重新签到' : '点击签到'
// }
// let someDate = new Date(item.signDay); // 假设这是需要判断的日期
// if (item.signDate && this.isToday(someDate)) {
// this.signInBtn = '已签到'
// }
// })
} else {
// uni.showToast({
// title: res.msg,
// icon: 'none'
// })
}
})
},
isToday(date) {
const today = new Date();
return date.getDate() === today.getDate() // 比较日期
&&
date.getMonth() === today.getMonth() // 比较月份
&&
date.getFullYear() === today.getFullYear(); // 比较年份
},
/**
* 跳转
* @param {Object} item
*/
goNav(item) {
// jumpType (integer, optional): 跳转类型 1 内部路径 2 外部路径 ,
// type (integer, optional): 任务类型 1 普通任务 2 打卡任务 9 其它 ,
// buttonUrl
console.log(item, '调试1')
if (item.jumpType == 0) {
if (item.buttonTitle.indexOf("领取") != -1) {
this.taskReceive(item.id)
} else if (item.buttonTitle.indexOf("观看视频") != -1) {
// 首次加载广告
this.urlCallback = {
userId: uni.getStorageSync('userId'),
extra: uni.getStorageSync('userId') + "" + new Date().getTime(),
}
this.$refs.adRewardedVideo.show();
} else {
uni.switchTab({
url: "/pages/index/index2"
})
}
} else if (item.jumpType == 1) {
let source, buttonUrl;
buttonUrl = item.buttonUrl
if (buttonUrl == '/me/invite/index') {
buttonUrl = "/me/yaoqing/ymf-yaoqing-home"
}
if (buttonUrl == '/me/invite/zhifubao') {
buttonUrl = "/me/yaoqing/zhifubao-tixain"
}
if (buttonUrl == '/me/choujiang/choujiang') {
buttonUrl = "/me/VjgyqAzklr/VjgyqAzklr"
}
console.log(buttonUrl, 'debug')
if (item.title && item.title.indexOf('每周打卡奖励') != -1) {
// source = 2
buttonUrl = item.buttonUrl + '?source=2'
}
if (item.title && item.title.indexOf('每月打卡奖励1') != -1) {
source = 3
buttonUrl = item.buttonUrl + '?source=' + source
}
if (item.title && item.title.indexOf('每月打卡奖励2') != -1) {
buttonUrl =
`${item.buttonUrl}?standard=${item.discNumber == null ? true : false}&taskId=${item.id}`
}
console.log(buttonUrl, 'debug')
if (buttonUrl == '/me/invite/index') {
uni.navigateTo({
url: '/me/yaoqing/ymf-yaoqing-home'
})
} else {
uni.navigateTo({
url: buttonUrl
})
}
} else if (item.jumpType == 3) {
uni.switchTab({
url: item.buttonUrl
})
} else if (item.jumpType == 2) {
plus.runtime.openURL(item.buttonUrl)
}
},
/**
* 领取
*/
taskReceive(id) {
let data = {
id: id
}
this.$Request.getT('/app/taskCenter/taskReceive', data).then(res => {
if (res.code == 0) {
uni.showToast({
title: id == 15 ? '签到成功' : '领取成功',
icon: 'none'
})
setTimeout(() => {
this.getTaskdata()
this.getsignIn()
}, 1000)
} else {
uni.switchTab({
url: '/pages/index/index2'
})
}
})
},
/**
* 获取任务列表
*/
getTaskdata() {
this.$Request.getT('/app/taskCenter/selectTaskCenter', {}).then(res => {
if (res.code == 0) {
if (!this.isShowMoneyPay) {
if (res.data[0].title == '分享奖励') {
res.data.shift()
this.list = res.data
} else {
this.list = res.data
}
} else {
this.list = res.data
}
}
uni.stopPullDownRefresh();
})
},
/**
* 下拉加载
*/
onPullDownRefresh: function() {
console.log(2)
this.getTaskdata();
},
}
}
</script>
<style lang="scss">
.container {
width: 100%;
background-color: #F3F4F8;
.task_bg {
width: 100% !important;
height: 494rpx !important;
}
.icon {
.icon_title {
color: #000000;
margin-left: 28rpx;
top: -20rpx;
}
.task_icon1 {
width: 74rpx !important;
height: 78rpx !important;
margin-left: 235rpx;
}
.task_icon2 {
width: 126rpx !important;
height: 120rpx !important;
top: -40rpx;
}
}
.navTitle {
width: 100%;
position: relative;
z-index: 9;
display: flex;
align-items: center;
justify-content: space-between;
padding: 106rpx 28rpx 0 28rpx;
.title {
font-weight: bold;
font-size: 40rpx;
color: #000000;
}
.navTitleIcon {
width: 40.48rpx !important;
height: 46rpx !important;
align-self: flex-end;
}
}
.content {
border-radius: 16rpx;
top: -115rpx;
padding: 28rpx;
.cell {
align-items: center;
padding: 32rpx 0;
border-bottom: 2rpx solid #EBEBEB;
.cell_left {
flex-direction: column;
.cell_title {
align-items: center;
margin-bottom: 12rpx;
color: #333;
.title {
flex-shrink: 0;
}
.cell_icon {
width: 34rpx !important;
height: 34rpx !important;
margin-left: 16rpx;
}
.tip {
margin-left: 22rpx;
color: #FC5B67;
}
}
.subhead {
color: #999;
}
}
.cell_right {
flex-direction: column;
align-items: center;
flex-shrink: 0;
margin-left: 20rpx;
.btn {
width: 148rpx;
height: 56rpx;
line-height: 56rpx;
text-align: center;
background-color: #EC6F48;
color: #FFFFFF;
border-radius: 12rpx 12rpx 12rpx 12rpx;
}
.tip {
color: #EC6F48;
height: 44rpx;
line-height: 44rpx;
margin-top: 5rpx;
}
.opt {
color: #D39B7E;
background-color: #FBF3EB;
}
.disabled {
color: #999999;
background-color: #E2E2E2;
}
}
}
.cell:last-child {
border-bottom: none;
}
}
.signIn {
>.title {
font-weight: 400;
font-size: 32rpx;
color: #666666;
.num {
font-weight: bold;
color: #EC6F48;
margin: 0 10rpx;
}
.dk {
font-weight: 400;
font-size: 24rpx;
color: #333333;
align-items: center;
}
}
.signInList {
margin-top: 24rpx;
margin-bottom: 26rpx;
position: relative;
.line {
width: 92%;
height: 0rpx;
border-radius: 0rpx 0rpx 0rpx 0rpx;
border: 2rpx solid #D8D5D5;
position: absolute;
left: 0;
right: 0;
bottom: 57rpx;
margin: auto;
}
.signIn-Item {
display: flex;
flex-direction: column;
align-items: center;
position: relative;
z-index: 5;
.signIn_icon {
width: 52.33rpx;
height: 51.68rpx;
margin-bottom: 32rpx;
}
.radius {
width: 26rpx;
height: 26rpx;
border-radius: 10rpx;
background-color: #D8D5D5;
}
._label {
font-weight: 400;
font-size: 18rpx;
color: #333333;
margin-top: 24rpx;
}
}
.signIn-Item.active {
.radius {
background-color: #EA9EA8;
}
}
}
.tishi {
width: 100%;
text-align: center;
font-weight: 400;
font-size: 20rpx;
color: #7F7F7F;
margin-top: 20rpx;
}
.signInBtn {
width: 355rpx;
height: 64rpx;
line-height: 64rpx;
font-weight: 400;
font-size: 32rpx;
color: #FFFFFF;
text-align: center;
background: #EA9EA8;
border-radius: 14rpx 14rpx 14rpx 14rpx;
margin: 32rpx auto;
box-shadow: 0 0 0 rgba(234, 158, 168, 0.75);
position: relative;
}
.signInBtnBg {
width: 327rpx;
height: 52rpx;
background: rgba(234, 158, 168, 0.75);
border-radius: 14rpx 14rpx 14rpx 14rpx;
opacity: 0.31;
position: absolute;
bottom: -10rpx;
left: 0;
right: 0;
margin: auto;
}
}
}
</style>