Browse Source

feat: 广告页、引导页改为组件

test2
xuesinan 4 years ago
parent
commit
2be7903127
  1. 8
      App.vue
  2. 1
      CHANGELOG.md
  3. 99
      components/Adv/Adv.vue
  4. 76
      components/Guide/Guide.vue
  5. 6
      components/Title/Title.vue
  6. 28
      pages.json
  7. 40
      pages/guide/adv.vue
  8. 340
      pages/index/index.vue
  9. 10
      store/index.js

8
App.vue

@ -24,8 +24,16 @@ export default {
} }
// 广 // 广
// #ifdef APP-PLUS
uni.$storage.setStorageSync('isOpenApp', true);
this.$store.commit('setIsOpenApp', true);
// App
let firstOpenApp = uni.$storage.getStorageSync('firstOpenApp');
this.$store.commit('setFirstOpenApp');
this.getGuide(0); this.getGuide(0);
this.getGuide(1); this.getGuide(1);
// #endif
// //
if (!uni.$storage.getStorageSync('businessPlugin')) { if (!uni.$storage.getStorageSync('businessPlugin')) {

1
CHANGELOG.md

@ -44,6 +44,7 @@
- | 主体颜色 | [bb5c0e3](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/bb5c0e3) - | 主体颜色 | [bb5c0e3](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/bb5c0e3)
- | 注册、用户协议 | [68e9189](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/68e9189) - | 注册、用户协议 | [68e9189](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/68e9189)
- | app.vue | [970cf9a](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/970cf9a) - | app.vue | [970cf9a](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/970cf9a)
- | app端请求路径不对 | [b31fa14](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/b31fa14)
deliver 交付物 | 点击交付物链接webview打开链接 | [daa59f1](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/daa59f1) deliver 交付物 | 点击交付物链接webview打开链接 | [daa59f1](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/daa59f1)
- | first commit | [8dc26de](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/8dc26de) - | first commit | [8dc26de](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/8dc26de)
- | get请求 | [3a61439](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/3a61439) - | get请求 | [3a61439](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/3a61439)

99
components/Adv/Adv.vue

@ -0,0 +1,99 @@
<template>
<view class="adv-box relative">
<swiper v-if="imgs.length > 0" class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" circular="true">
<swiper-item v-for="(item, index) in imgs" :key="index">
<view class="swiper-item">
<image :src="item"></image>
</view>
</swiper-item>
</swiper>
<image v-else src="/common/img/adv.jpg"></image>
<view class="time-box absolute">{{ time }} 跳过</view>
</view>
</template>
<script setup>
import { ref, computed, watch } from 'vue';
import { useStore } from 'vuex';
const store = useStore();
const indicatorDots = true;
const autoplay = true;
const advs = computed(() => store.state.advs);
const imgs = ref([]);
if (advs.value) {
imgs.value = JSON.parse(advs.value);
}
watch(advs, () => {
imgs.value = JSON.parse(advs.value);
})
const time = ref(5);
let timer = setInterval(() => {
time.value--;
if (time.value === 0) {
clearInterval(timer);
uni.$storage.setStorageSync('isOpenApp', false);
store.commit('setIsOpenApp', false);
}
}, 1000);
// setTimeout(() => {
// // App
// let firstOpenApp = uni.$storage.getStorageSync('firstOpenApp');
// if (firstOpenApp) {
// // uni.navigateTo({
// // url: '/pages/index/index'
// // })
// } else {
// uni.$storage.setStorageSync('firstOpenApp', true);
// store.commit('setFirstOpenApp');
// // uni.navigateTo({
// // url: '/pages/guide/guide'
// // })
// }
// }, 5000);
</script>
<style lang="scss" scoped>
.adv-box {
width: 100%;
height: 100%;
image {
width: 100%;
height: 100%;
object-fit: cover;
}
}
.swiper {
height: 100%;
}
.swiper-item {
width: 100%;
height: 100%;
}
.time-box {
bottom: 50px;
right: 10px;
display: inline-block;
width: 60px;
height: 24px;
line-height: 22px;
font-size: 12px;
text-align: center;
background-color: rgba(255, 255, 255, .7);
border-radius: 12px;
color: #666;
border: 1px solid #eee;
}
</style>

76
components/Guide/Guide.vue

@ -0,0 +1,76 @@
<template>
<!-- indicator-dots 是否显示面板指示点 -->
<!-- indicator-color 指示点颜色 -->
<!-- indicator-active-color 当前选中的指示点颜色 -->
<swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay">
<swiper-item v-for="(item, index) in imgs" :key="index">
<view class="swiper-item relative">
<image :src="item"></image>
<u-button class="btn absolute" v-if="index === imgs.length - 1" @click="toIndex">点击进入APP</u-button>
</view>
</swiper-item>
</swiper>
</template>
<script setup>
import { ref, computed, watch } from 'vue';
import { useStore } from 'vuex';
const store = useStore();
const indicatorDots = true;
const autoplay = false;
const guide = computed(() => store.state.guide);
const imgs = ref([]);
if (guide.value) {
imgs.value = JSON.parse(guide.value);
}
watch(guide, () => {
imgs.value = JSON.parse(guide.value);
})
function toIndex() {
uni.$storage.setStorageSync('firstOpenApp', true);
store.commit('setFirstOpenApp');
// uni.navigateTo({
// url: '/pages/index/index'
// })
}
</script>
<style lang="scss" scoped>
.swiper {
height: 100%;
image {
width: 100%;
height: 100%;
object-fit: cover;
}
}
.swiper-item {
width: 100%;
height: 100%;
.btn {
bottom: 200px;
display: inline-block;
height: 40px;
line-height: 38px;
background-color: #ECF5FF;
left: 50%;
transform: translateX(-50%);
border-radius: 20px;
color: #2B85E4;
border: 1px solid #2B85E4;
&:after {
border: none;
}
}
}
</style>

6
components/Title/Title.vue

@ -102,7 +102,8 @@ function onBack() {
uni.navigateBack(); uni.navigateBack();
} else { } else {
// this.$u.route('/', { u: this.userId }); // this.$u.route('/', { u: this.userId });
uni.reLaunch({ url: `/pages/index/index?u=${userId.value}` }); // uni.reLaunch({ url: `/pages/index/index?u=${userId.value}` });
uni.reLaunch({ url: `/pages/index/index` });
} }
} }
@ -116,7 +117,8 @@ function projectOverview() {
} }
// //
function openIndex() { function openIndex() {
uni.webView.reLaunch({ url: `/pages/index/index?u=${this.userId}` }); // uni.webView.reLaunch({ url: `/pages/index/index?u=${this.userId}` });
uni.reLaunch({ url: `/pages/index/index` });
} }
// //

28
pages.json

@ -1,19 +1,19 @@
{ {
"pages": [ //pageshttps://uniapp.dcloud.io/collocation/pages "pages": [ //pageshttps://uniapp.dcloud.io/collocation/pages
{ // {
"path": "pages/guide/adv", // "path": "pages/guide/adv",
"style": { // "style": {
"navigationBarText": "TALL", // "navigationBarText": "TALL",
"navigationStyle": "custom" // "navigationStyle": "custom"
} // }
}, // },
{ // {
"path": "pages/guide/guide", // "path": "pages/guide/guide",
"style": { // "style": {
"navigationBarText": "TALL", // "navigationBarText": "TALL",
"navigationStyle": "custom" // "navigationStyle": "custom"
} // }
}, // },
{ {
"path": "pages/index/index", "path": "pages/index/index",
"style": { "style": {

40
pages/guide/adv.vue

@ -11,9 +11,9 @@
<image v-else src="/common/img/adv.jpg"></image> <image v-else src="/common/img/adv.jpg"></image>
<view class="time-box absolute">{{ time }} 跳过</view> <view class="time-box absolute">{{ time }} 跳过</view>
</view> </view>
</template> </template>
<script setup> <script setup>
import { ref, computed, watch } from 'vue'; import { ref, computed, watch } from 'vue';
import { useStore } from 'vuex'; import { useStore } from 'vuex';
@ -38,24 +38,24 @@
time.value--; time.value--;
if (time.value === 1) clearInterval(timer); if (time.value === 1) clearInterval(timer);
}, 1000); }, 1000);
setTimeout(() => { setTimeout(() => {
// App // App
let openNum = uni.$storage.getStorageSync('fistOpenApp'); let openNum = uni.$storage.getStorageSync('firstOpenApp');
if (openNum === 'true') { if (openNum === 'true') {
uni.navigateTo({ uni.navigateTo({
url: '/pages/index/index' url: '/pages/index/index'
}) })
} else { } else {
uni.$storage.setStorageSync('fistOpenApp', 'true'); uni.$storage.setStorageSync('firstOpenApp', true);
uni.navigateTo({ uni.navigateTo({
url: '/pages/guide/guide' url: '/pages/guide/guide'
}) })
} }
}, 5000); }, 5000);
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.adv-box { .adv-box {
width: 100%; width: 100%;
@ -90,5 +90,5 @@
border-radius: 12px; border-radius: 12px;
color: #666; color: #666;
border: 1px solid #eee; border: 1px solid #eee;
} }
</style> </style>

340
pages/index/index.vue

@ -1,165 +1,177 @@
<template> <template>
<!-- 这里是适配的状态栏的代码 --> <!-- #ifdef APP-PLUS -->
<view class="statbar"> <!-- 广告 -->
<view class="status_bar"></view> <Adv v-if="isOpenApp"></Adv>
</view>
<!-- 引导页 -->
<!-- <view class="flex flex-col h-full bg-gray-50" @click="openAuth"> --> <Guide v-if="!firstOpenApp"></Guide>
<theme class="flex flex-col h-full bg-gray-50"> <!-- #endif -->
<view class="relative">
<!-- <view class="relative" @touchmove="onMove"> --> <view>
<!-- 日历 --> <!-- 这里是适配的状态栏的代码 -->
<Calendar @selected-change="onDateChange" :show-back="true" ref="calendar" @handleFindPoint="handleFindPoint" /> <view class="statbar">
<view class="status_bar"></view>
<!-- 上传 导入wbs --> </view>
<Upload @success="onUploadSuccess" @error="onUploadError" />
</view> <!-- <view class="flex flex-col h-full bg-gray-50" @click="openAuth"> -->
<theme class="flex flex-col h-full bg-gray-50">
<u-button class="mt-4" @click="toLogin">登录</u-button> <view class="relative">
<!-- 项目列表 --> <!-- <view class="relative" @touchmove="onMove"> -->
<Projects @getProjects="getProjects" class="flex-1 overflow-y-auto" /> <!-- 日历 -->
<Calendar @selected-change="onDateChange" :show-back="true" ref="calendar" @handleFindPoint="handleFindPoint" />
<!-- 全局提示框 -->
<u-top-tips ref="uTips"></u-top-tips> <!-- 上传 导入wbs -->
</theme> <Upload @success="onUploadSuccess" @error="onUploadError" />
</template> </view>
<script setup> <u-button class="mt-4" @click="toLogin">登录</u-button>
import { reactive, computed, watchEffect, ref } from 'vue'; <!-- 项目列表 -->
import { useStore } from 'vuex'; <Projects @getProjects="getProjects" class="flex-1 overflow-y-auto" />
import dayjs from 'dayjs';
<!-- 全局提示框 -->
const store = useStore(); <u-top-tips ref="uTips"></u-top-tips>
const token = computed(() => store.state.user.token); </theme>
const uTips = ref(null); </view>
</template>
const data = reactive({
calendar: null, <script setup>
// days: [], import { reactive, computed, watchEffect, ref } from 'vue';
}); import { useStore } from 'vuex';
import dayjs from 'dayjs';
getProjects();
handleFindPoint(); const store = useStore();
const token = computed(() => store.state.user.token);
// token const uTips = ref(null);
// watchEffect(() => { const firstOpenApp = computed(() => store.state.firstOpenApp);
// if (!token.value) return; const isOpenApp = computed(() => store.state.isOpenApp); // APP
// if (token.value) {
// getProjects(); const data = reactive({
// handleFindPoint(); calendar: null,
// } // days: [],
// }); });
// getProjects();
function getProjects(start = dayjs().startOf('day').valueOf(), end = dayjs().endOf('day').valueOf()) { handleFindPoint();
uni.$catchReq.getProjects(start, end, (err, data) => {
if (err) { // token
console.error('err: ', err); // watchEffect(() => {
} else { // if (!token.value) return;
data.forEach(item => { // if (token.value) {
item.show = false; // getProjects();
}); // handleFindPoint();
store.commit('project/setProjects', data); // }
} // });
});
} //
function getProjects(start = dayjs().startOf('day').valueOf(), end = dayjs().endOf('day').valueOf()) {
async function handleFindPoint(start, end) { uni.$catchReq.getProjects(start, end, (err, data) => {
try { if (err) {
const startTime = start || dayjs().startOf('month').valueOf(); console.error('err: ', err);
const endTime = end || dayjs().endOf('month').valueOf(); } else {
const res = await uni.$u.api.findRedPoint(startTime, endTime); data.forEach(item => {
store.commit('project/setDotList', res); item.show = false;
} catch (error) { });
console.log('error: ', error); store.commit('project/setProjects', data);
} }
} });
}
//
const onDateChange = event => { async function handleFindPoint(start, end) {
const day = dayjs(event.fullDate); try {
const start = day.startOf('date').valueOf(); const startTime = start || dayjs().startOf('month').valueOf();
const end = day.endOf('date').valueOf(); const endTime = end || dayjs().endOf('month').valueOf();
getProjects(start, end); const res = await uni.$u.api.findRedPoint(startTime, endTime);
}; store.commit('project/setDotList', res);
} catch (error) {
// console.log('error: ', error);
const onUploadSuccess = () => { }
uni.$ui.showToast('导入成功,即将打开新项目', 3000); }
// uTips.show({
// title: '', //
// type: 'success', const onDateChange = event => {
// duration: '3000', const day = dayjs(event.fullDate);
// }); const start = day.startOf('date').valueOf();
}; const end = day.endOf('date').valueOf();
getProjects(start, end);
// };
const onUploadError = error => {
uni.$ui.showToast('导入失败', 6000); //
// uTips.show({ const onUploadSuccess = () => {
// title: error || '', uni.$ui.showToast('导入成功,即将打开新项目', 3000);
// type: 'error', // uTips.show({
// duration: '6000', // title: '',
// }); // type: 'success',
}; // duration: '3000',
// });
// / };
// function onMove(event) {
// const y = event.changedTouches[0].pageY; //
// const prevY = 0; const onUploadError = error => {
// if (y - prevY > 0) { uni.$ui.showToast('导入失败', 6000);
// // weekMode=true weekMode=false // uTips.show({
// data.calendar.weekMode && (data.calendar.weekMode = false); // title: error || '',
// } else if (y - prevY < 0) { // type: 'error',
// // weekMode=false weekMode=true // duration: '6000',
// !data.calendar.weekMode && (data.calendar.weekMode = true); // });
// } };
// prevY = y;
// data.calendar.initDate(); // /
// } // function onMove(event) {
// const y = event.changedTouches[0].pageY;
function toLogin() { // const prevY = 0;
uni.navigateTo({ // if (y - prevY > 0) {
url: '/pages/user/login' // // weekMode=true weekMode=false
}); // data.calendar.weekMode && (data.calendar.weekMode = false);
} // } else if (y - prevY < 0) {
</script> // // weekMode=false weekMode=true
// !data.calendar.weekMode && (data.calendar.weekMode = true);
<style lang="scss" scoped> // }
.statbar { // prevY = y;
width: 750rpx; // data.calendar.initDate();
height: var(--status-bar-height); // }
.status_bar { function toLogin() {
height: var(--status-bar-height); uni.navigateTo({
width: 100%; url: '/pages/user/login'
position: absolute; });
} }
} </script>
.content { <style lang="scss" scoped>
display: flex; .statbar {
flex-direction: column; width: 750rpx;
align-items: center; height: var(--status-bar-height);
justify-content: center;
} .status_bar {
height: var(--status-bar-height);
.logo { width: 100%;
height: 200rpx; position: absolute;
width: 200rpx; }
margin-top: 200rpx; }
margin-left: auto;
margin-right: auto; .content {
margin-bottom: 50rpx; display: flex;
} flex-direction: column;
align-items: center;
.text-area { justify-content: center;
display: flex; }
justify-content: center;
} .logo {
height: 200rpx;
.title { width: 200rpx;
font-size: 36rpx; margin-top: 200rpx;
color: #8f8f94; margin-left: auto;
} margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style> </style>

10
store/index.js

@ -20,6 +20,8 @@ const state = {
advs: '', // 广告图片json advs: '', // 广告图片json
businessPlugin: [], // 所有服务 businessPlugin: [], // 所有服务
allPlugin: [], // 所有插件 allPlugin: [], // 所有插件
firstOpenApp: false, // 是否是第一次打开APP或者引导页有更新,false表示从未打开过,true表示打开过
isOpenApp: true, // 是否打开APP
}; };
const getters = { const getters = {
@ -111,6 +113,14 @@ const mutations = {
*/ */
setAllPlugin(state, data) { setAllPlugin(state, data) {
state.allPlugin = data; state.allPlugin = data;
},
setFirstOpenApp(state, data) {
state.firstOpenApp = uni.$storage.getStorageSync('firstOpenApp');
},
setIsOpenApp(state, data) {
state.isOpenApp = data;
} }
}; };

Loading…
Cancel
Save