productDetails.vue 32 KB

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