【模版目录】更新移动端页面源码

This commit is contained in:
吴昊天 2022-12-06 18:47:28 +08:00
parent 01fa0e3b4b
commit 2ec3a28133
5 changed files with 200 additions and 538 deletions

View File

@ -1,203 +1,188 @@
<template>
<view>
<view :style="{height:footHeight+'px'}"></view>
<view v-if="newData.bgColor">
<view class="page-footer" id="target" :style="{'background-color':newData.bgColor.color[0].item}">
<view class="foot-item" v-for="(item,index) in newData.menuList" :key="index" @click="goRouter(item)">
<block v-if="item.link == activeRouter">
<image :src="item.imgList[0]"></image>
<view class="txt" :style="{color:newData.activeTxtColor.color[0].item}">{{item.name}}</view>
</block>
<block v-else>
<image :src="item.imgList[1]"></image>
<view class="txt" :style="{color:newData.txtColor.color[0].item}">{{item.name}}</view>
</block>
<div class="count-num"
v-if="item.link === '/pages/order_addcart/order_addcart' && $store.state.indexData.cartNum && $store.state.indexData.cartNum>0">
{{$store.state.indexData.cartNum}}
</div>
</view>
</view>
</view>
</view>
</template>
<script>
import {
mapState,
mapGetters
} from "vuex"
import {
getNavigation
} from '@/api/public.js'
import {
getCartCounts,
} from '@/api/order.js';
export default {
name: 'pageFooter',
props: {
noTop: {
type: Boolean,
default: true
},
status: {
type: Number | String,
default: 1
},
countNum: {
type: Number | String,
default: 0
},
},
computed: {
...mapState({
configData: state => state.app.pageFooter
})
},
computed: mapGetters(['isLogin', 'cartNum']),
watch: {
configData: {
handler(nVal, oVal) {
let self = this
const query = uni.createSelectorQuery().in(this);
this.newData = nVal
this.$nextTick(() => {
query.select('#target').boundingClientRect(data => {
uni.$emit('footHeight', data.height)
if (data) {
self.footHeight = data.height + 50
}
}).exec();
})
},
deep: true
},
cartNum(a, b) {
this.$store.commit('indexData/setCartNum', a + '')
if (a > 0) {
uni.setTabBarBadge({
index: Number(uni.getStorageSync('FOOTER_ADDCART')),
text: a + ''
})
} else {
wx.hideTabBarRedDot({
index: Number(uni.getStorageSync('FOOTER_ADDCART'))
})
}
}
},
created() {
let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
let curRoute = routes[routes.length - 1].route //获取当前页面路由
this.activeRouter = '/' + curRoute
},
onShow() {
uni.hideTabBar()
getNavigation().then(res => {
uni.setStorageSync('pageFoot', res.data)
this.$store.commit('FOOT_UPLOAD', res.data)
this.newData = res.data
})
},
mounted() {
let that = this
uni.hideTabBar()
this.newData = this.$store.state.app.pageFooter
if (this.isLogin) {
this.getCartNum()
}
},
data() {
return {
newData: {},
activeRouter: '/',
footHeight: 0
}
},
methods: {
goRouter(item) {
var pages = getCurrentPages();
if (pages.length) {
var page = (pages[pages.length - 1]).$page.fullPath;
} else {
page = ''
}
if (item.link == page) return
uni.switchTab({
url: item.link,
fail(err) {
uni.redirectTo({
url: item.link
})
}
})
},
getCartNum: function() {
let that = this;
getCartCounts().then(res => {
that.cartCount = res.data.count;
this.$store.commit('indexData/setCartNum', res.data.count > 99 ? '...' : res.data.count)
});
},
}
}
</script>
<style lang="scss" scoped>
.page-footer {
position: fixed;
bottom: 0;
z-index: 30;
display: flex;
align-items: center;
justify-content: space-around;
width: 100%;
height: calc(98rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
height: calc(98rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
box-sizing: border-box;
border-top: solid 1rpx #F3F3F3;
background-color: #fff;
box-shadow: 0px 0px 17rpx 1rpx rgba(206, 206, 206, 0.32);
padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
.foot-item {
display: flex;
width: max-content;
align-items: center;
justify-content: center;
flex-direction: column;
position: relative;
width: 100%;
.count-num {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
width: 40rpx;
height: 40rpx;
top: 0rpx;
right: -15rpx;
color: #fff;
font-size: 20rpx;
background-color: #FD502F;
border-radius: 50%;
padding: 4rpx;
}
}
.foot-item image {
height: 50rpx;
width: 50rpx;
text-align: center;
margin: 0 auto;
}
.foot-item .txt {
font-size: 24rpx;
&.active {}
}
}
<template>
<view>
<view v-if="newData" class="page-footer" id="target">
<view class="foot-item" v-for="(item,index) in newData.menuList" :key="index" @click="goRouter(item)"
:style="{'background-color':newData.bgColor.color[0].item}">
<block v-if="item.link == activeRouter">
<image :src="item.imgList[0]"></image>
<view class="txt" :style="{color:newData.activeTxtColor.color[0].item}">{{item.name}}</view>
</block>
<block v-else>
<image :src="item.imgList[1]"></image>
<view class="txt" :style="{color:newData.txtColor.color[0].item}">{{item.name}}</view>
</block>
<div class="count-num" v-if="item.link === '/pages/order_addcart/order_addcart' && cartNum>0">
{{cartNum > 99 ? '99+' : cartNum}}
</div>
</view>
</view>
</view>
</template>
<script>
import {
mapState,
mapGetters
} from "vuex"
import {
getNavigation
} from '@/api/public.js'
import {
getCartCounts,
} from '@/api/order.js';
export default {
name: 'pageFooter',
props: {
status: {
type: Number | String,
default: 1
},
countNum: {
type: Number | String,
default: 0
},
},
data() {
return {
newData: undefined
}
},
computed: {
...mapState({
configData: state => state.app.pageFooter
})
},
computed: mapGetters(['isLogin', 'cartNum']),
watch: {
configData: {
handler(nVal, oVal) {
let self = this
const query = uni.createSelectorQuery().in(this);
this.newData = nVal
this.$nextTick(() => {
query.select('#target').boundingClientRect(data => {
uni.$emit('footHeight', data.height)
if (data) {
self.footHeight = data.height + 50
}
}).exec();
})
},
deep: true
},
},
created() {
let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
let curRoute = routes[routes.length - 1].route //获取当前页面路由
this.activeRouter = '/' + curRoute
},
onShow() {
},
mounted() {
getNavigation().then(res => {
uni.setStorageSync('pageFoot', res.data)
this.$store.commit('FOOT_UPLOAD', res.data)
this.newData = res.data
})
let that = this
uni.hideTabBar()
console.log(this.cartNum, 'cartNum')
this.newData = this.$store.state.app.pageFooter
if (this.isLogin) {
this.getCartNum()
}
},
data() {
return {
newData: {},
activeRouter: '/',
footHeight: 0
}
},
methods: {
goRouter(item) {
var pages = getCurrentPages();
var page = (pages[pages.length - 1]).$page.fullPath;
if (item.link == page) return
uni.switchTab({
url: item.link,
fail(err) {
uni.redirectTo({
url: item.link
})
}
})
},
getCartNum: function() {
let that = this;
getCartCounts().then(res => {
that.cartCount = res.data.count;
this.$store.commit('indexData/setCartNum', res.data.count > 99 ? '...' : res.data.count)
});
},
}
}
</script>
<style lang="scss" scoped>
.page-footer {
position: fixed;
bottom: 0;
z-index: 30;
display: flex;
align-items: center;
justify-content: space-around;
width: 100%;
height: calc(98rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
height: calc(98rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
box-sizing: border-box;
border-top: solid 1rpx #F3F3F3;
background-color: #fff;
box-shadow: 0px 0px 17rpx 1rpx rgba(206, 206, 206, 0.32);
padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
.foot-item {
display: flex;
width: max-content;
align-items: center;
justify-content: center;
flex-direction: column;
position: relative;
width: 100%;
height: 100%;
.count-num {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
width: 40rpx;
height: 40rpx;
top: 0rpx;
right: calc(50% - 55rpx);
color: #fff;
font-size: 20rpx;
background-color: #FD502F;
border-radius: 50%;
padding: 4rpx;
}
}
.foot-item image {
height: 50rpx;
width: 50rpx;
text-align: center;
margin: 0 auto;
}
.foot-item .txt {
font-size: 24rpx;
&.active {}
}
}
</style>

View File

@ -53,24 +53,8 @@
</scroll-view>
</view>
</view>
<tabBar v-if="!is_diy" :pagePath="'/pages/goods_cate/goods_cate'"></tabBar>
<view class="foot" v-if="is_diy && newData.menuList && newData.menuList.length">
<view class="page-footer" id="target" :style="{'background-color':newData.bgColor.color[0].item}">
<view class="foot-item" v-for="(item,index) in newData.menuList" :key="index" @click="goRouter(item)">
<block v-if="item.link == activeRouter">
<image :src="item.imgList[0]"></image>
<view class="txt" :style="{color:newData.activeTxtColor.color[0].item}">{{$t(item.name)}}</view>
</block>
<block v-else>
<image :src="item.imgList[1]"></image>
<view class="txt" :style="{color:newData.txtColor.color[0].item}">{{$t(item.name)}}</view>
</block>
<div class="count-num" v-if="item.link === '/pages/order_addcart/order_addcart' && cartNum > 0">
{{cartNum}}
</div>
</view>
</view>
</view>
<tabBar v-if="!is_diy" :pagePath="'/pages/goods_cate/goods_cate'"></tabBar>
<pageFooter v-else></pageFooter>
</view>
</template>
@ -83,10 +67,10 @@
mapState,
mapGetters
} from "vuex"
import pageFooter from '@/components/pageFooter/index.vue'
import {
getNavigation
} from '@/api/public.js'
} from '@/api/public.js'
import pageFooter from '@/components/pageFooter/index.vue'
import tabBar from "@/pages/index/visualization/components/tabBar.vue";
const app = getApp();
export default {
@ -397,61 +381,4 @@
width: 120rpx;
text-align: center;
}
.page-footer {
position: fixed;
bottom: 0;
z-index: 30;
display: flex;
align-items: center;
justify-content: space-around;
width: 100%;
height: calc(98rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
height: calc(98rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
box-sizing: border-box;
border-top: solid 1rpx #F3F3F3;
background-color: #fff;
box-shadow: 0px 0px 17rpx 1rpx rgba(206, 206, 206, 0.32);
padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
.foot-item {
display: flex;
width: max-content;
align-items: center;
justify-content: center;
flex-direction: column;
position: relative;
width: 100%;
.count-num {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
width: 40rpx;
height: 40rpx;
top: 0rpx;
right: -15rpx;
color: #fff;
font-size: 20rpx;
background-color: #FD502F;
border-radius: 50%;
padding: 4rpx;
}
}
.foot-item image {
height: 50rpx;
width: 50rpx;
text-align: center;
margin: 0 auto;
}
.foot-item .txt {
font-size: 24rpx;
&.active {}
}
}
</style>

View File

@ -145,26 +145,7 @@
<view v-if="site_config" class="site-config" @click="goICP">{{ site_config }}</view>
<!-- #endif -->
<view class="uni-p-b-98"></view>
<view class="foot">
<view class="page-footer" id="target" :style="{'background-color':newData.bgColor.color[0].item}">
<view class="foot-item" v-for="(item,index) in newData.menuList" :key="index"
@click="goRouter(item)">
<block v-if="item.link == activeRouter">
<image :src="item.imgList[0]"></image>
<view class="txt" :style="{color:newData.activeTxtColor.color[0].item}">{{$t(item.name)}}
</view>
</block>
<block v-else>
<image :src="item.imgList[1]"></image>
<view class="txt" :style="{color:newData.txtColor.color[0].item}">{{$t(item.name)}}</view>
</block>
<div class="count-num"
v-if="item.link === '/pages/order_addcart/order_addcart' && countNum > 0">
{{countNum}}
</div>
</view>
</view>
</view>
<pageFooter></pageFooter>
</view>
</view>
<view v-else>
@ -208,9 +189,6 @@
getCouponNewUser,
siteConfig
} from '@/api/api.js';
import {
getNavigation
} from '@/api/public.js';
// #ifdef H5
import mConfig from './components/index.js';
// #endif
@ -382,9 +360,6 @@
}
});
})
getNavigation().then(res => {
this.newData = res.data
})
let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
let curRoute = routes[routes.length - 1].route //获取当前页面路由
this.activeRouter = '/' + curRoute
@ -709,20 +684,6 @@
if (item.name == 'headerSerch') {
this.isHeaderSerch = true
}
if (item.name == 'pageFoot') {
if (item.status && item.status.status) {
this.newData = item
}
uni.setStorageSync('FOOTER_BAR', item.status && item.status.status ? true :
false)
item.menuList.map((path, index) => {
if (path.link === '/pages/order_addcart/order_addcart') {
uni.setStorageSync('FOOTER_ADDCART', index)
}
})
arr.splice(index, 1);
}
if (item.name == 'promotionList') {
that.numConfig = item.numConfig.val;
that.goodType = item.tabConfig.list[0].link.activeVal;
@ -1160,59 +1121,4 @@
width: 100%;
}
}
.page-footer {
position: fixed;
bottom: 0;
z-index: 30;
display: flex;
align-items: center;
justify-content: space-around;
width: 100%;
height: calc(98rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
height: calc(98rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
box-sizing: border-box;
border-top: solid 1rpx #F3F3F3;
background-color: #fff;
box-shadow: 0px 0px 17rpx 1rpx rgba(206, 206, 206, 0.32);
padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
.foot-item {
display: flex;
width: max-content;
align-items: center;
justify-content: center;
flex-direction: column;
position: relative;
width: 100%;
.count-num {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
width: 40rpx;
height: 40rpx;
top: 0rpx;
right: -15rpx;
color: #fff;
font-size: 20rpx;
background-color: #FD502F;
border-radius: 50%;
padding: 4rpx;
}
}
.foot-item image {
height: 50rpx;
width: 50rpx;
text-align: center;
margin: 0 auto;
}
.foot-item .txt {
font-size: 24rpx;
&.active {}
}
}
</style>

View File

@ -144,24 +144,8 @@
<!-- <view class="uni-p-b-96"></view> -->
<view class="uni-p-b-98"></view>
<!-- <pageFooter :countNum="cartCount"></pageFooter> -->
<tabBar v-if="!is_diy" :pagePath="'/pages/order_addcart/order_addcart'"></tabBar>
<view class="foot" v-if="is_diy && newData.menuList && newData.menuList.length">
<view class="page-footer" id="target" :style="{'background-color':newData.bgColor.color[0].item}">
<view class="foot-item" v-for="(item,index) in newData.menuList" :key="index" @click="goRouter(item)">
<block v-if="item.link == activeRouter">
<image :src="item.imgList[0]"></image>
<view class="txt" :style="{color:newData.activeTxtColor.color[0].item}">{{item.name}}</view>
</block>
<block v-else>
<image :src="item.imgList[1]"></image>
<view class="txt" :style="{color:newData.txtColor.color[0].item}">{{item.name}}</view>
</block>
<div class="count-num" v-if="item.link === '/pages/order_addcart/order_addcart' && cartCount > 0">
{{cartCount}}
</div>
</view>
</view>
</view>
<tabBar v-if="!is_diy" :pagePath="'/pages/order_addcart/order_addcart'"></tabBar>
<pageFooter v-else></pageFooter>
</view>
</template>
@ -201,9 +185,6 @@
import {
HTTP_REQUEST_URL
} from '@/config/app';
import {
getNavigation
} from '@/api/public.js'
export default {
components: {
pageFooter,
@ -266,9 +247,6 @@
computed: mapGetters(['isLogin']),
onLoad(options) {
uni.hideTabBar()
getNavigation().then(res => {
this.newData = res.data
})
let that = this;
if (that.isLogin == false) {
toLogin();
@ -968,64 +946,6 @@
</script>
<style scoped lang="scss">
.page-footer {
position: fixed;
bottom: 0;
z-index: 30;
display: flex;
align-items: center;
justify-content: space-around;
width: 100%;
height: calc(98rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
height: calc(98rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
box-sizing: border-box;
border-top: solid 1rpx #F3F3F3;
background-color: #fff;
box-shadow: 0px 0px 17rpx 1rpx rgba(206, 206, 206, 0.32);
padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
.foot-item {
display: flex;
width: max-content;
align-items: center;
justify-content: center;
flex-direction: column;
position: relative;
width: 100%;
.count-num {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
width: 40rpx;
height: 40rpx;
top: 0rpx;
right: -15rpx;
color: #fff;
font-size: 20rpx;
background-color: #FD502F;
border-radius: 50%;
padding: 4rpx;
}
}
.foot-item image {
height: 50rpx;
width: 50rpx;
text-align: center;
margin: 0 auto;
}
.foot-item .txt {
font-size: 24rpx;
&.active {}
}
}
.shoppingCart {
/* #ifdef H5 */
// padding-bottom: 0;

View File

@ -272,24 +272,8 @@
<view class="uni-p-b-98"></view>
</scroll-view>
</view>
<tabBar v-if="!is_diy" :pagePath="'/pages/user/index'"></tabBar>
<view class="foot" v-if="is_diy && newData.menuList && newData.menuList.length">
<view class="page-footer" id="target" :style="{'background-color':newData.bgColor.color[0].item}">
<view class="foot-item" v-for="(item,index) in newData.menuList" :key="index" @click="goRouter(item)">
<block v-if="item.link == activeRouter">
<image :src="item.imgList[0]"></image>
<view class="txt" :style="{color:newData.activeTxtColor.color[0].item}">{{$t(item.name)}}</view>
</block>
<block v-else>
<image :src="item.imgList[1]"></image>
<view class="txt" :style="{color:newData.txtColor.color[0].item}">{{$t(item.name)}}</view>
</block>
<div class="count-num" v-if="item.link === '/pages/order_addcart/order_addcart' && cartNum > 0">
{{cartNum}}
</div>
</view>
</view>
</view>
<tabBar v-if="!is_diy" :pagePath="'/pages/user/index'"></tabBar>
<pageFooter v-else></pageFooter>
</view>
</template>
<script>
@ -302,7 +286,6 @@
} from '@/api/user.js';
import {
wechatAuthV2,
getNavigation,
silenceAuth
} from '@/api/public.js'
import {
@ -319,13 +302,15 @@
import dayjs from '@/plugin/dayjs/dayjs.min.js';
import Routine from '@/libs/routine';
import colors from '@/mixins/color';
import tabBar from "@/pages/index/visualization/components/tabBar.vue";
import tabBar from "@/pages/index/visualization/components/tabBar.vue";
import pageFooter from '@/components/pageFooter/index.vue'
import {
getCustomer
} from '@/utils/index.js'
export default {
components: {
tabBar,
tabBar,
pageFooter
},
// computed: mapGetters(['isLogin','cartNum']),
computed: {
@ -390,7 +375,6 @@
sysHeight: sysHeight,
mpHeight: 0,
showStatus: 1,
newData: {},
activeRouter: '',
// #ifdef H5 || MP
pageHeight: '100%',
@ -412,9 +396,6 @@
onLoad(option) {
uni.hideTabBar()
let that = this;
getNavigation().then(res => {
this.newData = res.data
})
// #ifdef MP
// 小程序静默授权
if (!this.$store.getters.isLogin) {
@ -1332,63 +1313,6 @@
}
}
.page-footer {
position: fixed;
bottom: 0;
z-index: 30;
display: flex;
align-items: center;
justify-content: space-around;
width: 100%;
height: calc(98rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
height: calc(98rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
box-sizing: border-box;
border-top: solid 1rpx #F3F3F3;
background-color: #fff;
box-shadow: 0px 0px 17rpx 1rpx rgba(206, 206, 206, 0.32);
padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
.foot-item {
display: flex;
width: max-content;
align-items: center;
justify-content: center;
flex-direction: column;
position: relative;
width: 100%;
.count-num {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
width: 40rpx;
height: 40rpx;
top: 0rpx;
right: -15rpx;
color: #fff;
font-size: 20rpx;
background-color: #FD502F;
border-radius: 50%;
padding: 4rpx;
}
}
.foot-item image {
height: 50rpx;
width: 50rpx;
text-align: center;
margin: 0 auto;
}
.foot-item .txt {
font-size: 24rpx;
&.active {}
}
}
.new-users {
padding-bottom: 0;
padding-bottom: constant(safe-area-inset-bottom);