Skip to content

Commit

Permalink
feat: 实现了每天第一次登陆奖励小鱼干 (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
buluu97 committed Dec 7, 2023
1 parent bba7c3d commit 1393e64
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/apis/auth/auth-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ export interface SetPasswordResp {
code: number;
msg: string;
}

export interface CheckIn {
isFirst: true;
getFishNum: 0;
}
38 changes: 36 additions & 2 deletions src/apis/auth/auth.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import {
GignInResp,
SendVerifyCodeReq,
SendVerifyCodeResp,
SetPasswordReq,
SetPasswordResp,
SignInReq,
GignInResp
SignInReq
} from "./auth-interfaces";
import { getPrefetchData } from "@/apis/prefetch";
import { StorageKeys } from "@/utils/const";
import { UserCheckInResp } from "@/apis/user/user-interfaces";

/**
* @description
Expand Down Expand Up @@ -38,6 +40,22 @@ export function signIn(req: SignInReq) {
});
}

/*const signInRes= await signIn({
authType: "wechat",
authId: appId,
verifyCode: res.code,
appId: AppId
});
uni.setStorageSync(StorageKeys.AccessToken, {
token: signInRes.accessToken,
expireTime: signInRes.accessExpire
});
uni.setStorageSync(StorageKeys.UserId,signInRes.userId);
if(signInRes.accessToken) {
const checkInRes = await checkIn();
uni.setStorageSync('checkInInfo',JSON.stringify(checkInRes));
}*/

/**
* @description
* @param req
Expand Down Expand Up @@ -79,3 +97,19 @@ export async function sendVerifyCode(req: SendVerifyCodeReq) {
});
});
}

/*async function checkIn(): Promise<string | AnyObject | ArrayBuffer> {
try {
const response = await uni.request({
url: "/api/check_in",
data: {
token: signInRes.accessToken
},
method: "GET",
});
const data: string | AnyObject | ArrayBuffer = response.data;
return response.data;
} catch (error) {
throw error;
}
}*/
15 changes: 15 additions & 0 deletions src/apis/community/community.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,18 @@ export async function listCommunity(req: ListCommunityReq) {
export function clearCache() {
cache = null;
}

/*export function onLoad() {
const checkInInfoStr = uni.getStorageSync('checkInInfo');
if (checkInInfoStr) {
const checkInInfo = JSON.parse(checkInInfoStr);
if (checkInInfo.isFirst) {
this.showToastBox = true;
this.gotFishNum += 30;
checkInInfo.isFirst = false;
checkInInfo.getFishNum += 30;
uni.setStorageSync('checkInInfo', JSON.stringify(checkInInfo));
}
}*/
1 change: 1 addition & 0 deletions src/apis/user/user-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ export interface UpdateUserInfoResp {

export interface UserCheckInResp {
isFirst: boolean;
getFirst: boolean;
getFishNum: number;
}
2 changes: 1 addition & 1 deletion src/pages/community/community.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ onReady(() => {
const checkIn = async () => {
const resp = await userCheckIn();
console.log(resp);
if (resp.isFirst) {
if (resp.getFish) {
gottenFishAmount.value = resp.getFishNum;
showToastBox.value = true;
}
Expand Down
6 changes: 3 additions & 3 deletions src/pages/plan/plan-details/Cards.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
</div>

<view class="time"
>募集时间: {{ displayDate(props.plan.startTime) }} ~
{{ displayDate(props.plan.endTime) }}</view
>募集时间: {{ displayDate(props.plan.startTime, "YYYY/MM/DD") }} -
{{ displayDate(props.plan.endTime, "YYYY/MM/DD") }}</view
>

<div class="dialog-box">
Expand Down Expand Up @@ -308,7 +308,7 @@ const nowPicIndex = ref<number>(0);
.progress {
width: 60vw;
height: 2vw;
background: linear-gradient(to right, #191970, #0000ff, #1e90ff);
background: linear-gradient(to right, #0000ff, #1e90ff);
border-radius: 1vw;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/plan/plan-details/DonatePanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ const decrement = () => {
flex-direction: column;
justify-content: center;
margin-bottom: 20px;
border: 1vw solid skyblue;
border: 0.5vw solid dodgerblue;
box-shadow: 0 0 2vw rgba(28, 140, 248, 0.5);
border-radius: 5vw;
height: 20vh;
width: 80vw;
Expand Down

0 comments on commit 1393e64

Please sign in to comment.