payCenter.vue 23 KB

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