提交 075fd9dd 编写于 作者: chendeli's avatar chendeli

add project

上级
{
"env": {
"test": {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
]
}
}
}
Android >= 4.0
iOS >= 7
\ No newline at end of file
# Created by .ignore support plugin (hsz.mobi)
### Node template
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# parcel-bundler cache (https://parceljs.org/)
.cache
# next.js build output
.next
# nuxt.js build output
.nuxt
# Nuxt generate
dist
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless
# IDE / Editor
.idea
.editorconfig
# Service worker
sw.*
# Mac OSX
.DS_Store
\ No newline at end of file
# nuxt-ssr
> nuxt ssr layout
## Build Setup
``` bash
# install dependencies
$ npm run install
# serve with hot reload at localhost:3000
$ npm run dev
# build for production and launch server
# 有环境变量 非本地打包请自行带上ENV => dev, test, uat, prod
$ ENV=上一行的变量 npm run build // eg: ENV=dev npm run build
$ npm run start // 对于 start 命令,可以根据需求自行 更改PORT (有部署冲突的时候会改)
# generate static project // 暂时用不到
$ npm run generate
```
\ No newline at end of file
# ASSETS
**This directory is not required, you can delete it if you don't want to use it.**
This directory contains your un-compiled assets such as LESS, SASS, or JavaScript.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/assets#webpacked).
img{
-webkit-user-select:none;
-moz-user-select:none;
-o-user-select:none;
user-select:none;
}
body, div, span, header, footer, nav, section, aside, article, ul, dl, dt, dd, li, a, p, h1, h2, h3, h4,h5, h6, i, b, textarea, button, input, select, figure, figcaption, {
padding: 0;
margin: 0;
list-style: none;
font-style: normal;
text-decoration: none;
border: none;
color: #333;
font-weight: normal;
font-family: "PingFangSC-Regular","-apple-system-font","Source Han Sans","Helvetica Neue","sans-serif";
box-sizing: border-box;
-webkit-tap-highlight-color:transparent;
-webkit-font-smoothing: antialiased;
&:hover{
outline: none;
}
}
/*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
::-webkit-scrollbar
{
width: 0px;
height: 0px;
background-color: #F5F5F5;
}
/*定义滚动条轨道 内阴影+圆角*/
::-webkit-scrollbar-track
{
-webkit-box-shadow: inset 0 0 1px rgba(0,0,0,0);
border-radius: 10px;
background-color: #F5F5F5;
}
/*定义滑块 内阴影+圆角*/
::-webkit-scrollbar-thumb
{
border-radius: 10px;
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
background-color: #555;
}
input[type="button"], input[type="submit"], input[type="search"], input[type="reset"] {
-webkit-appearance: none;
}
textarea { -webkit-appearance: none;}
html,body{
height: 100%;
width: 100%;
background-color: #fff;
}
.clear:after{
content: '';
display: block;
clear: both;
}
.clear{
zoom:1;
}
.back_img{
background-repeat: no-repeat;
background-size: 100% 100%;
}
.margin{
margin: 0 auto;
}
.left{
float: left;
}
.right{
float: right;
}
.hide{
display: none;
}
.show{
display: block;
}
.ellipsis{
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.paddingTop{
padding-top: 1.95rem;
}
@keyframes backOpacity{
0% { opacity: 1 }
25% { opacity: .5 }
50% { opacity: 1 }
75% { opacity: .5 }
100% { opacity: 1 }
}
.animation_opactiy{
animation: backOpacity 2s ease-in-out infinite;
}
.template-content .mint-cell-title {
display: none;
}
.template-content .mint-cell-value {
width: 100%;
}
.template-content .mint-cell-wrapper {
padding: 0;
}
\ No newline at end of file
@import './common.scss';
//定位
.relative{
position: relative;
}
.fixed{
position: fixed;
}
.flex{
display:-webkit-box;
display:-webkit-flex;
display:-ms-flexbox;
display:flex;
}
.space-between{
display:-webkit-box;
display:-webkit-flex;
display:-ms-flexbox;
display:flex;
-webkit-box-pack:justify;
-webkit-justify-content:space-between;
-ms-flex-pack:justify;
justify-content:space-between;
}
.flex-start{
display:-webkit-box;
display:-webkit-flex;
display:-ms-flexbox;
display:flex;
justify-content: flex-start;
}
.flex-center{
display:-webkit-box;
display:-webkit-flex;
display:-ms-flexbox;
display:flex;
justify-content: center;
}
.flex-end{
display:-webkit-box;
display:-webkit-flex;
display:-ms-flexbox;
display:flex;
justify-content: flex-end;
}
.textLeft{
float: left;
}
.center{
text-align: center;
}
.line20{
margin-top: px2rem(10px);
}
.pl30{
margin-left: px2rem(15px);
}
.ml5{
margin-left: px2rem(5px);
}
.mb30{
margin-bottom: px2rem(15px);
}
.mb34{
margin-bottom: px2rem(17px);
}
.marginLR30{
margin: 0 px2rem(15px);
}
.pdLR{
padding: px2rem(15px) 0;
}
.pdTB30{
padding: px2rem(45px) 0 px2rem(15px);
}
.pdTB60{
padding: px2rem(15px) 0 px2rem(15px);
}
.fs20{
font-size: px2rem(10px);
}
.fs11{
font-size: px2rem(11px);
}
.fs26{
font-size: px2rem(13px);
}
.fs14{
font-size: px2rem(14px);
}
.fs22{
font-size: px2rem(11px);
}
.fs24{
font-size: px2rem(12px);
}
.fs26{
font-size: px2rem(13px);
}
.fs28{
font-size: px2rem(14px);
}
.fs30{
font-size: px2rem(15px);
}
.fs32{
font-size: px2rem(16px);
}
.fs36{
font-size: px2rem(18px);
}
.fs50{
font-size: px2rem(25px);
}
.fw{
font-weight: bold;
}
//背景颜色
.bg-white{
background-color: #fff;
}
.bg-gray{
background-color: #F5F5F5;
}
//字体颜色
.gray{
color: rgba(177, 181, 184, 1);
}
.white{
color: #fff;
}
.fs30{
font-size: px2rem(15px);
}
//圆角
.radius{
border-radius: px2rem(3px);
}
.radiusTR{
border-radius: px2rem(3px) px2rem(3px) 0 0;
}
.one-line{
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
\ No newline at end of file
@import './global.scss';
$blue: #3190e8;
$bc: #e4e4e4;
$fc:#fff;
// 背景图片地址和大小
@mixin bis($url) {
background-image: url($url);
background-repeat: no-repeat;
background-size: 100% 100%;
}
@mixin borderRadius($radius) {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
-ms-border-radius: $radius;
-o-border-radius: $radius;
border-radius: $radius;
}
//定位全屏
@mixin allcover{
position:absolute;
top:0;
right:0;
}
//定位上下左右居中
@mixin center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
//定位上下居中
@mixin ct {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
//定位左右居中
@mixin cl {
position: absolute;
left: 50%;
transform: translateX(-50%);
}
//宽高
@mixin wh($width, $height){
width: $width;
height: $height;
}
//字体大小、行高、字体
@mixin font($size, $line-height, $family: 'Microsoft YaHei') {
font: #{$size}/#{$line-height} $family;
}
//字体大小,颜色
@mixin sc($size, $color){
font-size: $size;
color: $color;
}
//flex 布局和 子元素 对其方式
@mixin fj($type: space-between){
display: flex;
justify-content: $type;
}
@function px2rem($px){
$rem: 37.5px;
@return ($px / $rem) + rem;
}
\ No newline at end of file
# COMPONENTS
**This directory is not required, you can delete it if you don't want to use it.**
The components directory contains your Vue.js Components.
_Nuxt.js doesn't supercharge these components._
<template>
<no-ssr>
<div class="overp-pop">
<div class="over-pop-bg"></div>
<van-loading size="40px" color="#fff">图片上传中,请稍后...</van-loading>
</div>
</no-ssr>
</template>
<script>
export default {
data() {
return {
name: 'about'
}
}
}
</script>
<style lang="less">
.overp-pop{
position: fixed;
z-index: 3000;
width: 100%;
height: 100%;
top:0;
left:0;
.over-pop-bg{
background: rgba(0, 0, 0, 0.7);
position: absolute;
width: 100%;
height: 100%;
top:0;
left:0;
z-index: 3001;
}
.van-loading{
position: relative;
z-index: 3002;
width: 100%;
text-align: center;
height: 50px;
margin-top:-25px;
top:50%;
}
.van-loading__text{
color:#fff
}
}
</style>
\ No newline at end of file
<template>
<div class="pop-bg">
<div class="pop-box">
<div class="pop-txt">{{popAllObj.popTxt}}</div>
<div class="pop-btn" v-if="popAllObj.isAloneBtn" @click="popFun(popAllObj.index)">
{{popAllObj.aloneBtnTxt}}
</div>
<div class="pop-btn" v-else>
<span class="pop-btn-span cancel-btn" @click="popFun(popAllObj.cancelIndex?popAllObj.cancelIndex:'1')">{{popAllObj.cancelTxt || '退出'}}<i></i></span>
<span class="pop-btn-span sure-btn" @click="popFun(popAllObj.index)">{{popAllObj.sureTxt || '继续填写'}}</span>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {}
},
props: {
title: {
default: '问卷调查',
type: String
},
popAllObj: {
default: ()=>{},
type: Object,
},
},
mounted() {
//console.log(this.popAllObj)
},
computed: {},
methods: {
getIt() {
},
popFun(str) {
this.$emit('setPopFun', str)
}
},
}
</script>
<style>
</style>
<style lang="scss" scoped>
// @import '../assets/style/mixin';
.pop-bg {
background: rgba(0, 0, 0, 0.5);
position: fixed;
z-index: 1000;
width: 100%;
height: 100%;
min-height: 100vh;
left: 0;
top: 0;
}
.pop-box {
background: #fff;
border-radius: 3px;
width: 300px;
//height: px2rem(138px);
position: fixed;
left: 50%;
top: 50%;
margin: -55px 0 0 -150px;
z-index: 1001;
}
.pop-txt {
padding: 30px;
//height: px2rem(70px);
line-height: 21px;
border-bottom: 1PX solid #F0F1F2;
font-size: 14px;
color: #676869;
// text-align: center;
// margin-top:px2rem(18px);
}
.pop-btn {
text-align: center;
height: 50px;
font-size: 17px;
color: #449284;
line-height: 50px;
overflow: hidden;
}
.pop-btn .pop-btn-span {
width: 50%;
float: left;
}
.cancel-btn{
position:relative;
color: #979899;
i{
display: inline-block;
height: 100%;
width: 1PX;
background: #F0F1F2;
position: absolute;
right: 0;
top:0;
}
}
.sure-btn{
color: #449284;
}
.top-title {
height: 45px;
line-height: 25px;
font-size: 18px;
text-align: center;
color: #333;
padding: 10px 0;
border-bottom: 1PX solid #E7E7E7
}
</style>
<template>
<div class="top-title-new">
<span class="top-back" @click="backFun">
<img src="https://pica-pro.oss-cn-shanghai.aliyuncs.com/gpranking/left-icon.png">
</span>
<div class="txt">{{title}}</div>
</div>
</template>
<script>
export default {
data(){
return {
}
},
props:{
title:{
default:'问卷调查',
type:String
},
isScroll:{
default:false,
type:Boolean
}
},
mounted(){
},
computed:{
},
methods:{
backFun(){
this.$emit('setFun')
}
}
}
</script>
<style lang="scss" scoped>
@import '../assets/style/mixin.scss';
.top-title-new{
//height:px2rem(45px);
line-height:px2rem(25px);
font-size: px2rem(18px);
color:#333;
padding:px2rem(10px) px2rem(15px);
padding-top:px2rem(32px);
position: fixed;
top:0;
left: 0;
width: 100%;
z-index: 15;
background:#fff;
.txt{
text-align: center;
line-height: px2rem(25px);
height: px2rem(25px);
white-space: nowrap;
overflow: hidden;
text-overflow:ellipsis;
//width:100%;
}
}
.active{
background: #fff;
.txt{display: block}
}
.top-back{
display: inline-block;
width: px2rem(25px);
height: px2rem(25px);
float: left;
img{
display: block;
width: 100%;
height: 100%
}
}
</style>
module.exports = {
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/$1',
'^~/(.*)$': '<rootDir>/$1',
'^vue$': 'vue/dist/vue.common.js'
},
moduleFileExtensions: ['js', 'vue', 'json'],
transform: {
'^.+\\.js$': 'babel-jest',
'.*\\.(vue)$': 'vue-jest'
},
'collectCoverage': true,
'collectCoverageFrom': [
'<rootDir>/components/**/*.vue',
'<rootDir>/pages/**/*.vue'
]
}
# LAYOUTS
**This directory is not required, you can delete it if you don't want to use it.**
This directory contains your Application Layouts.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/views#layouts).
<template>
<div>
<nuxt />
</div>
</template>
<style>
</style>
# MIDDLEWARE
**This directory is not required, you can delete it if you don't want to use it.**
This directory contains your application middleware.
Middleware let you define custom functions that can be run before rendering either a page or a group of pages.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/routing#middleware).
module.exports = {
mode: 'universal',
/*
** Headers of the page
*/
head: {
title: '云鹊医-赋能基层医生',
meta: [
{ charset: 'utf-8' },
// { name: 'viewport', content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui' },
{ name: 'screen-orientation', content: 'portrait' },
{ name: 'apple-mobile-web-app-capable', content: 'yes' },
{ name: 'format-detection', content: 'telephone=no' },
{ name: 'full-screen', content: 'yes' },
{ name: 'x5-fullscreen', content: 'true' },
{ name: 'referrer', content: 'never' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
// { rel: 'stylesheet', href: '/css/common.css' }
],
style: [
{ cssText: `
@charset "utf-8";html{color:#000;background:#fff;overflow-y:scroll;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}html *{outline:0;-webkit-text-size-adjust:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}html,body{font-family:PingFangSC-Regular,-apple-system-font,Source Han Sans,Helvetica Neue,sans-serif}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td,hr,button,article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{margin:0;padding:0}table{border-collapse:collapse;border-spacing:0}fieldset,img{border:0}abbr,acronym{border:0;font-variant:normal}del{text-decoration:line-through}address,caption,cite,code,dfn,em,th,var{font-style:normal;font-weight:500}ol,ul{list-style:none}caption,th{text-align:left}q:before,q:after{content:''}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}a:hover{text-decoration:underline}ins,a{text-decoration:none}
`, type: 'text/css' }
],
__dangerouslyDisableSanitizers: ['script'],
script: [
{ innerHTML: `
!function(a,b){function c(){var b=f.getBoundingClientRect().width;b/i>540&&(b=540*i);var c=b/10;f.style.fontSize=c+"px",k.rem=a.rem=c}var d,e=a.document,f=e.documentElement,g=e.querySelector('meta[name="viewport"]'),h=e.querySelector('meta[name="flexible"]'),i=0,j=0,k=b.flexible||(b.flexible={});if(g){console.warn("将根据已有的meta标签来设置缩放比例");var l=g.getAttribute("content").match(/initial\-scale=([\d\.]+)/);l&&(j=parseFloat(l[1]),i=parseInt(1/j))}else if(h){var m=h.getAttribute("content");if(m){var n=m.match(/initial\-dpr=([\d\.]+)/),o=m.match(/maximum\-dpr=([\d\.]+)/);n&&(i=parseFloat(n[1]),j=parseFloat((1/i).toFixed(2))),o&&(i=parseFloat(o[1]),j=parseFloat((1/i).toFixed(2)))}}if(!i&&!j){var p=(a.navigator.appVersion.match(/android/gi),a.navigator.appVersion.match(/iphone/gi)),q=a.devicePixelRatio;i=p?q>=3&&(!i||i>=3)?3:q>=2&&(!i||i>=2)?2:1:1,j=1/i}if(f.setAttribute("data-dpr",i),!g)if(g=e.createElement("meta"),g.setAttribute("name","viewport"),g.setAttribute("content","initial-scale="+j+", maximum-scale="+j+", minimum-scale="+j+", user-scalable=no"),f.firstElementChild)f.firstElementChild.appendChild(g);else{var r=e.createElement("div");r.appendChild(g),e.write(r.innerHTML)}a.addEventListener("resize",function(){clearTimeout(d),d=setTimeout(c,300)},!1),a.addEventListener("pageshow",function(a){a.persisted&&(clearTimeout(d),d=setTimeout(c,300))},!1),"complete"===e.readyState?e.body.style.fontSize=12*i+"px":e.addEventListener("DOMContentLoaded",function(){e.body.style.fontSize=12*i+"px"},!1),c(),k.dpr=a.dpr=i,k.refreshRem=c,k.rem2px=function(a){var b=parseFloat(a)*this.rem;return"string"==typeof a&&a.match(/rem$/)&&(b+="px"),b},k.px2rem=function(a){var b=parseFloat(a)/this.rem;return"string"==typeof a&&a.match(/px$/)&&(b+="rem"),b}}(window,window.lib||(window.lib={}));
`, type: 'text/javascript', charset: 'utf-8'}
]
},
/*
** Customize the progress-bar color
*/
loading: { color: '#fff' },
/*
** Global CSS
*/
css: [
'vant/lib/index.css'
],
/*
** Plugins to load before mounting the App
*/
plugins: [
{
src: '~/plugins/vue-inject',
ssr: false
}, {
src: '~/plugins/vueComponent',
ssr: false
},
],
/*
** Nuxt.js modules
*/
modules: [],
/*
** Build configuration
*/
router: {
base: '/questionnaire_ssr/' //上下文根据自己的需求自行打开修改
},
build: {
postcss: {
plugins: {
'postcss-pxtorem': {
rootValue: 37.5,
propList: ['*']
}
}
},
extractCSS: true,
filenames: {
app: ({ isDev }) => isDev ? '[name].js' : '[name].[chunkhash:7].js',
chunk: ({ isDev }) => isDev ? '[name].js' : '[name].[chunkhash:7].js',
css: ({ isDev }) => isDev ? '[name].css' : '[name].[contenthash:7].css',
img: ({ isDev }) => isDev ? '[path][name].[ext]' : 'img/[name].[hash:7].[ext]',
font: ({ isDev }) => isDev ? '[path][name].[ext]' : 'fonts/[name].[hash:7].[ext]',
video: ({ isDev }) => isDev ? '[path][name].[ext]' : 'videos/[name].[hash:7].[ext]'
},
/*
** You can extend webpack config here
*/
extend(config, ctx) {
config.devtool = ['dev', 'test'].indexOf(process.env.NUXT_ENV_APP) !== -1 ? 'source-map' : false;
}
}
}
\ No newline at end of file
此差异已折叠。
{
"name": "nuxt-ssr",
"version": "1.0.0",
"description": "nuxt ssr layout",
"author": "souse",
"private": true,
"scripts": {
"test": "jest",
"dev": "cross-env NODE_ENV=development NUXT_ENV_APP=dev HOST=10.177.10.231 PORT=4000 nodemon server/index.js --watch server",
"build": "NUXT_ENV_APP=${ENV} nuxt build",
"start": "cross-env NUXT_ENV_APP=${ENV} HOST=0.0.0.0 PORT=3008 NODE_ENV=production node server/index.js",
"generate": "nuxt generate"
},
"dependencies": {
"cookie-universal": "^2.0.16",
"cross-env": "^5.2.0",
"exif-js": "^2.3.0",
"koa": "^2.6.2",
"node-sass": "^4.12.0",
"nuxt": "^2.0.0",
"pica-h5-login": "^1.0.63",
"pica-jsbridge": "^1.0.1",
"sass-loader": "^8.0.0",
"vant": "^2.0.9",
"web-buried-point": "^1.1.27"
},
"devDependencies": {
"@nuxtjs/axios": "^5.5.4",
"@vue/test-utils": "^1.0.0-beta.27",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "^24.1.0",
"jest": "^24.1.0",
"less": "^3.9.0",
"less-loader": "^5.0.0",
"nodemon": "^1.18.9",
"postcss-pxtorem": "^4.0.1",
"qs": "^6.7.0",
"vue-jest": "^3.0.3"
}
}
# PAGES
This directory contains your Application Views and Routes.
The framework reads all the `*.vue` files inside this directory and creates the router of your application.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/routing).
<template>
<section>
年终活动
</section>
</template>
<script>
import { Toast } from 'vant';
import { mapMutations } from 'vuex'
import request from '@/service/api';
import { check, questions,checkLogin } from '@/service';
import popAll from '../components/popAll.vue';
import { getBaseMainUrl, getCookie, delCookie, setCookie } from '../utils/index';
const cookies = require('cookie-universal')();
export default {
head() {
return {
title: '云鹊医-赋能基层医生',
};
},
data() {
return {
}
},
components: {
popAll,
},
created() {
},
mounted() {
let _this = this;
//init ios 方法
_this.$rocNative.appInit();
if (process.client) {
window.__refresh = function(params) {
if(_this.isUploadFresh){
return;
}
//alert(1)
_this.isFirstFresh = false;
_this.getUserInfo()
}
// this.getUserInfo();
this.pageUrl = this.getParmUrlCode('pageUrl')
}
},
methods: {
getParmUrlCode(parm) {
let url = location.href,
s = ''
let index = url.indexOf(parm)
if (index > -1) {
s = url.substr(index + 8)
s = decodeURIComponent(s)
}
return s;
},
getUserInfo(parm) {
const _this = this;
!_this.isWEB && _this.$rocNative.getUserInfo().then(res => {
if (!res.userMobile) {
if (_this.isFirstFresh) {
_this.$rocNative.gotoLogin();
}
if (!_this.isFirstFresh) {
_this.$rocNative.goBack()
}
_this.isFirstFresh = true;
} else {
//sessionStorage.setItem('token',res.userToken);
_this.userMobile = res.userMobile;
_this.getCheck(res.userToken);
}
})
},
...mapMutations([
'SET_TOKEN'
]),
},
}
</script>
<style>
</style>
\ No newline at end of file
# PLUGINS
**This directory is not required, you can delete it if you don't want to use it.**
This directory contains Javascript plugins that you want to run before mounting the root Vue.js application.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/plugins).
import Vue from 'vue'
import PicaJsBridge from '@/utils/jsbridge'
Vue.prototype.$rocNative = new PicaJsBridge();
import Vue from 'vue'
import { BASE_URL } from '@/utils/enumerate';
import PicaH5Login from 'pica-h5-login';
import { Dialog, Toast, Checkbox,Popup ,CheckboxGroup ,RadioGroup, Radio, Progress,ImagePreview ,Uploader,Overlay,Loading } from 'vant';
import WebBuriedPoint, { sendBuriedData } from 'web-buried-point';
Vue.use(Popup).use(Checkbox).use(CheckboxGroup).use(RadioGroup).use(Radio).use(Progress).use(ImagePreview).use(Uploader).use(Overlay).use(Loading);
Vue.use(PicaH5Login);
Vue.use(Toast)
Vue.use(Dialog)
const { NUXT_ENV_APP } = process.env;
Vue.use(WebBuriedPoint, {
class_name: `questionnaire_v2`,
url: `${BASE_URL[NUXT_ENV_APP]}/file/log/trace1`
});
Vue.prototype.$sendBuriedData = sendBuriedData;
\ No newline at end of file
const Koa = require('koa')
const consola = require('consola')
const { Nuxt, Builder } = require('nuxt')
const app = new Koa()
// Import and Set Nuxt.js options
const config = require('../nuxt.config.js')
config.dev = !(app.env === 'production')
async function start() {
// Instantiate nuxt.js
const nuxt = new Nuxt(config)
const {
host = process.env.HOST || '127.0.0.1',
port = process.env.PORT || 3008
} = nuxt.options.server
// Build in development
if (config.dev) {
const builder = new Builder(nuxt)
await builder.build()
} else {
await nuxt.ready()
}
app.use((ctx) => {
ctx.status = 200
ctx.respond = false // Bypass Koa's built-in response handling
ctx.req.ctx = ctx // This might be useful later on, e.g. in nuxtServerInit or with nuxt-stash
nuxt.render(ctx.req, ctx.res)
})
app.listen(port, host)
consola.ready({
message: `Server listening on http://${host}:${port}`,
badge: true
})
}
start()
import Axios from 'axios';
import { Toast } from 'vant';
import { API_CONFIG, REPONSE_CODE } from '@/utils/enumerate';
const { VUE_ENV } = process.env; // server or client
const cookies = require('cookie-universal')();
Axios.interceptors.request.use(
config => {
// 0. Do something before request is sent
// 1. can be add loading
// 2. make sure if need token
const method = config.method.toLocaleLowerCase();
if (method === 'post' || method === 'put' || method === 'delete') {}
if (config.withCredentials) {
config.headers.token = cookies.get('token') || sessionStorage.getItem('token');
}
return config;
},
error => {
// when set loading close it
if (
error.code === 'ECONNABORTED' &&
error.message.indexOf('timeout') !== -1
) {
VUE_ENV === 'client' && Toast({ message: '请求超时', duration: 1000 });
}
return Promise.reject(error);
}
)
export default function(options) {
if (typeof options !== 'object') {
throw new Error('make sure the params options is an Object...');
}
const cf = JSON.parse(JSON.stringify(API_CONFIG));
options = Object.assign(cf, options); // 合并 config
return new Promise((resolve, reject) => {
Axios(options)
.then(res => {
const { status, data } = res;
if (status !== 200) {
let cmsg = REPONSE_CODE[status];
let message = cmsg !== undefined ? cmsg : '系统异常。';
throw Error(message);
}
if (!data) throw Error('axios reponse data in not defined.');
if (data.code != '000000') {
// 如果要是有其他特殊需求在此处添加
console.log(`调用后台接口报错,CODE: ${data.code},MESSAGE: ${data.message}。`);
}
resolve(res.data);
})
.catch(error => {
console.log('axios catch error: ', error.message);
VUE_ENV === 'client' && Toast({ message: error.message, duration: 1000 });
// reject(error);
})
})
}
\ No newline at end of file
// import qs from 'qs';
import request from './api';
// import { async } from 'q';
export const check = async (params) => {
return request({
url: `/campaign/questionnaire/check`,
params,
// 需要在headers设置token
// withCredentials: true,
headers: {
token: params.token
}
})
}
export const checkLogin = async (params) => {
return request({
url: 'campaign/questionnaire/loginAuth',
params,
// 需要在headers设置token
// withCredentials: true,
// headers: {
// token: params.token
// }
})
}
export const questions = async (params) => {
let h = params.setEntry ? { token: params.token} : {}
return request({
url: `campaign/questionnaire/questions`,
params,
// withCredentials: true
headers: h
})
}
export const postQuestion = async (params) => {
return request({
url: `campaign/questionnaire/apply`,
method: 'post',
data: params,
// withCredentials: true
headers: {
token: params.token
}
})
}
\ No newline at end of file
# STATIC
**This directory is not required, you can delete it if you don't want to use it.**
This directory contains your static files.
Each file inside this directory is mapped to `/`.
Thus you'd want to delete this README.md before deploying to production.
Example: `/static/robots.txt` is mapped as `/robots.txt`.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/assets#static).
@charset "utf-8";
html {
color: #000;
background: #fff;
overflow-y: scroll;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%
}
html * {
outline: 0;
-webkit-text-size-adjust: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0)
}
html,body {
font-family: PingFangSC-Regular, -apple-system-font, Source Han Sans, Helvetica Neue, sans-serif;
}
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, textarea, p, blockquote, th, td, hr, button, article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
margin: 0;
padding: 0;
}
/*
input, select, textarea {
font-size: 100%;
}
*/
table {
border-collapse: collapse;
border-spacing: 0;
}
fieldset, img {
border: 0;
}
abbr, acronym {
border: 0;
font-variant: normal;
}
del {
text-decoration: line-through;
}
address, caption, cite, code, dfn, em, th, var {
font-style: normal;
font-weight: 500;
}
ol, ul {
list-style: none;
}
caption, th {
text-align: left;
}
/*
h1, h2, h3, h4, h5, h6 {
font-size: 100%;
font-weight: 500;
}
*/
q:before, q:after {
content: '';
}
sub, sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -.5em;
}
sub {
bottom: -.25em;
}
a:hover {
text-decoration: underline;
}
ins, a {
text-decoration: none;
}
;(function(win, lib) {
var doc = win.document;
var docEl = doc.documentElement;
var metaEl = doc.querySelector('meta[name="viewport"]');
var flexibleEl = doc.querySelector('meta[name="flexible"]');
var dpr = 0;
var scale = 0;
var tid;
var flexible = lib.flexible || (lib.flexible = {});
if (metaEl) {
console.warn('将根据已有的meta标签来设置缩放比例');
var match = metaEl.getAttribute('content').match(/initial\-scale=([\d\.]+)/);
if (match) {
scale = parseFloat(match[1]);
dpr = parseInt(1 / scale);
}
} else if (flexibleEl) {
var content = flexibleEl.getAttribute('content');
if (content) {
var initialDpr = content.match(/initial\-dpr=([\d\.]+)/);
var maximumDpr = content.match(/maximum\-dpr=([\d\.]+)/);
if (initialDpr) {
dpr = parseFloat(initialDpr[1]);
scale = parseFloat((1 / dpr).toFixed(2));
}
if (maximumDpr) {
dpr = parseFloat(maximumDpr[1]);
scale = parseFloat((1 / dpr).toFixed(2));
}
}
}
if (!dpr && !scale) {
var isAndroid = win.navigator.appVersion.match(/android/gi);
var isIPhone = win.navigator.appVersion.match(/iphone/gi);
var devicePixelRatio = win.devicePixelRatio;
if (isIPhone) {
// iOS下,对于2和3的屏,用2倍的方案,其余的用1倍方案
if (devicePixelRatio >= 3 && (!dpr || dpr >= 3)) {
dpr = 3;
} else if (devicePixelRatio >= 2 && (!dpr || dpr >= 2)){
dpr = 2;
} else {
dpr = 1;
}
} else {
// 其他设备下,仍旧使用1倍的方案
dpr = 1;
}
scale = 1 / dpr;
}
docEl.setAttribute('data-dpr', dpr);
if (!metaEl) {
metaEl = doc.createElement('meta');
metaEl.setAttribute('name', 'viewport');
metaEl.setAttribute('content', 'initial-scale=' + scale + ', maximum-scale=' + scale + ', minimum-scale=' + scale + ', user-scalable=no');
if (docEl.firstElementChild) {
docEl.firstElementChild.appendChild(metaEl);
} else {
var wrap = doc.createElement('div');
wrap.appendChild(metaEl);
doc.write(wrap.innerHTML);
}
}
function refreshRem(){
var width = docEl.getBoundingClientRect().width;
if (width / dpr > 540) {
width = 540 * dpr;
}
var rem = width / 10;
docEl.style.fontSize = rem + 'px';
flexible.rem = win.rem = rem;
}
win.addEventListener('resize', function() {
clearTimeout(tid);
tid = setTimeout(refreshRem, 300);
}, false);
win.addEventListener('pageshow', function(e) {
if (e.persisted) {
clearTimeout(tid);
tid = setTimeout(refreshRem, 300);
}
}, false);
if (doc.readyState === 'complete') {
doc.body.style.fontSize = 12 * dpr + 'px';
} else {
doc.addEventListener('DOMContentLoaded', function(e) {
doc.body.style.fontSize = 12 * dpr + 'px';
}, false);
}
refreshRem();
flexible.dpr = win.dpr = dpr;
flexible.refreshRem = refreshRem;
flexible.rem2px = function(d) {
var val = parseFloat(d) * this.rem;
if (typeof d === 'string' && d.match(/rem$/)) {
val += 'px';
}
return val;
}
flexible.px2rem = function(d) {
var val = parseFloat(d) / this.rem;
if (typeof d === 'string' && d.match(/px$/)) {
val += 'rem';
}
return val;
}
})(window, window['lib'] || (window['lib'] = {}));
\ No newline at end of file
# STORE
**This directory is not required, you can delete it if you don't want to use it.**
This directory contains your Vuex Store files.
Vuex Store option is implemented in the Nuxt.js framework.
Creating a file in this directory automatically activates the option in the framework.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/vuex-store).
// import { getHospital } from '@/service';
export const state = () => ({
userToken:null,
});
export const mutations = {
SET_TOKEN: (state, userToken) => {
state.userToken = userToken
},
};
export const actions = {
setToken({ commit }, userToken) {
commit('SET_TOKEN', userToken)
},
};
import { mount } from '@vue/test-utils'
import Logo from '@/components/Logo.vue'
describe('Logo', () => {
test('is a Vue instance', () => {
const wrapper = mount(Logo)
expect(wrapper.isVueInstance()).toBeTruthy()
})
})
const { NUXT_ENV_APP } = process.env;
export const BASE_URL = {
//dev: 'https://dev-sc.yunqueyi.com',
dev:'https://uat-sc.yunqueyi.com',
test: 'https://test1-sc.yunqueyi.com',
uat: 'https://uat-sc.yunqueyi.com',
prod: 'https://sc.yunqueyi.com'
};
export const API_CONFIG = {
baseURL: BASE_URL[NUXT_ENV_APP],
headers: {
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'application/json;charset=UTF-8'
},
timeout: 10000,
withCredentials: false,
responseType: 'json',
method: 'get'
}
export const REPONSE_CODE = {
400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
401: '用户没有权限(登录过期、token错误)',
403: '用户得到授权,但是访问是被禁止的。',
404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
406: '请求的格式不可得。',
410: '请求的资源被永久删除,且不会再得到的。',
422: '当创建一个对象时,发生一个验证错误。',
500: '服务器发生错误,请检查服务器。',
502: '网关错误。',
503: '服务不可用,服务器暂时过载或维护。',
504: '网关超时。'
};
export const ENV_CONFIG = {
development: {
baseUrl: 'http://10.177.10.217:10201/',
apiUrl: 'https://dev-api.yunqueyi.com/',
shareUrl: 'https://dev-phome.yunqueyi.com/',
topicUrl: 'http://10.177.11.245:8081',
wxLoginUrl : 'https://sc.yunqueyi.com/wechats/users',
},
dev: {
baseUrl: 'https://dev-sc.yunqueyi.com/',
apiUrl: 'https://dev-api.yunqueyi.com/',
shareUrl:'https://dev-phome.yunqueyi.com/',
topicUrl:'https://dev-discuss.yunqueyi.com',
wxLoginUrl: 'https://sc.yunqueyi.com/wechats/users',
domain:'https://dev-sc.yunqueyi.com/account',
APPID:'wx2c577552a2d28550',
},
test: {
baseUrl: 'https://test1-sc.yunqueyi.com/',
apiUrl: 'https://test1-api.yunqueyi.com/',
shareUrl: 'https://test1-phome.yunqueyi.com/',
topicUrl: 'https://test1-discuss.yunqueyi.com',
wxLoginUrl : 'https://test1-sc.yunqueyi.com/wechats/users',
domain : 'https://test1-sc.yunqueyi.com/account',
APPID:'wxebc0cc65cca7694b' ,
},
uat: {
baseUrl: 'https://uat-sc.yunqueyi.com/',
apiUrl: 'https://uat-api.yunqueyi.com/',
shareUrl: 'https://uat-phome.yunqueyi.com/',
topicUrl: 'https://uat-discuss.yunqueyi.com',
wxLoginUrl : 'https://uat-sc.yunqueyi.com/wechats/users',
domain : 'https://uat-sc.yunqueyi.com/account',
APPID:'wx342ef0e5afee54a7',
},
prod: {
baseUrl: 'https://sc.yunqueyi.com/',
apiUrl: 'https://api.yunqueyi.com/',
shareUrl: 'https://phome.yunqueyi.com/',
topicUrl: 'https://discuss.yunqueyi.com',
wxLoginUrl : 'https://sc.yunqueyi.com/wechats/users',
domain : 'https://sc.yunqueyi.com/account',
APPID:'wx2c577552a2d28550',
}
};
import { ENV_CONFIG } from './enumerate.js'
function p_getElm(elmId) {
return document.getElementById(elmId)
}
/**
* 配置编译环境和线上环境之间的切换
*/
function getTestEnv (ipAddress) {
let environments = ["localhost","dev", "uat","test1","10.177.10.231"];
for (let i = 0; i < environments.length; i++) {
if (ipAddress.indexOf(environments[i]) > -1) {
return environments[i];
}
}
return null;
};
// 根据不同环境,生成URL
function getConfigByEnvType(urlType) {
if (process.client){
console.log(window)
let ipAddress = "https://" + window.location.host;
let parm = null;
let env = getTestEnv(ipAddress);
if(env == 'localhost' || env == 'dev' || env == 'test1' || env == "10.177.10.231"){
parm = 'test'
}else{
parm = 'prod'
}
// console.log(parm)
console.log(ENV_CONFIG[parm][urlType])
return ENV_CONFIG[parm][urlType]
}
}
import { ENV_CONFIG } from './enumerate';
const { NUXT_ENV_APP } = process.env;
export const getSearchByName = name => {
const match = RegExp(`[?&]${name}=([^&]*)`).exec(window.location.href);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
};
export const getItem = name => {
if (!name) return;
const v = sessionStorage.getItem(name);
let val = null;
try {
val = JSON.parse(v);
} catch (e) {
// JSON.parse 失败 后 直接赋v给val;
val = v;
}
return val;
};
export const setItem = (name, value) => {
if (!name) return;
if (typeof value !== 'string') {
value = JSON.stringify(value);
}
sessionStorage.setItem(name, value);
};
export const removeItem = name => {
if (!name) return;
sessionStorage.removeItem(name);
};
export const getConfigByEvtType = key => {
return ENV_CONFIG[NUXT_ENV_APP][key];
}
export const getNoticeUrl = url => {
return `${getConfigByEvtType('noticeUrl')}${url}`;
}
export const getWxLoginUrl = url => {
return `${getConfigByEvtType('wxLoginUrl')}`;
}
export const getWxAPPID = url => {
return `${getConfigByEvtType('APPID')}`;
}
// 获取SC服务器域名地址
export const getBaseUrl = url => {
return `${getConfigByEvtType('baseUrl')}${url}`;
}
// 获取API服务器域名地址
export const getApiUrl = url => {
return `${getConfigByEvtType('apiUrl')}${url}`;
}
export const getWxDomainUrl = url => {
return `${getConfigByEvtType('domain')}`;
}
export const getShareUrl = url => {
return `${getConfigByEvtType('shareUrl')}`;
}
export const getBaseMainUrl = url => {
return `${getConfigByEvtType('baseUrl')}`;
}
export const getCookie = cname => {
        var name = cname + "=";
        var ca = document.cookie.split(';');
        //console.log("获取cookie,现在循环")
        for (var i = 0; i < ca.length; i++) {
          var c = ca[i];
         // console.log(c)
          while (c.charAt(0) == ' ') c = c.substring(1);
          if (c.indexOf(name) != -1){
            return c.substring(name.length, c.length);
          }
        }
        return "";
    };
export const delCookie = (name,domain) =>{
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval = getCookie(name);
if(cval!=null){
//document.cookie = name + "="+cval+";expires="+exp.toGMTString();
document.cookie = name + '=; path=/; expires=' + new Date(0).toUTCString();
document.cookie = name + '=; path=/; domain=.yunqueyi.com; expires=' + new Date(0).toUTCString();
}
};
export const setCookie = (cname, cvalue, exdays) => {
        var d = new Date();
        d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
//d.setTime(d.getTime() + (2* 60 * 1000));
        var expires = "expires=" + d.toUTCString();
       // console.info(cname + "=" + cvalue + "; " + expires);
        document.cookie = cname + "=" + cvalue + ";path=/;" + expires;
        //console.info(document.cookie);
    };
export const setEventByModuleCode = (itemData, token) => {
let modeCode = itemData.code || '';
let paramList = itemData.paramList ? itemData.paramList : '';
if (modeCode === 'M001' || modeCode === 'M002' || modeCode === 'M003') {
paramList = '';
} else if (
modeCode === 'M100' ||
modeCode === 'M300' ||
modeCode === 'M500' || modeCode === 'M301'
) {
let urlPara = getUrlParmByCode(paramList, token);
paramList[0] && (paramList[0].value += urlPara);
// 前端拼接了数据,原生不用再拼接
paramList = paramList.slice(0, 1)
}
if (typeof paramList === 'string' && !paramList) {
paramList = [];
}
return paramList;
}
export const refreFun = () => {
let str = location.href,
a = '',
b = '',
url = ''
if(str.indexOf('?code') > -1){
a = str.split('#')[0].split('?')[0];
b = str.split('#')[1];
url = a + '#' + b;
console.log(url)
setTimeout(()=>{
location.href = url;
},1000)
}
}
export const pageBurialPoin = (options) => {
let opt = {
menuLevel: options.menuLevel || '',
functionCode: options.functionCode || '',
actionCode: options.actionCode || '',
// label:options.label || '',
labelId: options.labelId || '',
labelValue: options.labelValue || '',
createdTime: options.createdTime || new Date().getTime(),
//type: options.type || '0',
menuCode: options.menuCode || '',
// menuToCode:options.menuToCode || '',
duration: options.duration || 0,
menuFromCode: options.menuFromCode || '',
params: options.params || '',
session: options.session || ''
};
rocNative.appBuryingPointEntrust(opt);
}
function getUrlParmByCode(paramList, token) {
if (paramList.length <= 1) return `?token=${token}`;
let dataStr = '', list = [];
let str = paramList.length > 0 && paramList[0].value.indexOf('?') > -1 ? '&' : '?';
for (let i = 1; i < paramList.length; i++) {
list.push(paramList[i].key + '=' + encodeURI(paramList[i].value));
}
dataStr = list.join('&');
s
if (dataStr !== '') return `${str}${dataStr}&token=${token}`;
return `${str}token=${token}`;
}
// 根据不同环境获取topic的URL
// export function getTopicUrl() {
// return getConfigByEvtType('topicUrl')
// }
// // 获取WEB部署服务器域名地址
// export function getBaseMainUrl() {
// return getConfigByEvtType('baseUrl');
// }
// 根据不同环境,生成URL
\ No newline at end of file
/*
* @Author: souse
* @Date: 2019-08-12 18:08:07
* @Last Modified by: souse
* @Last Modified time: 2019-09-05 15:45:26
* @Descript 和app交互的接口调用 单例模式
*/
const ARRAY_CLASS = '[object Array]';
const _toString = Object.prototype.toString;
/**
* set default options
*/
export const JsBridgeOptions = {
GLOBAL_NAME: 'rocNative',
NATIVE_IOS_NAME: 'rociOS',
NATIVE_ANDROID_NAME: '__rocAndroid',
initMethodsWithCallBack: ['getToken', 'getUserInfo','addEnclosure'], // value is string
initMethodsWithoutCallBack: ['appInit', 'goBack','gotoLogin', 'shareWechat', 'showNativeToast', 'dispatchEventByModuleCode', 'appBuryingPointEntrust', 'webLoadSuccess','WfileImageCallBack','selectPhoto'] // value is string
}
/**
* @description
* @author souse
* @date 2019-08-12
* @export
* @class PicaJsBridge
*/
export default class PicaJsBridge {
constructor(options = JsBridgeOptions) {
const initMethodsWithCallBack = options.initMethodsWithCallBack;
const initMethodsWithoutCallBack = options.initMethodsWithoutCallBack;
this._callbakFns = {};
this._callbackId = 0;
this._GLOBAL_NAME = options.GLOBAL_NAME;
this._NATIVE_IOS_NAME = options.NATIVE_IOS_NAME;
this._NATIVE_ANDROID_NAME = options.NATIVE_ANDROID_NAME;
this.isIOS = this._isIos();
this.isAndroid = this._isAndroid();
this.isWeb = this._isWeb();
if (_toString.call(initMethodsWithCallBack) === ARRAY_CLASS && initMethodsWithCallBack.length !== 0) {
this.registerMethods(initMethodsWithCallBack, true);
}
if (_toString.call(initMethodsWithoutCallBack) === ARRAY_CLASS && initMethodsWithoutCallBack.length !== 0) {
this.registerMethods(initMethodsWithoutCallBack, false);
}
this.mountToWindow();
}
// is ios flag
_isIos() {
return !!(window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers[this._NATIVE_IOS_NAME]);
}
// is android flag
_isAndroid() {
return !!window[this._NATIVE_ANDROID_NAME];
}
// is web flag
_isWeb() {
return !this.isIOS && !this.isAndroid;
}
// register method width callback in window
_registerMethod(method) {
const _this = this;
_this[method] = (param) => {
return new Promise((response, reject) => {
_this._callNative(method, param, function(result) {
response(result);
}) ? void 0 : reject(`${method} not handled.`);
});
}
}
// register method widthout callback in window
_registerMethodWithoutMethod(method) {
const _this = this;
_this[method] = (param) => {
return new Promise((response, reject) => {
_this._callNative(method, param, null) ? response('success') : reject(`${method} not handled.`);
});
}
}
// window call app method
_callNative(name, param, callbackFn) {
let callbackId = 0, pm;
//alert(name)
if (typeof callbackFn === 'function') {
this._callbackId++;
callbackId = this._callbackId;
this._callbakFns[callbackId] = callbackFn;
}
pm = JSON.stringify({
name,
callbackId: callbackId ? callbackId.toString() : '',
param: param || {}
});
if (this.isAndroid) {
window[this._NATIVE_ANDROID_NAME].postMessage(pm);
return true;
}
if (this.isIOS) {
window.webkit.messageHandlers[this._NATIVE_IOS_NAME].postMessage(pm);
return true;
}
return false;
}
// app call window method
// __nativeCall(name, callbackId, result) {
// const fun = callbackId && this._callbakFns[callbackId];
//
// delete this._callbakFns[callbackId];
//
// if (fun && typeof fun === 'function') fun(result);
// }
__nativeCall(name, callbackId, result) {
// alert(`${name}__${callbackId}__${JSON.stringify(result)}`);
const wFun = callbackId === '__refresh' ? window[callbackId] : window[name];
const fun = callbackId && this._callbakFns[callbackId];
//add by zhangping
if (wFun && typeof wFun === 'function') {
wFun(result);
return;
}
delete this._callbakFns[callbackId];
if (fun && typeof fun === 'function') fun(result);
}
// batch register methods
registerMethods(methods = [], widthCallback) {
if (undefined === widthCallback)
throw Error('widthCallback flag not defined, registerMethods should take second param value(true/false) for is not has callback.');
methods.forEach(m => {
widthCallback === true ? this._registerMethod(m) : this._registerMethodWithoutMethod(m)
});
}
// async call app method do not need register
asyncCallNative(method, param) {
const _this = this;
return new Promise(resolve => {
_this._callNative(method, param, function(result) {
resolve(result);
});
});
}
// call app method direct without register and callback
callNative(method, param) {
return this._callNative(method, param, null);
}
// register jsbridge to window
mountToWindow() {
window[this._GLOBAL_NAME] = this;
}
}
\ No newline at end of file
/* eslint-disable */
import axios from 'axios';
import { getWxLoginUrl,getWxDomainUrl,getWxAPPID } from './index'
let wxLoginUrl = getWxLoginUrl();
let domain = getWxDomainUrl();
// let AAPID = getWxAPPID()
// console.log(AAPID)
// 查询url的参数
const getSearch = (paraName) => {
var url = document.location.toString();
var arrObj = url.split("?");
if (arrObj.length > 1) {
var arrPara = arrObj[1].split("&");
var arr;
for (var i = 0; i < arrPara.length; i++) {
arr = arrPara[i].split("=");
if (arr != null && arr[0] == paraName) {
return arr[1];
}
}
return "";
}
else {
return "";
}
}
const _getUnionid = (openId) => {
//alert('_getUnionid')
return axios.get(`${wxLoginUrl}?openId=${openId}&type=15`)
}
const _getToken = (unionid) => {
return axios.post(`${domain}/account/login/wechat`,{
unionid
})
}
// 获取AppId
const _getAppId = (weixinCode) => {
return axios.get(`${wxLoginUrl}/openid?code=${weixinCode}&type=15`)
}
//获取数据
export const getMessage = async (code, call) => {
let appid,Unionid,token;
appid = await _getAppId(code);
//alert('appid:'+JSON.stringify(appid))
if (appid.data.code == '000000') {
//'oS3TnwCgn0w13GQzL0lvuHi-0ho4'
Unionid = await _getUnionid(appid.data.data.openId)
//alert('Unionid:'+JSON.stringify(Unionid))
console.log(Unionid.data.code)
if(Unionid.data.code == '000000'){
if(Unionid.data.data.unionid){
window.sessionStorage.setItem("unionid", Unionid.data.data.unionid);
}
token = await _getToken(Unionid.data.data.unionid)
call(token.data.data);
// if(token.data.code == '000000'){
//
// call(token.data.data);
// }
}
}
}
//弹出微信授权
export const wxGetCode = () => {
let url = location.href
let redirectUrl = encodeURIComponent(url);
const appid = getWxAPPID();
window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirectUrl}&response_type=code&scope=snsapi_userinfo&#wechat_redirect`
}
//截取微信授权后的code
export const wxGetUrlCode = () => {
// let weixinCode = '021SKjQz1nnukc0Y3rNz1WqbQz1SKjQy';
let code = getSearch('code'); //获取返回路径的code
return code || '';
}
// export const wxGetToken
//判断当前是不是微信内部
export const is_weixin = () => {
let ua = navigator.userAgent.toLowerCase();
 let isWeixin = ua.indexOf('micromessenger') != -1;
 if (isWeixin) {
  return true;
 }else{
   return false;
 }
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册