mine.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <div class="pb_content">
  3. <div class="pb_content_body">
  4. <div class="body_student">
  5. <!-- <div class="student_head">
  6. <div class="box_course">
  7. <div class="wheel">
  8. <img
  9. :src="
  10. studentMessage.headportrait != null
  11. ? studentMessage.headportrait
  12. : tx
  13. "
  14. alt=""
  15. />
  16. </div>
  17. <div class="right_box">
  18. <div class="right_box_title">{{ studentMessage.name }}</div>
  19. <div class="people">
  20. <div>
  21. <span>班级:</span
  22. ><span style="color: #999">{{ studentMessage.cname }}</span>
  23. </div>
  24. <div style="margin-left: 50px">
  25. <span>所属学校:</span
  26. ><span style="color: #999">{{ studentMessage.sname }}</span>
  27. </div>
  28. </div>
  29. <div>
  30. <span>手机号码:</span
  31. ><span style="color: #999">{{
  32. studentMessage.phonenumber
  33. }}</span>
  34. </div>
  35. </div>
  36. </div>
  37. </div> -->
  38. <div class="student_body">
  39. <div class="tx">
  40. <img
  41. :src="ruleForm.headportrait != null ? ruleForm.headportrait : tx"
  42. alt=""
  43. />
  44. </div>
  45. <el-form
  46. :model="ruleForm"
  47. :rules="rules"
  48. ref="ruleForm"
  49. label-width="100px"
  50. class="demo-ruleForm"
  51. >
  52. <el-form-item label="姓名:" prop="name">
  53. <el-input
  54. v-model="ruleForm.name"
  55. style="width: 250px"
  56. placeholder="请输入名字"
  57. ></el-input>
  58. </el-form-item>
  59. <el-form-item label="性别:">
  60. <el-radio-group v-model="ruleForm.sex">
  61. <el-radio label="男"></el-radio>
  62. <el-radio label="女"></el-radio>
  63. </el-radio-group>
  64. </el-form-item>
  65. <el-form-item label="电子邮箱:" prop="mail">
  66. <el-input
  67. v-model="ruleForm.mail"
  68. style="width: 300px"
  69. placeholder="请输入电子邮箱"
  70. ></el-input>
  71. </el-form-item>
  72. <el-form-item label="手机号码:" prop="phonenumber">
  73. <el-input
  74. disabled
  75. v-model="ruleForm.phonenumber"
  76. style="width: 300px"
  77. placeholder="请输入手机号码"
  78. ></el-input>
  79. </el-form-item>
  80. <el-form-item label="组织:" prop="sname">
  81. <el-input
  82. disabled
  83. v-model="ruleForm.sname"
  84. style="width: 300px"
  85. ></el-input>
  86. </el-form-item>
  87. <el-form-item label="班级:" prop="cname">
  88. <el-input
  89. disabled
  90. v-model="ruleForm.cname"
  91. style="width: 300px"
  92. ></el-input>
  93. </el-form-item>
  94. <el-form-item label="个人简介:" prop="intro">
  95. <el-input
  96. v-model="ruleForm.intro"
  97. type="textarea"
  98. :rows="5"
  99. resize="none"
  100. placeholder="想说点什么..."
  101. style="width: 300px"
  102. ></el-input>
  103. </el-form-item>
  104. <el-form-item>
  105. <el-button
  106. type="primary"
  107. style="
  108. background: #41cda6;
  109. border-color: #41cda6;
  110. width: 200px;
  111. height: 20px;
  112. line-height: 0px;
  113. "
  114. @click="submitForm('ruleForm')"
  115. >修改</el-button
  116. >
  117. </el-form-item>
  118. </el-form>
  119. </div>
  120. </div>
  121. </div>
  122. </div>
  123. </template>
  124. <script>
  125. export default {
  126. data() {
  127. var validatePass = (rule, value, callback) => {
  128. if (value == "") {
  129. return;
  130. }
  131. var reg =
  132. /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/;
  133. if (!reg.test(value)) {
  134. callback(new Error("请输入正确的邮箱"));
  135. } else {
  136. callback();
  137. }
  138. };
  139. var validatePass1 = (rule, value, callback) => {
  140. var reg = /^1\d{10}$/;
  141. if (!reg.test(value)) {
  142. callback(new Error("请输入正确的手机号码"));
  143. } else {
  144. callback();
  145. }
  146. };
  147. return {
  148. studentMessage: [],
  149. tx: require("../assets/tx.png"),
  150. userid: this.$route.query.userid,
  151. ruleForm: {
  152. name: "",
  153. sex: "男",
  154. intro: "",
  155. mail: "",
  156. phonenumber: "",
  157. sname: "",
  158. headportrait: "",
  159. cname: "",
  160. },
  161. rules: {
  162. pass: [{ validator: validatePass, trigger: "blur" }],
  163. name: [{ required: true, message: "请输入你的名字", trigger: "blur" }],
  164. mail: [
  165. {
  166. validator: validatePass,
  167. trigger: "blur",
  168. },
  169. ],
  170. phone: [
  171. { required: true, message: "请输入你的手机号码", trigger: "blur" },
  172. {
  173. validator: validatePass1,
  174. trigger: "blur",
  175. },
  176. ],
  177. },
  178. };
  179. },
  180. methods: {
  181. goTo(path) {
  182. this.$router.push(path);
  183. },
  184. selectSDetail() {
  185. let params = {
  186. uid: this.userid,
  187. };
  188. this.ajax
  189. .get(this.$store.state.api + "selectSDetail", params)
  190. .then((res) => {
  191. res.data[0][0].sex = res.data[0][0].sex ? "女" : "男";
  192. this.ruleForm = res.data[0][0];
  193. console.log(this.ruleForm);
  194. })
  195. .catch((err) => {
  196. console.error(err);
  197. });
  198. },
  199. submitForm(formName) {
  200. this.$refs[formName];
  201. let params = [
  202. {
  203. uid: this.userid,
  204. sname: this.ruleForm.name,
  205. ph: this.ruleForm.phonenumber,
  206. sex: this.ruleForm.sex == "男" ? "0" : "1",
  207. email: this.ruleForm.mail == null ? "" : this.ruleForm.mail,
  208. js: this.ruleForm.intro == null ? "" : this.ruleForm.intro,
  209. },
  210. ];
  211. this.ajax
  212. .post(this.$store.state.api + "updateUser", params)
  213. .then((res) => {
  214. this.$message({
  215. message: "修改成功",
  216. type: "success",
  217. });
  218. this.selectSDetail();
  219. })
  220. .catch((err) => {
  221. this.$message.error("修改失败");
  222. console.error(err);
  223. });
  224. },
  225. },
  226. created() {
  227. this.selectSDetail();
  228. },
  229. };
  230. </script>
  231. <style scoped>
  232. .body_student {
  233. margin: 0px auto;
  234. width: 98%;
  235. height: 100%;
  236. }
  237. .student_head {
  238. width: 80%;
  239. margin: 0 auto;
  240. background: #fff;
  241. height: 30%;
  242. }
  243. .wheel > img, .mine_pic > img {
  244. width: 100%;
  245. height: 100%;
  246. }
  247. .box_course {
  248. display: flex;
  249. padding: 35px 0 25px 60px;
  250. align-items: center;
  251. }
  252. .wheel {
  253. width: 210px;
  254. }
  255. .right_box {
  256. display: flex;
  257. flex-direction: column;
  258. margin-left: 30px;
  259. /* justify-content: space-around; */
  260. }
  261. .right_box_title {
  262. font-size: 23px;
  263. }
  264. .people {
  265. display: flex;
  266. margin: 30px 0 15px 0px;
  267. }
  268. .student_body {
  269. width: 100%;
  270. margin: 0 auto;
  271. background: #fff;
  272. margin-top: 20px;
  273. min-height: 1000px;
  274. display: flex;
  275. padding: 5% 0 0 0;
  276. justify-content: center;
  277. }
  278. .mine_pic {
  279. width: 120px;
  280. height: 116px;
  281. margin: 0 auto;
  282. }
  283. .box_three_pic {
  284. margin: 0 auto;
  285. width: 80%;
  286. padding: 50px 0 20px 0;
  287. display: flex;
  288. flex-direction: row;
  289. justify-content: flex-start;
  290. flex-wrap: wrap;
  291. }
  292. .pic_box {
  293. text-align: center;
  294. width: 33%;
  295. cursor: pointer;
  296. margin-bottom: 100px;
  297. }
  298. .pic_box > div:nth-child(2) {
  299. margin-top: 12px;
  300. }
  301. .tx {
  302. width: 200px;
  303. height: 200px;
  304. }
  305. .tx > img {
  306. width: 100%;
  307. height: 100%;
  308. }
  309. </style>