purchase.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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-form validate-first>
  38. <van-field
  39. class="editable"
  40. v-model="tel"
  41. name="validator"
  42. type="tel"
  43. label="手机号码"
  44. placeholder="请输入手机号码"
  45. @input="iptValue()"
  46. :rules="[{ validator, message: '手机号格式错误' }]"
  47. />
  48. </van-form>
  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" @click="checkBtn()">我已阅读并同意<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.btnChecked" @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, Form } from 'vant'
  73. import { mapActions } from 'vuex'
  74. import { isWeiXinBrowser, formatSize } from '../../utils/globalFunctions'
  75. @Component({
  76. name: 'purchase-page',
  77. components: {
  78. [Checkbox.name]: Checkbox,
  79. [CheckboxGroup.name]: CheckboxGroup,
  80. [Field.name]: Field,
  81. [Form.name]: Form,
  82. [CellGroup.name]: CellGroup
  83. },
  84. methods: {
  85. ...mapActions({
  86. getDocPay: 'main/getDocPay',
  87. getDetails: 'main/getDetails',
  88. getListDetail: 'main/getListDetail',
  89. getAccountInfo: 'main/getAccountInfo'
  90. })
  91. }
  92. })
  93. export default class extends Vue {
  94. protected getDocPay!: any
  95. protected getDetails!: any
  96. protected getListDetail!: any
  97. protected getAccountInfo!: any
  98. checked = false
  99. btnChecked = false
  100. tel = ''
  101. regPhoneExg = /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57]|19[0-9])[0-9]{8}$/
  102. query: any
  103. $router: any
  104. response = {
  105. docName: '',
  106. price: '',
  107. downTimes: '',
  108. docFileSize: '',
  109. docPageSize: '',
  110. previewImgId: '',
  111. balance: ''
  112. }
  113. created () {
  114. this.query = location.href.split('/')[location.href.split('/').length - 1] // 获取id
  115. this.getWordInfor()
  116. this.getBindPhone()
  117. }
  118. validator (val: any) {
  119. if (this.tel === '') {
  120. return true
  121. }
  122. return this.regPhoneExg.test(val)
  123. }
  124. checkBtn () {
  125. this.getBool(this.validator(this.tel))
  126. }
  127. // 判断按钮是否可以点击
  128. iptValue () {
  129. let bool = this.validator(this.tel)
  130. if (this.tel === '') {
  131. bool = true
  132. } else {
  133. bool = false
  134. }
  135. this.getBool(this.validator(this.tel))
  136. }
  137. getBool (bool) {
  138. if (this.checked === true && bool === true) {
  139. this.btnChecked = true
  140. } else {
  141. this.btnChecked = false
  142. }
  143. }
  144. // 获取绑定的手机号
  145. getBindPhone () {
  146. this.getAccountInfo().then((res: any) => {
  147. console.log(res)
  148. this.tel = res.data.phone
  149. })
  150. }
  151. // 文档信息
  152. async getWordInfor () {
  153. this.getDetails({ docId: this.query }).then((res: any) => {
  154. console.log(res)
  155. const item = res.data.detail
  156. if (res.error_code === 0) {
  157. this.response.docName = item.docName
  158. this.response.price = item.price
  159. this.response.downTimes = item.downTimes
  160. this.response.docFileSize = formatSize(item.docFileSize)
  161. this.response.docPageSize = item.docPageSize
  162. this.response.previewImgId = item.previewImgId
  163. }
  164. })
  165. this.getListDetail({ B: true }).then((res: any) => {
  166. console.log(res)
  167. if (res.error_code === 0) {
  168. console.log(111)
  169. this.response.balance = res.data.points.balance
  170. }
  171. })
  172. }
  173. // 确定兑换
  174. exchange () {
  175. this.getDocPay({ docId: this.query, phone: this.tel }).then((res: any) => {
  176. console.log(res)
  177. if (res.error_code === 0) {
  178. sessionStorage.setItem('paydata', JSON.stringify(res.data))
  179. this.$router.push('/purchasesuccess' + this.response.balance)
  180. }
  181. })
  182. }
  183. // 剑鱼文库线上购买及服务条款
  184. clause () {
  185. this.$router.push('/onlineterm')
  186. }
  187. // 剑鱼标讯产品与服务线上购买服务条款
  188. clause2 () {
  189. if (!isWeiXinBrowser) {
  190. location.href = '/front/staticPage/wx-serviceterms.html'
  191. } else {
  192. location.href = '/jyapp/front/staticPage/dataExport_serviceterms.html'
  193. }
  194. }
  195. }
  196. </script>
  197. <style lang="scss">
  198. .purchase-page{
  199. box-sizing: border-box;
  200. background: #F5F6F7;
  201. .exchange_main{
  202. .docs_infor{
  203. display: flex;
  204. justify-content: space-between;
  205. align-items: flex-start;
  206. padding: 20px 16px;
  207. background: #ffffff;
  208. .docs_left{
  209. position: relative;
  210. width: 100px;
  211. height: 124px;
  212. border-radius: 4px;
  213. border: 1px solid #000000;
  214. .docs_img{
  215. width: 100%;
  216. height: 100%;
  217. }
  218. .icon_word{
  219. position: absolute;
  220. right: 0;
  221. bottom: 0;
  222. display: flex;
  223. width: 24px;
  224. height: 24px;
  225. 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;
  226. background-size: contain;
  227. }
  228. }
  229. .docs_right{
  230. flex: 1;
  231. margin-left: 16px;
  232. .docs_title{
  233. color: #171826;
  234. font-weight: bold;
  235. font-size: 14px;
  236. line-height: 20px;
  237. letter-spacing: 0px;
  238. text-align: left;
  239. }
  240. .docs_other{
  241. margin-top: 22px;
  242. color: #9B9CA3;
  243. font-weight: medium;
  244. font-size: 12px;
  245. line-height: 18px;
  246. letter-spacing: 0px;
  247. text-align: left;
  248. .docs_download{
  249. line-height: 18px;
  250. }
  251. .docs_money{
  252. margin-top: 2px;
  253. line-height: 24px;
  254. .docs_num{
  255. font-size: 16px;
  256. }
  257. }
  258. }
  259. }
  260. }
  261. .rechargehave_pay_content{
  262. padding: 0 16px;
  263. margin-top: 8px;
  264. width: 100%;
  265. height: 100px;
  266. box-sizing: border-box;
  267. border-bottom: 1px solid rgba($color: #000000, $alpha: 0.05);
  268. background: #ffffff;
  269. .pay_title{
  270. margin-top: 16px;
  271. width: 100%;
  272. height: 24px;
  273. color: #171826;
  274. font-size: 16px;
  275. line-height: 24px;
  276. }
  277. .jianyu_pay{
  278. display: flex;
  279. justify-content: space-between;
  280. align-items: center;
  281. margin-top: 24px;
  282. width: 100%;
  283. height: 20px;
  284. color: #171826;
  285. font-size: 14px;
  286. line-height: 20px;
  287. .jy_pay_left{
  288. .jy_tip{
  289. color: #2abed1;
  290. }
  291. }
  292. .jy_pay_icon{
  293. width: 24px;
  294. height: 24px;
  295. .icon_right_option{
  296. width: 100%;
  297. height: 100%;
  298. }
  299. }
  300. }
  301. }
  302. .docs_phone {
  303. padding: 15px 0;
  304. width: 100%;
  305. .van-field__control{
  306. font-size: 16px;
  307. }
  308. .van-field__control::placeholder {
  309. color: #C0C4CC;
  310. font-weight: medium;
  311. font-size: 16px;
  312. line-height: 24px;
  313. }
  314. }
  315. }
  316. .exchange_footer{
  317. padding: 0 16px;
  318. height: 148px;
  319. background: #ffffff;
  320. .apply_detail{
  321. display: flex;
  322. justify-content: space-between;
  323. align-items: center;
  324. height: 38px;
  325. .det_left{
  326. color: #9B9CA3;
  327. font-family: PingFang SC;
  328. font-weight: medium;
  329. font-size: 12px;
  330. line-height: 18px;
  331. }
  332. .det_right{
  333. display: flex;
  334. align-items: center;
  335. color: #2ABED1;
  336. font-weight: medium;
  337. font-size: 14px;
  338. line-height: 30px;
  339. .det_money{
  340. display: flex;
  341. margin-right: 4px;
  342. font-size: 20px;
  343. }
  344. }
  345. }
  346. .apply_footer {
  347. display: flex;
  348. align-items: center;
  349. justify-content: center;
  350. height: 46px;
  351. padding: 8px 0 12px;
  352. background: rgba(255, 255, 255, 0.96);
  353. }
  354. .apply_button {
  355. width: 100%;
  356. height: 46px;
  357. border-radius: 8px;
  358. background: #2abed1;
  359. font-size: 18px;
  360. color: #f7f9fa;
  361. }
  362. .readly{
  363. display:flex;
  364. align-items:center;
  365. min-height:32px;
  366. font-size: 12px;
  367. color: #5F5E64;
  368. .clause{
  369. color:#2ABED1;
  370. }
  371. .van-checkbox__icon{
  372. font-size:18px;
  373. }
  374. }
  375. }
  376. }
  377. </style>