index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. <template>
  2. <div class="pay-layout">
  3. <div class="pay-header">
  4. <div class="h-left">
  5. <img :src="language==='en'?`${$cdn}images/logo-black-en.png`:`${$cdn}images/logo-black.png`" alt>
  6. <span class="h-line"></span>
  7. <span>{{languagePay.paycenter}}</span>
  8. </div>
  9. <div class="h-right">{{languagePay.name}}{{info.userName}}</div>
  10. </div>
  11. <div class="pay-con">
  12. <div class="pay-left">
  13. <div class="mid">
  14. <div class="attr">{{languagePay.method}}</div>
  15. <div class="body">
  16. <div class="pay-tag" :class="{'tag-active':paytype==='alipay'}" @click="paytype='alipay'">
  17. <img :src="`${$cdn}images/ali-pay.png`" class="t-icon" alt>
  18. <span>{{languagePay.ali}}</span>
  19. <img :src="`${$cdn}images/tag-icon.png`" class="t-click" alt>
  20. </div>
  21. <div class="pay-tag" :class="{'tag-active':paytype==='wechatPay'}" @click="paytype='wechatPay'">
  22. <img :src="`${$cdn}images/wechat-pay.png`" class="t-icon" alt>
  23. <span>{{languagePay.wechatpay}}</span>
  24. <img :src="`${$cdn}images/tag-icon.png`" class="t-click" alt>
  25. </div>
  26. </div>
  27. </div>
  28. <div class="bottom">
  29. <div class="attr">{{languagePay.amount}}</div>
  30. <div class="price-detail">
  31. <img class="scanicon" :src="language==='en'?`${$cdn}images/scanicon-en.png`:`${$cdn}images/scanicon.png`" alt="">
  32. <div class="price">¥{{response.price}}</div>
  33. <img v-if="response.src" :src="`${$serverName}${response.src}`" alt="">
  34. <div class="dec">{{languagePay.use1}}<span style="color:#ff0000">{{payZH}}</span>{{languagePay.use2}}</div>
  35. </div>
  36. </div>
  37. </div>
  38. <!-- <div class="pay-right">
  39. <p class="p-title">功能卓越</p>
  40. <ul class="pay-icon">
  41. <li v-for="(item,i) in payicon" :key="i">
  42. <img :src="item.img" >
  43. <p>{{item.name}}</p>
  44. </li>
  45. </ul>
  46. </div> -->
  47. </div>
  48. </div>
  49. </template>
  50. <script>
  51. import { mapState } from 'vuex'
  52. let payTypes = {
  53. wechatPay: '微信',
  54. alipay: '支付宝',
  55. paypal: 'paypal'
  56. }
  57. let payTypesEn = {
  58. wechatPay: 'Wechat',
  59. alipay: 'Alipay',
  60. paypal: 'paypal'
  61. }
  62. let PAYS = {
  63. 0: 'wechatPay',
  64. 1: 'alipay',
  65. 2: 'paypal'
  66. }
  67. let PAYSID = {
  68. wechatPay: 0,
  69. alipay: 1,
  70. paypal: 2
  71. }
  72. export default {
  73. data () {
  74. let payicon = [{
  75. img: this.$cdn + 'images/paylogo1.png',
  76. name: '轻松操作高效建模'
  77. }, {
  78. img: this.$cdn + 'images/paylogo2.png',
  79. name: '高精还原空间漫游'
  80. }, {
  81. img: this.$cdn + 'images/paylogo3.png',
  82. name: '室内外皆可拍摄'
  83. }, {
  84. img: this.$cdn + 'images/paylogo4.png',
  85. name: '自由编辑随时更新'
  86. }]
  87. return {
  88. payicon,
  89. privilege: 'year',
  90. response: '',
  91. t1: null,
  92. paytype: PAYS[this.$route.params.payType]
  93. }
  94. },
  95. computed: {
  96. ...mapState({
  97. language: state => state.language.current,
  98. languagePay: state => state.language.home.paypage,
  99. token: state => state.user.token,
  100. info: state => state.user.info,
  101. langToast: state => state.language.home.toast
  102. }),
  103. payZH () {
  104. return this.language === 'en' ? payTypesEn[this.paytype] : payTypes[this.paytype]
  105. }
  106. },
  107. watch: {
  108. paytype (newVal, oldVal) {
  109. this.getCode()
  110. }
  111. },
  112. mounted () {
  113. this.getCode()
  114. },
  115. methods: {
  116. inverRequest () {
  117. clearInterval(this.t1)
  118. this.t1 = null
  119. this.t1 = setInterval(() => {
  120. this.queryOrderStatus()
  121. }, 5000)
  122. },
  123. async queryOrderStatus () {
  124. if (this.t1) {
  125. let {orderSn, orderType} = this.$route.params
  126. if (!orderSn) {
  127. return this.$toast.show('error', this.langToast['1'])
  128. }
  129. let params = {
  130. orderSn,
  131. orderType: Number(orderType),
  132. payType: Number(PAYSID[this.paytype])
  133. }
  134. let res = await this.$http
  135. .post('/user/order/queryOrderStatus', params, {
  136. headers: {
  137. token: this.token
  138. }
  139. })
  140. let response = res.data
  141. if (response.code === 0 && response.data) {
  142. this.t1 = null
  143. this.t1 && clearInterval(this.t1)
  144. this.$router.replace({
  145. name: 'payresult',
  146. params: {
  147. isSuccess: 'success'
  148. }
  149. })
  150. }
  151. }
  152. },
  153. async getCode () {
  154. let {orderId, orderType} = this.$route.params
  155. if (!orderId || (!orderType && orderType !== 0)) {
  156. return this.$toast.show('error', this.langToast['1'])
  157. }
  158. if (this.paytype !== 'paypal') {
  159. let params = {
  160. orderId: orderId,
  161. orderType: Number(orderType)
  162. }
  163. let res = await this.$http
  164. .post(`/order/pay/${this.paytype}`, params, {
  165. headers: {
  166. token: this.token
  167. }
  168. })
  169. let response = res.data
  170. if (response.code !== 0) {
  171. return this.$toast.show('error', this.langToast['2'], () => {
  172. this.t1 = null
  173. this.t1 && clearInterval(this.t1)
  174. })
  175. }
  176. this.response = response.data
  177. this.inverRequest()
  178. } else {
  179. this.t1 = null
  180. this.t1 && clearInterval(this.t1)
  181. this.$toast.show('warn', this.langToast['3'])
  182. }
  183. }
  184. },
  185. beforeDestroy () {
  186. clearInterval(this.t1)
  187. this.t1 = null
  188. }
  189. }
  190. </script>
  191. <style lang="scss" scoped>
  192. $theme-color: #1fe4dc;
  193. .pay-layout {
  194. width: 700px;
  195. min-height: 74vh;
  196. margin: 25px auto;
  197. .pay-header {
  198. width: 100%;
  199. margin-bottom: 20px;
  200. display: flex;
  201. align-items: flex-start;
  202. flex-direction: column;
  203. .h-left {
  204. display: flex;
  205. justify-content: space-between;
  206. align-items: center;
  207. .h-line {
  208. width: 1px;
  209. height: 20px;
  210. background: #000;
  211. margin: 0 10px;
  212. display: inline-block;
  213. }
  214. span {
  215. font-size: 20px;
  216. color: #2d2d2d;
  217. }
  218. }
  219. .h-right {
  220. font-size: 14px;
  221. color: #2d2d2d;
  222. margin-top: 20px;
  223. }
  224. }
  225. .pay-con {
  226. background: #f4f4f4;
  227. padding: 40px;
  228. display: flex;
  229. justify-content: space-between;
  230. margin-bottom: 80px;
  231. .pay-left {
  232. .top,
  233. .mid,
  234. .bottom {
  235. display: flex;
  236. margin-bottom: 50px;
  237. .attr {
  238. font-size: 14px;
  239. color: #2d2d2d;
  240. }
  241. .val {
  242. display: flex;
  243. align-items: center;
  244. margin-left: 20px;
  245. .tag {
  246. height: 100%;
  247. font-size: 0;
  248. margin-right: 50px;
  249. display: flex;
  250. align-items: center;
  251. border: 1px solid #f4f4f4;
  252. position: relative;
  253. .year {
  254. width: 52px;
  255. height: 48px;
  256. line-height: 48px;
  257. text-align: center;
  258. display: inline-block;
  259. background: #ededed;
  260. color: #777777;
  261. font-size: 14px;
  262. flex-shrink: 0;
  263. }
  264. .price {
  265. background: #fff;
  266. height: 48px;
  267. width: 160px;
  268. line-height: 48px;
  269. display: inline-block;
  270. font-size: 18px;
  271. color: #ff0000;
  272. text-align: center;
  273. .per {
  274. font-size: 12px;
  275. margin-left: 20px;
  276. color: #777777;
  277. }
  278. }
  279. img {
  280. position: absolute;
  281. bottom: 0;
  282. right: 0;
  283. width: 14px;
  284. }
  285. }
  286. .tag-active {
  287. border: 1px solid $theme-color;
  288. box-sizing: border-box;
  289. }
  290. }
  291. .body {
  292. margin-left: 20px;
  293. .pay-tag {
  294. cursor: pointer;
  295. border: 1px solid #e7e7e7;
  296. width: 200px;
  297. line-height: 36px;
  298. height: 36px;
  299. margin-bottom: 20px;
  300. position: relative;
  301. span {
  302. margin-left: 36px;
  303. display: inline-block;
  304. text-align: center;
  305. padding-left: 60px;
  306. }
  307. img {
  308. position: absolute;
  309. }
  310. .t-icon {
  311. width: 36px;
  312. height: 36px;
  313. padding: 6px;
  314. left: 0;
  315. border-right: 1px solid #e7e7e7;
  316. }
  317. .t-click {
  318. right: 0;
  319. bottom: 0;
  320. display: none;
  321. }
  322. }
  323. .paypal-con{
  324. position: relative;
  325. .form-con{
  326. opacity: 0;
  327. input[type='text']{
  328. width: 1px;
  329. height: 1px;
  330. position: absolute;
  331. top: 0;
  332. opacity: 0;
  333. left: 0;
  334. }
  335. input[type='submit']{
  336. width: 100%;
  337. position: absolute;
  338. top: 0;
  339. left: 0;
  340. opacity: 0;
  341. height: 100%;
  342. }
  343. }
  344. }
  345. .tag-active {
  346. border: 1px solid $theme-color;
  347. span {
  348. color: #000;
  349. }
  350. .t-icon {
  351. border-right: 1px solid $theme-color;
  352. }
  353. .t-click {
  354. display: inline-block;
  355. }
  356. }
  357. }
  358. .price-detail{
  359. margin-left: 6px;
  360. text-align: center;
  361. position: relative;
  362. width: 165px;
  363. top: -15px;
  364. .price{
  365. font-size: 30px;
  366. color: #ff0000;
  367. margin: 0 0 0 8px;
  368. text-align: left;
  369. padding: 0;
  370. margin-bottom: 24px;
  371. }
  372. .sao{
  373. font-size: 14px;
  374. color: #2d2d2d;
  375. margin-bottom: 5px;
  376. }
  377. .dec{
  378. color: #2d2d2d;
  379. font-size: 12px;
  380. margin-top: 10px;
  381. }
  382. img{
  383. width: 130px;
  384. box-shadow: 0 0 10px rgba(0,0,0,0.2);
  385. height: 130px;
  386. }
  387. .scanicon{
  388. position: absolute;
  389. left: 180px;
  390. width: 200px;
  391. top: 30px;
  392. height: auto;
  393. box-shadow:none;
  394. }
  395. }
  396. }
  397. .bottom {
  398. margin-bottom: 0;
  399. }
  400. .mid{
  401. margin-bottom: 40px;
  402. }
  403. }
  404. .pay-right {
  405. text-align: center;
  406. border-left: 1px solid #e5e5e5;
  407. padding-left: 28px;
  408. .p-title{
  409. font-size: 20px;
  410. color: #777777;
  411. }
  412. .pay-icon{
  413. margin-top: 20px;
  414. img{
  415. margin: 15px 0;
  416. }
  417. p{
  418. color: #969696;
  419. font-size: 14px;
  420. }
  421. }
  422. .pay-detail{
  423. height: 28px;
  424. margin: 90px 0 20px;
  425. cursor: pointer;
  426. line-height: 28px;
  427. font-size: 14px;
  428. color: #777777;
  429. width: 128px;
  430. border: 1px solid #e5e5e5;
  431. }
  432. }
  433. }
  434. .pay-bottom{
  435. color: #969696;
  436. font-size: 12px;
  437. text-align: center;
  438. margin-top: 20px;
  439. }
  440. }
  441. </style>