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

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