userCenterSecuritySetting.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <div style="width: 100%;background: #fff;min-height: 700px;">
  3. <div
  4. style="height: 80px;line-height: 80px;margin-top: 20px;margin: 0 20px; color: #666;font-size: 15px; border-bottom: 1px solid #bcbcbc;">
  5. {{ $t('common.Your Current Account Number:') }} {{ this.account }}
  6. </div>
  7. <div style="height: 60px;padding: 40px 50px;">
  8. <span style="width: 80px;height: 100%;float: left;"><i class="el-icon-lock"
  9. style="font-size: 65px;color: #3688ff;margin-top: 32px;vertical-align:middle;"></i></span>
  10. <span style="float: left;width: 600px;;padding-top: 36px;">
  11. <div style="font-size: 18px;color: #666;font-weight: 700;">{{ $t('common.Login Password') }}</div>
  12. <div
  13. style="margin-top: 16px;font-size: 15px;color: #999;">{{
  14. $t('common.It is recommended that you change your password')
  15. }}</div>
  16. </span>
  17. <span style="float: left;width: 200px;;padding-top: 36px;">
  18. <el-button type="primary" plain style="margin-top: 12px;"
  19. @click="dialogVisibles()">{{ $t('common.Modify') }}</el-button>
  20. </span>
  21. </div>
  22. <div style="height: 60px;padding: 40px 50px;">
  23. <span style="width: 80px;height: 100%;float: left;"><i class="el-icon-mobile-phone"
  24. style="font-size: 65px;color: #3688ff;margin-top: 32px;vertical-align:middle;"></i></span>
  25. <span style="float: left;width: 600px;;padding-top: 36px;">
  26. <div style="font-size: 18px;color: #666;font-weight: 700;">{{ $t('common.Secure Mobile Phone') }}</div>
  27. <div
  28. style="margin-top: 16px;font-size: 15px;color: #999;">{{
  29. $t('common.Secure mobile phone can')
  30. }}</div>
  31. </span>
  32. <!-- <span style="float: left;width: 200px;;padding-top: 36px;">
  33. <el-button type="primary" plain style="margin-top: 12px;" @click="toView('securitySettingChangePhone','')">更换手机号</el-button>
  34. </span>-->
  35. <span style="float: left;width: 200px;;padding-top: 36px;">
  36. <el-button type="primary" plain style="margin-top: 12px;"
  37. @click="toView('securitySettingChangePhone','')">{{ this.mobileButtonStr }}</el-button>
  38. </span>
  39. </div>
  40. <div style="height: 60px;padding: 40px 50px;">
  41. <span style="width: 80px;height: 100%;float: left;"><i class="el-icon-message"
  42. style="font-size: 65px;color: #3688ff;margin-top: 32px;vertical-align:middle;"></i></span>
  43. <span style="float: left;width: 600px;;padding-top: 36px;">
  44. <div style="font-size: 18px;color: #666;font-weight: 700;">{{ $t('common.Verify Mailbox') }}</div>
  45. <div style="margin-top: 16px;font-size: 15px;color: #999;">{{ this.emailButtonStr }}</div>
  46. </span>
  47. <span style="float: left;width: 200px;;padding-top: 36px;">
  48. <el-button type="primary" plain style="margin-top: 12px;"
  49. @click="toView2('securitySettingChangeMail','')">{{
  50. $t('common.Verify Mailbox')
  51. }}</el-button>
  52. </span>
  53. </div>
  54. <div style="height: 60px;padding: 40px 50px;">
  55. <span style="width: 80px;height: 100%;float: left;">
  56. <i class="el-icon-message"
  57. style="font-size: 65px;color: #3688ff;margin-top: 32px;vertical-align:middle;"></i></span>
  58. <span style="float: left;width: 600px;;padding-top: 36px;">
  59. <div style="font-size: 18px;color: #666;font-weight: 700;">{{ $t('common.settingLanguage') }}</div>
  60. <div style="margin-top: 16px;font-size: 15px;color: #999;">{{ this.mainLanguage }}</div>
  61. </span>
  62. <span style="float: left;width: 200px;;padding-top: 36px;">
  63. <el-button type="primary" plain style="margin-top: 12px;"
  64. @click="handleClose">{{ $t('common.switchLanguage') }}</el-button>
  65. </span>
  66. </div>
  67. <!-- 修改密码弹框-->
  68. <el-dialog
  69. :title="$t('common.Change Password')"
  70. :visible.sync="dialogVisible"
  71. width="30%"
  72. height='40%'
  73. :before-close="PassworldHandleClose">
  74. <div style="height: 200px;position: relative;width: 100%;">
  75. <el-form ref="form" :model="form" :label-width="$i18n.locale=='zh'?'20%':'35%'"
  76. style="position: absolute;left: 56%;top: 55%;transform: translate(-55%,-50%);width: 400px;">
  77. <el-form-item :label="$t('common.Original Password:')">
  78. <el-input v-model="passWord.passWord1" show-password maxlength="20" show-word-limit></el-input>
  79. </el-form-item>
  80. <el-form-item :label="$t('common.New Password:')">
  81. <el-input v-model="passWord.passWord2" show-password maxlength="20" show-word-limit></el-input>
  82. </el-form-item>
  83. <el-form-item :label="$t('common.Confirm Password:')">
  84. <el-input v-model="passWord.passWord3" show-password maxlength="20" show-word-limit></el-input>
  85. </el-form-item>
  86. </el-form>
  87. </div>
  88. <span slot="footer" class="dialog-footer">
  89. <el-button @click="PassworldHandleClose">{{ $t('common.Cancel') }}</el-button>
  90. <el-button type="primary" @click="pwdSetting(form)">{{ $t('common.Determine') }}</el-button>
  91. </span>
  92. </el-dialog>
  93. </div>
  94. </template>
  95. <script>
  96. import {setPwd, getUserInfoById, settingLanguage} from '@/api/user';
  97. import {getToken} from '@/api/token.js';
  98. var jsSHA = require("jssha");
  99. export default {
  100. name: 'userCenterSecuritySetting',
  101. data() {
  102. return {
  103. informationsClass: '1',
  104. dialogVisible: this.$route.query.dialogVisible ? true : false,
  105. ifDiaslog: '',
  106. account: '',
  107. salfPhone: '',
  108. mobileButtonStr: '',
  109. emailButtonStr: '',
  110. isMobilePass: true,
  111. isEmailPass: true,
  112. title: '',
  113. mainLanguage: '',
  114. llanguage: '',
  115. form: {
  116. name: '1233@163.com',
  117. region: '普通用户',
  118. date1: '2018-05-19',
  119. date3: '2018-05-19',
  120. date2: '2020-05-25 11:20:23',
  121. delivery: false,
  122. type: [],
  123. resource: '',
  124. desc: ''
  125. },
  126. passWord: {
  127. passWord1: '',
  128. passWord2: '',
  129. passWord3: '',
  130. },
  131. Emal: {
  132. newEmal: '',
  133. VerificationCode: ''
  134. },
  135. mobileStatus: {
  136. 0: true,
  137. 1: false
  138. },
  139. emailStatus: {
  140. 0: true,
  141. 1: false
  142. },
  143. show: true,
  144. count: '',
  145. timer: null,
  146. }
  147. },
  148. watch: {
  149. "$i18n.locale"() {
  150. this.initData();
  151. },
  152. },
  153. mounted() {
  154. this.initData();
  155. },
  156. methods: {
  157. getData() {
  158. getUserInfoStatus().then((result) => {
  159. var data = result.data;
  160. if (data.language) {
  161. this.mainLanguage = data.language;
  162. }
  163. });
  164. },
  165. PassworldHandleClose(done) {
  166. if (this.$route.query.dialogVisible) {
  167. this.$confirm(this.$t('common.PasswordExpire') + "!", this.$t('common.Tips'), {
  168. confirmButtonText: this.$t('common.submit'),
  169. cancelButtonText: this.$t('common.cancel'),
  170. type: 'warning'
  171. }).then(() => {
  172. this.$store
  173. .dispatch("user/LOGOUT")
  174. .then(() => {
  175. // location.href = "/";
  176. this.$router.go(-1);
  177. })
  178. .catch((error) => {
  179. location.href = "/";
  180. });
  181. }).catch(() => {
  182. });
  183. } else {
  184. this.dialogVisible = false;
  185. }
  186. },
  187. // 切换语言
  188. handleClose(done) {
  189. const that = this;
  190. //language需要从数据库中查询
  191. let language = this.$i18n.locale;
  192. let sessionLanguage = window.sessionStorage.getItem("locale");
  193. let Hint;
  194. if (language == 'zh') {
  195. if (sessionLanguage == 'zh') {
  196. Hint = language ? '是否设置为英语?' : 'Set to Chinese?';
  197. } else {
  198. Hint = language ? '是否设置为中文?' : 'Set to English?';
  199. }
  200. } else {
  201. if (sessionLanguage == 'zh') {
  202. Hint = language ? 'Set to English?' : '是否设置为中文?';
  203. } else {
  204. Hint = language ? 'Set to Chinese?' : '是否设置为英语?';
  205. }
  206. }
  207. this.$confirm(Hint, {
  208. confirmButtonText: this.$t('common.OK'),
  209. cancelButtonText: this.$t('common.cancel'),
  210. })
  211. .then(_ => {
  212. // that.$i18n.locale=that.$i18n.locale=='zh'?'en':'zh';
  213. let sessionLocale = window.sessionStorage.getItem("locale");
  214. if (sessionLocale) {
  215. that.$i18n.locale = sessionLocale == 'zh' ? 'en' : 'zh';
  216. } else {
  217. that.$i18n.locale = that.$i18n.locale == 'zh' ? 'en' : 'zh';
  218. }
  219. //保存语言设置
  220. settingLanguage(that.$i18n.locale).then(result => {
  221. let locale = window.localStorage.getItem("locale");
  222. if (locale && sessionLocale) {
  223. window.localStorage.setItem("locale", that.$i18n.locale);
  224. window.sessionStorage.setItem("locale", that.$i18n.locale);
  225. } else {
  226. window.localStorage["locale"] = lang;
  227. window.sessionStorage["locale"] = lang;
  228. }
  229. if (that.$i18n.locale == 'zh') {
  230. this.mainLanguage = '中文';
  231. } else {
  232. this.mainLanguage = 'EN';
  233. }
  234. // done();
  235. }).catch((error) => {
  236. this.$message({
  237. message: this.$t('common.errorMessage'),
  238. type: 'error'
  239. });
  240. })
  241. })
  242. .catch(_ => {
  243. });
  244. },
  245. initData() {
  246. getUserInfoById().then(result => {
  247. if (result) {
  248. var phone = result.data.userPreferredMobile;
  249. if (phone) {
  250. this.salfPhone = phone.substr(0, 3) + '****' + phone.substr(7);
  251. }
  252. this.account = result.data.userUid;
  253. console.log(result.data.userMobileStatus);
  254. this.isMobilePass = this.mobileStatus[result.data.userMobileStatus];
  255. this.isEmailPass = this.emailStatus[result.data.userEmailStatus];
  256. console.log(this.isMobilePass);
  257. if (this.isMobilePass) {
  258. this.mobileButtonStr = this.$t('common.Change Mobile Phone Number');
  259. } else {
  260. this.mobileButtonStr = this.$t('common.BindPhone');
  261. }
  262. if (this.isEmailPass) {
  263. this.emailButtonStr = this.$t('common.EmailVerifications');
  264. } else {
  265. this.emailButtonStr = this.$t('common.EmailVerificationNo');
  266. }
  267. let language = result.data.languageSettingDict;
  268. if (language) {
  269. this.llanguage = language;
  270. if (language == 'zh') {
  271. if (this.$i18n.locale == 'en') {
  272. this.mainLanguage = 'ZH';
  273. } else {
  274. this.mainLanguage = '中文';
  275. }
  276. } else {
  277. this.mainLanguage = 'EN';
  278. }
  279. }
  280. }
  281. }).catch((error) => {
  282. })
  283. },
  284. getInformation(num) {
  285. this.informationsClass = num
  286. },
  287. toView(router, json) {
  288. if (this.isMobilePass) {
  289. //修改手机
  290. this.$router.push({name: router, params: json})
  291. } else {
  292. //绑定手机
  293. this.$router.push({name: "securitySettingBindPhone", params: json})
  294. }
  295. },
  296. toView2(router, json) {
  297. this.$router.push({name: router, params: json})
  298. },
  299. // handleClose(done) {
  300. // this.$confirm('确认关闭?')
  301. // .then(_ => {
  302. // done();
  303. // })
  304. // .catch(_ => {});
  305. // },
  306. dialogVisibles() {
  307. this.passWord.passWord1 = '';
  308. this.passWord.passWord2 = "";
  309. this.passWord.passWord3 = "";
  310. this.dialogVisible = true;
  311. },
  312. getCode() {
  313. const TIME_COUNT = 60;
  314. if (!this.timer) {
  315. this.count = TIME_COUNT;
  316. this.show = false;
  317. this.timer = setInterval(() => {
  318. if (this.count > 0 && this.count <= TIME_COUNT) {
  319. this.count--;
  320. } else {
  321. this.show = true;
  322. clearInterval(this.timer);
  323. this.timer = null;
  324. }
  325. }, 1000)
  326. }
  327. },
  328. pwdSetting() {
  329. if (this.passWord.passWord1 == "" || this.passWord.passWord1 == null) {
  330. this.$message.warning(this.$t('common.Oldpasswordcannotbeempty'));
  331. return;
  332. }
  333. if (this.passWord.passWord2 == "" || this.passWord.passWord2 == null) {
  334. this.$message.warning(this.$t('common.Newpasswordcannotbeempty'));
  335. return;
  336. }
  337. if (this.passWord.passWord3 == "" || this.passWord.passWord3 == null) {
  338. this.$message.warning(this.$t('common.Confirmpasswordcannotbeempty'));
  339. return;
  340. }
  341. //判断两次密码是否一致
  342. if (this.passWord.passWord2 != this.passWord.passWord3) {
  343. this.$message.warning(this.$t('common.Thetwopasswordsarenotthesame'));
  344. return;
  345. }
  346. //校验密码格式
  347. var msg = /^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_]+$)(?![a-z0-9]+$)(?![a-z\W_]+$)(?![0-9\W_]+$)[a-zA-Z0-9\W_]{8,20}$/.test(
  348. this.passWord.passWord3) ? "" : this.$i18n.locale == 'en' ? 'Please input 8 to 20 digits password, at least 3 items of upper and lower case letters, numbers and special symbols' : '请输入8到20位密码,大小写字母,数字,特殊符号至少三项';
  349. if (msg != "") {
  350. return this.$message({
  351. message: msg,
  352. type: 'warning'
  353. })
  354. }
  355. let token = getToken();
  356. let param = {};
  357. param.id = JSON.parse(this.$Cookies.get('userInfo')).userId;
  358. param.password = this.passWord.passWord3;
  359. param.OriginalPassword = this.passWord.passWord1;
  360. setPwd(JSON.stringify(param), token).then(result => {
  361. if (result.status == 200) {
  362. this.$message({
  363. message: this.$t("common.Passwordchangedsuccessfully") + "!",
  364. type: 'success'
  365. })
  366. this.dialogVisible = false;
  367. } else {
  368. return this.$message({
  369. message: this.$t("common.ThesystemisbusyPleasetryagainlater") + "!",
  370. type: 'warning'
  371. })
  372. }
  373. })
  374. }
  375. }
  376. }
  377. </script>
  378. <style scoped>
  379. .el-button {
  380. width: 150px;
  381. height: 45px;
  382. }
  383. </style>