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

1057 lines
28 KiB

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