goods.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913
  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. </view>
  232. </template>
  233. <script>
  234. // #ifdef MP-ALIPAY
  235. import aliParse from 'mini-html-parser2';
  236. // #endif
  237. import {
  238. collectif,
  239. footgoods,
  240. goodsxiang,
  241. collecttian,
  242. cartadd,
  243. pingjia
  244. } from '../../utils/api_goods.js'
  245. import usePopup from '../../components/use-popup/use-popup.vue'
  246. import useListTitle from '../../components/use-list-title/use-list-title.vue'
  247. import useRate from '../../components/use-rate/use-rate.vue'
  248. import usetotop from '../../components/use-totop/use-totop.vue'
  249. import lPainter from '@/packageShang/uni_modules/lime-painter/components/lime-painter/';
  250. import uposter from '@/packageShang/common/poster.js';
  251. import { mapState } from 'vuex';
  252. export default {
  253. components:{
  254. lPainter,
  255. useListTitle,
  256. useRate,
  257. usePopup,
  258. usetotop
  259. },
  260. computed: {
  261. ...mapState(['islogin', 'member'])
  262. },
  263. data() {
  264. return {
  265. // 商品ID
  266. id: 0,
  267. // 分享ID
  268. mid: 0,
  269. // 商品数据
  270. goods: {},
  271. // 轮播图
  272. swiperDatas: [],
  273. // SKU
  274. sku: {},
  275. skuDatas: [],
  276. // 分享
  277. shareShow: false,
  278. // 海报
  279. posterQRcode: '',
  280. posterUrl: '',
  281. posterShow: false,
  282. posterData: {},
  283. //优惠券
  284. couponShow: false,
  285. couponDatas: [],
  286. // 服务标签
  287. tagShow: false,
  288. tagDatas: [],
  289. // 商品评价
  290. evaluateDatas: [],
  291. evaluateTitle: '评价',
  292. // 商品详情
  293. html_nodes: '',
  294. // 收藏
  295. favorite: false,//是否收藏
  296. scrollTop: 0
  297. };
  298. },
  299. watch: {
  300. sku(e) {
  301. this.goods.price = e.price;
  302. this.goods.marketPrice = e.market_price;
  303. this.goods.stockNum = e.num;
  304. }
  305. },
  306. onShareAppMessage: function(ops) {
  307. let _this = this;
  308. let mid = 0;
  309. if (_this.member && _this.member._id) {
  310. mid = _this.member._id;
  311. }
  312. return {
  313. title: _this.goods.share_title,
  314. path: `/pages/goods/goods?id=${this.id}&mid=${mid}`, //这里设定都是以"/page"开头,并拼接好传递的参数
  315. success: function(res) {
  316. // 转发成功
  317. console.log('转发成功', res);
  318. },
  319. fail: function(res) {
  320. // 转发失败
  321. console.log('转发失败', res);
  322. }
  323. };
  324. },
  325. onPageScroll(e) {
  326. //this.scrollTop = e.scrollTop;
  327. this.$refs.usetop.change(e.scrollTop);
  328. },
  329. onLoad(options) {
  330. if (options) {
  331. this.mid = options.mid || '';
  332. if (options.id) {
  333. this.id = options.id;
  334. } else if (options.q) {
  335. let query = decodeURIComponent(options.q) || decodeURIComponent(uni.getStorageInfoSync('__scene_query_q'));
  336. this.resolveQueryq(query);
  337. }
  338. }
  339. if (!this.id) {
  340. this.$api.msg('商品ID无效');
  341. return;
  342. }
  343. },
  344. onShow(options) {
  345. if (!this.id) {
  346. const query = decodeURIComponent(uni.getStorageInfoSync('__scene_query_q'));
  347. this.resolveQueryq(query);
  348. }
  349. var _self=this
  350. var header={
  351. "Mall-Token": uni.getStorageSync('tokenId')
  352. }
  353. //是否收藏
  354. var data=_self.id
  355. collectif(data,header).then((res) => {
  356. if(res.data){
  357. _self.favorite=true
  358. }else{
  359. _self.favorite=false
  360. }
  361. _self.loadData();
  362. })
  363. //商品足迹
  364. footgoods(data,header).then((res) => {
  365. if(res.success){
  366. }
  367. })
  368. },
  369. methods: {
  370. loadData() {
  371. let _self = this;
  372. var data=_self.id
  373. _self.swiperDatas = []
  374. goodsxiang(data).then((res) => {
  375. if(res.success){
  376. _self.swiperDatas=(res.data.imgs).split(",")
  377. _self.goods = res.data;
  378. // 服务标签
  379. if (typeof _self.goods.goodsServiceTags === 'string') {
  380. _self.goods.goodsServiceTags = _self.goods.goodsServiceTags.split(',').filter(x => x);
  381. }
  382. let __tagDatas = [];
  383. _self.goods.goodsServiceTags.forEach((data, index) => {
  384. __tagDatas.push({
  385. data: data,
  386. selected: index == 0
  387. });
  388. });
  389. _self.tagDatas = __tagDatas;
  390. }
  391. })
  392. //商品评价
  393. var data='?goodsId='+_self.id
  394. pingjia(data).then((res) => {
  395. console.log('评价',res)
  396. if(res.success){
  397. // 商品评价
  398. _self.evaluateDatas = res.data.list;
  399. if (res.data.evaluate_cnt) _self.evaluateTitle = `评价(${res.data.evaluate_cnt})`;
  400. // if (typeof res.data.goods.imgs === 'string') {
  401. // _self.swiperDatas = res.data.goods.imgs.split(',').filter(x => x);
  402. // } else {
  403. // _self.swiperDatas = res.data.goods.imgs;
  404. // }
  405. }
  406. })
  407. // await this.$func.usemall
  408. // .call('goods/detail', {
  409. // goods_id: this.id,
  410. // share_mid: this.mid
  411. // })
  412. // .then(res => {
  413. // if (res.code === 200) {
  414. // // 商品评价
  415. // this.evaluateDatas = res.datas.evaluate;
  416. // if (res.datas.evaluate_cnt) this.evaluateTitle = `评价(${res.datas.evaluate_cnt})`;
  417. // if (typeof res.datas.goods.imgs === 'string') {
  418. // this.swiperDatas = res.datas.goods.imgs.split(',').filter(x => x);
  419. // } else {
  420. // this.swiperDatas = res.datas.goods.imgs;
  421. // }
  422. // this.goods = res.datas.goods;
  423. // // 商品详情
  424. // let __goods_detail = res.datas.goods_detail;
  425. // // #ifndef MP-ALIPAY
  426. // this.html_nodes = __goods_detail.desc_mobile;
  427. // // #endif
  428. // // #ifdef MP-ALIPAY
  429. // this.html_nodes = [];
  430. // aliParse(__goods_detail.desc_mobile.replace(/"><*/gi, '"/><'), (err, nodes) => {
  431. // if (!err) {
  432. // this.html_nodes = nodes;
  433. // }
  434. // });
  435. // // #endif
  436. // // 商品SKU
  437. // let __goods_skus = res.datas.goods_skus;
  438. // if (__goods_skus.length > 0) {
  439. // let __skuDatas = [];
  440. // __goods_skus.forEach((sku, index) => {
  441. // // { id: 1, name: '45寸(大规格)', price: 788, market_price: 999, num: 0, selected: !0 },
  442. // __skuDatas.push({
  443. // id: sku._id,
  444. // sku: sku.goods_sku,
  445. // name: sku.spec,
  446. // price: sku.price,
  447. // market_price: sku.market_price || this.goods.market_price,
  448. // num: sku.stock_num,
  449. // selected: index == 0
  450. // });
  451. // });
  452. // this.skuDatas = __skuDatas;
  453. // }
  454. // // SKU
  455. // if (this.skuDatas.length > 0) {
  456. // this.sku = this.skuDatas[0];
  457. // }
  458. // // 服务标签
  459. // if (typeof this.goods.tags === 'string') {
  460. // this.goods.tags = this.goods.tags.split(',').filter(x => x);
  461. // }
  462. // let __tagDatas = [];
  463. // this.goods.tags.forEach((data, index) => {
  464. // __tagDatas.push({
  465. // name: data,
  466. // selected: index == 0
  467. // });
  468. // });
  469. // this.tagDatas = __tagDatas;
  470. // // 收藏状态
  471. // this.favorite = this.goods.collected === 1;
  472. // return;
  473. // }
  474. // this.$api.msg(res.msg);
  475. // });
  476. },
  477. // 处理 query q 数据
  478. resolveQueryq(query) {
  479. const arr = query
  480. .split('/')
  481. .slice(-1)[0]
  482. .split('_');
  483. if (arr.length == 2) this.mid = arr[1];
  484. this.id = arr[0];
  485. },
  486. // 图片预览
  487. preview(imgs, cur) {
  488. if (!imgs) return;
  489. uni.previewImage({
  490. urls: imgs,
  491. current: cur,
  492. longPressActions: {
  493. itemList: ['发送给朋友', '保存图片', '收藏'],
  494. success: function(data) {
  495. console.log(res);
  496. },
  497. fail: function(err) {
  498. console.log(err);
  499. }
  500. }
  501. });
  502. },
  503. // 打开分享
  504. shareOpen() {
  505. // if (!this.loginCheck()) return;
  506. this.shareShow = true
  507. },
  508. // 关闭分享
  509. shareClose() {
  510. // if (!this.loginCheck()) return;
  511. this.shareShow = false
  512. },
  513. // 创建海报
  514. createPoster() {
  515. if (this.posterUrl) {
  516. this.posterShow = true;
  517. return;
  518. }
  519. uni.showLoading({
  520. title: '生成海报中'
  521. });
  522. // #ifdef MP
  523. // 此处的二维码内容,需自己在小程序端配置普通二维码规则
  524. this.posterQRcode = `https://usemall.use-cloud.com/wxmp-product/${this.goods.id}_${this.member._id}`;
  525. // #endif
  526. // #ifdef H5
  527. // 如果为 h5,二维码内容需配置为线上版本产品详情路径
  528. this.posterQRcode = `https://usemall-h5.use-cloud.com/#/pages/goods/goods?id=${this.goods.id}&mid=${this.member._id}`;
  529. // #endif
  530. },
  531. // 海报二维码生成成功
  532. posterQRcodeResult(res) {
  533. // 获取产品海报数据
  534. this.posterData = uposter.getGoodsData(this.member, this.goods, res);
  535. // console.log('this.posterData', this.posterData);
  536. this.posterShow = true;
  537. },
  538. // 海报生成完成
  539. posterSuccess(res) {
  540. this.posterUrl = res;
  541. uni.hideLoading();
  542. },
  543. // 保存海报
  544. posterSave() {
  545. if (this.posterUrl) {
  546. uni.showLoading({
  547. title: '保存中'
  548. })
  549. uni.saveImageToPhotosAlbum({
  550. filePath: this.posterUrl,
  551. success: function() {
  552. uni.hideLoading();
  553. uni.showToast({
  554. title: '海报保存成功',
  555. icon: 'success',
  556. duration: 2000
  557. });
  558. }
  559. });
  560. }
  561. },
  562. // 商品SKU
  563. selectSKU(res) {
  564. this.skuDatas.forEach(item => {
  565. if (res.sku == item.sku) {
  566. this.$set(item, 'selected', true);
  567. } else {
  568. this.$set(item, 'selected', false);
  569. }
  570. });
  571. this.sku = res;
  572. },
  573. // 评论
  574. toevaluate() {
  575. uni.navigateTo({
  576. url: `/pages/goods/goods-evaluate?id=${this.id}`
  577. });
  578. },
  579. // 首页
  580. tohome() {
  581. this.$api.tohome();
  582. },
  583. // 收藏
  584. tofavorite() {
  585. // if (!this.loginCheck()) return;
  586. this.favorite = !this.favorite;
  587. let _data = {
  588. goods_id: this.id,
  589. state: !this.favorite ? '已取消' : '已收藏'
  590. };
  591. var header={
  592. "Mall-Token": uni.getStorageSync('tokenId')
  593. }
  594. var data=this.id
  595. collecttian(data,header).then((res) => {
  596. if(res.success){
  597. !this.favorite ? this.$api.msg('取消成功') : this.$api.msg('收藏成功');
  598. return;
  599. }
  600. this.$api.msg(res.msg);
  601. })
  602. },
  603. // 加入购物车
  604. tocart(params) {
  605. var _self=this
  606. var data='?num=1&'+'goodId='+params.id
  607. cartadd(data).then((res) => {
  608. if(res.success){
  609. _self.$api.msg('加购成功');
  610. return;
  611. }
  612. _self.$api.msg(res.msg);
  613. })
  614. // this.$func.usemall
  615. // .call('goods/addcart', {
  616. // goods_id: params._id,
  617. // goods_num: 1,
  618. // goods_sku: this.sku.id
  619. // })
  620. // .then(res => {
  621. // if (res.code === 200) {
  622. // this.$api.msg(res.datas.msg);
  623. // return;
  624. // }
  625. // this.$api.msg(res.msg);
  626. // });
  627. },
  628. // 立即购买
  629. tobuy(item) {
  630. let _this = this;
  631. // if (!this.loginCheck()) return;
  632. uni.navigateTo({
  633. url: `/packageShang/pages/order/create?goods_id=${this.id}&sku_id=${this.sku.id || ''}&type=1`
  634. });
  635. },
  636. // 检测是否已登录
  637. // loginCheck() {
  638. // if (!this.islogin) {
  639. // let _this = this;
  640. // uni.showModal({
  641. // title: '授权登录',
  642. // success: function(res) {
  643. // if (res.confirm) {
  644. // _this.$api.tologin();
  645. // }
  646. // }
  647. // });
  648. // return false;
  649. // }
  650. // return true;
  651. // }
  652. }
  653. };
  654. </script>
  655. <style lang="scss">
  656. @import url('/packageShang/components/iconfont/iconfont.css');
  657. @import url('/packageShang/common/common.scss');
  658. page {
  659. background: $page-color-base;
  660. padding-bottom: 120rpx;
  661. }
  662. contact-button {
  663. display: flex;
  664. justify-content: center;
  665. align-items: center;
  666. width: 50px;
  667. height: 50px;
  668. }
  669. .fixed-top {
  670. bottom: 230rpx;
  671. }
  672. /* 01. 轮播区 */
  673. .swiper-area {
  674. height: 720rpx;
  675. top: 0;
  676. z-index: -1;
  677. }
  678. /* #ifndef MP */
  679. .swiper-area {
  680. margin-top: calc(44px + env(safe-area-inset-top));
  681. margin-top: 44px;
  682. }
  683. /* #endif */
  684. /* #ifdef APP-PLUS */
  685. .swiper-area {
  686. margin-top: 0;
  687. }
  688. /* #endif */
  689. /* 02. 商品数据区 */
  690. .goods-area {
  691. margin-top: 720rpx;
  692. .price-box {
  693. display: flex;
  694. align-items: baseline;
  695. }
  696. .title1 {
  697. height: 46rpx;
  698. line-height: 46rpx;
  699. }
  700. .title {
  701. color: $font-color-dark;
  702. height: 46rpx;
  703. line-height: 46rpx;
  704. }
  705. }
  706. .share-area {
  707. .vertical-line {
  708. right: 50%;
  709. height: 40%;
  710. }
  711. }
  712. /* 03. 规格区 */
  713. .sku-area .active {
  714. background: $base-color;
  715. color: #fff !important;
  716. }
  717. /* 04. 服务区 */
  718. .icon-detail {
  719. right: 30rpx;
  720. top: 24rpx;
  721. }
  722. /* 05. 评价 */
  723. .evaluate-area {
  724. .portrait {
  725. flex-shrink: 0;
  726. width: 80rpx;
  727. height: 80rpx;
  728. }
  729. .right-area {
  730. image {
  731. margin-right: 10rpx;
  732. margin-bottom: 10rpx;
  733. height: 200rpx;
  734. width: 30%;
  735. }
  736. }
  737. }
  738. /* 06. 详情区 */
  739. .detail-area {
  740. .d-header {
  741. font-size: $font-base + 2upx;
  742. position: relative;
  743. text {
  744. padding: 0 20rpx;
  745. background: #fff;
  746. position: relative;
  747. z-index: 1;
  748. }
  749. &:after {
  750. position: absolute;
  751. left: 50%;
  752. top: 50%;
  753. transform: translateX(-50%);
  754. width: 300rpx;
  755. height: 0;
  756. content: '';
  757. border-bottom: 1px solid #ccc;
  758. }
  759. }
  760. /* 产品详情 */
  761. .pro-detail {
  762. width: 100%;
  763. overflow: hidden;
  764. -webkit-touch-callout: none;
  765. img {
  766. width: 100%;
  767. max-width: 100%;
  768. overflow: hidden;
  769. }
  770. }
  771. }
  772. /* 07. 操作区 */
  773. .oper-area {
  774. left: 0;
  775. bottom: 0;
  776. background: rgba(255, 255, 255, 0.95);
  777. box-shadow: 0 0 20rpx 0 #f0f0f0;
  778. height: 100rpx;
  779. z-index: 95;
  780. .btn-area {
  781. font-size: $font-sm;
  782. color: $font-color-base;
  783. width: 96rpx;
  784. .iconfont {
  785. font-size: 40rpx;
  786. line-height: 48rpx;
  787. }
  788. }
  789. }
  790. /* 优惠券区 */
  791. .coupon-area {
  792. max-height: 60vh;
  793. min-height: 30vh;
  794. .coupon-item {
  795. margin-bottom: 20rpx;
  796. &:last-child {
  797. margin-bottom: 0;
  798. }
  799. .content {
  800. &:after {
  801. position: absolute;
  802. left: 0;
  803. bottom: 0;
  804. content: '';
  805. width: 100%;
  806. height: 0;
  807. border-bottom: 1px dashed #f3f3f3;
  808. transform: scaleY(50%);
  809. }
  810. }
  811. .circle {
  812. position: absolute;
  813. bottom: -10rpx;
  814. z-index: 10;
  815. width: 20rpx;
  816. height: 20rpx;
  817. background: #f5f5f5;
  818. border-radius: 50%;
  819. &.r {
  820. right: -6rpx;
  821. }
  822. &.l {
  823. left: -6rpx;
  824. }
  825. }
  826. }
  827. }
  828. </style>