Skip to content

Commit

Permalink
添加签到功能
Browse files Browse the repository at this point in the history
  • Loading branch information
wyndem committed Aug 21, 2023
1 parent 79805f2 commit a51de02
Show file tree
Hide file tree
Showing 6 changed files with 205 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VITE_VERSION='2.1.3'
VITE_VERSION='2.1.4'
43 changes: 33 additions & 10 deletions src/api/aliyun.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,36 @@ export const createSessionUrl=(data,signature,deviceId)=>axios({



// export const getDownloadUrl=(data)=>axios({
// method: 'post',
// url:'/v2/file/get_download_url',
// data:{
// ...data
// },
// headers:{
// '_token':false
// }
// })
/**
* 签到
*/
export const signInList=()=>axios({
method: 'post',
url:'https://member.aliyundrive.com/v1/activity/sign_in_list',
data:{
"_rx-s": "mobile"
},
headers:{
'content-type': 'application/json;charset=UTF-8',
'_token':false
}

})


/**
* 签到 领取奖励
* @param signInDay 领取第几天的奖励
*/
export const signInReward=(signInDay)=>axios({
method: 'post',
url:'https://member.aliyundrive.com/v1/activity/sign_in_reward',
data:{
"signInDay": signInDay
},
headers:{
'content-type': 'application/json;charset=UTF-8',
'_token':false
}

})
31 changes: 30 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


import { ElMessage } from 'element-plus'
import { ElMessage,ElMessageBox } from 'element-plus'
import { listen } from './api/intercept'
import user from './util/user'
import ui from './ui/index'
Expand Down Expand Up @@ -46,6 +46,35 @@ function start() {


function run(val) {

$(function() {

var versionRegex = /\/(\d+\.\d+\.\d+)/;
var scriptSrc = $('script[src*="bundle.js"]').attr('src');
var match = scriptSrc.match(versionRegex);
var version = match ? match[1] : null; // 提取匹配到的版本号
console.log("UI版本: "+version)
if(version == '4.6.0'){
ElMessageBox.confirm('目前版本不兼容老版本UI,点击按钮安装兼容版本:v2.1.2?',"提示",{
confirmButtonText: '确定',
showCancelButton: false,
closeOnClickModal: false,
closeOnPressEscape: false,
showClose: false
})
.then(() => {
var url = 'https://greasyfork.org/zh-CN/scripts/458626?version=1219577';
window.open(url, '_blank');
})
.catch(() => {

})
}
});




setInterval(user.refSession, 300000);
user.refSession()
ui()
Expand Down
144 changes: 126 additions & 18 deletions src/page/SignInPage.vue
Original file line number Diff line number Diff line change
@@ -1,29 +1,137 @@
<script setup>
import { ref, onMounted,computed } from "vue";
import user from '../util/user';
import { ElSwitch, ElForm, ElFormItem } from 'element-plus'
import { signInList, signInReward } from "../api/aliyun"
import { showSuccess, showError } from "../ui/util";
const signInSwitch = ref(false)
const signInSet= ref({
goods_info:{
name:"",
description:"",
notice:""
}
})
const isSigIn = computed(() => {
// 在这里编写计算属性的逻辑
return isSignIn();
});
/** 签到 */
async function signIn() {
const data =await signInList();
if (data.status !== 200) {
showError("签到失败,服务器响应:" + data.status)
return
}
let signin_count = data.data['result']['signInCount']; // 获取签到次数
console.log(signin_count)
var reward = await signInReward(signin_count);
if (data.status !== 200) {
showError("领取奖励失败,服务器响应:" + reward.status)
return
}
const res = reward.data;
let rewardName = res["result"]["name"];
let rewardDescription = res["result"]["description"];
let rewardNotice= res["result"]["notice"];
signInSet.value['last_siginIn'] = getNowDate();
signInSet.value['goods_info'] = {
name: rewardName,
description: rewardDescription,
notice: rewardNotice
}
showSuccess(rewardNotice)
user.setSignInSet(signInSet.value)
}
const changeEvent = () => {
signInSet.value['status'] = signInSwitch.value
if(!isSignIn() && signInSwitch.value) {
signIn()
}
user.setSignInSet(signInSet.value)
}
function getNowDate() {
var currentDate = new Date();
var year = currentDate.getFullYear();
var month = currentDate.getMonth() + 1;
var day = currentDate.getDate();
return year + '' + month + '' + day;
}
/**
* 已签到 true
* 末签到 false
*/
function isSignIn(){
const now = getNowDate();
return signInSet.value['last_siginIn'] == now
}
onMounted(async () => {
let _signInSet = user.getSignInSet()
if(Object.keys(_signInSet).length > 0){
signInSet.value=_signInSet;
}
signInSwitch.value = _signInSet['status'] == true;
if(!isSignIn() && signInSwitch.value) {
signIn()
}
})
</script>

<template>
<span class="text--dDJGu">
signIn
</span>

<p>
<span v-if="isSigIn" class="notice">今日:已签到</span> <br />
<span v-if="!isSigIn" class="notice2">今日:末签到</span>
<p v-if="isSigIn" class="notice">

{{ signInSet.goods_info.name }}<br />
{{ signInSet.goods_info.description }}<br />
</p>

</p>
<el-form style="max-width: 100%">
<el-form-item label="自动签到">
<el-switch v-model="signInSwitch" inline-prompt active-text="" inactive-text="" @change="changeEvent"/>
</el-form-item>
</el-form>
</template>

<style scoped>
.text--dDJGu {
margin-bottom: 12px;
line-height: 30px;
-ms-flex-align: center;
align-items: center;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
font-size: 15px;
line-height: 1.6;
-ms-flex-pack: justify;
justify-content: space-between;
color: var(--context_primary);
.notice {
color: #6592F9;
font-size: 8pt;
}
.notice2 {
color: red;
font-size: 8pt;
}
</style>
2 changes: 1 addition & 1 deletion src/ui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function signInUi(){
app.mount(
(() => {
const app = document.createElement('div');
storage.append(app);
storage.prepend (app);
return app;
})(),
);
Expand Down
14 changes: 14 additions & 0 deletions src/util/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ class User {
return this.video;
}

/**
* 获取自动签到设置
*
*/
getSignInSet(){
let config= store.getItem("signIn_config")
return config == '' ? {} :config
}

setSignInSet(signInInfo){
return store.setItem("signIn_config",signInInfo)
}

//保存当前播放器设置
saveVideoPlayerSet(art){

Expand Down Expand Up @@ -136,6 +149,7 @@ class User {
store.removeItem('x-signature')
store.removeItem('deviceName')
store.removeItem('modelName')
store.removeItem('signIn_config')
}

clearAll(){
Expand Down

0 comments on commit a51de02

Please sign in to comment.