productDetails.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476
  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.storeInfo.doctorList = this.storeInfo.doctorList.map(doctor => {
  398. return {
  399. ...doctor,
  400. // 假设images字段是逗号分隔的图片字符串
  401. imagesArray: doctor.practiseImages ?
  402. doctor.practiseImages.split(',').map(img => img.trim()).filter(img => img) : []
  403. };
  404. });
  405. this.$refs.getStoreInfo.getDescHeight()
  406. }
  407. })
  408. },
  409. handleShow() {
  410. uni.showLoading({
  411. title: '加载中',
  412. icon: 'none'
  413. })
  414. instructionsViewable({productId: this.productId}).then(
  415. res => {
  416. uni.hideLoading()
  417. if(res.code==200){
  418. this.isView = res.data ? 1 : 0
  419. this.show = this.isView == 0
  420. }else{
  421. uni.showToast({
  422. icon:'none',
  423. title: "请求失败",
  424. });
  425. }
  426. },
  427. rej => {}
  428. );
  429. },
  430. goStoreDetail(item) {
  431. uni.navigateTo({
  432. url: '/pages_store/storeIndex?storeId=' + item.storeId
  433. })
  434. },
  435. getDicts: function() {
  436. getDicts().then(
  437. res => {
  438. if (res.code == 200) {
  439. uni.setStorageSync('dicts', JSON.stringify(res));
  440. }
  441. },
  442. rej => {}
  443. );
  444. },
  445. showImg(img) {
  446. if (img != null) {
  447. var imgs = [];
  448. imgs.push(img)
  449. //预览图片
  450. uni.previewImage({
  451. urls: imgs,
  452. current: imgs[0]
  453. });
  454. } else {
  455. //预览图片
  456. uni.previewImage({
  457. urls: this.banner,
  458. current: this.banner[0]
  459. });
  460. }
  461. },
  462. doAddCart(type) {
  463. if (this.specNum == 0) {
  464. uni.showToast({
  465. icon: 'none',
  466. title: "库存不足",
  467. });
  468. return;
  469. }
  470. var isBuy = type == "buy" ? 1 : 0;
  471. let data = {
  472. isBuy: isBuy,
  473. cartNum: this.specNum,
  474. productId: this.productValueSelect.productId,
  475. attrValueId: this.productValueSelect.id
  476. };
  477. addCart(data).then(
  478. res => {
  479. if (res.code == 200) {
  480. if (type == "buy") {
  481. const selectCarts = [{
  482. storeId: this.storeId,
  483. data: {
  484. type: this.type,
  485. cartIds: res.id,
  486. }
  487. }]
  488. uni.navigateTo({
  489. url: '/pages_shopping/confirmOrder?type=' + this.type + '&orderType=' +
  490. this.orderType + '&confirmParam=' + encodeURIComponent(JSON.stringify(
  491. selectCarts))
  492. })
  493. } else {
  494. this.getCartCount()
  495. uni.showToast({
  496. icon: 'success',
  497. title: "添加成功",
  498. });
  499. }
  500. } else {
  501. uni.showToast({
  502. icon: 'none',
  503. title: res.msg,
  504. });
  505. this.getProductDetails()
  506. }
  507. },
  508. rej => {}
  509. );
  510. },
  511. getProductDetails() {
  512. let data = {
  513. productId: this.productId
  514. };
  515. getProductDetails(data).then(
  516. res => {
  517. this.loadding = false
  518. if (res.code == 200) {
  519. this.product = res.product;
  520. if (this.product.productType == 1) {
  521. this.buyText = "立即购买"
  522. } else if (this.product.productType == 2) {
  523. this.buyText = "开方购买"
  524. }
  525. this.product.otPrice = this.product.otPrice.toFixed(2);
  526. this.product.price = this.product.price.toFixed(2);
  527. if (this.product.sliderImage != null) {
  528. this.banner = this.product.sliderImage.split(',');
  529. } else {
  530. this.banner = []
  531. }
  532. this.attrs = res.productAttr;
  533. this.attrs.forEach((item, index, arr) => {
  534. item.values = item.attrValues.split(',');
  535. item.index = 0
  536. })
  537. console.log(this.attrs)
  538. this.values = res.productValues;
  539. this.storeId = res.store.storeId || ''
  540. this.storeList = [res.store] || [];
  541. if (this.storeList && this.storeList.length > 0) {
  542. const idx = this.storeList.indexOf(Number(this.storeId || 0));
  543. if (this.storeId && idx > -1) {
  544. this.chooseStore = this.storeList[idx]
  545. } else {
  546. this.chooseStore = this.storeList[0]
  547. }
  548. }
  549. this.choseSpec(0, 0)
  550. this.getCommentByUser()
  551. this.getStoreInfo();
  552. } else {
  553. uni.showToast({
  554. icon: 'none',
  555. title: res.msg,
  556. });
  557. setTimeout(function() {
  558. uni.reLaunch({
  559. url: '/pages/index/index',
  560. })
  561. }, 2000)
  562. }
  563. },
  564. rej => {}
  565. );
  566. },
  567. getCartCount() {
  568. let data = {};
  569. getCartCount(data).then(
  570. cartRes => {
  571. if (cartRes.code == 200) {
  572. this.cartCount = cartRes.data;
  573. }
  574. },
  575. rej => {}
  576. );
  577. },
  578. // swiper变化事件
  579. swiperChange(event) {
  580. this.activeBanner = event.detail.current + 1
  581. },
  582. // 回到首页
  583. goHome() {
  584. uni.switchTab({
  585. url: '/pages/index/index'
  586. })
  587. },
  588. // 跳转页面
  589. navgetTo(url) {
  590. this.$isLogin().then(res => {
  591. if (res) {
  592. uni.navigateTo({
  593. url: url
  594. })
  595. }
  596. })
  597. },
  598. // 加入购物车
  599. addCart(type) {
  600. this.show=false
  601. this.$isLogin().then(res => {
  602. if (res) {
  603. this.type = type;
  604. this.specVisible = true
  605. } else {
  606. uni.navigateTo({
  607. url: '/pages/auth/login'
  608. })
  609. }
  610. })
  611. },
  612. // 规格选择
  613. choseSpec(index, subIndex) {
  614. this.attrs[index].index = subIndex;
  615. this.$forceUpdate();
  616. let productAttr = this.attrs;
  617. let values = [];
  618. for (let i = 0; i < productAttr.length; i++) {
  619. for (let j = 0; j < productAttr[i].values.length; j++) {
  620. if (productAttr[i].index === j) {
  621. values.push(productAttr[i].values[j]);
  622. }
  623. }
  624. }
  625. var selectVal = values.sort().join(",");
  626. console.log(selectVal)
  627. var valueSelect = this.values.filter((item) => {
  628. return item.sku == selectVal;
  629. })
  630. if (valueSelect != null && valueSelect.length == 1) {
  631. this.productValueSelect = valueSelect[0];
  632. }
  633. this.updateSpecNum();
  634. },
  635. //更新数量
  636. updateSpecNum() {
  637. if (this.productValueSelect.stock == 0) {
  638. this.specNum = 0;
  639. } else {
  640. this.specNum = 1;
  641. }
  642. },
  643. changeNum(e) {
  644. this.specNum = e.detail.value.replace(/\D/g, '')
  645. if (this.specNum < 1) {
  646. this.specNum = 1
  647. }
  648. if (this.specNum >= this.productValueSelect.stock) {
  649. this.specNum = this.productValueSelect.stock
  650. }
  651. },
  652. // 数量减法
  653. lessNum() {
  654. this.specNum--
  655. if (this.specNum < 1) {
  656. this.specNum = 1
  657. }
  658. if (this.specNum >= this.productValueSelect.stock) {
  659. this.specNum = this.productValueSelect.stock
  660. }
  661. },
  662. // 数量加法
  663. addNum() {
  664. if (this.specNum < 10) {
  665. this.specNum++
  666. } else {
  667. uni.showToast({
  668. icon: 'none',
  669. title: '限购10盒',
  670. });
  671. }
  672. if (this.specNum >= this.productValueSelect.stock) {
  673. this.specNum = this.productValueSelect.stock
  674. }
  675. },
  676. // 确定选择该规格
  677. submit() {
  678. this.specVisible = false
  679. this.doAddCart(this.type);
  680. },
  681. moreEvaluate() {
  682. uni.navigateTo({
  683. url: '/pages_shopping/evaluate?storeId='+this.storeId+ '&productIds='+this.productId,
  684. })
  685. },
  686. getCommentByUser(){
  687. const param = {
  688. page: 1,
  689. pageSize: 2,
  690. storeId:this.storeId,
  691. orderId: null,
  692. productIds:this.productId,
  693. userId: uni.getStorageSync('userId') || null,
  694. showSelf: 0
  695. }
  696. selectCommentByUser(param).then(res=>{
  697. if(res.code==200) {
  698. this.evaluate = res.data.list
  699. this.evaluateTotal = res.data.total
  700. } else {
  701. this.evaluate = []
  702. this.evaluateTotal = 0
  703. }
  704. })
  705. }
  706. }
  707. }
  708. </script>
  709. <style lang="scss" scoped>
  710. .hiddenbox {
  711. height: 240rpx;
  712. overflow: hidden;
  713. }
  714. .popupbox {
  715. width: 80vw;
  716. font-size: 32upx;
  717. font-family: PingFang SC;
  718. color: #333333;
  719. &-title{
  720. font-weight: bold;
  721. padding: 30rpx;
  722. text-align: center;
  723. }
  724. &-body {
  725. padding: 24rpx 30rpx;
  726. line-height: 2;
  727. }
  728. .confirm {
  729. background-color: #2583EB;
  730. border-radius: 10rpx;
  731. color: #fff;
  732. padding: 10rpx 24rpx;
  733. margin: 0 10rpx;
  734. }
  735. &-footer {
  736. border-top: 1rpx solid #F7F7F7;
  737. padding: 30rpx;
  738. color: red;
  739. text-align: center;
  740. }
  741. }
  742. .shadowbox{
  743. display: flex;
  744. align-items: center;
  745. justify-content: center;
  746. background: linear-gradient(-180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255,0.5) 50%,rgb(255, 255, 255) 80%);
  747. padding-top: 240rpx;
  748. margin-top: -240rpx;
  749. position: relative;
  750. &-btn {
  751. padding: 10rpx 40rpx;
  752. border-radius: 10rpx;
  753. border: 1rpx solid #ccc;
  754. display: inline-flex;
  755. }
  756. }
  757. .img-item {
  758. position: relative;
  759. width: 44rpx;
  760. height: 44rpx;
  761. margin: 0 20rpx 0 10rpx;
  762. image {
  763. width: 100%;
  764. height: 100%;
  765. }
  766. }
  767. .other-box {
  768. background: #FFFFFF;
  769. border-radius: 16rpx 16rpx 16rpx 16rpx;
  770. padding: 12rpx 24rpx;
  771. margin: 24rpx;
  772. &-item {
  773. display: flex;
  774. align-items: flex-start;
  775. padding: 10rpx 0;
  776. }
  777. .label {
  778. flex-shrink: 0;
  779. color: #999999;
  780. font-size: 28rpx;
  781. font-family: PingFang SC;
  782. line-height: 1.3;
  783. margin-right: 40rpx;
  784. min-width: 4em;
  785. text-align: justify;
  786. /* 两端对齐 */
  787. text-align-last: justify;
  788. /* 最后一行也撑满 */
  789. }
  790. .safe-box {
  791. display: flex;
  792. align-items: center;
  793. image {
  794. width: 28rpx;
  795. height: 28rpx;
  796. margin-right: 8rpx;
  797. }
  798. }
  799. .text {
  800. font-family: PingFang SC, PingFang SC;
  801. font-weight: 400;
  802. font-size: 24rpx;
  803. color: #333333;
  804. }
  805. }
  806. .shop-banner {
  807. height: 756upx;
  808. background-color: #FFFFFF;
  809. position: relative;
  810. .swiper-item {
  811. box-sizing: border-box;
  812. }
  813. .swiper,
  814. .swiper-item,
  815. .swiper-item image {
  816. width: 100%;
  817. height: 100%;
  818. }
  819. .banner-mask {
  820. width: 100%;
  821. height: 44upx;
  822. // background: linear-gradient(0deg, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0));
  823. // opacity: 0.8;
  824. position: absolute;
  825. left: 0;
  826. bottom: 0;
  827. z-index: 9;
  828. background-image: url(https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/shopping/black_mask.png);
  829. background-size: 20upx 44upx;
  830. background-repeat: repeat-x;
  831. }
  832. .num-box {
  833. width: 80upx;
  834. height: 44upx;
  835. line-height: 44upx;
  836. text-align: center;
  837. font-size: 24upx;
  838. font-family: PingFang SC;
  839. font-weight: 500;
  840. color: #FFFFFF;
  841. background: rgba(0, 0, 0, .3);
  842. border-radius: 22upx;
  843. position: absolute;
  844. right: 30upx;
  845. bottom: 30upx;
  846. z-index: 10;
  847. }
  848. }
  849. .det-info {
  850. background: #FFFFFF;
  851. padding: 36upx 30upx 25upx;
  852. margin: 20rpx 24rpx;
  853. border-radius: 16rpx 16rpx 16rpx 16rpx;
  854. .price-box {
  855. display: flex;
  856. align-items: center;
  857. justify-content: space-between;
  858. .price {
  859. display: flex;
  860. align-items: baseline;
  861. .label {
  862. color: #999999;
  863. font-size: 28upx;
  864. font-family: PingFang SC;
  865. line-height: 1.3;
  866. margin-right: 5upx;
  867. }
  868. .unit {
  869. font-size: 28upx;
  870. font-family: PingFang SC;
  871. font-weight: bold;
  872. color: #FF6633;
  873. line-height: 1.3;
  874. }
  875. .num {
  876. font-size: 40upx;
  877. font-family: PingFang SC;
  878. font-weight: bold;
  879. color: #FF6633;
  880. margin: 0 20upx 0 0;
  881. line-height: 1;
  882. }
  883. .old {
  884. font-size: 28upx;
  885. font-family: PingFang SC;
  886. font-weight: 500;
  887. text-decoration: line-through;
  888. color: #999999;
  889. line-height: 1.3;
  890. }
  891. }
  892. .share-box {
  893. width: 120upx;
  894. height: 46upx;
  895. border: 1px solid #2583EB;
  896. border-radius: 23upx;
  897. display: flex;
  898. align-items: center;
  899. justify-content: center;
  900. position: relative;
  901. .text {
  902. font-size: 26upx;
  903. font-family: PingFang SC;
  904. font-weight: 500;
  905. color: #2583EB;
  906. }
  907. image {
  908. margin-left: 2rpx;
  909. width: 25upx;
  910. height: 24upx;
  911. }
  912. .share {
  913. display: inline-block;
  914. position: absolute;
  915. top: 0;
  916. left: 0;
  917. width: 100%;
  918. height: 100%;
  919. opacity: 0;
  920. }
  921. }
  922. .spec {
  923. font-size: 24upx;
  924. font-family: PingFang SC;
  925. font-weight: 500;
  926. color: #999999;
  927. line-height: 36upx;
  928. }
  929. }
  930. .name-box {
  931. font-size: 32upx;
  932. font-family: PingFang SC;
  933. font-weight: bold;
  934. color: #111111;
  935. line-height: 44upx;
  936. margin-top: 32upx;
  937. .tag {
  938. display: inline-block;
  939. padding: 0 6upx;
  940. height: 30upx;
  941. background: linear-gradient(90deg, #2583EB 0%, #92C1F5 100%);
  942. border-radius: 4upx;
  943. margin-right: 10upx;
  944. font-size: 22upx;
  945. font-family: PingFang SC;
  946. font-weight: bold;
  947. color: #FFFFFF;
  948. line-height: 30upx;
  949. float: left;
  950. margin-top: 7upx;
  951. }
  952. }
  953. .intro {
  954. display: block;
  955. font-size: 26upx;
  956. font-family: PingFang SC;
  957. font-weight: 500;
  958. color: #999999;
  959. line-height: 36upx;
  960. padding-top: 18upx;
  961. }
  962. }
  963. .inventor {
  964. height: 88upx;
  965. padding: 0 39upx 0 30upx;
  966. margin-top: 10upx;
  967. background: #FFFFFF;
  968. display: flex;
  969. align-items: center;
  970. justify-content: space-between;
  971. .left {
  972. display: flex;
  973. align-items: center;
  974. .head-box {
  975. margin-right: 27upx;
  976. display: flex;
  977. align-items: center;
  978. .head {
  979. width: 48upx;
  980. height: 48upx;
  981. border-radius: 50%;
  982. overflow: hidden;
  983. box-shadow: 0 0 0 1px #fff;
  984. margin-right: -10upx;
  985. image {
  986. width: 100%;
  987. height: 100%;
  988. }
  989. }
  990. }
  991. .num-box {
  992. font-size: 24upx;
  993. font-family: PingFang SC;
  994. font-weight: 500;
  995. color: #999999;
  996. .text {
  997. font-size: 24upx;
  998. font-family: PingFang SC;
  999. font-weight: 500;
  1000. color: #999999;
  1001. }
  1002. }
  1003. }
  1004. .right {
  1005. font-size: 24upx;
  1006. font-family: PingFang SC;
  1007. font-weight: 500;
  1008. color: #999999;
  1009. .text {
  1010. font-size: 24upx;
  1011. font-family: PingFang SC;
  1012. font-weight: 500;
  1013. color: #666666;
  1014. }
  1015. }
  1016. }
  1017. .effect {
  1018. box-sizing: border-box;
  1019. padding: 30rpx;
  1020. background: #FFFFFF;
  1021. font-size: 28upx;
  1022. font-family: PingFang SC;
  1023. font-weight: 500;
  1024. color: #666666;
  1025. line-height: 1.8;
  1026. margin: 24rpx 24rpx 0 24rpx;
  1027. border-radius: 16rpx;
  1028. .label {
  1029. font-size: 30upx;
  1030. font-family: PingFang SC;
  1031. font-weight: bold;
  1032. color: #333333;
  1033. line-height: 1;
  1034. }
  1035. }
  1036. .det-box {
  1037. padding: 30upx 30upx 0 30upx;
  1038. background-color: #FFFFFF;
  1039. margin: 24rpx 24rpx 0 24rpx;
  1040. border-radius: 16rpx;
  1041. .title {
  1042. font-size: 30upx;
  1043. font-family: PingFang SC;
  1044. font-weight: bold;
  1045. color: #333333;
  1046. line-height: 1;
  1047. margin-bottom: 24rpx;
  1048. }
  1049. .label,
  1050. .text {
  1051. font-size: 30upx !important;
  1052. }
  1053. }
  1054. .btn-foot {
  1055. box-sizing: border-box;
  1056. width: 100%;
  1057. height: 121upx;
  1058. background: #FFFFFF;
  1059. padding: 0 32upx 0 28upx;
  1060. display: flex;
  1061. align-items: center;
  1062. justify-content: space-between;
  1063. position: fixed;
  1064. left: 0;
  1065. bottom: 0;
  1066. z-index: 99;
  1067. .menu-box {
  1068. display: flex;
  1069. align-items: center;
  1070. .item {
  1071. display: flex;
  1072. align-items: center;
  1073. flex-direction: column;
  1074. margin-right: 48upx;
  1075. &:last-child {
  1076. margin-right: 0;
  1077. }
  1078. image {
  1079. width: 36upx;
  1080. height: 36upx;
  1081. margin-bottom: 10upx;
  1082. }
  1083. .label {
  1084. font-size: 20upx;
  1085. font-family: PingFang SC;
  1086. font-weight: 500;
  1087. color: #666666;
  1088. text-align: center;
  1089. }
  1090. }
  1091. ::v-deep.uni-badge--x {
  1092. display: flex;
  1093. align-items: center;
  1094. justify-content: center;
  1095. }
  1096. ::v-deep.uni-badge {
  1097. border: none;
  1098. background-color: #FF3636;
  1099. font-family: Roboto;
  1100. }
  1101. }
  1102. .btn-box {
  1103. display: flex;
  1104. align-items: center;
  1105. .btn {
  1106. position: relative;
  1107. width: 200upx;
  1108. height: 88upx;
  1109. line-height: 88upx;
  1110. text-align: center;
  1111. border-radius: 44upx;
  1112. margin-left: 20upx;
  1113. font-size: 30upx;
  1114. font-family: PingFang SC;
  1115. font-weight: bold;
  1116. color: #FFFFFF;
  1117. &:first-child {
  1118. margin-left: 0;
  1119. }
  1120. &.cart {
  1121. background: #FF6633;
  1122. .share {
  1123. display: inline-block;
  1124. position: absolute;
  1125. top: 0;
  1126. left: 0;
  1127. width: 100%;
  1128. height: 100%;
  1129. opacity: 0;
  1130. }
  1131. }
  1132. &.buy {
  1133. background: #2583EB;
  1134. }
  1135. }
  1136. }
  1137. }
  1138. .product-spec {
  1139. .pro-info {
  1140. display: flex;
  1141. align-items: center;
  1142. .img-box {
  1143. width: 200upx;
  1144. height: 200upx;
  1145. background: #FFFFFF;
  1146. border-radius: 16upx;
  1147. overflow: hidden;
  1148. margin-right: 30upx;
  1149. image {
  1150. width: 100%;
  1151. height: 100%;
  1152. }
  1153. }
  1154. .info-text {
  1155. height: 200upx;
  1156. display: flex;
  1157. flex-direction: column;
  1158. justify-content: space-between;
  1159. .price {
  1160. display: flex;
  1161. align-items: flex-end;
  1162. .unit {
  1163. font-size: 32upx;
  1164. font-family: PingFang SC;
  1165. font-weight: bold;
  1166. color: #FF6633;
  1167. line-height: 1.2;
  1168. margin-right: 10upx;
  1169. }
  1170. .num {
  1171. font-size: 50upx;
  1172. font-family: PingFang SC;
  1173. font-weight: bold;
  1174. color: #FF6633;
  1175. line-height: 1;
  1176. }
  1177. }
  1178. .desc-box {
  1179. display: flex;
  1180. flex-direction: column;
  1181. padding-bottom: 9upx;
  1182. .text {
  1183. font-size: 26upx;
  1184. font-family: PingFang SC;
  1185. font-weight: 500;
  1186. color: #999999;
  1187. margin-top: 27upx;
  1188. line-height: 1;
  1189. &:first-child {
  1190. margin-top: 0;
  1191. }
  1192. }
  1193. }
  1194. }
  1195. }
  1196. .spec-box {
  1197. padding-top: 50upx;
  1198. .title {
  1199. font-size: 34upx;
  1200. font-family: PingFang SC;
  1201. font-weight: bold;
  1202. color: #111111;
  1203. line-height: 1;
  1204. }
  1205. .spec-list {
  1206. display: flex;
  1207. flex-wrap: wrap;
  1208. margin-top: 30upx;
  1209. .item {
  1210. box-sizing: border-box;
  1211. height: 64upx;
  1212. padding: 0 30upx;
  1213. line-height: 64upx;
  1214. font-size: 28upx;
  1215. font-family: PingFang SC;
  1216. font-weight: 500;
  1217. color: #111111;
  1218. background: #F7F7F7;
  1219. border: 1px solid #F7F7F7;
  1220. border-radius: 32upx;
  1221. margin-right: 20upx;
  1222. margin-bottom: 30upx;
  1223. &.active {
  1224. background: #F1FFFE;
  1225. border: 1px solid #2583EB;
  1226. color: #2583EB;
  1227. }
  1228. }
  1229. }
  1230. }
  1231. .price-num {
  1232. display: flex;
  1233. align-items: center;
  1234. justify-content: space-between;
  1235. margin-top: 14upx;
  1236. .label {
  1237. font-size: 34upx;
  1238. font-family: PingFang SC;
  1239. font-weight: bold;
  1240. color: #111111;
  1241. }
  1242. .num-box {
  1243. display: flex;
  1244. align-items: center;
  1245. .img-box {
  1246. width: 60upx;
  1247. height: 60upx;
  1248. // border-radius: 4upx;
  1249. border: 1px solid #dddddd;
  1250. display: flex;
  1251. align-items: center;
  1252. justify-content: center;
  1253. image {
  1254. width: 25rpx;
  1255. height: 25rpx;
  1256. }
  1257. }
  1258. input {
  1259. width: 60upx;
  1260. height: 60upx;
  1261. line-height: 60upx;
  1262. font-size: 28upx;
  1263. font-family: PingFang SC;
  1264. font-weight: 500;
  1265. color: #111111;
  1266. // border-radius: 4upx;
  1267. border-top: 1px solid #dddddd;
  1268. border-bottom: 1px solid #dddddd;
  1269. text-align: center;
  1270. // margin: 0 16upx;
  1271. }
  1272. }
  1273. }
  1274. .sub-btn {
  1275. width: 100%;
  1276. height: 88upx;
  1277. line-height: 88upx;
  1278. text-align: center;
  1279. font-size: 30upx;
  1280. font-family: PingFang SC;
  1281. font-weight: bold;
  1282. color: #FFFFFF;
  1283. background: #2583EB;
  1284. border-radius: 44upx;
  1285. margin-top: 30upx;
  1286. // margin-bottom: 30upx;
  1287. }
  1288. }
  1289. .contact-btn {
  1290. display: inline-block;
  1291. position: absolute;
  1292. top: 0;
  1293. left: 0;
  1294. width: 100%;
  1295. height: 100%;
  1296. opacity: 0;
  1297. z-index: 9999;
  1298. }
  1299. .loadding {
  1300. background-color: #fff;
  1301. display: flex;
  1302. flex-direction: column;
  1303. align-items: center;
  1304. justify-content: center;
  1305. position: absolute;
  1306. top: 0;
  1307. left: 0;
  1308. width: 100%;
  1309. height: 100%;
  1310. z-index: 9999;
  1311. image {
  1312. border-radius: 50%;
  1313. animation: load linear 1s infinite;
  1314. width: 120rpx;
  1315. height: 120rpx;
  1316. }
  1317. .text {
  1318. font-size: 28rpx;
  1319. margin-top: 20rpx;
  1320. }
  1321. }
  1322. .storebox {
  1323. margin: 24rpx;
  1324. padding: 28rpx 26rpx;
  1325. font-family: PingFang SC, PingFang SC;
  1326. color: #333;
  1327. background: #FFFFFF;
  1328. border-radius: 16rpx 16rpx 16rpx 16rpx;
  1329. .logo {
  1330. width: 104rpx;
  1331. height: 104rpx;
  1332. background: #FFFFFF;
  1333. border-radius: 16rpx 16rpx 16rpx 16rpx;
  1334. margin-right: 26rpx;
  1335. }
  1336. .storename {
  1337. font-weight: 500;
  1338. font-size: 32rpx;
  1339. }
  1340. .storedesc {
  1341. margin-top: 12rpx;
  1342. font-weight: 400;
  1343. font-size: 22rpx;
  1344. }
  1345. .storebox-r {
  1346. flex: 1;
  1347. overflow: hidden;
  1348. }
  1349. .storebox-btn {
  1350. flex-shrink: 0;
  1351. padding: 10rpx 24rpx;
  1352. font-size: 28rpx;
  1353. border-radius: 28rpx 28rpx 28rpx 28rpx;
  1354. border: 2rpx solid #FF5C03;
  1355. font-weight: 500;
  1356. font-size: 24rpx;
  1357. color: #FF5C03;
  1358. }
  1359. }
  1360. .evaluate {
  1361. .title {
  1362. margin: 0;
  1363. padding-bottom: 24rpx;
  1364. }
  1365. }
  1366. .footer-desc {
  1367. text-align: center;
  1368. padding: 0 32rpx 24rpx 0;
  1369. font-size: 28rpx;
  1370. color: #999;
  1371. image{
  1372. margin-left: 10rpx;
  1373. width:15rpx;
  1374. height:20rpx;
  1375. }
  1376. }
  1377. </style>