index.js 711 字节
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3 4 5
import {
  callPageHook
} from '../util'

import createPage from './create-page'
6 7 8 9 10 11 12 13 14 15 16 17 18 19

// 与小程序保持一致,尝试decodeURIComponent一次参数
function getDecodedQuery (query = {}) {
  const decodedQuery = {}
  Object.keys(query).forEach(name => {
    try {
      decodedQuery[name] = decodeURIComponent(query[name])
    } catch (e) {
      decodedQuery[name] = query[name]
    }
  })
  return decodedQuery
}

fxy060608's avatar
fxy060608 已提交
20 21 22
export function createPageMixin () {
  return {
    created: function pageCreated () {
23 24 25
      const options = getDecodedQuery(this.$route.query)
      createPage(this, options)
      callPageHook(this, 'onLoad', options)
fxy060608's avatar
fxy060608 已提交
26 27 28 29
      callPageHook(this, 'onShow')
    }
  }
}