user.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  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 + 1)==1 && mydata_userInfo.UserID=='4c80ab9c-7e0a-4f41-b8d0-c62f30e0f85c')
  134. {
  135. alert('专家号不能查看个人信息!')
  136. return;
  137. }
  138. if (index == this.userMenu_student.length - 1) {
  139. this.$emit("onClick_proManage");
  140. }
  141. else
  142. {
  143. this.isShow_xssyqk = false;
  144. this.checkedIndex_leftMenu = index;
  145. this.showIndex = index + 1;
  146. // console.log('checkedIndex_leftMenu=',index)
  147. // console.log('showIndex=',index+1)
  148. }
  149. if (this.userInfo.role == '老师')
  150. {
  151. switch (index) {
  152. case 0: //个人信息
  153. break;
  154. case 1: //学生管理
  155. // this.$refs.XSGL.updateInfo();
  156. this.$refs.XSGL.initPage();
  157. break;
  158. case 2: //创作项目管理平台
  159. break;
  160. default:
  161. }
  162. }
  163. else
  164. {
  165. switch (index) {
  166. case 0: //个人信息
  167. break;
  168. case 1: //个人学习记录
  169. break;
  170. case 2: //创作项目管理平台
  171. break;
  172. default:
  173. }
  174. }
  175. this.getUserInfo();
  176. },
  177. getUserInfo() {
  178. let url = mydata_api + "/user/getuserinfo";
  179. let _self = this;
  180. uni.request({
  181. header: {
  182. 'Content-Type': 'application/json;charset=UTF-8'
  183. },
  184. url: url,
  185. method: 'POST',
  186. data: {
  187. "UserID": mydata_userInfo.UserID,
  188. },
  189. dataType: 'json',
  190. success: (res) => {
  191. let data = res.data;
  192. //100成功
  193. if (data.Code == 100) {
  194. // console.log("请求成功", res);
  195. this.$refs.GRXX.updateInfo(data.User);
  196. mydata_userInfo.email = data.User.Email;
  197. // console.log('00000000000=',mydata_userInfo.role)
  198. if (mydata_userInfo.role == '老师')
  199. {
  200. // this.$refs.XSSYQK.updateInfo(data.User);
  201. }
  202. else
  203. {
  204. this.$refs.GRXXJL.updateInfo(data.User);
  205. //请求分数
  206. url = mydata_api + "/score/getscore";
  207. uni.request({
  208. header: {
  209. 'Content-Type': 'application/json;charset=UTF-8'
  210. },
  211. url: url,
  212. method: 'POST',
  213. data: {
  214. "UserID": data.User.Id,
  215. },
  216. dataType: 'json',
  217. success: (res) => {
  218. let data = res.data;
  219. //100成功
  220. if (data.Code == 100) {
  221. // console.log("请求分数成功", res);
  222. this.$refs.GRXXJL.updateLearnProgress(data.Scores);
  223. }
  224. //200失败
  225. else {
  226. console.log("fail200=", res)
  227. }
  228. // console.log("success+++**+*", res.data.Code)
  229. },
  230. fail: (res) => {
  231. console.log("fail+**+*", res)
  232. }
  233. });
  234. }
  235. }
  236. //200失败
  237. else {
  238. console.log("fail200=", res)
  239. }
  240. // console.log("success+++**+*", res.data.Code)
  241. },
  242. fail: (res) => {
  243. console.log("fail+**+*", res)
  244. }
  245. });
  246. },
  247. scroll(e) {
  248. //记录scroll 位置
  249. this.oldScrollTop = e.detail.scrollTop
  250. },
  251. goTop(e) {
  252. //视图会发生重新渲染
  253. this.scrollTop = this.oldScrollTop
  254. //当视图渲染结束 重新设置为0
  255. this.$nextTick(() => {
  256. this.scrollTop = 0
  257. });
  258. },
  259. onClick_XSSYQK(UserID){
  260. // console.log("11111=",this.userInfo.role);
  261. // console.log("2222=",this.isShow_xssyqk);
  262. // console.log("UserID=",UserID);
  263. this.isShow_xssyqk = true;
  264. this.checkedIndex_leftMenu = 1;
  265. this.showIndex = 2;
  266. let url = mydata_api + "/user/getuserinfo";
  267. uni.request({
  268. header: {
  269. 'Content-Type': 'application/json;charset=UTF-8'
  270. },
  271. url: url,
  272. method: 'POST',
  273. data: {
  274. "UserID": UserID,
  275. },
  276. dataType: 'json',
  277. success: (res) => {
  278. let data = res.data;
  279. //100成功
  280. if (data.Code == 100) {
  281. // console.log("请求成功", res);
  282. this.$refs.XSSYQK.updateInfo(data.User);
  283. }
  284. //200失败
  285. else {
  286. }
  287. // console.log("success+++**+*", res.data.Code)
  288. },
  289. fail: (res) => {
  290. console.log("fail+**+*", res)
  291. }
  292. });
  293. url = mydata_api + "/score/getscore";
  294. uni.request({
  295. header: {
  296. 'Content-Type': 'application/json;charset=UTF-8'
  297. },
  298. url: url,
  299. method: 'POST',
  300. data: {
  301. "UserID": UserID,
  302. },
  303. dataType: 'json',
  304. success: (res) => {
  305. let data = res.data;
  306. //100成功
  307. if (data.Code == 100) {
  308. // console.log("请求分数成功", res);
  309. this.$refs.XSSYQK.updateLearnProgress(data.Scores);
  310. }
  311. //200失败
  312. else {
  313. console.log("fail+200+*", res)
  314. }
  315. },
  316. fail: (res) => {
  317. console.log("fail+**+*", res)
  318. }
  319. });
  320. },
  321. onUploadAvatar(){
  322. uni.chooseFile({
  323. success: (chooseFileRes) => {
  324. uni.showLoading({
  325. title: '正在上传'
  326. });
  327. const tempFilePaths = chooseFileRes.tempFilePaths;
  328. uni.uploadFile({
  329. url: mydata_api + "/user/uploaduserheadimage", //仅为示例,非真实的接口地址
  330. filePath: tempFilePaths[0],
  331. name: 'file',
  332. formData: {
  333. 'UserID':mydata_userInfo.UserID, // 创建用户 id
  334. },
  335. success: (uploadFileRes) => {
  336. console.log('选择图片ok=',uploadFileRes.data);
  337. uni.showLoading({
  338. title: '上传中'
  339. });
  340. //刷新avatar
  341. uni.request({
  342. header: {
  343. 'Content-Type': 'application/json;charset=UTF-8'
  344. },
  345. url: mydata_api + "/user/getuserinfo", //仅为示例,非真实的接口地址
  346. method: 'POST',
  347. data: {
  348. 'UserID':mydata_userInfo.UserID,
  349. },
  350. dataType: 'json',
  351. success: (res) => {
  352. console.log('上传头像成功url=',res)
  353. this.userInfo.avatarSrc = res.data.User.HeadImageURL;
  354. uni.hideLoading();
  355. },
  356. fail: (res) => {
  357. // console.log("uploadFileRes+fail+", res)
  358. uni.hideLoading();
  359. alert("上传头像失败")
  360. }
  361. });
  362. }
  363. });
  364. }
  365. });
  366. }
  367. }
  368. }
  369. </script>
  370. <style lang="scss">
  371. $btnN:4;
  372. .content-box {
  373. width: px2vw(312*$btnN+34*(($btnN)-1));
  374. height: px2vw(367);
  375. }
  376. .user-full {
  377. width: 100%;
  378. height: 100%;
  379. }
  380. .user-show {
  381. width: 100%;
  382. // height: 100%;
  383. height: px2vh(960);
  384. }
  385. .user-left-box {
  386. width: px2vw(374);
  387. background: #FFFFFF;
  388. box-shadow: px2vw(3) 0px px2vw(6) 0px rgba(0, 0, 0, 0.1);
  389. margin-top: px2vw(10);
  390. }
  391. .user-left-avatar img {
  392. width: px2vw(120);
  393. height: px2vw(120);
  394. // overflow: hidden;
  395. margin-top: px2vw(74);
  396. }
  397. .user-left-btn {
  398. width: px2vw(158);
  399. height: px2vw(48);
  400. background: #EA252C;
  401. border-radius: px2vw(8);
  402. font-size: px2vw(18);
  403. color: #FFFFFF;
  404. line-height: px2vw(24);
  405. margin-top: px2vw(31);
  406. margin-bottom: px2vw(65);
  407. }
  408. .user-left-line {
  409. width: px2vw(374);
  410. height: 1px;
  411. background: #DDDDDD;
  412. }
  413. .user-left-menu-item {
  414. height: px2vw(80);
  415. margin-top: px2vw(16);
  416. margin-bottom: px2vw(16);
  417. }
  418. .user-left-menu-item-left {
  419. width: px2vw(317);
  420. }
  421. .user-left-menu-icon {
  422. margin-left: px2vw(33);
  423. }
  424. .text-checked {
  425. font-size: px2vw(20);
  426. color: #FF0019;
  427. line-height: px2vw(26);
  428. margin-left: px2vw(15);
  429. }
  430. .text-unchecked {
  431. font-size: px2vw(20);
  432. color: #070707;
  433. line-height: px2vw(26);
  434. margin-left: px2vw(15);
  435. }
  436. .user-right-box {
  437. background: #F4F4F4;
  438. box-shadow: px2vw(3) 0px px2vw(6) 0px rgba(0, 0, 0, 0.1);
  439. flex: 1;
  440. margin-left: px2vw(10);
  441. }
  442. </style>