paymentPage.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. <template>
  2. <view class="payment_bg">
  3. <view class="payment_info">
  4. <view class="people_num"><text>{{peopleNum}}人已测</text></view>
  5. <view class="price_num"><text>¥{{orderInfo.total}}</text></view>
  6. <view class="pay_btn_sm" @click="payHandle">{{orderInfo.total}}元解锁专属测试报告</view>
  7. </view>
  8. <view class="payment_desc">
  9. <image src="https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/paymentPage/pay_scale_desc.png"
  10. mode="widthFix"></image>
  11. </view>
  12. <view class="top_footer">
  13. <template v-if="hasDiscount">
  14. <view class="pay_price">
  15. <!-- <view class='pay_price_y'>优惠价</view> -->
  16. <view class="pay_price_p">¥{{price}}</view>
  17. <view class="pro_tag"><text style="margin: 6rpx 5rpx 0 0;">优惠后:</text><text
  18. class="price">¥{{promotionPrice}}</text></view>
  19. </view>
  20. <view style="display: flex;justify-content: center; align-items: center; margin: 20rpx 0;">
  21. <!-- <view class="people_sy"> 本次优惠剩余名额:{{residueNum}} </view> -->
  22. <view class="people_sy_time">
  23. <!-- <uni-countdown :show-day="false" :hour="testHour" :minute="testMinute" :second="testSecond" /> -->
  24. <text>优惠倒计时:</text><uni-countdown :show-day="true" background-color="#FF9D41" color="#ffffff"
  25. :start="start" :hour="testHour" :minute="testMinute" :second="testSecond" />
  26. </view>
  27. </view>
  28. </template>
  29. <view class="pay_btn_lg" @click="payHandle">
  30. {{hasDiscount? promotionPrice : price}}元解锁专属测试报告
  31. </view>
  32. </view>
  33. <uni-popup ref="popup" type="center">
  34. <view class="pay_dialog">
  35. <view class="btn_area">
  36. <image style="margin-right: 89rpx;" @click="completeHandle"
  37. src="https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/complete_btn.png"
  38. mode="widthFix"></image>
  39. <image @click="uncompleteHandle"
  40. src="https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/uncomplete_btn.png"
  41. mode="widthFix"></image>
  42. </view>
  43. </view>
  44. </uni-popup>
  45. </view>
  46. </template>
  47. <script>
  48. import {
  49. timestampFormatter
  50. } from '../../utils/util.js'
  51. export default {
  52. data() {
  53. return {
  54. orderNo: '',
  55. orderInfo: {},
  56. peopleNum: 0,
  57. residueNum: 0, // 剩余名额
  58. price: 0, // 正常价格
  59. promotionPrice: 0, // 优惠价格
  60. promotionEndTime: 0, // 结束时间(时间戳)
  61. testHour: 0, // 时
  62. testMinute: 0, // 分
  63. testSecond: 0, // 秒
  64. start: false
  65. }
  66. },
  67. onLoad(options) {
  68. if (options.orderNo) {
  69. this.orderNo = options.orderNo;
  70. setTimeout(() => {
  71. this.payEnsure();
  72. }, 200)
  73. }
  74. this.orderInfo = uni.getStorageSync('orderInfo');
  75. this.getPeople();
  76. this.queryPromotion();
  77. },
  78. computed: {
  79. // 是否有折扣
  80. hasDiscount() {
  81. let timeSpan = new Date().getTime();
  82. let endTime = this.promotionEndTime - timeSpan;
  83. return this.residueNum > 0 && endTime > 0
  84. }
  85. },
  86. methods: {
  87. payHandle() {
  88. // #ifdef H5
  89. this.getH5Pay();
  90. // #endif
  91. // #ifdef MP-TOUTIAO
  92. this.createOrder();
  93. // #endif
  94. },
  95. // 检查订单支付状态
  96. checkOrder() {
  97. let _this = this;
  98. _this.$request
  99. .get({
  100. url: `api/wx-pay/queryOrder/${_this.orderNo}`,
  101. loadingTip: "加载中...",
  102. data: {},
  103. })
  104. .then((res) => {
  105. uni.hideLoading();
  106. let resultInfo = JSON.parse(res.data.body)
  107. if (resultInfo.trade_state === 'SUCCESS') {
  108. uni.navigateTo({
  109. url: `/newScale/Charm/testResult?resultId=${this.orderInfo.resultId}&messageShare=1`
  110. });
  111. } else {
  112. return;
  113. }
  114. });
  115. },
  116. // 拉起微信支付
  117. getH5Pay(params) {
  118. let _this = this;
  119. _this.$request
  120. .get({
  121. url: `api/orderInfo/queryOrderByResultIdAndUserId/${this.orderInfo.userId}/${this.orderInfo.resultId}`,
  122. loadingTip: "加载中...",
  123. data: {},
  124. })
  125. .then((res) => {
  126. uni.hideLoading();
  127. if (res.data && res.data.orderStatus === '支付成功') {
  128. uni.navigateTo({
  129. url: `/newScale/Charm/testResult?resultId=${this.orderInfo.resultId}&messageShare=1`
  130. });
  131. } else {
  132. // _this.orderInfo.total = _this.hasDiscount ? _this.promotionPrice : _this.price;
  133. _this.$request
  134. .post({
  135. url: "api/wx-pay/h5Pay",
  136. loadingTip: "加载中...",
  137. data: _this.orderInfo
  138. })
  139. .then((res) => {
  140. let redirect_url = encodeURI(
  141. `http://hnhong-duo.com/webo/newScale/Charm/paymentPage?orderNo=${res.data.orderNo}`
  142. )
  143. window.location.href = `${res.data.codeUrl}&redirect_url=${redirect_url}`;
  144. });
  145. }
  146. });
  147. },
  148. createOrder() {
  149. let _this = this;
  150. let params = {
  151. resultId: _this.orderInfo.resultId,
  152. subject: _this.orderInfo.description,
  153. body: _this.orderInfo.description,
  154. total_amount: _this.orderInfo.total * 100,
  155. msgPage: "",
  156. }
  157. _this.$request
  158. .post({
  159. url: "api/douyin/createOrder",
  160. loadingTip: "加载中...",
  161. data: params
  162. })
  163. .then((res) => {
  164. _this.orderNo = res.data.orderNo;
  165. let imageUrl = 'https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/banner1.png';
  166. _this.payToutiao(
  167. res.data.orderId,
  168. res.data.orderToken,
  169. res.data.orderNo
  170. );
  171. });
  172. },
  173. payToutiao(orderId, orderToken, orderNo) {
  174. let _this = this;
  175. tt.pay({
  176. orderInfo: {
  177. order_id: orderId,
  178. order_token: orderToken,
  179. },
  180. service: 5,
  181. success: (response) => {
  182. _this.timer = setInterval(() => {
  183. _this.getQueryOrder(orderNo);
  184. }, 1000);
  185. },
  186. fail: (err) => {
  187. uni.showToast({
  188. icon: "none",
  189. name: "支付失败",
  190. });
  191. },
  192. });
  193. },
  194. // 订单状态
  195. getQueryOrder(orderNo) {
  196. let _this = this;
  197. _this.$request
  198. .get({
  199. url: `api/douyin/queryOrder/${orderNo}`,
  200. loadingTip: "加载中...",
  201. data: {},
  202. })
  203. .then((res) => {
  204. if (res.code == "200") {
  205. if (res.data.statusCode == "SUCCESS") {
  206. let imageUrl =
  207. 'https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/banner1.png';
  208. uni.navigateTo({
  209. url: `/newScale/Charm/testResult?resultId=${_this.orderInfo.resultId}&messageShare=1`
  210. });
  211. clearInterval(_this.timer);
  212. uni.showToast({
  213. title: "支付成功",
  214. });
  215. } else if (res.data.statusCode == "CLOSED") {
  216. // console.log("订单支付回调成功===========CLOSED》", _this.trade_state_closed );
  217. } else {
  218. clearInterval(_this.timer);
  219. // console.log("订单支付回调成功CLOSED===========》", _this.trade_state_closed);
  220. }
  221. } else {
  222. uni.showToast({
  223. title: "支付失败",
  224. });
  225. }
  226. });
  227. },
  228. // 查询测试人数
  229. getPeople() {
  230. let _this = this;
  231. _this.$request
  232. .get({
  233. url: "record/countByFlag?flag=20210804164957",
  234. loadingTip: "加载中..."
  235. })
  236. .then((res) => {
  237. _this.peopleNum = res.data + 57000
  238. });
  239. },
  240. payEnsure() {
  241. // console.log(11111)
  242. this.$refs.popup.open();
  243. },
  244. uncompleteHandle() {
  245. this.$refs.popup.close();
  246. },
  247. completeHandle() {
  248. uni.showLoading({
  249. title: ''
  250. });
  251. this.checkOrder();
  252. },
  253. // 查询优惠信息
  254. queryPromotion() {
  255. let _this = this;
  256. _this.$request
  257. .get({
  258. url: `api/promotionInfo/queryPromotionDetail/${this.orderInfo.productId}`,
  259. loadingTip: "加载中...",
  260. data: {},
  261. })
  262. .then((res) => {
  263. this.residueNum = res.data.residueNum
  264. this.price = res.data.price;
  265. this.promotionPrice = res.data.promotionPrice;
  266. this.promotionEndTime = new Date(res.data.promotionEndTime).getTime()
  267. this.getDhms();
  268. uni.hideLoading();
  269. });
  270. },
  271. // 获取天时分秒
  272. getDhms() {
  273. let timeSpan = this.promotionEndTime - new Date().getTime();
  274. let time = timestampFormatter(timeSpan);
  275. this.testHour = time.h;
  276. this.testMinute = time.m;
  277. this.testSecond = time.s;
  278. this.start = true;
  279. }
  280. }
  281. }
  282. </script>
  283. <style scoped>
  284. .payment_bg {
  285. width: 100%;
  286. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/payment_bg.png) no-repeat top;
  287. background-size: 100% auto;
  288. overflow: hidden;
  289. padding-bottom: 311rpx;
  290. }
  291. .payment_info {
  292. width: 750rpx;
  293. height: 531rpx;
  294. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/paymentPage/pay_scale_info.png) no-repeat center;
  295. background-size: cover;
  296. position: relative;
  297. margin-top: 143rpx;
  298. overflow: hidden;
  299. }
  300. .payment_info image {
  301. width: 100%;
  302. height: auto;
  303. margin-top: 134rpx;
  304. }
  305. .payment_info .pay_btn_sm {
  306. width: 640rpx;
  307. height: 73rpx;
  308. line-height: 73rpx;
  309. position: absolute;
  310. left: 55rpx;
  311. bottom: 73rpx;
  312. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/pay_button.png) no-repeat center;
  313. background-size: 100% auto;
  314. font-family: 'Alibaba PuHuiTi 2.0';
  315. font-weight: bold;
  316. font-size: 36rpx;
  317. color: #FFFFFF;
  318. text-shadow: 0rpx 0rpx 5rpx rgba(168, 63, 90, 0.5);
  319. text-align: center;
  320. }
  321. .payment_desc image {
  322. width: 750rpx;
  323. }
  324. .pay_btn_lg {
  325. width: 640rpx;
  326. height: 73rpx;
  327. line-height: 73rpx;
  328. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/pay_button.png) no-repeat center;
  329. background-size: 100% auto;
  330. font-family: 'Alibaba PuHuiTi 2.0';
  331. font-weight: bold;
  332. font-size: 36rpx;
  333. color: #FFFFFF;
  334. text-shadow: 0rpx 0rpx 5rpx rgba(168, 63, 90, 0.5);
  335. text-align: center;
  336. margin: 20rpx auto 60rpx;
  337. }
  338. .pay_dialog {
  339. width: 594rpx;
  340. height: 360rpx;
  341. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/dialog_bg.png) no-repeat top;
  342. background-size: cover;
  343. position: fixed;
  344. top: 540rpx;
  345. left: 50%;
  346. transform: translate(-50%, -50%);
  347. }
  348. .btn_area {
  349. margin: 240rpx 0 0 96rpx;
  350. }
  351. .btn_area image {
  352. width: 160rpx;
  353. }
  354. .btn_area image:active {
  355. border: 1rpx solid #999999;
  356. opacity: 0.8;
  357. border-radius: 28rpx;
  358. }
  359. .people_num {
  360. margin-top: 177rpx;
  361. }
  362. .people_num text {
  363. min-width: 157rpx;
  364. height: 44rpx;
  365. padding: 0 10rpx;
  366. background: #FFEDF1;
  367. border-radius: 22rpx;
  368. font-family: 'Alibaba PuHuiTi 2.0';
  369. font-size: 28rpx;
  370. color: #FC716D;
  371. line-height: 44rpx;
  372. text-align: center;
  373. margin-left: 373rpx;
  374. }
  375. .price_num {
  376. margin-top: 72rpx;
  377. }
  378. .price_num text {
  379. min-width: 74rpx;
  380. font-family: 'Alibaba PuHuiTi 2.0';
  381. font-weight: normal;
  382. font-size: 32rpx;
  383. color: #FC716D;
  384. line-height: 24rpx;
  385. margin-left: 374rpx;
  386. }
  387. .top_footer {
  388. width: 750rpx;
  389. height: 261rpx;
  390. background: #FFFFFF;
  391. padding-bottom: 20rpx;
  392. position: fixed;
  393. bottom: 0;
  394. }
  395. .pay_price {
  396. box-sizing: border-box;
  397. display: flex;
  398. justify-content: space-between;
  399. align-items: center;
  400. width: 100%;
  401. padding: 10px 50rpx 0 50rpx;
  402. }
  403. .pay_price_y {
  404. background-color: #fe605f;
  405. margin-left: 20px;
  406. margin-right: 5px;
  407. color: #ffffff;
  408. }
  409. .pay_price_p {
  410. font-size: 32rpx;
  411. font-family: Source Han Sans-Bold, Source Han Sans;
  412. font-weight: 700;
  413. color: #f94206;
  414. /* line-height: 38px; */
  415. margin-left: 10px;
  416. }
  417. .radio_class {
  418. display: flex;
  419. background-color: #ffffff;
  420. margin-bottom: 10px;
  421. padding-left: 10px;
  422. padding-right: 10px;
  423. padding-top: 5px;
  424. border-radius: 5px;
  425. padding-bottom: 5px;
  426. align-items: center;
  427. }
  428. .radio_class_1 {
  429. display: flex;
  430. justify-content: space-around;
  431. }
  432. .pay_title {
  433. text-align: center;
  434. /* margin-top:38px; */
  435. font-size: 20px;
  436. font-family: AlibabaPuHuiTi-Heavy, AlibabaPuHuiTi;
  437. font-weight: 900;
  438. color: #500000;
  439. line-height: 101px;
  440. }
  441. .top_page_yh {
  442. font-size: 14px;
  443. font-family: Source Han Sans-Regular, Source Han Sans;
  444. font-weight: 400;
  445. color: #656c74;
  446. line-height: 20px;
  447. }
  448. .main_scale_gmcp {
  449. display: flex;
  450. justify-content: center;
  451. align-items: center;
  452. }
  453. .main_scale_font_gmcp {
  454. font-size: 16px;
  455. font-family: Source Han Sans-Medium, Source Han Sans;
  456. font-weight: 700;
  457. color: #040000;
  458. }
  459. .main_xing_left {
  460. height: 30px;
  461. width: 20px;
  462. margin-right: 20px;
  463. }
  464. .main_xing_right {
  465. height: 30px;
  466. width: 20px;
  467. margin-left: 20px;
  468. }
  469. .scale_gmcp_connent {
  470. margin-top: 10px;
  471. background-color: #ffffff;
  472. border-radius: 10px 10px 10px 10px;
  473. opacity: 1;
  474. padding: 24px 15px;
  475. margin-bottom: 200px;
  476. overflow-y: scroll;
  477. }
  478. .pub_time {
  479. margin-top: 5px;
  480. font-size: 12px;
  481. font-family: Source Han Sans-Regular, Source Han Sans;
  482. font-weight: 400;
  483. color: #c4c4c4;
  484. line-height: 17px;
  485. }
  486. .pub_connnet {
  487. font-size: 14px;
  488. font-family: Source Han Sans-Regular, Source Han Sans;
  489. font-weight: 400;
  490. color: #3d3d3d;
  491. line-height: 20px;
  492. }
  493. .people_sy {
  494. font-size: 14px;
  495. font-family: Source Han Sans-Regular, Source Han Sans;
  496. font-weight: 400;
  497. color: #656c74;
  498. line-height: 20px;
  499. margin-left: 4px;
  500. }
  501. .people_sy_time {
  502. font-family: 'Alibaba PuHuiTi 2.0';
  503. font-weight: normal;
  504. font-size: 32rpx;
  505. color: #333333;
  506. line-height: 16rpx;
  507. display: flex;
  508. margin-right: 4px;
  509. display: flex;
  510. justify-content: center;
  511. align-items: center;
  512. }
  513. .time_ol {
  514. background: linear-gradient(270deg, #ff9d41 0%, #fc3c3c 100%);
  515. border-radius: 4px 4px 4px 4px;
  516. padding: 2px;
  517. color: #ffffff;
  518. }
  519. .time_mao {
  520. color: #ff9d41;
  521. }
  522. .pro_tag {
  523. height: 62rpx;
  524. padding: 0 20rpx;
  525. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Charm/paymentPage/price_bg.png) no-repeat center;
  526. border-radius: 40rpx 40rpx 40rpx 40rpx;
  527. margin-left: 16rpx;
  528. color: #ffffff;
  529. display: flex;
  530. align-items: center;
  531. font-family: 'Alibaba PuHuiTi 2.0';
  532. font-weight: normal;
  533. font-size: 24rpx;
  534. color: #FFFFFF;
  535. .price {
  536. font-family: 'Alibaba PuHuiTi 2.0';
  537. font-weight: bold;
  538. font-size: 40rpx;
  539. color: #FFFFFF;
  540. line-height: 16rpx;
  541. }
  542. }
  543. </style>