金诚优选前端代码
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.

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