goods.vue 26 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048
  1. <template>
  2. <view>
  3. <!-- 01. 轮播区 -->
  4. <view class="swiper-area w-full pos-f">
  5. <swiper class="h-full pos-r" indicator-dots circular="true" duration="400">
  6. <swiper-item v-for="(item, index) in swiperDatas" :key="index">
  7. <view class="wh-full"><image :src="item" class="wh-full loaded" lazy-load="true" mode="aspectFill"></image></view>
  8. </swiper-item>
  9. </swiper>
  10. </view>
  11. <!-- 02. 商品数据区 -->
  12. <view class="goods-area bg-main padding">
  13. <view class="price-box dflex-b">
  14. <view>
  15. <text class="price fwb fs-big">{{ goods.price || '' }}</text>
  16. <text class="m-price" v-if="goods.marketPrice > 0">{{ goods.marketPrice || '' }}</text>
  17. </view>
  18. <view class="dflex fs-sm ft-dark">
  19. <!-- #ifdef MP-WEIXIN || H5 -->
  20. <view class="margin-right-sm dflex" @click="shareOpen">
  21. <view class="iconfont iconfenxiang padding-right-xs"></view>
  22. <text>分享</text>
  23. </view>
  24. <!-- #endif -->
  25. <!-- #ifdef MP-ALIPAY || MP-BAIDU || MP-QQ || MP-TOUTIAO -->
  26. <button class="btn no-border padding-0 fs-sm ft-dark" open-type="share" @click="shareOpen">
  27. <view class="margin-right-sm dflex">
  28. <view class="iconfont iconfenxiang padding-right-xs"></view>
  29. <text>分享</text>
  30. <text>{{ goods.shareCnt || '0' }}</text>
  31. </view>
  32. </button>
  33. <!-- #endif -->
  34. <view class="margin-right-sm dflex">
  35. <view class="padding-right-xs padding-right-xs">已售</view>
  36. <text>{{ goods.saleCnt || '0' }}</text>
  37. </view>
  38. <view class="dflex">
  39. <view class="padding-right-xs padding-right-xs">库存</view>
  40. <text>{{ goods.stockNum || '0' }}</text>
  41. </view>
  42. </view>
  43. </view>
  44. <text class="title1 fs">{{ goods.name || '' }}</text>
  45. </view>
  46. <view class="gap"></view>
  47. <!-- 分享 -->
  48. <use-popup mode="bottom" bgclass=" " v-model="shareShow">
  49. <view class="share-area margin border-radius bg-main" @click="shareClose">
  50. <view class="tac w-full padding-sm">分享</view>
  51. <view class="padding-lr margin-bottom-xl dflex-b pos-r">
  52. <!-- #ifdef MP-WEIXIN -->
  53. <button class="dflex-c dflex-flow-c no-border btn" style="color: #07c160" open-type="share">
  54. <view class="iconfont iconweixin padding-lr-sm border-radius-c fs-xxxl"></view>
  55. <view class="dflex-c fs-sm ft-dark">微信好友</view>
  56. </button>
  57. <!-- <view class="vertical-line"></view> -->
  58. <!-- #endif -->
  59. <!-- <button class="dflex-c dflex-flow-c no-border btn ft-base" @click="createPoster">
  60. <view class="iconfont iconhaibao1 padding-lr-sm border-radius-c fs-xxxl"></view>
  61. <view class="dflex-c fs-sm ft-dark">生成海报</view>
  62. </button> -->
  63. </view>
  64. </view>
  65. </use-popup>
  66. <!-- 海报二维码 -->
  67. <view class="qrcode tac padding-tb pos-f pos-tl-c">
  68. <!-- <use-qrcode :onval="true" :val="posterQRcode" :show="false" loading-text="生成海报中" qrsize="200" @result="posterQRcodeResult"></use-qrcode> -->
  69. </view>
  70. <!-- 海报 -->
  71. <view v-if="posterShow && !posterUrl" class="poster pos-f pos-tl-c padding">
  72. <l-painter custom-style="position: fixed;z-index: -1;top: -200vh;left: -100vw;" :board="posterData" isRenderImage @success="posterSuccess" />
  73. </view>
  74. <!-- <use-popup mode="bottom" bgclass=" " v-model="posterShow" @close="">
  75. <view class="padding border-radius margin">
  76. <view v-if="!posterUrl" class="tac bg-main padding border-radius pos-a pos-l-c" style="bottom: 45vh">海报生成中,请稍等</view>
  77. <view class="w-full" style="height: 70vh"><image :src="posterUrl" class="wh-full" mode="aspectFit"></image></view>
  78. <view class="padding w-full margin-top">
  79. <view class="dflex-b border-radius-big"> -->
  80. <!-- #ifdef MP -->
  81. <!-- <view class="tac padding-tb-sm flex1 bg-base" @click="posterSave">保存到相册</view> -->
  82. <!-- #endif -->
  83. <!-- #ifdef H5 || MP-360 -->
  84. <!-- <view class="tac padding-tb-sm flex1 bg-base">长按图片保存到相册</view> -->
  85. <!-- #endif -->
  86. <!-- </view>
  87. </view>
  88. </view>
  89. </use-popup> -->
  90. <!-- 03. 规格区 -->
  91. <!-- <view v-if="skuDatas.length > 0" class="sku-area bg-main padding-lr padding-top padding-bottom-xs pos-r">
  92. <view class="con dflex dflex-wrap-w">
  93. <view
  94. class="margin-right-sm margin-bottom-sm dflex bg-drak border-radius-lg padding-tb-16 padding-lr"
  95. :class="{ active: item.selected }"
  96. v-for="(item, index) in skuDatas"
  97. :key="index"
  98. @click="selectSKU(item)"
  99. >
  100. <text class="fs-xs">{{ item.name }}</text>
  101. </view>
  102. </view>
  103. </view>
  104. <view v-if="skuDatas.length > 0" class="gap"></view> -->
  105. <!-- 04.01 优惠券 -->
  106. <!-- <use-list-title title="优惠" tip="领取优惠券" color="#ff6a6c" iconfont="iconyouhui" @goto="couponShow = true"></use-list-title> -->
  107. <!-- 04.01 优惠券弹出层 -->
  108. <use-popup mode="bottom" v-model="couponShow" @open="couponOpen">
  109. <!-- 优惠券区 -->
  110. <scroll-view>
  111. <view class="coupon-area padding bg-drak">
  112. <view class="coupon-item bg-main pos-r fs-xs" v-for="(item, index) in couponDatas" :key="index">
  113. <view class="content pos-r padding dflex-b">
  114. <view class="">
  115. <view class="margin-bottom-xs fs">{{ item.name }}</view>
  116. <view class="ft-dark">有效期至 {{ item.end_time.split(' ')[0] }}</view>
  117. </view>
  118. <view class="tar">
  119. <view class="margin-bottom-xs price">{{ item.price }}</view>
  120. <view v-if="item.order_amount > 0" class="ft-dark">满{{ item.order_amount }}可用</view>
  121. <view v-else class="ft-dark">不限</view>
  122. </view>
  123. <view class="circle l"></view>
  124. <view class="circle r"></view>
  125. </view>
  126. <view class="dflex-b">
  127. <text class="ft-dark padding-lr">{{ item.type }}</text>
  128. <text class="ft-base padding-tb-sm padding-lr" @click="couponReceive(item.id)">立即领取</text>
  129. </view>
  130. </view>
  131. </view>
  132. </scroll-view>
  133. </use-popup>
  134. <!-- 04.02 服务标签 -->
  135. <view class="bg-main padding-lr padding-top padding-bottom-xs pos-r" @click="tagShow = true">
  136. <view class="dflex dflex-wrap-w">
  137. <view v-for="(item, index) in tagDatas" :key="index" class="margin-right-sm margin-bottom-sm dflex">
  138. <view class="iconfont iconyiwancheng- fwb fs-xs ft-base margin-right-xs"></view>
  139. <text class="fs-xs">{{ item.data.tagName }}</text>
  140. </view>
  141. </view>
  142. <!-- <view class="icon-detail pos-a"><view class="iconfont iconxiangqing ft-dark fs-sm"></view></view> -->
  143. </view>
  144. <view class="gap"></view>
  145. <!-- 04.02 服务标签弹出层 -->
  146. <use-popup mode="bottom" v-model="tagShow">
  147. <view class="tac w-full padding-sm">服务说明</view>
  148. <view class="padding-lr padding-bottom-sm">
  149. <view v-for="(item, index) in tagDatas" :key="index" class="margin-right-sm margin-bottom-sm dflex dflex-s">
  150. <view class="iconfont iconyiwancheng- fwb fs ft-base margin-right-xs"></view>
  151. <view>
  152. <view class="fs-sm">{{ item.data.tagName }}</view>
  153. <view class="fs-xs">{{ item.data.tagDesc }}</view>
  154. </view>
  155. </view>
  156. </view>
  157. </use-popup>
  158. <!-- 05. 评价区 -->
  159. <view class="evaluate-area" v-if="evaluateDatas.length > 0">
  160. <use-list-title :title="evaluateTitle" tip="好评率 100%" color="#ff6a6c" iconfont=" " @goto="toevaluate"></use-list-title>
  161. <view class="padding-lr bg-main">
  162. <view class="eva-box dflex-s padding-bottom-lg" v-for="(item, index) in evaluateDatas" :key="index">
  163. <image class="portrait border-radius-c" :src="item.member_headimg"></image>
  164. <view class="right-area flex1 padding-left-sm">
  165. <view class="dflex-b ft-dark">
  166. <view class="dflex">
  167. <text class="name margin-right">{{ item.member_name }}</text>
  168. <use-rate :value="item.reviewCnt" disabled></use-rate>
  169. </view>
  170. <text class="time fs-xs">{{ $api.format(item.createTime, 'yyyy-MM-dd') }}</text>
  171. </view>
  172. <view class="fs-sm ft-main padding-top-xs padding-bottom-sm">{{ item.reviewContent }}</view>
  173. <view class="dflex dflex-wrap-w">
  174. <image
  175. class=""
  176. mode="widthFix"
  177. v-for="(img, i) in item.reviewImgs"
  178. :lazy-load="true"
  179. :key="i"
  180. :src="img"
  181. @click="preview(item.reviewImgs, img)"
  182. ></image>
  183. <!-- <image class="border-radius-xs" v-if="((item.imgs).indexOf(',')) != -1"
  184. mode="aspectFill" :lazy-load="true" :src="((item.imgs).substring(0, ((item.imgs).indexOf(','))))"></image>
  185. <image class="border-radius-xs" v-else
  186. mode="aspectFill" :lazy-load="true" :src="item.imgs"></image> -->
  187. </view>
  188. <view class="">
  189. <text class="fs-xs ft-dark">{{ item.goods_type || '套餐1' }}</text>
  190. </view>
  191. </view>
  192. </view>
  193. </view>
  194. <view class="gap"></view>
  195. </view>
  196. <!-- 06. 详情区 -->
  197. <view class="detail-area bg-main">
  198. <view class="d-header padding dflex-c"><text>图文详情</text></view>
  199. <rich-text class="pro-detail" :nodes="goods.desc"></rich-text>
  200. </view>
  201. <!-- 07. 操作区 -->
  202. <view class="oper-area pos-f dflex-b w-full padding-lr-sm">
  203. <view class="btn-area dflex dflex-flow-c" @click="tohome">
  204. <text class="iconfont iconshouye-1"></text>
  205. <text>首页</text>
  206. </view>
  207. <!-- #ifndef MP-ALIPAY || H5 || MP-360 -->
  208. <button class="btn no-border dflex" open-type="contact">
  209. <view class="btn-area dflex-c dflex-flow-c">
  210. <text class="iconfont iconkefu-01"></text>
  211. <text>客服</text>
  212. </view>
  213. </button>
  214. <!-- #endif -->
  215. <view class="btn-area dflex dflex-flow-c" :class="{ active: favorite }" @click="tofavorite">
  216. <text class="iconfont" :class="favorite ? 'iconshoucang-' : 'iconshoucang-01'"></text>
  217. <text>收藏</text>
  218. </view>
  219. <view class="flex1 btn-container dflex-b border-radius-big">
  220. <view class="tac padding-tb-sm flex1 bg-warn" v-if="goods.stockNum > goods.saleCnt && goods.state == 1" @click="tocart(goods)">加入购物车</view>
  221. <view class="tac padding-tb-sm flex1 bg-base-gou" v-if="goods.stockNum > goods.saleCnt && goods.state == 1" @click="tobuy(goods)">立即购买</view>
  222. <view class="tac padding-tb-sm flex1 bg-disabled" v-if="goods.stockNum == goods.saleCnt && goods.state == 1">已售磐</view>
  223. <view class="tac padding-tb-sm flex1 bg-disabled" v-if="goods.state == 0">已下架</view>
  224. </view>
  225. </view>
  226. <!-- #ifdef MP-ALIPAY -->
  227. <view class="fixed-top dflex-c dflex-flow-c"><contact-button tnt-inst-id="0Xu_1aaW" scene="SCE00225456" size="50" color="#bbb" /></view>
  228. <!-- #endif -->
  229. <!-- 置顶 -->
  230. <use-totop ref="usetop" bottom="120"></use-totop>
  231. <!-- 点击加入购物车弹窗区域 -->
  232. <uv-popup ref="addPopup" bgColor="none" :safeAreaInsetBottom="false">
  233. <view class="body_pop">
  234. <!-- 关闭图标区域 -->
  235. <img class="pop_icon" src="../../../static/index/close3.png" @click="handleClosePop" />
  236. <!-- 顶部信息区域 -->
  237. <view class="pop_header">
  238. <img
  239. class="header_img"
  240. mode="aspectFill"
  241. src="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-7e00db99-ad65-4b9f-a74b-61bccb92b124/96f1dd40-2075-4f6f-988c-14c2753d9fb2.jpg"
  242. />
  243. <view class="header_info">
  244. <view class="info_price">
  245. <text>8600</text>
  246. </view>
  247. <view class="info_tags">
  248. <view class="tag">包邮</view>
  249. <view class="tag">8600积分</view>
  250. </view>
  251. </view>
  252. </view>
  253. <!-- 颜色区域 -->
  254. <view class="pop_title">颜色(3)</view>
  255. <view class="pop_tags">
  256. <view class="tag">白沙银</view>
  257. <view class="tag">白沙银</view>
  258. <view class="tag">白沙银</view>
  259. </view>
  260. <!-- 容量区域 -->
  261. <view class="pop_title">容量(3)</view>
  262. <view class="pop_tags">
  263. <view class="tag">256G+512G</view>
  264. <view class="tag">256G</view>
  265. <view class="tag">256G</view>
  266. </view>
  267. <!-- 购买数量区域 -->
  268. <view class="pop_title">
  269. 购买数量
  270. <text>库存10件</text>
  271. </view>
  272. <view class="pop_num">
  273. <uni-number-box @change="changeValue" />
  274. </view>
  275. </view>
  276. </uv-popup>
  277. </view>
  278. </template>
  279. <script>
  280. // #ifdef MP-ALIPAY
  281. import aliParse from 'mini-html-parser2'
  282. // #endif
  283. import { collectif, footgoods, goodsxiang, collecttian, cartadd, pingjia } from '../../utils/api_goods.js'
  284. import usePopup from '../../components/use-popup/use-popup.vue'
  285. import useListTitle from '../../components/use-list-title/use-list-title.vue'
  286. import useRate from '../../components/use-rate/use-rate.vue'
  287. import usetotop from '../../components/use-totop/use-totop.vue'
  288. import lPainter from '@/packageShang/uni_modules/lime-painter/components/lime-painter/'
  289. import uposter from '@/packageShang/common/poster.js'
  290. import { mapState } from 'vuex'
  291. export default {
  292. components: {
  293. lPainter,
  294. useListTitle,
  295. useRate,
  296. usePopup,
  297. usetotop
  298. },
  299. computed: {
  300. ...mapState(['islogin', 'member'])
  301. },
  302. data() {
  303. return {
  304. // 商品ID
  305. id: 0,
  306. // 分享ID
  307. mid: 0,
  308. // 商品数据
  309. goods: {},
  310. // 轮播图
  311. swiperDatas: [],
  312. // SKU
  313. sku: {},
  314. skuDatas: [],
  315. // 分享
  316. shareShow: false,
  317. // 海报
  318. posterQRcode: '',
  319. posterUrl: '',
  320. posterShow: false,
  321. posterData: {},
  322. //优惠券
  323. couponShow: false,
  324. couponDatas: [],
  325. // 服务标签
  326. tagShow: false,
  327. tagDatas: [],
  328. // 商品评价
  329. evaluateDatas: [],
  330. evaluateTitle: '评价',
  331. // 商品详情
  332. html_nodes: '',
  333. // 收藏
  334. favorite: false, //是否收藏
  335. scrollTop: 0
  336. }
  337. },
  338. watch: {
  339. sku(e) {
  340. this.goods.price = e.price
  341. this.goods.marketPrice = e.market_price
  342. this.goods.stockNum = e.num
  343. }
  344. },
  345. onShareAppMessage: function (ops) {
  346. let _this = this
  347. let mid = 0
  348. if (_this.member && _this.member._id) {
  349. mid = _this.member._id
  350. }
  351. return {
  352. title: _this.goods.share_title,
  353. path: `/pages/goods/goods?id=${this.id}&mid=${mid}`, //这里设定都是以"/page"开头,并拼接好传递的参数
  354. success: function (res) {
  355. // 转发成功
  356. console.log('转发成功', res)
  357. },
  358. fail: function (res) {
  359. // 转发失败
  360. console.log('转发失败', res)
  361. }
  362. }
  363. },
  364. onPageScroll(e) {
  365. //this.scrollTop = e.scrollTop;
  366. this.$refs.usetop.change(e.scrollTop)
  367. },
  368. onLoad(options) {
  369. if (options) {
  370. this.mid = options.mid || ''
  371. if (options.id) {
  372. this.id = options.id
  373. } else if (options.q) {
  374. let query = decodeURIComponent(options.q) || decodeURIComponent(uni.getStorageInfoSync('__scene_query_q'))
  375. this.resolveQueryq(query)
  376. }
  377. }
  378. if (!this.id) {
  379. this.$api.msg('商品ID无效')
  380. return
  381. }
  382. },
  383. onShow(options) {
  384. if (!this.id) {
  385. const query = decodeURIComponent(uni.getStorageInfoSync('__scene_query_q'))
  386. this.resolveQueryq(query)
  387. }
  388. var _self = this
  389. var header = {
  390. 'Mall-Token': uni.getStorageSync('tokenId')
  391. }
  392. //是否收藏
  393. var data = _self.id
  394. collectif(data, header).then((res) => {
  395. if (res.data) {
  396. _self.favorite = true
  397. } else {
  398. _self.favorite = false
  399. }
  400. _self.loadData()
  401. })
  402. //商品足迹
  403. footgoods(data, header).then((res) => {
  404. if (res.success) {
  405. }
  406. })
  407. },
  408. methods: {
  409. loadData() {
  410. let _self = this
  411. var data = _self.id
  412. _self.swiperDatas = []
  413. goodsxiang(data).then((res) => {
  414. if (res.success) {
  415. _self.swiperDatas = res.data.imgs.split(',')
  416. _self.goods = res.data
  417. // 服务标签
  418. if (typeof _self.goods.goodsServiceTags === 'string') {
  419. _self.goods.goodsServiceTags = _self.goods.goodsServiceTags.split(',').filter((x) => x)
  420. }
  421. let __tagDatas = []
  422. _self.goods.goodsServiceTags.forEach((data, index) => {
  423. __tagDatas.push({
  424. data: data,
  425. selected: index == 0
  426. })
  427. })
  428. _self.tagDatas = __tagDatas
  429. }
  430. })
  431. //商品评价
  432. var data = '?goodsId=' + _self.id
  433. pingjia(data).then((res) => {
  434. console.log('评价', res)
  435. if (res.success) {
  436. // 商品评价
  437. _self.evaluateDatas = res.data.list
  438. if (res.data.evaluate_cnt) _self.evaluateTitle = `评价(${res.data.evaluate_cnt})`
  439. // if (typeof res.data.goods.imgs === 'string') {
  440. // _self.swiperDatas = res.data.goods.imgs.split(',').filter(x => x);
  441. // } else {
  442. // _self.swiperDatas = res.data.goods.imgs;
  443. // }
  444. }
  445. })
  446. // await this.$func.usemall
  447. // .call('goods/detail', {
  448. // goods_id: this.id,
  449. // share_mid: this.mid
  450. // })
  451. // .then(res => {
  452. // if (res.code === 200) {
  453. // // 商品评价
  454. // this.evaluateDatas = res.datas.evaluate;
  455. // if (res.datas.evaluate_cnt) this.evaluateTitle = `评价(${res.datas.evaluate_cnt})`;
  456. // if (typeof res.datas.goods.imgs === 'string') {
  457. // this.swiperDatas = res.datas.goods.imgs.split(',').filter(x => x);
  458. // } else {
  459. // this.swiperDatas = res.datas.goods.imgs;
  460. // }
  461. // this.goods = res.datas.goods;
  462. // // 商品详情
  463. // let __goods_detail = res.datas.goods_detail;
  464. // // #ifndef MP-ALIPAY
  465. // this.html_nodes = __goods_detail.desc_mobile;
  466. // // #endif
  467. // // #ifdef MP-ALIPAY
  468. // this.html_nodes = [];
  469. // aliParse(__goods_detail.desc_mobile.replace(/"><*/gi, '"/><'), (err, nodes) => {
  470. // if (!err) {
  471. // this.html_nodes = nodes;
  472. // }
  473. // });
  474. // // #endif
  475. // // 商品SKU
  476. // let __goods_skus = res.datas.goods_skus;
  477. // if (__goods_skus.length > 0) {
  478. // let __skuDatas = [];
  479. // __goods_skus.forEach((sku, index) => {
  480. // // { id: 1, name: '45寸(大规格)', price: 788, market_price: 999, num: 0, selected: !0 },
  481. // __skuDatas.push({
  482. // id: sku._id,
  483. // sku: sku.goods_sku,
  484. // name: sku.spec,
  485. // price: sku.price,
  486. // market_price: sku.market_price || this.goods.market_price,
  487. // num: sku.stock_num,
  488. // selected: index == 0
  489. // });
  490. // });
  491. // this.skuDatas = __skuDatas;
  492. // }
  493. // // SKU
  494. // if (this.skuDatas.length > 0) {
  495. // this.sku = this.skuDatas[0];
  496. // }
  497. // // 服务标签
  498. // if (typeof this.goods.tags === 'string') {
  499. // this.goods.tags = this.goods.tags.split(',').filter(x => x);
  500. // }
  501. // let __tagDatas = [];
  502. // this.goods.tags.forEach((data, index) => {
  503. // __tagDatas.push({
  504. // name: data,
  505. // selected: index == 0
  506. // });
  507. // });
  508. // this.tagDatas = __tagDatas;
  509. // // 收藏状态
  510. // this.favorite = this.goods.collected === 1;
  511. // return;
  512. // }
  513. // this.$api.msg(res.msg);
  514. // });
  515. },
  516. // 处理 query q 数据
  517. resolveQueryq(query) {
  518. const arr = query.split('/').slice(-1)[0].split('_')
  519. if (arr.length == 2) this.mid = arr[1]
  520. this.id = arr[0]
  521. },
  522. // 图片预览
  523. preview(imgs, cur) {
  524. if (!imgs) return
  525. uni.previewImage({
  526. urls: imgs,
  527. current: cur,
  528. longPressActions: {
  529. itemList: ['发送给朋友', '保存图片', '收藏'],
  530. success: function (data) {
  531. console.log(res)
  532. },
  533. fail: function (err) {
  534. console.log(err)
  535. }
  536. }
  537. })
  538. },
  539. // 打开分享
  540. shareOpen() {
  541. // if (!this.loginCheck()) return;
  542. this.shareShow = true
  543. },
  544. // 关闭分享
  545. shareClose() {
  546. // if (!this.loginCheck()) return;
  547. this.shareShow = false
  548. },
  549. // 创建海报
  550. createPoster() {
  551. if (this.posterUrl) {
  552. this.posterShow = true
  553. return
  554. }
  555. uni.showLoading({
  556. title: '生成海报中'
  557. })
  558. // #ifdef MP
  559. // 此处的二维码内容,需自己在小程序端配置普通二维码规则
  560. this.posterQRcode = `https://usemall.use-cloud.com/wxmp-product/${this.goods.id}_${this.member._id}`
  561. // #endif
  562. // #ifdef H5
  563. // 如果为 h5,二维码内容需配置为线上版本产品详情路径
  564. this.posterQRcode = `https://usemall-h5.use-cloud.com/#/pages/goods/goods?id=${this.goods.id}&mid=${this.member._id}`
  565. // #endif
  566. },
  567. // 海报二维码生成成功
  568. posterQRcodeResult(res) {
  569. // 获取产品海报数据
  570. this.posterData = uposter.getGoodsData(this.member, this.goods, res)
  571. // console.log('this.posterData', this.posterData);
  572. this.posterShow = true
  573. },
  574. // 海报生成完成
  575. posterSuccess(res) {
  576. this.posterUrl = res
  577. uni.hideLoading()
  578. },
  579. // 保存海报
  580. posterSave() {
  581. if (this.posterUrl) {
  582. uni.showLoading({
  583. title: '保存中'
  584. })
  585. uni.saveImageToPhotosAlbum({
  586. filePath: this.posterUrl,
  587. success: function () {
  588. uni.hideLoading()
  589. uni.showToast({
  590. title: '海报保存成功',
  591. icon: 'success',
  592. duration: 2000
  593. })
  594. }
  595. })
  596. }
  597. },
  598. // 商品SKU
  599. selectSKU(res) {
  600. this.skuDatas.forEach((item) => {
  601. if (res.sku == item.sku) {
  602. this.$set(item, 'selected', true)
  603. } else {
  604. this.$set(item, 'selected', false)
  605. }
  606. })
  607. this.sku = res
  608. },
  609. // 评论
  610. toevaluate() {
  611. uni.navigateTo({
  612. url: `/pages/goods/goods-evaluate?id=${this.id}`
  613. })
  614. },
  615. // 首页
  616. tohome() {
  617. this.$api.tohome()
  618. },
  619. // 收藏
  620. tofavorite() {
  621. // if (!this.loginCheck()) return;
  622. this.favorite = !this.favorite
  623. let _data = {
  624. goods_id: this.id,
  625. state: !this.favorite ? '已取消' : '已收藏'
  626. }
  627. var header = {
  628. 'Mall-Token': uni.getStorageSync('tokenId')
  629. }
  630. var data = this.id
  631. collecttian(data, header).then((res) => {
  632. if (res.success) {
  633. !this.favorite ? this.$api.msg('取消成功') : this.$api.msg('收藏成功')
  634. return
  635. }
  636. this.$api.msg(res.msg)
  637. })
  638. },
  639. // 加入购物车
  640. tocart(params) {
  641. // var _self=this
  642. // var data='?num=1&'+'goodId='+params.id
  643. // cartadd(data).then((res) => {
  644. // if(res.success){
  645. // _self.$api.msg('加购成功');
  646. // return;
  647. // }
  648. // _self.$api.msg(res.msg);
  649. // })
  650. // this.$func.usemall
  651. // .call('goods/addcart', {
  652. // goods_id: params._id,
  653. // goods_num: 1,
  654. // goods_sku: this.sku.id
  655. // })
  656. // .then(res => {
  657. // if (res.code === 200) {
  658. // this.$api.msg(res.datas.msg);
  659. // return;
  660. // }
  661. // this.$api.msg(res.msg);
  662. // });
  663. this.$refs.addPopup.open('bottom')
  664. },
  665. // 立即购买
  666. tobuy(item) {
  667. let _this = this
  668. // if (!this.loginCheck()) return;
  669. uni.navigateTo({
  670. url: `/packageShang/pages/order/create?goods_id=${this.id}&sku_id=${this.sku.id || ''}&type=1`
  671. })
  672. },
  673. // 点击弹窗关闭图标回调
  674. handleClosePop() {
  675. this.$refs.addPopup.close()
  676. },
  677. changeValue(value) {
  678. console.log('返回数值:', value)
  679. }
  680. // 检测是否已登录
  681. // loginCheck() {
  682. // if (!this.islogin) {
  683. // let _this = this;
  684. // uni.showModal({
  685. // title: '授权登录',
  686. // success: function(res) {
  687. // if (res.confirm) {
  688. // _this.$api.tologin();
  689. // }
  690. // }
  691. // });
  692. // return false;
  693. // }
  694. // return true;
  695. // }
  696. }
  697. }
  698. </script>
  699. <style lang="scss">
  700. @import url('/packageShang/components/iconfont/iconfont.css');
  701. @import url('/packageShang/common/common.scss');
  702. page {
  703. background: $page-color-base;
  704. padding-bottom: 120rpx;
  705. }
  706. contact-button {
  707. display: flex;
  708. justify-content: center;
  709. align-items: center;
  710. width: 50px;
  711. height: 50px;
  712. }
  713. .fixed-top {
  714. bottom: 230rpx;
  715. }
  716. /* 01. 轮播区 */
  717. .swiper-area {
  718. height: 720rpx;
  719. top: 0;
  720. z-index: -1;
  721. }
  722. /* #ifndef MP */
  723. .swiper-area {
  724. margin-top: calc(44px + env(safe-area-inset-top));
  725. margin-top: 44px;
  726. }
  727. /* #endif */
  728. /* #ifdef APP-PLUS */
  729. .swiper-area {
  730. margin-top: 0;
  731. }
  732. /* #endif */
  733. /* 02. 商品数据区 */
  734. .goods-area {
  735. margin-top: 720rpx;
  736. .price-box {
  737. display: flex;
  738. align-items: baseline;
  739. }
  740. .title1 {
  741. height: 46rpx;
  742. line-height: 46rpx;
  743. }
  744. .title {
  745. color: $font-color-dark;
  746. height: 46rpx;
  747. line-height: 46rpx;
  748. }
  749. }
  750. .share-area {
  751. .vertical-line {
  752. right: 50%;
  753. height: 40%;
  754. }
  755. }
  756. /* 03. 规格区 */
  757. .sku-area .active {
  758. background: $base-color;
  759. color: #fff !important;
  760. }
  761. /* 04. 服务区 */
  762. .icon-detail {
  763. right: 30rpx;
  764. top: 24rpx;
  765. }
  766. /* 05. 评价 */
  767. .evaluate-area {
  768. .portrait {
  769. flex-shrink: 0;
  770. width: 80rpx;
  771. height: 80rpx;
  772. }
  773. .right-area {
  774. image {
  775. margin-right: 10rpx;
  776. margin-bottom: 10rpx;
  777. height: 200rpx;
  778. width: 30%;
  779. }
  780. }
  781. }
  782. /* 06. 详情区 */
  783. .detail-area {
  784. .d-header {
  785. font-size: $font-base + 2upx;
  786. position: relative;
  787. text {
  788. padding: 0 20rpx;
  789. background: #fff;
  790. position: relative;
  791. z-index: 1;
  792. }
  793. &:after {
  794. position: absolute;
  795. left: 50%;
  796. top: 50%;
  797. transform: translateX(-50%);
  798. width: 300rpx;
  799. height: 0;
  800. content: '';
  801. border-bottom: 1px solid #ccc;
  802. }
  803. }
  804. /* 产品详情 */
  805. .pro-detail {
  806. width: 100%;
  807. overflow: hidden;
  808. -webkit-touch-callout: none;
  809. img {
  810. width: 100%;
  811. max-width: 100%;
  812. overflow: hidden;
  813. }
  814. }
  815. }
  816. /* 07. 操作区 */
  817. .oper-area {
  818. left: 0;
  819. bottom: 0;
  820. background: rgba(255, 255, 255, 0.95);
  821. box-shadow: 0 0 20rpx 0 #f0f0f0;
  822. height: 100rpx;
  823. z-index: 95;
  824. .btn-area {
  825. font-size: $font-sm;
  826. color: $font-color-base;
  827. width: 96rpx;
  828. .iconfont {
  829. font-size: 40rpx;
  830. line-height: 48rpx;
  831. }
  832. }
  833. }
  834. /* 优惠券区 */
  835. .coupon-area {
  836. max-height: 60vh;
  837. min-height: 30vh;
  838. .coupon-item {
  839. margin-bottom: 20rpx;
  840. &:last-child {
  841. margin-bottom: 0;
  842. }
  843. .content {
  844. &:after {
  845. position: absolute;
  846. left: 0;
  847. bottom: 0;
  848. content: '';
  849. width: 100%;
  850. height: 0;
  851. border-bottom: 1px dashed #f3f3f3;
  852. transform: scaleY(50%);
  853. }
  854. }
  855. .circle {
  856. position: absolute;
  857. bottom: -10rpx;
  858. z-index: 10;
  859. width: 20rpx;
  860. height: 20rpx;
  861. background: #f5f5f5;
  862. border-radius: 50%;
  863. &.r {
  864. right: -6rpx;
  865. }
  866. &.l {
  867. left: -6rpx;
  868. }
  869. }
  870. }
  871. }
  872. // 加入购物车弹窗样式
  873. .body_pop {
  874. position: relative;
  875. padding: 0 20rpx;
  876. height: 955rpx;
  877. border-radius: 22rpx 22rpx 0 0;
  878. background-color: #fff;
  879. overflow-y: auto;
  880. .pop_icon {
  881. position: absolute;
  882. top: 20rpx;
  883. right: 30rpx;
  884. width: 58rpx;
  885. height: 58rpx;
  886. }
  887. .pop_header {
  888. display: flex;
  889. margin-top: 30rpx;
  890. .header_img {
  891. width: 200rpx;
  892. height: 200rpx;
  893. }
  894. .header_info {
  895. flex: 1;
  896. padding-left: 20rpx;
  897. display: flex;
  898. flex-direction: column;
  899. justify-content: space-around;
  900. width: 100%;
  901. height: 200rpx;
  902. color: #ea6d67;
  903. font-size: 30rpx;
  904. .info_price {
  905. flex: 1;
  906. display: flex;
  907. align-items: center;
  908. text {
  909. font-size: 60rpx;
  910. }
  911. }
  912. .info_tags {
  913. flex: 1;
  914. display: flex;
  915. align-items: center;
  916. .tag {
  917. padding: 5rpx;
  918. margin-right: 10rpx;
  919. border-radius: 10rpx;
  920. border: 1rpx solid #ea6d67;
  921. }
  922. }
  923. }
  924. }
  925. .pop_title {
  926. margin: 10rpx 0;
  927. font-size: 40rpx;
  928. text {
  929. margin-left: 15rpx;
  930. color: #ccc;
  931. }
  932. }
  933. .pop_tags {
  934. display: flex;
  935. .tag {
  936. padding: 20rpx 30rpx;
  937. margin-right: 20rpx;
  938. font-size: 30rpx;
  939. border-radius: 40rpx;
  940. background-color: #f6f6f6;
  941. }
  942. }
  943. .pop_num {
  944. margin-top: 15rpx;
  945. }
  946. }
  947. </style>