product.vue 34 KB

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