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