setting.vue 14 KB

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