register.vue 11 KB

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