|
|
@@ -3,67 +3,51 @@
|
|
|
<view class="task-header">
|
|
|
<view class="task-header-title"
|
|
|
>我的积分<text class="big">{{
|
|
|
- (singInfo && singInfo.total_score) || 0
|
|
|
+ (userInfo && userInfo.score) || 0
|
|
|
}}</text></view
|
|
|
>
|
|
|
<view class="task-header-desc">每日签到做任务可领取积分</view>
|
|
|
- <image
|
|
|
+ <!-- <image
|
|
|
:src="require('@/assets/task/icon-help.png')"
|
|
|
class="invite-icon"
|
|
|
@tap="$refs.popup_info.open()"
|
|
|
- ></image>
|
|
|
+ ></image> -->
|
|
|
</view>
|
|
|
<view class="task-box">
|
|
|
- <view class="task-box-title">签到得积分</view>
|
|
|
- <template v-if="userInfo && singInfo">
|
|
|
- <view class="task-days">
|
|
|
- <view
|
|
|
- v-for="item in singInfo.data"
|
|
|
- :key="item.date"
|
|
|
- :class="['task-day', { 'task-day-active': !!item.is_signin }]"
|
|
|
- >
|
|
|
- <view class="task-day-integral">{{ item.score }}</view>
|
|
|
- {{ item.day_name }}
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- <button class="task-days-btn" @click="handleSing">
|
|
|
- {{ singInfo.is_current_signin ? "今日已签到" : "立即签到" }}
|
|
|
+ <view class="task-btns">
|
|
|
+ <button class="task-btn" @click="uploadFiles">拍照积分</button>
|
|
|
+ <button class="task-btn" :disabled="isSing" @click="handleSing">
|
|
|
+ {{ isSing ? "已签到" : "签到积分" }}
|
|
|
</button>
|
|
|
- </template>
|
|
|
- <button v-else class="task-days-btn" @click="handleSing">
|
|
|
- 登录签到领积分
|
|
|
- </button>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
- <view class="task-box">
|
|
|
- <view class="task-box-title">每日任务得积分</view>
|
|
|
- <view v-if="userInfo && singInfo" class="task-list">
|
|
|
+ <view class="task-box" v-if="photoList.length">
|
|
|
+ <view class="task-box-title">拍照积分记录</view>
|
|
|
+ <view class="task-list">
|
|
|
<view
|
|
|
- v-for="item in singInfo.task"
|
|
|
- :key="item.task_id"
|
|
|
+ v-for="item in photoList"
|
|
|
+ :key="item.id"
|
|
|
class="task-item"
|
|
|
+ @click="handlePreviewImage(item.img)"
|
|
|
>
|
|
|
- <image
|
|
|
- v-if="item.type === 2"
|
|
|
- class="task-item-icon"
|
|
|
- :src="require('@/assets/task/icon-video.png')"
|
|
|
- />
|
|
|
- <image
|
|
|
- v-else
|
|
|
- class="task-item-icon"
|
|
|
- :src="require('@/assets/task/icon-money.png')"
|
|
|
- />
|
|
|
+ <image class="task-item-icon" :src="item.img" />
|
|
|
<view class="task-item-body">
|
|
|
- <view class="task-item-title"
|
|
|
- >{{ item.name
|
|
|
- }}<text class="task-item-label"
|
|
|
- >{{ item.symbol }}{{ item.score }}{{ item.unit }}</text
|
|
|
- ></view
|
|
|
+ <view class="task-item-title" v-if="item.status === 1"
|
|
|
+ >审核通过</view
|
|
|
>
|
|
|
- <view v-if="item.type !== 2" class="task-item-desc"
|
|
|
- >完成 {{ item.finish }}/{{ item.total }}</view
|
|
|
+ <view class="task-item-title" v-else-if="item.status === 2"
|
|
|
+ >审核失败</view
|
|
|
>
|
|
|
+ <view class="task-item-title" v-else>待审核</view>
|
|
|
+ <view class="task-item-desc" v-if="item.reason">{{
|
|
|
+ item.reason
|
|
|
+ }}</view>
|
|
|
+ <view class="task-item-desc">{{ item.upload_time }}</view>
|
|
|
</view>
|
|
|
- <button
|
|
|
+ <view class="task-after" v-if="item.score && item.status === 1"
|
|
|
+ >{{ item.score }}积分</view
|
|
|
+ >
|
|
|
+ <!-- <button
|
|
|
v-if="item.status === 1"
|
|
|
class="task-item-btn receive"
|
|
|
@click="handleReceive(item)"
|
|
|
@@ -73,9 +57,7 @@
|
|
|
<button v-else-if="item.status === 2" class="task-item-btn disabled">
|
|
|
已完成
|
|
|
</button>
|
|
|
- <button v-else class="task-item-btn" @click="handleDoTask(item)">
|
|
|
- 去完成
|
|
|
- </button>
|
|
|
+ <button v-else class="task-item-btn">去完成</button> -->
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -101,13 +83,11 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import api from "@/lib/api/api";
|
|
|
+import { getSingInfo, postSingInfo } from "@/lib/api/task";
|
|
|
+import { getUserInfo } from "@/lib/api/user";
|
|
|
+import { getMyPhotoList } from "@/lib/api/shop";
|
|
|
+import request from "@/lib/utils/request";
|
|
|
import login from "@/lib/utils/login";
|
|
|
-import createShowRewardedVideoAd from "@/lib/utils/showRewardedVideoAd";
|
|
|
-import {
|
|
|
- requestSubscribeMessage,
|
|
|
- defaultTemplateIds,
|
|
|
-} from "@/lib/utils/wxSubscribe";
|
|
|
|
|
|
export default {
|
|
|
name: "PageTask",
|
|
|
@@ -115,6 +95,8 @@ export default {
|
|
|
return {
|
|
|
userInfo: null,
|
|
|
singInfo: null,
|
|
|
+ isSing: false,
|
|
|
+ photoList: [],
|
|
|
};
|
|
|
},
|
|
|
|
|
|
@@ -122,87 +104,83 @@ export default {
|
|
|
const uinfoStr = uni.getStorageSync("userinfo");
|
|
|
if (uinfoStr) {
|
|
|
this.userInfo = JSON.parse(uinfoStr);
|
|
|
- this.getTaskInfo();
|
|
|
+ this.getSingInfo();
|
|
|
+ this.getMyPhotoList();
|
|
|
}
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
- async handleShowAd(item) {
|
|
|
- if (!this.showRewardedVideoAd) {
|
|
|
- this.showRewardedVideoAd = createShowRewardedVideoAd();
|
|
|
- }
|
|
|
- try {
|
|
|
- const res = await this.showRewardedVideoAd();
|
|
|
+ async getUserInfo() {
|
|
|
+ const data = await getUserInfo();
|
|
|
+ this.userInfo = { ...this.userInfo, ...data.data };
|
|
|
+ uni.setStorageSync("userinfo", JSON.stringify(this.userInfo));
|
|
|
+ },
|
|
|
|
|
|
- if (res && res.isEnded) {
|
|
|
- this.adComplete(item);
|
|
|
- }
|
|
|
- } catch (e) {
|
|
|
- uni.showToast({
|
|
|
- icon: "none",
|
|
|
- title: e?.errMsg || "广告播放失败",
|
|
|
- duration: 2e3,
|
|
|
- mask: true,
|
|
|
- });
|
|
|
- }
|
|
|
+ async getSingInfo() {
|
|
|
+ const res = await getSingInfo();
|
|
|
+ this.isSing = !!res.is_signin;
|
|
|
},
|
|
|
|
|
|
async handleSing() {
|
|
|
- if (!this.userInfo || !this.userInfo.session) {
|
|
|
- await this.login();
|
|
|
- }
|
|
|
- if (this.singInfo.is_current_signin) {
|
|
|
+ if (this.isSing) {
|
|
|
uni.showToast({
|
|
|
icon: "none",
|
|
|
- title: "今日已签到",
|
|
|
- duration: 2e3,
|
|
|
- mask: true,
|
|
|
+ title: "已签到",
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
- try {
|
|
|
- // #ifdef MP-WEIXIN
|
|
|
- await requestSubscribeMessage(defaultTemplateIds).catch(() => void 0);
|
|
|
- // #endif
|
|
|
-
|
|
|
- const data = await api.userNewSingIn({
|
|
|
- session: this.userInfo.session,
|
|
|
- });
|
|
|
- this.singInfo = { ...this.singInfo, ...data };
|
|
|
-
|
|
|
- if (data.errno === 10000) {
|
|
|
- uni.showToast({
|
|
|
- icon: "success",
|
|
|
- title: "签到成功",
|
|
|
- duration: 2e3,
|
|
|
- mask: true,
|
|
|
- });
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- icon: "none",
|
|
|
- title: data.errmsg || "签到失败,请重试",
|
|
|
- duration: 2e3,
|
|
|
- mask: true,
|
|
|
- });
|
|
|
- }
|
|
|
- } catch (e) {
|
|
|
+ const res = await postSingInfo();
|
|
|
+ if (res.errno === 10000) {
|
|
|
uni.showToast({
|
|
|
icon: "none",
|
|
|
- title: "签到失败,请重试",
|
|
|
- duration: 2e3,
|
|
|
- mask: true,
|
|
|
+ title: "签到成功",
|
|
|
});
|
|
|
+ this.isSing = true;
|
|
|
+ this.getUserInfo();
|
|
|
+ return;
|
|
|
}
|
|
|
+ uni.showToast({
|
|
|
+ icon: "none",
|
|
|
+ title: res.errmsg,
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
- async getTaskInfo() {
|
|
|
- if (!this.userInfo.session) {
|
|
|
- return Promise.reject();
|
|
|
- }
|
|
|
- const data = await api.getTaskInfo(this.userInfo.session);
|
|
|
- data.task = (data.task || []).sort((a, b) => a.sort - b.sort);
|
|
|
- this.singInfo = data;
|
|
|
+ async getMyPhotoList() {
|
|
|
+ const res = await getMyPhotoList();
|
|
|
+ this.photoList = res?.data || [];
|
|
|
+ },
|
|
|
+
|
|
|
+ uploadFiles() {
|
|
|
+ uni.chooseImage({
|
|
|
+ count: 1,
|
|
|
+ success: (chooseImageRes) => {
|
|
|
+ const tempFilePaths = chooseImageRes.tempFilePaths;
|
|
|
+ uni.uploadFile({
|
|
|
+ url: "https://yggc.weapp.yergoo.com/weapp/score/photo/upload", //仅为示例,非真实的接口地址
|
|
|
+ filePath: tempFilePaths[0],
|
|
|
+ name: "f",
|
|
|
+ header: request.getCommonHeader(),
|
|
|
+ timeout: 30000,
|
|
|
+ success: (uploadFileRes) => {
|
|
|
+ const res = JSON.parse(uploadFileRes.data);
|
|
|
+ console.log(res);
|
|
|
+ uni.showToast({
|
|
|
+ icon: "none",
|
|
|
+ title: res.errno === 10000 ? "上传成功" : res.errmsg,
|
|
|
+ });
|
|
|
+ if (res.errno === 10000) this.getMyPhotoList();
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ handlePreviewImage(url) {
|
|
|
+ uni.previewImage({
|
|
|
+ urls: [url],
|
|
|
+ });
|
|
|
},
|
|
|
+
|
|
|
login() {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
login.wxLogin(async (userInfo) => {
|
|
|
@@ -225,72 +203,6 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
- async adComplete(item) {
|
|
|
- try {
|
|
|
- const data = await api.setAdTask({
|
|
|
- session: this.userInfo.session,
|
|
|
- task_id: `${item.task_id}`,
|
|
|
- });
|
|
|
- if (data.errno === 10000) {
|
|
|
- this.handleReceive(item);
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- icon: "none",
|
|
|
- title: data.errmsg || "领取失败",
|
|
|
- duration: 2e3,
|
|
|
- mask: true,
|
|
|
- });
|
|
|
- }
|
|
|
- } catch (e) {
|
|
|
- uni.showToast({
|
|
|
- icon: "none",
|
|
|
- title: "领取失败",
|
|
|
- duration: 2e3,
|
|
|
- mask: true,
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- handleDoTask(item) {
|
|
|
- if (item.type === 2) {
|
|
|
- this.handleShowAd(item);
|
|
|
- } else {
|
|
|
- uni.switchTab({
|
|
|
- url: "/pages/index/index",
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- async handleReceive(item) {
|
|
|
- uni.showLoading({ title: "领取中", mask: true });
|
|
|
- try {
|
|
|
- const data = await api.getTaskScore({
|
|
|
- session: this.userInfo.session,
|
|
|
- task_id: `${item.task_id}`,
|
|
|
- });
|
|
|
- uni.hideLoading();
|
|
|
- if (data.errno === 10000) {
|
|
|
- data.task = (data.task || []).sort((a, b) => a.sort - b.sort);
|
|
|
- this.singInfo = {
|
|
|
- ...this.singInfo,
|
|
|
- ...data,
|
|
|
- };
|
|
|
- uni.showToast({
|
|
|
- icon: "success",
|
|
|
- title: "领取成功",
|
|
|
- duration: 2e3,
|
|
|
- mask: true,
|
|
|
- });
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- icon: "none",
|
|
|
- title: data.errmsg || "领取失败",
|
|
|
- duration: 2e3,
|
|
|
- mask: true,
|
|
|
- });
|
|
|
- }
|
|
|
- } catch (e) {
|
|
|
- uni.hideLoading();
|
|
|
- }
|
|
|
- },
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
|
@@ -301,6 +213,8 @@ export default {
|
|
|
overflow: hidden;
|
|
|
background: #f6f6f6;
|
|
|
min-height: 100vh;
|
|
|
+ box-sizing: border-box;
|
|
|
+ padding-bottom: 60rpx;
|
|
|
|
|
|
.task-header {
|
|
|
box-sizing: border-box;
|
|
|
@@ -347,7 +261,7 @@ export default {
|
|
|
.task-box-title {
|
|
|
height: 54rpx;
|
|
|
font-size: 42rpx;
|
|
|
- font-family: ysbth;
|
|
|
+ // font-family: ysbth;
|
|
|
color: #000000;
|
|
|
line-height: 54rpx;
|
|
|
margin-bottom: 12rpx;
|
|
|
@@ -456,6 +370,9 @@ export default {
|
|
|
color: #ffffff;
|
|
|
}
|
|
|
}
|
|
|
+ .task-after {
|
|
|
+ color: #22c8c9;
|
|
|
+ }
|
|
|
.task-item-body {
|
|
|
flex: 1;
|
|
|
width: 0;
|
|
|
@@ -481,4 +398,16 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+.task-btns {
|
|
|
+ display: flex;
|
|
|
+ .task-btn {
|
|
|
+ flex: 1;
|
|
|
+ border-radius: 1000px;
|
|
|
+ background-color: #08c2c3;
|
|
|
+ margin: 0 20rpx;
|
|
|
+ &::after {
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|