productDetails.vue 34 KB

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