payCenter.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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. <ul class="mp-list record-list">
  82. <li v-for="record in recordList">
  83. <div class="content-line">
  84. <span class="inline-block title">时间:</span>
  85. <span class="inline-block content text-ellipse">{{record.paytime | time}}</span>
  86. </div>
  87. <div class="content-line">
  88. <span class="inline-block title">订单号:</span>
  89. <span class="inline-block content text-ellipse">{{record.orderid}}</span>
  90. </div>
  91. <div class="content-line">
  92. <span class="inline-block title">卖家名称:</span>
  93. <span class="inline-block content text-ellipse">{{record.sellername}}</span>
  94. </div>
  95. <div class="content-line">
  96. <span class="inline-block title">币种:</span>
  97. <span class="inline-block content text-ellipse">{{record.currencyName}}</span>
  98. </div>
  99. <div class="content-line">
  100. <span class="inline-block title">金额:</span>
  101. <span class="inline-block content text-ellipse"><i class="fa fa-minus" style="color: #1da902;"></i>{{record.ensurePrice}}</span>
  102. </div>
  103. <div class="content-line">
  104. <span class="inline-block title">交易方式:</span>
  105. <span class="inline-block content text-ellipse">{{record.paytype == 1103 ? '线下支付' : '线上支付'}}</span>
  106. </div>
  107. <div class="content-line">
  108. <span class="inline-block title">状态:</span>
  109. <span class="inline-block content text-ellipse">支付成功</span>
  110. </div>
  111. </li>
  112. </ul>
  113. </div>
  114. <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
  115. <pull-up :fixId="'mobileFixContent'" :searchMore="fetching" :allPage="allPage" :page="page" @pullUpAction="onPullUpAction"></pull-up>
  116. <!-- 新增账户弹框start -->
  117. <div class="mobile-modal account-modal" @click="showSimilar = false" v-if="showModal">
  118. <div class="account-modal-wrap add-account-modal">
  119. <div class="account-modal">
  120. <p class="title">新增账户</p>
  121. <div class="modal-content-line">
  122. <span class="inline-block"><i>*</i>开户银行:</span>
  123. <input type="text" readonly placeholder="例如:中国银行" v-model="bankAccountObj.bankname" @click.stop="showSimilar = !showSimilar">
  124. <ul v-if="showSimilar" class="similar">
  125. <li class="text-ellipse" v-for="bank in bankList" @click.stop="setBankName(bank)">{{bank}}</li>
  126. </ul>
  127. </div>
  128. <div class="modal-content-line">
  129. <span class="inline-block"><i>*</i>开户支行:</span>
  130. <input type="text" placeholder="例如:乔香支行" v-model="bankAccountObj.branchname" @blur="checkBranchname">
  131. </div>
  132. <div class="modal-content-line">
  133. <span class="inline-block"><i>*</i>银行账号:</span>
  134. <input type="text" placeholder="请填写银行账号" v-model="bankAccountObj.number" @blur="checkNumber">
  135. </div>
  136. <div class="modal-content-line">
  137. <span class="inline-block"><i>*</i>开户名称:</span>
  138. <input type="text" placeholder="请填写开户人姓名或企业名称" v-model="bankAccountObj.accountname" @blur="checkAccountname">
  139. </div>
  140. <div class="modal-content-line clearfix">
  141. <p class="remind"><i>*</i>为保障您的资金安全,账户信息加密显示且不可修改,只能删除后重新提交。</p>
  142. </div>
  143. <div class="am-btn-wrap">
  144. <button @click="showModal = false">取消</button>
  145. <button @click="addAccount">确认</button>
  146. </div>
  147. </div>
  148. </div>
  149. </div>
  150. <empty-status v-if="isEmpty" :text="switchType == 'record' ? '暂无支付记录,请下单购买商品吧!' : '暂无账户信息'" :showLink="true"></empty-status>
  151. <!-- 新增账户弹框end -->
  152. </div>
  153. </template>
  154. <script>
  155. import { RemindBox, PullUp, EmptyStatus } from '~components/mobile/common'
  156. import { ModalWrapper } from '~components/mobile/base'
  157. export default {
  158. layout: 'mobile',
  159. middleware: 'authenticated',
  160. data () {
  161. return {
  162. remindText: '',
  163. timeoutCount: '',
  164. page: 1,
  165. count: 10,
  166. accountList: [],
  167. recordList: [],
  168. switchType: 'record',
  169. // 分页重置标志
  170. isChange: false,
  171. showModal: false,
  172. bankList: [],
  173. showSimilar: false,
  174. bankAccountObj: {
  175. bankname: '',
  176. branchname: '',
  177. number: '',
  178. accountname: ''
  179. },
  180. validBankAccountObj: {
  181. bankname: false,
  182. branchname: false,
  183. number: false,
  184. accountname: false
  185. },
  186. filterParams: {
  187. keyword: '',
  188. fromDate: '',
  189. toDate: '',
  190. currencyName: '',
  191. // 交易方式
  192. method: ''
  193. },
  194. showSelectMethod: false,
  195. showSelectCurrency: false,
  196. showSelectStatus: false,
  197. dateObj: {
  198. fromDate: '',
  199. toDate: ''
  200. }
  201. }
  202. },
  203. components: {
  204. RemindBox,
  205. PullUp,
  206. ModalWrapper,
  207. EmptyStatus
  208. },
  209. fetch ({store}) {
  210. return Promise.all([
  211. // store.dispatch('payCenter/loadBuyerAccount', {count: 10, page: 1, sorting: {num: 'ASC'}, type: 'buyer'})
  212. store.dispatch('payCenter/loadBuyerRecord', {count: 10, page: 1, sorting: {'paytime': 'DESC'}})
  213. ])
  214. },
  215. watch: {
  216. 'buyerAccount': {
  217. handler: function (val) {
  218. if (val && val.content) {
  219. if (this.isChange) {
  220. this.accountList = []
  221. this.isChange = false
  222. }
  223. this.accountList = [...this.accountList, ...val.content]
  224. }
  225. }
  226. },
  227. 'buyerRecord': {
  228. handler: function (val) {
  229. if (val && val.content) {
  230. if (this.isChange) {
  231. this.recordList = []
  232. this.isChange = false
  233. }
  234. this.recordList = [...this.recordList, ...val.content]
  235. }
  236. },
  237. immediate: true
  238. }
  239. },
  240. computed: {
  241. accountData () {
  242. return this.$store.state.payCenter.data.buyerAccount
  243. },
  244. recordData () {
  245. return this.$store.state.payCenter.data.buyerRecord
  246. },
  247. buyerAccount () {
  248. return this.accountData.data
  249. },
  250. buyerRecord () {
  251. return this.recordData.data
  252. },
  253. fetching () {
  254. return this.switchType === 'account' ? this.accountData.fetching : this.recordData.fetching
  255. },
  256. allPage () {
  257. return this.switchType === 'account' ? this.buyerAccount.totalPages : this.buyerRecord.totalPages
  258. },
  259. isEmpty () {
  260. return (this.switchType === 'record' && this.recordList.length === 0) || (this.switchType === 'account' && this.accountList.length === 0)
  261. }
  262. },
  263. methods: {
  264. setRemindText: function (str) {
  265. this.remindText = str
  266. this.timeoutCount++
  267. },
  268. reloadList () {
  269. if (this.switchType === 'account') {
  270. this.$store.dispatch('payCenter/loadBuyerAccount', {
  271. count: this.count,
  272. page: this.page,
  273. sorting: {num: 'ASC'},
  274. type: 'buyer'
  275. })
  276. } else {
  277. this.$store.dispatch('payCenter/loadBuyerRecord', {
  278. count: this.count,
  279. page: this.page,
  280. sorting: {'paytime': 'DESC'},
  281. currencyName: this.filterParams.currencyName || null,
  282. fromDate: this.filterParams.fromDate || null,
  283. toDate: this.filterParams.toDate || null,
  284. method: this.filterParams.method || null,
  285. keyword: this.filterParams.keyword || null
  286. })
  287. }
  288. },
  289. initList () {
  290. this.isChange = true
  291. this.page = 1
  292. this.reloadList()
  293. },
  294. onPullUpAction () {
  295. this.page++
  296. this.reloadList()
  297. },
  298. setSwitchType (type) {
  299. this.switchType = type
  300. if (type === 'record') {
  301. this.initFilterParams()
  302. }
  303. this.initList()
  304. },
  305. initFilterParams () {
  306. this.filterParams = {
  307. keyword: '',
  308. fromDate: '',
  309. toDate: '',
  310. currencyName: '',
  311. method: ''
  312. }
  313. },
  314. filterRecord () {
  315. this.isChange = true
  316. this.reloadList()
  317. },
  318. setShowSelect (type, flag) {
  319. if (type === 'all') {
  320. this.showSelectMethod = flag
  321. this.showSelectCurrency = flag
  322. this.showSelectStatus = flag
  323. } else if (type === 'method') {
  324. this.showSelectMethod = flag
  325. this.showSelectCurrency = false
  326. this.showSelectStatus = false
  327. } else if (type === 'currencyName') {
  328. this.showSelectCurrency = flag
  329. this.showSelectStatus = false
  330. this.showSelectMethod = false
  331. } else if (type === 'status') {
  332. this.showSelectStatus = flag
  333. this.showSelectMethod = false
  334. this.showSelectCurrency = false
  335. }
  336. },
  337. setSelect (type, val) {
  338. if (type === 'method') {
  339. this.filterParams.method = val
  340. this.setShowSelect('method', false)
  341. } else if (type === 'currencyName') {
  342. this.filterParams.currencyName = val
  343. this.setShowSelect('currencyName', false)
  344. } else if (type === 'status') {
  345. this.filterParams.status = val
  346. this.setShowSelect('status', false)
  347. }
  348. this.filterRecord(this.filterParams.currencyName)
  349. },
  350. setDate (type) {
  351. if (this.dateObj[type]) {
  352. this.filterParams[type] = new Date(this.dateObj[type]).getTime() - 8 * 60 * 60 * 1000
  353. if (this.filterParams.fromDate && this.filterParams.toDate && this.filterParams.fromDate > this.filterParams.toDate) {
  354. if (type === 'fromDate') {
  355. this.setRemindText('起始时间不能大于结束时间')
  356. } else {
  357. this.setRemindText('结束时间不能小于起始时间')
  358. }
  359. this.filterParams[type] = null
  360. this.dateObj[type] = null
  361. } else {
  362. if (this.filterParams.fromDate && this.filterParams.toDate && this.filterParams.fromDate === this.filterParams.toDate) {
  363. // 23:59:59
  364. this.filterParams.toDate += 23 * 60 * 60 * 1000 + 59 * 60 * 1000 + 59 * 1000
  365. }
  366. this.filterRecord()
  367. }
  368. } else {
  369. this.filterParams[type] = null
  370. this.filterRecord()
  371. }
  372. },
  373. setDefaultAccount (account) {
  374. this.$http.get(`/trade/bankInfo/setDefaultAccount/${account.id}`).then(() => {
  375. this.setRemindText('设置完成')
  376. this.initList()
  377. })
  378. },
  379. deleteAccount (account) {
  380. this.$http.delete(`/trade/bankInfo/delete/${account.id}`).then(res => {
  381. if (res.data === 'success') {
  382. this.setRemindText('删除成功')
  383. this.initList()
  384. }
  385. })
  386. },
  387. initAccount () {
  388. this.bankAccountObj = {
  389. bankname: '',
  390. branchname: '',
  391. number: '',
  392. accountname: ''
  393. }
  394. this.validBankAccountObj = {
  395. bankname: false,
  396. branchname: false,
  397. number: false,
  398. accountname: false
  399. }
  400. },
  401. openAddAccount () {
  402. if (!this.bankList || !this.bankList.length) {
  403. this.$http.get('/data/bank.json').then(res => {
  404. this.bankList = res.data.list
  405. this.initAccount()
  406. this.showModal = true
  407. })
  408. } else {
  409. this.initAccount()
  410. this.showModal = true
  411. }
  412. },
  413. setBankName (name) {
  414. this.bankAccountObj.bankname = name
  415. this.showSimilar = false
  416. this.validBankAccountObj.bankname = true
  417. },
  418. checkBranchname () {
  419. this.validBankAccountObj.branchname = true
  420. if (!(this.bankAccountObj.branchname && this.bankAccountObj.branchname.length)) {
  421. this.setRemindText('开户支行不能为空')
  422. this.validBankAccountObj.branchname = false
  423. } else if (this.baseUtils.getRealLen(this.bankAccountObj.branchname) > 40) {
  424. this.setRemindText('开户支行不能大于40字符')
  425. this.validBankAccountObj.branchname = false
  426. } else if (!/^[\u2E80-\u9FFF]+$/.test(this.bankAccountObj.branchname)) {
  427. this.setRemindText('请输入正确的开户支行')
  428. this.validBankAccountObj.branchname = false
  429. }
  430. },
  431. checkNumber () {
  432. this.validBankAccountObj.number = true
  433. if (!(this.bankAccountObj.number && this.bankAccountObj.number.length)) {
  434. this.validBankAccountObj.number = false
  435. this.setRemindText('银行账号不能为空')
  436. } else if (this.baseUtils.getRealLen(this.bankAccountObj.number) > 30) {
  437. this.setRemindText('银行账号不能大于30字符')
  438. this.validBankAccountObj.number = false
  439. } else if (!/^[0-9]+$/.test(this.bankAccountObj.number)) {
  440. this.setRemindText('请输入正确的银行账号')
  441. this.validBankAccountObj.number = false
  442. }
  443. if (this.validBankAccountObj.number) {
  444. this.$http.get('/trade/bankInfo/number/count', {params: {type: 1061, number: this.bankAccountObj.number}}).then(res => {
  445. if (res.data.success) {
  446. this.validBankAccountObj.number = res.data.data === 0
  447. } else {
  448. this.validBankAccountObj.number = false
  449. this.setRemindText(res.data.message || '银行账号校验失败')
  450. }
  451. }, err => {
  452. this.validBankAccountObj.number = false
  453. this.setRemindText(err.response.data || '银行账号校验失败')
  454. console.log(err)
  455. })
  456. }
  457. },
  458. checkAccountname () {
  459. this.validBankAccountObj.accountname = true
  460. if (!(this.bankAccountObj.accountname && this.bankAccountObj.accountname.length)) {
  461. this.validBankAccountObj.accountname = false
  462. this.setRemindText('账户名称不能为空')
  463. } else if (this.baseUtils.getRealLen(this.bankAccountObj.accountname) > 100) {
  464. this.setRemindText('账户名称不能大于100个字符')
  465. this.validBankAccountObj.accountname = false
  466. }
  467. },
  468. addAccount () {
  469. if (!this.validBankAccountObj.bankname) {
  470. this.setRemindText('请选择开户银行')
  471. } else if (!this.validBankAccountObj.branchname) {
  472. this.setRemindText('请填写正确的开户支行')
  473. } else if (!this.validBankAccountObj.number) {
  474. this.setRemindText('请填写正确的银行账号')
  475. } else if (!this.validBankAccountObj.accountname) {
  476. this.setRemindText('请填写正确的开户名称')
  477. } else {
  478. this.$http.post('/trade/bankInfo/save/personal?type=buyer', this.bankAccountObj).then(res => {
  479. if (res.data.id) {
  480. this.setRemindText('新增账户成功')
  481. this.initList()
  482. this.showModal = false
  483. } else {
  484. this.setRemindText('新增账户失败')
  485. }
  486. }, err => {
  487. this.setRemindText(err.response.data || '新增账户失败')
  488. console.log(err)
  489. })
  490. }
  491. }
  492. }
  493. }
  494. </script>
  495. <style lang="scss" scoped>
  496. @import '~assets/scss/mobilePayCenter';
  497. </style>