123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- <!-- DetailHeader.vue -->
- <template>
- <view class="div ui-detail-header-wrapper">
- <title-header />
- <view class="div ui-detail-header">
- <text class="span iconfont" @click="goBack()"></text>
- <!-- <view class="div navbar-wrapper">
- <view class="div"
- v-for="(item, key) in data"
- :key="key"
- v-bind:class="{ navbar_active: key == index }"
- v-on:click="changeEvent(key)"
- >
- {{ item.name }}
- </view>
- </view> -->
- <view class="div navbar-wrapper">
- <view class="div" :class="{'navbar_active':navbaractive ==1}"><text @click="goanchor('#goods-swipe')">商品</text></view>
- <view class="div" :class="{'navbar_active':navbaractive ==2}"><text @click="goanchor('#review')">评论</text></view>
- <view class="div" :class="{'navbar_active':navbaractive ==3}"><text @click="goanchor('#mbBody')">详情</text></view>
- </view>
- <text class="span iconfont right" @click="popupMore"><view v-if="showDot" class="div dot"></view></text>
- </view>
- <header-more v-if="share_info" :goods_id="goods_id" :share_info="share_info" v-show="popupVisible" :showDot="showDot"></header-more>
- </view>
- </template>
- <script>
- import TitleHeader from '../../TitleHeader'
- import { header } from './static'
- import { getChatCount } from '../../../api/memberInstantMessage'
- import { mapState, mapMutations } from 'vuex'
- import HeaderMore from '../../HeaderMore'
- import { env } from '@/static/config'
- import { urlencode } from '@/util/common'
- export default {
- data () {
- return {
- navHeight: 0,
- currentUrl:'',
- data: header,
- popupVisible: false,
- showDot:false,
- navbaractive:1,
- }
- },
- props:['mbBodytop','reviewtop'],
- components: {
- HeaderMore,
- TitleHeader
- },
- computed: {
- ...mapState({
- detailInfo: state => state.goodsdetail.detailInfo,
- goods_id: state => state.goodsdetail.currentProductId,
- index: state => state.goodsdetail.index,
- isOnline:state => state.member.isOnline,
- }),
- share_info: function () {
- return this.detailInfo?{ title: this.detailInfo.goods_name, link: this.currentUrl, imgUrl: this.detailInfo.photos[0], desc: this.detailInfo.goods_advword }:false
- },
- listenChange(){
- let mbBodytop = this.mbBodytop
- let reviewtop = this.reviewtop
- return { mbBodytop, reviewtop}
- }
- },
- mounted () {
- // #ifdef MP-WEIXIN
- this.navHeight = uni.getMenuButtonBoundingClientRect().top
- // #endif
- var pages = getCurrentPages()
- var page = pages[pages.length - 1]
- this.currentUrl=env.H5_HOST + page.route+(page.options?('?'+urlencode(page.options)):'')
- this.changeIndex(0)
- this.saveNumber(1)
- if(this.isOnline){
- getChatCount().then(res=>{
- if(res.result){
- if(!this.showDot){
- this.showDot={}
- }
- this.showDot['chat']=true
- }
- })
- }
- },
- methods: {
- ...mapMutations({
- changeIndex: 'changeIndex',
- saveNumber: 'saveNumber'
- }),
- popupMore () {
- if (!this.popupVisible) {
- this.popupVisible = true
- } else {
- this.popupVisible = false
- }
- },
- changeEvent (index) {
- this.changeIndex(index)
- },
- goanchor(id){
- document.querySelector(id).scrollIntoView({
- behavior:"smooth"
- });
- },
- goBack () {
- uni.navigateBack({delta:1})
- }
- },
- watch:{
- listenChange(val){
- val.mbBodytop = val.mbBodytop - 100
- val.reviewtop = val.reviewtop - 100
- if(val.mbBodytop > 0 && val.reviewtop >0){
- this.navbaractive = 1
- }else if(val.reviewtop < 0 && val.mbBodytop > 0){
- this.navbaractive = 2
- }else if(val.reviewtop < 0 && val.mbBodytop < 0){
- this.navbaractive = 3
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .ui-detail-header-wrapper{
- position: fixed;
- top:0;
- padding-top: var(--status-bar-height);
- background: rgba(255, 255, 255, 1);
- left: 0;
- right: 0;
- z-index: 10;
- }
- .dot{position:absolute;width:.5rem;height:.5rem;background:red;border-radius:50%;top:.2rem;right:0;}
- .ui-detail-header {
- padding: 0 0.45rem;
- // height:3.2rem;
- color: #55595f;
- font-size:$h2;
- width: auto;
- display: flex;
- justify-content: center;
- align-content: center;
- align-items: center;
- flex-basis: auto;
- .iconfont {
- width: 1.2rem;
- font-size:$h2;
- height: $headerHeight;
- line-height:$headerHeight;
- cursor: pointer;
- position: absolute;
- left: 0.45rem;
- bottom: 0;
- }
- .iconfont.right{left:auto;right:0.45rem}
- .div.navbar-wrapper {
- line-height: $headerHeight;
- height: $headerHeight;
- .div {
- // line-height: 2.1rem;
- border-bottom: 0;
- display: inline-block;
- margin-right:2.4rem;
- color: #55595f;
- background-color: #fff;
- position: relative;
- &.navbar_active {
- color: $primaryColor;
- &::after{content:'';display: block;height: .1rem;width: 1rem;position: absolute;bottom:0;left:50%;margin-left:-.5rem;background: $primaryColor}
- }
- &:last-child {
- margin-right: 0;
- }
- &:focus {
- outline: none;
- }
- }
- }
- }
- </style>
|