product.vue 34 KB

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