1.微信公众平台配置(下载校验文件放到域名目录里面)
2.index.js
import util from 'util' onLoad(options) { var src = decodeURIComponent(options.q); var params = util.getSplit(src); console.log(params.code); }
3.util.js
static getSplit(res) { var arr = res.split('?'); var sub; var code = ""; if(arr && arr.length > 0){ sub = arr[1].split("&"); for (var i in sub){ var ca = sub[i].split('='); if(ca.length>0 && ca[0] == "code"){ code = ca[1]; } } } return { code: code } }