product.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  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: false, //判断是否支付中
  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. if (!obj.payLoding) {
  282. return
  283. }
  284. if (obj.type == 'weixin') {
  285. obj.$api.msg('微信暂未开通!')
  286. uni.hideLoading()
  287. obj.payLoding = true
  288. return
  289. }
  290. // 判断是否是市场进入
  291. if (obj.isSc == 1) {
  292. obj.marketPay();
  293. }
  294. // 判断是否是市场进入
  295. if (obj.isSc == 2) {
  296. obj.firstCreateOrder();
  297. }
  298. },
  299. // 市场支付
  300. marketPay() {
  301. const obj = this;
  302. nftBuy({
  303. pay_type: obj.type
  304. }, obj.shopId).then(res => {
  305. console.log(res, '购入');
  306. uni.hideLoading()
  307. if (obj.type == 'yue') {
  308. obj.paySuccessTo();
  309. }
  310. if (obj.type == 'ali') {
  311. const url = res.data.result.payConfig;
  312. console.log(url, 'url');
  313. uni.requestPayment({
  314. provider: 'alipay',
  315. orderInfo: url,
  316. success: res => {
  317. obj.paySuccessTo();
  318. },
  319. fail: e => {
  320. console.log(e);
  321. },
  322. complete: () => {}
  323. });
  324. }
  325. }).catch(() => {
  326. obj.payLoding = true
  327. })
  328. return
  329. },
  330. //普通商品支付
  331. firstCreateOrder() {
  332. let obj = this;
  333. // 获取下单页面数据
  334. // let prepage = obj.$api.prePage();
  335. // console.log(prepage,'prepage');
  336. let pages = getCurrentPages(); // 获取页面栈
  337. let current = pages[pages.length - 1]; // 当前页面
  338. console.log(current, 'current');
  339. let data = {
  340. real_name: '', //联系人名称
  341. phone: '', //联系人号码
  342. couponId: '', //优惠券编号
  343. addressId: '', //支付地址id
  344. useIntegral: 0, //是否积分抵扣1为是0为否
  345. payType: obj.type, //支付类型 weixin-微信 yue-余额
  346. mark: '', //备注
  347. from: 'app', //来源
  348. shipping_type: 1 //提货方式 1 快递 2自提
  349. }
  350. // 生成订单
  351. console.log(obj.orderKey, 'obj.orderKey');
  352. createOrderkey(data, obj.orderKey)
  353. .then(({
  354. data,
  355. status,
  356. msg
  357. }) => {
  358. console.log(status);
  359. // 判断是否支付失败
  360. if (data.status == 'ORDER_EXIST') {
  361. uni.showModal({
  362. title: '提示',
  363. content: msg,
  364. showCancel: false
  365. });
  366. uni.hideLoading();
  367. obj.payLoding = false;
  368. return;
  369. }
  370. // 保存订单号
  371. obj.orderId = data.result.orderId;
  372. // 判断是否为余额支付
  373. if (obj.type == 'yue') {
  374. if (status == 200) {
  375. obj.paySuccessTo();
  376. } else {
  377. obj.$api.msg(msg);
  378. }
  379. } else {
  380. // 立即支付
  381. obj.orderMoneyPay();
  382. }
  383. })
  384. .catch(e => {
  385. uni.hideLoading();
  386. obj.payLoding = false;
  387. console.log(e, '123456789');
  388. });
  389. },
  390. //立即支付订单
  391. orderMoneyPay() {
  392. let obj = this;
  393. orderPay({
  394. uni: obj.orderKey,
  395. from: 'app', //来源
  396. paytype: obj.type //支付类型 weixin-微信 yue-余额
  397. }).then(res => {
  398. console.log(res, '订单支付信息')
  399. if (res.data.status == 'SUCCESS' && obj.type == 'yue') {
  400. if (res.status == 200) {
  401. obj.paySuccessTo()
  402. } else {
  403. obj.$api.msg(msg)
  404. console.log('失败');
  405. }
  406. }
  407. if (obj.type == 'ali') {
  408. const url = res.data.result.payConfig;
  409. console.log(url, 'url');
  410. uni.requestPayment({
  411. provider: 'alipay',
  412. orderInfo: url,
  413. success: res => {
  414. console.log(res);
  415. uni.showToast({
  416. title: '支付成功',
  417. duration: 2000
  418. });
  419. obj.paySuccessTo();
  420. },
  421. fail: e => {
  422. console.log(e);
  423. },
  424. complete: () => {}
  425. });
  426. }
  427. uni.hideLoading();
  428. obj.payLoding = true;
  429. })
  430. },
  431. // 获取商品详情
  432. goodsDetail() {
  433. let obj = this
  434. console.log(obj.isSc, 'issc');
  435. goodsDetails({}, obj.shopId).then(res => {
  436. obj.uniqueId = res.data.productValue['默认'].unique
  437. obj.shopDetail = res.data.storeInfo
  438. console.log(obj.shopDetail, obj.uniqueId, 'res1111');
  439. if (obj.shopDetail.description != null) {
  440. obj.shopDetail.description = obj.shopDetail.description.replace(/<img/g,
  441. '<img class="rich-img"').replace(/<p>\s*<img/g, '<p class="pHeight"><img');
  442. }
  443. if (obj.shopDetail.rule != null) {
  444. obj.shopDetail.rule = '<p>' + obj.shopDetail.rule.replace(/\n/g, '</p><p>').trim() + '</p>'
  445. }
  446. let time = new Date(obj.shopDetail.sell_time * 1000);
  447. obj.shopDetail.cmy_pay_time = time.getFullYear() + '年' + (time.getMonth() + 1) + '月' + time
  448. .getDate() + '日' + time.getHours() + '时' + time.getMinutes() + '分' + time.getSeconds() +
  449. '秒'
  450. return
  451. })
  452. },
  453. // 获取交易市场进入时候的数据
  454. getNftDetail() {
  455. let obj = this
  456. nftDetail({}, obj.shopId).then(res => {
  457. // obj.uniqueId = res.data.productValue['默认'].unique
  458. // obj.shopDetail = res.data.storeInfo
  459. obj.shopDetail = res.data.info
  460. console.log(res, obj.isSc, 'res1111');
  461. })
  462. },
  463. // 支付成功跳转
  464. paySuccessTo() {
  465. uni.hideLoading();
  466. uni.redirectTo({
  467. url: '/pages/money/paySuccess?orderKey=' + this.orderKey
  468. });
  469. },
  470. }
  471. };
  472. </script>
  473. <style lang="scss">
  474. .container,
  475. page {
  476. background: #111111;
  477. min-height: 100%;
  478. }
  479. /deep/ .rich-img {
  480. width: 100% !important;
  481. height: auto;
  482. }
  483. /* #ifdef MP */
  484. .rich-img {
  485. width: 100% !important;
  486. height: auto;
  487. }
  488. // 处理图片间白色间距问题
  489. .pHeight {
  490. line-height: 0;
  491. }
  492. /* #endif */
  493. .swiper-box {
  494. background: #0C0A36;
  495. }
  496. .img {
  497. margin: 0 auto;
  498. width: 750rpx;
  499. image {
  500. width: 100%;
  501. }
  502. }
  503. .content-box {
  504. border-bottom: 2rpx solid #919295;
  505. padding: 30rpx;
  506. display: flex;
  507. flex-direction: column;
  508. .content-top {
  509. display: flex;
  510. justify-content: space-between;
  511. align-items: center;
  512. .hd {
  513. font-size: 38rpx;
  514. font-family: PingFang SC;
  515. font-weight: bold;
  516. color: #FFFFFF;
  517. line-height: 42rpx;
  518. }
  519. .content-img {
  520. display: flex;
  521. align-items: center;
  522. justify-content: space-around;
  523. font-size: 24rpx;
  524. font-family: PingFang SC;
  525. font-weight: 500;
  526. color: #585BE7;
  527. line-height: 39rpx;
  528. padding: 10rpx;
  529. height: 41rpx;
  530. border: 2rpx solid #585BE7;
  531. border-radius: 5rpx;
  532. image {
  533. width: 26rpx;
  534. height: 26rpx;
  535. }
  536. }
  537. }
  538. .content-center {
  539. margin: 20rpx 0;
  540. display: flex;
  541. flex-direction: column;
  542. .title {
  543. font-size: 24rpx;
  544. font-weight: 500;
  545. color: #FFFFFF;
  546. line-height: 42rpx;
  547. }
  548. }
  549. .content-bottom {
  550. display: flex;
  551. align-items: center;
  552. justify-content: space-between;
  553. .price {
  554. display: flex;
  555. justify-content: flex-end;
  556. font-size: 48rpx;
  557. font-weight: bold;
  558. color: #585BE7;
  559. span {
  560. font-size: 24rpx;
  561. font-weight: bold;
  562. color: #666666;
  563. font-family: SourceHanSerifSC;
  564. line-height: 66rpx;
  565. }
  566. }
  567. .gobuy {
  568. width: 334rpx;
  569. height: 90rpx;
  570. background: linear-gradient(270deg, #6E8DF7, #9977F6);
  571. border-radius: 10rpx;
  572. font-size: 36rpx;
  573. font-weight: 500;
  574. color: #FFFFFF;
  575. line-height: 90rpx;
  576. text-align: center;
  577. }
  578. }
  579. }
  580. .rz {
  581. display: flex;
  582. flex-direction: column;
  583. align-items: center;
  584. .rz-title {
  585. margin: 35rpx 0;
  586. font-size: 36rpx;
  587. font-family: PingFang SC;
  588. font-weight: bold;
  589. color: #FFFFFF;
  590. line-height: 42rpx;
  591. }
  592. .rich {
  593. display: block;
  594. justify-content: center;
  595. margin: 30rpx;
  596. width: 750rpx;
  597. overflow: hidden;
  598. }
  599. .rz-ms {
  600. padding: 0 20rpx;
  601. width: 690rpx;
  602. font-size: 24rpx;
  603. line-height: 36rpx;
  604. color: #FFFFFF;
  605. word-wrap: break-word;
  606. word-break: normal;
  607. }
  608. .rz-content {
  609. padding: 20rpx;
  610. display: flex;
  611. flex-direction: column;
  612. width: 690rpx;
  613. background: #222222;
  614. border-radius: 20rpx;
  615. .con-box {
  616. line-height: 60rpx;
  617. display: flex;
  618. justify-content: space-between;
  619. align-items: center;
  620. .left {
  621. font-size: 24rpx;
  622. color: #A5A5A5;
  623. }
  624. .right {
  625. display: flex;
  626. align-items: center;
  627. .address {
  628. color: #6363FE;
  629. font-size: 24rpx;
  630. width: 300rpx;
  631. text-align: right;
  632. overflow: hidden;
  633. text-overflow: ellipsis;
  634. white-space: nowrap;
  635. }
  636. .copy {
  637. margin-left: 15rpx;
  638. margin-bottom: 22rpx;
  639. width: 30rpx;
  640. height: 30rpx;
  641. image {
  642. width: 30rpx;
  643. height: 30rpx;
  644. }
  645. }
  646. }
  647. }
  648. }
  649. }
  650. .popup-box {
  651. width: 750rpx;
  652. background: #FFFFFF;
  653. border-radius: 10rpx 10rpx 0px 0px;
  654. padding-bottom: 130rpx;
  655. .pop-title {
  656. line-height: 1;
  657. padding-top: 30rpx;
  658. padding-left: 30rpx;
  659. padding-bottom: 10rpx;
  660. font-size: 34rpx;
  661. font-weight: bold;
  662. color: #333333;
  663. }
  664. .pop-radio {
  665. display: flex;
  666. .pop-radio-box {
  667. height: 100rpx;
  668. display: flex;
  669. align-items: center;
  670. padding: 25rpx;
  671. justify-content: space-between;
  672. width: 750rpx;
  673. .pop-radio-cont {
  674. display: flex;
  675. img {
  676. width: 40rpx;
  677. height: 40rpx;
  678. }
  679. text {
  680. margin-left: 10rpx;
  681. font-size: 28rpx;
  682. font-weight: 400;
  683. color: #3F454B;
  684. }
  685. }
  686. }
  687. .pop-bottom {
  688. position: fixed;
  689. bottom: 0;
  690. right: 0;
  691. height: 93rpx;
  692. width: 750rpx;
  693. display: flex;
  694. justify-content: space-between;
  695. .pirce {
  696. display: flex;
  697. align-items: center;
  698. margin-left: 25rpx;
  699. .price-left {
  700. font-size: 28rpx;
  701. font-family: PingFang SC;
  702. font-weight: 400;
  703. color: #3F454B;
  704. line-height: 100px;
  705. }
  706. display: flex;
  707. .price-right {
  708. font-size: 24rpx;
  709. font-weight: 500;
  710. color: #FD3B39;
  711. line-height: 55px;
  712. span {
  713. font-size: 36rpx;
  714. font-weight: 500;
  715. color: #FD3B39;
  716. line-height: 55px;
  717. }
  718. }
  719. }
  720. .buy {
  721. width: 360rpx;
  722. height: 93rpx;
  723. background: linear-gradient(270deg, #6E8DF7, #9977F6);
  724. font-size: 32rpx;
  725. font-weight: bold;
  726. line-height: 93rpx;
  727. text-align: center;
  728. color: #FFFFFF;
  729. }
  730. }
  731. }
  732. }
  733. .clickbg {
  734. background-color: $color-gray !important;
  735. }
  736. </style>