product.vue 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369
  1. <template>
  2. <view class="product" :style="{paddingBottom: userIdentity==1 ? '0rpx' :'188rpx'}">
  3. <custom-p v-if="isHeaderPoduct"
  4. :systeminfo='systeminfo'
  5. :navbar-data='nvabarData'
  6. :headerBtnPosi ="headerBtnPosi"
  7. :headerColor="headerColor"
  8. :type="isShareType"
  9. :page='backPage'>
  10. </custom-p>
  11. <tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading ="true" :loadingType="5"></tui-skeleton>
  12. <view class="container-product tui-skeleton">
  13. <view class="product-top">
  14. <view class="banner-section">
  15. <uni-swiper-dot :info="productImage" :current="current" field="content" :mode="mode" >
  16. <swiper class="banner tui-banner tui-skeleton-rect" circular @change="swiperChange" :duration='800' :autoplay="false" :circular="false" >
  17. <swiper-item v-for="(item, index) in productImage" :key="index" class="banner-item">
  18. <image :src="item" @click="previewImg(index)" class="product-img" />
  19. </swiper-item>
  20. </swiper>
  21. <view class="swiper__dots-box">
  22. <view v-for="(item,idx) in productImage"
  23. :key="idx"
  24. :class="[idx===current?'swiper__dots-long':'none']"
  25. :data-index="current" class="swiper__dots-item">
  26. </view>
  27. </view>
  28. </uni-swiper-dot>
  29. </view>
  30. <view class="product-wrap clearfix">
  31. <view class="wrap-top" :class="goodsData.isNoneDisabled ? 'none' : ''">
  32. <view class="p-title tui-skeleton-fillet">
  33. {{product.name == undefined ? '' : product.name}}
  34. </view>
  35. <view class="productRemarks" v-if="product.productRemarks!=''&&product.productRemarks!=null">
  36. <text class="text">{{product.productRemarks}}</text>
  37. </view>
  38. <view class="wrap-label" v-if="product.tagsList.length>0">
  39. <view class="label-a tui-skeleton-fillet" v-for="(label,index) in product.tagsList" :key="index">{{label}}</view>
  40. </view>
  41. <view class="wrap-top-price" v-if="!goodsData.isNoneDisabled">
  42. <cm-price v-if="isRequest"
  43. :product="product"
  44. :userIdentity="userIdentity"
  45. :promotions="product.promotions"
  46. :ladderPriceList="ladderPriceList"/>
  47. </view>
  48. </view>
  49. <view class="attributes">
  50. <cm-attributes v-if="isRequest" :product="product" :goodsData="goodsData" />
  51. </view>
  52. </view>
  53. </view>
  54. <view class="product-supplier" @click="goSupplier">
  55. <text class="title">供应商信息</text>
  56. <text class="name">{{shop.name}}</text>
  57. <text class="iconfont icon-xiayibu"></text>
  58. </view>
  59. <view class="product-details">
  60. <!-- 头部 -->
  61. <view v-if="goodsData.isNoneDisabled" class="navbar" :class="navbarFiexd" :style="{top:headerBtnPosi.bottom + (headerBtnPosi.bottom - headerBtnPosi.height - systeminfo.statusBarHeight) +'px'}">
  62. <view class="nav-item tui-skeleton-fillet" v-for="(item,index) in disabledTabNavList" :key="index" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index+2)">
  63. <text class="line"></text>
  64. <text>{{item.name}}</text>
  65. </view>
  66. </view>
  67. <view v-else class="navbar" :class="navbarFiexd" :style="{top:headerBtnPosi.bottom + (headerBtnPosi.bottom - headerBtnPosi.height - systeminfo.statusBarHeight) +'px'}">
  68. <view class="nav-item tui-skeleton-fillet" :class="{ current: tabCurrentIndex === 0 }" @click="tabClick(0)">
  69. <text>商品详情</text>
  70. <text class="line"></text>
  71. </view>
  72. <view class="nav-item tui-skeleton-fillet"
  73. :class="{ current: tabCurrentIndex === 1 }"
  74. @click="tabClick(1)"
  75. v-if="product.parametersList != ''">
  76. <text>相关参数</text>
  77. <text class="line"></text>
  78. </view>
  79. <view class="nav-item tui-skeleton-fillet"
  80. :class="{ current: tabCurrentIndex === 2 }"
  81. @click="tabClick(2)"
  82. v-if="product.productDetail.orderInfo || product.productDetail.serviceInfo">
  83. <text>服务项目</text>
  84. <text class="line"></text>
  85. </view>
  86. <view class="nav-item tui-skeleton-fillet" :class="{ current: tabCurrentIndex === 3 }" @click="tabClick(3)">
  87. <text>相关推荐</text>
  88. <text class="line"></text>
  89. </view>
  90. </view>
  91. <!-- 商品详情,相关参数,服务项目,相关推荐-->
  92. <view class="content tui-banner tui-skeleton-rect" v-if="tabCurrentIndex === 0">
  93. <parser :html="html" :img-mode="widthFix"></parser>
  94. </view>
  95. <view class="content param" v-if="tabCurrentIndex === 1">
  96. <cm-parameter :product="product" v-if="isRarameter"></cm-parameter>
  97. </view>
  98. <view class="content service" v-if="tabCurrentIndex === 2">
  99. <cm-service :product="product.productDetail" v-if="isService"></cm-service>
  100. </view>
  101. <view class="content hot" v-if="tabCurrentIndex === 3">
  102. <recommend :query-productid="product.productID" v-if="isRecommend"></recommend>
  103. </view>
  104. </view>
  105. <!-- 底部按钮 -->
  106. <view class="menu" v-if="userIdentity!=1">
  107. <view class="bottom-btn" :style="{paddingBottom :isIphoneX ? '68rpx' : '0rpx'}">
  108. <view class="bottom-le">
  109. <view class="item-bt" @click="this.$api.switchTabTo('/pages/tabBar/home/home')">
  110. <image src="../../static/icon-home-active@3x.png"></image>
  111. <text>首页</text>
  112. </view>
  113. <view class="item-bt">
  114. <!-- #ifdef MP-WEIXIN -->
  115. <button class="contact-btn" open-type="contact" @bindcontact="handleContact">
  116. <image src="../../static/severs@3x.png"></image>
  117. <text>客服</text>
  118. </button>
  119. <!-- #endif -->
  120. </view>
  121. <view class="item-bt" @click="buyProductCart()">
  122. <image src="../../static/icon-cart-active@3x.png"></image>
  123. <text>购物车</text>
  124. <text v-if="hasLogin && goodsData.cartCount>0"
  125. class="uni-badge uni-badge-error uni-small uni-badge--small icon-num"
  126. :class="[goodsData.cartCount < 10 ? 'goleft':'']">
  127. {{ goodsData.cartCount >= 100 ? '99+': goodsData.cartCount}}
  128. </text>
  129. <view class="animation-num" :class="isAnimation ? 'animation' : 'restion'">+1</view>
  130. </view>
  131. </view>
  132. <view class="bottom-ri">
  133. <button
  134. :disabled="goodsData.disabled"
  135. class="btn btn-cart"
  136. :class="[goodsData.disabled ? 'disabled':'']"
  137. @tap.stop="btnGetConfirm('add')">加入购物车</button>
  138. <button
  139. :disabled="goodsData.disabled"
  140. class="btn btn-bay"
  141. :class="[goodsData.disabled ? 'disabled':'']"
  142. @tap.stop="btnGetConfirm('buy')">立即购买</button>
  143. </view>
  144. </view>
  145. </view>
  146. <!--底部选择模态层弹窗组件 -->
  147. <view class="popup spec" :class="specClass" @touchmove.stop.prevent="discard" @tap="hideSpec">
  148. <!-- 遮罩层 -->
  149. <view class="mask"></view>
  150. <view class="layer" @tap.stop="discard" :style="{paddingBottom :isIphoneX ? '68rpx' : '36rpx',bottom:isIphoneX ?'-352rpx' : '-296rpx'}">
  151. <view class="content">
  152. <view class="layer-smimg">
  153. <image :src="product.mainImage" mode=""></image>
  154. </view>
  155. <view class="layer-nunbox">
  156. <view class="layer-nunbox-t" v-if="product.step === 2">
  157. <view class="text">*该商品只能以起订量的整数倍购买</view>
  158. </view>
  159. <view class="layer-nunbox-t">
  160. <view class="layer-nunbox-text">数量:</view>
  161. <view class="number-box">
  162. <view class="iconfont icon-jianhao" :class="[isQuantity==true?'disabled':'']" @click="changeCountSub()"></view>
  163. <input class="btn-input" type="number" v-model="number" maxlength='4' @blur="changeNumber($event)">
  164. <view class="iconfont icon-jiahao" :class="[isStock==true?'disabled':'']" @click="changeCountAdd()"></view>
  165. </view>
  166. </view>
  167. <view class="layer-nunbox-b">
  168. <view class="text">单价:
  169. <text class="p sm">¥</text>
  170. <text class="p bg">{{buyRetailPrice.toFixed(2)}}</text>
  171. </view>
  172. </view>
  173. </view>
  174. </view>
  175. <view class="btn"><view class="button" @click.stop="btnConfirm">确定</view></view>
  176. </view>
  177. </view>
  178. </view>
  179. </view>
  180. </template>
  181. <script>
  182. import { mapState,mapMutations } from 'vuex'
  183. import customP from '@/components/cm-module/headerNavbar/header-poduct' //自定义导航
  184. import cmPrice from "@/components/cm-module/productDetails/cm-price.vue" //价格显示
  185. import cmAttributes from "@/components/cm-module/productDetails/cm-attributes.vue" //规格信息
  186. import authorize from '@/common/config/authorize.js'
  187. import uniStars from '@/components/uni-stars/uni-stars.vue'
  188. import parser from "@/components/jyf-Parser/index" //富文本处理
  189. import tuiSkeleton from "@/components/tui-skeleton/tui-skeleton"
  190. import recommend from "@/components/cm-module/productDetails/recommend" //相关推荐
  191. import cmParameter from "@/components/cm-module/productDetails/cm-parameter" //相关参数
  192. import cmService from "@/components/cm-module/productDetails/cm-service" //服务项目
  193. import wxLogin from "@/common/config/wxLogin.js"
  194. var isPreviewImg;
  195. export default{
  196. components:{
  197. customP,
  198. parser,
  199. tuiSkeleton,
  200. recommend,
  201. cmPrice,
  202. cmAttributes,
  203. cmParameter,
  204. cmService
  205. },
  206. data(){
  207. return{
  208. html:'<div style="text-align: center;color:#333333;">暂无内容</div>',
  209. disabledTabNavList:[{name:'相关推荐'}],
  210. mode:'round',
  211. specClass: '',//规格弹窗css类,控制开关动画
  212. isBtnType:'',
  213. isRequest:false,
  214. current:0,
  215. isShareType:'',
  216. isHeaderPoduct:false,
  217. navbarFiexd:'none',
  218. ladderPriceFlag:'',
  219. ladderPriceList:'',
  220. isRecommend:false,
  221. isRarameter:true,
  222. isService:false,
  223. isEvaluate:false,
  224. isAnimation:false,
  225. skeletonShow:true,
  226. isQuantity:false,
  227. isStock:false,
  228. disabled:false,
  229. isNoneDisabled:false,
  230. tabCurrentIndex:0,
  231. userID:'',
  232. productID:0,
  233. userIdentity:'',//用户类型
  234. goodsData:{},//自定义数据
  235. shop:{},//供应商信息
  236. product:{},//采美
  237. productImage:[],
  238. retailPrice:0,
  239. buyRetailPrice:0,
  240. buyRetailPriceStep:1,
  241. stock:0,
  242. number:0,
  243. minBuyNumber:0,
  244. productsList:[],
  245. goodListData:[],
  246. headerBtnPosi: this.setHeaderBtnPosi(), //获取设备顶部胶囊高度
  247. systeminfo: this.setSysteminfo(), //获取设备信息
  248. isIphoneX:this.$store.state.isIphoneX,
  249. windowHeight: '',
  250. headerColor:false,
  251. backPage:1,
  252. nvabarData: { //顶部自定义导航
  253. showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示
  254. title: '' // 导航栏 中间的标题
  255. },
  256. linkPath:''
  257. }
  258. },
  259. onLoad(option) {
  260. this.productID = option.id;//获取商品ID
  261. this.isShareType = option.type
  262. this.linkPath = option.path
  263. this.isHeaderPoduct = true
  264. if(option.page == 2){
  265. this.backPage = option.page
  266. }
  267. if(this.isShareType =='share'){
  268. authorize.getSetting().then(wxResponse =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
  269. console.log(wxResponse)
  270. if(wxResponse == 1){
  271. wxLogin.wxLoginAuthorize()
  272. }else{
  273. console.log(new Date +'用户未授权微信信息')
  274. }
  275. })
  276. }
  277. },
  278. computed: {
  279. ...mapState(['hasLogin','isWxAuthorize'])
  280. },
  281. methods:{
  282. initData(){// 初始化商品详情查询
  283. this.ProductService.queryProductDetils({userId:this.userID,productID:this.productID}).then(response =>{
  284. this.skeletonShow = false
  285. this.productImage=[];
  286. this.shop = response.data.shop
  287. this.product = response.data
  288. this.ladderPriceFlag = this.product.ladderPriceFlag;
  289. this.html = this.product.productDetail == null ? this.html : this.$api.adaptRichTextImg(this.product.productDetail.detailInfo)
  290. this.stock = this.product.stock
  291. this.buyRetailPriceStep = this.product.step
  292. this.number = this.product.minBuyNumber
  293. this.minBuyNumber = this.product.minBuyNumber
  294. //处理商品图片列表
  295. this.product.imageList.forEach(item =>{
  296. this.productImage.push(item.image);
  297. })
  298. //购物车数量
  299. this.goodsData.cartCount = this.product.productCount
  300. //处理阶梯价格
  301. if(this.product.ladderPriceList!=null){
  302. this.ladderPriceList = this.product.ladderPriceList;
  303. }
  304. //拆分金额并转千分位格式显示
  305. if(this.product.retailPrice!=null){
  306. this.retailPrice = this.product.retailPrice.toFixed(2);
  307. this.buyRetailPrice = this.product.retailPrice;
  308. }
  309. //处理下架商品和售罄商品
  310. if(this.product.validFlag =='3' || this.stock == 0 ){
  311. this.disabled = true
  312. this.isNoneDisabled = true
  313. this.tabCurrentIndex = 2;// 页面显示是默认选中第一
  314. this.isRecommend = true
  315. this.goodsData.disabledText = '下架'
  316. }else{
  317. this.disabled = false
  318. this.isNoneDisabled = false
  319. this.tabCurrentIndex = 0;// 页面显示是默认选中第三
  320. this.goodsData.disabledText = ''
  321. }
  322. if(this.product.price1TextFlag == "1"){
  323. this.disabled = true
  324. }
  325. if(this.product.price1TextFlag == "2"){
  326. if(this.userIdentity == 4){
  327. this.disabled = true
  328. }else{
  329. this.disabled = false
  330. }
  331. }
  332. this.goodsData.disabled = this.disabled
  333. this.goodsData.isNoneDisabled = this.isNoneDisabled
  334. if(this.product.validFlag =='3'){
  335. this.goodsData.disabledText = '下架'
  336. }
  337. if(this.stock == 0){
  338. this.goodsData.disabledText = '售罄'
  339. }
  340. this.isRequest = true
  341. }).catch(error =>{
  342. this.$util.msg(error.msg,2000);
  343. })
  344. },
  345. swiperChange(e) {//顶部商品图片切换
  346. const index = e.detail.current;
  347. this.current = index;
  348. },
  349. previewImg (index) {//顶部商品图片预览
  350. isPreviewImg = true
  351. let previewUrls = this.productImage
  352. uni.previewImage({
  353. current: index, //图片索引
  354. urls: previewUrls, //必须是http图片,本地图片无效
  355. longPressActions:''
  356. })
  357. },
  358. tabClick(index) {//商品详情&&供应商信息tab切换
  359. this.tabCurrentIndex = index;
  360. switch(this.tabCurrentIndex){
  361. case 1:
  362. this.isRarameter = true
  363. break;
  364. case 2:
  365. this.isService = true
  366. break;
  367. case 3:
  368. this.isRecommend = true
  369. break;
  370. }
  371. },
  372. handleContact(e){//跳转小程序客服
  373. },
  374. buyProductCart(){//底部购物车按钮点击
  375. authorize.getSetting().then(wxResponse =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
  376. if(wxResponse == 1){
  377. if(this.hasLogin){
  378. this.$api.navigateTo('/pages/goods/cart')
  379. }else{
  380. this.$api.navigateTo('/pages/login/login?type=1')
  381. }
  382. }else{
  383. this.$api.navigateTo('/pages/authorization/authorization?type=1')
  384. }
  385. })
  386. },
  387. btnGetConfirm(type){//加入购物车&&立即购买点击
  388. authorize.getSetting().then(wxResponse =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
  389. if(wxResponse == 1){
  390. if(this.hasLogin){
  391. this.showSpec(type);
  392. }else{
  393. this.$api.navigateTo('/pages/login/login?type=1')
  394. }
  395. }else{
  396. this.$api.navigateTo('/pages/authorization/authorization?type=1')
  397. }
  398. })
  399. },
  400. changeCountAdd(){//popup弹窗数量增加按钮
  401. if(this.buyRetailPriceStep == 2){
  402. this.number+=this.minBuyNumber
  403. }else{
  404. this.number++
  405. }
  406. this.processActivityPrice()
  407. },
  408. changeCountSub(){//popup弹窗数量减按钮
  409. if(this.number<=this.minBuyNumber){
  410. this.number= this.minBuyNumber
  411. this.isQuantity =true
  412. this.$util.msg(`该商品最小起订量为${this.minBuyNumber}`,2000);
  413. return
  414. }else{
  415. if(this.buyRetailPriceStep == 2){
  416. this.number-=this.minBuyNumber
  417. }else{
  418. this.number--
  419. }
  420. this.processActivityPrice()
  421. this.isQuantity =false
  422. }
  423. },
  424. changeNumber(e){
  425. let _value = e.detail.value;
  426. if(!this.$api.isNumber(_value)){
  427. this.number = this.minBuyNumber
  428. }else if(_value < this.minBuyNumber){
  429. this.$util.msg(`该商品最小起订量为${this.minBuyNumber}`,2000);
  430. this.number = this.minBuyNumber
  431. }else if( _value % this.minBuyNumber !=0 ){
  432. this.$util.msg(`购买量必须为起订量的整数倍`,2000);
  433. this.number = this.minBuyNumber
  434. }else{
  435. this.number = e.detail.value
  436. }
  437. this.processActivityPrice()
  438. },
  439. processActivityPrice(){//单独处理活动价格和阶梯价格
  440. if(this.ladderPriceFlag == '0' && this.product.actStatus == 0 || this.product.actStatus == 1){
  441. this.buyRetailPrice = this.product.retailPrice
  442. }else{
  443. this.ladderPriceList.forEach((item,index)=>{
  444. if(this.number>=item.buyNum){
  445. this.buyRetailPrice = item.buyPrice
  446. }
  447. })
  448. }
  449. },
  450. showSpec(type) {//显示选择数量确认弹窗
  451. this.isBtnType = type
  452. this.specClass = 'show';
  453. },
  454. hideSpec() {//关闭选择数量确认弹窗
  455. this.specClass = 'hide';
  456. setTimeout(() => {
  457. this.specClass = 'none';
  458. }, 200);
  459. },
  460. btnConfirm() {//加入购物车&&立即购买跳转订单页并关闭弹窗
  461. if(this.isBtnType == 'add'){
  462. this.getAddProductCart()
  463. }else{
  464. this.toConfirmation()
  465. }
  466. },
  467. toConfirmation(){//跳转确认订单页面
  468. this.specClass = 'hide';
  469. let productStp ={
  470. allPrice:this.number*this.buyRetailPrice,
  471. allCount:this.number,
  472. productID:this.product.productID,
  473. productCount:this.number
  474. }
  475. this.$api.navigateTo(`/pages/user/order/create-order?type=prodcut&data=${JSON.stringify({data:productStp})}`)
  476. setTimeout(() => {
  477. this.specClass = 'none';
  478. }, 200);
  479. },
  480. getAddProductCart(){//增加购物车成功和toast弹窗提示成功
  481. this.ProductService.shoppingAddCart({productID:this.productID,userID:this.userID,productCount:this.number}).then(response => {
  482. this.specClass = 'hide';
  483. this.$util.msg('加入购物车成功',1500,true,'success')
  484. this.isAnimation = true
  485. setTimeout(() => {this.specClass = 'none'}, 200)
  486. setTimeout(() => {this.isAnimation = false},2000)
  487. this.goodsData.cartCount = response.data;
  488. }).catch(error =>{
  489. this.$util.msg(error.msg,2000);
  490. })
  491. },
  492. navToLogin(){
  493. authorize.getSetting().then(wxResponse =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
  494. if(wxResponse == 1){
  495. this.$store.commit('setLoginType',8)
  496. this.$store.commit('setLoginProductId',this.productID)
  497. this.$api.navigateTo(`/pages/login/login?id=${this.productID}`)
  498. }else{
  499. this.$api.navigateTo('/pages/authorization/authorization?type=1')
  500. }
  501. })
  502. },
  503. setHeaderBtnPosi(){
  504. // 获得胶囊按钮位置信息
  505. let headerBtnPosi = uni.getMenuButtonBoundingClientRect();
  506. return headerBtnPosi
  507. },
  508. setSysteminfo(){
  509. let systeminfo;
  510. uni.getSystemInfo({ // 获取设备信息
  511. success: (res) => {
  512. systeminfo = res
  513. },
  514. })
  515. return systeminfo
  516. },
  517. getOptionFn(e){
  518. this.isShareType = e.type
  519. },
  520. goSupplier(){
  521. this.$api.setStorage('supplierInfo',this.shop)
  522. this.$api.navigateTo('/pages/goods/supplier')
  523. },
  524. discard(){
  525. //丢弃
  526. }
  527. },
  528. onPageScroll(e){//实时获取到滚动的值
  529. if(e.scrollTop>50){
  530. this.headerColor = true
  531. this.nvabarData={
  532. showCapsule: 1,
  533. title: '商品详情',
  534. }
  535. }else{
  536. this.headerColor = false
  537. this.nvabarData={
  538. showCapsule: 1,
  539. title: '',
  540. }
  541. }
  542. if(e.scrollTop>700){
  543. this.navbarFiexd = 'fixed'
  544. }else{
  545. this.navbarFiexd = 'none'
  546. }
  547. },
  548. onShareAppMessage(res){//分享转发
  549. if (res.from === 'button') {
  550. // 来自页面内转发按钮
  551. }
  552. return {
  553. title: `${this.product.name}`,
  554. path: `pages/goods/product?type=share&id=${this.productID}`,
  555. imageUrl:`${this.productImage[0]}`
  556. }
  557. },
  558. onShow() {
  559. this.$api.getStorage().then((resolve) => {
  560. this.userID = resolve.userID ? resolve.userID : '';
  561. this.userIdentity = resolve.userIdentity ? resolve.userIdentity : 3
  562. if (isPreviewImg) {
  563. isPreviewImg = false;
  564. return;
  565. } else {
  566. this.initData();
  567. }
  568. }).catch(error =>{
  569. this.initData();
  570. })
  571. }
  572. }
  573. </script>
  574. <style lang="scss">
  575. page{
  576. background-color: #F7F7F7;
  577. }
  578. .productRemarks{
  579. height: 36rpx;
  580. margin: 8rpx 0;
  581. width: 100%;
  582. float: left;
  583. .text{
  584. display: inline-block;
  585. padding: 0 18rpx;
  586. line-height: 32rpx;
  587. font-size: 20rpx;
  588. color: #FF2A2A;
  589. text-align: center;
  590. border-radius: 4rpx;
  591. background: #FFFFFF;
  592. border: 1px solid #FF2A2A;
  593. float: left;
  594. opacity: 0.8;
  595. }
  596. }
  597. .banner-section{
  598. width: 100%;
  599. height: 750rpx;
  600. position: relative;
  601. border-bottom: 1px solid #EBEBEB;
  602. }
  603. .banner{
  604. width: 100%;
  605. height: 750rpx;
  606. .product-img{
  607. width: 750rpx;
  608. }
  609. image {
  610. width: 100%;
  611. height: 100%;
  612. }
  613. }
  614. .swiper__dots-box{
  615. position: absolute;
  616. bottom: 24px;
  617. right: 24rpx;
  618. /* #ifndef APP-NVUE */
  619. display: flex;
  620. /* #endif */
  621. flex: 1;
  622. flex-direction: row;
  623. justify-content: center;
  624. align-items: center;
  625. height: 12rpx;
  626. padding: 10rpx;
  627. background: rgba(174,174,174,0.6);
  628. border-radius:16rpx;
  629. .swiper__dots-item{
  630. width: 12rpx;
  631. height: 12rpx;
  632. border-radius: 100%;
  633. margin: 6rpx;
  634. background: rgba(62,62,62,1);
  635. }
  636. .none{
  637. background:#FFFFFF;
  638. }
  639. .swiper__dots-long{
  640. background: rgba(62,62,62,1);
  641. transition: all 0.1s;
  642. }
  643. }
  644. .product-wrap{
  645. width: 100%;
  646. height: auto;
  647. padding: 24rpx 0 0 0;
  648. background-color: #FFFFFF;
  649. border-bottom: 20rpx solid #F7F7F7;
  650. .wrap-top{
  651. width: 702rpx;
  652. padding: 0 24rpx;
  653. height: auto;
  654. float: left;
  655. padding-bottom:20rpx;
  656. border-bottom: 1px solid #F8F8F8;
  657. &.none{
  658. .p-title{
  659. color:#999999
  660. }
  661. }
  662. .p-title{
  663. line-height: 40rpx;
  664. font-size: $font-size-28;
  665. color: $text-color;
  666. font-weight: Bold;
  667. -o-text-overflow: ellipsis;
  668. text-overflow: ellipsis;
  669. display: -webkit-box;
  670. word-break: break-all;
  671. -webkit-box-orient: vertical;
  672. -webkit-line-clamp: 2;
  673. overflow: hidden;
  674. }
  675. .wrap-main-text{
  676. line-height: 56rpx;
  677. color: #FF2A2A;
  678. font-size: $font-size-26;
  679. display: block;
  680. float: left;
  681. font-weight: normal;
  682. }
  683. .wrap-main-none{
  684. display: block;
  685. width: 256rpx;
  686. height: 44rpx;
  687. padding-left: 20rpx;
  688. border-radius: 11rpx;
  689. background: $btn-confirm;
  690. float: right;
  691. line-height: 44rpx;
  692. color: #FFFFFF;
  693. text-align: center;
  694. font-size: $font-size-24;
  695. }
  696. .p-price-none{
  697. height: 44rpx;
  698. line-height: 44rpx;
  699. float: left;
  700. font-size: $font-size-24;
  701. color: #666;
  702. text-decoration: line-through;
  703. margin-left: 8rpx;
  704. }
  705. .p-minBuy{
  706. height: 44rpx;
  707. line-height: 44rpx;
  708. float: right;
  709. padding: 0 18rpx;
  710. border-radius: 22rpx;
  711. background-color: #f7f7f7;
  712. color: #7F7F7F;
  713. font-size: 24rpx;
  714. text-align: center;
  715. .min-text{
  716. margin: 0 6rpx;
  717. }
  718. }
  719. .p-login{
  720. height: 56rpx;
  721. line-height: 56rpx;
  722. color: $color-system;
  723. font-size: $font-size-24;
  724. &.grade{
  725. .price-left{
  726. float: left;
  727. .none{
  728. display: block;
  729. font-size: $font-size-20;
  730. line-height: 48rpx;
  731. color: #4A4B54;
  732. float: left;
  733. font-weight: bold;
  734. margin-left: 5rpx;
  735. text{
  736. letter-spacing: 4rpx;
  737. font-size: $font-size-32;
  738. }
  739. }
  740. }
  741. }
  742. .p-no{
  743. float: left;
  744. margin-right: 5rpx;
  745. font-size: $font-size-28;
  746. color: $text-color;
  747. }
  748. .p-login-btn{
  749. display: block;
  750. height: 44rpx;
  751. padding: 0 10rpx 0 20rpx;
  752. border-radius: 11rpx;
  753. background: $btn-confirm;
  754. float: right;
  755. line-height: 44rpx;
  756. color: #FFFFFF;
  757. text-align: center;
  758. font-size: $font-size-24;
  759. }
  760. }
  761. }
  762. .wrap-label{
  763. float: left;
  764. width: 100%;
  765. box-sizing: border-box;
  766. .label-a{
  767. padding: 0 18rpx;
  768. line-height: 32rpx;
  769. font-size: $font-size-20;
  770. color: #999999;
  771. text-align: center;
  772. border-radius: 16rpx;
  773. background:#FFFFFF;
  774. margin: 0 20rpx 15rpx 0;
  775. display: inline-block;
  776. border: 1px solid #EDEDED;
  777. }
  778. }
  779. .wrap-top-price{
  780. float: left;
  781. width: 100%;
  782. box-sizing: border-box;
  783. .wrap-main-item{
  784. width: 100%;
  785. height: 56rpx;
  786. .p-price{
  787. height: 56rpx;
  788. line-height: 56rpx;
  789. float: left;
  790. color: #FF2A2A;
  791. &.none{
  792. text-decoration: line-through;
  793. color: #999999;
  794. }
  795. .txt{
  796. margin:0 2rpx;
  797. }
  798. .txt.sm{
  799. font-size: $font-size-24;
  800. }
  801. .txt.big{
  802. font-size: $font-size-32;
  803. }
  804. }
  805. }
  806. .floor-item-act{
  807. height: 56rpx;
  808. text-align: center;
  809. box-sizing: border-box;
  810. float: left;
  811. padding:10rpx 0;
  812. margin-left: 10rpx;
  813. .floor-tags{
  814. float: right;
  815. height: 36rpx;
  816. border-radius: 4rpx;
  817. background-color: rgba(225, 86, 22, 0.1);
  818. line-height: 36rpx;
  819. color: $color-system;
  820. text-align: center;
  821. display: inline-block;
  822. padding:0 16rpx;
  823. font-size: $font-size-20;
  824. }
  825. }
  826. .floor-item-btn{
  827. float: right;
  828. height: 40rpx;
  829. margin-top: 8rpx;
  830. .btn{
  831. line-height: 40rpx;
  832. padding: 0 20rpx;
  833. height: 40rpx;
  834. background: $btn-confirm;
  835. color: #FFFFFF;
  836. font-size: $font-size-20;
  837. border-radius: 4rpx;
  838. }
  839. }
  840. }
  841. .wrap-info{
  842. float: left;
  843. width: 702rpx;
  844. padding: 24rpx 24rpx 0 24rpx;
  845. border-bottom: 1px solid #F8F8F8;
  846. .info-viewT{
  847. width: 100%;
  848. min-height: 40rpx;
  849. font-size: $font-size-28;
  850. color: $text-color;
  851. line-height: 40rpx;
  852. text-align: left;
  853. &.none{
  854. color: #999999;
  855. }
  856. .info-viewL{
  857. min-width: 350rpx;
  858. float: left;
  859. margin-bottom: 24rpx;
  860. }
  861. .info-viewR{
  862. min-width: 352rpx;
  863. float: left;
  864. margin-bottom: 24rpx;
  865. }
  866. }
  867. .info-viewB{
  868. width: 100%;
  869. height: auto;
  870. }
  871. .info-f{
  872. width: 50%;
  873. float: left;
  874. font-size: $font-size-28;
  875. color: $text-color;
  876. line-height: 40rpx;
  877. margin-bottom: 24rpx;
  878. text-align: left;
  879. }
  880. }
  881. .wrap-seve{
  882. float: left;
  883. width: 702rpx;
  884. padding: 0 24rpx;
  885. height: 72rpx;
  886. line-height: 72rpx;
  887. font-size: $font-size-28;
  888. color: $text-color;
  889. border-bottom: 1px solid #F8F8F8;
  890. &.none{
  891. color: #999999;
  892. .text{
  893. color: #999999;
  894. }
  895. }
  896. .iconfont{
  897. color: $color-system;
  898. margin-left: 20rpx;
  899. font-size: $font-size-24;
  900. }
  901. .text{
  902. font-size: $font-size-24;
  903. color: $text-color;
  904. margin-left: 10rpx;
  905. }
  906. }
  907. }
  908. .product-supplier{
  909. width: 702rpx;
  910. height: 88rpx;
  911. padding: 0 24rpx;
  912. background-color: #FFFFFF;
  913. margin-bottom: 24rpx;
  914. position: relative;
  915. display: flex;
  916. .title{
  917. display: flex;
  918. flex: 2;
  919. line-height: 88rpx;
  920. display: inline-block;
  921. float: left;
  922. font-size: $font-size-28;
  923. color: $text-color;
  924. }
  925. .name{
  926. display: flex;
  927. flex: 2;
  928. line-height: 88rpx;
  929. display: inline-block;
  930. float: left;
  931. font-size: $font-size-24;
  932. color: #999999;
  933. float: right;
  934. padding-right: 48rpx;
  935. overflow: hidden;
  936. text-overflow:ellipsis;
  937. white-space: nowrap;
  938. text-align: right;
  939. }
  940. .icon-xiayibu{
  941. line-height: 88rpx;
  942. display: inline-block;
  943. position: absolute;
  944. width: 48rpx;
  945. top: 0;
  946. right: 0;
  947. }
  948. }
  949. .product-details {
  950. height: 100%;
  951. background: #FFFFFF;
  952. .navbar {
  953. width: 702rpx;
  954. height: 96rpx;
  955. padding: 0 24rpx;
  956. background: #fff;
  957. z-index: 10;
  958. display: flex;
  959. border-bottom: 1px solid #F8F8F8;
  960. &.fixed{
  961. position: fixed;
  962. left: 0;
  963. }
  964. .nav-item {
  965. display: flex;
  966. flex: 1;
  967. justify-content: center;
  968. align-items: center;
  969. height: 96rpx;
  970. font-size: $font-size-28;
  971. color: $text-color;
  972. position: relative;
  973. float: left;
  974. position: relative;
  975. .line{
  976. width: 60%;
  977. height: 2px;
  978. border-radius: 1px;
  979. background: #FFFFFF;
  980. position: absolute;
  981. bottom: 0;
  982. left: 50%;
  983. margin-left: -30%;
  984. }
  985. &.current{
  986. color:$color-system;
  987. .line{
  988. background: $color-system;
  989. }
  990. }
  991. }
  992. }
  993. .content{
  994. width: 100%;
  995. min-height: 750rpx;
  996. }
  997. }
  998. .isLower{
  999. width: 100%;
  1000. height: 116rpx;
  1001. line-height: 116rpx;
  1002. text-align: center;
  1003. color: #000000;
  1004. font-size: $font-size-32;
  1005. font-weight: bold;
  1006. }
  1007. .bottom-btn{
  1008. width: 100%;
  1009. height: 110rpx;
  1010. position: fixed;
  1011. bottom: 0;
  1012. left: 0;
  1013. background: #FFFFFF;
  1014. z-index: 99;
  1015. .bottom-le{
  1016. width: 302rpx;
  1017. height: 86rpx;
  1018. padding:12rpx 24rpx;
  1019. float: left;
  1020. .item-bt{
  1021. width: 86rpx;
  1022. height: 100%;
  1023. margin-right:22rpx;
  1024. display: flex;
  1025. float: left;
  1026. flex-direction: column;
  1027. align-items: center;
  1028. font-size: $font-size-24;
  1029. color: $text-color;
  1030. line-height: 34rpx;
  1031. position: relative;
  1032. .animation-num{
  1033. font-size:$font-size-32 ;
  1034. color: #FF2A2A;
  1035. position: absolute;
  1036. top: -12rpx;
  1037. right: 4rpx;
  1038. font-weight: bold;
  1039. }
  1040. .animation{
  1041. animation: showAmnation 2.2s ease-in-out both;
  1042. }
  1043. .restion{
  1044. animation: hideAmnation 1s ease-in-out both;
  1045. }
  1046. .icon-num{
  1047. position: absolute;
  1048. right:-12rpx;
  1049. top: -9rpx;
  1050. }
  1051. .icon-num.goleft{
  1052. right: 4rpx;
  1053. }
  1054. &:last-child{
  1055. margin-right: 0;
  1056. }
  1057. image {
  1058. width: 40rpx;
  1059. height: 40rpx;
  1060. margin-bottom: 8rpx;
  1061. }
  1062. button.contact-btn{
  1063. width: 100%;
  1064. height: 100%;
  1065. margin: 0;
  1066. padding: 0;
  1067. display: flex;
  1068. flex-direction: column;
  1069. align-items: center;
  1070. box-sizing: border-box;
  1071. font-size: $font-size-24;
  1072. text-align: center;
  1073. text-decoration: none;
  1074. line-height: 34rpx;
  1075. border-radius: 0;
  1076. -webkit-tap-highlight-color: transparent;
  1077. overflow: hidden;
  1078. color: $text-color;
  1079. background-color:#FFFFFF;
  1080. }
  1081. }
  1082. }
  1083. .bottom-ri{
  1084. width: 400rpx;
  1085. height: 100%;
  1086. float: right;
  1087. display: flex;
  1088. .btn{
  1089. flex: 1;
  1090. width: 200rpx;
  1091. line-height: 110rpx;
  1092. text-align: center;
  1093. font-size: $font-size-28;
  1094. color: #FFFFFF;
  1095. }
  1096. .btn-cart{
  1097. background-color: #EFAF00;
  1098. }
  1099. .btn-cart.disabled{
  1100. background-color: rgba(239, 175, 0, 0.5);
  1101. }
  1102. .btn-bay{
  1103. background:linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  1104. }
  1105. .btn-bay.disabled{
  1106. background-color: linear-gradient(135deg,rgba(242,143,49,0.5) 0%,rgba(225,86,22,0.5) 100%);;
  1107. }
  1108. }
  1109. }
  1110. .uni-badge--small {
  1111. -webkit-transform: scale(.8);
  1112. -ms-transform: scale(.8);
  1113. transform: scale(.8);
  1114. -webkit-transform-origin: center center;
  1115. -ms-transform-origin: center center;
  1116. transform-origin: center center;
  1117. }
  1118. .uni-badge {
  1119. font-family: 'Helvetica Neue', Helvetica, sans-serif;
  1120. -webkit-box-sizing: border-box;
  1121. box-sizing: border-box;
  1122. font-size: 12px;
  1123. line-height: 1;
  1124. display: inline-block;
  1125. padding: 3px 6px;
  1126. color: #333;
  1127. border-radius: 100px;
  1128. background-color: #f1f1f1;
  1129. }
  1130. .uni-badge-error {
  1131. color: #fff;
  1132. background-color: #dd524d;
  1133. }
  1134. /* 加入购物模态层*/
  1135. @keyframes showPopup {
  1136. 0% {
  1137. opacity: 0;
  1138. }
  1139. 100% {
  1140. opacity: 1;
  1141. }
  1142. }
  1143. @keyframes hidePopup {
  1144. 0% {
  1145. opacity: 1;
  1146. }
  1147. 100% {
  1148. opacity: 0;
  1149. }
  1150. }
  1151. @keyframes showLayer {
  1152. 0% {
  1153. transform: translateY(0);
  1154. }
  1155. 100% {
  1156. transform: translateY(-100%);
  1157. }
  1158. }
  1159. @keyframes hideLayer {
  1160. 0% {
  1161. transform: translateY(-100%);
  1162. }
  1163. 100% {
  1164. transform: translateY(0);
  1165. }
  1166. }
  1167. @keyframes showAmnation {
  1168. 0% {
  1169. top: -12rpx;
  1170. opacity: 0;
  1171. }
  1172. 50% {
  1173. top: -60rpx;
  1174. opacity: 1;
  1175. }
  1176. 100% {
  1177. top: -100rpx;
  1178. opacity: 0;
  1179. }
  1180. }
  1181. @keyframes hideAmnation {
  1182. 0% {
  1183. top: -100rpx;
  1184. opacity: 0;
  1185. }
  1186. 100% {
  1187. top: -12rpx;
  1188. opacity: 0;
  1189. }
  1190. }
  1191. .popup {
  1192. position: fixed;
  1193. top: 0;
  1194. width: 100%;
  1195. height: 100%;
  1196. z-index: 999;
  1197. display: none;
  1198. .mask{
  1199. position: fixed;
  1200. top: 0;
  1201. width: 100%;
  1202. height: 100%;
  1203. z-index: 21;
  1204. background-color: rgba(0, 0, 0, 0.6);
  1205. }
  1206. .layer {
  1207. position: fixed;
  1208. z-index: 22;
  1209. bottom: -294rpx;
  1210. width: 702rpx;
  1211. padding: 24rpx 24rpx 36rpx 24rpx;
  1212. height: 260rpx;
  1213. border-radius: 20rpx 20rpx 0 0;
  1214. background-color: #fff;
  1215. display: flex;
  1216. flex-wrap: wrap;
  1217. align-content: space-between;
  1218. .content {
  1219. width: 100%;
  1220. }
  1221. .btn {
  1222. width: 100%;
  1223. height: 88rpx;
  1224. margin-top: 20rpx;
  1225. .button {
  1226. width: 100%;
  1227. height: 88rpx;
  1228. color: #fff;
  1229. display: flex;
  1230. align-items: center;
  1231. justify-content: center;
  1232. background: $btn-confirm;
  1233. font-size: $font-size-28;
  1234. border-radius: 14rpx;
  1235. }
  1236. }
  1237. }
  1238. &.show {
  1239. display: block;
  1240. .mask{
  1241. animation: showPopup 0.2s linear both;
  1242. }
  1243. .layer {
  1244. animation: showLayer 0.2s linear both;
  1245. }
  1246. }
  1247. &.hide {
  1248. display: block;
  1249. .mask{
  1250. animation: hidePopup 0.2s linear both;
  1251. }
  1252. .layer {
  1253. animation: hideLayer 0.2s linear both;
  1254. }
  1255. }
  1256. &.none {
  1257. display: none;
  1258. }
  1259. &.service {
  1260. .row {
  1261. margin: 30upx 0;
  1262. .title {
  1263. font-size: 30upx;
  1264. margin: 10upx 0;
  1265. }
  1266. .description {
  1267. font-size: 28upx;
  1268. color: #999;
  1269. }
  1270. }
  1271. }
  1272. .layer-smimg{
  1273. width: 114rpx;
  1274. height: 114rpx;
  1275. float: left;
  1276. border-radius: 10rpx;
  1277. margin-right: 24rpx;
  1278. image{
  1279. width: 114rpx;
  1280. height: 114rpx;
  1281. border-radius: 10rpx;
  1282. }
  1283. }
  1284. .layer-nunbox{
  1285. justify-content: space-between;
  1286. align-items: center;
  1287. width: 536rpx;
  1288. height: auto;
  1289. float: left;
  1290. .layer-nunbox-t{
  1291. width: 100%;
  1292. height:44rpx;
  1293. position:relative;
  1294. display: flex;
  1295. margin-bottom: 10rpx;
  1296. .text{
  1297. font-size: $font-size-24;
  1298. line-height: 48rpx;
  1299. color: #999999;
  1300. }
  1301. .layer-nunbox-text{
  1302. line-height: 44rpx;
  1303. font-size: $font-size-28;
  1304. }
  1305. .number-box{
  1306. display: flex;
  1307. justify-content: center;
  1308. align-items: center;
  1309. .iconfont{
  1310. font-size: $font-size-32;
  1311. padding:0 20rpx;
  1312. font-size: $text-color;
  1313. }
  1314. .btn-input{
  1315. width: 62rpx;
  1316. height: 48rpx;
  1317. line-height: 48rpx;
  1318. background: #F8F8F8;
  1319. border-radius: 4rpx;
  1320. text-align: center;
  1321. font-size: $font-size-28;
  1322. }
  1323. }
  1324. .product-step{
  1325. position: absolute;
  1326. left: 45rpx;
  1327. bottom: 0;
  1328. height: 44rpx;
  1329. background: #FFFFFF;
  1330. }
  1331. }
  1332. .layer-nunbox-b{
  1333. width: 100%;
  1334. height:44rpx;
  1335. margin-top: 13rpx;
  1336. }
  1337. .text{
  1338. line-height: 44rpx;
  1339. font-size: $font-size-28;
  1340. .p{
  1341. color: #FF2A2A;
  1342. }
  1343. .p:first-child{
  1344. margin-left: 30rpx;
  1345. }
  1346. .p.sm{
  1347. font-size: $font-size-24;
  1348. }
  1349. }
  1350. }
  1351. }
  1352. /*富文本样式*/
  1353. rich-text.p{
  1354. width: 702rpx !important;
  1355. padding: 0 24rpx;
  1356. text-align: justify;
  1357. }
  1358. rich-text.img{
  1359. width: 100%;
  1360. height: auto;
  1361. }
  1362. </style>