productDetails.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467
  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. <view class="storebox" v-if="chooseStore.storeId">
  91. <view class="x-bc">
  92. <view class="x-f">
  93. <image class="logo" :src="chooseStore.logoUrl" mode="aspectFill"></image>
  94. <view class="storebox-r" @click="goStoreDetail(chooseStore)">
  95. <view class="storename ellipsis2">{{chooseStore.storeName||''}}</view>
  96. <!-- <view class="storedesc">24小时营业 销售{{$formatSalesNum(chooseStore.salesCount) }}</view> -->
  97. </view>
  98. </view>
  99. <view class="storebox-btn" @click="goStoreDetail(chooseStore)">进店</view>
  100. </view>
  101. <detail :source="'product'" ref="getStoreInfo" :storeInfo="storeInfo"></detail>
  102. </view>
  103. <!-- 购买人数、库存 -->
  104. <!-- <view class="inventor">
  105. <view class="left">
  106. <view class="head-box">
  107. <view class="head" v-for="(item,j) in 5" :key="j">
  108. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/shopping/head.jpg" mode=""></image>
  109. </view>
  110. </view>
  111. <view class="num-box">
  112. 已有 <text class="text">{{product.sales}}</text> 人购买
  113. </view>
  114. </view>
  115. <view class="right">
  116. 库存 <text class="text">{{product.stock}}{{product.unitName}}</text>
  117. </view>
  118. <view class="right">
  119. <text class="text">库存{{product.stock>0?'充足':'售罄'}} </text>
  120. </view>
  121. </view> -->
  122. <!-- 功效 -->
  123. <view class="effect" v-if="product.instructionManual">
  124. <view class="label">{{product.productName}}药品说明书</view>
  125. <view :class="product.productType ==2&&isView==0 ? 'hiddenbox':''">
  126. <u-parse :content="product.instructionManual" :style="{display: 'block'}"></u-parse>
  127. </view>
  128. <view class="shadowbox" v-if="product.productType ==2&&isView==0">
  129. <view class="shadowbox-btn x-ac" @click="handleShow">
  130. <text style="margin-right: 10rpx;">点击查看说明书全文</text>
  131. <u-icon name="arrow-down" color="#999" size="14"></u-icon>
  132. </view>
  133. </view>
  134. </view>
  135. <u-popup :show="show" mode="center" :round="10" @close="show=false" :closeOnClickOverlay="false">
  136. <view class="popupbox">
  137. <view class="popupbox-title">如何查看说明书</view>
  138. <view class="popupbox-body">
  139. <text style="font-weight: bold;">普通用户:</text>需要先问诊获得处方后才能查看说明书,请点<text class="confirm" @click="addCart('buy')">问诊开药</text>开处方!
  140. </view>
  141. <view class="popupbox-footer" @click="show=false">我知道了</view>
  142. </view>
  143. </u-popup>
  144. <!-- 商品评价 -->
  145. <view class="det-box evaluate">
  146. <view class="title">商品评价({{evaluateTotal}})</view>
  147. <view class="evaluate">
  148. <evaluateItem v-for="(item,index) in evaluate" :key="index" :item="item"></evaluateItem>
  149. <view class="footer-desc" v-if="evaluate&&evaluate.length>0">
  150. <text @click="moreEvaluate">查看更多评价</text>
  151. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/arrow_gray.png"></image>
  152. </view>
  153. </view>
  154. </view>
  155. <!-- 图文详情 -->
  156. <view class="det-box">
  157. <view class="title">图文详情</view>
  158. <view class="inner">
  159. <view v-html="product.description" style="font-size:0"></view>
  160. </view>
  161. <!-- <view class="other-box" style="margin: 0;padding: 24rpx 0;">
  162. <view class="other-box-item" v-if="product.dosage">
  163. <view class="label" style="margin-right: 16rpx;">【用法用量】</view>
  164. <view class="text">{{product.dosage}}</view>
  165. </view>
  166. <view class="other-box-item" v-if="product.adverseReactions">
  167. <view class="label" style="margin-right: 16rpx;">【不良反应】</view>
  168. <view class="text">{{product.adverseReactions}}</view>
  169. </view>
  170. <view class="other-box-item" v-if="product.contraindications">
  171. <view class="label" style="margin-right: 16rpx;">【禁忌】</view>
  172. <view class="text">{{product.contraindications}}</view>
  173. </view>
  174. <view class="other-box-item" v-if="product.precautions">
  175. <view class="label" style="margin-right: 16rpx;">【注意事项】</view>
  176. <view class="text">{{product.precautions}}</view>
  177. </view>
  178. </view> -->
  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: 30upx;
  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>