|
@@ -1,11 +1,165 @@
|
|
|
import { createStore } from 'vuex'
|
|
|
-
|
|
|
+import axios from '@lib/plug/axios.js'
|
|
|
+const uri = '/naf/items/'
|
|
|
+const codes = ['region']
|
|
|
+const api = {
|
|
|
+ pagedetails: '/api/pages/fetch/',
|
|
|
+ contentlist: '/api/content/query',
|
|
|
+ contentfetch: '/api/content/fetch/',
|
|
|
+ hospitalquery: '/api/hospital/query',
|
|
|
+ hospitaldetails: '/api/hospital/fetch/',
|
|
|
+ specialistquery: '/api/specialist/query',
|
|
|
+ specialistdetails: '/api/specialist/fetch/',
|
|
|
+ orderquery: '/api/order/query',
|
|
|
+ orderdetails: '/api/order/fetch/',
|
|
|
+ ordercreate: '/api/order/create',
|
|
|
+ register: '/api/user/create',
|
|
|
+ userquery: '/api/user/query',
|
|
|
+ userupdate: '/api/user/update',
|
|
|
+ subjectquery: '/api/subject/query',
|
|
|
+ orderPay: '/api/weixin/orderPay'
|
|
|
+}
|
|
|
export default createStore({
|
|
|
state: {
|
|
|
+ dict: {},
|
|
|
+ pageItem: null,
|
|
|
+ contentList: [],
|
|
|
+ contentItem: null,
|
|
|
+ hospitalList: [],
|
|
|
+ subjectList: [],
|
|
|
+ specialistlList: [],
|
|
|
+ specialistlItem: null,
|
|
|
+ hospitalItem: null,
|
|
|
+ orderList: [],
|
|
|
+ orderItem: []
|
|
|
},
|
|
|
mutations: {
|
|
|
+ // 字典
|
|
|
+ setdice (state, { type, list }) {
|
|
|
+ state.dict[type] = list
|
|
|
+ },
|
|
|
+ details (state, payload) {
|
|
|
+ state.pageItem = payload.data
|
|
|
+ },
|
|
|
+ contentlist (state, payload) {
|
|
|
+ state.contentList = payload.data
|
|
|
+ },
|
|
|
+ contentfetch (state, payload) {
|
|
|
+ state.contentItem = payload.data
|
|
|
+ },
|
|
|
+ hospitalquery (state, payload) {
|
|
|
+ state.hospitalList = payload.data
|
|
|
+ },
|
|
|
+ hospitaldetails (state, payload) {
|
|
|
+ state.hospitalItem = payload.data
|
|
|
+ },
|
|
|
+ subjectquery (state, payload) {
|
|
|
+ state.subjectList = payload.data
|
|
|
+ },
|
|
|
+ specialistquery (state, payload) {
|
|
|
+ state.specialistlList = payload.data
|
|
|
+ },
|
|
|
+ specialistdetails (state, payload) {
|
|
|
+ state.specialistlItem = payload.data
|
|
|
+ },
|
|
|
+ orderquery (state, payload) {
|
|
|
+ state.orderList = payload.data
|
|
|
+ },
|
|
|
+ orderdetails (state, payload) {
|
|
|
+ state.orderItem = payload.data
|
|
|
+ }
|
|
|
},
|
|
|
actions: {
|
|
|
+ // 字典
|
|
|
+ async init ({ commit }) {
|
|
|
+ codes.filter(async e => {
|
|
|
+ const res = await axios.get(`${uri}${e}/list`)
|
|
|
+ if (res.errcode === 0) {
|
|
|
+ commit('setdice', { type: e, list: res.data })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 单字典
|
|
|
+ async dictinit ({ commit }, e) {
|
|
|
+ const res = await axios.get(`${uri}${e}/list`)
|
|
|
+ if (res.errcode === 0) {
|
|
|
+ commit('setdice', { type: e, list: res.data })
|
|
|
+ }
|
|
|
+ return res
|
|
|
+ },
|
|
|
+ async pagedetails ({ commit }, { code }) {
|
|
|
+ const res = await axios.get(`${api.pagedetails}${code}`)
|
|
|
+ if (res.errcode === 0) commit('details', res)
|
|
|
+ return res
|
|
|
+ },
|
|
|
+ async contentquery ({ commit }, { code }) {
|
|
|
+ const res = await axios.get(`${api.contentlist}`, { params: { column: code } })
|
|
|
+ if (res.errcode === 0) commit('contentlist', res)
|
|
|
+ return res
|
|
|
+ },
|
|
|
+ async contentfetch ({ commit }, { _id }) {
|
|
|
+ const res = await axios.get(`${api.contentfetch}${_id}`)
|
|
|
+ if (res.errcode === 0) commit('contentfetch', res)
|
|
|
+ return res
|
|
|
+ },
|
|
|
+ // 医院
|
|
|
+ async hospitalquery ({ commit }, { region } = {}) {
|
|
|
+ const res = await axios.get(`${api.hospitalquery}`, { params: { region } })
|
|
|
+ if (res.errcode === 0) commit('hospitalquery', res)
|
|
|
+ return res
|
|
|
+ },
|
|
|
+ async hospitaldetails ({ commit }, { _id }) {
|
|
|
+ const res = await axios.get(`${api.hospitaldetails}${_id}`)
|
|
|
+ if (res.errcode === 0) commit('hospitaldetails', res)
|
|
|
+ return res
|
|
|
+ },
|
|
|
+ // 科室
|
|
|
+ async subjectquery ({ commit }, { hospitalId } = {}) {
|
|
|
+ const res = await axios.get(`${api.subjectquery}`, { params: { hospitalId } })
|
|
|
+ if (res.errcode === 0) commit('subjectquery', res)
|
|
|
+ return res
|
|
|
+ },
|
|
|
+ // 专家
|
|
|
+ async specialistquery ({ commit }, { subjectId } = {}) {
|
|
|
+ const res = await axios.get(`${api.specialistquery}`, { params: { subjectId } })
|
|
|
+ if (res.errcode === 0) commit('specialistquery', res)
|
|
|
+ return res
|
|
|
+ },
|
|
|
+ async specialistdetails ({ commit }, { _id }) {
|
|
|
+ const res = await axios.get(`${api.specialistdetails}${_id}`)
|
|
|
+ if (res.errcode === 0) commit('specialistdetails', res)
|
|
|
+ return res
|
|
|
+ },
|
|
|
+ async orderquery ({ commit }, { openid }) {
|
|
|
+ const res = await axios.get(api.orderquery, { params: { openid } })
|
|
|
+ if (res.errcode === 0) commit('orderquery', res)
|
|
|
+ return res
|
|
|
+ },
|
|
|
+ async orderdetails ({ commit }, { _id }) {
|
|
|
+ const res = await axios.get(`${api.orderdetails}${_id}`)
|
|
|
+ if (res.errcode === 0) commit('orderdetails', res)
|
|
|
+ return res
|
|
|
+ },
|
|
|
+ async ordercreate ({ commit }, payload) {
|
|
|
+ const res = await axios.post(api.ordercreate, payload)
|
|
|
+ return res
|
|
|
+ },
|
|
|
+ async orderPay ({ commit }, payload) {
|
|
|
+ const res = await axios.post(api.orderPay, payload)
|
|
|
+ return res
|
|
|
+ },
|
|
|
+ async register ({ commit }, { name, openid, phone }) {
|
|
|
+ const res = await axios.post(`${api.register}`, { name, openid, phone })
|
|
|
+ return res
|
|
|
+ },
|
|
|
+ async userquery ({ commit }, { openid }) {
|
|
|
+ const res = await axios.get(`${api.userquery}`, { params: { openid } })
|
|
|
+ return res
|
|
|
+ },
|
|
|
+ async userupdate ({ commit }, { openid, _id, name, phone }) {
|
|
|
+ const res = await axios.post(`${api.userupdate}`, { openid, _id, name, phone })
|
|
|
+ return res
|
|
|
+ }
|
|
|
},
|
|
|
modules: {
|
|
|
}
|