index.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { connect } from 'herculex';
  2. import { parseUrlQuery, prefixPagePath, dynamicPageName } from "../../../../core/utils/index";
  3. import { toast } from "../../../../core/utils/jsapi";
  4. Component(connect({
  5. mapStateToProps: {
  6. titleBarHeight: state => state.$global.titleBarHeight
  7. }
  8. })({
  9. props: {},
  10. data: {
  11. defaultData: {
  12. logo: 'https://gw.alipayobjects.com/mdn/rms_ce4c6f/afts/img/A*hkCKTJY-nXMAAAAAAAAAAABkARQnAQ',
  13. tips: '通行证已过期',
  14. desc: '请重新扫码登记'
  15. }
  16. },
  17. methods: {
  18. onScan() {
  19. // my.scan({
  20. // scanType: ['qrCode'],
  21. my.ap.navigateToAlipayPage({
  22. appCode: 'alipayScan',
  23. success: res => {
  24. // 解析扫码结果,缓存小区信息,跳转页面
  25. if (!res.qrCode) return;
  26. const app = parseUrlQuery(res.qrCode);
  27. const query = parseUrlQuery(app.page);
  28. if (query.pageCode !== 'visitReasonPage' || !query.communityCode) {
  29. this.commit({
  30. errorType: 'NOCOMMUNITY',
  31. errorMsg: '小区不存在',
  32. errorBrief: '请扫描正确的二维码'
  33. });
  34. return;
  35. }
  36. my.redirectTo({
  37. url: `${prefixPagePath}/${dynamicPageName}/index?pageCode=${query.pageCode}&communityCode=${query.communityCode}&communityName=${query.communityName || ''}&sceneCode=${query.sceneCode || ''}`
  38. });
  39. },
  40. fail: error => {
  41. if (error.code === 11) {
  42. toast('扫码操作失败');
  43. }
  44. }
  45. });
  46. }
  47. }
  48. }));