user.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. <template>
  2. <div class="page flex-col">
  3. <s-header
  4. :name="sys ? sys.title : $t('public.sysName')"
  5. :noback="true"
  6. :isFixed="false"
  7. ></s-header>
  8. <div class="userPageBox">
  9. <div class="userBaseBox">
  10. <div class="baseRow flex-row justify-between">
  11. <div class="group2 flex-col"></div>
  12. <span class="baseText">{{ $t("user.essentialInformation") }}</span>
  13. </div>
  14. <div class="userMessage flex-row justify-between">
  15. <div class="userId">
  16. <p class="userText">{{ accountDetail.managerId }}</p>
  17. <p class="userText">{{ $t("user.systemId") }}</p>
  18. </div>
  19. <div class="userLine"></div>
  20. <div class="userId">
  21. <p class="userText">{{ accountDetail.username }}</p>
  22. <p class="userText">{{ $t("user.myAccount") }}</p>
  23. </div>
  24. <div class="userLine"></div>
  25. <div class="userId">
  26. <p class="userText">{{ accountDetail.name }}</p>
  27. <p class="userText">{{ $t("user.myName") }}</p>
  28. </div>
  29. </div>
  30. <div class="userInfoBox">
  31. <!-- 地区 -->
  32. <div v-if="!areaShow" class="userInfo l-flex-between">
  33. <span class="userInfoLeft">{{ $t("user.region") }}: </span>
  34. <div class="cust_vantBorder">
  35. <div class="filedInpPad">
  36. <van-field
  37. @click-input="fieldValueInpClk"
  38. readonly
  39. clearable
  40. v-model="fieldValue"
  41. :placeholder="$t('user.regionPlace')"
  42. >
  43. <template #right-icon>
  44. <div class="l-flex-RC">
  45. <van-icon
  46. v-if="fieldValue"
  47. @click="
  48. fieldValue = '';
  49. accountDetail.areaId = '';
  50. "
  51. class="o-mr-6"
  52. name="clear"
  53. />
  54. <van-icon @click="fieldValueInpClk" name="arrow-down" />
  55. </div>
  56. </template>
  57. </van-field>
  58. </div>
  59. </div>
  60. <van-icon name="edit" class="editIcon" @click="editClk(4)" />
  61. </div>
  62. <div v-else class="userInfo l-flex-between">
  63. <span class="userInfoLeft">{{ $t("user.region") }}: </span>
  64. <span>{{ fieldValue }}</span>
  65. <van-icon name="edit" class="editIcon" @click="editClk(4)" />
  66. </div>
  67. <!-- 手机号 -->
  68. <div v-if="!phoneNumberShow" class="userInfo l-flex-between">
  69. <span class="userInfoLeft">{{ $t("user.phoneNumber") }}: </span>
  70. <div class="cust_vantBorder">
  71. <van-field
  72. class="relationClass"
  73. v-model="cofficentForm.phone"
  74. :placeholder="$t('user.phoneNumberPlace')"
  75. >
  76. <template #button>
  77. <van-button
  78. type="primary"
  79. @click="mailboxChg(cofficentForm.phone, 3)"
  80. >{{ $t("user.confirmLog") }}
  81. </van-button>
  82. </template>
  83. </van-field>
  84. </div>
  85. <van-icon name="edit" class="editIcon" @click="editClk(3)" />
  86. </div>
  87. <div v-else class="userInfo l-flex-between">
  88. <span class="userInfoLeft">{{ $t("user.phoneNumber") }}: </span>
  89. <span>{{ accountDetail.phone }}</span>
  90. <van-icon name="edit" class="editIcon" @click="editClk(3)" />
  91. </div>
  92. <!-- 邮箱 -->
  93. <div v-if="!mailboxShow" class="userInfo l-flex-between">
  94. <span class="userInfoLeft">{{ $t("user.mailbox") }}: </span>
  95. <div class="cust_vantBorder">
  96. <van-field
  97. class="relationClass"
  98. v-model="cofficentForm.mailBox"
  99. :placeholder="$t('user.mailboxPlace')"
  100. >
  101. <template #button>
  102. <van-button
  103. type="primary"
  104. @click="mailboxChg(cofficentForm.mailBox, 2)"
  105. >{{ $t("user.confirmLog") }}
  106. </van-button>
  107. </template>
  108. </van-field>
  109. </div>
  110. <van-icon name="edit" class="editIcon" @click="editClk(2)" />
  111. </div>
  112. <div v-else class="userInfo l-flex-between">
  113. <span class="userInfoLeft">{{ $t("user.mailbox") }}: </span>
  114. <span>{{ accountDetail.email }}</span>
  115. <van-icon name="edit" class="editIcon" @click="editClk(2)" />
  116. </div>
  117. <!-- 关联上级 -->
  118. <div v-if="!relationType" class="userInfo l-flex-between">
  119. <span class="userInfoLeft">{{ $t("user.associateParent") }}: </span>
  120. <div class="cust_vantBorder">
  121. <van-field
  122. class="relationClass"
  123. v-model="cofficentForm.associateParent"
  124. :placeholder="$t('user.associateParentPlace')"
  125. >
  126. <template #button>
  127. <van-button
  128. type="primary"
  129. @click="mailboxChg(cofficentForm.associateParent, 1)"
  130. >{{ $t("user.confirmLog") }}</van-button
  131. >
  132. </template>
  133. </van-field>
  134. </div>
  135. <van-icon name="edit" class="editIcon" @click="editClk(1)" />
  136. </div>
  137. <div v-else class="userInfo l-flex-between">
  138. <span class="userInfoLeft">{{ $t("user.associateParent") }}: </span>
  139. <span>{{ relationAdminName }}</span>
  140. <van-icon name="edit" class="editIcon" @click="editClk(1)" />
  141. </div>
  142. </div>
  143. </div>
  144. <div class="lineBox"></div>
  145. <div class="commonOperBox">
  146. <div class="baseRow flex-row justify-between">
  147. <div class="group2 flex-col"></div>
  148. <span class="baseText">{{ $t("user.commonOperations") }}</span>
  149. </div>
  150. <div class="operListBox">
  151. <div
  152. v-if="roleCheck()"
  153. class="taskListRow flex-col"
  154. @click="pushPageList('/taskMessage')"
  155. >
  156. <div class="taskIcon taskMessageIcon"></div>
  157. <div class="taskRight">
  158. <div class="taskTitle">{{ $t("user.taskMessage") }}</div>
  159. </div>
  160. </div>
  161. <div
  162. class="taskListRow flex-col"
  163. @click="pushPageList('/joinpayMch')"
  164. >
  165. <div class="taskIcon joinPayMchIcon"></div>
  166. <div class="taskRight">
  167. <div class="taskTitle">{{ $t("user.withdrawalAccountNo") }}</div>
  168. </div>
  169. </div>
  170. <div class="taskListRow flex-col" @click="pushPageList('/shandeMch')">
  171. <div class="taskIcon shandeMchIcon"></div>
  172. <div class="taskRight">
  173. <div class="taskTitle">
  174. {{ $t("user.standbyWithdrawalAccountNo") }}
  175. </div>
  176. </div>
  177. </div>
  178. <div
  179. class="taskListRow flex-col"
  180. @click="pushPageList('/changepassword')"
  181. >
  182. <div class="taskIcon changePasswordIcon"></div>
  183. <div class="taskRight">
  184. <div class="taskTitle">{{ $t("user.changePassword") }}</div>
  185. </div>
  186. </div>
  187. <div class="taskListRow flex-col" @click="operUnipay()">
  188. <div class="taskIcon selfPayIcon"></div>
  189. <div class="taskRight">
  190. <div class="taskTitle">{{ $t("user.selfRecharging") }}</div>
  191. </div>
  192. </div>
  193. <div class="taskListRow flex-col" @click="onperExitSys()">
  194. <div class="taskIcon loginOutIcon"></div>
  195. <div class="taskRight">
  196. <div class="taskTitle">{{ $t("user.logOut") }}</div>
  197. </div>
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. <nav-bar></nav-bar>
  203. <!-- 退出登录弹窗 -->
  204. <kDialog
  205. :dialogTitle="$t('user.logOutTips')"
  206. :cancelBtnTxt="$t('user.cancelLog')"
  207. :confirmBtnTxt="$t('user.confirmLog')"
  208. ref="kDialogRef"
  209. :dialogContent="$t('user.logOutContent')"
  210. @confirmclk="confirmClk"
  211. >
  212. </kDialog>
  213. <!-- 地区弹窗 -->
  214. <kCascader
  215. @getareaname="getAreaName"
  216. :selectId="accountDetail.areaId"
  217. @areapopfinish="areaPopFinish"
  218. ref="kCascaderRef"
  219. ></kCascader>
  220. </div>
  221. </template>
  222. <script>
  223. // 导入地区弹窗
  224. import kCascader from "@/components/commom/kCascader/index.vue";
  225. // 导入接口
  226. import { getAdmin } from "@/service/merchantManage";
  227. import { updateAdmin } from "@/service/merchantManage";
  228. // 引入弹窗
  229. import kDialog from "@/components/commom/kDialog/index.vue";
  230. import { onMounted, reactive, ref } from "vue";
  231. import sHeader from "@/components/SimpleHeader";
  232. import navBar from "@/components/NavBar";
  233. import {
  234. getLoginUser,
  235. $M_EmailAvailable,
  236. $M_PhoneTest,
  237. } from "@/common/js/utils";
  238. import { useRouter } from "vue-router";
  239. import { tAdminGetRelation, tAdminSetRelationAdmin } from "@/service/user";
  240. import { Toast } from "vant";
  241. import { useI18n } from "vue-i18n";
  242. export default {
  243. components: { sHeader, navBar, kDialog, kCascader },
  244. setup() {
  245. // 引入语言
  246. const { t } = useI18n();
  247. // 账户信息
  248. const accountDetail = ref({});
  249. // 控制都去显示隐藏
  250. const areaShow = ref(true);
  251. // 控制手机显示隐藏
  252. const phoneNumberShow = ref(true);
  253. // 控制邮箱显示隐藏
  254. const mailboxShow = ref(true);
  255. const user = getLoginUser();
  256. const router = useRouter();
  257. const relationAdminName = ref("");
  258. const relationType = ref(true);
  259. const sys = ref(null);
  260. // 修改的个人信息
  261. const cofficentForm = reactive({
  262. associateParent: relationAdminName.value,
  263. mailBox: accountDetail.value.email,
  264. phone: accountDetail.value.phone,
  265. area: "",
  266. });
  267. // 点击修改图标
  268. const editClk = (idx) => {
  269. switch (idx) {
  270. case 1:
  271. cofficentForm.associateParent = relationAdminName.value;
  272. relationType.value = !relationType.value;
  273. mailboxShow.value = true;
  274. phoneNumberShow.value = true;
  275. areaShow.value = true;
  276. break;
  277. case 2:
  278. cofficentForm.mailBox = accountDetail.value.email;
  279. relationType.value = true;
  280. mailboxShow.value = !mailboxShow.value;
  281. phoneNumberShow.value = true;
  282. areaShow.value = true;
  283. break;
  284. case 3:
  285. cofficentForm.phone = accountDetail.value.phone;
  286. relationType.value = true;
  287. mailboxShow.value = true;
  288. phoneNumberShow.value = !phoneNumberShow.value;
  289. areaShow.value = true;
  290. break;
  291. case 4:
  292. cofficentForm.area = accountDetail.value.area;
  293. relationType.value = true;
  294. mailboxShow.value = true;
  295. phoneNumberShow.value = true;
  296. areaShow.value = !areaShow.value;
  297. break;
  298. }
  299. };
  300. // 点击邮箱的确定按钮
  301. const mailboxChg = async (e, idx) => {
  302. switch (idx) {
  303. case 1:
  304. if (!e) {
  305. Toast(t("user.associateParentPlace"));
  306. } else {
  307. const { data } = await tAdminSetRelationAdmin({
  308. adminId: user.id,
  309. username: e,
  310. });
  311. relationType.value = true;
  312. if (data.code === "00000") {
  313. Toast(data.message);
  314. setTimeout(() => {
  315. gettAdminGetRelation();
  316. }, 500);
  317. }
  318. }
  319. break;
  320. case 2:
  321. if (!e) {
  322. Toast(t("user.mailboxPlace"));
  323. } else if (!$M_EmailAvailable(e)) {
  324. Toast(t("user.corrEmailPlace"));
  325. } else {
  326. const params = {
  327. id: user.id,
  328. email: e,
  329. };
  330. const { data } = await updateAdmin(params);
  331. mailboxShow.value = true;
  332. if (data.code === "00000") {
  333. Toast(data.message);
  334. setTimeout(() => {
  335. getAcccountDetail();
  336. }, 500);
  337. }
  338. }
  339. break;
  340. case 3:
  341. if (!e) {
  342. Toast(t("user.phoneNumberPlace"));
  343. } else if (!$M_PhoneTest(e)) {
  344. Toast(t("user.corrPhonePlace"));
  345. } else {
  346. const params = {
  347. id: user.id,
  348. phone: e,
  349. };
  350. const { data } = await updateAdmin(params);
  351. phoneNumberShow.value = true;
  352. if (data.code === "00000") {
  353. Toast(data.message);
  354. setTimeout(() => {
  355. getAcccountDetail();
  356. }, 500);
  357. }
  358. }
  359. break;
  360. }
  361. };
  362. // 获取账户详情
  363. const getAcccountDetail = () => {
  364. getAdmin({ id: user.id }).then((res) => {
  365. accountDetail.value = res.data.data;
  366. // 查询地址回显
  367. kCascaderRef.value.init(accountDetail.value.areaId);
  368. });
  369. };
  370. // 退出登录弹窗
  371. const kDialogRef = ref(null);
  372. // 点击右侧按钮
  373. const confirmClk = () => {
  374. // 获取缓存的语言
  375. const curLang = localStorage.getItem("curLang");
  376. // 清空缓存
  377. localStorage.clear();
  378. localStorage.setItem("curLang", curLang);
  379. if (sys.value) {
  380. setTimeout(() => {
  381. router.push({
  382. path: "login",
  383. query: { relation_admin_id: sys.value.relationAdminId },
  384. });
  385. }, 200);
  386. } else {
  387. setTimeout(() => {
  388. router.push({ path: "login" });
  389. }, 200);
  390. }
  391. };
  392. // 初始化页面获取列表
  393. onMounted(async () => {
  394. if (localStorage.getItem("loginSys")) {
  395. const loginSysString = localStorage.getItem("loginSys");
  396. sys.value = JSON.parse(loginSysString);
  397. }
  398. // 获取关联上级
  399. gettAdminGetRelation();
  400. // 获取账户
  401. getAcccountDetail();
  402. });
  403. const gettAdminGetRelation = async () => {
  404. const { data } = await tAdminGetRelation({
  405. relationAdminId: user.relationAdminId,
  406. });
  407. if (typeof data === "string") {
  408. relationAdminName.value = data;
  409. }
  410. };
  411. const operUnipay = () => {
  412. router.push({ path: "uniPay" });
  413. };
  414. const onperExitSys = () => {
  415. kDialogRef.value.openDialog();
  416. };
  417. const pushPageList = (url) => {
  418. router.push({ path: url });
  419. };
  420. const roleCheck = () => {
  421. if (user.isAdmined) {
  422. return true;
  423. } else {
  424. const menuList = user.menuCodeList.filter((item) => item === "M6");
  425. return menuList.length > 0;
  426. }
  427. };
  428. // 地区弹窗
  429. const fieldValue = ref("");
  430. const kCascaderRef = ref(null);
  431. // 点击地区输入框
  432. const fieldValueInpClk = () => {
  433. kCascaderRef.value.openPop();
  434. };
  435. // 选择地区完成
  436. const areaPopFinish = async (e) => {
  437. console.log("e", e);
  438. fieldValue.value = e.selectName;
  439. accountDetail.value.areaId = e.selectId;
  440. const params = {
  441. id: user.id,
  442. areaId: e.selectId,
  443. };
  444. const { data } = await updateAdmin(params);
  445. areaShow.value = true;
  446. if (data.code === "00000") {
  447. Toast(data.message);
  448. setTimeout(() => {
  449. getAcccountDetail();
  450. }, 500);
  451. }
  452. };
  453. // 获取回显的值
  454. const getAreaName = (e) => {
  455. fieldValue.value = e;
  456. };
  457. return {
  458. user,
  459. operUnipay,
  460. onperExitSys,
  461. relationAdminName,
  462. relationType,
  463. pushPageList,
  464. roleCheck,
  465. sys,
  466. kDialogRef,
  467. confirmClk,
  468. mailboxShow,
  469. mailboxChg,
  470. phoneNumberShow,
  471. editClk,
  472. cofficentForm,
  473. areaShow,
  474. accountDetail,
  475. fieldValue,
  476. kCascaderRef,
  477. fieldValueInpClk,
  478. areaPopFinish,
  479. getAreaName,
  480. };
  481. },
  482. };
  483. </script>
  484. <style lang="less" scoped>
  485. @import "../common/style/mixin.less";
  486. .page {
  487. width: 100%;
  488. background: url(../assets/user/bg.png) top center no-repeat;
  489. background-size: 100%;
  490. position: relative;
  491. /deep/ .simple-header {
  492. background: transparent;
  493. }
  494. .userPageBox {
  495. width: 100%;
  496. height: calc(100% - 100px);
  497. height: 100%;
  498. margin-bottom: 100px;
  499. overflow: auto;
  500. overflow-x: hidden;
  501. }
  502. .userBaseBox {
  503. width: 100%;
  504. }
  505. .baseRow {
  506. width: 100%;
  507. height: 20px;
  508. margin-left: 15px;
  509. margin-top: 5px;
  510. justify-content: flex-start;
  511. .group2 {
  512. background-color: rgba(128, 150, 236, 1);
  513. border-radius: 2px;
  514. width: 4px;
  515. height: 16px;
  516. margin-top: 4px;
  517. }
  518. .baseText {
  519. width: 150px;
  520. height: 20px;
  521. overflow-wrap: break-word;
  522. color: rgba(64, 77, 116, 1);
  523. font-size: 14px;
  524. font-family: PingFangSC-Medium;
  525. text-align: left;
  526. white-space: nowrap;
  527. line-height: 20px;
  528. display: block;
  529. margin-left: 15px;
  530. }
  531. }
  532. .userMessage {
  533. text-align: center;
  534. width: 80%;
  535. margin: 0 auto;
  536. margin-top: 30px;
  537. line-height: 1.7;
  538. .userText {
  539. font-size: 14px;
  540. font-family: PingFangSC-Medium;
  541. margin: 0;
  542. }
  543. .userLine {
  544. width: 1px;
  545. height: 3.5em;
  546. font-size: 14px;
  547. background: #e7eaf7;
  548. }
  549. }
  550. .userInfoBox {
  551. margin-top: 25px;
  552. padding: 0px 15px 20px;
  553. .userInfo {
  554. // width: 87%;
  555. margin: 0 auto;
  556. justify-content: flex-start;
  557. margin-top: 20px;
  558. position: relative;
  559. .filedInpPad {
  560. /deep/ .van-cell {
  561. padding: 0 !important;
  562. }
  563. }
  564. .editIcon {
  565. position: absolute;
  566. right: 0;
  567. font-size: 18px;
  568. color: #4d6add;
  569. }
  570. .userInfoLeft {
  571. width: 76px;
  572. }
  573. .relationClass {
  574. padding: 0;
  575. /deep/ .van-field__button button {
  576. background-color: #4d6add;
  577. color: #fff;
  578. padding: 0 0.5em;
  579. margin-left: 10px;
  580. }
  581. }
  582. }
  583. }
  584. .lineBox {
  585. width: 100%;
  586. height: 15px;
  587. background-color: #f6f7fc;
  588. }
  589. .commonOperBox {
  590. width: 100%;
  591. background: #fff;
  592. .operListBox {
  593. margin-top: 20px;
  594. .taskListRow {
  595. width: 100%;
  596. height: 53px;
  597. flex-wrap: wrap;
  598. .taskIcon {
  599. width: 13%;
  600. height: 100%;
  601. position: relative;
  602. &.taskMessageIcon::after {
  603. content: "";
  604. position: absolute;
  605. background: #fff url("../assets/user/taskMessageIcon.png") top
  606. center no-repeat;
  607. background-size: 100%;
  608. width: 0.6rem;
  609. height: 0.6rem;
  610. right: 0.15rem;
  611. top: 0.4rem;
  612. }
  613. &.joinPayMchIcon::after {
  614. content: "";
  615. position: absolute;
  616. background: #fff url("../assets/user/joinPayMchIcon.png") top center
  617. no-repeat;
  618. background-size: 100%;
  619. width: 0.6rem;
  620. height: 0.6rem;
  621. right: 0.15rem;
  622. top: 0.4rem;
  623. }
  624. &.shandeMchIcon::after {
  625. content: "";
  626. position: absolute;
  627. background: #fff url("../assets/user/shandeMchIcon.png") top center
  628. no-repeat;
  629. background-size: 100%;
  630. width: 0.6rem;
  631. height: 0.6rem;
  632. right: 0.15rem;
  633. top: 0.4rem;
  634. }
  635. &.changePasswordIcon::after {
  636. content: "";
  637. position: absolute;
  638. background: #fff url("../assets/user/changePasswordIcon.png") top
  639. center no-repeat;
  640. background-size: 100%;
  641. width: 0.6rem;
  642. height: 0.6rem;
  643. right: 0.15rem;
  644. top: 0.4rem;
  645. }
  646. &.selfPayIcon::after {
  647. content: "";
  648. position: absolute;
  649. background: #fff url("../assets/user/self.png") top center no-repeat;
  650. background-size: 100%;
  651. width: 0.6rem;
  652. height: 0.6rem;
  653. right: 0.15rem;
  654. top: 0.4rem;
  655. }
  656. &.loginOutIcon::after {
  657. content: "";
  658. position: absolute;
  659. background: #fff url("../assets/user/loginOut.png") top center
  660. no-repeat;
  661. background-size: 100%;
  662. width: 0.6rem;
  663. height: 0.6rem;
  664. right: 0.15rem;
  665. top: 0.4rem;
  666. }
  667. }
  668. .taskRight {
  669. width: 87%;
  670. height: 100%;
  671. position: relative;
  672. border-bottom: 1px solid #e7eaf7;
  673. &::after {
  674. content: "";
  675. position: absolute;
  676. width: 6px;
  677. height: 12px;
  678. background: url(https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPng51122feddbc4a9b3e0b055ed6181d290e60825befaa5c777794f1412ff817e57)
  679. top center no-repeat;
  680. background-size: 100%;
  681. right: 0.55rem;
  682. top: 0.5rem;
  683. }
  684. .taskTitle {
  685. line-height: 53px;
  686. }
  687. }
  688. }
  689. }
  690. }
  691. }
  692. </style>