product.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799
  1. <template>
  2. <view class="container">
  3. <view class="swiper-box">
  4. <view class="img" v-if="isSc==2">
  5. <image :src="shopDetail.image" mode="widthFix"></image>
  6. </view>
  7. <view class="img" v-if="isSc==1">
  8. <image :src="shopDetail.class_info.uri" mode="widthFix"></image>
  9. </view>
  10. </view>
  11. <view class="content-box">
  12. <view class="content-top">
  13. <view class="hd">
  14. {{shopDetail.store_name}}
  15. </view>
  16. <view class="content-img">
  17. <image src="../../static/img/fx.png" mode=""></image>分享
  18. </view>
  19. </view>
  20. <view class="content-center" v-if="isSc==2">
  21. <view class="title">
  22. 发行数量: {{shopDetail.ficti+shopDetail.stock}}份
  23. </view>
  24. <view class="title">
  25. 已售数量: {{shopDetail.ficti}}份
  26. </view>
  27. <view class="title">
  28. 个人限购: {{shopDetail.buy_limit}}
  29. </view>
  30. <view class="title">
  31. 开售时间: {{shopDetail.cmy_pay_time}}
  32. </view>
  33. </view>
  34. <view class="content-center" v-else>
  35. <view class="title" style="font-size: 38rpx;font-weight: bold;color: #FFFFFF;">
  36. {{shopDetail.class_info.name}}
  37. </view>
  38. <view class="title">
  39. 持有者: {{shopDetail.user.nickname}}
  40. </view>
  41. </view>
  42. <view class="content-bottom">
  43. <view class="price">
  44. {{shopDetail.price}} <span>RMB</span>
  45. </view>
  46. <view class="gobuy" @click="buy()">
  47. 立即购买
  48. </view>
  49. </view>
  50. </view>
  51. <view class="rz" v-show="isSc==2">
  52. <view class="rz-title">
  53. 作品描述
  54. </view>
  55. <view class="rz-ms">
  56. {{shopDetail.store_info}}
  57. </view>
  58. </view>
  59. <view class="rz" v-show="isSc==2">
  60. <view class="rz-title">
  61. 作品详情
  62. </view>
  63. <rich-text class="rich" :nodes="shopDetail.description"></rich-text>
  64. </view>
  65. <uni-popup ref="popupkf" type="bottom">
  66. <view class="popup-box">
  67. <view class="pop-title">
  68. 选择支付方式
  69. </view>
  70. <view class="pop-radio">
  71. <radio-group name="">
  72. <!-- #ifdef APP-PLUS -->
  73. <label class="pop-radio-box" @click="type='ali'">
  74. <view class="pop-radio-cont">
  75. <image src="../../static/img/ali.png" style="width: 40rpx;height: 40rpx;"
  76. mode="scaleToFill">
  77. </image>
  78. <text>支付宝支付</text>
  79. </view>
  80. <radio :checked="type=='ali'" style="transform: scale(0.8);" />
  81. </label>
  82. <!-- <label class="pop-radio-box" @click="type='weixin'">
  83. <view class="pop-radio-cont">
  84. <image src="../../static/img/weixin.png" style="width: 40rpx;height: 40rpx;"
  85. mode="scaleToFill">
  86. </image>
  87. <text>微信支付</text>
  88. </view>
  89. <radio :checked="type=='weixin'" style="transform: scale(0.8);" />
  90. </label> -->
  91. <!-- #endif -->
  92. <label class="pop-radio-box" @click="type='yue'">
  93. <view class="pop-radio-cont">
  94. <image src="../../static/img/yue.png" style="width: 40rpx;height: 40rpx;"
  95. mode="scaleToFill">
  96. </image>
  97. <text>余额支付:{{now_money}}</text>
  98. </view>
  99. <radio :checked="type=='yue'" style="transform: scale(0.8);" />
  100. </label>
  101. </radio-group>
  102. <view class="pop-bottom">
  103. <view class="pirce">
  104. <view class="price-left">
  105. 合计:
  106. </view>
  107. <view class="price-right">
  108. ¥<span>{{shopDetail.price}}</span>
  109. </view>
  110. </view>
  111. <!-- "!payLoding ? pay() : ''" -->
  112. <view class="buy" @click="pay()" :class="{ clickbg: payLoding }">
  113. 立即支付
  114. </view>
  115. </view>
  116. </view>
  117. </view>
  118. </uni-popup>
  119. <!-- <uni-popup ref="popupZf" type="bottom" >
  120. </uni-popup> -->
  121. </view>
  122. </template>
  123. <script>
  124. // import uniPopup from '@/components/uni-popup/uni-popup.vue'
  125. import {
  126. balance
  127. } from '@/api/wallet.js';
  128. import {
  129. mapState
  130. } from 'vuex';
  131. import {
  132. goodsDetails,
  133. cartAdd
  134. } from '@/api/product.js';
  135. import {
  136. confirm,
  137. orderPay,
  138. createOrderkey,
  139. nftmall,
  140. nftDetail,
  141. nftBuy
  142. } from '@/api/order.js'
  143. export default {
  144. data() {
  145. return {
  146. orderId: '', //订单编号
  147. moneyAll: '', //购物车订单
  148. now_money: 0, //余额
  149. payLoding: true, //判断是否支付中
  150. orderKey: '', //订单的key值
  151. addressData: {}, //地址信息
  152. shopList: [], //商品列表
  153. cartId: '', //购物车id
  154. uniqueId: '',
  155. type: 'yue', //支付状态
  156. shopDetail: {
  157. class_info: {},
  158. user: {}
  159. }, //商品详情
  160. weixin: '',
  161. yue: '',
  162. shopId: '', //商品id
  163. list: [
  164. // 'https://img.php.cn/upload/article/202104/15/2021041518005466284.jpg',
  165. // 'https://img.php.cn/upload/article/202104/15/2021041518005466284.jpg',
  166. // 'https://img.php.cn/upload/article/202104/15/2021041518005466284.jpg'
  167. ],
  168. froms: '', //保存h5中数据来源对象
  169. isSc: 0, //是否是是市场传递过来的参数
  170. };
  171. },
  172. onLoad(options) {
  173. // 保存当前获取数据的类型
  174. this.isSc = options.isSc
  175. // 商品id
  176. this.shopId = options.id
  177. // 判断是否是首页
  178. if (this.isSc == 2) {
  179. this.goodsDetail()
  180. }
  181. // 判断是否是市场
  182. if (this.isSc == 1) {
  183. this.getNftDetail()
  184. }
  185. // 载入余额
  186. balance({}).then(({
  187. data
  188. }) => {
  189. // 获取余额
  190. this.now_money = data.now_money;
  191. });
  192. },
  193. computed: {
  194. ...mapState(['weichatObj', 'baseURL', 'urlFile']),
  195. ...mapState('user', ['userInfo', 'hasLogin'])
  196. },
  197. methods: {
  198. //选择支付方式
  199. changePayType(type) {
  200. this.type = type;
  201. },
  202. buy() {
  203. // 判断是否是首页
  204. if (this.isSc == 2) {
  205. this.indexPay()
  206. }
  207. // 判断是否是市场
  208. if (this.isSc == 1) {
  209. this.$refs.popupkf.open()
  210. }
  211. },
  212. // 判断是否是首页进入交易
  213. indexPay() {
  214. let obj = this;
  215. let lj = true;
  216. // 判断是否需要拦截
  217. if (obj.userInfo.is_company == 1 || obj.userInfo.is_partner == 1) {
  218. lj = false
  219. }
  220. if (lj) {
  221. let time = new Date();
  222. if (time.getTime() < obj.shopDetail.sell_time * 1000) {
  223. uni.showModal({
  224. title: '错误',
  225. content: '未到开售时间,不能购买',
  226. showCancel: false,
  227. success: res => {},
  228. fail: () => {},
  229. });
  230. return
  231. }
  232. }
  233. let data = {
  234. cartNum: 1,
  235. uniqueId: obj.uniqueId, //商品标签.默认无
  236. new: '1',
  237. // mer_id: '',//商店id暂未知晓
  238. productId: obj.shopId
  239. }
  240. //生成订单
  241. cartAdd(data).then(res => {
  242. console.log(res, 'res');
  243. //需要获取购物车号
  244. obj.cartId = res.data.cartId
  245. this.getKeys()
  246. }).catch(e => {
  247. console.log(e);
  248. });
  249. this.$refs.popupkf.open()
  250. },
  251. getKeys() {
  252. let obj = this
  253. confirm({
  254. cartId: obj.cartId
  255. }).then(data => {
  256. console.log(data, '生平具体信息');
  257. obj.addressData = data.data.addressInfo || {};
  258. obj.shopList = data.data.cartInfo; //商品列表
  259. // obj.moneyAll = data.data.cartInfo.truePrice; //金额数据
  260. obj.orderKey = data.data.orderKey; //订单key
  261. // let url = `/pages/money/pay?key=${obj.orderKey}`
  262. // console.log(url);
  263. })
  264. },
  265. //支付
  266. async pay() {
  267. let obj = this
  268. if (obj.type == 'yue' && obj.now_money * 1 < obj.shopDetail.price * 1) {
  269. uni.showModal({
  270. title: '提示',
  271. content: '账户余额不足!',
  272. showCancel: false,
  273. });
  274. return;
  275. }
  276. // uni.hideLoading()
  277. uni.showLoading({
  278. title: "支付中",
  279. mask: true
  280. })
  281. // 判断是否支付中
  282. if (!obj.payLoding) {
  283. return
  284. }
  285. obj.payLoding = false;
  286. if (obj.type == 'weixin') {
  287. obj.$api.msg('微信暂未开通!')
  288. uni.hideLoading()
  289. obj.payLoding = true
  290. return
  291. }
  292. // 判断是否是市场进入
  293. if (obj.isSc == 1) {
  294. console.log('sc');
  295. obj.marketPay();
  296. }
  297. // 判断是否是市场进入
  298. if (obj.isSc == 2) {
  299. obj.firstCreateOrder();
  300. }
  301. },
  302. // 市场支付
  303. marketPay() {
  304. const obj = this;
  305. nftBuy({
  306. pay_type: obj.type
  307. }, obj.shopId).then(res => {
  308. console.log(res, '购入');
  309. uni.hideLoading()
  310. if (obj.type == 'yue') {
  311. obj.paySuccessTo();
  312. }
  313. if (obj.type == 'ali') {
  314. const url = res.data.payConfig;
  315. console.log(url, 'url');
  316. uni.requestPayment({
  317. provider: 'alipay',
  318. orderInfo: url,
  319. success: res => {
  320. obj.paySuccessTo();
  321. },
  322. fail: e => {
  323. console.log(e);
  324. },
  325. complete: () => {}
  326. });
  327. }
  328. }).catch(() => {
  329. obj.payLoding = true
  330. })
  331. return
  332. },
  333. //普通商品支付
  334. firstCreateOrder() {
  335. let obj = this;
  336. // 获取下单页面数据
  337. // let prepage = obj.$api.prePage();
  338. // console.log(prepage,'prepage');
  339. let pages = getCurrentPages(); // 获取页面栈
  340. let current = pages[pages.length - 1]; // 当前页面
  341. console.log(current, 'current');
  342. let data = {
  343. real_name: '', //联系人名称
  344. phone: '', //联系人号码
  345. couponId: '', //优惠券编号
  346. addressId: '', //支付地址id
  347. useIntegral: 0, //是否积分抵扣1为是0为否
  348. payType: obj.type, //支付类型 weixin-微信 yue-余额
  349. mark: '', //备注
  350. from: 'app', //来源
  351. shipping_type: 1 //提货方式 1 快递 2自提
  352. }
  353. // 生成订单
  354. console.log(obj.orderKey, 'obj.orderKey');
  355. createOrderkey(data, obj.orderKey)
  356. .then(({
  357. data,
  358. status,
  359. msg
  360. }) => {
  361. console.log(status);
  362. // 判断是否支付失败
  363. if (data.status == 'ORDER_EXIST') {
  364. uni.showModal({
  365. title: '提示',
  366. content: msg,
  367. showCancel: false
  368. });
  369. uni.hideLoading();
  370. obj.payLoding = true;
  371. return;
  372. }
  373. // 保存订单号
  374. obj.orderId = data.result.orderId;
  375. // 判断是否为余额支付
  376. if (obj.type == 'yue') {
  377. if (status == 200) {
  378. obj.paySuccessTo();
  379. } else {
  380. obj.$api.msg(msg);
  381. }
  382. } else {
  383. // 立即支付
  384. obj.orderMoneyPay();
  385. }
  386. })
  387. .catch(e => {
  388. uni.hideLoading();
  389. obj.payLoding = true;
  390. console.log(e, '123456789');
  391. });
  392. },
  393. //立即支付订单
  394. orderMoneyPay() {
  395. let obj = this;
  396. orderPay({
  397. uni: obj.orderKey,
  398. from: 'app', //来源
  399. paytype: obj.type //支付类型 weixin-微信 yue-余额
  400. }).then(res => {
  401. console.log(res, '订单支付信息')
  402. if (res.data.status == 'SUCCESS' && obj.type == 'yue') {
  403. if (res.status == 200) {
  404. obj.paySuccessTo()
  405. } else {
  406. obj.$api.msg(msg)
  407. console.log('失败');
  408. }
  409. }
  410. if (obj.type == 'ali') {
  411. const url = res.data.result.payConfig;
  412. console.log(url, 'url');
  413. uni.requestPayment({
  414. provider: 'alipay',
  415. orderInfo: url,
  416. success: res => {
  417. console.log(res);
  418. uni.showToast({
  419. title: '支付成功',
  420. duration: 2000
  421. });
  422. obj.paySuccessTo();
  423. },
  424. fail: e => {
  425. console.log(e);
  426. },
  427. complete: () => {}
  428. });
  429. }
  430. uni.hideLoading();
  431. obj.payLoding = true;
  432. })
  433. },
  434. // 获取商品详情
  435. goodsDetail() {
  436. let obj = this
  437. console.log(obj.isSc, 'issc');
  438. goodsDetails({}, obj.shopId).then(res => {
  439. obj.uniqueId = res.data.productValue['默认'].unique
  440. obj.shopDetail = res.data.storeInfo
  441. console.log(obj.shopDetail, obj.uniqueId, 'res1111');
  442. if (obj.shopDetail.description != null) {
  443. obj.shopDetail.description = obj.shopDetail.description.replace(/<img/g,
  444. '<img class="rich-img"').replace(/<p>\s*<img/g, '<p class="pHeight"><img');
  445. }
  446. if (obj.shopDetail.rule != null) {
  447. obj.shopDetail.rule = '<p>' + obj.shopDetail.rule.replace(/\n/g, '</p><p>').trim() + '</p>'
  448. }
  449. let time = new Date(obj.shopDetail.sell_time * 1000);
  450. obj.shopDetail.cmy_pay_time = time.getFullYear() + '年' + (time.getMonth() + 1) + '月' + time
  451. .getDate() + '日' + time.getHours() + '时' + time.getMinutes() + '分' + time.getSeconds() +
  452. '秒'
  453. return
  454. })
  455. },
  456. // 获取交易市场进入时候的数据
  457. getNftDetail() {
  458. let obj = this
  459. nftDetail({}, obj.shopId).then(res => {
  460. // obj.uniqueId = res.data.productValue['默认'].unique
  461. // obj.shopDetail = res.data.storeInfo
  462. obj.shopDetail = res.data.info
  463. console.log(res, obj.isSc, 'res1111');
  464. })
  465. },
  466. // 支付成功跳转
  467. paySuccessTo() {
  468. uni.hideLoading();
  469. uni.redirectTo({
  470. url: '/pages/money/paySuccess?orderKey=' + this.orderKey
  471. });
  472. },
  473. }
  474. };
  475. </script>
  476. <style lang="scss">
  477. .container,
  478. page {
  479. background: #111111;
  480. min-height: 100%;
  481. }
  482. /deep/ .rich-img {
  483. width: 100% !important;
  484. height: auto;
  485. }
  486. /* #ifdef MP */
  487. .rich-img {
  488. width: 100% !important;
  489. height: auto;
  490. }
  491. // 处理图片间白色间距问题
  492. .pHeight {
  493. line-height: 0;
  494. }
  495. /* #endif */
  496. .swiper-box {
  497. background: #0C0A36;
  498. }
  499. .img {
  500. margin: 0 auto;
  501. width: 750rpx;
  502. image {
  503. width: 100%;
  504. }
  505. }
  506. .content-box {
  507. border-bottom: 2rpx solid #919295;
  508. padding: 30rpx;
  509. display: flex;
  510. flex-direction: column;
  511. .content-top {
  512. display: flex;
  513. justify-content: space-between;
  514. align-items: center;
  515. .hd {
  516. font-size: 38rpx;
  517. font-family: PingFang SC;
  518. font-weight: bold;
  519. color: #FFFFFF;
  520. line-height: 42rpx;
  521. }
  522. .content-img {
  523. display: flex;
  524. align-items: center;
  525. justify-content: space-around;
  526. font-size: 24rpx;
  527. font-family: PingFang SC;
  528. font-weight: 500;
  529. color: #585BE7;
  530. line-height: 39rpx;
  531. padding: 10rpx;
  532. height: 41rpx;
  533. border: 2rpx solid #585BE7;
  534. border-radius: 5rpx;
  535. image {
  536. width: 26rpx;
  537. height: 26rpx;
  538. }
  539. }
  540. }
  541. .content-center {
  542. margin: 20rpx 0;
  543. display: flex;
  544. flex-direction: column;
  545. .title {
  546. font-size: 24rpx;
  547. font-weight: 500;
  548. color: #FFFFFF;
  549. line-height: 42rpx;
  550. }
  551. }
  552. .content-bottom {
  553. display: flex;
  554. align-items: center;
  555. justify-content: space-between;
  556. .price {
  557. display: flex;
  558. justify-content: flex-end;
  559. font-size: 48rpx;
  560. font-weight: bold;
  561. color: #585BE7;
  562. span {
  563. font-size: 24rpx;
  564. font-weight: bold;
  565. color: #666666;
  566. font-family: SourceHanSerifSC;
  567. line-height: 66rpx;
  568. }
  569. }
  570. .gobuy {
  571. width: 334rpx;
  572. height: 90rpx;
  573. background: linear-gradient(270deg, #6E8DF7, #9977F6);
  574. border-radius: 10rpx;
  575. font-size: 36rpx;
  576. font-weight: 500;
  577. color: #FFFFFF;
  578. line-height: 90rpx;
  579. text-align: center;
  580. }
  581. }
  582. }
  583. .rz {
  584. display: flex;
  585. flex-direction: column;
  586. align-items: center;
  587. .rz-title {
  588. margin: 35rpx 0;
  589. font-size: 36rpx;
  590. font-family: PingFang SC;
  591. font-weight: bold;
  592. color: #FFFFFF;
  593. line-height: 42rpx;
  594. }
  595. .rich {
  596. display: block;
  597. justify-content: center;
  598. margin: 30rpx;
  599. width: 750rpx;
  600. overflow: hidden;
  601. }
  602. .rz-ms {
  603. padding: 0 20rpx;
  604. width: 690rpx;
  605. font-size: 24rpx;
  606. line-height: 36rpx;
  607. color: #FFFFFF;
  608. word-wrap: break-word;
  609. word-break: normal;
  610. }
  611. .rz-content {
  612. padding: 20rpx;
  613. display: flex;
  614. flex-direction: column;
  615. width: 690rpx;
  616. background: #222222;
  617. border-radius: 20rpx;
  618. .con-box {
  619. line-height: 60rpx;
  620. display: flex;
  621. justify-content: space-between;
  622. align-items: center;
  623. .left {
  624. font-size: 24rpx;
  625. color: #A5A5A5;
  626. }
  627. .right {
  628. display: flex;
  629. align-items: center;
  630. .address {
  631. color: #6363FE;
  632. font-size: 24rpx;
  633. width: 300rpx;
  634. text-align: right;
  635. overflow: hidden;
  636. text-overflow: ellipsis;
  637. white-space: nowrap;
  638. }
  639. .copy {
  640. margin-left: 15rpx;
  641. margin-bottom: 22rpx;
  642. width: 30rpx;
  643. height: 30rpx;
  644. image {
  645. width: 30rpx;
  646. height: 30rpx;
  647. }
  648. }
  649. }
  650. }
  651. }
  652. }
  653. .popup-box {
  654. width: 750rpx;
  655. background: #FFFFFF;
  656. border-radius: 10rpx 10rpx 0px 0px;
  657. padding-bottom: 130rpx;
  658. .pop-title {
  659. line-height: 1;
  660. padding-top: 30rpx;
  661. padding-left: 30rpx;
  662. padding-bottom: 10rpx;
  663. font-size: 34rpx;
  664. font-weight: bold;
  665. color: #333333;
  666. }
  667. .pop-radio {
  668. display: flex;
  669. .pop-radio-box {
  670. height: 100rpx;
  671. display: flex;
  672. align-items: center;
  673. padding: 25rpx;
  674. justify-content: space-between;
  675. width: 750rpx;
  676. .pop-radio-cont {
  677. display: flex;
  678. img {
  679. width: 40rpx;
  680. height: 40rpx;
  681. }
  682. text {
  683. margin-left: 10rpx;
  684. font-size: 28rpx;
  685. font-weight: 400;
  686. color: #3F454B;
  687. }
  688. }
  689. }
  690. .pop-bottom {
  691. position: fixed;
  692. bottom: 0;
  693. right: 0;
  694. height: 93rpx;
  695. width: 750rpx;
  696. display: flex;
  697. justify-content: space-between;
  698. .pirce {
  699. display: flex;
  700. align-items: center;
  701. margin-left: 25rpx;
  702. .price-left {
  703. font-size: 28rpx;
  704. font-family: PingFang SC;
  705. font-weight: 400;
  706. color: #3F454B;
  707. line-height: 100px;
  708. }
  709. display: flex;
  710. .price-right {
  711. font-size: 24rpx;
  712. font-weight: 500;
  713. color: #FD3B39;
  714. line-height: 55px;
  715. span {
  716. font-size: 36rpx;
  717. font-weight: 500;
  718. color: #FD3B39;
  719. line-height: 55px;
  720. }
  721. }
  722. }
  723. .buy {
  724. width: 360rpx;
  725. height: 93rpx;
  726. background: linear-gradient(270deg, #6E8DF7, #9977F6);
  727. font-size: 32rpx;
  728. font-weight: bold;
  729. line-height: 93rpx;
  730. text-align: center;
  731. color: #FFFFFF;
  732. }
  733. }
  734. }
  735. }
  736. .clickbg {
  737. background-color: $color-gray !important;
  738. }
  739. </style>