detail-navbar.js 4.5 KB

1
  1. "use strict";const e=require("../../../../common/vendor.js"),r=require("../../../../sheep/index.js"),t=require("../../../../sheep/helper/throttle.js"),o=require("../../../../sheep/hooks/useModal.js"),s=require("../../../../sheep/api/product/favorite.js");if(require("../../../../sheep/url/index.js"),require("../../../../sheep/store/index.js"),require("../../../../sheep/store/app.js"),require("../../../../sheep/api/promotion/diy.js"),require("../../../../sheep/request/index.js"),require("../../../../sheep/config/index.js"),require("../../../../sheep/platform/index.js"),require("../../../../sheep/platform/provider/wechat/index.js"),require("../../../../sheep/platform/provider/wechat/miniProgram.js"),require("../../../../sheep/api/member/auth.js"),require("../../../../sheep/api/member/social.js"),require("../../../../sheep/api/member/user.js"),require("../../../../sheep/platform/provider/apple/index.js"),require("../../../../sheep/platform/share.js"),require("../../../../sheep/router/index.js"),require("../../../../sheep/platform/pay.js"),require("../../../../sheep/helper/index.js"),require("../../../../sheep/helper/test.js"),require("../../../../sheep/helper/digit.js"),require("../../../../sheep/api/pay/order.js"),require("../../../../sheep/store/user.js"),require("../../../../sheep/store/cart.js"),require("../../../../sheep/api/trade/cart.js"),require("../../../../sheep/api/pay/wallet.js"),require("../../../../sheep/api/trade/order.js"),require("../../../../sheep/api/promotion/coupon.js"),require("../../../../sheep/store/sys.js"),require("../../../../sheep/store/modal.js"),require("../../../../sheep/config/zIndex.js"),require("../../../../sheep/api/member/signin.js"),!Array){(e.resolveComponent("su-status-bar")+e.resolveComponent("su-fixed"))()}Math||((()=>"../../../../sheep/ui/su-status-bar/su-status-bar.js")+(()=>"../../../../sheep/ui/su-fixed/su-fixed.js"))();const a={__name:"detail-navbar",props:{modelValue:{type:Object,default(){}},collectIcon:{type:Boolean,default:!0},shareIcon:{type:Boolean,default:!0}},emits:["clickLeft"],setup(a,{emit:i}){const l=e.computed((()=>r.sheep.$store("user").isLogin)),p=r.sheep.$platform.device.statusBarHeight,u=r.sheep.$platform.navbar,c={width:r.sheep.$platform.capsule.width+"px",height:r.sheep.$platform.capsule.height+"px"},n=e.reactive({tabOpacityVal:0,curTab:"goods",tabList:[{label:"商品",value:"goods",to:"detail-swiper-selector"},{label:"评价",value:"comment",to:"detail-comment-selector"},{label:"详情",value:"detail",to:"detail-content-selector"}]}),h=a,d=i,m=r.sheep.$router.hasHistory();function f(){m?r.sheep.$router.back():r.sheep.$router.go("/pages/index/index"),d("clickLeft")}function b(){o.showMenuTools()}let j={top:0,bottom:0};async function q(){if(l.value)if(h.modelValue.favorite){const{code:e}=await s.FavoriteApi.deleteFavorite(h.modelValue.id);if(0!==e)return;r.sheep.$helper.toast("取消收藏"),h.modelValue.favorite=!1}else{const{code:e}=await s.FavoriteApi.createFavorite(h.modelValue.id);if(await s.FavoriteApi.createCollectBefore(h.modelValue.id),0!==e)return;r.sheep.$helper.toast("收藏成功"),h.modelValue.favorite=!0}else o.showAuthModal()}return e.onPageScroll((o=>{n.tabOpacityVal=o.scrollTop>r.sheep.$platform.navbar?1:.01*o.scrollTop,0===j.top&&t.throttle((()=>{new Promise(((r,t)=>{e.index.createSelectorQuery().select(".detail-comment-selector").boundingClientRect((e=>{e?(j.top=e.top,j.bottom=e.top+e.height,r(e)):r(null)})).exec()}))}),50),o.scrollTop<j.top-u?n.curTab="goods":o.scrollTop>=j.top-u&&o.scrollTop<=j.bottom-u?n.curTab="comment":n.curTab="detail"})),(t,s)=>e.e({a:e.unref(m)},(e.unref(m),{}),{b:e.o(f),c:e.o(b),d:e.f(n.tabList,((r,t,o)=>({a:e.t(r.label),b:e.n(n.curTab===r.value?"cur-tab-title":""),c:n.curTab===r.value,d:r.value,e:e.o((t=>function(r){let t=0;"comment"===r.value?t=j.top-u+1:"detail"===r.value&&(t=j.bottom-u+1),e.index.pageScrollTo({scrollTop:t,duration:200})}(r)),r.value)}))),e:e.s({opacity:n.tabOpacityVal}),f:a.collectIcon},a.collectIcon?e.e({g:a.modelValue.favorite},a.modelValue.favorite?{h:e.unref(r.sheep).$url.static("/static/images/collect_1.gif")}:{i:e.unref(r.sheep).$url.static("/static/images/collect_0.png")},{j:e.o(q)}):{},{k:a.shareIcon},a.shareIcon?{l:e.unref(r.sheep).$url.static("/static/images/share.png"),m:e.o((r=>e.unref(o.showShareModal)(a.modelValue.id)))}:{},{n:e.s({opacity:n.tabOpacityVal}),o:e.s(c),p:e.s({height:e.unref(u)-e.unref(p)+"px"}),q:e.p({alway:!0,bgStyles:{background:"#fff"},val:0,noNav:!0,opacity:!0,placeholder:!1})})}},i=e._export_sfc(a,[["__scopeId","data-v-e878b9b7"]]);wx.createComponent(i);