payCenter.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. <template>
  2. <div class="mobile-pay-center mobile-fix-content mobile-centerfix-content" id="mobileFixContent" @click="setShowSelect('all', false)">
  3. <div class="mp-head">
  4. <span class="inline-block" :class="{'active': switchType === 'record'}" @click="setSwitchType('record')">交易记录</span>
  5. <span class="inline-block" :class="{'active': switchType === 'account'}" @click="setSwitchType('account')">付款账户</span>
  6. </div>
  7. <div class="mp-content" v-if="switchType == 'account'">
  8. <p class="mp-content-header">已设置的账户信息<span class="fr" @click="openAddAccount"><i class="iconfont icon-xinzeng"></i>新增账户</span></p>
  9. <ul class="mp-list">
  10. <li v-for="account in accountList">
  11. <div class="content-line">
  12. <span class="inline-block title">开户银行:</span>
  13. <span class="inline-block content text-ellipse">{{account.bankname}}</span>
  14. </div>
  15. <div class="content-line">
  16. <span class="inline-block title">开户支行:</span>
  17. <span class="inline-block content text-ellipse">{{account.branchname}}</span>
  18. </div>
  19. <div class="content-line">
  20. <span class="inline-block title">银行账户:</span>
  21. <span class="inline-block content text-ellipse">{{account.number}}</span>
  22. </div>
  23. <div class="content-line">
  24. <span class="inline-block title">开户名称:</span>
  25. <span class="inline-block content text-ellipse">{{account.accountname}}</span>
  26. </div>
  27. <div class="content-line clearfix">
  28. <span class="inline-block title">操作:</span>
  29. <a class="fr inline-block default-icon" v-if="account.num == 1">默认账户</a>
  30. <a class="fr inline-block set-default-icon" v-if="account.num != 1" @click="setDefaultAccount(account)">设为默认</a>
  31. <a class="fr inline-block" @click="deleteAccount(account)">删除</a>
  32. </div>
  33. </li>
  34. </ul>
  35. </div>
  36. <div class="mp-record" v-if="switchType == 'record'">
  37. <div class="search-content">
  38. <input type="text" placeholder="卖家名称/订单号" v-model="filterParams.keyword" @keyup.13="filterRecord">
  39. <span @click="filterRecord"><i class="iconfont icon-sousuo"></i></span>
  40. </div>
  41. <!--<div class="filters-wrap">
  42. <div class="date-wrap">
  43. <label>
  44. <i class="iconfont icon-ico-date"></i>
  45. <input type="date" v-model="dateObj.fromDate" @change="setDate('fromDate')">
  46. <p v-if="filterParams.fromDate">{{filterParams.fromDate | date}}</p>
  47. </label>
  48. <span>—</span>
  49. <label>
  50. <i class="iconfont icon-ico-date"></i>
  51. <input type="date" v-model="dateObj.toDate" @change="setDate('toDate')">
  52. <p v-if="filterParams.toDate">{{filterParams.toDate | date}}</p>
  53. </label>
  54. </div>
  55. <ul class="select-wrap">
  56. <li class="inline-block">
  57. <div @click.stop="setShowSelect('method', !showSelectMethod)">{{filterParams.method ? filterParams.method == 1103 ? '线下支付' : '线上支付' : '交易方式'}}</div>
  58. <ul class="select-list" v-show="showSelectMethod">
  59. <li @click.stop="setSelect('method', null)">交易方式</li>
  60. <li @click.stop="setSelect('method', 1103)">线下支付</li>
  61. <li @click.stop="setSelect('method', 1102)">线上支付</li>
  62. </ul>
  63. </li>
  64. <li class="inline-block">
  65. <div @click.stop="setShowSelect('currencyName', !showSelectCurrency)">{{filterParams.currencyName || '币种'}}</div>
  66. <ul class="select-list" v-show="showSelectCurrency">
  67. <li @click.stop="setSelect('currencyName', null)">币种</li>
  68. <li @click.stop="setSelect('currencyName', 'RMB')">RMB</li>
  69. <li @click.stop="setSelect('currencyName', 'USD')">USD</li>
  70. </ul>
  71. </li>
  72. <li class="inline-block">
  73. <div @click.stop="setShowSelect('status', !showSelectStatus)">{{filterParams.status || '状态'}}</div>
  74. <ul class="select-list" v-show="showSelectStatus">
  75. <li @click.stop="setSelect('status', null)">状态</li>
  76. <li @click.stop="setSelect('status', '支付成功')">支付成功</li>
  77. </ul>
  78. </li>
  79. </ul>
  80. </div>-->
  81. <div class="filters-wrap">
  82. <base-filter
  83. v-for="filterOption in filterOptions"
  84. :key="filterOption.selectOption"
  85. :selectItems="filterOption.selectItems"
  86. :defaultVal="filterOption.defaultVal"
  87. :selectOption="filterOption.selectOption"
  88. @selectAction="onSelectAction"
  89. :title="filterOption.title"></base-filter>
  90. </div>
  91. <ul class="mp-list record-list">
  92. <li v-for="record in recordList">
  93. <div class="content-line">
  94. <span class="inline-block title">订单号:</span>
  95. <nuxt-link :to="`/mobile/order/details?uuid=${baseUtils.enidfilter(record.orderid)}&type=buyer`" class="inline-block content link">{{record.orderid}}</nuxt-link>
  96. </div>
  97. <div class="content-line">
  98. <span class="inline-block title">金额:</span>
  99. <span class="inline-block content">{{record.currencyName | currencyFilter}}{{record.ensurePrice}}</span>
  100. </div>
  101. <div class="content-line">
  102. <span class="inline-block title">卖家:</span>
  103. <span class="inline-block content">{{record.sellername}}</span>
  104. </div>
  105. <!--<div class="content-line">
  106. <span class="inline-block title">交易方式:</span>
  107. <span class="inline-block content text-ellipse">{{record.paytype == 1103 ? '线下支付' : '线上支付'}}</span>
  108. </div>-->
  109. <div class="content-line">
  110. <span class="inline-block title">收款方式:</span>
  111. <span class="inline-block content">卖家收款</span>
  112. </div>
  113. <div class="content-line">
  114. <span class="inline-block title">时间:</span>
  115. <span class="inline-block content">{{record.paytime | time}}</span>
  116. </div>
  117. <div class="content-line">
  118. <span class="inline-block title">状态:</span>
  119. <span class="inline-block content">支付成功</span>
  120. </div>
  121. </li>
  122. </ul>
  123. </div>
  124. <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
  125. <pull-up :fixId="'mobileFixContent'" :searchMore="fetching" :allPage="allPage" :page="page" @pullUpAction="onPullUpAction"></pull-up>
  126. <!-- 新增账户弹框start -->
  127. <div class="mobile-modal account-modal" @click="showSimilar = false" v-if="showModal">
  128. <div class="account-modal-wrap add-account-modal">
  129. <div class="account-modal">
  130. <p class="title">新增账户</p>
  131. <div class="modal-content-line">
  132. <span class="inline-block"><i>*</i>开户银行:</span>
  133. <input type="text" readonly placeholder="例如:中国银行" v-model="bankAccountObj.bankname" @click.stop="showSimilar = !showSimilar">
  134. <ul v-if="showSimilar" class="similar">
  135. <li class="text-ellipse" v-for="bank in bankList" @click.stop="setBankName(bank)">{{bank}}</li>
  136. </ul>
  137. </div>
  138. <div class="modal-content-line">
  139. <span class="inline-block"><i>*</i>开户支行:</span>
  140. <input type="text" placeholder="例如:乔香支行" v-model="bankAccountObj.branchname" @blur="checkBranchname">
  141. </div>
  142. <div class="modal-content-line">
  143. <span class="inline-block"><i>*</i>银行账号:</span>
  144. <input type="text" placeholder="请填写银行账号" v-model="bankAccountObj.number" @blur="checkNumber">
  145. </div>
  146. <div class="modal-content-line">
  147. <span class="inline-block"><i>*</i>开户名称:</span>
  148. <input type="text" placeholder="请填写开户人姓名或企业名称" v-model="bankAccountObj.accountname" @blur="checkAccountname">
  149. </div>
  150. <div class="modal-content-line clearfix">
  151. <p class="remind"><i>*</i>为保障您的资金安全,账户信息加密显示且不可修改,只能删除后重新提交。</p>
  152. </div>
  153. <div class="am-btn-wrap">
  154. <button @click="showModal = false">取消</button>
  155. <button @click="addAccount">确认</button>
  156. </div>
  157. </div>
  158. </div>
  159. </div>
  160. <empty-status v-if="isEmpty" :text="switchType == 'record' ? '暂无支付记录,请下单购买商品吧!' : '暂无账户信息'" :showLink="true"></empty-status>
  161. <!-- 新增账户弹框end -->
  162. </div>
  163. </template>
  164. <script>
  165. import { RemindBox, PullUp, EmptyStatus } from '~components/mobile/common'
  166. import { ModalWrapper, BaseFilter } from '~components/mobile/base'
  167. export default {
  168. layout: 'mobile',
  169. middleware: 'authenticated',
  170. data () {
  171. return {
  172. remindText: '',
  173. timeoutCount: '',
  174. page: 1,
  175. count: 10,
  176. accountList: [],
  177. recordList: [],
  178. switchType: 'record',
  179. // 分页重置标志
  180. isChange: false,
  181. showModal: false,
  182. bankList: [],
  183. showSimilar: false,
  184. bankAccountObj: {
  185. bankname: '',
  186. branchname: '',
  187. number: '',
  188. accountname: ''
  189. },
  190. validBankAccountObj: {
  191. bankname: false,
  192. branchname: false,
  193. number: false,
  194. accountname: false
  195. },
  196. filterParams: {
  197. keyword: '',
  198. fromDate: '',
  199. toDate: '',
  200. currencyName: '',
  201. // 交易方式
  202. method: ''
  203. },
  204. showSelectMethod: false,
  205. showSelectCurrency: false,
  206. showSelectStatus: false,
  207. dateObj: {
  208. fromDate: '',
  209. toDate: ''
  210. },
  211. filterOptions: [
  212. // {
  213. // title: '交易方式',
  214. // selectOption: 'method',
  215. // selectItems: [{key: '全部',
  216. // val: 0
  217. // }, {
  218. // key: '卖家收款',
  219. // val: 1
  220. // }, {
  221. // key: '平台代收',
  222. // val: 2
  223. // }],
  224. // defaultVal: 0
  225. // },
  226. {
  227. title: '交易币种',
  228. selectOption: 'currencyName',
  229. selectItems: [{key: '全部',
  230. val: 0
  231. }, {
  232. key: 'RMB',
  233. val: 'RMB'
  234. }, {
  235. key: 'USD',
  236. val: 'USD'
  237. }],
  238. defaultVal: 0
  239. },
  240. // {
  241. // title: '交易状态',
  242. // selectOption: 'status',
  243. // selectItems: [{key: '全部',
  244. // val: 0
  245. // }, {
  246. // key: '已付款',
  247. // val: 1
  248. // }, {
  249. // key: '待付款',
  250. // val: 2
  251. // }],
  252. // defaultVal: 0
  253. // },
  254. {
  255. title: '交易时间',
  256. selectOption: 'date',
  257. selectItems: [{key: '全部',
  258. val: 0
  259. }, {
  260. key: '一个月',
  261. val: 1
  262. }, {
  263. key: '三个月',
  264. val: 2
  265. }, {
  266. key: '六个月',
  267. val: 3
  268. }, {
  269. key: '自定义',
  270. val: 4
  271. }],
  272. defaultVal: 0
  273. }
  274. ]
  275. }
  276. },
  277. components: {
  278. RemindBox,
  279. PullUp,
  280. ModalWrapper,
  281. EmptyStatus,
  282. BaseFilter
  283. },
  284. fetch ({store}) {
  285. return Promise.all([
  286. // store.dispatch('payCenter/loadBuyerAccount', {count: 10, page: 1, sorting: {num: 'ASC'}, type: 'buyer'})
  287. store.dispatch('payCenter/loadBuyerRecord', {count: 10, page: 1, sorting: {'paytime': 'DESC'}})
  288. ])
  289. },
  290. watch: {
  291. 'buyerAccount': {
  292. handler: function (val) {
  293. if (val && val.content) {
  294. if (this.isChange) {
  295. this.accountList = []
  296. this.isChange = false
  297. }
  298. this.accountList = [...this.accountList, ...val.content]
  299. }
  300. }
  301. },
  302. 'buyerRecord': {
  303. handler: function (val) {
  304. if (val && val.content) {
  305. if (this.isChange) {
  306. this.recordList = []
  307. this.isChange = false
  308. }
  309. this.recordList = [...this.recordList, ...val.content]
  310. }
  311. },
  312. immediate: true
  313. }
  314. },
  315. computed: {
  316. accountData () {
  317. return this.$store.state.payCenter.data.buyerAccount
  318. },
  319. recordData () {
  320. return this.$store.state.payCenter.data.buyerRecord
  321. },
  322. buyerAccount () {
  323. return this.accountData.data
  324. },
  325. buyerRecord () {
  326. return this.recordData.data
  327. },
  328. fetching () {
  329. return this.switchType === 'account' ? this.accountData.fetching : this.recordData.fetching
  330. },
  331. allPage () {
  332. return this.switchType === 'account' ? this.buyerAccount.totalPages : this.buyerRecord.totalPages
  333. },
  334. isEmpty () {
  335. return (this.switchType === 'record' && this.recordList.length === 0) || (this.switchType === 'account' && this.accountList.length === 0)
  336. }
  337. },
  338. methods: {
  339. setRemindText: function (str) {
  340. this.remindText = str
  341. this.timeoutCount++
  342. },
  343. reloadList () {
  344. if (this.switchType === 'account') {
  345. this.$store.dispatch('payCenter/loadBuyerAccount', {
  346. count: this.count,
  347. page: this.page,
  348. sorting: {num: 'ASC'},
  349. type: 'buyer'
  350. })
  351. } else {
  352. this.$store.dispatch('payCenter/loadBuyerRecord', {
  353. count: this.count,
  354. page: this.page,
  355. sorting: {'paytime': 'DESC'},
  356. currencyName: this.filterParams.currencyName || null,
  357. fromDate: this.filterParams.fromDate || null,
  358. toDate: this.filterParams.toDate || null,
  359. method: this.filterParams.method || null,
  360. keyword: this.filterParams.keyword || null
  361. })
  362. }
  363. },
  364. initList () {
  365. this.isChange = true
  366. this.page = 1
  367. this.reloadList()
  368. },
  369. onPullUpAction () {
  370. this.page++
  371. this.reloadList()
  372. },
  373. setSwitchType (type) {
  374. this.switchType = type
  375. if (type === 'record') {
  376. this.initFilterParams()
  377. }
  378. this.initList()
  379. },
  380. initFilterParams () {
  381. this.filterParams = {
  382. keyword: '',
  383. fromDate: '',
  384. toDate: '',
  385. currencyName: '',
  386. method: ''
  387. }
  388. },
  389. filterRecord () {
  390. this.isChange = true
  391. this.reloadList()
  392. },
  393. setShowSelect (type, flag) {
  394. if (type === 'all') {
  395. this.showSelectMethod = flag
  396. this.showSelectCurrency = flag
  397. this.showSelectStatus = flag
  398. } else if (type === 'method') {
  399. this.showSelectMethod = flag
  400. this.showSelectCurrency = false
  401. this.showSelectStatus = false
  402. } else if (type === 'currencyName') {
  403. this.showSelectCurrency = flag
  404. this.showSelectStatus = false
  405. this.showSelectMethod = false
  406. } else if (type === 'status') {
  407. this.showSelectStatus = flag
  408. this.showSelectMethod = false
  409. this.showSelectCurrency = false
  410. }
  411. },
  412. setSelect (type, val) {
  413. // if (type === 'method') {
  414. // this.filterParams.method = val
  415. // this.setShowSelect('method', false)
  416. // } else if (type === 'currencyName') {
  417. // this.filterParams.currencyName = val
  418. // this.setShowSelect('currencyName', false)
  419. // } else if (type === 'status') {
  420. // this.filterParams.status = val
  421. // this.setShowSelect('status', false)
  422. // }
  423. if (type === 'date') {
  424. if (val) {
  425. this.filterParams.fromDate = val.fromDate
  426. this.filterParams.toDate = val.toDate
  427. } else {
  428. this.filterParams.fromDate = null
  429. this.filterParams.toDate = null
  430. }
  431. } else {
  432. this.filterParams[type] = val
  433. }
  434. this.filterRecord()
  435. },
  436. onSelectAction (selectObj) {
  437. this.setSelect(selectObj.key, selectObj.value)
  438. },
  439. setDate (type) {
  440. if (this.dateObj[type]) {
  441. this.filterParams[type] = new Date(this.dateObj[type]).getTime() - 8 * 60 * 60 * 1000
  442. if (this.filterParams.fromDate && this.filterParams.toDate && this.filterParams.fromDate > this.filterParams.toDate) {
  443. if (type === 'fromDate') {
  444. this.setRemindText('起始时间不能大于结束时间')
  445. } else {
  446. this.setRemindText('结束时间不能小于起始时间')
  447. }
  448. this.filterParams[type] = null
  449. this.dateObj[type] = null
  450. } else {
  451. if (this.filterParams.fromDate && this.filterParams.toDate && this.filterParams.fromDate === this.filterParams.toDate) {
  452. // 23:59:59
  453. this.filterParams.toDate += 23 * 60 * 60 * 1000 + 59 * 60 * 1000 + 59 * 1000
  454. }
  455. this.filterRecord()
  456. }
  457. } else {
  458. this.filterParams[type] = null
  459. this.filterRecord()
  460. }
  461. },
  462. setDefaultAccount (account) {
  463. this.$http.get(`/trade/bankInfo/setDefaultAccount/${account.id}`).then(() => {
  464. this.setRemindText('设置完成')
  465. this.initList()
  466. })
  467. },
  468. deleteAccount (account) {
  469. this.$http.delete(`/trade/bankInfo/delete/${account.id}`).then(res => {
  470. if (res.data === 'success') {
  471. this.setRemindText('删除成功')
  472. this.initList()
  473. }
  474. })
  475. },
  476. initAccount () {
  477. this.bankAccountObj = {
  478. bankname: '',
  479. branchname: '',
  480. number: '',
  481. accountname: ''
  482. }
  483. this.validBankAccountObj = {
  484. bankname: false,
  485. branchname: false,
  486. number: false,
  487. accountname: false
  488. }
  489. },
  490. openAddAccount () {
  491. if (!this.bankList || !this.bankList.length) {
  492. this.$http.get('/data/bank.json').then(res => {
  493. this.bankList = res.data.list
  494. this.initAccount()
  495. this.showModal = true
  496. })
  497. } else {
  498. this.initAccount()
  499. this.showModal = true
  500. }
  501. },
  502. setBankName (name) {
  503. this.bankAccountObj.bankname = name
  504. this.showSimilar = false
  505. this.validBankAccountObj.bankname = true
  506. },
  507. checkBranchname () {
  508. this.validBankAccountObj.branchname = true
  509. if (!(this.bankAccountObj.branchname && this.bankAccountObj.branchname.length)) {
  510. this.setRemindText('开户支行不能为空')
  511. this.validBankAccountObj.branchname = false
  512. } else if (this.baseUtils.getRealLen(this.bankAccountObj.branchname) > 40) {
  513. this.setRemindText('开户支行不能大于40字符')
  514. this.validBankAccountObj.branchname = false
  515. } else if (!/^[\u2E80-\u9FFF]+$/.test(this.bankAccountObj.branchname)) {
  516. this.setRemindText('请输入正确的开户支行')
  517. this.validBankAccountObj.branchname = false
  518. }
  519. },
  520. checkNumber () {
  521. this.validBankAccountObj.number = true
  522. if (!(this.bankAccountObj.number && this.bankAccountObj.number.length)) {
  523. this.validBankAccountObj.number = false
  524. this.setRemindText('银行账号不能为空')
  525. } else if (this.baseUtils.getRealLen(this.bankAccountObj.number) > 30) {
  526. this.setRemindText('银行账号不能大于30字符')
  527. this.validBankAccountObj.number = false
  528. } else if (!/^[0-9]+$/.test(this.bankAccountObj.number)) {
  529. this.setRemindText('请输入正确的银行账号')
  530. this.validBankAccountObj.number = false
  531. }
  532. if (this.validBankAccountObj.number) {
  533. this.$http.get('/trade/bankInfo/number/count', {params: {type: 1061, number: this.bankAccountObj.number}}).then(res => {
  534. if (res.data.success) {
  535. this.validBankAccountObj.number = res.data.data === 0
  536. } else {
  537. this.validBankAccountObj.number = false
  538. this.setRemindText(res.data.message || '银行账号校验失败')
  539. }
  540. }, err => {
  541. this.validBankAccountObj.number = false
  542. this.setRemindText(err.response.data || '银行账号校验失败')
  543. console.log(err)
  544. })
  545. }
  546. },
  547. checkAccountname () {
  548. this.validBankAccountObj.accountname = true
  549. if (!(this.bankAccountObj.accountname && this.bankAccountObj.accountname.length)) {
  550. this.validBankAccountObj.accountname = false
  551. this.setRemindText('账户名称不能为空')
  552. } else if (this.baseUtils.getRealLen(this.bankAccountObj.accountname) > 100) {
  553. this.setRemindText('账户名称不能大于100个字符')
  554. this.validBankAccountObj.accountname = false
  555. }
  556. },
  557. addAccount () {
  558. if (!this.validBankAccountObj.bankname) {
  559. this.setRemindText('请选择开户银行')
  560. } else if (!this.validBankAccountObj.branchname) {
  561. this.setRemindText('请填写正确的开户支行')
  562. } else if (!this.validBankAccountObj.number) {
  563. this.setRemindText('请填写正确的银行账号')
  564. } else if (!this.validBankAccountObj.accountname) {
  565. this.setRemindText('请填写正确的开户名称')
  566. } else {
  567. this.$http.post('/trade/bankInfo/save/personal?type=buyer', this.bankAccountObj).then(res => {
  568. if (res.data.id) {
  569. this.setRemindText('新增账户成功')
  570. this.initList()
  571. this.showModal = false
  572. } else {
  573. this.setRemindText('新增账户失败')
  574. }
  575. }, err => {
  576. this.setRemindText(err.response.data || '新增账户失败')
  577. console.log(err)
  578. })
  579. }
  580. }
  581. }
  582. }
  583. </script>
  584. <style lang="scss" scoped>
  585. @import '~assets/scss/mobilePayCenter';
  586. </style>