purchase.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <template>
  2. <div class="purchase-page">
  3. <div class="j-main exchange_main">
  4. <div class="docs_infor">
  5. <div class="docs_left">
  6. <img :src="response.previewImgId" class="docs_img" alt="">
  7. <span class="icon_word"></span>
  8. </div>
  9. <div class="docs_right">
  10. <div class="docs_title ellipsis-2">
  11. {{response.docName}}
  12. </div>
  13. <div class="docs_other">
  14. <!-- <div class="docs_auther">贡献者:张三</div> -->
  15. <div class="docs_download">
  16. <span>{{response.downTimes}}次下载</span> | 共{{response.docPageSize}}页 | {{response.docFileSize}}K
  17. </div>
  18. <div class="docs_money"><span class="docs_num">{{response.price}}</span> 剑鱼币</div>
  19. </div>
  20. </div>
  21. </div>
  22. <div class="rechargehave_pay_content">
  23. <div class="pay_title">
  24. 支付方式
  25. </div>
  26. <div class="jianyu_pay">
  27. <div class="jy_pay_left">
  28. <span class="jy_money">剑鱼币</span>
  29. <span class="jy_tip">(剩余{{response.balance}}剑鱼币)</span>
  30. </div>
  31. <div class="jy_pay_icon">
  32. <img src="../../assets/icon/checked.png" class="icon_right_option" />
  33. </div>
  34. </div>
  35. </div>
  36. <div class="docs_phone">
  37. <!-- <van-cell-group>
  38. <van-field v-model="tel" type="number" label="手机号码" placeholder="请输入手机号码" />
  39. </van-cell-group> -->
  40. <van-field
  41. class="editable"
  42. v-model="tel"
  43. name="phone"
  44. type="tel"
  45. label="手机号码"
  46. placeholder="请输入手机号码"
  47. :rules="phoneRules"
  48. />
  49. </div>
  50. </div>
  51. <div class="j-footer exchange_footer">
  52. <div class="apply_detail">
  53. <div class="det_left">
  54. 支付积分:
  55. </div>
  56. <div class="det_right">
  57. <span class="det_money">{{response.price}}</span>
  58. <span>剑鱼币</span>
  59. </div>
  60. </div>
  61. <div class="readly">
  62. <van-checkbox v-model="checked" checked-color="#2ABED1" >我已阅读并同意<a href="javascript:;" class="clause" @click="clause()">《剑鱼文库线上购买及服务条款》</a><a href="javascript:;" class="clause" @click="clause2()">《剑鱼标讯产品与服务线上购买服务条款》</a></van-checkbox>
  63. </div>
  64. <div class="apply_footer">
  65. <button class="apply_button" :disabled="!this.checked" @click="exchange()">确定兑换</button>
  66. </div>
  67. </div>
  68. </div>
  69. </template>
  70. <script lang="ts">
  71. import { Component, Vue } from 'vue-property-decorator'
  72. import { Checkbox, CheckboxGroup, Field, CellGroup } from 'vant'
  73. import { mapActions } from 'vuex'
  74. // import { getDocPay } from '../../api/main'
  75. const regPhoneExg = /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57]|19[0-9])[0-9]{8}$/
  76. @Component({
  77. name: 'purchase-page',
  78. components: {
  79. [Checkbox.name]: Checkbox,
  80. [CheckboxGroup.name]: CheckboxGroup,
  81. [Field.name]: Field,
  82. [CellGroup.name]: CellGroup
  83. },
  84. methods: {
  85. ...mapActions({
  86. getDocPay: 'main/getDocPay',
  87. getDetails: 'main/getDetails',
  88. getListDetail: 'main/getListDetail'
  89. })
  90. }
  91. })
  92. export default class extends Vue {
  93. protected getDocPay!: any
  94. protected getDetails!: any
  95. protected getListDetail!: any
  96. checked = false
  97. tel = ''
  98. query: any
  99. $router: any
  100. response = {
  101. docName: '',
  102. price: '',
  103. downTimes: '',
  104. docFileSize: '',
  105. docPageSize: '',
  106. previewImgId: '',
  107. balance: ''
  108. }
  109. created () {
  110. this.query = location.href.split('/')[location.href.split('/').length - 1] // 获取id
  111. this.getWordInfor()
  112. }
  113. // 文档信息
  114. async getWordInfor () {
  115. this.getDetails({ docId: this.query }).then((res: any) => {
  116. console.log(res)
  117. const item = res.data.detail
  118. if (res.error_code === 0) {
  119. this.response.docName = item.docName
  120. this.response.price = item.price
  121. this.response.downTimes = item.downTimes
  122. this.response.docFileSize = item.docFileSize
  123. this.response.docPageSize = item.docPageSize
  124. this.response.previewImgId = item.previewImgId
  125. }
  126. })
  127. this.getListDetail({ B: true }).then((res: any) => {
  128. console.log(res)
  129. if (res.error_code === 0) {
  130. this.response.balance = res.points.balance
  131. }
  132. })
  133. }
  134. // 确定兑换
  135. exchange () {
  136. this.getDocPay({ docId: this.query, phone: this.tel }).then((res: any) => {
  137. console.log(res)
  138. if (res.error_code === 0) {
  139. sessionStorage.setItem('paydata', JSON.stringify(res.data))
  140. this.$router.push('/purchasesuccess')
  141. }
  142. })
  143. }
  144. phoneRules = [{
  145. validator: (val: string) => {
  146. const status = regPhoneExg.test(val)
  147. if (val === '') {
  148. console.log(true)
  149. return true
  150. }
  151. return status
  152. },
  153. message: '手机号格式错误'
  154. }]
  155. // 剑鱼文库线上购买及服务条款
  156. clause () {
  157. this.$router.push('/onlineterm')
  158. }
  159. // 剑鱼标讯产品与服务线上购买服务条款
  160. clause2 () {
  161. // app:https://app-a2.jianyu360.com/jyapp/front/staticPage/dataExport_serviceterms.html
  162. // this.$router.push('/readme')
  163. // wx:https://www.jianyu360.com/front/staticPage/wx-serviceterms.html
  164. }
  165. }
  166. </script>
  167. <style lang="scss">
  168. .purchase-page{
  169. box-sizing: border-box;
  170. background: #F5F6F7;
  171. .exchange_main{
  172. .docs_infor{
  173. display: flex;
  174. justify-content: space-between;
  175. align-items: flex-start;
  176. padding: 20px 16px;
  177. background: #ffffff;
  178. .docs_left{
  179. position: relative;
  180. width: 100px;
  181. height: 124px;
  182. border-radius: 4px;
  183. border: 1px solid #000000;
  184. .docs_img{
  185. width: 100%;
  186. height: 100%;
  187. }
  188. .icon_word{
  189. position: absolute;
  190. right: 0;
  191. bottom: 0;
  192. display: flex;
  193. width: 24px;
  194. height: 24px;
  195. background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJASURBVHgB7Zm/TuQwEMY/J5x016B7gC2oqbju2muuuOoKClooqEGiodliGxokqLdYXoACWireACpqin0ARAMCEvONcXaXf+sQjTdI+CclTuKJM+NMnBkbSCQSiTYxdYS+79gFCh7wcInbT8TG4MhabN5um8uwaACv/BlmofhzrizwK2TEHAIYgz1YKm9wmN2hV2S4RkRMhg6LDT5v2b/1P9PkM4Sw+O/KEvuxlXePKzEsHtDzp0sh+bABEw1jRmTjjgq6bW0DPivJgLZJBrRN8D/wHibHZXVsCyygARptJBdqm2RA20QzwAVlOfosd/MS84hE41EoBKPYPotFCdjtN5YF/iECUd6A9LoV5T1yLNcQAXUDqKiL5V9XML6XOmVUDfDKj5Sk9wzY+4OxAOsyrEERtW+AMfxfO6E8FT/h3/UpMcmdO/2WQ34bXZ5fs+4QCqi8ASq+WJpnPj7M77FVnRT3WKdBFyN5oCv3QAEVA9j7fbpLNVQOqeHKZPopGZaxWHd1cK41L/dAAa1voONLp/xb6ae7JnUYGdaBAqofcVnSVabkzlLHbQWKqBnAiage3eQiJOdltqCEjgEG+5x2GdQVdyOQ3KNAcwMqBVjah48r4+6ZaAMNCU4t/tihc6B5xtSUKlu72TZTdUzhdNt8CQOuZBczKXmJn6GuRR0DzmVXzqH7kYab4juqCgqPQ/LBaJRD0Kpb4HiK8Zc5OkSlHLcvCxzB/CH4BmSFRFZKGG0eYTaI4qd1VmcSiUSifR4BOQuhbc3lgT4AAAAASUVORK5CYII=) no-repeat;
  196. background-size: contain;
  197. }
  198. }
  199. .docs_right{
  200. flex: 1;
  201. margin-left: 16px;
  202. .docs_title{
  203. color: #171826;
  204. font-weight: bold;
  205. font-size: 14px;
  206. line-height: 20px;
  207. letter-spacing: 0px;
  208. text-align: left;
  209. }
  210. .docs_other{
  211. margin-top: 22px;
  212. color: #9B9CA3;
  213. font-weight: medium;
  214. font-size: 12px;
  215. line-height: 18px;
  216. letter-spacing: 0px;
  217. text-align: left;
  218. .docs_download{
  219. line-height: 18px;
  220. }
  221. .docs_money{
  222. margin-top: 2px;
  223. line-height: 24px;
  224. .docs_num{
  225. font-size: 16px;
  226. }
  227. }
  228. }
  229. }
  230. }
  231. .rechargehave_pay_content{
  232. padding: 0 16px;
  233. margin-top: 8px;
  234. width: 100%;
  235. height: 100px;
  236. box-sizing: border-box;
  237. border-bottom: 1px solid rgba($color: #000000, $alpha: 0.05);
  238. background: #ffffff;
  239. .pay_title{
  240. margin-top: 16px;
  241. width: 100%;
  242. height: 24px;
  243. color: #171826;
  244. font-size: 16px;
  245. line-height: 24px;
  246. }
  247. .jianyu_pay{
  248. display: flex;
  249. justify-content: space-between;
  250. align-items: center;
  251. margin-top: 24px;
  252. width: 100%;
  253. height: 20px;
  254. color: #171826;
  255. font-size: 14px;
  256. line-height: 20px;
  257. .jy_pay_left{
  258. .jy_tip{
  259. color: #2abed1;
  260. }
  261. }
  262. .jy_pay_icon{
  263. width: 24px;
  264. height: 24px;
  265. .icon_right_option{
  266. width: 100%;
  267. height: 100%;
  268. }
  269. }
  270. }
  271. }
  272. .docs_phone {
  273. padding: 15px 0;
  274. width: 100%;
  275. .van-field__control{
  276. font-size: 16px;
  277. }
  278. .van-field__control::placeholder {
  279. color: #C0C4CC;
  280. font-weight: medium;
  281. font-size: 16px;
  282. line-height: 24px;
  283. }
  284. }
  285. }
  286. .exchange_footer{
  287. padding: 0 16px;
  288. height: 148px;
  289. background: #ffffff;
  290. .apply_detail{
  291. display: flex;
  292. justify-content: space-between;
  293. align-items: center;
  294. height: 38px;
  295. .det_left{
  296. color: #9B9CA3;
  297. font-family: PingFang SC;
  298. font-weight: medium;
  299. font-size: 12px;
  300. line-height: 18px;
  301. }
  302. .det_right{
  303. display: flex;
  304. align-items: center;
  305. color: #2ABED1;
  306. font-weight: medium;
  307. font-size: 14px;
  308. line-height: 30px;
  309. .det_money{
  310. display: flex;
  311. margin-right: 4px;
  312. font-size: 20px;
  313. }
  314. }
  315. }
  316. .apply_footer {
  317. display: flex;
  318. align-items: center;
  319. justify-content: center;
  320. height: 46px;
  321. padding: 8px 0 12px;
  322. background: rgba(255, 255, 255, 0.96);
  323. }
  324. .apply_button {
  325. width: 100%;
  326. height: 46px;
  327. border-radius: 8px;
  328. background: #2abed1;
  329. font-size: 18px;
  330. color: #f7f9fa;
  331. }
  332. .readly{
  333. display:flex;
  334. align-items:center;
  335. min-height:32px;
  336. font-size: 12px;
  337. color: #5F5E64;
  338. .clause{
  339. color:#2ABED1;
  340. }
  341. .van-checkbox__icon{
  342. font-size:18px;
  343. }
  344. }
  345. }
  346. }
  347. </style>