index.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. import { fetch, post, corePost } from '@/api/http'
  2. import jwtDecode from 'jwt-decode'
  3. import config from '@/store/module/config'
  4. import ClassMgmt from './classMgmt'
  5. import talMgmt from './talMgmt'
  6. // import cloudApi from '../store/api/index'
  7. import schoolSetting from './schoolSetting'
  8. import totalAnalysis from './totalAnalysis'
  9. import stuAccount from './stuAccount'
  10. import syllabus from './syllabus'
  11. import knowledge from './knowledge'
  12. import teachContent from './teachContent'
  13. import uploadFile from './uploadFile'
  14. import courseMgmt from './courseMgmt'
  15. import login from './login'
  16. import schoolList from './schoolList'
  17. import newEvaluation from './newEvaluation'
  18. import learnActivity from './learnActivity'
  19. import questionnaire from './questionnaire'
  20. import teachMgmt from './teachMgmt'
  21. import schoolUser from './schoolUser'
  22. import accessToken from './accessToken'
  23. import studentWeb from './studentWeb'
  24. import regist from './regist'
  25. import forgetPW from './forgetPW'
  26. import classroom from './classroom'
  27. export default {
  28. accessToken,
  29. learnActivity,
  30. studentWeb,
  31. questionnaire,
  32. ClassMgmt,
  33. stuAccount,
  34. syllabus,
  35. knowledge,
  36. schoolSetting,
  37. totalAnalysis,
  38. talMgmt,
  39. teachContent,
  40. // cloudApi,
  41. uploadFile,
  42. courseMgmt,
  43. newEvaluation,
  44. login,
  45. schoolList,
  46. teachMgmt,
  47. schoolUser,
  48. regist,
  49. forgetPW,
  50. classroom,
  51. // 获取登录跳转链接
  52. getLoginLink: function (data) {
  53. return post('api/login/login', data)
  54. },
  55. // 验证登录
  56. checkLogin: function (data) {
  57. return post('api/login/CheckLogin', data)
  58. },
  59. // 获取登录人员角色列表
  60. getLoginRoles: function (data) {
  61. return post('api/role/GetLoginRoles', data)
  62. },
  63. // 查找地区对应学校列表
  64. getSchoolList: function (data) {
  65. return post('api/School/getSchool', data)
  66. },
  67. // 根据当前登录用户获取已授权的AI智慧学校
  68. getAuthSchool: function (data) {
  69. return post('api/School/AuthorizedAISchool', data)
  70. },
  71. // 获取全部科目
  72. FindSubjectsByDict: function (data) {
  73. return post('api/subject/FindSubjectsByDict', data)
  74. },
  75. // 获取当前学校全部科目
  76. FindSchoolSubjectsByDict: function (data) {
  77. return post('api/subject/FindSchoolSubjectsByDict', data)
  78. },
  79. // 获取当前学校全部册别
  80. FindSchoolVolumesByDict: function (data) {
  81. return post('api/volume/FindSchoolVolumesByDict', data)
  82. },
  83. // 获取当前学校全部学段
  84. FindSchoolPeriodsByDict: function (data) {
  85. return post('api/period/FindSchoolPeriodsByDict', data)
  86. },
  87. // 获取当前学校全部年级
  88. FindSchoolGradesByDict: function (data) {
  89. return post('api/grade/FindSchoolGradesByDict', data)
  90. },
  91. // 获取当前学校全部学期
  92. FindSchoolTermsByDict: function (data) {
  93. return post('api/term/FindSchoolTermsByDict', data)
  94. },
  95. // 获取登录人员身份信息
  96. getLoginClaim: function (data) {
  97. return post('api/role/GetLoginClaim', data)
  98. },
  99. // 新建习题保存到题库
  100. SaveItemBank: function (data) {
  101. return post('api/evaluation/ItemBank', data)
  102. },
  103. // 新建试卷到试卷库
  104. SaveTestPaper: function (data) {
  105. return post('api/Evaluation/testPaper', data)
  106. },
  107. // 新建试卷到试卷库
  108. SaveAnalyzeHtml: function (data) {
  109. return post('/api/ImportExercise/AnalyzeHtml', data)
  110. },
  111. // 获取所有学校信息
  112. GetAllSchool: function (data) {
  113. return post('api/school/GetAllSchool', data)
  114. },
  115. // 取得所有學校(只取基本資料)
  116. GetAllSchoolBaesInfo: function (data) {
  117. return post('/school/init/get-all-school-base', data)
  118. },
  119. // 根据条件获取学段
  120. FindPeriodsByDict: function (data) {
  121. return post('api/period/FindPeriodsByDict', data)
  122. },
  123. // 根据条件获取年级
  124. FindGradesByDict: function (data) {
  125. return post('api/grade/FindGradesByDict', data)
  126. },
  127. // 根据条件获取学科
  128. FindSubjectsByDict: function (data) {
  129. return post('api/subject/FindSubjectsByDict', data)
  130. },
  131. /*
  132. *评测
  133. */
  134. // 上传图片
  135. UploadFile: function (data) {
  136. return post('/api/file/uploadFile', data)
  137. },
  138. /**
  139. * 通用查询接口
  140. */
  141. FindCollection: function (data) {
  142. return post('/api/Common/FindCollection', data)
  143. },
  144. /**
  145. * 發送驗證簡訊
  146. * @param {String} applyType - 寄信類型(email, phone)
  147. * @param {String} to - 寄信位置
  148. * @param {String} lang - 要傳送的語言代碼,請用標準zh-CN、zh-TW、en-US
  149. * @param {Boolean} hasUser - true,代表必須存在用戶,才能發送,false,代表用戶必須不存在,才能發送
  150. * @param {Number} country - 手機區碼,無須+號(有phone為必填)
  151. */
  152. SendPinCode: function(item) {
  153. return new Promise((resolve) => {
  154. let srvAdr = localStorage.getItem('srvAdr')
  155. let url = config.state[srvAdr].coreAPIUrl
  156. let data = {
  157. 'to': item.to.toString(),
  158. 'lang': item.lang,
  159. 'HasUser': item.hasUser,
  160. }
  161. if(item.applyType == 'phone'){
  162. data.country= item.country.toString()
  163. url += '/service/sandsms/pin'
  164. } else {
  165. url += '/service/sandmail/pin'
  166. }
  167. corePost(url, data).then( res => {
  168. resolve(res)
  169. },err => {
  170. console.log(err)
  171. })
  172. })
  173. },
  174. /**
  175. * 組合呼叫第三方的網址
  176. * @param {String} provider - (必要)
  177. * @param {String} url - (必要)
  178. * @returns {String} - 網址
  179. */
  180. BuildOauthUrl: async function(provider, url){
  181. return new Promise((resolve) => {
  182. let result = ''
  183. let redirect_uri = encodeURIComponent(url)
  184. switch (provider) {
  185. case 'facebook':
  186. result = 'https://www.facebook.com/v7.0/dialog/oauth?scope=public_profile,email&redirect_uri=' + redirect_uri + '&response_type=code&client_id=1382704845111595&display=popup&state=facebook'
  187. break;
  188. case 'google':
  189. result = 'https://accounts.google.com/o/oauth2/v2/auth?scope=https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email&redirect_uri=' + redirect_uri + '&response_type=code&client_id=30604537950-2e6eojbqt5k1kjg43jdvdq6g3gp0eo33.apps.googleusercontent.com&display=popup&state=google'
  190. break;
  191. case 'wechat':
  192. result = 'https://open.weixin.qq.com/connect/qrconnect?appid=wx207be4d5a37eca4a&redirect_uri='+ redirect_uri +'&response_type=code&scope=snsapi_login&state=wechat#wechat_redirect'
  193. break;
  194. }
  195. resolve(result)
  196. })
  197. },
  198. /**
  199. * 請求雲端協助第三方登入
  200. * @param {String} grant_type
  201. * @param {String} code
  202. * @param {String} redirect_uri
  203. */
  204. OauthLogin: function(grant_type, code, redirect_uri){
  205. return new Promise((resolve) => {
  206. let srvAdr = localStorage.getItem('srvAdr')
  207. let url = config.state[srvAdr].coreAPIUrl
  208. let nonceStr = 'habook' // 檢查項目
  209. let data = {
  210. 'client_id': config.state[srvAdr].clientID,
  211. 'grant_type': grant_type,
  212. 'nonce': nonceStr,
  213. 'open_code': code,
  214. 'redirect_uri': redirect_uri
  215. }
  216. corePost(url+'/oauth2/login', data).then( res => {
  217. if(res.error){
  218. resolve(res)
  219. } else {
  220. let t_data = jwtDecode(res.id_token)
  221. if(nonceStr === t_data.nonce){
  222. resolve(res)
  223. } else {
  224. resolve({error: 'nonce'})
  225. }
  226. }
  227. },err => {
  228. console.log(err)
  229. if(err.status != 200){
  230. resolve({error: 'Bad Request'})
  231. }
  232. })
  233. })
  234. },
  235. /**
  236. * 大雲快速登入
  237. * @param {String} code
  238. */
  239. SSOLogin: function(code){
  240. return new Promise((resolve, reject) => {
  241. let srvAdr = localStorage.getItem('srvAdr')
  242. let url = config.state[srvAdr].coreAPIUrl
  243. let nonceStr = 'habook' // 檢查項目
  244. let data = {
  245. 'grant_type': 'authorization_code',
  246. 'client_id': config.state[srvAdr].clientID,
  247. 'code': code,
  248. 'nonce': nonceStr
  249. }
  250. corePost(url+'/oauth2/token', data).then( res => {
  251. resolve(res)
  252. },err => {
  253. console.log(err)
  254. if(err.status != 200){
  255. resolve({error: 'Bad Request'})
  256. }
  257. })
  258. })
  259. },
  260. /**
  261. * 數據中心當前所有學校名單
  262. */
  263. getSchoolList: function () {
  264. return post('/teacher/init/get-school-list')
  265. },
  266. }