Commit dfc1d76d by 潘琦

增加鉴权相关代码

parent 14971bd8
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
const merge = require('webpack-merge') const merge = require('webpack-merge')
const prodEnv = require('./prod.env') const prodEnv = require('./prod.env')
const baseUrl = '"http://voucher.check.icaremgt.com"' //打包后请求前缀(开发)
// const baseUrl = '"http://voucher.check.icaremgt.com"' //打包后请求前缀(正式)
module.exports = merge(prodEnv, { module.exports = merge(prodEnv, {
NODE_ENV: '"development"' NODE_ENV: '"development"',
API_ROOT: baseUrl
}) })
...@@ -3,11 +3,18 @@ ...@@ -3,11 +3,18 @@
// see http://vuejs-templates.github.io/webpack for documentation. // see http://vuejs-templates.github.io/webpack for documentation.
const path = require('path') const path = require('path')
// const url = 'http://voucher.check.icaremgt.com' // 开发 const url = 'http://voucher.check.icaremgt.com' // 开发
const url = 'http://voucher.icaremgt.com' // 正式 // const url = 'http://voucher.icaremgt.com' // 正式
// const sjkgurl = 'https://api-wx-service.check.icaremgt.com' // 机构空间(开发) const sjkgurl = 'https://api-wx-service.check.icaremgt.com' // 机构空间(开发)
const sjkgurl = 'https://sjkg-wx-service.icaremgt.com' // 机构空间(正式) // const sjkgurl = 'https://sjkg-wx-service.icaremgt.com' // 机构空间(正式)
// console.log('NODE_ENV' + process.env.NODE_ENV)
// if (process.env.NODE_ENV === 'production') {
// let root = process.env.API_ROOT
// axios.defaults.baseURL = root // 开发服
// }
module.exports = { module.exports = {
dev: { dev: {
...@@ -84,7 +91,7 @@ module.exports = { ...@@ -84,7 +91,7 @@ module.exports = {
// Paths // Paths
assetsRoot: path.resolve(__dirname, '../dist'), assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static', assetsSubDirectory: 'static',
assetsPublicPath: '/', assetsPublicPath: '/voucher/',
/** /**
* Source Maps * Source Maps
......
'use strict' 'use strict'
module.exports = { const merge = require('webpack-merge')
NODE_ENV: '"production"' const prodEnv = require('./prod.env')
}
const baseUrl = '"http://voucher.check.icaremgt.com"' //打包后请求前缀(开发)
// const baseUrl = '"http://voucher.check.icaremgt.com"' //打包后请求前缀(正式)
module.exports = merge(prodEnv, {
NODE_ENV: '"production"',
API_ROOT: baseUrl
})
...@@ -16331,6 +16331,11 @@ ...@@ -16331,6 +16331,11 @@
"integrity": "sha1-XS/yKXcAPsaHpLhwc9+7rBRszyk=", "integrity": "sha1-XS/yKXcAPsaHpLhwc9+7rBRszyk=",
"dev": true "dev": true
}, },
"weixin-js-sdk": {
"version": "1.4.0-test",
"resolved": "https://registry.npm.taobao.org/weixin-js-sdk/download/weixin-js-sdk-1.4.0-test.tgz",
"integrity": "sha1-YSu6/Ml62E9a/m3IRwFTTMWfw8o="
},
"whatwg-encoding": { "whatwg-encoding": {
"version": "1.0.5", "version": "1.0.5",
"resolved": "https://registry.npm.taobao.org/whatwg-encoding/download/whatwg-encoding-1.0.5.tgz", "resolved": "https://registry.npm.taobao.org/whatwg-encoding/download/whatwg-encoding-1.0.5.tgz",
......
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
"qrcodejs2": "0.0.2", "qrcodejs2": "0.0.2",
"vue": "^2.5.2", "vue": "^2.5.2",
"vue-router": "^3.0.1", "vue-router": "^3.0.1",
"vuex": "^3.1.1" "vuex": "^3.1.1",
"weixin-js-sdk": "^1.4.0-test"
}, },
"devDependencies": { "devDependencies": {
"autoprefixer": "^7.1.2", "autoprefixer": "^7.1.2",
......
...@@ -109,7 +109,7 @@ ul li { ...@@ -109,7 +109,7 @@ ul li {
color: #fff; color: #fff;
font-size: 1.1em; font-size: 1.1em;
box-shadow: 2px 3px 10px rgb(67, 209, 190, 0.5); box-shadow: 2px 3px 10px rgb(67, 209, 190, 0.5);
padding: 12px 0; padding: 15px 0;
line-height: initial; line-height: initial;
border: 0; border: 0;
outline: none; outline: none;
...@@ -176,6 +176,13 @@ ul li { ...@@ -176,6 +176,13 @@ ul li {
outline: none; outline: none;
} }
.btn-white{
color: #333;
background-color: #fff;
border-color: #ccc;
padding: 10px;
outline: none;
}
.btn-white-o { .btn-white-o {
display: inline-block; display: inline-block;
background-color: transparent; background-color: transparent;
...@@ -186,6 +193,7 @@ ul li { ...@@ -186,6 +193,7 @@ ul li {
line-height: initial; line-height: initial;
border-radius: 25px; border-radius: 25px;
border: 1px solid #eeeeee; border: 1px solid #eeeeee;
outline: none;
} }
.btn-samll { .btn-samll {
...@@ -196,6 +204,10 @@ ul li { ...@@ -196,6 +204,10 @@ ul li {
color: #43d1be; color: #43d1be;
} }
.btn-circle {
border-radius: 32px;
}
.m-normal { .m-normal {
margin: 0 !important; margin: 0 !important;
} }
...@@ -210,6 +222,43 @@ ul li { ...@@ -210,6 +222,43 @@ ul li {
padding-bottom: 0 !important; padding-bottom: 0 !important;
} }
.icon-pleased-gray::before{
content: " ";
display: inline-block;
width: 22px;
height: 22px;
background-image: url("./assets/images/icon-pleased-gray.png");
background-repeat: no-repeat;
background-size: 100% auto;
}
.icon-pleased-white::before{
content: " ";
display: inline-block;
width: 22px;
height: 22px;
background-image: url("./assets/images/icon-pleased-white.png");
background-repeat: no-repeat;
background-size: 100% auto;
}
.icon-unpleased-gray::before{
content: " ";
display: inline-block;
width: 22px;
height: 22px;
background-image: url("./assets/images/icon-unpleased-gray.png");
background-repeat: no-repeat;
background-size: 100% auto;
}
.icon-unpleased-white::before{
content: " ";
display: inline-block;
width: 22px;
height: 22px;
background-image: url("./assets/images/icon-pleased-white.png");
background-repeat: no-repeat;
background-size: 100% auto;
}
.detail-card { .detail-card {
background-color:#fff; background-color:#fff;
border-radius: 7px; border-radius: 7px;
......
...@@ -83,3 +83,12 @@ export function getContentInfo (params) { ...@@ -83,3 +83,12 @@ export function getContentInfo (params) {
method: 'GET' method: 'GET'
}) })
} }
// 服务券服务评价
export function evaluationThree (params) {
return request({
url: '/apply/evaluation/evaluationThree',
method: 'POST',
params: params
})
}
import request from '@/router/request' import request from '@/router/requestToken'
// 鉴权 // 鉴权
export function getOauth (params) { export function getOauth (params) {
return request({ return request({
url: '/auth/oauth/token', url: '/wxoauth/getToken',
headers: { // headers: {
isToken: false, // isToken: false,
'TENANT_ID': '1', // 'TENANT_ID': '1',
'Authorization': 'Basic dGVzdDp0ZXN0' // 'Authorization': 'Basic dGVzdDp0ZXN0'
}, // },
method: 'POST',
params: params
})
}
// 根据token获取用户信息
export function getUserByToken (params) {
return request({
url: '/wxoauth/getUserByToken',
method: 'POST', method: 'POST',
params: params params: params
}) })
......
import request from '@/router/requestToken' import request from '@/router/requestToken'
// 团队列表 // 团队列表
export function WXconfirm(params) { export function WXconfirm (params) {
return request({ return request({
url: '/wxjsauth/getToken', url: '/wxjsauth/getToken',
method: 'post', method: 'post',
......
...@@ -3001,7 +3001,7 @@ select[multiple].input-lg { ...@@ -3001,7 +3001,7 @@ select[multiple].input-lg {
-ms-user-select: none; -ms-user-select: none;
user-select: none; user-select: none;
} }
.btn:focus, /* .btn:focus,
.btn:active:focus, .btn:active:focus,
.btn.active:focus, .btn.active:focus,
.btn.focus, .btn.focus,
...@@ -3009,7 +3009,7 @@ select[multiple].input-lg { ...@@ -3009,7 +3009,7 @@ select[multiple].input-lg {
.btn.active.focus { .btn.active.focus {
outline: 5px auto -webkit-focus-ring-color; outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px; outline-offset: -2px;
} } */
.btn:hover, .btn:hover,
.btn:focus, .btn:focus,
.btn.focus { .btn.focus {
......
<template>
<div class="comment-result">
<div class="status">
<img src="../assets/images/result-success.png" class="result-img" mode="widthFix"/>
<div class="message">评价成功</div>
</div>
<!-- <div class="body">
<div class="title">猜你喜欢</div>
<div class="content-list m-b">
<div class="content-item">
<div class="content-body">
<div class="content-cell info">
<div class="title">梁惠贞教授本周巡回巡回巡回</div>
<div class="des">
宫寒常伴不孕,听梁惠贞专家怎么说宫寒常伴不孕,听梁
</div>
<div class="datetime">
2018/11/01 17:00
</div>
</div>
<div class="content-cell poster">
<div class="poster-img">
<img src="/static/images/doctor.jpg" class="full-width" mode="widthFix"/>
</div>
</div>
</div>
</div>
<div class="content-item">
<div class="content-body">
<div class="content-cell info">
<div class="title">梁惠贞教授本周巡回巡回巡回</div>
<div class="des">
宫寒常伴不孕,听梁
</div>
<div class="datetime">
2018/11/01 17:00
</div>
</div>
<div class="content-cell poster">
<div class="poster-img">
<img src="/static/images/doctor.jpg" class="full-width" mode="widthFix"/>
</div>
</div>
</div>
</div>
</div>
</div> -->
</div>
</template>
<script>
export default {
props: [''],
methods: {
}
}
</script>
<style>
.comment-result {
background-color: #fafbfc;
padding: 10px;
font-size: 14px;
color: #343434;
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
z-index: 9;
}
.comment-result .status {
text-align: center;
margin: 30px 0 45px 0;
}
.comment-result .status .result-img {
width: 150px;
margin-bottom: 20px;
}
.comment-result .status .message {
font-size: 20px;
font-weight: bold;
color: #62cf50;
text-align: center;
}
.comment-result .body .title {
font-size: 14px;
margin-bottom: 10px;
color: #999;
}
/* .content-list {
} */
.content-list > .content-item {
padding: 10px;
box-shadow: 1px 5px 5px #eee;
background-color: #fff;
margin-bottom: 15px;
}
.content-list > .content-item .content-body {
display: table;
width: 100%;
}
.content-list > .content-item .content-body .content-cell {
display: table-cell;
vertical-align: middle;
}
.content-list > .content-item .content-body .info{
color: #999999;
}
.content-list > .content-item .content-body .content-cell.info{
position: relative;
padding-bottom: 30px;
}
.content-list > .content-item .content-body .info > .title {
font-size: 16px;
font-weight: bold;
color: #4B5760;
margin-bottom: 5px;
}
.content-list > .content-item .content-body .content-cell.info > .title {
white-space: nowrap;
text-overflow: ellipsis;
max-width: 200px;
overflow: hidden;
}
.content-list > .content-item .content-body .content-cell.info > .datetime {
position: absolute;
width: 100%;
bottom: 0;
left: 0;
}
.content-list > .content-item .content-body .content-cell.poster {
width: 120px;
}
.content-list > .content-item .content-body .poster .poster-img {
border-radius: 5px;
overflow: hidden;
}
</style>
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
// (runtime-only or standalone) has been set in webpack.base.conf with an alias. // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue' import Vue from 'vue'
import App from './App' import App from './App'
import router from './router'
import store from './store'
import './permission' // 权限 import './permission' // 权限
import router from './router/index'
import store from './store'
import { import {
Button, Button,
Cell, Cell,
...@@ -48,6 +48,7 @@ Vue.prototype.$MessageBox = MessageBox ...@@ -48,6 +48,7 @@ Vue.prototype.$MessageBox = MessageBox
Vue.prototype.$Indicator = Indicator Vue.prototype.$Indicator = Indicator
Vue.config.productionTip = false Vue.config.productionTip = false
// Vue.http.options.emulateJSON = true
/* eslint-disable no-new */ /* eslint-disable no-new */
new Vue({ new Vue({
......
import router from './router' import router from './router/index'
import {getStore, setStore} from '@/util/store' import store from '@/store'
// import {validatenull} from '@/util/validate' // import {validatenull} from '@/util/validate'
import { getOauth } from '@/api/auth/auth' import { getParamsByUrl, removeUrlParam } from '@/util/index'
import { getOauth, getUserByToken } from '@/api/auth/auth'
import { Toast } from 'mint-ui' import { Toast } from 'mint-ui'
// const baseUrl = 'http://www.icareyou.net' // 正式
const baseUrl = 'http://test.icareyou.net' // 开发
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
console.log('缓冲设置') console.log('缓冲设置')
let accessToken = getStore({ name: 'access_token' }) console.log('code ===' + store.getters.code)
if (accessToken) { // store.dispatch('setToken', '')
// store.dispatch('setUserId', '')
// let accessToken = store.getters.access_token
let storecode = store.getters.code
if (!storecode || storecode === '') {
let params = getParamsByUrl(window.location.href)
if (params.code) {
store.dispatch('setCode', params.code)
getOauthFn(() => {
next() next()
})
} else {
getWXOauth()
}
} else { } else {
next()
}
})
let getWXOauth = () => {
console.log()
let url = removeUrlParam('code')
// store.dispatch('setCode', '')
let authId = ''
if (getParamsByUrl(window.location.href).auth_id) {
authId = '&auth_id=' + getParamsByUrl(window.location.href).auth_id
store.dispatch('setAuthId', getParamsByUrl(window.location.href).auth_id)
}
window.location.href = baseUrl + '/wxoauth/route?redirect_uri=' + encodeURIComponent(url) + authId + '&scoe=&auth_scene=voucher'
}
let getOauthFn = (callback) => {
let spoauthParams = { let spoauthParams = {
username: 'admin', code: store.getters.code
password: '0nQrmF2Zl9jz40AIUbpsbg==',
// randomStr: '13131563353180801',
// code: '4882',
grant_type: 'password',
scope: 'server'
} }
getOauth(spoauthParams).then(function (res) { getOauth(spoauthParams).then(function (res) {
if (res.access_token && res.access_token !== '' && res.user_id && res.user_id !== '') { if (res.token && res.token !== '') {
setStore({ name: 'access_token', content: res.access_token }) getUserByTokenFn(res.token, store.getters.code, callback)
setStore({ name: 'user_id', content: res.user_id })
next()
} else { } else {
store.dispatch('setCode', '')
setTimeout(function () {
getWXOauth()
}, 3 * 1000)
Toast({ Toast({
message: 'token不能为空!', message: 'wx token已失效!',
position: 'center', position: 'center',
duration: 3000 duration: 3 * 1000
}) })
} }
}).catch((error) => { }).catch((error) => {
...@@ -36,58 +65,72 @@ router.beforeEach((to, from, next) => { ...@@ -36,58 +65,72 @@ router.beforeEach((to, from, next) => {
Toast({ Toast({
message: '鉴权失败', message: '鉴权失败',
position: 'center', position: 'center',
duration: 3000 duration: 3 * 1000
}) })
// setTimeout(function () {
// getWXOauth()
// }, 3 * 1000)
}) })
}
const getUserByTokenFn = (token, code, callback) => {
let spoauthParams = {
token: token
} }
// // 缓冲设置 getUserByToken(spoauthParams).then(function (res) {
// if (to.meta.keepAlive === true && store.state.tags.tagList.some(ele => { let accessToken = ''
// return ele.value === to.fullPath let userId = ''
// })) { if (res.ext && res.ext !== '') {
// to.meta.$keepAlive = true let extOBJ = JSON.parse(res.ext)
// } else { accessToken = extOBJ.access_token
// NProgress.start() userId = extOBJ.user_id
// if (to.meta.keepAlive === true && validatenull(to.meta.$keepAlive)) { }
// to.meta.$keepAlive = true if (accessToken !== '') {
// } else { if (userId !== '') {
// to.meta.$keepAlive = false store.dispatch('setToken', accessToken)
// } store.dispatch('setUserId', userId)
store.dispatch('setCode', code)
callback()
} else {
setTimeout(function () {
getWXOauth()
}, 3 * 1000)
Toast({
message: 'user id不能为空!',
position: 'center',
duration: 3 * 1000
})
}
} else {
setTimeout(function () {
getWXOauth()
}, 3 * 1000)
Toast({
message: 'token不能为空!',
position: 'center',
duration: 3 * 1000
})
}
}).catch((error) => {
console.log(error)
Toast({
message: '鉴权失败',
position: 'center',
duration: 3 * 1000
})
setTimeout(function () {
getWXOauth()
}, 3 * 1000)
})
}
// const nextToPath = (to, from, next) => {
// let toquery = to.query
// if (from.query.code) {
// toquery.code = from.query.code
// } // }
// const meta = to.meta || {} // next({
// if (store.getters.access_token) { // path: to.path,
// if (store.getters.isLock && to.path != lockPage) { // query: toquery
// next({path: lockPage})
// } else if (to.path === '/login') {
// next({path: '/'})
// } else {
// if (store.getters.roles.length === 0) {
// store.dispatch('GetUserInfo').then(() => {
// next({...to, replace: true})
// }).catch(() => {
// store.dispatch('FedLogOut').then(() => {
// next({path: '/login'})
// })
// })
// } else {
// const value = to.query.src || to.fullPath
// const label = to.query.name || to.name
// if (meta.isTab !== false && !validatenull(value) && !validatenull(label)) {
// store.commit('ADD_TAG', {
// label: label,
// value: value,
// params: to.params,
// query: to.query,
// group: router.$avueRouter.group || []
// }) // })
// } // }
// next()
// }
// }
// } else {
// if (meta.isAuth === false) {
// next()
// } else {
// next('/h5')
// }
// }
})
...@@ -84,6 +84,21 @@ export default new Router({ ...@@ -84,6 +84,21 @@ export default new Router({
meta: {keepAlive: false, title: '知识详情'} meta: {keepAlive: false, title: '知识详情'}
}, },
{ {
path: '/comment',
name: 'comment',
component: (resolve) => require(['@/views/comment/index'], resolve),
redirect: '/comment/comment',
meta: {keepAlive: false, title: '服务评价'},
children: [
{
path: 'comment',
name: '服务评价',
component: (resolve) => require(['@/views/comment/comment'], resolve),
meta: {keepAlive: false, title: '服务评价'}
}
]
},
{
path: '/recommend', path: '/recommend',
name: 'recommend', name: 'recommend',
component: (resolve) => require(['@/views/recommend/index'], resolve), component: (resolve) => require(['@/views/recommend/index'], resolve),
...@@ -104,5 +119,6 @@ export default new Router({ ...@@ -104,5 +119,6 @@ export default new Router({
} }
] ]
} }
] ],
base: '/voucher/'
}) })
import axios from 'axios' import axios from 'axios'
import { getStore, setStore } from '@/util/store' import store from '../store'
import { Toast } from 'mint-ui' import { Toast } from 'mint-ui'
import router from '@/router/index' import router from '@/router/index'
import { removeUrlParam } from '@/util/index'
axios.defaults.timeout = 30000 axios.defaults.timeout = 30000
console.log('NODE_ENV' + process.env.NODE_ENV)
if (process.env.NODE_ENV === 'production') {
let root = process.env.API_ROOT
axios.defaults.baseURL = root // 开发服
}
// 返回其他状态吗 // 返回其他状态吗
axios.defaults.validateStatus = function (status) { axios.defaults.validateStatus = function (status) {
return status // 默认的 return status // 默认的
...@@ -12,7 +18,7 @@ axios.defaults.validateStatus = function (status) { ...@@ -12,7 +18,7 @@ axios.defaults.validateStatus = function (status) {
axios.defaults.withCredentials = true axios.defaults.withCredentials = true
// request拦截器 // request拦截器
axios.interceptors.request.use(config => { axios.interceptors.request.use(config => {
let token = getStore({name: 'access_token'}) let token = store.getters.access_token
if (token) { if (token) {
config.headers['Authorization'] = 'Bearer ' + token config.headers['Authorization'] = 'Bearer ' + token
} }
...@@ -35,10 +41,12 @@ axios.interceptors.response.use(response => { ...@@ -35,10 +41,12 @@ axios.interceptors.response.use(response => {
position: 'center', position: 'center',
duration: 5 * 1000 duration: 5 * 1000
}) })
setStore({ name: 'access_token', content: '' }) store.dispatch('setToken', '')
store.dispatch('setUserId', '')
store.dispatch('setCode', '')
setTimeout(function () { setTimeout(function () {
window.location.reload() window.location.href = removeUrlParam('code')
}, 5 * 1000) }, 4 * 1000)
} else if (status === 403) { } else if (status === 403) {
if (res.msg === '请先进行实名认证') { // 跳转至社区推荐页 if (res.msg === '请先进行实名认证') { // 跳转至社区推荐页
router.push({ router.push({
......
const getters = { const getters = {
access_token: state => state.common.access_token, access_token: state => state.user.access_token,
user_id: state => state.common.user_id, user_id: state => state.user.user_id,
userInfo: state => state.user.userInfo userInfo: state => state.user.userInfo,
code: state => state.user.code,
authId: state => state.user.authId
} }
export default getters export default getters
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
import common from './modules/common'
import user from './modules/user' import user from './modules/user'
import getters from './getters' import getters from './getters'
Vue.use(Vuex) Vue.use(Vuex)
const store = new Vuex.Store({ const store = new Vuex.Store({
modules: { modules: {
common,
user user
}, },
getters getters
......
import { getStore, setStore } from '@/util/store'
const common = {
state: {
access_token: getStore({ name: 'access_token' }),
user_id: getStore({ name: 'user_id' })
},
actions: {
AccessToken (context, id) {
context.commit('access_token', id)
},
UserId (context, id) {
context.commit('user_id', id)
}
},
mutations: {
SET_ACCESSTOKEN: (state, active) => {
this.state.access_token = active
setStore({
name: 'access_token',
content: state.access_token
})
},
SET_USERID: (state, active) => {
this.state.user_id = active
setStore({
name: 'user_id',
content: state.user_id
})
}
}
}
export default common
// import { getStore, setStore } from '@/util/store' import { getStore, setStore } from '@/util/store'
const user = { const user = {
state: { state: {
access_token: getStore({
name: 'access_token'
}) || '',
user_id: getStore({
name: 'user_id'
}) || '',
code: getStore({
name: 'code'
}) || '',
authId: '',
userInfo: {} userInfo: {}
}, },
actions: { actions: {
setToken ({ commit }, param) {
commit('SET_TOKEN', param)
},
setUserId ({ commit }, param) {
commit('SET_USERID', param)
},
setCode ({ commit }, param) {
commit('SET_CODE', param)
},
setAuthId ({ commit }, param) {
commit('SET_AUTHID', param)
}
}, },
mutations: { mutations: {
SET_TOKEN: (state, token) => {
state.access_token = token
console.log(state.access_token)
setStore({
name: 'access_token',
content: state.access_token,
type: 'session'
})
},
SET_USERID: (state, userid) => {
state.user_id = userid
setStore({
name: 'user_id',
content: state.user_id,
type: 'session'
})
},
SET_CODE: (state, code) => {
state.code = code
setStore({
name: 'code',
content: state.code,
type: 'session'
})
},
SET_AUTHID: (state, authId) => {
state.authId = authId
setStore({
name: 'code',
content: state.authId,
type: 'session'
})
},
SET_USERIFNO: (state, userInfo) => { SET_USERIFNO: (state, userInfo) => {
state.userInfo = userInfo state.userInfo = userInfo
} }
......
import Qs from 'qs'
/** /**
* 取消滚动条 * 取消滚动条
* @param {*} s * @param {*} s
...@@ -15,7 +17,7 @@ export function renewscroll () { ...@@ -15,7 +17,7 @@ export function renewscroll () {
} }
/** /**
* 根据身份证获取性别 * 根据身份证获取性别 1=男 2=女
* @param {*} s * @param {*} s
*/ */
export function getSexByIdCard (idNumber) { export function getSexByIdCard (idNumber) {
...@@ -130,3 +132,55 @@ export function SubtractDay (day) { ...@@ -130,3 +132,55 @@ export function SubtractDay (day) {
date.setDate(date.getDate() - day) date.setDate(date.getDate() - day)
return date return date
} }
/**
* 获取域名后参数
* @param {*} s
*/
export function getParamsByUrl (url) {
try {
let paramstr = url.split('?')
if (paramstr.length > 1) {
let paramarr = paramstr[1].split('&')
const params = {}
for (const i in paramarr) {
const obj = paramarr[i].split('=')
params[obj[0]] = obj[1]
}
return params
} else {
return {}
}
} catch (error) {
return {}
}
}
/**
* 移除域名后指定参数
* @param {*} s
*/
export function removeUrlParam (key) {
// let loc = window.location
let url = window.location.href
let paramstr = url.split('?')
let lochref = paramstr[0]
if (paramstr.length > 1) {
let paramarr = paramstr[1].split('&')
const params = {}
for (const i in paramarr) {
const obj = paramarr[i].split('=')
if (key !== obj[0]) {
params[obj[0]] = obj[1]
}
}
let urlparamstr = Qs.stringify(params)
if (urlparamstr !== '') {
return lochref + '?' + urlparamstr
} else {
return lochref
}
} else {
return url
}
}
...@@ -31,6 +31,7 @@ export const getStore = (params = {}) => { ...@@ -31,6 +31,7 @@ export const getStore = (params = {}) => {
name, name,
debug debug
} = params } = params
console.log(params)
name = keyName + name name = keyName + name
let obj = {} let obj = {}
let content let content
......
<template>
<div class="full-page">
<keep-alive>
<router-view v-if="$route.meta.keepAlive"></router-view>
</keep-alive>
<router-view v-if="!$route.meta.keepAlive"></router-view>
</div>
</template>
<script>
export default {
data () {
return {
}
},
methods: {
},
created () {
},
mounted () {
}
}
</script>
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
// import { getUserCard, getunUsedCountById } from '@/api/apply/apply' // import { getUserCard, getunUsedCountById } from '@/api/apply/apply'
import { getContentInfo } from '@/api/apply/apply' import { getContentInfo } from '@/api/apply/apply'
import defaultOrgImg from '../../assets/images/org-default-picture.png' import defaultOrgImg from '../../assets/images/org-default-picture.png'
import { wxpermission } from '@/wxpermission'
const wx = require('weixin-js-sdk')
export default { export default {
name: 'Home', name: 'Home',
...@@ -57,8 +59,45 @@ export default { ...@@ -57,8 +59,45 @@ export default {
producerPicUrl: res.data.producerPicUrl !== '' ? res.data.producerPicUrl : defaultOrgImg, producerPicUrl: res.data.producerPicUrl !== '' ? res.data.producerPicUrl : defaultOrgImg,
producerName: res.data.producerName, producerName: res.data.producerName,
producerOrgName: res.data.producerOrgName, producerOrgName: res.data.producerOrgName,
content: res.data.content content: res.data.content,
mainTitle: res.data.mainTitle,
subheading: res.data.subheading
} }
console.log('getContentInfo')
wxpermission(() => {
const shareData = {
title: this.data.mainTitle,
imgUrl: this.data.producerPicUrl,
desc: this.data.subheading,
link: window.location.href
}
wx.onMenuShareAppMessage({
title: shareData.title, // 分享标题
desc: shareData.desc, // 分享描述
link: shareData.link, // 分享链接
imgUrl: shareData.imgUrl, // 分享图标
type: 'link', // 分享类型,music、video或link,不填默认为link
dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
success: function () {
// 用户确认分享后执行的回调函数
},
cancel: function () {
// 用户取消分享后执行的回调函数
}
})
wx.onMenuShareTimeline({
title: shareData.title, // 分享标题
desc: shareData.desc, // 分享描述
link: shareData.link, // 分享链接
imgUrl: shareData.imgUrl, // 分享图标
success: function () {
// 用户确认分享后执行的回调函数
},
cancel: function () {
// 用户取消分享后执行的回调函数
}
})
})
} }
}).catch((error) => { }).catch((error) => {
this.$toast({ this.$toast({
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
</template> </template>
<script> <script>
import { getStore } from '@/util/store' import store from '@/store'
// import store from '@/store' // import store from '@/store'
import CardItem from '@/components/cardItem' import CardItem from '@/components/cardItem'
import ListItem from '@/components/listItem' import ListItem from '@/components/listItem'
...@@ -33,7 +33,7 @@ export default { ...@@ -33,7 +33,7 @@ export default {
name: 'Home', name: 'Home',
data () { data () {
return { return {
userId: getStore({ name: 'user_id' }), userId: store.getters.user_id,
voucherData: [], voucherData: [],
userInfo: { userInfo: {
name: '', name: '',
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="form"> <div class="form" v-if="userData.sex === '2'">
<div class="table"> <div class="table">
<div class="tr"> <div class="tr">
<div class="td label">末次月经时间</div> <div class="td label">末次月经时间</div>
...@@ -82,6 +82,7 @@ export default { ...@@ -82,6 +82,7 @@ export default {
userData: { userData: {
name: '', name: '',
idCard: '', idCard: '',
sex: 1,
phone: '', phone: '',
lastMensesTime: '' // 末次月经时间 lastMensesTime: '' // 末次月经时间
}, },
...@@ -123,6 +124,7 @@ export default { ...@@ -123,6 +124,7 @@ export default {
if (cardid(this.userData.idCard)[0]) { if (cardid(this.userData.idCard)[0]) {
this.BaseValidate.idCardState = false this.BaseValidate.idCardState = false
} else { } else {
this.userData.sex = getSexByIdCard(this.userData.idCard)
this.BaseValidate.idCardState = true this.BaseValidate.idCardState = true
} }
}, },
...@@ -152,11 +154,15 @@ export default { ...@@ -152,11 +154,15 @@ export default {
month = '0' + (selectedDate.getMonth() + 1) month = '0' + (selectedDate.getMonth() + 1)
} }
this.userData.lastMensesTime = selectedDate.getFullYear() + '-' + month + '-' + selectedDate.getDate() this.userData.lastMensesTime = selectedDate.getFullYear() + '-' + month + '-' + selectedDate.getDate()
this.BaseValidateMensesLastDate()
}, },
handelSave () { handelSave () {
console.log('submit') console.log('submit')
this.BaseValidateHandle() this.BaseValidateHandle()
if (!this.BaseValidate.nameState || !this.BaseValidate.phoneState || !this.BaseValidate.idCardState || !this.BaseValidate.lastMensesTimeState) { if (!this.BaseValidate.nameState || !this.BaseValidate.phoneState || !this.BaseValidate.idCardState) {
return true
}
if (this.userData.sex === '2' && !this.BaseValidate.lastMensesTimeState) {
return true return true
} }
let params = { let params = {
...@@ -196,6 +202,8 @@ export default { ...@@ -196,6 +202,8 @@ export default {
}) })
} }
}).catch((error) => { }).catch((error) => {
this.btnDisabled = false
this.$Indicator.close()
this.$toast({ this.$toast({
message: error.message, message: error.message,
position: 'center', position: 'center',
......
...@@ -34,8 +34,9 @@ ...@@ -34,8 +34,9 @@
</div> </div>
<div class="tr" v-if="labelId===2"> <div class="tr" v-if="labelId===2">
<div class="td label">出生年月</div> <div class="td label">出生年月</div>
<div class="td text-right" @click="openPickerBirth"> <div class="td text-right">
<input type="text" class="form-control" placeholder="请选择子女出生日期" disabled v-model="userData.birthKid"/> <span @click="openPickerBirth">{{userData.birthKid === '' ? '请选择子女出生日期': userData.birthKid}}</span>
<!-- <input type="text" class="form-control" placeholder="请选择子女出生日期" disabled v-model="userData.birthKid"/> -->
<span v-show="!BaseValidate.birthKidState" class="small-hint">请选择子女出生日期</span> <span v-show="!BaseValidate.birthKidState" class="small-hint">请选择子女出生日期</span>
</div> </div>
</div> </div>
...@@ -209,6 +210,7 @@ export default { ...@@ -209,6 +210,7 @@ export default {
this.userData.lastMensesTime = selectedDate.getFullYear() + '-' + month + '-' + selectedDate.getDate() this.userData.lastMensesTime = selectedDate.getFullYear() + '-' + month + '-' + selectedDate.getDate()
}, },
openPickerBirth () { // 打开出生日期控件 openPickerBirth () { // 打开出生日期控件
console.log('openPickerBirth')
this.$refs.pickerBirth.open() this.$refs.pickerBirth.open()
}, },
pickerBirthConfirm (date) { pickerBirthConfirm (date) {
...@@ -258,7 +260,7 @@ export default { ...@@ -258,7 +260,7 @@ export default {
this.$Indicator.close() this.$Indicator.close()
if (res.code === 0 && res.data) { if (res.code === 0 && res.data) {
this.$toast({ this.$toast({
message: '保存成功', message: '实名认证成功',
position: 'center', position: 'center',
duration: 3000 duration: 3000
}) })
...@@ -270,7 +272,7 @@ export default { ...@@ -270,7 +272,7 @@ export default {
}, 2500) }, 2500)
} else { } else {
this.$toast({ this.$toast({
message: '保存失败', message: '实名认证失败',
position: 'center', position: 'center',
duration: 3000 duration: 3000
}) })
......
...@@ -36,8 +36,8 @@ ...@@ -36,8 +36,8 @@
</div> </div>
<div class="tr" v-if="userData.role===1"> <div class="tr" v-if="userData.role===1">
<div class="td label">出生日期</div> <div class="td label">出生日期</div>
<div class="td text-right" @click="openPickerBirth"> <div class="td text-right">
<input type="text" class="form-control" placeholder="请选择子女出生日期" disabled v-model="userData.birth"/> <span @click="openPickerBirth">{{userData.birth==='' ? '请选择子女出生日期' : userData.birth}}</span>
<span v-show="!BaseValidate.birthState" class="small-hint">请选择子女出生日期</span> <span v-show="!BaseValidate.birthState" class="small-hint">请选择子女出生日期</span>
</div> </div>
</div> </div>
...@@ -180,6 +180,7 @@ export default { ...@@ -180,6 +180,7 @@ export default {
name: '配偶', name: '配偶',
method: that.selectedRole2 method: that.selectedRole2
}] }]
console.log('member edit')
if (this.memberId) { if (this.memberId) {
this.getUserInfoByIdFn(this.memberId) // 根据用户id获取该成员信息(成员编辑) this.getUserInfoByIdFn(this.memberId) // 根据用户id获取该成员信息(成员编辑)
} }
...@@ -350,7 +351,7 @@ export default { ...@@ -350,7 +351,7 @@ export default {
} }
if (this.userData.role === 1) { // 子女 if (this.userData.role === 1) { // 子女
params.idCard = this.userData.idCardKid === '' ? null : this.userData.idCardKid params.idCard = this.userData.idCardKid === '' ? null : this.userData.idCardKid
params.sex = this.userData.idCardKid !== '' ? getSexByIdCard(this.idCardKid) : this.userData.sex === '男孩' ? '1' : this.sex === '女孩' ? '2' : '3' params.sex = this.userData.idCardKid !== '' ? getSexByIdCard(this.idCardKid) : this.userData.sex === '男孩' ? '1' : this.userData.sex === '女孩' ? '2' : '3'
params.birth = this.userData.birth params.birth = this.userData.birth
} else if (this.userData.role === 2) { // 配偶 } else if (this.userData.role === 2) { // 配偶
params.idCard = this.userData.idCard === '' ? null : this.userData.idCard params.idCard = this.userData.idCard === '' ? null : this.userData.idCard
......
...@@ -218,7 +218,7 @@ export default { ...@@ -218,7 +218,7 @@ export default {
padding: 0 0.5em; padding: 0 0.5em;
margin: 0 0.5em; margin: 0 0.5em;
color: #80848f; color: #80848f;
width: 5em; max-width: 5em;
height: 2em; height: 2em;
font-size: 1em; font-size: 1em;
} }
...@@ -233,7 +233,7 @@ export default { ...@@ -233,7 +233,7 @@ export default {
} }
.user-page .user-body > .tab-content { .user-page .user-body > .tab-content {
padding: 0 0.5em; padding: 0 0.8em;
} }
.user-page .user-body > .tab-content > .tips { .user-page .user-body > .tab-content > .tips {
......
import { WXconfirm } from '@/api/wxconfirm'
import store from '@/store'
const wx = require('weixin-js-sdk')
export const wxpermission = (fn) => {
console.log('微信鉴权')
console.log(window.location.href)
WXconfirm({
url: window.location.href,
auth_id: store.getters.authId
}).then(res => {
console.log(res)
wx.config({
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId: res.appId, // 必填,公众号的唯一标识
timestamp: res.timestamp, // 必填,生成签名的时间戳
nonceStr: res.noncestr, // 必填,生成签名的随机串
signature: res.signature, // 必填,签名,见附录1
jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'startRecord', 'stopRecord', 'onVoiceRecordEnd', 'playVoice', 'pauseVoice', 'stopVoice', 'onVoicePlayEnd', 'uploadVoice', 'downloadVoice', 'chooseImage', 'previewImage', 'uploadImage', 'downloadImage', 'translateVoice', 'openLocation', 'getLocation', 'hideOptionMenu', 'showOptionMenu', 'hideMenuItems', 'showMenuItems', 'scanQRCode', 'chooseWXPay', 'addCard', 'chooseCard', 'openCard'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
})
wx.ready(() => {
fn()
wx.hideMenuItems({
menuList: ['menuItem:share:appMessage', 'menuItem:share:timeline', 'menuItem:copyUrl', 'menuItem:share:qq', 'menuItem:share:weiboApp', 'menuItem:favorite', 'menuItem:share:facebook', 'menuItem:share:QZone', 'menuItem:originPage', 'menuItem:openWithQQBrowser', 'menuItem:openWithSafari', 'menuItem:share:email', 'menuItem:share:brand', 'menuItem:editTag'] // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3
})
})
})
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment