user.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. <template>
  2. <!-- 用户 -->
  3. <view class="df jcc aic myComRoot">
  4. <!-- 一级页面 -->
  5. <view class="df content-box jcsb" v-show="showIndex==0">
  6. <view v-for="(item,i) in (userInfo.role=='老师'?userMenu_teacher:userMenu_student)" :key="i" class="df jcc aic fdc btn1-box"
  7. @click="onClick_Btn1(i)">
  8. <view class="btn1-icon">
  9. <img :src="item.icon_large"></img>
  10. </view>
  11. <view class="btn1-text">{{item.text}}</view>
  12. </view>
  13. </view>
  14. <!-- 展示页 -->
  15. <view class="user-show df fdr" v-show="showIndex!=0">
  16. <view class="user-left-box">
  17. <view class="df fdc aic">
  18. <view class="user-left-avatar df">
  19. <img :src="userInfo.avatarSrc"></img>
  20. </view>
  21. <view class="user-left-btn df jcc aic" @click="onUploadAvatar">上传头像</view>
  22. </view>
  23. <view class="user-left-line"></view>
  24. <view class="user-left-menu">
  25. <view class="df fdc" v-for="(menu,menuI) in (userInfo.role=='老师'?userMenu_teacher:userMenu_student)" :key="menuI"
  26. @click="onClick_Btn1(menuI)">
  27. <view class="user-left-menu-item df fdr aic">
  28. <view class="user-left-menu-item-left df fdr aic">
  29. <view class="df" :style="{opacity:checkedIndex_leftMenu==menuI?1:0}">
  30. <img src="../../assets/user/icon_user_09.png"></img>
  31. </view>
  32. <view class="df user-left-menu-icon">
  33. <img :src="checkedIndex_leftMenu==menuI?menu.icon_checked:menu.icon_unchecked"></img>
  34. </view>
  35. <view :class="checkedIndex_leftMenu==menuI?'text-checked':'text-unchecked'">{{menu.text}}</view>
  36. </view>
  37. <view class="df user-left-menu-arrow">
  38. <img :src="checkedIndex_leftMenu==menuI?user_left_arrow_checked:user_left_arrow_unchecked"></img>
  39. </view>
  40. </view>
  41. <view class="user-left-line"></view>
  42. </view>
  43. </view>
  44. </view>
  45. <scroll-view class="rightBox user-right-box" scroll-y="true" :scroll-top="scrollTop" @scroll="scroll">
  46. <!-- <view class="user-right-box"> -->
  47. <GRXX ref="GRXX" v-show="showIndex==1"></GRXX>
  48. <XSGL ref="XSGL" v-show="showIndex==2&&userInfo.role=='老师'&&!isShow_xssyqk" v-on:onClick_XSSYQK="onClick_XSSYQK"></XSGL>
  49. <XSSYQK ref="XSSYQK" v-show="showIndex==2&&userInfo.role=='老师'&&isShow_xssyqk"></XSSYQK>
  50. <GRXXJL ref="GRXXJL" v-show="showIndex==2&&userInfo.role=='学生'"></GRXXJL>
  51. <!-- </view> -->
  52. </scroll-view>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import GRXX from './selfInfo.vue'
  58. import XSGL from './stuManage.vue'
  59. import XSSYQK from './stuTestDetails.vue'
  60. import GRXXJL from './personalLearning.vue'
  61. export default {
  62. components: {
  63. GRXX, //个人信息
  64. XSGL, //学生管理
  65. XSSYQK, //学生实验情况
  66. GRXXJL, //个人学习记录
  67. },
  68. mounted() {
  69. },
  70. data() {
  71. return {
  72. //0一级页面1个人信息2学生管理3学生实验情况4学生创作项目管理平台
  73. showIndex: 0,
  74. checkedIndex_leftMenu: 0,
  75. userInfo: mydata_userInfo,
  76. isShow_xssyqk: false,
  77. scrollTop: 0,
  78. oldScrollTop: 0,
  79. userMenu_teacher: [{
  80. "icon_large": require("../../assets/user/icon_user_01.png"),
  81. "text": "个人信息",
  82. "icon_checked": require("../../assets/user/icon_user_05_02.png"),
  83. "icon_unchecked": require("../../assets/user/icon_user_05_01.png"),
  84. },
  85. {
  86. "icon_large": require("../../assets/user/icon_user_02.png"),
  87. "text": "学生管理",
  88. "icon_checked": require("../../assets/user/icon_user_06_02.png"),
  89. "icon_unchecked": require("../../assets/user/icon_user_06_01.png"),
  90. },
  91. {
  92. "icon_large": require("../../assets/user/icon_user_04.png"),
  93. "text": "创作项目管理平台",
  94. "icon_checked": require("../../assets/user/icon_user_08_02.png"),
  95. "icon_unchecked": require("../../assets/user/icon_user_08_01.png"),
  96. }
  97. ],
  98. userMenu_student: [{
  99. "icon_large": require("../../assets/user/icon_user_01.png"),
  100. "text": "个人信息",
  101. "icon_checked": require("../../assets/user/icon_user_05_02.png"),
  102. "icon_unchecked": require("../../assets/user/icon_user_05_01.png"),
  103. },
  104. {
  105. "icon_large": require("../../assets/user/icon_user_03.png"),
  106. "text": '个人学习记录',
  107. "icon_checked": require("../../assets/user/icon_user_07_02.png"),
  108. "icon_unchecked": require("../../assets/user/icon_user_07_01.png"),
  109. },
  110. {
  111. "icon_large": require("../../assets/user/icon_user_04.png"),
  112. "text": "创作项目管理平台",
  113. "icon_checked": require("../../assets/user/icon_user_08_02.png"),
  114. "icon_unchecked": require("../../assets/user/icon_user_08_01.png"),
  115. }
  116. ],
  117. user_left_arrow_checked: require("../../assets/user/icon_user_10_02.png"),
  118. user_left_arrow_unchecked: require("../../assets/user/icon_user_10_01.png"),
  119. }
  120. },
  121. methods: {
  122. initData() {
  123. this.showIndex = 0;
  124. },
  125. onshow()
  126. {
  127. console.log('onshow......')
  128. this.showIndex = false;
  129. },
  130. onClick_Btn1(index) {
  131. // console.log('index===',index)
  132. // console.log('this.userMenu_student===',this.userMenu_student)
  133. if (index == this.userMenu_student.length - 1) {
  134. this.$emit("onClick_proManage");
  135. }
  136. else
  137. {
  138. this.isShow_xssyqk = false;
  139. this.checkedIndex_leftMenu = index;
  140. this.showIndex = index + 1;
  141. // console.log('checkedIndex_leftMenu=',index)
  142. // console.log('showIndex=',index+1)
  143. }
  144. if (this.userInfo.role == '老师')
  145. {
  146. switch (index) {
  147. case 0: //个人信息
  148. break;
  149. case 1: //学生管理
  150. this.$refs.XSGL.updateInfo();
  151. break;
  152. case 2: //创作项目管理平台
  153. break;
  154. default:
  155. }
  156. }
  157. else
  158. {
  159. switch (index) {
  160. case 0: //个人信息
  161. break;
  162. case 1: //个人学习记录
  163. break;
  164. case 2: //创作项目管理平台
  165. break;
  166. default:
  167. }
  168. }
  169. this.getUserInfo();
  170. },
  171. getUserInfo() {
  172. let url = this.$Api + "/user/getuserinfo";
  173. let _self = this;
  174. uni.request({
  175. header: {
  176. 'Content-Type': 'application/json;charset=UTF-8'
  177. },
  178. url: url,
  179. method: 'POST',
  180. data: {
  181. "UserID": mydata_userInfo.UserID,
  182. },
  183. dataType: 'json',
  184. success: (res) => {
  185. let data = res.data;
  186. //100成功
  187. if (data.Code == 100) {
  188. console.log("请求成功", res);
  189. this.$refs.GRXX.updateInfo(data.User);
  190. mydata_userInfo.email = data.User.Email;
  191. // console.log('00000000000=',mydata_userInfo.role)
  192. if (mydata_userInfo.role == '老师')
  193. {
  194. // this.$refs.XSSYQK.updateInfo(data.User);
  195. }
  196. else
  197. {
  198. this.$refs.GRXXJL.updateInfo(data.User);
  199. //请求分数
  200. url = this.$Api + "/score/getscore";
  201. uni.request({
  202. header: {
  203. 'Content-Type': 'application/json;charset=UTF-8'
  204. },
  205. url: url,
  206. method: 'POST',
  207. data: {
  208. "UserID": data.User.Id,
  209. },
  210. dataType: 'json',
  211. success: (res) => {
  212. let data = res.data;
  213. //100成功
  214. if (data.Code == 100) {
  215. // console.log("请求分数成功", res);
  216. this.$refs.GRXXJL.updateLearnProgress(data.Scores);
  217. }
  218. //200失败
  219. else {
  220. console.log("fail200=", res)
  221. }
  222. // console.log("success+++**+*", res.data.Code)
  223. },
  224. fail: (res) => {
  225. console.log("fail+**+*", res)
  226. }
  227. });
  228. }
  229. }
  230. //200失败
  231. else {
  232. console.log("fail200=", res)
  233. }
  234. // console.log("success+++**+*", res.data.Code)
  235. },
  236. fail: (res) => {
  237. console.log("fail+**+*", res)
  238. }
  239. });
  240. },
  241. scroll(e) {
  242. //记录scroll 位置
  243. this.oldScrollTop = e.detail.scrollTop
  244. },
  245. goTop(e) {
  246. //视图会发生重新渲染
  247. this.scrollTop = this.oldScrollTop
  248. //当视图渲染结束 重新设置为0
  249. this.$nextTick(() => {
  250. this.scrollTop = 0
  251. });
  252. },
  253. //范例,直接复制
  254. testPost() {
  255. let url = this.$Api + "/user/getuserinfo";
  256. uni.request({
  257. header: {
  258. 'Content-Type': 'application/json;charset=UTF-8'
  259. },
  260. url: url,
  261. method: 'POST',
  262. data: {
  263. "UserID": mydata_userInfo.UserID,
  264. },
  265. dataType: 'json',
  266. success: (res) => {
  267. let data = res.data;
  268. //100成功
  269. if (data.Code == 100) {
  270. }
  271. //200失败
  272. else {
  273. }
  274. console.log("success+++**+*", res.data.Code)
  275. },
  276. fail: (res) => {
  277. console.log("fail+**+*", res)
  278. }
  279. });
  280. },
  281. onClick_XSSYQK(UserID){
  282. // console.log("11111=",this.userInfo.role);
  283. // console.log("2222=",this.isShow_xssyqk);
  284. // console.log("UserID=",UserID);
  285. this.isShow_xssyqk = true;
  286. this.checkedIndex_leftMenu = 1;
  287. this.showIndex = 2;
  288. let url = this.$Api + "/user/getuserinfo";
  289. uni.request({
  290. header: {
  291. 'Content-Type': 'application/json;charset=UTF-8'
  292. },
  293. url: url,
  294. method: 'POST',
  295. data: {
  296. "UserID": UserID,
  297. },
  298. dataType: 'json',
  299. success: (res) => {
  300. let data = res.data;
  301. //100成功
  302. if (data.Code == 100) {
  303. console.log("请求成功", res);
  304. this.$refs.XSSYQK.updateInfo(data.User);
  305. }
  306. //200失败
  307. else {
  308. }
  309. // console.log("success+++**+*", res.data.Code)
  310. },
  311. fail: (res) => {
  312. console.log("fail+**+*", res)
  313. }
  314. });
  315. url = this.$Api + "/score/getscore";
  316. uni.request({
  317. header: {
  318. 'Content-Type': 'application/json;charset=UTF-8'
  319. },
  320. url: url,
  321. method: 'POST',
  322. data: {
  323. "UserID": UserID,
  324. },
  325. dataType: 'json',
  326. success: (res) => {
  327. let data = res.data;
  328. //100成功
  329. if (data.Code == 100) {
  330. console.log("请求分数成功", res);
  331. this.$refs.XSSYQK.updateLearnProgress(data.Scores);
  332. }
  333. //200失败
  334. else {
  335. }
  336. // console.log("success+++**+*", res.data.Code)
  337. },
  338. fail: (res) => {
  339. console.log("fail+**+*", res)
  340. }
  341. });
  342. },
  343. onUploadAvatar(){
  344. uni.chooseFile({
  345. success: (chooseFileRes) => {
  346. const tempFilePaths = chooseFileRes.tempFilePaths;
  347. uni.uploadFile({
  348. url: this.$Api + "/user/uploaduserheadimage", //仅为示例,非真实的接口地址
  349. filePath: tempFilePaths[0],
  350. name: 'file',
  351. formData: {
  352. 'UserID':this.$UserId, // 创建用户 id
  353. },
  354. success: (uploadFileRes) => {
  355. console.log('upload ok=',uploadFileRes.data);
  356. //刷新avatar
  357. uni.request({
  358. header: {
  359. 'Content-Type': 'application/json;charset=UTF-8'
  360. },
  361. url: this.$Api + "/user/getuserinfo", //仅为示例,非真实的接口地址
  362. method: 'POST',
  363. data: {
  364. 'UserID':this.$UserId,
  365. },
  366. dataType: 'json',
  367. success: (res) => {
  368. this.userInfo.avatarSrc = res.data.User.HeadImageURL;
  369. },
  370. fail: (res) => {
  371. console.log("fail+**+*", res)
  372. }
  373. });
  374. }
  375. });
  376. }
  377. });
  378. }
  379. }
  380. }
  381. </script>
  382. <style lang="scss">
  383. $btnN:4;
  384. .content-box {
  385. width: px2vw(312*$btnN+34*(($btnN)-1));
  386. height: px2vw(367);
  387. }
  388. .user-full {
  389. width: 100%;
  390. height: 100%;
  391. }
  392. .user-show {
  393. width: 100%;
  394. // height: 100%;
  395. height: px2vh(960);
  396. }
  397. .user-left-box {
  398. width: px2vw(374);
  399. background: #FFFFFF;
  400. box-shadow: px2vw(3) 0px px2vw(6) 0px rgba(0, 0, 0, 0.1);
  401. margin-top: px2vw(10);
  402. }
  403. .user-left-avatar img {
  404. width: px2vw(120);
  405. margin-top: px2vw(74);
  406. }
  407. .user-left-btn {
  408. width: px2vw(158);
  409. height: px2vw(48);
  410. background: #EA252C;
  411. border-radius: px2vw(8);
  412. font-size: px2vw(18);
  413. color: #FFFFFF;
  414. line-height: px2vw(24);
  415. margin-top: px2vw(31);
  416. margin-bottom: px2vw(65);
  417. }
  418. .user-left-line {
  419. width: px2vw(374);
  420. height: 1px;
  421. background: #DDDDDD;
  422. }
  423. .user-left-menu-item {
  424. height: px2vw(80);
  425. margin-top: px2vw(16);
  426. margin-bottom: px2vw(16);
  427. }
  428. .user-left-menu-item-left {
  429. width: px2vw(317);
  430. }
  431. .user-left-menu-icon {
  432. margin-left: px2vw(33);
  433. }
  434. .text-checked {
  435. font-size: px2vw(20);
  436. color: #FF0019;
  437. line-height: px2vw(26);
  438. margin-left: px2vw(15);
  439. }
  440. .text-unchecked {
  441. font-size: px2vw(20);
  442. color: #070707;
  443. line-height: px2vw(26);
  444. margin-left: px2vw(15);
  445. }
  446. .user-right-box {
  447. background: #F4F4F4;
  448. box-shadow: px2vw(3) 0px px2vw(6) 0px rgba(0, 0, 0, 0.1);
  449. flex: 1;
  450. margin-left: px2vw(10);
  451. }
  452. </style>