Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(questionnaire): rewrite in hooks #152

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/components/Questionnaire/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
max-height: 500px;
margin-top: 0.5rem;
border-top: 2Px solid var(--wjh-color-border);
transition: all 0.3s;
transition: max-height 0.3s;
}

.questionnaire-title {
flex: 1;
font-size: 1.3rem;
display: flex;
align-items: center;
Expand Down Expand Up @@ -64,4 +65,4 @@
line-height: 200%;
}

}
}
42 changes: 16 additions & 26 deletions src/components/Questionnaire/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
icon-name="questionnaire"
>
<view class="questionnaire-header">
<view class="questionnaire-title" @tap="openQuestionnaire">
<view class="questionnaire-title" @tap="handleOpen">
<view class="iconfont icon-questionnaire" />
<text>调查问卷</text>
</view>
<view class="questionnaire-action">
<template v-if="!isFold">
<template v-if="status !== 'fold'">
<text @tap="toggleFold(true)">
折叠
</text>
Expand All @@ -21,16 +21,16 @@
</text>
<view
class="questionnaire-close-icon iconfont icon-close"
@tap="closeQuesionnaire"
@tap="handleClose"
/>
</template>
</view>
</view>
<view
class="questionnaire-body"
:style="!isFold ? undefined : { maxHeight: 0, margin: 0, border: 0 }"
:style="status != 'fold' ? undefined : { maxHeight: 0, margin: 0, border: 0 }"
>
<view class="default-content" @tap="openQuestionnaire">
<view class="default-content" @tap="handleOpen">
<view>点击卡片参与问卷调查 </view>
<view>为微精弘的更新迭代提出一份建议吧~</view>
</view>
Expand All @@ -42,45 +42,35 @@
import "./index.scss";
import Taro from "@tarojs/taro";
import { ref } from "vue";
import store, { systemStore } from "@/store";
import { questionnaireInfo } from "@/constants/updateInfo";
import useQuestionnaireStore from "@/store/service/questionnaire";
import { storeToRefs } from "pinia";

const { status } = storeToRefs(useQuestionnaireStore());
const showQuestionnaire = ref(true);
const isFold = ref(false);
isFold.value = systemStore.questionnaire.state === "fold" ? true : false;

const closeQuesionnaire = () => {
function handleClose() {
Taro.showModal({
content: "您确定要关闭此选项卡吗?",
cancelText: "仅一次",
confirmText: "永久关闭",
success(res) {
if (res.confirm)
store.commit("setQuestionnaire", {
path: systemStore.questionnaire.path,
state: "close"
});
else if (res.cancel) {
showQuestionnaire.value = false;
}
if (res.confirm) status.value = "close";
else if (res.cancel) showQuestionnaire.value = false;
}
});
};

const toggleFold = (state: boolean) => {
isFold.value = state;
store.commit("setQuestionnaire", {
path: systemStore.questionnaire.path,
state: state ? "fold" : "open"
});
const toggleFold = (value: boolean) => {
status.value = value ? "fold" : "open";
};

const openQuestionnaire = () => {
toggleFold(true);
Taro.navigateToMiniProgram({
const handleOpen = async () => {
await Taro.navigateToMiniProgram({
appId: questionnaireInfo.appId,
path: questionnaireInfo.path
});
toggleFold(true);
};

</script>
1 change: 1 addition & 0 deletions src/constants/updateInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const updateInfo: UpdateInfoType = {
};

export const questionnaireInfo = {
// TODO: 配置化
isAccess: false,
appId: "wxd947200f82267e58",
path: "pages/wjxqList/wjxqList?activityId=O5QdXK"
Expand Down
Loading