productMh.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. <template>
  2. <view class="container padding-b-30">
  3. <view class="swiper-box">
  4. <view class="img">
  5. <image :src="shopDetail.pic" mode="widthFix"></image>
  6. </view>
  7. </view>
  8. <view class="content-box">
  9. <view class="content-top">
  10. <view class="hd">{{ shopDetail.name }}</view>
  11. </view>
  12. <view class="content-center">
  13. <view class="title">发行方:艺绘官方 </view>
  14. </view>
  15. <view class="content-bottom">
  16. <view class="price">
  17. {{ shopDetail.price }}
  18. <span>RMB</span>
  19. </view>
  20. <view class="gobuy" @click="buy()">立即购买</view>
  21. </view>
  22. </view>
  23. <view class="rz">
  24. <view class="rz-title">认证信息</view>
  25. <view class="rz-ms">
  26. <view class="tc-item flex">
  27. <view class="tcitem-name">创作者</view>
  28. <view class="ali-name clamp">艺绘官方</view>
  29. </view>
  30. <view class="tc-item flex margin-t-30">
  31. <view class="tcitem-name">发行方</view>
  32. <view class="ali-name clamp">艺绘官方</view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="rz">
  37. <view class="rz-title">购买需知</view>
  38. <view class="rz-ms">
  39. 1.著作权人同意,在交易完成后,您将获得该数字艺术品除人身权利外的其他著作权(包括复制权、发行权、出租权、展览权、表演权、放映权、广播权、信息网络传播权、摄制权、改编权、翻译权、汇编权等)。
  40. <br/>
  41. 2.数字藏品的版权由发行方或创作者所有,除另行去取得版权 所有者书面同意外, 用户不得将数字藏品用于任何商业用途。
  42. </view>
  43. </view>
  44. <view class="rz">
  45. <view class="rz-title">权益需知</view>
  46. <view class="rz-ms">
  47. 数字藏品为虚拟数字商品,而非实物,仅限实名认证为年满18周岁的中国大陆用户购买。本商品一经售出,不支持任何形式的退换货。本商品源文件不支持本地下载。请勿对数字藏品进行炒作、场外交易、欺诈,或以其他任何非法形式进行交易和使用。
  48. </view>
  49. </view>
  50. <uni-popup ref="popupkf" type="bottom">
  51. <view class="popup-box">
  52. <view class="pop-title flex borde-b">
  53. <view class="title ">
  54. 购买数量
  55. </view>
  56. <u--input :border='"surround"' class='margin-l-30' placeholder="请输入数量" type='number' clearable v-model="num" inputAlign='right'
  57. @input="changeNum"></u--input>
  58. </view>
  59. <view class="pop-radio">
  60. <radio-group name="">
  61. <!-- #ifdef APP-PLUS -->
  62. <label class="pop-radio-box" @click="type = 'ali'">
  63. <view class="pop-radio-cont">
  64. <image src="../../static/img/ali.png" style="width: 40rpx;height: 40rpx;"
  65. mode="scaleToFill"></image>
  66. <text>支付宝支付</text>
  67. </view>
  68. <radio :checked="type == 'ali'" style="transform: scale(0.8);" />
  69. </label>
  70. <!-- <label class="pop-radio-box" @click="type='weixin'">
  71. <view class="pop-radio-cont">
  72. <image src="../../static/img/weixin.png" style="width: 40rpx;height: 40rpx;"
  73. mode="scaleToFill">
  74. </image>
  75. <text>微信支付</text>
  76. </view>
  77. <radio :checked="type=='weixin'" style="transform: scale(0.8);" />
  78. </label> -->
  79. <!-- #endif -->
  80. <label class="pop-radio-box" @click="type = 'yue'">
  81. <view class="pop-radio-cont">
  82. <image src="../../static/img/yue.png" style="width: 40rpx;height: 40rpx;"
  83. mode="scaleToFill"></image>
  84. <text>余额支付:{{ now_money }}</text>
  85. </view>
  86. <radio :checked="type == 'yue'" style="transform: scale(0.8);" />
  87. </label>
  88. </radio-group>
  89. <view class="pop-bottom">
  90. <view class="pirce">
  91. <view class="price-left">合计:</view>
  92. <view class="price-right">
  93. <span>{{ shopDetail.price*num }}</span>
  94. </view>
  95. </view>
  96. <!-- "!payLoding ? pay() : ''" -->
  97. <view class="buy" @click="pay()" :class="{ clickbg: payLoding }">立即支付</view>
  98. </view>
  99. </view>
  100. </view>
  101. </uni-popup>
  102. </view>
  103. </template>
  104. <script>
  105. import {
  106. balance
  107. } from '@/api/wallet.js';
  108. import {
  109. mapState
  110. } from 'vuex';
  111. import uniCopy from '@/components/js_sdk/xb-copy/uni-copy.js';
  112. import {
  113. mysteryDetail,
  114. mysteryPay
  115. } from '@/api/product.js';
  116. export default {
  117. data() {
  118. return {
  119. num: 1, //默认购买数量
  120. now_money: 0, //余额
  121. payLoding: true, //判断是否支付中
  122. type: 'yue', //支付状态
  123. shopDetail: {
  124. }, //商品详情
  125. weixin: '',
  126. yue: '',
  127. shopId: '', //商品id
  128. list: [],
  129. };
  130. },
  131. onLoad(options) {
  132. this.shopId = options.id;
  133. // 加载详情
  134. this.goodsDetail();
  135. // 载入余额
  136. balance({}).then(({
  137. data
  138. }) => {
  139. // 获取余额
  140. this.now_money = data.now_money;
  141. });
  142. },
  143. computed: {
  144. ...mapState(['weichatObj', 'baseURL', 'urlFile']),
  145. ...mapState('user', ['userInfo', 'hasLogin'])
  146. },
  147. methods: {
  148. // 判断是否输入正确数量
  149. changeNum(s) {
  150. console.log(s);
  151. let num = Math.floor(s);
  152. if(s.indexOf('.')>-1){
  153. uni.showModal({
  154. title: '错误',
  155. content: '只可填入整数',
  156. showCancel: false,
  157. });
  158. }
  159. this.$nextTick(() => {
  160. this.num = +num
  161. })
  162. },
  163. //选择支付方式
  164. changePayType(type) {
  165. this.type = type;
  166. },
  167. //复制
  168. copy(value) {
  169. let obj = this;
  170. let content = value; //需要复制的内容
  171. console.log('复制的内容:', content);
  172. // content = typeof content === 'string' ? content : content.toString(); // 复制内容,必须字符串,数字需要转换为字符串
  173. const result = uniCopy(content);
  174. if (result === false) {
  175. uni.showToast({
  176. title: '不支持'
  177. });
  178. } else {
  179. uni.showToast({
  180. title: '复制成功',
  181. icon: 'none'
  182. });
  183. }
  184. },
  185. // 支付
  186. buy() {
  187. this.$refs.popupkf.open();
  188. },
  189. //支付
  190. async pay() {
  191. let obj = this;
  192. if (obj.type == 'yue' && obj.now_money * 1 < obj.shopDetail.price * 1) {
  193. uni.showModal({
  194. title: '提示',
  195. content: '账户余额不足!',
  196. showCancel: false
  197. });
  198. return;
  199. }
  200. // uni.hideLoading()
  201. uni.showLoading({
  202. title: '支付中',
  203. mask: true
  204. });
  205. // 判断是否支付中
  206. if (!obj.payLoding) {
  207. return;
  208. }
  209. obj.payLoding = false;
  210. if (obj.type == 'weixin') {
  211. obj.$api.msg('微信暂未开通!');
  212. uni.hideLoading();
  213. obj.payLoding = true;
  214. return;
  215. }
  216. obj.marketPay();
  217. },
  218. // 市场支付
  219. marketPay() {
  220. const obj = this;
  221. mysteryPay({
  222. pay_type: obj.type,
  223. id: obj.shopId,
  224. num: obj.num
  225. })
  226. .then(res => {
  227. console.log(res, '购入');
  228. uni.hideLoading();
  229. if (obj.type == 'yue') {
  230. obj.paySuccessTo();
  231. }
  232. if (obj.type == 'ali') {
  233. const url = res.data.payConfig;
  234. console.log(url, 'url');
  235. uni.requestPayment({
  236. provider: 'alipay',
  237. orderInfo: url,
  238. success: res => {
  239. obj.paySuccessTo();
  240. },
  241. fail: e => {
  242. uni.showModal({
  243. title: '错误',
  244. content: '未成功支付',
  245. showCancel: false
  246. });
  247. console.log(e);
  248. },
  249. complete: () => {}
  250. });
  251. }
  252. })
  253. .catch(() => {
  254. obj.payLoding = true;
  255. });
  256. return;
  257. },
  258. // 获取商品详情
  259. goodsDetail() {
  260. let obj = this;
  261. mysteryDetail({
  262. id: obj.shopId
  263. }, ).then(res => {
  264. obj.shopDetail = res.data.info;
  265. console.log(res, 'xq');
  266. });
  267. },
  268. // 支付成功跳转
  269. paySuccessTo() {
  270. uni.hideLoading();
  271. uni.redirectTo({
  272. url: '/pages/money/paySuccess?orderKey=' + this.orderKey
  273. });
  274. }
  275. }
  276. };
  277. </script>
  278. <style lang="scss">
  279. .container,
  280. page {
  281. min-height: 100%;
  282. }
  283. /deep/ .rich-img {
  284. width: 100% !important;
  285. height: auto;
  286. }
  287. /* #ifdef MP */
  288. .rich-img {
  289. width: 100% !important;
  290. height: auto;
  291. }
  292. // 处理图片间白色间距问题
  293. .pHeight {
  294. line-height: 0;
  295. }
  296. /* #endif */
  297. .img {
  298. margin: 0 auto;
  299. width: 750rpx;
  300. line-height: 0;
  301. image {
  302. width: 100%;
  303. }
  304. }
  305. .content-box {
  306. border-bottom: 2rpx solid #919295;
  307. padding: 30rpx;
  308. display: flex;
  309. flex-direction: column;
  310. .content-top {
  311. display: flex;
  312. justify-content: space-between;
  313. align-items: center;
  314. .hd {
  315. font-size: 38rpx;
  316. font-family: PingFang SC;
  317. font-weight: bold;
  318. color: #ffffff;
  319. line-height: 42rpx;
  320. }
  321. .content-img {
  322. display: flex;
  323. align-items: center;
  324. justify-content: space-around;
  325. font-size: 24rpx;
  326. font-family: PingFang SC;
  327. font-weight: 500;
  328. color: #FDD58A;
  329. line-height: 39rpx;
  330. padding: 10rpx;
  331. height: 41rpx;
  332. border: 2rpx solid #FDD58A;
  333. border-radius: 5rpx;
  334. image {
  335. width: 26rpx;
  336. height: 26rpx;
  337. }
  338. }
  339. }
  340. .content-center {
  341. margin: 20rpx 0;
  342. display: flex;
  343. flex-direction: column;
  344. .title {
  345. font-size: 24rpx;
  346. font-weight: 500;
  347. color: #ffffff;
  348. line-height: 42rpx;
  349. }
  350. }
  351. .content-bottom {
  352. display: flex;
  353. align-items: center;
  354. justify-content: space-between;
  355. .price {
  356. display: flex;
  357. justify-content: flex-end;
  358. font-size: 48rpx;
  359. font-weight: bold;
  360. color: #FDD58A;
  361. span {
  362. font-size: 24rpx;
  363. font-weight: bold;
  364. color: #666666;
  365. font-family: SourceHanSerifSC;
  366. line-height: 66rpx;
  367. }
  368. }
  369. .gobuy {
  370. width: 334rpx;
  371. height: 90rpx;
  372. background: $bgBaseBg;
  373. border-radius: 10rpx;
  374. font-size: 36rpx;
  375. font-weight: 500;
  376. color: #9F570E;
  377. line-height: 90rpx;
  378. text-align: center;
  379. }
  380. }
  381. }
  382. .rz {
  383. display: flex;
  384. flex-direction: column;
  385. align-items: center;
  386. .rz-title {
  387. margin: 35rpx 0;
  388. font-size: 36rpx;
  389. font-family: PingFang SC;
  390. font-weight: bold;
  391. color: #ffffff;
  392. line-height: 42rpx;
  393. }
  394. .rich {
  395. display: block;
  396. justify-content: center;
  397. margin: 30rpx;
  398. width: 750rpx;
  399. overflow: hidden;
  400. }
  401. .rz-ms {
  402. padding: 30rpx;
  403. width: 690rpx;
  404. font-size: 24rpx;
  405. line-height: 36rpx;
  406. color: #ffffff;
  407. word-wrap: break-word;
  408. word-break: normal;
  409. background-color: rgb(29, 28, 33);
  410. border-radius: 20rpx;
  411. }
  412. .rz-content {
  413. padding: 20rpx;
  414. display: flex;
  415. flex-direction: column;
  416. width: 690rpx;
  417. background: #222222;
  418. border-radius: 20rpx;
  419. .con-box {
  420. line-height: 60rpx;
  421. display: flex;
  422. justify-content: space-between;
  423. align-items: center;
  424. .left {
  425. font-size: 24rpx;
  426. color: #a5a5a5;
  427. }
  428. .right {
  429. display: flex;
  430. align-items: center;
  431. .address {
  432. color: #6363fe;
  433. font-size: 24rpx;
  434. width: 300rpx;
  435. text-align: right;
  436. overflow: hidden;
  437. text-overflow: ellipsis;
  438. white-space: nowrap;
  439. }
  440. .copy {
  441. margin-left: 15rpx;
  442. margin-bottom: 22rpx;
  443. width: 30rpx;
  444. height: 30rpx;
  445. image {
  446. width: 30rpx;
  447. height: 30rpx;
  448. }
  449. }
  450. }
  451. }
  452. }
  453. .tc-item {
  454. width: 100%;
  455. line-height: 1;
  456. .tcitem-name {
  457. flex-shrink: 0;
  458. font-size: 30rpx;
  459. font-family: PingFang SC;
  460. font-weight: 500;
  461. color: #fff;
  462. }
  463. .ali-name {
  464. font-size: 30rpx;
  465. font-family: PingFang SC;
  466. font-weight: 500;
  467. color: #FDD58A;
  468. }
  469. .tcitem-image {
  470. flex-shrink: 0;
  471. width: 26rpx;
  472. height: 28rpx;
  473. }
  474. }
  475. }
  476. .popup-box {
  477. width: 750rpx;
  478. background: #ffffff;
  479. border-radius: 10rpx 10rpx 0px 0px;
  480. padding-bottom: 130rpx;
  481. .pop-title {
  482. line-height: 1;
  483. padding: 30rpx;
  484. padding-bottom: 10rpx;
  485. font-size: 34rpx;
  486. font-weight: bold;
  487. color: #333333;
  488. }
  489. .pop-radio {
  490. display: flex;
  491. .pop-radio-box {
  492. height: 100rpx;
  493. display: flex;
  494. align-items: center;
  495. padding: 25rpx;
  496. justify-content: space-between;
  497. width: 750rpx;
  498. .pop-radio-cont {
  499. display: flex;
  500. img {
  501. width: 40rpx;
  502. height: 40rpx;
  503. }
  504. text {
  505. margin-left: 10rpx;
  506. font-size: 28rpx;
  507. font-weight: 400;
  508. color: #3f454b;
  509. }
  510. }
  511. }
  512. .pop-bottom {
  513. position: fixed;
  514. bottom: 0;
  515. right: 0;
  516. height: 93rpx;
  517. width: 750rpx;
  518. display: flex;
  519. justify-content: space-between;
  520. .pirce {
  521. display: flex;
  522. align-items: center;
  523. margin-left: 25rpx;
  524. .price-left {
  525. font-size: 28rpx;
  526. font-family: PingFang SC;
  527. font-weight: 400;
  528. color: #3f454b;
  529. line-height: 100px;
  530. }
  531. display: flex;
  532. .price-right {
  533. font-size: 24rpx;
  534. font-weight: 500;
  535. color: #fd3b39;
  536. line-height: 55px;
  537. span {
  538. font-size: 36rpx;
  539. font-weight: 500;
  540. color: #fd3b39;
  541. line-height: 55px;
  542. }
  543. }
  544. }
  545. .buy {
  546. width: 360rpx;
  547. height: 93rpx;
  548. background: $bgBaseBg;
  549. font-size: 32rpx;
  550. font-weight: bold;
  551. line-height: 93rpx;
  552. text-align: center;
  553. color: #ffffff;
  554. }
  555. }
  556. }
  557. }
  558. .clickbg {
  559. background-color: $color-gray !important;
  560. }
  561. </style>