index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { getCardList } from '../utils/service';
  2. import { createSubscribe } from 'applet-page-component';
  3. import { history, replaceStar, openCardForm } from '../utils';
  4. import { reportCmPV_YL } from '../utils/cloudMonitorHelper';
  5. Component(createSubscribe({
  6. onShow() {
  7. this.scrollFetch && this.scrollFetch.fetchList({
  8. pageIndex: 1
  9. }, true, true);
  10. }
  11. })({
  12. data: {
  13. serviceList: []
  14. },
  15. props: {
  16. componentData: {}
  17. },
  18. didMount() {
  19. const {
  20. serviceCode
  21. } = getCurrentPages().pop().options;
  22. reportCmPV_YL({
  23. title: '在线充值',
  24. query: {
  25. serviceCode
  26. }
  27. });
  28. },
  29. methods: {
  30. saveRef(ref) {
  31. this.scrollFetch = ref;
  32. },
  33. toRechargeCard(params, cardInfo) {
  34. history.openPage({
  35. pageType: 'recharge-page',
  36. data: {
  37. cardNum: params,
  38. balance: String(cardInfo.balance || 0)
  39. }
  40. });
  41. },
  42. async getCardLists(params) {
  43. const [err, res] = await getCardList({
  44. type: 0,
  45. ...params
  46. });
  47. if (res) {
  48. res.list = res.list.map(item => ({ ...item,
  49. viewCardNum: replaceStar(item.cardNum, 3, 4)
  50. }));
  51. }
  52. return [err, res];
  53. },
  54. createCard(e) {
  55. openCardForm(e.target.dataset.item);
  56. }
  57. }
  58. }));