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

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