register.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. <template>
  2. <div class="pb_content" v-loading="isloading">
  3. <div class="pb_content_body" style="position: relative">
  4. <div style="width: 100%; margin: 0px auto">
  5. <div class="formTop">
  6. <div class="tx">
  7. <img :src="ruleForm.headportrait ? ruleForm.headportrait : tx" alt />
  8. </div>
  9. </div>
  10. <div class="reBox">
  11. <div class="first">
  12. <div>
  13. <div style="color: red">*</div>
  14. 请输入地区
  15. </div>
  16. <div>
  17. <!-- <el-input
  18. v-model="ruleForm.region"
  19. style="width: 300px"
  20. placeholder="请输入市区"
  21. ></el-input> -->
  22. <el-cascader size="large" style="width: 300px" clearable :options="region" v-model="selectedOptions"
  23. @change="handleChange" placeholder="请选择市区">
  24. </el-cascader>
  25. </div>
  26. </div>
  27. <div class="first">
  28. <div>详细地址</div>
  29. <div>
  30. <el-input v-model="ruleForm.address" style="width: 300px" placeholder="请输入详细地址"></el-input>
  31. </div>
  32. </div>
  33. <div class="first">
  34. <div>
  35. <div style="color: red">*</div>
  36. 学校
  37. </div>
  38. <div>
  39. <el-select v-model="ruleForm.school" filterable clearable @clear="clearSchoolList" :allow-create="false"
  40. @focus="remoteMethodclick" remote placeholder="请输入学校" :remote-method="remoteMethod" :loading="loading"
  41. no-data-text="暂未查询到此学校">
  42. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
  43. </el-option>
  44. </el-select>
  45. </div>
  46. </div>
  47. <div class="first">
  48. <div>
  49. <div style="color: red">*</div>
  50. 姓名
  51. </div>
  52. <div>
  53. <el-input v-model="ruleForm.name" style="width: 300px" placeholder="请输入姓名"></el-input>
  54. </div>
  55. </div>
  56. <div class="first">
  57. <div>
  58. <div style="color: red">*</div>
  59. 联系方式
  60. </div>
  61. <div>
  62. <el-input v-model="ruleForm.phone" style="width: 300px" placeholder="请输入手机号或邮箱"></el-input>
  63. </div>
  64. </div>
  65. <div class="isButton">
  66. <el-button @click="addRaceUser">确定提交</el-button>
  67. <el-button @click="goTo('/login')">返回登录</el-button>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. <el-dialog :show-close="false" title="提交成功" :visible.sync="dialogVisibleSuccess" :append-to-body="true"
  73. width="600px" :close-on-click-modal="false" :before-close="handleClose" class="dialog_diy">
  74. <div class="s_box">
  75. <div class="s_top">
  76. <span>恭喜您</span>
  77. <span>成功申请广东省案例征集活动管理账号!</span>
  78. </div>
  79. <div class="s_content">
  80. <div class="title">以下为您的登录账号密码</div>
  81. <div class="content">
  82. <div>
  83. <span class="user">{{ num }}</span>
  84. </div>
  85. <div><span>密码:</span><span class="password">123456</span></div>
  86. </div>
  87. <div class="tips1">请截图保存好自己的账号密码</div>
  88. <div class="tips2">复制账号和密码,登录后进行操作</div>
  89. </div>
  90. </div>
  91. <span slot="footer" class="dialog-footer">
  92. <el-button type="primary" class="tag-read" style="
  93. background: rgb(112, 183, 79);
  94. border-color: rgb(112, 183, 79);
  95. margin-right: 50px;
  96. " @click="copy" :data-clipboard-text="copyText">复制账号</el-button>
  97. <el-button type="primary" @click="goTo('/login')">返回登陆</el-button>
  98. </span>
  99. </el-dialog>
  100. <!-- <div class="copyright">
  101. 版权所有:广州师培社教育科技有限公司 粤ICP备09132871号
  102. </div> -->
  103. </div>
  104. </template>
  105. <script>
  106. import { regionData, CodeToText } from "element-china-area-data";
  107. import Clipboard from "clipboard";
  108. const Data = regionData.filter((ele) => {
  109. return ele.value == "440000";
  110. });
  111. export default {
  112. data() {
  113. return {
  114. region: Data[0].children,
  115. selectedOptions: [], //"440000","440100"
  116. ruleForm: {
  117. headportrait: "",
  118. region: "",
  119. address: "",
  120. school: "",
  121. name: "",
  122. phone: "",
  123. },
  124. tx: require("../assets/avatar2.png"),
  125. options: [],
  126. list: [],
  127. loading: false,
  128. schoolList: [],
  129. num: "",
  130. dialogVisibleSuccess: false,
  131. copyText: "",
  132. isloading: false,
  133. };
  134. },
  135. // mounted() {
  136. // this.list = this.schoolList.map((item) => {
  137. // return { value: `value:${item}`, label: `学校:${item}` };
  138. // });
  139. // },
  140. methods: {
  141. handleClose(done) {
  142. done();
  143. },
  144. goTo(path) {
  145. this.$router.push(path);
  146. },
  147. handleChange() {
  148. if (!this.selectedOptions) {
  149. return;
  150. }
  151. var loc = "";
  152. for (let i = 0; i < this.selectedOptions.length; i++) {
  153. loc += CodeToText[this.selectedOptions[i]];
  154. }
  155. this.ruleForm.region = "广东省" + loc;
  156. },
  157. remoteMethodclick() {
  158. if (!this.options.length) {
  159. var _option = []
  160. for (var i = 0; i < 10; i++) {
  161. var _a = this.randomNum(0, 10);
  162. _option.push(this.list[_a])
  163. }
  164. this.options = _option
  165. }
  166. },
  167. remoteMethod(query) {
  168. if (query !== "") {
  169. this.loading = true;
  170. setTimeout(() => {
  171. this.loading = false;
  172. this.options = this.list.filter((item) => {
  173. return item.label.toLowerCase().indexOf(query.toLowerCase()) > -1;
  174. });
  175. }, 200);
  176. } else {
  177. // this.options = [];
  178. var _option = []
  179. for (var i = 0; i < 10; i++) {
  180. var _a = this.randomNum(0, 10);
  181. _option.push(this.list[_a])
  182. }
  183. this.options = _option
  184. }
  185. },
  186. clearSchoolList() {
  187. // var _option = []
  188. this.ruleForm.school = ""
  189. },
  190. getSchool() {
  191. this.isloading = true;
  192. let params = {
  193. n: "",
  194. };
  195. this.ajax
  196. .get(this.$store.state.api + "getSchool", params)
  197. .then((res) => {
  198. this.schoolList = res.data[0];
  199. this.list = this.schoolList.map((item) => {
  200. return { value: item.id, label: item.name };
  201. });
  202. var _option = []
  203. for (var i = 0; i < 10; i++) {
  204. var _a = this.randomNum(0, this.list.length);
  205. _option.push(this.list[_a])
  206. }
  207. this.options = _option
  208. this.isloading = false;
  209. })
  210. .catch((err) => {
  211. this.isloading = false;
  212. console.error(err);
  213. });
  214. },
  215. addRaceUser() {
  216. if (this.ruleForm.region == "") {
  217. this.$message.error("请填写地区");
  218. return;
  219. } else if (this.ruleForm.school == "") {
  220. this.$message.error("请填写学校");
  221. return;
  222. } else if (this.ruleForm.name == "") {
  223. this.$message.error("请填写姓名");
  224. return;
  225. } else if (this.ruleForm.phone == "") {
  226. this.$message.error("请填写手机号");
  227. return;
  228. }
  229. this.isloading = true
  230. let params = [
  231. {
  232. reg: this.ruleForm.region,
  233. res: this.ruleForm.address,
  234. sch: this.ruleForm.school,
  235. n: this.ruleForm.name,
  236. p: this.ruleForm.phone,
  237. t:"1",
  238. parent:"",
  239. },
  240. ];
  241. this.ajax
  242. .post(this.$store.state.api + "addRaceUser", params)
  243. .then((res) => {
  244. this.$message({
  245. message: "创建成功",
  246. type: "success",
  247. });
  248. this.isloading = false
  249. this.dialogVisibleSuccess = true;
  250. this.num = res.data.num;
  251. })
  252. .catch((err) => {
  253. this.isloading = false
  254. this.$message.error("创建失败");
  255. console.error(err);
  256. });
  257. },
  258. randomNum(minNum, maxNum) {
  259. switch (arguments.length) {
  260. case 1:
  261. return parseInt(Math.random() * minNum + 1, 10);
  262. break;
  263. case 2:
  264. return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
  265. break;
  266. default:
  267. return 0;
  268. break;
  269. }
  270. },
  271. copy() {
  272. this.copyText = this.num;
  273. var clipboard = new Clipboard(".tag-read");
  274. clipboard.on("success", (e) => {
  275. this.$message.success("复制成功");
  276. console.log("复制成功");
  277. clipboard.destroy(); // 释放内存
  278. });
  279. clipboard.on("error", (e) => {
  280. console.log("不支持复制,该浏览器不支持自动复制");
  281. this.$message.error("不支持复制,该浏览器不支持自动复制");
  282. clipboard.destroy(); // 释放内存
  283. });
  284. },
  285. },
  286. created() {
  287. this.getSchool();
  288. },
  289. };
  290. </script>
  291. <style scoped>
  292. .dialog_diy>>>.el-dialog__header {
  293. background: #3c3c3c !important;
  294. padding: 15px 20px;
  295. }
  296. .dialog_diy>>>.el-dialog__title {
  297. color: #fff;
  298. }
  299. .dialog_diy>>>.el-dialog__headerbtn {
  300. top: 19px;
  301. }
  302. .dialog_diy>>>.el-dialog__headerbtn .el-dialog__close {
  303. color: #fff;
  304. }
  305. .dialog_diy>>>.el-dialog__headerbtn .el-dialog__close:hover {
  306. color: #fff;
  307. }
  308. .dialog_diy>>>.el-dialog__body,
  309. .dialog_diy>>>.el-dialog__footer {
  310. background: #fafafa;
  311. }
  312. .dialog_diy>>>.el-dialog__footer {
  313. display: flex;
  314. justify-content: center;
  315. }
  316. .pb_content {
  317. display: flex;
  318. align-items: center;
  319. justify-content: center;
  320. width: 100%;
  321. height: 100%;
  322. }
  323. .pb_content_body {
  324. background: #fff;
  325. padding: 20px 0;
  326. width: 500px;
  327. border-radius: 5px;
  328. }
  329. .formTop {
  330. display: flex;
  331. align-items: center;
  332. justify-content: center;
  333. margin: 20px 0;
  334. }
  335. .formTop>>>.el-form {
  336. margin: 0 auto;
  337. }
  338. .tx {
  339. width: 100px;
  340. /* margin-right: 15px; */
  341. min-width: 50px;
  342. min-height: 50px;
  343. }
  344. .tx>img {
  345. width: 100%;
  346. height: 100%;
  347. }
  348. .reBox {
  349. width: 100%;
  350. display: flex;
  351. flex-direction: column;
  352. flex-wrap: nowrap;
  353. align-content: center;
  354. justify-content: center;
  355. align-items: center;
  356. }
  357. .first {
  358. margin: 5px 0;
  359. width: 300px;
  360. }
  361. .first>div:nth-child(1) {
  362. margin-bottom: 5px;
  363. font-weight: bold;
  364. display: flex;
  365. flex-direction: row;
  366. flex-wrap: nowrap;
  367. justify-content: flex-start;
  368. align-items: center;
  369. }
  370. .first>div:nth-child(2)>.el-select {
  371. width: 300px;
  372. }
  373. .isButton {
  374. margin-top: 20px;
  375. }
  376. .isButton>>>.el-button {
  377. background: #5492ff !important;
  378. color: #fff !important;
  379. cursor: pointer;
  380. }
  381. .copyright {
  382. position: absolute;
  383. left: 20px;
  384. bottom: 15px;
  385. }
  386. .s_box {
  387. background: #fff;
  388. border-radius: 5px;
  389. }
  390. .s_top {
  391. width: 90%;
  392. margin: 0 auto;
  393. border-bottom: 1px solid #eee;
  394. padding: 20px 0;
  395. display: flex;
  396. flex-direction: column;
  397. font-size: 22px;
  398. }
  399. .s_top span:nth-child(1) {
  400. font-size: 26px;
  401. }
  402. .s_content {
  403. width: 90%;
  404. margin: 0 auto;
  405. padding: 20px 0 50px;
  406. }
  407. .s_content .title {
  408. font-size: 18px;
  409. }
  410. .s_content .content {
  411. padding: 50px 0;
  412. display: flex;
  413. flex-direction: column;
  414. align-items: center;
  415. }
  416. .s_content .content div+div {
  417. margin-top: 20px;
  418. }
  419. .s_content .content .user {
  420. font-size: 20px;
  421. color: rgb(64, 145, 234);
  422. }
  423. .s_content .content .password {
  424. font-size: 24px;
  425. color: rgb(64, 145, 234);
  426. }
  427. .s_content .tips1 {
  428. color: rgb(162, 162, 162);
  429. }
  430. .s_content .tips2 {
  431. font-size: 18px;
  432. }
  433. </style>