Settings.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <script>
  2. import { post, put } from '../../utils/request'
  3. import { country } from '../../utils/country.js'
  4. import { userStore } from '@/store/userInfo'
  5. export default {
  6. props: {
  7. getInfo: {
  8. type: Function,
  9. default: null
  10. }
  11. },
  12. data() {
  13. return {
  14. active: 0,
  15. country: [],
  16. ruleForm: {
  17. userName: '',
  18. email: '',
  19. area: ''
  20. },
  21. rules: {
  22. userName: [
  23. { required: true, message: 'User name is required', trigger: [''] }
  24. ],
  25. email: [],
  26. area: [{ required: true, message: 'Area is required', trigger: [''] }]
  27. },
  28. ruleFormPass: {
  29. oldPassword: '',
  30. newPassword: '',
  31. confirmPassword: ''
  32. },
  33. rulesPass: {
  34. oldPassword: [
  35. { required: true, message: 'Please fill old password', trigger: [''] }
  36. ],
  37. newPassword: [
  38. { required: true, message: 'Please fill new password', trigger: [''] }
  39. ],
  40. confirmPassword: [
  41. {
  42. required: true,
  43. message: 'Confirm password is required',
  44. trigger: ['']
  45. }
  46. ]
  47. },
  48. generalLoading: false,
  49. role: ''
  50. }
  51. },
  52. methods: {
  53. changePassword() {
  54. this.$refs['ruleFormPass'].validate((valid) => {
  55. if (valid) {
  56. post('/pdf-tech/vppMember/updatePassword', {
  57. password: this.ruleFormPass.oldPassword,
  58. newPassword: this.ruleFormPass.newPassword,
  59. newPasswordConfirm: this.ruleFormPass.confirmPassword
  60. }).then((res) => {
  61. if (
  62. res.data.code === 200 &&
  63. res.data.msg === 'Password updated successfully'
  64. ) {
  65. this.$message({
  66. duration: 5000,
  67. message: 'Change Successfully',
  68. type: 'success'
  69. })
  70. this.$router.push('/login')
  71. } else if (
  72. res.data.code === 700 &&
  73. res.data.msg === 'Old Password error'
  74. ) {
  75. this.$message.error({
  76. duration: 5000,
  77. message: 'Old Password Incorrect'
  78. })
  79. } else if (
  80. res.data.code === 700 &&
  81. res.data.msg === 'Different Password'
  82. ) {
  83. this.$message.error({
  84. message: "New password and confirm password don't match"
  85. })
  86. } else if (
  87. res.data.code === 700 &&
  88. res.data.msg === 'Password must between 6-24 characters'
  89. ) {
  90. this.$message.error({
  91. message: 'The passwords must be 6-24 characters'
  92. })
  93. } else if (
  94. res.data.code === 302 &&
  95. res.data.msg === 'Please Create your Account first'
  96. ) {
  97. this.$message.error({
  98. duration: 5000,
  99. message: 'Please Create your Account first'
  100. })
  101. }
  102. })
  103. } else {
  104. return false
  105. }
  106. })
  107. },
  108. changeInfo() {
  109. this.$refs['ruleForm'].validate((valid) => {
  110. if (valid) {
  111. if (this.generalLoading) return
  112. this.generalLoading = true
  113. put('/pdf-tech/vppSet/setGeneral', {
  114. userName: this.ruleForm.userName,
  115. area: this.ruleForm.area
  116. }).then((res) => {
  117. setTimeout(() => {
  118. this.generalLoading = false
  119. }, 2000)
  120. if (res.data.code === 200 && res.data.msg === 'success') {
  121. this.$message({
  122. duration: 5000,
  123. message: 'Change Success',
  124. type: 'success'
  125. })
  126. this.getInfo()
  127. } else if (
  128. res.data.code === 306 &&
  129. res.data.msg === '账号或者密码错误'
  130. ) {
  131. this.$message.error({
  132. duration: 5000,
  133. message: 'Old Password Incorrect'
  134. })
  135. } else if (
  136. res.data.code === 302 &&
  137. res.data.msg === 'Please Create your Account first'
  138. ) {
  139. this.$message.error({
  140. duration: 5000,
  141. message: 'Please Create your Account first'
  142. })
  143. }
  144. })
  145. } else {
  146. return false
  147. }
  148. })
  149. }
  150. },
  151. mounted() {
  152. this.country = country()
  153. this.ruleForm.email = userStore().user.email
  154. this.ruleForm.userName = userStore().user.userName
  155. this.ruleForm.area = userStore().user.area || ''
  156. this.role = userStore().user.role
  157. }
  158. }
  159. </script>
  160. <template>
  161. <div>
  162. <h1 class="text-28px leading-40px mb-15px font-700">Settings</h1>
  163. <div class="flex">
  164. <span
  165. class="
  166. flex
  167. justify-center
  168. bg-[#C6C9CC]
  169. rounded-t-8px
  170. items-center
  171. font-bold
  172. w-200px
  173. h-32px
  174. hand
  175. "
  176. @click="active = 0"
  177. :class="active === 0 ? 'active' : ''"
  178. >General</span
  179. >
  180. <span
  181. class="
  182. flex
  183. justify-center
  184. bg-[#C6C9CC]
  185. rounded-t-8px
  186. items-center
  187. font-bold
  188. w-200px
  189. h-32px
  190. ml-8px
  191. hand
  192. "
  193. @click="active = 1"
  194. :class="active === 1 ? 'active' : ''"
  195. >Security</span
  196. >
  197. </div>
  198. <div class="bg-[#fff] card">
  199. <el-form
  200. :model="ruleForm"
  201. ref="ruleForm"
  202. :rules="rules"
  203. label-position="top"
  204. label-width="100px"
  205. inline-message
  206. class="p-40px"
  207. v-show="active === 0"
  208. >
  209. <el-form-item label="Reseller Name" prop="userName" v-if="role === '4'">
  210. <div style="display: flex">
  211. <el-input
  212. v-model="ruleForm.userName"
  213. class="username"
  214. disabled="true"
  215. placeholder="Reseller Name"
  216. >
  217. </el-input>
  218. </div>
  219. </el-form-item>
  220. <el-form-item label="User Name" prop="userName" v-else>
  221. <div style="display: flex">
  222. <el-input
  223. v-model="ruleForm.userName"
  224. class="username"
  225. placeholder="User Name"
  226. >
  227. </el-input>
  228. </div>
  229. </el-form-item>
  230. <el-form-item label="Email" prop="email" class="w-600px">
  231. <div style="display: flex">
  232. <el-input
  233. v-model.trim="ruleForm.email"
  234. class="email"
  235. disabled
  236. placeholder="Email address confirmation"
  237. >
  238. </el-input>
  239. </div>
  240. </el-form-item>
  241. <el-form-item label="Country/Region">
  242. <select v-model="ruleForm.area" class="flex w-600px !h-40px" :class="{ '!text-[#232A40]': ruleForm.area !== '' }">
  243. <option value="" selected>Choose your country/region</option>
  244. <option
  245. v-for="(item, index) in country"
  246. :key="index"
  247. :value="item.name"
  248. >
  249. {{ item.name }}
  250. </option>
  251. </select>
  252. </el-form-item>
  253. <el-form-item>
  254. <button
  255. type="button"
  256. @click="changeInfo()"
  257. class="
  258. w-168px
  259. h-48px
  260. bg-[#1460F3]
  261. text-[#fff]
  262. rounded-8px
  263. font-bold
  264. hover:opacity-80
  265. "
  266. >
  267. Save the Change
  268. </button>
  269. </el-form-item>
  270. </el-form>
  271. <el-form
  272. :model="ruleFormPass"
  273. ref="ruleFormPass"
  274. :rules="rulesPass"
  275. label-position="top"
  276. label-width="100px"
  277. inline-message
  278. class="p-40px"
  279. v-show="active === 1"
  280. >
  281. <el-form-item prop="oldPassword">
  282. <span slot="label" class="font-bold"
  283. >Old Password<span class="text-[#FF5054]">*</span></span
  284. >
  285. <div style="display: flex">
  286. <el-input
  287. type="password"
  288. class="username"
  289. v-model.trim="ruleFormPass.oldPassword"
  290. placeholder="Please enter an old password "
  291. >
  292. </el-input>
  293. </div>
  294. </el-form-item>
  295. <el-form-item prop="newPassword">
  296. <span slot="label" class="font-bold"
  297. >New Password<span class="text-[#FF5054]">*</span></span
  298. >
  299. <div style="display: flex">
  300. <el-input
  301. type="password"
  302. class="username"
  303. v-model.trim="ruleFormPass.newPassword"
  304. placeholder="Please enter a new password "
  305. >
  306. </el-input>
  307. </div>
  308. </el-form-item>
  309. <el-form-item prop="confirmPassword">
  310. <span slot="label" class="font-bold"
  311. >Confirm Password<span class="text-[#FF5054]">*</span></span
  312. >
  313. <div style="display: flex">
  314. <el-input
  315. type="password"
  316. class="username"
  317. v-model.trim="ruleFormPass.confirmPassword"
  318. placeholder="Please confirm the new password "
  319. >
  320. </el-input>
  321. </div>
  322. </el-form-item>
  323. <router-link
  324. to="/forget-password"
  325. class="flex ml-8px leading-20px mb-10px text-[#1460F3]"
  326. >Forgot Your Password?</router-link
  327. >
  328. <el-form-item>
  329. <button
  330. type="button"
  331. @click="changePassword()"
  332. class="
  333. w-168px
  334. h-48px
  335. bg-[#1460F3]
  336. text-[#fff]
  337. rounded-8px
  338. font-bold
  339. hover:opacity-80
  340. "
  341. >
  342. Save the Change
  343. </button>
  344. </el-form-item>
  345. </el-form>
  346. </div>
  347. </div>
  348. </template>
  349. <style lang="scss" scoped>
  350. .hand {
  351. cursor: pointer;
  352. }
  353. .el-form-item::v-deep label {
  354. color: #232a40 !important;
  355. }
  356. .active {
  357. color: #1460f3;
  358. background-color: #fff;
  359. }
  360. .card {
  361. border-radius: 8px;
  362. border-top-left-radius: 0px;
  363. }
  364. .el-input::v-deep input {
  365. border: 0px !important;
  366. border-bottom: 1px solid #d9d9d9 !important;
  367. border-radius: 6px !important;
  368. }
  369. .username::v-deep input {
  370. border-radius: 0px !important;
  371. }
  372. .email::v-deep input {
  373. border: 0px !important;
  374. }
  375. .el-form-item::v-deep label::before {
  376. display: none;
  377. }
  378. .el-form-item::v-deep label {
  379. font-weight: 700;
  380. padding: 0;
  381. margin-left: 8px;
  382. }
  383. </style>