user.vue 12 KB

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