AdminSetting.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <template>
  2. <div class="context">
  3. <div class="panel">
  4. <h5>系统设置</h5>
  5. <div class="pages">
  6. <el-tabs v-model="activeName" type="card">
  7. <el-tab-pane label="密码修改" name="second">
  8. <div class="form_container">
  9. <el-form ref="form" :model="form" label-width="110px" :rules="rules">
  10. <el-form-item label="请输入原密码" prop="old">
  11. <el-input v-model="form.old" type="password"></el-input>
  12. </el-form-item>
  13. <el-form-item label="新密码" prop="newpwd">
  14. <el-input v-model="form.newpwd" type="password"></el-input>
  15. </el-form-item>
  16. <el-form-item label="确认密码" prop="again">
  17. <el-input v-model="form.again" type="password"></el-input>
  18. </el-form-item>
  19. <el-form-item>
  20. <el-button type="" @click="onSubmit('form')">确认修改</el-button>
  21. </el-form-item>
  22. </el-form>
  23. </div>
  24. </el-tab-pane>
  25. </el-tabs>
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. import { PassEdit } from "../api/getApiRes";
  32. let qs = require('qs');
  33. import Global from '../Global.js'
  34. import {
  35. testTable,
  36. } from '../api/getApiRes.js'
  37. export default {
  38. data() {
  39. let samepass = (rule, value, callback) => {
  40. if (value !== this.form.newpwd) {
  41. callback(new Error('两次输入密码不一致!'));
  42. } else {
  43. callback();
  44. }
  45. };
  46. let pwdPass = (rule, value, callback) => {
  47. let re = /^[0-9a-zA-Z_]{1,}$/;
  48. if (value.search(re) == -1) {
  49. callback(new Error('错了哦,密码只能由字母、数字及下划线组成'));
  50. } else {
  51. callback()
  52. }
  53. };
  54. return {
  55. activeName: 'second',
  56. pageApppoint: true,
  57. valImgSrc: '',
  58. overtime: '',
  59. appoint: '0',
  60. form: {
  61. old: '',
  62. newpwd: '',
  63. again: '',
  64. valid: '',
  65. },
  66. rules: {
  67. old: [
  68. { required: true, message: '请输入原密码', trigger: 'blur' },
  69. { min: 6, max: 32, message: '长度在 6 到 32 个字符', trigger: 'blur' }
  70. ],
  71. newpwd: [
  72. { required: true, message: '请输入新密码', trigger: 'blur' },
  73. { min: 6, max: 32, message: '长度在 6 到 32 个字符', trigger: 'blur' },
  74. { validator: pwdPass, trigger: 'blur' }
  75. ],
  76. again: [
  77. { required: true, message: '请输入确认密码', trigger: 'blur' },
  78. { min: 6, max: 32, message: '长度在 6 到 32 个字符', trigger: 'blur' },
  79. { validator: pwdPass, trigger: 'blur' },
  80. { validator: samepass, trigger: 'blur' },
  81. ],
  82. valid: [
  83. { required: true, message: '请输入图形验证码', trigger: 'blur' },
  84. { min: 3, max: 4, message: '长度在 4 个字符', trigger: 'blur' }
  85. ],
  86. }
  87. }
  88. },
  89. mounted() {
  90. // 读取验证码
  91. this.overtime = new Date();
  92. // 读取当前店铺预约状态 todo
  93. },
  94. methods: {
  95. // 微信可见与否
  96. changeWechat(e, appoint) {
  97. let that = this;
  98. let param = {
  99. token: localStorage.token,
  100. wxVisible: e,//
  101. };
  102. let postdata = qs.stringify(param);
  103. testTable(postdata).then(res => {
  104. let json = res;
  105. if (json.Code == 0) {
  106. that.$message({
  107. showClose: true,
  108. message: '本店预约已关闭',
  109. type: 'success'
  110. });
  111. // 重载列表
  112. that.getTableQuery();
  113. } else {
  114. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  115. }
  116. })
  117. },
  118. // 跳转tab页面
  119. goTab(url) {
  120. this.$router.push({ path: url });
  121. },
  122. // 点击验证码切换
  123. changeValImg: function () {
  124. this.validImgState = true;
  125. this.CurenttestTable();
  126. },
  127. onSubmit(formName) {
  128. let that = this;
  129. this.$refs[formName].validate((valid) => {
  130. if (valid) {
  131. that.submitPwd()
  132. } else {
  133. that.$message({
  134. showClose: true,
  135. message: '错了哦,提交新密码失败',
  136. type: 'error'
  137. });
  138. that.form.old = '';
  139. that.form.newpwd = '';
  140. that.form.again = '';
  141. // 提交失败也要重载验证码
  142. this.CurenttestTable();
  143. return false;
  144. }
  145. });
  146. },
  147. resetForm(formName) {
  148. this.$refs[formName].resetFields();
  149. },
  150. submitPwd() {
  151. let that = this;
  152. let param = {
  153. token: localStorage.token,
  154. oldpass: that.form.old,
  155. newpass: that.form.newpwd,
  156. };
  157. let postdata = qs.stringify(param);
  158. PassEdit(postdata).then(res => {
  159. let json = res;
  160. // 无论成功与否都重载验证码
  161. if (json.Code == 0) {
  162. that.$message({
  163. showClose: true,
  164. message: '密码修改成功',
  165. type: 'success'
  166. });
  167. // clean info
  168. that.old = '';
  169. that.newpwd = '';
  170. that.again = '';
  171. that.logoutPage();
  172. } else {
  173. that.$message.error(json.Memo + ',错误代码:' + json.Code);
  174. }
  175. });
  176. },
  177. // 重登录
  178. logoutPage() {
  179. const that = this;
  180. let param = {
  181. token: localStorage.token,
  182. };
  183. let postdata = qs.stringify(param);
  184. testTable(postdata).then(res => {
  185. let json = res;
  186. if (json.Code == 0) {
  187. that.$router.push({
  188. path: '/login',
  189. query: {
  190. status: 1
  191. }
  192. })
  193. } else {
  194. that.$message.error(json.Memo + ',错误代码:' + json.Code);
  195. }
  196. })
  197. }
  198. },
  199. }
  200. </script>
  201. <style scoped>
  202. @import "../assets/css/panel.css";
  203. ul {
  204. margin: 0;
  205. padding: 0;
  206. list-style: none;
  207. }
  208. .tabs ul {
  209. width: 358px;
  210. margin: 0 auto;
  211. margin-top: 15px;
  212. }
  213. .image-border {
  214. position: absolute;
  215. width: 20px;
  216. height: 20px;
  217. }
  218. .image-border1 {
  219. top: 0;
  220. left: 25px;
  221. border-left: 2px solid #6DC1FF;
  222. border-top: 2px solid #6DC1FF;
  223. }
  224. .image-border2 {
  225. top: 0;
  226. right: 12px;
  227. border-right: 2px solid #6DC1FF;
  228. border-top: 2px solid #6DC1FF;
  229. }
  230. .image-border3 {
  231. bottom: 0;
  232. left: 25px;
  233. border-bottom: 2px solid #6DC1FF;
  234. border-left: 2px solid #6DC1FF;
  235. }
  236. .image-border4 {
  237. bottom: 0;
  238. right: 12px;
  239. border-right: 2px solid #6DC1FF;
  240. border-bottom: 2px solid #6DC1FF;
  241. }
  242. .pages {
  243. width: 100%;
  244. min-height: 600px;
  245. overflow: hidden;
  246. display: block;
  247. margin: 0 auto;
  248. padding-bottom: 80px;
  249. }
  250. .form_container {
  251. width: 50%;
  252. overflow: hidden;
  253. margin: 0 auto;
  254. margin-top: 20px;
  255. padding: 20px;
  256. }
  257. s {
  258. height: 50px;
  259. line-height: 40px;
  260. padding-left: 20px;
  261. text-decoration: none;
  262. font-style: normal;
  263. }
  264. i {
  265. color: red;
  266. }
  267. s em {
  268. font-style: normal;
  269. }
  270. /deep/ .el-form {
  271. width: 500px;
  272. overflow: hidden;
  273. display: block;
  274. margin: 0 auto;
  275. }
  276. /deep/ .el-form-item__label {
  277. width: 120px !important;
  278. /*color: #6DC1FF;*/
  279. font-size: 16px;
  280. float: left;
  281. }
  282. /deep/ .el-form-item__content {
  283. width: 370px;
  284. float: right;
  285. overflow: hidden;
  286. margin-left: 0px !important;
  287. }
  288. /deep/ .el-input__inner {
  289. background: none;
  290. color: #6DC1FF;
  291. border: 1px solid #DCDFE6;
  292. border-radius: 0;
  293. }
  294. /deep/ .el-range-input {
  295. background: none;
  296. color: #6DC1FF;
  297. }
  298. .el-button--primary {
  299. width: 186px;
  300. height: 30px;
  301. background: #0162AA;
  302. color: #6DC1FF;
  303. border: 1px solid #6DC1FF;
  304. border-radius: 0;
  305. }
  306. #validImg {
  307. position: relative;
  308. float: right;
  309. bottom: 35px;
  310. }
  311. .context {
  312. /* height: 770px; */
  313. overflow-y: scroll;
  314. display: block;
  315. margin: 0 auto;
  316. background-color: #fff !important;
  317. padding: 30px;
  318. }
  319. .panel-body {
  320. padding: 20px;
  321. background: #F0F2F5;
  322. }
  323. .change button {
  324. float: left;
  325. margin-right: 10px;
  326. }
  327. .change button.el-button--primary {
  328. height: 38px;
  329. color: #fff;
  330. background: #409EFF;
  331. padding: 3px 5px;
  332. width: 120px;
  333. }
  334. .form_container {
  335. width: 100%;
  336. overflow: hidden;
  337. display: block;
  338. margin: 0 auto;
  339. padding-left: 0;
  340. padding-right: 0;
  341. }
  342. .form_container .gary {
  343. width: 100%;
  344. height: 64px;
  345. overflow: hidden;
  346. display: block;
  347. margin: 0 auto;
  348. padding: 34px 32px;
  349. padding-bottom: 0;
  350. background: #F0F2F5;
  351. border-radius: 2px;
  352. }
  353. .gary span {
  354. float: left;
  355. margin-right: 30px;
  356. }
  357. /deep/ .el-switch {
  358. float: left;
  359. }
  360. .gary em {
  361. position: relative;
  362. top: -10px;
  363. left: 30px;
  364. padding: 13px 37px;
  365. float: left;
  366. background: #fff;
  367. border-radius: 250px;
  368. color: #E38F00;
  369. font-size: 14px;
  370. font-style: normal;
  371. }
  372. /deep/ .el-form {
  373. width: 600px;
  374. float: left;
  375. }
  376. /deep/ .el-form-item__content {
  377. width: 437px;
  378. float: left;
  379. }
  380. .panel /deep/ .el-input__inner {
  381. width: 437px;
  382. float: left;
  383. }
  384. /deep/ .el-button {
  385. float: left;
  386. margin-left: 120px;
  387. }
  388. </style>