user.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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">上传头像</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. onLoad() {
  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. uni.request({
  167. header: {
  168. 'Content-Type': 'application/json;charset=UTF-8'
  169. },
  170. url: url,
  171. method: 'POST',
  172. data: {
  173. "UserID": mydata_userInfo.UserID,
  174. },
  175. dataType: 'json',
  176. success: (res) => {
  177. let data = res.data;
  178. //100成功
  179. if (data.Code == 100) {
  180. console.log("请求成功", res);
  181. this.$refs.GRXX.updateInfo(data.User);
  182. mydata_userInfo.email = data.User.Email;
  183. // console.log('00000000000=',mydata_userInfo.role)
  184. if (mydata_userInfo.role == '老师') {
  185. // this.$refs.XSSYQK.updateInfo(data.User);
  186. } else {
  187. this.$refs.GRXXJL.updateInfo(data.User);
  188. }
  189. }
  190. //200失败
  191. else {
  192. }
  193. // console.log("success+++**+*", res.data.Code)
  194. },
  195. fail: (res) => {
  196. console.log("fail+**+*", res)
  197. }
  198. });
  199. },
  200. scroll(e) {
  201. //记录scroll 位置
  202. this.oldScrollTop = e.detail.scrollTop
  203. },
  204. goTop(e) {
  205. //视图会发生重新渲染
  206. this.scrollTop = this.oldScrollTop
  207. //当视图渲染结束 重新设置为0
  208. this.$nextTick(() => {
  209. this.scrollTop = 0
  210. });
  211. },
  212. //范例,直接复制
  213. testPost() {
  214. let url = this.$Api + "/user/getuserinfo";
  215. uni.request({
  216. header: {
  217. 'Content-Type': 'application/json;charset=UTF-8'
  218. },
  219. url: url,
  220. method: 'POST',
  221. data: {
  222. "UserID": mydata_userInfo.UserID,
  223. },
  224. dataType: 'json',
  225. success: (res) => {
  226. let data = res.data;
  227. //100成功
  228. if (data.Code == 100) {
  229. }
  230. //200失败
  231. else {
  232. }
  233. console.log("success+++**+*", res.data.Code)
  234. },
  235. fail: (res) => {
  236. console.log("fail+**+*", res)
  237. }
  238. });
  239. },
  240. onClick_XSSYQK(UserID){
  241. // console.log("11111=",this.userInfo.role);
  242. // console.log("2222=",this.isShow_xssyqk);
  243. console.log("UserID=",UserID);
  244. this.isShow_xssyqk = true;
  245. this.checkedIndex_leftMenu = 1;
  246. this.showIndex = 2;
  247. let url = this.$Api + "/user/getuserinfo";
  248. uni.request({
  249. header: {
  250. 'Content-Type': 'application/json;charset=UTF-8'
  251. },
  252. url: url,
  253. method: 'POST',
  254. data: {
  255. "UserID": UserID,
  256. },
  257. dataType: 'json',
  258. success: (res) => {
  259. let data = res.data;
  260. //100成功
  261. if (data.Code == 100) {
  262. console.log("请求成功", res);
  263. this.$refs.XSSYQK.updateInfo(data.User);
  264. }
  265. //200失败
  266. else {
  267. }
  268. // console.log("success+++**+*", res.data.Code)
  269. },
  270. fail: (res) => {
  271. console.log("fail+**+*", res)
  272. }
  273. });
  274. }
  275. }
  276. }
  277. </script>
  278. <style lang="scss">
  279. $btnN:4;
  280. .content-box {
  281. width: px2vw(312*$btnN+34*(($btnN)-1));
  282. height: px2vw(367);
  283. }
  284. .user-full {
  285. width: 100%;
  286. height: 100%;
  287. }
  288. .user-show {
  289. width: 100%;
  290. // height: 100%;
  291. height: px2vh(960);
  292. }
  293. .user-left-box {
  294. width: px2vw(374);
  295. background: #FFFFFF;
  296. box-shadow: px2vw(3) 0px px2vw(6) 0px rgba(0, 0, 0, 0.1);
  297. margin-top: px2vw(10);
  298. }
  299. .user-left-avatar img {
  300. width: px2vw(120);
  301. margin-top: px2vw(74);
  302. }
  303. .user-left-btn {
  304. width: px2vw(158);
  305. height: px2vw(48);
  306. background: #EA252C;
  307. border-radius: px2vw(8);
  308. font-size: px2vw(18);
  309. color: #FFFFFF;
  310. line-height: px2vw(24);
  311. margin-top: px2vw(31);
  312. margin-bottom: px2vw(65);
  313. }
  314. .user-left-line {
  315. width: px2vw(374);
  316. height: 1px;
  317. background: #DDDDDD;
  318. }
  319. .user-left-menu-item {
  320. height: px2vw(80);
  321. margin-top: px2vw(16);
  322. margin-bottom: px2vw(16);
  323. }
  324. .user-left-menu-item-left {
  325. width: px2vw(317);
  326. }
  327. .user-left-menu-icon {
  328. margin-left: px2vw(33);
  329. }
  330. .text-checked {
  331. font-size: px2vw(20);
  332. color: #FF0019;
  333. line-height: px2vw(26);
  334. margin-left: px2vw(15);
  335. }
  336. .text-unchecked {
  337. font-size: px2vw(20);
  338. color: #070707;
  339. line-height: px2vw(26);
  340. margin-left: px2vw(15);
  341. }
  342. .user-right-box {
  343. background: #F4F4F4;
  344. box-shadow: px2vw(3) 0px px2vw(6) 0px rgba(0, 0, 0, 0.1);
  345. flex: 1;
  346. margin-left: px2vw(10);
  347. }
  348. </style>