product.vue 17 KB

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