productDetails.vue 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483
  1. <template>
  2. <view class="content" style="padding-bottom: 144rpx;">
  3. <!-- 商品轮播图片 -->
  4. <view class="shop-banner" @click="showImg()">
  5. <swiper class="swiper" :indicator-dots="false" :circular="true" :autoplay="true" :interval="3000"
  6. :duration="1000" indicator-color="rgba(255, 255, 255, 0.6)" indicator-active-color="#ffffff"
  7. @change="swiperChange">
  8. <swiper-item class="swiper-item" v-for="(item,index) in banner" :key="index">
  9. <image :src="item" mode="aspectFill"></image>
  10. </swiper-item>
  11. </swiper>
  12. <!-- 底部遮罩 -->
  13. <view class="banner-mask"></view>
  14. <!-- 数量 -->
  15. <view class="num-box">{{ activeBanner }}/{{ banner.length }}</view>
  16. </view>
  17. <!-- 详细信息 -->
  18. <view class="det-info">
  19. <view class="price-box">
  20. <view class="price">
  21. <text class="label" style="color: #FF5C03;">会员价</text>
  22. <text class="unit">¥</text>
  23. <text class="num">{{product.price}}</text>
  24. <text class="label">零售价</text>
  25. <text class="old">¥{{product.otPrice}}</text>
  26. </view>
  27. <view class="share-box">
  28. <text class="text">分享</text>
  29. <image
  30. src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/shopping/share1.png"
  31. mode=""></image>
  32. <button class="share" data-name="shareBtn" open-type="share">分享</button>
  33. </view>
  34. </view>
  35. <view class="name-box">
  36. <view class="tag" :style="{background:_background(product.productType)}">
  37. {{$getDictLabelName("storeProductType",product.productType)}}</view>{{product.productName}}
  38. </view>
  39. <view class="intro" v-if="product.productInfo!=null" v-html="product.productInfo.replace(/\n/g,'<br>')">
  40. </view>
  41. </view>
  42. <view class="other-box">
  43. <view class="other-box-item">
  44. <view class="label">产品名称</view>
  45. <view class="text">{{product.productName||'--'}}</view>
  46. </view>
  47. <view class="other-box-item">
  48. <view class="label">包装规格</view>
  49. <view class="text">{{product.prescribeSpec||'--'}}</view>
  50. </view>
  51. <view class="other-box-item">
  52. <view class="label">包装单位</view>
  53. <view class="text">{{product.unitName||'--'}}</view>
  54. </view>
  55. <view class="other-box-item">
  56. <view class="label">批准文号</view>
  57. <view class="text">{{product.drugRegCertNo||'--'}}</view>
  58. </view>
  59. <view class="other-box-item">
  60. <view class="label">生产厂家</view>
  61. <view class="text">{{product.mah||'--'}}</view>
  62. </view>
  63. <view class="other-box-item">
  64. <view class="label">商品条码</view>
  65. <view class="text">{{product.barCode||'--'}}</view>
  66. </view>
  67. <!-- <view class="other-box-item">
  68. <view class="label">功能主治</view>
  69. <view class="text">{{product.indications||'--'}}</view>
  70. </view> -->
  71. <!-- <view class="other-box-item" v-if="product.sales">
  72. <view class="label">已售</view>
  73. <view class="text">{{$formatSalesNum(product.sales)}}</view>
  74. </view>
  75. <view class="other-box-item">
  76. <view class="label" style="width: 4em;">服务</view>
  77. <view class="safe-box">
  78. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/shopping/safe.png"
  79. mode=""></image>
  80. <text class="text" style="margin-right: 34rpx;">品质保障</text>
  81. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/shopping/safe.png"
  82. mode=""></image>
  83. <text class="text" style="margin-right: 34rpx;">药师服务</text>
  84. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/shopping/safe.png"
  85. mode=""></image>
  86. <text class="text">隐私保护</text>
  87. </view>
  88. </view> -->
  89. </view>
  90. <!-- 购买人数、库存 -->
  91. <!-- <view class="inventor">
  92. <view class="left">
  93. <view class="head-box">
  94. <view class="head" v-for="(item,j) in 5" :key="j">
  95. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/shopping/head.jpg" mode=""></image>
  96. </view>
  97. </view>
  98. <view class="num-box">
  99. 已有 <text class="text">{{product.sales}}</text> 人购买
  100. </view>
  101. </view>
  102. <view class="right">
  103. 库存 <text class="text">{{product.stock}}{{product.unitName}}</text>
  104. </view>
  105. <view class="right">
  106. <text class="text">库存{{product.stock>0?'充足':'售罄'}} </text>
  107. </view>
  108. </view> -->
  109. <!-- 功效 -->
  110. <view class="effect" v-if="product.instructionManual">
  111. <view class="label">{{product.productName}}药品说明书</view>
  112. <view :class="product.productType ==2&&isView==0 ? 'hiddenbox':''" style="margin-top: 20rpx;">
  113. <u-parse :content="product.instructionManual" :style="{display: 'block'}"></u-parse>
  114. </view>
  115. <view class="shadowbox" v-if="product.productType ==2&&isView==0">
  116. <view class="shadowbox-btn x-ac" @click="handleShow">
  117. <text style="margin-right: 10rpx;">点击查看说明书全文</text>
  118. <u-icon name="arrow-down" color="#999" size="14"></u-icon>
  119. </view>
  120. </view>
  121. </view>
  122. <u-popup :show="show" mode="center" :round="10" @close="show=false" :closeOnClickOverlay="false">
  123. <view class="popupbox">
  124. <view class="popupbox-title">如何查看说明书</view>
  125. <view class="popupbox-body">
  126. 需要先问诊获得处方后才能查看说明书,请点<text class="confirm" @click="addCart('buy')">问诊开药</text>开处方!
  127. </view>
  128. <view class="popupbox-footer" @click="show=false">我知道了</view>
  129. </view>
  130. </u-popup>
  131. <!-- 商品评价 -->
  132. <view class="det-box evaluate">
  133. <view class="title">商品评价({{evaluateTotal}})</view>
  134. <view class="evaluate">
  135. <evaluateItem v-for="(item,index) in evaluate" :key="index" :item="item"></evaluateItem>
  136. <view class="footer-desc" v-if="evaluate&&evaluate.length>0">
  137. <text @click="moreEvaluate">查看更多评价</text>
  138. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/arrow_gray.png"></image>
  139. </view>
  140. </view>
  141. </view>
  142. <!-- 图文详情 -->
  143. <view class="det-box">
  144. <view class="title">图文详情</view>
  145. <view class="inner">
  146. <view v-html="product.description" style="font-size:0"></view>
  147. </view>
  148. <view class="other-box" style="margin: 0;padding: 24rpx 0;" v-if="product.productType !=2||isView==1">
  149. <view class="other-box-item" v-if="product.indications">
  150. <view class="label" style="margin-right: 16rpx;">【功能主治】</view>
  151. <view class="text">{{product.indications}}</view>
  152. </view>
  153. <view class="other-box-item" v-if="product.dosage">
  154. <view class="label" style="margin-right: 16rpx;">【用法用量】</view>
  155. <view class="text">{{product.dosage}}</view>
  156. </view>
  157. <view class="other-box-item" v-if="product.adverseReactions">
  158. <view class="label" style="margin-right: 16rpx;">【不良反应】</view>
  159. <view class="text">{{product.adverseReactions}}</view>
  160. </view>
  161. <view class="other-box-item" v-if="product.contraindications">
  162. <view class="label" style="margin-right: 16rpx;">【禁忌】</view>
  163. <view class="text">{{product.contraindications}}</view>
  164. </view>
  165. <view class="other-box-item" v-if="product.precautions">
  166. <view class="label" style="margin-right: 16rpx;">【注意事项】</view>
  167. <view class="text">{{product.precautions}}</view>
  168. </view>
  169. </view>
  170. </view>
  171. <view class="storebox" v-if="chooseStore.storeId">
  172. <view class="x-bc">
  173. <view class="x-f">
  174. <image class="logo" :src="chooseStore.logoUrl" mode="aspectFill"></image>
  175. <view class="storebox-r" @click="goStoreDetail(chooseStore)">
  176. <view class="storename ellipsis2">{{chooseStore.storeName||''}}</view>
  177. <!-- <view class="storedesc">24小时营业 销售{{$formatSalesNum(chooseStore.salesCount) }}</view> -->
  178. </view>
  179. </view>
  180. <view class="storebox-btn" @click="goStoreDetail(chooseStore)">进店</view>
  181. </view>
  182. <detail :source="'product'" ref="getStoreInfo" :storeInfo="storeInfo"></detail>
  183. </view>
  184. <!-- 底部按钮 -->
  185. <view class="btn-foot">
  186. <view class="menu-box">
  187. <view class="item" @click="goHome">
  188. <image
  189. src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/shopping/back_home.png"
  190. mode=""></image>
  191. <text class="label">首页</text>
  192. </view>
  193. <!-- <view class="item" style="position: relative;">
  194. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/shopping/consult_small.png" mode=""></image>
  195. <text class="label">咨询</text>
  196. <button class="contact-btn" open-type="contact"></button>
  197. </view> -->
  198. <view class="item" @click="navgetTo('./cart')">
  199. <view class="img-item">
  200. <u-badge type="error" max="99" :value="cartCount" :offset="[-10,-10]"
  201. :absolute="true"></u-badge>
  202. <image
  203. src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/fs/20250929/73574822bab04a86ae77b772b4e28952.png"
  204. mode=""></image>
  205. </view>
  206. <text class="label">购物车</text>
  207. </view>
  208. </view>
  209. <view class="btn-box">
  210. <view class="btn cart" @click="addCart('cart')">加入购物车</view>
  211. <view class="btn buy" @click="addCart('buy')">{{buyText}}</view>
  212. </view>
  213. </view>
  214. <!-- 选择药品规格弹窗 -->
  215. <popupBottom ref="popup" :visible.sync="specVisible" title=" " radius="32" maxHeight="1024">
  216. <view class="product-spec">
  217. <!-- 商品信息 -->
  218. <view class="pro-info">
  219. <view class="img-box" @click="showImg(productValueSelect.image)">
  220. <image
  221. :src="productValueSelect.image==null||productValueSelect.image==''?product.image:productValueSelect.image"
  222. mode="aspectFill"></image>
  223. </view>
  224. <view class="info-text">
  225. <view class="price">
  226. <text class="unit">¥</text>
  227. <text class="num">{{ productValueSelect.price.toFixed(2) }}</text>
  228. </view>
  229. <view class="desc-box">
  230. <text class="text">已选:{{ productValueSelect.sku }}</text>
  231. <text class="text">库存{{ productValueSelect.stock?'充足':'售罄' }}</text>
  232. </view>
  233. </view>
  234. </view>
  235. <!-- 规格 -->
  236. <view class="spec-box">
  237. <view v-for="(item,index) in attrs">
  238. <view class="title">{{item.attrName}}</view>
  239. <view class="spec-list">
  240. <view v-for="(subItem,subindex) in item.values" :key="subindex"
  241. :class="subindex==item.index?'item active':'item'" @click="choseSpec(index,subindex)">
  242. {{ subItem }}
  243. </view>
  244. </view>
  245. </view>
  246. </view>
  247. <!-- 数量 -->
  248. <view class="price-num">
  249. <view class="label">数量</view>
  250. <view class="num-box">
  251. <view class="img-box" @click="lessNum()">
  252. <image v-if="specNum <= 1"
  253. src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/shopping/jian.png"
  254. mode=""></image>
  255. <image v-else
  256. src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/shopping/jian2.png"
  257. mode=""></image>
  258. </view>
  259. <input type="number" @change="changeNum" v-model="specNum" />
  260. <view class="img-box" @click="addNum()">
  261. <image
  262. src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/shopping/add.png"
  263. mode=""></image>
  264. </view>
  265. </view>
  266. </view>
  267. <view class="sub-btn" @click="submit">确定</view>
  268. </view>
  269. </popupBottom>
  270. <view class="loadding" v-if="loadding==true">
  271. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/logo.png"></image>
  272. <text class="text">加载中...</text>
  273. </view>
  274. </view>
  275. </template>
  276. <script>
  277. import detail from '@/components/storeDetail.vue'
  278. import {getCartCount,storeDetail} from '@/api/index.js'
  279. import {getDicts} from '@/api/common.js'
  280. import { getProductDetails, addCart,instructionsViewable } from './api/product.js'
  281. import {selectCommentByUser} from '@/api/myStoreOrder.js'
  282. import popupBottom from './components/px-popup-bottom.vue'
  283. import evaluateItem from '@/components/evaluateItem.vue'
  284. export default {
  285. components: {
  286. popupBottom,
  287. evaluateItem,
  288. detail
  289. },
  290. data() {
  291. return {
  292. loadding: true,
  293. buyText: "立即购买",
  294. type: null,
  295. productValueSelect: {
  296. price: 0,
  297. },
  298. banner: [],
  299. productId: null,
  300. attrs: [],
  301. values: [],
  302. product: {
  303. price: 0,
  304. otPrice: 0,
  305. },
  306. // 当前轮播的图片
  307. activeBanner: 1,
  308. // 购物车数量
  309. cartCount: 0,
  310. // 规格弹窗
  311. specVisible: false,
  312. // 规格数量
  313. specNum: 1,
  314. chooseStore: {},
  315. storeList: [],
  316. storeId: '',
  317. evaluateTotal: 0,
  318. evaluate: [],
  319. show: false,
  320. isView: 0,
  321. storeInfo: {},
  322. stockNum: 0
  323. };
  324. },
  325. computed: {
  326. _background() {
  327. //productType: 1:OTC,2:Rx,3:非药品,4:器械
  328. return (productType) => {
  329. switch (productType) {
  330. case 1:
  331. return '#37E2EA' // OTC
  332. case 2:
  333. return 'red' // Rx
  334. case 3:
  335. return '#2583EB' // 非药品
  336. case 4:
  337. return '#999' // 器械
  338. default:
  339. return '#ccc'
  340. }
  341. }
  342. }
  343. },
  344. onLoad(options) {
  345. if (options.userId != null) {
  346. uni.setStorageSync('tuiUserId', options.userId);
  347. } else if (options.hasOwnProperty('q') && options.q) {
  348. // 通过下面这步解码,可以拿到url的值
  349. const url = decodeURIComponent(options.q)
  350. this.url = url;
  351. // // 对url中携带的参数提取处理
  352. const obj = this.$urlToObj(url)
  353. uni.setStorageSync('tuiUserId', obj.userId);
  354. }
  355. this.storeId = options.storeId || '';
  356. uni.showShareMenu({
  357. withShareTicket: true,
  358. //小程序的原生菜单中显示分享按钮,才能够让发送给朋友与分享到朋友圈两个按钮可以点击
  359. menus: ["shareAppMessage", "shareTimeline"] //不设置默认发送给朋友
  360. })
  361. this.getDicts();
  362. this.productId = options.productId;
  363. this.$isLogin().then(res => {
  364. if (res) {
  365. this.getCartCount();
  366. }
  367. })
  368. },
  369. onShow() {
  370. this.getProductDetails();
  371. },
  372. //发送给朋友
  373. onShareAppMessage(res) {
  374. this.$isLogin().then(res => {
  375. if (res) {
  376. var user = JSON.parse(uni.getStorageSync('userInfo'))
  377. return {
  378. title: this.product.productName,
  379. path: '/pages_shopping/productDetails?productId=' + this.product.productId + "&userId=" +
  380. user.userId,
  381. }
  382. }
  383. })
  384. },
  385. //分享到朋友圈
  386. onShareTimeline(res) {
  387. this.$isLogin().then(res => {
  388. if (res) {
  389. var user = JSON.parse(uni.getStorageSync('userInfo'))
  390. return {
  391. title: this.product.productName,
  392. query: 'productId=' + this.product.productId + "&userId=" + user.userId, //页面参数
  393. }
  394. }
  395. })
  396. },
  397. methods: {
  398. getStoreInfo() {
  399. storeDetail(this.storeId).then(res=>{
  400. if(res.code==200) {
  401. this.storeInfo =res.data || {}
  402. this.storeInfo.doctorList = this.storeInfo.doctorList.map(doctor => {
  403. return {
  404. ...doctor,
  405. // 假设images字段是逗号分隔的图片字符串
  406. imagesArray: doctor.practiseImages ?
  407. doctor.practiseImages.split(',').map(img => img.trim()).filter(img => img) : []
  408. };
  409. });
  410. this.$refs.getStoreInfo.getDescHeight()
  411. }
  412. })
  413. },
  414. handleShow() {
  415. uni.showLoading({
  416. title: '加载中',
  417. icon: 'none'
  418. })
  419. instructionsViewable({productId: this.productId}).then(
  420. res => {
  421. uni.hideLoading()
  422. if(res.code==200){
  423. this.isView = res.data ? 1 : 0
  424. this.show = this.isView == 0
  425. }else{
  426. uni.showToast({
  427. icon:'none',
  428. title: "请求失败",
  429. });
  430. }
  431. },
  432. rej => {}
  433. );
  434. },
  435. goStoreDetail(item) {
  436. uni.navigateTo({
  437. url: '/pages_store/storeIndex?storeId=' + item.storeId
  438. })
  439. },
  440. getDicts: function() {
  441. getDicts().then(
  442. res => {
  443. if (res.code == 200) {
  444. uni.setStorageSync('dicts', JSON.stringify(res));
  445. }
  446. },
  447. rej => {}
  448. );
  449. },
  450. showImg(img) {
  451. if (img != null) {
  452. var imgs = [];
  453. imgs.push(img)
  454. //预览图片
  455. uni.previewImage({
  456. urls: imgs,
  457. current: imgs[0]
  458. });
  459. } else {
  460. //预览图片
  461. uni.previewImage({
  462. urls: this.banner,
  463. current: this.banner[0]
  464. });
  465. }
  466. },
  467. doAddCart(type) {
  468. if (this.specNum == 0) {
  469. uni.showToast({
  470. icon: 'none',
  471. title: "库存不足",
  472. });
  473. return;
  474. }
  475. var isBuy = type == "buy" ? 1 : 0;
  476. let data = {
  477. isBuy: isBuy,
  478. cartNum: this.specNum,
  479. productId: this.productValueSelect.productId,
  480. attrValueId: this.productValueSelect.id,
  481. type: 1
  482. };
  483. addCart(data).then(
  484. res => {
  485. if (res.code == 200) {
  486. if (type == "buy") {
  487. const selectCarts = [{
  488. storeId: this.storeId,
  489. data: {
  490. type: this.type,
  491. cartIds: res.id,
  492. }
  493. }]
  494. uni.navigateTo({
  495. url: '/pages_shopping/confirmOrder?type=' + this.type + '&orderType=' +
  496. this.orderType + '&confirmParam=' + encodeURIComponent(JSON.stringify(
  497. selectCarts))
  498. })
  499. } else {
  500. this.getCartCount()
  501. uni.showToast({
  502. icon: 'success',
  503. title: "添加成功",
  504. });
  505. }
  506. } else {
  507. uni.showToast({
  508. icon: 'none',
  509. title: res.msg,
  510. });
  511. this.getProductDetails()
  512. }
  513. },
  514. rej => {}
  515. );
  516. },
  517. getProductDetails() {
  518. let data = {
  519. productId: this.productId
  520. };
  521. getProductDetails(data).then(
  522. res => {
  523. this.loadding = false
  524. if (res.code == 200) {
  525. this.stockNum = res.num || 0;
  526. this.product = res.product;
  527. if (this.product.productType == 1) {
  528. this.buyText = "立即购买"
  529. } else if (this.product.productType == 2) {
  530. this.buyText = "开方购买"
  531. }
  532. this.product.otPrice = this.product.otPrice.toFixed(2);
  533. this.product.price = this.product.price.toFixed(2);
  534. if (this.product.sliderImage != null) {
  535. this.banner = this.product.sliderImage.split(',');
  536. } else {
  537. this.banner = []
  538. }
  539. this.attrs = res.productAttr;
  540. this.attrs.forEach((item, index, arr) => {
  541. item.values = item.attrValues.split(',');
  542. item.index = 0
  543. })
  544. console.log(this.attrs)
  545. this.values = res.productValues;
  546. this.storeId = res.store.storeId || ''
  547. this.storeList = [res.store] || [];
  548. if (this.storeList && this.storeList.length > 0) {
  549. const idx = this.storeList.indexOf(Number(this.storeId || 0));
  550. if (this.storeId && idx > -1) {
  551. this.chooseStore = this.storeList[idx]
  552. } else {
  553. this.chooseStore = this.storeList[0]
  554. }
  555. }
  556. this.choseSpec(0, 0)
  557. this.getCommentByUser()
  558. this.getStoreInfo();
  559. } else {
  560. uni.showToast({
  561. icon: 'none',
  562. title: res.msg,
  563. });
  564. setTimeout(function() {
  565. uni.reLaunch({
  566. url: '/pages/index/index',
  567. })
  568. }, 2000)
  569. }
  570. },
  571. rej => {}
  572. );
  573. },
  574. getCartCount() {
  575. let data = {};
  576. getCartCount(data).then(
  577. cartRes => {
  578. if (cartRes.code == 200) {
  579. this.cartCount = cartRes.data;
  580. }
  581. },
  582. rej => {}
  583. );
  584. },
  585. // swiper变化事件
  586. swiperChange(event) {
  587. this.activeBanner = event.detail.current + 1
  588. },
  589. // 回到首页
  590. goHome() {
  591. uni.switchTab({
  592. url: '/pages/index/index'
  593. })
  594. },
  595. // 跳转页面
  596. navgetTo(url) {
  597. this.$isLogin().then(res => {
  598. if (res) {
  599. uni.navigateTo({
  600. url: url
  601. })
  602. }
  603. })
  604. },
  605. // 加入购物车
  606. addCart(type) {
  607. this.show=false
  608. this.$isLogin().then(res => {
  609. if (res) {
  610. this.type = type;
  611. this.specVisible = true
  612. } else {
  613. uni.navigateTo({
  614. url: '/pages/auth/login'
  615. })
  616. }
  617. })
  618. },
  619. // 规格选择
  620. choseSpec(index, subIndex) {
  621. this.attrs[index].index = subIndex;
  622. this.$forceUpdate();
  623. let productAttr = this.attrs;
  624. let values = [];
  625. for (let i = 0; i < productAttr.length; i++) {
  626. for (let j = 0; j < productAttr[i].values.length; j++) {
  627. if (productAttr[i].index === j) {
  628. values.push(productAttr[i].values[j]);
  629. }
  630. }
  631. }
  632. var selectVal = values.sort().join(",");
  633. console.log('selectVal',selectVal,this.values)
  634. var valueSelect = this.values.filter((item) => {
  635. return item.sku == selectVal;
  636. })
  637. if (valueSelect != null && valueSelect.length == 1) {
  638. this.productValueSelect = valueSelect[0];
  639. }
  640. this.updateSpecNum();
  641. },
  642. //更新数量
  643. updateSpecNum() {
  644. if (this.productValueSelect.stock == 0) {
  645. this.specNum = 0;
  646. } else {
  647. this.specNum = 1;
  648. }
  649. },
  650. changeNum(e) {
  651. this.specNum = e.detail.value.replace(/\D/g, '')
  652. if (this.specNum < 1) {
  653. this.specNum = 1
  654. }
  655. if (this.specNum >= this.productValueSelect.stock) {
  656. this.specNum = this.productValueSelect.stock
  657. }
  658. },
  659. // 数量减法
  660. lessNum() {
  661. this.specNum--
  662. if (this.specNum < 1) {
  663. this.specNum = 1
  664. }
  665. if (this.specNum >= this.productValueSelect.stock) {
  666. this.specNum = this.productValueSelect.stock
  667. }
  668. },
  669. // 数量加法
  670. addNum() {
  671. if (this.specNum < 10) {
  672. this.specNum++
  673. } else {
  674. uni.showToast({
  675. icon: 'none',
  676. title: '限购10盒',
  677. });
  678. }
  679. if (this.specNum >= this.productValueSelect.stock) {
  680. this.specNum = this.productValueSelect.stock
  681. }
  682. },
  683. // 确定选择该规格
  684. submit() {
  685. this.specVisible = false
  686. this.doAddCart(this.type);
  687. },
  688. moreEvaluate() {
  689. uni.navigateTo({
  690. url: '/pages_shopping/evaluate?storeId='+this.storeId+ '&productIds='+this.productId,
  691. })
  692. },
  693. getCommentByUser(){
  694. const param = {
  695. page: 1,
  696. pageSize: 2,
  697. storeId:this.storeId,
  698. orderId: null,
  699. productIds:this.productId,
  700. userId: uni.getStorageSync('userId') || null,
  701. showSelf: 0
  702. }
  703. selectCommentByUser(param).then(res=>{
  704. if(res.code==200) {
  705. this.evaluate = res.data.list
  706. this.evaluateTotal = res.data.total
  707. } else {
  708. this.evaluate = []
  709. this.evaluateTotal = 0
  710. }
  711. })
  712. }
  713. }
  714. }
  715. </script>
  716. <style lang="scss" scoped>
  717. .hiddenbox {
  718. height: 240rpx;
  719. overflow: hidden;
  720. }
  721. .popupbox {
  722. width: 80vw;
  723. font-size: 32upx;
  724. font-family: PingFang SC;
  725. color: #333333;
  726. &-title{
  727. font-weight: bold;
  728. padding: 30rpx;
  729. text-align: center;
  730. }
  731. &-body {
  732. padding: 24rpx 30rpx;
  733. line-height: 2;
  734. }
  735. .confirm {
  736. background-color: #2583EB;
  737. border-radius: 10rpx;
  738. color: #fff;
  739. padding: 10rpx 24rpx;
  740. margin: 0 10rpx;
  741. }
  742. &-footer {
  743. border-top: 1rpx solid #F7F7F7;
  744. padding: 30rpx;
  745. color: red;
  746. text-align: center;
  747. }
  748. }
  749. .shadowbox{
  750. display: flex;
  751. align-items: center;
  752. justify-content: center;
  753. background: linear-gradient(-180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255,0.5) 50%,rgb(255, 255, 255) 80%);
  754. padding-top: 240rpx;
  755. margin-top: -240rpx;
  756. position: relative;
  757. &-btn {
  758. padding: 10rpx 40rpx;
  759. border-radius: 10rpx;
  760. border: 1rpx solid #ccc;
  761. display: inline-flex;
  762. }
  763. }
  764. .img-item {
  765. position: relative;
  766. width: 44rpx;
  767. height: 44rpx;
  768. margin: 0 20rpx 0 10rpx;
  769. image {
  770. width: 100%;
  771. height: 100%;
  772. }
  773. }
  774. .other-box {
  775. background: #FFFFFF;
  776. border-radius: 16rpx 16rpx 16rpx 16rpx;
  777. padding: 12rpx 24rpx;
  778. margin: 24rpx;
  779. &-item {
  780. display: flex;
  781. align-items: flex-start;
  782. padding: 10rpx 0;
  783. }
  784. .label {
  785. flex-shrink: 0;
  786. color: #999999;
  787. font-size: 28rpx;
  788. font-family: PingFang SC;
  789. line-height: 1.3;
  790. margin-right: 40rpx;
  791. min-width: 4em;
  792. text-align: justify;
  793. /* 两端对齐 */
  794. text-align-last: justify;
  795. /* 最后一行也撑满 */
  796. }
  797. .safe-box {
  798. display: flex;
  799. align-items: center;
  800. image {
  801. width: 28rpx;
  802. height: 28rpx;
  803. margin-right: 8rpx;
  804. }
  805. }
  806. .text {
  807. font-family: PingFang SC, PingFang SC;
  808. font-weight: 400;
  809. font-size: 24rpx;
  810. color: #333333;
  811. }
  812. }
  813. .shop-banner {
  814. height: 756upx;
  815. background-color: #FFFFFF;
  816. position: relative;
  817. .swiper-item {
  818. box-sizing: border-box;
  819. }
  820. .swiper,
  821. .swiper-item,
  822. .swiper-item image {
  823. width: 100%;
  824. height: 100%;
  825. }
  826. .banner-mask {
  827. width: 100%;
  828. height: 44upx;
  829. // background: linear-gradient(0deg, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0));
  830. // opacity: 0.8;
  831. position: absolute;
  832. left: 0;
  833. bottom: 0;
  834. z-index: 9;
  835. background-image: url(https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/shopping/black_mask.png);
  836. background-size: 20upx 44upx;
  837. background-repeat: repeat-x;
  838. }
  839. .num-box {
  840. width: 80upx;
  841. height: 44upx;
  842. line-height: 44upx;
  843. text-align: center;
  844. font-size: 24upx;
  845. font-family: PingFang SC;
  846. font-weight: 500;
  847. color: #FFFFFF;
  848. background: rgba(0, 0, 0, .3);
  849. border-radius: 22upx;
  850. position: absolute;
  851. right: 30upx;
  852. bottom: 30upx;
  853. z-index: 10;
  854. }
  855. }
  856. .det-info {
  857. background: #FFFFFF;
  858. padding: 36upx 30upx 25upx;
  859. margin: 20rpx 24rpx;
  860. border-radius: 16rpx 16rpx 16rpx 16rpx;
  861. .price-box {
  862. display: flex;
  863. align-items: center;
  864. justify-content: space-between;
  865. .price {
  866. display: flex;
  867. align-items: baseline;
  868. .label {
  869. color: #999999;
  870. font-size: 28upx;
  871. font-family: PingFang SC;
  872. line-height: 1.3;
  873. margin-right: 5upx;
  874. }
  875. .unit {
  876. font-size: 28upx;
  877. font-family: PingFang SC;
  878. font-weight: bold;
  879. color: #FF6633;
  880. line-height: 1.3;
  881. }
  882. .num {
  883. font-size: 40upx;
  884. font-family: PingFang SC;
  885. font-weight: bold;
  886. color: #FF6633;
  887. margin: 0 20upx 0 0;
  888. line-height: 1;
  889. }
  890. .old {
  891. font-size: 28upx;
  892. font-family: PingFang SC;
  893. font-weight: 500;
  894. text-decoration: line-through;
  895. color: #999999;
  896. line-height: 1.3;
  897. }
  898. }
  899. .share-box {
  900. width: 120upx;
  901. height: 46upx;
  902. border: 1px solid #2583EB;
  903. border-radius: 23upx;
  904. display: flex;
  905. align-items: center;
  906. justify-content: center;
  907. position: relative;
  908. .text {
  909. font-size: 26upx;
  910. font-family: PingFang SC;
  911. font-weight: 500;
  912. color: #2583EB;
  913. }
  914. image {
  915. margin-left: 2rpx;
  916. width: 25upx;
  917. height: 24upx;
  918. }
  919. .share {
  920. display: inline-block;
  921. position: absolute;
  922. top: 0;
  923. left: 0;
  924. width: 100%;
  925. height: 100%;
  926. opacity: 0;
  927. }
  928. }
  929. .spec {
  930. font-size: 24upx;
  931. font-family: PingFang SC;
  932. font-weight: 500;
  933. color: #999999;
  934. line-height: 36upx;
  935. }
  936. }
  937. .name-box {
  938. font-size: 32upx;
  939. font-family: PingFang SC;
  940. font-weight: bold;
  941. color: #111111;
  942. line-height: 44upx;
  943. margin-top: 32upx;
  944. .tag {
  945. display: inline-block;
  946. padding: 0 6upx;
  947. height: 30upx;
  948. background: linear-gradient(90deg, #2583EB 0%, #92C1F5 100%);
  949. border-radius: 4upx;
  950. margin-right: 10upx;
  951. font-size: 22upx;
  952. font-family: PingFang SC;
  953. font-weight: bold;
  954. color: #FFFFFF;
  955. line-height: 30upx;
  956. float: left;
  957. margin-top: 7upx;
  958. }
  959. }
  960. .intro {
  961. display: block;
  962. font-size: 26upx;
  963. font-family: PingFang SC;
  964. font-weight: 500;
  965. color: #999999;
  966. line-height: 36upx;
  967. padding-top: 18upx;
  968. }
  969. }
  970. .inventor {
  971. height: 88upx;
  972. padding: 0 39upx 0 30upx;
  973. margin-top: 10upx;
  974. background: #FFFFFF;
  975. display: flex;
  976. align-items: center;
  977. justify-content: space-between;
  978. .left {
  979. display: flex;
  980. align-items: center;
  981. .head-box {
  982. margin-right: 27upx;
  983. display: flex;
  984. align-items: center;
  985. .head {
  986. width: 48upx;
  987. height: 48upx;
  988. border-radius: 50%;
  989. overflow: hidden;
  990. box-shadow: 0 0 0 1px #fff;
  991. margin-right: -10upx;
  992. image {
  993. width: 100%;
  994. height: 100%;
  995. }
  996. }
  997. }
  998. .num-box {
  999. font-size: 24upx;
  1000. font-family: PingFang SC;
  1001. font-weight: 500;
  1002. color: #999999;
  1003. .text {
  1004. font-size: 24upx;
  1005. font-family: PingFang SC;
  1006. font-weight: 500;
  1007. color: #999999;
  1008. }
  1009. }
  1010. }
  1011. .right {
  1012. font-size: 24upx;
  1013. font-family: PingFang SC;
  1014. font-weight: 500;
  1015. color: #999999;
  1016. .text {
  1017. font-size: 24upx;
  1018. font-family: PingFang SC;
  1019. font-weight: 500;
  1020. color: #666666;
  1021. }
  1022. }
  1023. }
  1024. .effect {
  1025. box-sizing: border-box;
  1026. padding: 30rpx;
  1027. background: #FFFFFF;
  1028. font-size: 28upx;
  1029. font-family: PingFang SC;
  1030. font-weight: 500;
  1031. color: #666666;
  1032. line-height: 1.8;
  1033. margin: 24rpx 24rpx 0 24rpx;
  1034. border-radius: 16rpx;
  1035. .label {
  1036. font-size: 30upx;
  1037. font-family: PingFang SC;
  1038. font-weight: bold;
  1039. color: #333333;
  1040. line-height: 1;
  1041. }
  1042. }
  1043. .det-box {
  1044. padding: 30upx 30upx 0 30upx;
  1045. background-color: #FFFFFF;
  1046. margin: 24rpx 24rpx 0 24rpx;
  1047. border-radius: 16rpx;
  1048. .title {
  1049. font-size: 30upx;
  1050. font-family: PingFang SC;
  1051. font-weight: bold;
  1052. color: #333333;
  1053. line-height: 1;
  1054. margin-bottom: 24rpx;
  1055. }
  1056. .label,
  1057. .text {
  1058. font-size: 30upx !important;
  1059. }
  1060. }
  1061. .btn-foot {
  1062. box-sizing: border-box;
  1063. width: 100%;
  1064. height: 121upx;
  1065. background: #FFFFFF;
  1066. padding: 0 32upx 0 28upx;
  1067. display: flex;
  1068. align-items: center;
  1069. justify-content: space-between;
  1070. position: fixed;
  1071. left: 0;
  1072. bottom: 0;
  1073. z-index: 99;
  1074. .menu-box {
  1075. display: flex;
  1076. align-items: center;
  1077. .item {
  1078. display: flex;
  1079. align-items: center;
  1080. flex-direction: column;
  1081. margin-right: 48upx;
  1082. &:last-child {
  1083. margin-right: 0;
  1084. }
  1085. image {
  1086. width: 36upx;
  1087. height: 36upx;
  1088. margin-bottom: 10upx;
  1089. }
  1090. .label {
  1091. font-size: 20upx;
  1092. font-family: PingFang SC;
  1093. font-weight: 500;
  1094. color: #666666;
  1095. text-align: center;
  1096. }
  1097. }
  1098. ::v-deep.uni-badge--x {
  1099. display: flex;
  1100. align-items: center;
  1101. justify-content: center;
  1102. }
  1103. ::v-deep.uni-badge {
  1104. border: none;
  1105. background-color: #FF3636;
  1106. font-family: Roboto;
  1107. }
  1108. }
  1109. .btn-box {
  1110. display: flex;
  1111. align-items: center;
  1112. .btn {
  1113. position: relative;
  1114. width: 200upx;
  1115. height: 88upx;
  1116. line-height: 88upx;
  1117. text-align: center;
  1118. border-radius: 44upx;
  1119. margin-left: 20upx;
  1120. font-size: 30upx;
  1121. font-family: PingFang SC;
  1122. font-weight: bold;
  1123. color: #FFFFFF;
  1124. &:first-child {
  1125. margin-left: 0;
  1126. }
  1127. &.cart {
  1128. background: #FF6633;
  1129. .share {
  1130. display: inline-block;
  1131. position: absolute;
  1132. top: 0;
  1133. left: 0;
  1134. width: 100%;
  1135. height: 100%;
  1136. opacity: 0;
  1137. }
  1138. }
  1139. &.buy {
  1140. background: #2583EB;
  1141. }
  1142. }
  1143. }
  1144. }
  1145. .product-spec {
  1146. .pro-info {
  1147. display: flex;
  1148. align-items: center;
  1149. .img-box {
  1150. width: 200upx;
  1151. height: 200upx;
  1152. background: #FFFFFF;
  1153. border-radius: 16upx;
  1154. overflow: hidden;
  1155. margin-right: 30upx;
  1156. image {
  1157. width: 100%;
  1158. height: 100%;
  1159. }
  1160. }
  1161. .info-text {
  1162. height: 200upx;
  1163. display: flex;
  1164. flex-direction: column;
  1165. justify-content: space-between;
  1166. .price {
  1167. display: flex;
  1168. align-items: flex-end;
  1169. .unit {
  1170. font-size: 32upx;
  1171. font-family: PingFang SC;
  1172. font-weight: bold;
  1173. color: #FF6633;
  1174. line-height: 1.2;
  1175. margin-right: 10upx;
  1176. }
  1177. .num {
  1178. font-size: 50upx;
  1179. font-family: PingFang SC;
  1180. font-weight: bold;
  1181. color: #FF6633;
  1182. line-height: 1;
  1183. }
  1184. }
  1185. .desc-box {
  1186. display: flex;
  1187. flex-direction: column;
  1188. padding-bottom: 9upx;
  1189. .text {
  1190. font-size: 26upx;
  1191. font-family: PingFang SC;
  1192. font-weight: 500;
  1193. color: #999999;
  1194. margin-top: 27upx;
  1195. line-height: 1;
  1196. &:first-child {
  1197. margin-top: 0;
  1198. }
  1199. }
  1200. }
  1201. }
  1202. }
  1203. .spec-box {
  1204. padding-top: 50upx;
  1205. .title {
  1206. font-size: 34upx;
  1207. font-family: PingFang SC;
  1208. font-weight: bold;
  1209. color: #111111;
  1210. line-height: 1;
  1211. }
  1212. .spec-list {
  1213. display: flex;
  1214. flex-wrap: wrap;
  1215. margin-top: 30upx;
  1216. .item {
  1217. box-sizing: border-box;
  1218. height: 64upx;
  1219. padding: 0 30upx;
  1220. line-height: 64upx;
  1221. font-size: 28upx;
  1222. font-family: PingFang SC;
  1223. font-weight: 500;
  1224. color: #111111;
  1225. background: #F7F7F7;
  1226. border: 1px solid #F7F7F7;
  1227. border-radius: 32upx;
  1228. margin-right: 20upx;
  1229. margin-bottom: 30upx;
  1230. &.active {
  1231. background: #F1FFFE;
  1232. border: 1px solid #2583EB;
  1233. color: #2583EB;
  1234. }
  1235. }
  1236. }
  1237. }
  1238. .price-num {
  1239. display: flex;
  1240. align-items: center;
  1241. justify-content: space-between;
  1242. margin-top: 14upx;
  1243. .label {
  1244. font-size: 34upx;
  1245. font-family: PingFang SC;
  1246. font-weight: bold;
  1247. color: #111111;
  1248. }
  1249. .num-box {
  1250. display: flex;
  1251. align-items: center;
  1252. .img-box {
  1253. width: 60upx;
  1254. height: 60upx;
  1255. // border-radius: 4upx;
  1256. border: 1px solid #dddddd;
  1257. display: flex;
  1258. align-items: center;
  1259. justify-content: center;
  1260. image {
  1261. width: 25rpx;
  1262. height: 25rpx;
  1263. }
  1264. }
  1265. input {
  1266. width: 60upx;
  1267. height: 60upx;
  1268. line-height: 60upx;
  1269. font-size: 28upx;
  1270. font-family: PingFang SC;
  1271. font-weight: 500;
  1272. color: #111111;
  1273. // border-radius: 4upx;
  1274. border-top: 1px solid #dddddd;
  1275. border-bottom: 1px solid #dddddd;
  1276. text-align: center;
  1277. // margin: 0 16upx;
  1278. }
  1279. }
  1280. }
  1281. .sub-btn {
  1282. width: 100%;
  1283. height: 88upx;
  1284. line-height: 88upx;
  1285. text-align: center;
  1286. font-size: 30upx;
  1287. font-family: PingFang SC;
  1288. font-weight: bold;
  1289. color: #FFFFFF;
  1290. background: #2583EB;
  1291. border-radius: 44upx;
  1292. margin-top: 30upx;
  1293. // margin-bottom: 30upx;
  1294. }
  1295. }
  1296. .contact-btn {
  1297. display: inline-block;
  1298. position: absolute;
  1299. top: 0;
  1300. left: 0;
  1301. width: 100%;
  1302. height: 100%;
  1303. opacity: 0;
  1304. z-index: 9999;
  1305. }
  1306. .loadding {
  1307. background-color: #fff;
  1308. display: flex;
  1309. flex-direction: column;
  1310. align-items: center;
  1311. justify-content: center;
  1312. position: absolute;
  1313. top: 0;
  1314. left: 0;
  1315. width: 100%;
  1316. height: 100%;
  1317. z-index: 9999;
  1318. image {
  1319. border-radius: 50%;
  1320. animation: load linear 1s infinite;
  1321. width: 120rpx;
  1322. height: 120rpx;
  1323. }
  1324. .text {
  1325. font-size: 28rpx;
  1326. margin-top: 20rpx;
  1327. }
  1328. }
  1329. .storebox {
  1330. margin: 24rpx;
  1331. padding: 28rpx 26rpx;
  1332. font-family: PingFang SC, PingFang SC;
  1333. color: #333;
  1334. background: #FFFFFF;
  1335. border-radius: 16rpx 16rpx 16rpx 16rpx;
  1336. .logo {
  1337. width: 104rpx;
  1338. height: 104rpx;
  1339. background: #FFFFFF;
  1340. border-radius: 16rpx 16rpx 16rpx 16rpx;
  1341. margin-right: 26rpx;
  1342. }
  1343. .storename {
  1344. font-weight: 500;
  1345. font-size: 32rpx;
  1346. }
  1347. .storedesc {
  1348. margin-top: 12rpx;
  1349. font-weight: 400;
  1350. font-size: 22rpx;
  1351. }
  1352. .storebox-r {
  1353. flex: 1;
  1354. overflow: hidden;
  1355. }
  1356. .storebox-btn {
  1357. flex-shrink: 0;
  1358. padding: 10rpx 24rpx;
  1359. font-size: 28rpx;
  1360. border-radius: 28rpx 28rpx 28rpx 28rpx;
  1361. border: 2rpx solid #FF5C03;
  1362. font-weight: 500;
  1363. font-size: 24rpx;
  1364. color: #FF5C03;
  1365. }
  1366. }
  1367. .evaluate {
  1368. .title {
  1369. margin: 0;
  1370. padding-bottom: 24rpx;
  1371. }
  1372. }
  1373. .footer-desc {
  1374. text-align: center;
  1375. padding: 0 32rpx 24rpx 0;
  1376. font-size: 28rpx;
  1377. color: #999;
  1378. image{
  1379. margin-left: 10rpx;
  1380. width:15rpx;
  1381. height:20rpx;
  1382. }
  1383. }
  1384. </style>