金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1064 lines
29 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <template>
  2. <view>
  3. <lf-nav title="商品详情" titleColor="#fff" :spreadOut="false" :showIcon="true" bgColor="transparent"></lf-nav>
  4. <skeleton :loading="skeletonLoading" :row="12" :showAvatar="false" :showTitle="true">
  5. <block>
  6. <!-- 商品图片轮播 -->
  7. <swiper :current="current" :indicator-dots="pictures.length > 1" :circular="true" class="swiper-box" indicator-active-color="#1998FE">
  8. <swiper-item v-for="(item, index) in pictures" :key="index">
  9. <image mode="aspectFill" :src="item" style="width: 100%; height: 100%;" @click="lookImg(index)"></image>
  10. <view class="seckill-box" v-if="type == 'seckill' && $isRight(seckill.seckill.end_left_time)" style="z-index: 999;">
  11. <view>距离结束还剩余</view>
  12. <view v-if="$isRight(seckill.seckill.end_left_time)">
  13. <countdown-time
  14. :day="seckill.seckill.end_left_time[0]"
  15. :hour="seckill.seckill.end_left_time[1]"
  16. :minute="seckill.seckill.end_left_time[2]"
  17. :second="seckill.seckill.end_left_time[3]"
  18. color="white"
  19. splitorColor="white"
  20. >
  21. </countdown-time>
  22. </view>
  23. </view>
  24. <view class="seckill-box" v-if="type == 'seckill' && $isRight(seckill.seckill.start_left_time)" style="z-index: 999;">
  25. <view>距离开始还剩余</view>
  26. <view v-if="$isRight(seckill.seckill.start_left_time)">
  27. <countdown-time
  28. :day="seckill.seckill.start_left_time[0]"
  29. :hour="seckill.seckill.start_left_time[1]"
  30. :minute="seckill.seckill.start_left_time[2]"
  31. :second="seckill.seckill.start_left_time[3]"
  32. color="white"
  33. splitorColor="white"
  34. >
  35. </countdown-time>
  36. </view>
  37. </view>
  38. </swiper-item>
  39. </swiper>
  40. <!-- 商品主要信息 -->
  41. <view class="head-info">
  42. <view class="lf-row-between">
  43. <view v-if="type == 'point'">
  44. <text class="lf-font-48 lf-color-primary lf-font-bold">{{ goods_detail.redeem_point }}</text>
  45. <text class="lf-font-28 lf-color-777 lf-m-l-10">个积分兑换</text>
  46. </view>
  47. <lf-price :iftext="false" :price="goods_detail.sell_price || 0" v-else></lf-price>
  48. <text class="lf-iconfont icon-fenxiang lf-font-40" @click="shareGraphic()"></text>
  49. </view>
  50. <view class="lf-row-between lf-font-24 lf-m-t-20 lf-p-b-20">
  51. <view class="lf-font-bold lf-font-32 lf-color-222">{{ goods_detail.name }}</view>
  52. </view>
  53. <view class="lf-row-between lf-font-24 lf-p-b-30">
  54. <view class="lf-font-28 lf-color-777 lf-row-between">可自提/可邮寄</view>
  55. </view>
  56. </view>
  57. <!-- 商品优惠 -->
  58. <block v-if="coupons && coupons.length">
  59. <self-line></self-line>
  60. <view class="bg-white" >
  61. <view class="cu-bar padding-lr">
  62. <view class="lf-flex">
  63. <text class="lf-color-777 lf-font-28">优惠</text>
  64. <view style="width: 580rpx;">
  65. <view class="lf-color-222 lf-font-26 lf-m-l-30"
  66. v-for="(item, index) in coupons" :key="index">{{ item.title }}
  67. </view>
  68. </view>
  69. </view>
  70. <view>
  71. <text class="lf-font-24 lf-color-777 lf-iconfont icon-xiangyou"></text>
  72. </view>
  73. </view>
  74. </view>
  75. </block>
  76. <self-line></self-line>
  77. <!-- 服务tags -->
  78. <block v-if="goods_detail.tags.length">
  79. <view class="bg-white">
  80. <view class="cu-bar padding-lr">
  81. <view class="lf-flex">
  82. <text class="lf-color-777 lf-font-28">服务</text>
  83. <view style="width: 600rpx;flex-wrap: wrap;display: flex;margin-top: 32rpx;">
  84. <view class="lf-m-l-30" v-for="(tagItem, tagIndex) in goods_detail.tags" :key="tagIndex">
  85. <text class="lf-iconfont icon-xuanzhong lf-font-30" style="color: #15716E;"></text>
  86. <text class="lf-m-l-10 lf-font-26 lf-color-black">{{ tagItem }}</text>
  87. </view>
  88. </view>
  89. </view>
  90. <view>
  91. <text class="lf-font-24 lf-color-777 lf-iconfont icon-xiangyou"></text>
  92. </view>
  93. </view>
  94. </view>
  95. </block>
  96. <!-- 商品选择规格 -->
  97. <block v-if="$isRight(goods_stock.specs)">
  98. <view class="bg-white">
  99. <view class="cu-bar padding-lr" @click="shoot(3)" v-if="type == 'point'">
  100. <view class="lf-flex">
  101. <text class="lf-color-777 lf-font-28">选择</text>
  102. <text class="lf-color-222 lf-font-26 lf-m-l-30">{{ showSpec }}</text>
  103. </view>
  104. <view>
  105. <text class="lf-font-24 lf-color-777 lf-iconfont icon-xiangyou"></text>
  106. </view>
  107. </view>
  108. <view class="cu-bar padding-lr" @click="shoot(2)" v-else>
  109. <view class="lf-flex">
  110. <text class="lf-color-777 lf-font-28">选择</text>
  111. <text class="lf-color-222 lf-font-26 lf-m-l-30">{{ showSpec }}</text>
  112. </view>
  113. <view>
  114. <text class="lf-font-24 lf-color-777 lf-iconfont icon-xiangyou"></text>
  115. </view>
  116. </view>
  117. </view>
  118. <self-line></self-line>
  119. </block>
  120. <!-- 店铺信息 -->
  121. <view v-if="type != 'point'">
  122. <view class="user-top">
  123. <view class="lf-row-between lf-w-100">
  124. <view class="lf-flex" @click="$url('/pages/shop/shopdetail?id='+ brand_detail.id)">
  125. <view class="tag-father">
  126. <image :src="brand_detail.logo" mode="widthFix" class="head-img"></image>
  127. </view>
  128. <view class="lf-flex-column lf-m-l-20">
  129. <text class="lf-font-28 lf-color-black lf-font-bold">{{ brand_detail.name }}</text>
  130. <view class="lf-font-24 lf-color-777">
  131. <text class="lf-iconfont icon-dizhi lf-font-24 lf-color-primary"></text>
  132. <text class="lf-m-l-10">{{ brand_detail.floor }}</text>
  133. </view>
  134. </view>
  135. </view>
  136. <!-- <view>
  137. <button class="head-btn" @click="$url('/pages/user/my/chatonline')">
  138. <text class="lf-iconfont icon-kefuhdpi lf-font-24"></text>
  139. <text class="lf-m-l-10">客服</text>
  140. </button>
  141. </view> -->
  142. </view>
  143. </view>
  144. <scroll-view class="scroll-view" :scroll-x="true">
  145. <view class="scroll-content">
  146. <view class="goods-item"
  147. v-for="(item, index) in brand_detail.goods"
  148. :key="index"
  149. @click="$url('/pages/shop/goodsdetail?id='+ item.id)">
  150. <image class="goods-img" :src="item.img"></image>
  151. <view class="goods-info">
  152. <view class="lf-line-1">{{ item.name }}</view>
  153. <view>{{ item.sell_price }}</view>
  154. </view>
  155. </view>
  156. <view class="goods-item" @click="$url('/pages/shop/shopdetail?id='+ brand_detail.id)">
  157. <view class="more-box">
  158. <text>查看更多</text>
  159. <text class="lf-iconfont icon--2 lf-text-vertical"></text>
  160. </view>
  161. </view>
  162. </view>
  163. </scroll-view>
  164. </view>
  165. <!-- 商品详情 -->
  166. <view class="goods-detail">
  167. <view class="lf-font-32 lf-font-bold lf-m-b-20">商品详情</view>
  168. <rich-text :nodes="formatRichText(goods_detail.content)"></rich-text>
  169. <!-- <image class="goods-img" :src="item" v-for="(item, index) in goods_detail.content" :key="index" v-if="goods_detail.content_type == 'img'"></image> -->
  170. </view>
  171. <!-- 修饰专用 -->
  172. <view class="extra"></view>
  173. <!-- 吸底操作按钮 -->
  174. <view class="lf-row-between fixed-bottom">
  175. <view class="lf-flex lf-p-t-10 lf-p-b-10">
  176. <!-- <view class="lf-flex-column lf-row-center icon-item" open-type="contact">
  177. <text class="lf-iconfont icon-pinglun- icon-img"></text>
  178. <view class="lf-m-t-1">客服</view>
  179. </view> -->
  180. <view class="lf-flex-column lf-row-center icon-item" @click="switchCollect">
  181. <text class="lf-iconfont icon-shoucang2 icon-img lf-color-price" v-if="is_collect"></text>
  182. <text class="lf-iconfont icon-shoucang11 icon-img" v-else></text>
  183. <view class="lf-m-t-1">{{ is_collect ? '已收藏' : '收藏' }}</view>
  184. </view>
  185. <button class="lf-flex-column lf-row-center icon-item" @click="$url('/pages/store/cart/cart')">
  186. <text class="lf-iconfont icon-gouwulan icon-img"></text>
  187. <view class="lf-m-t-1">购物车</view>
  188. </button>
  189. </view>
  190. <view v-if="type == 'seckill'">
  191. <button class="btn" style="width: 349rpx;" @click="shoot(2)">立即秒杀</button>
  192. </view>
  193. <view v-else-if="type == 'point'">
  194. <button class="btn" style="width: 349rpx;" @click="shoot(3)">立即兑换</button>
  195. </view>
  196. <view class="lf-flex" v-else>
  197. <button class="btn1" @click="shoot(1)">加入购物车</button>
  198. <button class="btn lf-m-l-15" @click="shoot(2)">立即购买</button>
  199. </view>
  200. </view>
  201. <!-- 加入购物车立即购买模态框选规格 -->
  202. <u-popup v-model="show_popup" mode="bottom" :round="true" borderRadius="20">
  203. <view class="popup-content">
  204. <!-- 商品信息及关闭按钮 -->
  205. <view class="popup-head">
  206. <view class="lf-flex">
  207. <image class="goods-img" :src="goods_detail.img"></image>
  208. <view class="goods-info">
  209. <view class="price">{{ showGoodsSpecPrice }}</view>
  210. <view class="goods-name">{{ goods_detail.name }}</view>
  211. </view>
  212. </view>
  213. <view @click="show_popup = false">
  214. <text class="lf-iconfont icon-cuo lf-font-50"></text>
  215. </view>
  216. </view>
  217. <!-- 规格 -->
  218. <view v-for="(value, key) in goods_stock.specs" :key="key">
  219. <view class="spec-title">{{ value.label }}</view>
  220. <view class="lf-flex-wrap">
  221. <view :class="{
  222. 'spec-item': true,
  223. 'spec-active': value.spec_current === index}"
  224. @click="activeSpec(key, index)"
  225. v-for="(item, index) in value.list"
  226. :key="index">{{ item.value }}
  227. </view>
  228. </view>
  229. </view>
  230. <!-- 数量 -->
  231. <view class="lf-row-between lf-m-t-40">
  232. <view class="lf-font-28 lf-color-555">数量</view>
  233. <view class="lf-flex">
  234. <view class="num-btn" @click="changeNum('less')">
  235. <text class="lf-iconfont icon-jian1 lf-font-30"></text>
  236. </view>
  237. <view>
  238. <input class="input" :value="goods_num" :disabled="true" />
  239. </view>
  240. <view class="num-btn lf-text-right" @click="changeNum('add')">
  241. <text class="lf-iconfont icon-jia lf-font-30"></text>
  242. </view>
  243. </view>
  244. </view>
  245. <!-- 操作按钮 -->
  246. <button class="comfirm-btn" @click="specConfirm">{{ click_type == 1 ? '加入购物车' : '立即购买' }}</button>
  247. </view>
  248. </u-popup>
  249. <!-- 回到顶部 -->
  250. <u-back-top :scroll-top="pageScrollTop"></u-back-top>
  251. </block>
  252. </skeleton>
  253. </view>
  254. </template>
  255. <script>
  256. import countdownTime from '@/components/uni-countdown/uni-countdown.vue';
  257. export default {
  258. components: {
  259. countdownTime
  260. },
  261. data(){
  262. return {
  263. current: 0, // 轮播下标
  264. goods_id: 0,
  265. goods_detail: {},
  266. is_collect: false, // 1为当前收藏商品了,0为否
  267. skeletonLoading: false,
  268. pictures: [],
  269. show_popup: false, // 是否显示选规格模态框
  270. click_type: null, // 当前点击的是加入购物车[1]还是立即购买[2]
  271. type: 'mail', // 页面显示类型,mail普通可邮寄商品,point积分商品,seckill秒杀商品
  272. time: 0,
  273. goods_stock: {
  274. specs: {},
  275. stores: {}
  276. },
  277. seckill: {}, // 秒杀商品的信息
  278. brand_detail: {},
  279. token: '',
  280. coupons: [], // 优惠
  281. goods_num: 1,
  282. is_date_finish: false
  283. }
  284. },
  285. computed: {
  286. showGoodsSpecPrice(){
  287. let goods_detail = this.goods_detail;
  288. let stores = this.goods_stock.stores;
  289. let specs = this.goods_stock.specs;
  290. if(!this.$isRight(specs[1])){
  291. return `${goods_detail.min_price} - ¥${goods_detail.max_price}`;
  292. }
  293. let spec_current_1 = specs[1].spec_current;
  294. let spec_current_2 = specs[2].spec_current;
  295. if(specs[1].spec_current != null && specs[2].spec_current != null){
  296. let id_1 = specs[1].list[spec_current_1].id;
  297. let id_2 = specs[2].list[spec_current_2].id;
  298. if(id_1 < id_2){
  299. let id_3 = id_2;
  300. id_2 = id_1;
  301. id_1 = id_3;
  302. }
  303. return "¥"+ stores[id_2 +'-'+ id_1].price;
  304. }else{
  305. return `${goods_detail.min_price} - ¥${goods_detail.max_price}`;
  306. }
  307. },
  308. showSpec(){
  309. let specs = this.goods_stock.specs;
  310. let str = '';
  311. for(let i in specs){
  312. if(specs[i].spec_current != null){
  313. str += specs[i].list[specs[i].spec_current].value +';';
  314. }
  315. }
  316. if(str == ''){
  317. str = '请选择规格'
  318. }
  319. return str;
  320. }
  321. },
  322. onLoad(options){
  323. console.log("options", options)
  324. this.token = this.$cookieStorage.get('user_token');
  325. this.goods_id = options.id;
  326. this.getNewdetail();
  327. this.getGoodsStock(); // 获取商品库存、规格信息
  328. },
  329. methods: {
  330. // 切换商品收藏
  331. switchCollect(){
  332. if(!this.token){
  333. this.$url('/pages/login/index');
  334. return;
  335. }
  336. this.addCollcet()
  337. },
  338. //收藏
  339. addCollcet() {
  340. this.$http.post({
  341. api: 'api/collect/create',
  342. data: {
  343. type:'jc_goods',
  344. collect_id: this.goods_detail.id,
  345. },
  346. header: {
  347. Authorization: this.token
  348. }
  349. }).then(res => {
  350. this.$msg(res.data.data);
  351. this.getNewdetail();
  352. }).catch(err => {
  353. console.log("====", err);
  354. })
  355. },
  356. // 加入购物车和立即购买
  357. shoot(type){
  358. this.click_type = type;
  359. if(this.$isRight(this.goods_stock.specs)){
  360. this.show_popup = true;
  361. }else{
  362. this.confirm();
  363. }
  364. },
  365. // 选规格提交
  366. specConfirm(){
  367. let specs = this.goods_stock.specs;
  368. let flag = true;
  369. for(let i in specs){
  370. if(specs[i].spec_current == null){
  371. flag = false;
  372. }
  373. }
  374. if(flag){
  375. this.confirm();
  376. }else{
  377. this.$msg('您未选完整规格')
  378. }
  379. },
  380. // 商品选规格
  381. activeSpec(key, index){
  382. let obj = this.goods_stock.specs;
  383. if(obj[key]['spec_current'] == index){
  384. obj[key]['spec_current'] = null;
  385. }else{
  386. obj[key]['spec_current'] = index;
  387. }
  388. this.$set(this.goods_stock, 'specs', obj);
  389. },
  390. // 商品加减
  391. changeNum(type){
  392. if(type == 'add'){
  393. if(this.goods_num < 10){
  394. this.goods_num++;
  395. }
  396. }else if(type == 'less'){
  397. if(this.goods_num > 1){
  398. this.goods_num--;
  399. }
  400. }
  401. },
  402. // 跳转至下单页TODO
  403. confirm(){
  404. if(this.is_date_finish){
  405. return this.$msg('活动已结束');
  406. }
  407. let goods_detail = this.goods_detail;
  408. let specs = this.goods_stock.specs;
  409. let stores = this.goods_stock.stores;
  410. let par = {};
  411. let have_specs = '';
  412. let no_specs = '';
  413. if(this.$isRight(specs)){
  414. let s_id_1 = 1;
  415. let s_id_2 = 2;
  416. for(let i in specs){
  417. if(specs[i].label_key == 'size'){
  418. s_id_1 = 1;
  419. }
  420. if(specs[i].label_key == 'color'){
  421. s_id_2 = 2;
  422. }
  423. }
  424. let spec_current_1 = specs[s_id_1].spec_current;
  425. let spec_current_2 = specs[s_id_2].spec_current;
  426. let id_1 = specs[s_id_1].list[spec_current_1].id;
  427. let id_2 = specs[s_id_2].list[spec_current_2].id;
  428. if(id_1 > id_2){
  429. let id_3 = id_2;
  430. id_2 = id_1;
  431. id_1 = id_3;
  432. }
  433. par = {
  434. attributes: {
  435. color: specs[s_id_2].list[specs[s_id_2].spec_current].value,
  436. com_id: goods_detail.id,
  437. img: goods_detail.img,
  438. size: specs[s_id_1].list[specs[s_id_1].spec_current].value,
  439. sku: goods_detail.goods_no +'-'+ specs[s_id_1].list[specs[s_id_1].spec_current].value
  440. },
  441. id: stores[id_1 +'-'+ id_2].id,
  442. product_id: stores[id_1 +'-'+ id_2].id,
  443. price: stores[id_1 +'-'+ id_2].price,
  444. store_count: stores[id_1 +'-'+ id_2].store,
  445. market_price: goods_detail.market_price,
  446. name: goods_detail.name,
  447. qty: this.goods_num
  448. }
  449. have_specs = stores[id_1 +'-'+ id_2].id;
  450. }else{
  451. par = {
  452. attributes: {
  453. com_id: goods_detail.id,
  454. img: goods_detail.img
  455. },
  456. id: goods_detail.id,
  457. product_id: goods_detail.id,
  458. price: goods_detail.sell_price,
  459. store_count: goods_detail.store_nums,
  460. market_price: goods_detail.market_price,
  461. name: goods_detail.name,
  462. qty: this.goods_num
  463. }
  464. no_specs = goods_detail.id;
  465. }
  466. // 秒杀商品
  467. if(this.$isRight(this.seckill)){
  468. delete par.product_id;
  469. par.seckill_goods_id = this.seckill.item_id;
  470. par.seckill_item_id = this.seckill.id;
  471. par.price = this.seckill.seckill_price;
  472. par.total = this.goods_num;
  473. }
  474. uni.showLoading({
  475. title: '正在提交'
  476. })
  477. this.show_popup = false;
  478. if(this.click_type == 1){
  479. // 加入购物车
  480. this.$http.post({
  481. api: 'api/shopping/cart',
  482. data: {"0": par},
  483. header: {
  484. Authorization: this.token
  485. }
  486. }).then(res => {
  487. if(res.data.code == 200){
  488. this.$msg('加入购物车成功', {icon: 'success'})
  489. }else{
  490. this.$msg('加入购物车失败', {icon: 'error'})
  491. }
  492. uni.hideLoading()
  493. }).catch(err => uni.hideLoading())
  494. }else if(this.click_type == 2){
  495. // 直接结算
  496. this.$cookieStorage.set('order_confirm', par);
  497. uni.hideLoading();
  498. this.$url('/pages/order/confirm/confirm');
  499. // this.$http.post({
  500. // api: 'api/shopping/order/checkout',
  501. // data: par,
  502. // header: {
  503. // Authorization: this.token
  504. // }
  505. // }).then(res => {
  506. // if(res.data.code == 200){
  507. // this.$url('/pages/order/confirm/confirm');
  508. // }else{
  509. // this.$msg('提交失败', {icon: 'error'})
  510. // }
  511. // uni.hideLoading()
  512. // }).catch(err => uni.hideLoading())
  513. }else if(this.click_type == 3) {
  514. let params = {};
  515. if(have_specs) {
  516. uni.hideLoading()
  517. this.$url('/pages/order/pointconfirm/confirm?quantity='+this.goods_num+'&product_id='+have_specs+'&goods_type=0')
  518. }else {
  519. uni.hideLoading()
  520. this.$url('/pages/order/pointconfirm/confirm?quantity='+this.goods_num+'&goods_id='+no_specs+'&goods_type=0')
  521. }
  522. }
  523. },
  524. // 点击页面分享按钮
  525. shareGraphic(){
  526. this.getCreateShareImg();
  527. },
  528. //请求h5的图片接口
  529. getCreateShareImg(){
  530. wx.showLoading({
  531. title:"生成中",
  532. mask:true
  533. })
  534. let origin = window.location.origin;
  535. let share_url = origin+'/pages/store/detail/detail';
  536. this.$http.get({
  537. api:'api/distribution/createH5ShareImg',
  538. data:{
  539. goods_id:this.id,
  540. share_url:share_url
  541. }
  542. }).then(res=>{
  543. res = res.data;
  544. if(res.status){
  545. this.qr_code_image = res.data.image;
  546. if(this.qr_code_image){
  547. this.share_gaphic =!this.share_gaphic;
  548. this.is_toggle_share = false;
  549. }
  550. } else{
  551. wx.showModal({
  552. content: res.message || '请求失败,请重试',
  553. showCancel: false
  554. });
  555. }
  556. wx.hideLoading()
  557. }).catch(rej=>{
  558. wx.hideLoading()
  559. wx.showModal({
  560. content: rej.message || '内部错误,请重试',
  561. showCancel: false
  562. });
  563. })
  564. },
  565. // 商品详情
  566. getNewdetail(){
  567. this.$http.get({
  568. api: 'api/store/detail/'+ this.goods_id,
  569. header: {
  570. Authorization: this.token
  571. }
  572. }).then(res => {
  573. console.log("===---", res);
  574. let meta = res.data.meta;
  575. let goods_detail = res.data.data;
  576. this.goods_detail = goods_detail;
  577. this.pictures = [res.data.data.img];
  578. this.is_collect = Boolean(res.data.data.is_collect) || false;
  579. let type = 'mail';
  580. if(this.$isRight(goods_detail.is_largess)){
  581. type = 'point';
  582. }
  583. if(this.$isRight(meta.seckill)){
  584. type = 'seckill';
  585. this.seckill = meta.seckill;
  586. let currentDate = this.$shared.recordTime();
  587. this.time = new Date(meta.seckill.ends_at).getTime() - new Date(currentDate).getTime()
  588. }
  589. if(type != 'point'){
  590. this.getBrandDetail(goods_detail.brand_id);
  591. }
  592. if(this.$isRight(meta.discounts)){
  593. this.coupons = meta.discounts.coupons;
  594. }
  595. this.type = type;
  596. }).catch(err => {
  597. console.log("====", err);
  598. })
  599. },
  600. // 获取商家信息
  601. getBrandDetail(brand_id){
  602. this.$http.get({
  603. api: 'api/brand/detail',
  604. data: {
  605. brand_id: brand_id
  606. },
  607. header: {
  608. Authorization: this.token
  609. }
  610. }).then(res => {
  611. this.brand_detail = res.data.data;
  612. })
  613. },
  614. // 获取商品库存信息
  615. getGoodsStock(){
  616. this.$http.get({
  617. api: `api/store/detail/${this.goods_id}/stock`
  618. }).then(res => {
  619. let data = res.data.data;
  620. for(let i in data.specs){
  621. data.specs[i].spec_current = null;
  622. }
  623. this.goods_stock = data;
  624. })
  625. },
  626. // 拨打电话
  627. makePhoneCall(phoneStr){
  628. uni.makePhoneCall({
  629. phoneNumber: String(phoneStr)
  630. })
  631. },
  632. // 打开地图 PS.暂时用不到
  633. openMap(){
  634. let { address, lat, lng } = this.goods_detail?.store || {};
  635. uni.openLocation({
  636. longitude: Number(lat),
  637. latitude: Number(lng),
  638. scale: 20,
  639. name: address
  640. });
  641. },
  642. // 预览图片
  643. lookImg(index){
  644. this.$u.throttle(() => {
  645. let banners = this.pictures;
  646. uni.previewImage({
  647. urls: banners,
  648. current: index
  649. })
  650. }, 200);
  651. },
  652. // 倒计时结束
  653. dateFinish(){
  654. this.is_date_finish = true;
  655. },
  656. // 富文本处理
  657. formatRichText(richText){
  658. if(richText != null){
  659. let newRichText= richText.replace(/<img[^>]*>/gi, function(match, capture){
  660. match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
  661. match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
  662. match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
  663. return match;
  664. });
  665. newRichText = newRichText.replace(/style="[^"]+"/gi,function(match, capture){
  666. match = match.replace(/width:[^;]+;/gi, 'width:100%;').replace(/width:[^;]+;/gi, 'width:100%;');
  667. return match;
  668. });
  669. newRichText = newRichText.replace(/<br[^>]*\/>/gi, '');
  670. newRichText = newRichText.replace(/\<img/gi, '<img style="width:100%;height:auto;display:block;margin:10px 0;"');
  671. return newRichText;
  672. }else{
  673. return null;
  674. }
  675. }
  676. },
  677. onShareAppMessage(){
  678. let goods = this.goods_detail;
  679. let title = goods.name;
  680. let imageUrl = goods.share_cover || goods.cover || goods.img;
  681. let path = '/pages/route/index?route=detail&id='+ goods.id;
  682. return {
  683. title,
  684. path,
  685. imageUrl
  686. }
  687. }
  688. }
  689. </script>
  690. <style>
  691. page{
  692. background-color: #f5f5f5;
  693. overflow-x: hidden;
  694. }
  695. </style>
  696. <style lang="scss" scoped="scoped">
  697. //商品上去scrollview部分
  698. .scroll-view{
  699. height: 310rpx;
  700. width: 100%;
  701. // margin-top: 20rpx;
  702. padding: 0 30rpx 30rpx 30rpx;
  703. background-color: white;
  704. .scroll-content{
  705. display: flex;
  706. width: 100%;
  707. .goods-item{
  708. margin-right: 15rpx;
  709. width: 180rpx;
  710. }
  711. .goods-img{
  712. width: 180rpx;
  713. height: 180rpx;
  714. background-color: #EEEEEE;
  715. }
  716. .goods-info{
  717. text-align: center;
  718. color: #222222;
  719. &>view:nth-child(1n){
  720. font-size: 24rpx;
  721. }
  722. &>view:nth-child(2n){
  723. font-size: 28rpx;
  724. font-weight: bold;
  725. text-align: left;
  726. color: #F63434;
  727. }
  728. }
  729. .more-box{
  730. width: 180rpx;
  731. height: 180rpx;
  732. background-color: #EEEEEE;
  733. text-align: center;
  734. line-height: 180rpx;
  735. font-size: 24rpx;
  736. }
  737. }
  738. }
  739. //scrollview结束
  740. .tag-father {
  741. position: relative;
  742. }
  743. .head-tag {
  744. color: white;
  745. display: flex;
  746. align-items: center;
  747. justify-content: center;
  748. text-align: center;
  749. font-size: 24rpx;
  750. width: 36rpx;
  751. height: 36rpx;
  752. border-radius: 50%;
  753. background-color: #15716E;
  754. border: 1rpx solid #FFFFFF;
  755. position: absolute;
  756. left: 76rpx;
  757. top: 86rpx;
  758. z-index: 99;
  759. }
  760. .qzone-img {
  761. width: 220rpx;
  762. height: 220rpx;
  763. border-radius: 10rpx;
  764. margin-right: 12rpx;
  765. &:nth-child(3n) {
  766. margin-right: 0;
  767. }
  768. &:nth-child(n + 4) {
  769. margin-top: 12rpx;
  770. }
  771. }
  772. .user-top {
  773. background-color: #F3F8F8;
  774. padding: 30rpx;
  775. display: flex;
  776. align-items: center;
  777. background-color: white;
  778. }
  779. .head-img {
  780. width: 80rpx;
  781. height: 80rpx;
  782. border-radius: 50%;
  783. }
  784. .head-btn {
  785. display: flex;
  786. width: max-content;
  787. height: 45rpx;
  788. background: white;
  789. border: 2rpx solid #15716E;
  790. align-items: center;
  791. font-size: 22rpx;
  792. color: #15716E;
  793. justify-content: space-between;
  794. border-radius: 35rpx;
  795. padding: 10rpx!important;
  796. }
  797. .swiper-box{
  798. width: 750rpx;
  799. height: 750rpx;
  800. background-color: #FFFFFF;
  801. position: relative;
  802. .seckill-box{
  803. position: absolute;
  804. bottom: 0;
  805. left: 0;
  806. display: flex;
  807. justify-content: space-between;
  808. align-items: center;
  809. padding: 0 32rpx;
  810. width: 100%;
  811. height: 77rpx;
  812. background-color: #15716E;
  813. color: #FFFFFF;
  814. font-size: 26rpx;
  815. }
  816. }
  817. .head-info{
  818. width: 750rpx;
  819. height: auto;
  820. box-sizing: border-box;
  821. padding: 0 32rpx;
  822. padding-top: 20rpx;
  823. background-color: #FFFFFF;
  824. // .price>view:nth-of-type(1){
  825. // color: #FF0000;
  826. // margin-right: 22rpx;
  827. // font-weight: bold;
  828. // }
  829. .price>view:nth-of-type(1){
  830. text-decoration: line-through;
  831. color: #777777;
  832. margin-right: 22rpx;
  833. }
  834. .price>view:nth-of-type(2){
  835. width: max-content;
  836. padding: 0 18rpx;
  837. height: 46rpx;
  838. background-color: #1998FE;
  839. border-radius: 10rpx;
  840. display: flex;
  841. justify-content: center;
  842. align-items: center;
  843. color: #FFFFFF;
  844. }
  845. .label-box{
  846. min-height: 130rpx;
  847. width: 100%;
  848. border-top: 1rpx solid #E5E5E5;
  849. display: flex;
  850. flex-wrap: wrap;
  851. padding: 30rpx 0 10rpx 0;
  852. .label-item{
  853. width: max-content;
  854. padding: 20rpx;
  855. height: 70rpx;
  856. border-radius: 10rpx;
  857. border: 2rpx solid #1998FE;
  858. display: flex;
  859. justify-content: center;
  860. align-items: center;
  861. font-size: 28rpx;
  862. color: #1998FE;
  863. margin-right: 20rpx;
  864. margin-bottom: 20rpx;
  865. }
  866. }
  867. }
  868. .address-box{
  869. width: 750rpx;
  870. height: auto;
  871. box-sizing: border-box;
  872. background-color: #FFFFFF;
  873. padding: 32rpx;
  874. margin-top: 20rpx;
  875. .shop-img{
  876. width: 60rpx;
  877. height: 60rpx;
  878. border-radius: 50%;
  879. }
  880. }
  881. .goods-detail{
  882. width: 750rpx;
  883. height: auto;
  884. background-color: #FFFFFF;
  885. padding: 32rpx;
  886. box-sizing: border-box;
  887. margin-top: 20rpx;
  888. .goods-img{
  889. width: 100%;
  890. }
  891. }
  892. .extra{
  893. width: 100%;
  894. height: 110rpx;
  895. padding-bottom: constant(safe-area-inset-bottom);
  896. padding-bottom: env(safe-area-inset-bottom);
  897. box-sizing: content-box;
  898. }
  899. .fixed-bottom{
  900. position: fixed;
  901. bottom: 0;
  902. left: 0;
  903. background-color: #FFFFFF;
  904. width: 100%;
  905. height: auto;
  906. padding: 0 32rpx;
  907. border-top: 1rpx solid #e5e5e5;
  908. padding-bottom: constant(safe-area-inset-bottom);
  909. padding-bottom: env(safe-area-inset-bottom);
  910. .icon-item{
  911. text-align: center;
  912. margin-right: 16rpx;
  913. background-color: transparent;
  914. margin: 0;
  915. line-height: initial;
  916. font-size: 28rpx;
  917. font-weight: inherit;
  918. margin-right: 10rpx;
  919. padding: 0;
  920. width: 88rpx;
  921. position: relative;
  922. &:first-child{
  923. padding-left: 0;
  924. }
  925. .icon-img{
  926. height: 50rpx;
  927. width: 50rpx;
  928. font-size: 40rpx;
  929. line-height: 1;
  930. }
  931. }
  932. .btn1{
  933. margin: 0;
  934. width: max-content;
  935. height: 80rpx;
  936. background-color: rgba(21, 113, 110, 0.1);
  937. color: #15716E;
  938. line-height: 80rpx;
  939. font-size: 32rpx;
  940. padding: 0 20rpx;
  941. border-radius: 42rpx;
  942. font-size: 26rpx;
  943. border: 2rpx solid #15716E;
  944. }
  945. .btn{
  946. margin: 0;
  947. padding: 0 20rpx;
  948. width: max-content;
  949. height: 80rpx;
  950. background-color: #15716E;
  951. color: #FFFFFF;
  952. line-height: 80rpx;
  953. font-size: 26rpx;
  954. border-radius: 42rpx;
  955. }
  956. }
  957. .popup-content{
  958. height: max-content;
  959. width: 750rpx;
  960. background: #FFFFFF;
  961. border-radius: 20rpx 20rpx 0rpx 0rpx !important;
  962. padding: 40rpx 32rpx;
  963. max-height: 80vh;
  964. overflow-y: scroll;
  965. .popup-head{
  966. display: flex;
  967. justify-content: space-between;
  968. .goods-img{
  969. width: 150rpx;
  970. height: 150rpx;
  971. border-radius: 2rpx;
  972. margin-right: 20rpx;
  973. }
  974. .goods-info{
  975. width: 400rpx;
  976. height: 150rpx;
  977. display: flex;
  978. flex-direction: column;
  979. justify-content: space-around;
  980. .price{
  981. font-size: 48rpx;
  982. font-weight: bold;
  983. color: #F63434;
  984. line-height: 1;
  985. }
  986. .goods-name{
  987. font-size: 32rpx;
  988. color: #222222;
  989. line-height: 1.4;
  990. }
  991. }
  992. }
  993. .spec-title{
  994. font-size: 28rpx;
  995. color: #555555;
  996. margin-top: 40rpx;
  997. margin-bottom: 20rpx;
  998. }
  999. .spec-item{
  1000. width: 142rpx;
  1001. height: 64rpx;
  1002. border-radius: 33rpx;
  1003. border: 2rpx solid #555555;
  1004. font-size: 28rpx;
  1005. color: #555555;
  1006. display: flex;
  1007. justify-content: center;
  1008. align-items: center;
  1009. margin-right: 20rpx;
  1010. &:nth-child(4n){
  1011. margin-right: 0rpx;
  1012. }
  1013. &:nth-child(n+5){
  1014. margin-top: 20rpx;
  1015. }
  1016. }
  1017. .spec-active{
  1018. border: none;
  1019. background-color: #15716E;
  1020. color: #FFFFFF;
  1021. }
  1022. .input{
  1023. width: 40rpx;
  1024. height: 45rpx;
  1025. border-radius: 2rpx;
  1026. background-color: #F3F8F7;
  1027. text-align: center;
  1028. }
  1029. .num-btn{
  1030. width: 36rpx;
  1031. }
  1032. .comfirm-btn{
  1033. width: 550rpx;
  1034. height: 100rpx;
  1035. background: #15716E;
  1036. border-radius: 50rpx;
  1037. color: #FFFFFF;
  1038. line-height: 100rpx;
  1039. margin-top: 62rpx;
  1040. }
  1041. }
  1042. </style>