payCenter.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  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="filterParams.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="filterParams.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('currency', !showSelectCurrency)">{{filterParams.currency || '币种'}}</div>
  66. <ul class="select-list" v-show="showSelectCurrency">
  67. <li @click.stop="setSelect('currency', null)">币种</li>
  68. <li @click.stop="setSelect('currency', 'RMB')">RMB</li>
  69. <li @click.stop="setSelect('currency', '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. }
  198. },
  199. components: {
  200. RemindBox,
  201. PullUp,
  202. ModalWrapper,
  203. EmptyStatus
  204. },
  205. fetch ({store}) {
  206. return Promise.all([
  207. // store.dispatch('payCenter/loadBuyerAccount', {count: 10, page: 1, sorting: {num: 'ASC'}, type: 'buyer'})
  208. store.dispatch('payCenter/loadBuyerRecord', {count: 10, page: 1, sorting: {'paytime': 'DESC'}})
  209. ])
  210. },
  211. watch: {
  212. 'buyerAccount': {
  213. handler: function (val) {
  214. if (val && val.content) {
  215. if (this.isChange) {
  216. this.accountList = []
  217. this.isChange = false
  218. }
  219. this.accountList = [...this.accountList, ...val.content]
  220. }
  221. }
  222. },
  223. 'buyerRecord': {
  224. handler: function (val) {
  225. if (val && val.content) {
  226. if (this.isChange) {
  227. this.recordList = []
  228. this.isChange = false
  229. }
  230. this.recordList = [...this.recordList, ...val.content]
  231. }
  232. },
  233. immediate: true
  234. }
  235. },
  236. computed: {
  237. accountData () {
  238. return this.$store.state.payCenter.data.buyerAccount
  239. },
  240. recordData () {
  241. return this.$store.state.payCenter.data.buyerRecord
  242. },
  243. buyerAccount () {
  244. return this.accountData.data
  245. },
  246. buyerRecord () {
  247. return this.recordData.data
  248. },
  249. fetching () {
  250. return this.switchType === 'account' ? this.accountData.fetching : this.recordData.fetching
  251. },
  252. allPage () {
  253. return this.switchType === 'account' ? this.buyerAccount.totalPages : this.buyerRecord.totalPages
  254. },
  255. isEmpty () {
  256. return (this.switchType === 'record' && this.recordList.length === 0) || (this.switchType === 'account' && this.accountList.length === 0)
  257. }
  258. },
  259. methods: {
  260. setRemindText: function (str) {
  261. this.remindText = str
  262. this.timeoutCount++
  263. },
  264. reloadList () {
  265. if (this.switchType === 'account') {
  266. this.$store.dispatch('payCenter/loadBuyerAccount', {
  267. count: this.count,
  268. page: this.page,
  269. sorting: {num: 'ASC'},
  270. type: 'buyer'
  271. })
  272. } else {
  273. this.$store.dispatch('payCenter/loadBuyerRecord', {
  274. count: this.count,
  275. page: this.page,
  276. sorting: {'paytime': 'DESC'},
  277. currencyName: this.filterParams.currencyName || null,
  278. fromDate: this.filterParams.fromDate || null,
  279. toDate: this.filterParams.toDate || null,
  280. method: this.filterParams.method || null,
  281. keyword: this.filterParams.keyword || null
  282. })
  283. }
  284. },
  285. initList () {
  286. this.isChange = true
  287. this.page = 1
  288. this.reloadList()
  289. },
  290. onPullUpAction () {
  291. this.page++
  292. this.reloadList()
  293. },
  294. setSwitchType (type) {
  295. this.switchType = type
  296. if (type === 'record') {
  297. this.initFilterParams()
  298. }
  299. this.initList()
  300. },
  301. initFilterParams () {
  302. this.filterParams = {
  303. keyword: '',
  304. fromDate: '',
  305. toDate: '',
  306. currencyName: '',
  307. method: ''
  308. }
  309. },
  310. filterRecord () {
  311. this.isChange = true
  312. this.reloadList()
  313. },
  314. setShowSelect (type, flag) {
  315. if (type === 'all') {
  316. this.showSelectMethod = flag
  317. this.showSelectCurrency = flag
  318. this.showSelectStatus = flag
  319. } else if (type === 'method') {
  320. this.showSelectMethod = flag
  321. this.showSelectCurrency = false
  322. this.showSelectStatus = false
  323. } else if (type === 'currency') {
  324. this.showSelectCurrency = flag
  325. this.showSelectStatus = false
  326. this.showSelectMethod = false
  327. } else if (type === 'status') {
  328. this.showSelectStatus = flag
  329. this.showSelectMethod = false
  330. this.showSelectCurrency = false
  331. }
  332. },
  333. setSelect (type, val) {
  334. if (type === 'method') {
  335. this.filterParams.method = val
  336. this.setShowSelect('method', false)
  337. } else if (type === 'currency') {
  338. this.filterParams.currency = val
  339. this.setShowSelect('currency', false)
  340. } else if (type === 'status') {
  341. this.filterParams.status = val
  342. this.setShowSelect('status', false)
  343. }
  344. this.filterRecord()
  345. },
  346. setDate (type) {
  347. // 00:00:00
  348. this.filterParams[type] = new Date(this.filterParams[type]).getTime() - 8 * 60 * 60 * 1000
  349. if (this.filterParams.fromDate && this.filterParams.toDate && this.filterParams.fromDate > this.filterParams.toDate) {
  350. this.setRemindText('起始时间不能大于结束时间')
  351. this.filterParams[type] = null
  352. } else {
  353. if (this.filterParams.fromDate && this.filterParams.toDate && this.filterParams.fromDate === this.filterParams.toDate) {
  354. // 23:59:59
  355. this.filterParams.toDate += 23 * 60 * 60 * 1000 + 59 * 60 * 1000 + 59 * 1000
  356. }
  357. this.filterRecord()
  358. }
  359. },
  360. setDefaultAccount (account) {
  361. this.$http.get(`/trade/bankInfo/setDefaultAccount/${account.id}`).then(() => {
  362. this.setRemindText('设置完成')
  363. this.initList()
  364. })
  365. },
  366. deleteAccount (account) {
  367. this.$http.delete(`/trade/bankInfo/delete/${account.id}`).then(res => {
  368. if (res.data === 'success') {
  369. this.setRemindText('删除成功')
  370. this.initList()
  371. }
  372. })
  373. },
  374. initAccount () {
  375. this.bankAccountObj = {
  376. bankname: '',
  377. branchname: '',
  378. number: '',
  379. accountname: ''
  380. }
  381. this.validBankAccountObj = {
  382. bankname: false,
  383. branchname: false,
  384. number: false,
  385. accountname: false
  386. }
  387. },
  388. openAddAccount () {
  389. if (!this.bankList || !this.bankList.length) {
  390. this.$http.get('/data/bank.json').then(res => {
  391. this.bankList = res.data.list
  392. this.initAccount()
  393. this.showModal = true
  394. })
  395. } else {
  396. this.initAccount()
  397. this.showModal = true
  398. }
  399. },
  400. setBankName (name) {
  401. this.bankAccountObj.bankname = name
  402. this.showSimilar = false
  403. this.validBankAccountObj.bankname = true
  404. },
  405. checkBranchname () {
  406. this.validBankAccountObj.branchname = true
  407. if (!(this.bankAccountObj.branchname && this.bankAccountObj.branchname.length)) {
  408. this.setRemindText('开户支行不能为空')
  409. this.validBankAccountObj.branchname = false
  410. } else if (this.baseUtils.getRealLen(this.bankAccountObj.branchname) > 40) {
  411. this.setRemindText('开户支行不能大于40字符')
  412. this.validBankAccountObj.branchname = false
  413. } else if (!/^[\u2E80-\u9FFF]+$/.test(this.bankAccountObj.branchname)) {
  414. this.setRemindText('请输入正确的开户支行')
  415. this.validBankAccountObj.branchname = false
  416. }
  417. },
  418. checkNumber () {
  419. this.validBankAccountObj.number = true
  420. if (!(this.bankAccountObj.number && this.bankAccountObj.number.length)) {
  421. this.validBankAccountObj.number = false
  422. this.setRemindText('银行账号不能为空')
  423. } else if (this.baseUtils.getRealLen(this.bankAccountObj.number) > 30) {
  424. this.setRemindText('银行账号不能大于30字符')
  425. this.validBankAccountObj.number = false
  426. } else if (!/^[0-9]+$/.test(this.bankAccountObj.number)) {
  427. this.setRemindText('请输入正确的银行账号')
  428. this.validBankAccountObj.number = false
  429. }
  430. if (this.validBankAccountObj.number) {
  431. this.$http.get('/trade/bankInfo/number/count', {params: {type: 1061, number: this.bankAccountObj.number}}).then(res => {
  432. if (res.data.success) {
  433. this.validBankAccountObj.number = res.data.data === 0
  434. } else {
  435. this.validBankAccountObj.number = false
  436. this.setRemindText(res.data.message || '银行账号校验失败')
  437. }
  438. }, err => {
  439. this.validBankAccountObj.number = false
  440. this.setRemindText(err.response.data || '银行账号校验失败')
  441. console.log(err)
  442. })
  443. }
  444. },
  445. checkAccountname () {
  446. this.validBankAccountObj.accountname = true
  447. if (!(this.bankAccountObj.accountname && this.bankAccountObj.accountname.length)) {
  448. this.validBankAccountObj.accountname = false
  449. this.setRemindText('账户名称不能为空')
  450. } else if (this.baseUtils.getRealLen(this.bankAccountObj.accountname) > 100) {
  451. this.setRemindText('账户名称不能大于100个字符')
  452. this.validBankAccountObj.accountname = false
  453. }
  454. },
  455. addAccount () {
  456. if (!this.validBankAccountObj.bankname) {
  457. this.setRemindText('请选择开户银行')
  458. } else if (!this.validBankAccountObj.branchname) {
  459. this.setRemindText('请填写正确的开户支行')
  460. } else if (!this.validBankAccountObj.number) {
  461. this.setRemindText('请填写正确的银行账号')
  462. } else if (!this.validBankAccountObj.accountname) {
  463. this.setRemindText('请填写正确的开户名称')
  464. } else {
  465. this.$http.post('/trade/bankInfo/save/personal?type=buyer', this.bankAccountObj).then(res => {
  466. if (res.data.id) {
  467. this.setRemindText('新增账户成功')
  468. this.initList()
  469. this.showModal = false
  470. } else {
  471. this.setRemindText('新增账户失败')
  472. }
  473. }, err => {
  474. this.setRemindText(err.response.data || '新增账户失败')
  475. console.log(err)
  476. })
  477. }
  478. }
  479. }
  480. }
  481. </script>
  482. <style lang="scss" scoped>
  483. @import '~assets/scss/mobilePayCenter';
  484. </style>