index.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. didMount() {},
  12. methods: {
  13. onHandleScan() {
  14. // my.scan({
  15. // scanType: ['qrCode'],
  16. my.ap.navigateToAlipayPage({
  17. appCode: 'alipayScan',
  18. success: res => {
  19. // console.log(res);
  20. // 解析扫码结果,缓存小区信息,跳转页面
  21. if (!res.qrCode) return;
  22. const app = parseUrlQuery(res.qrCode);
  23. const query = parseUrlQuery(app.page);
  24. if (query.pageCode !== 'visitReasonPage' || !query.communityCode) {
  25. this.commit({
  26. errorType: 'NOCOMMUNITY',
  27. errorMsg: '小区不存在',
  28. errorBrief: '请扫描正确的二维码'
  29. });
  30. return;
  31. }
  32. my.redirectTo({
  33. url: `${prefixPagePath}/${dynamicPageName}/index?pageCode=${query.pageCode}&communityCode=${query.communityCode}&communityName=${query.communityName || ''}&sceneCode=${query.sceneCode || ''}`
  34. });
  35. },
  36. fail: error => {
  37. if (error.code === 11) {
  38. toast('扫码操作失败');
  39. }
  40. }
  41. });
  42. }
  43. }
  44. }));