user.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  1. <template>
  2. <div class="userPage flex-col">
  3. <div class="userPageBox">
  4. <s-header :name="sys ? sys.title : $t('user.personalCenter')" :noback="true" :isFixed="false"></s-header>
  5. <div class="userBaseBox">
  6. <div class="baseRow flex-row justify-between">
  7. <div class="group2 flex-col"></div>
  8. <span class="baseText">{{ $t("user.essentialInformation") }}</span>
  9. </div>
  10. <div class="userMessage flex-row justify-between">
  11. <div class="userId">
  12. <p class="userText">{{ accountDetail.managerId }}</p>
  13. <p class="userText">{{ $t("user.systemId") }}</p>
  14. </div>
  15. <div class="userLine"></div>
  16. <div class="userId">
  17. <p class="userText">{{ accountDetail.username }}</p>
  18. <p class="userText">{{ $t("user.myAccount") }}</p>
  19. </div>
  20. <div class="userLine"></div>
  21. <div class="userId">
  22. <p class="userText">{{ accountDetail.name }}</p>
  23. <p class="userText">{{ $t("user.myName") }}</p>
  24. </div>
  25. </div>
  26. <div class="userInfoBox">
  27. <!-- 地区 -->
  28. <div v-if="isInland && user.type != '0'">
  29. <div v-if="!areaShow" class="userInfo l-flex-between">
  30. <span class="userInfoLeft">{{ $t("user.region") }}: </span>
  31. <div class="cust_vantBorder">
  32. <div class="filedInpPad">
  33. <van-field @click-input="fieldValueInpClk" readonly clearable v-model="fieldValue"
  34. :placeholder="$t('user.regionPlace')">
  35. <template #right-icon>
  36. <div class="l-flex-RC">
  37. <van-icon v-if="fieldValue" @click="
  38. fieldValue = '';
  39. accountDetail.areaId = '';
  40. " class="o-mr-6" name="clear" />
  41. <van-icon @click="fieldValueInpClk" name="arrow-down" />
  42. </div>
  43. </template>
  44. </van-field>
  45. </div>
  46. </div>
  47. <van-icon name="edit" class="editIcon" @click="editClk(4)" />
  48. </div>
  49. <div v-else class="userInfo l-flex-between">
  50. <span class="userInfoLeft">{{ $t("user.region") }}: </span>
  51. <span>{{ fieldValue }}</span>
  52. <van-icon name="edit" class="editIcon" @click="editClk(4)" />
  53. </div>
  54. </div>
  55. <!-- 邮箱 -->
  56. <div v-if="user.type != '0'">
  57. <div v-if="!mailboxShow" class="userInfo l-flex-between">
  58. <span class="userInfoLeft">{{ $t("user.mailbox") }}: </span>
  59. <div>
  60. <van-field class="relationClass" v-model="cofficentForm.mailBox" :placeholder="$t('user.mailboxPlace')">
  61. <template #button>
  62. <van-button type="primary" @click="mailboxChg(cofficentForm.mailBox, 2)">{{ $t("user.confirmLog") }}
  63. </van-button>
  64. </template>
  65. </van-field>
  66. </div>
  67. <van-icon name="edit" class="editIcon" @click="editClk(2)" />
  68. </div>
  69. <div v-else class="userInfo l-flex-between">
  70. <span class="userInfoLeft">{{ $t("user.mailbox") }}: </span>
  71. <span>{{ accountDetail.email }}</span>
  72. <van-icon name="edit" class="editIcon" @click="editClk(2)" />
  73. </div>
  74. </div>
  75. <!-- 上级账号 -->
  76. <div v-if="isInland && user.type == '2'">
  77. <div v-if="haveRelation" class="userInfo l-flex-between">
  78. <span class="userInfoLeft">{{ $t("user.superiorAccount") }}: </span>
  79. <span>{{ relationAdminName }}</span>
  80. </div>
  81. </div>
  82. <!-- 手机号码 -->
  83. <div v-if="user.type != '0'">
  84. <div v-if="!phoneNumberShow" class="userInfo l-flex-between">
  85. <span class="userInfoLeft">{{ $t("user.phoneNumber") }}: </span>
  86. <div>
  87. <van-field class="relationClass" v-model="cofficentForm.phone" :placeholder="$t('user.phoneNumberPlace')">
  88. <template #button>
  89. <van-button type="primary" @click="mailboxChg(cofficentForm.phone, 3)">{{ $t("user.confirmLog") }}
  90. </van-button>
  91. </template>
  92. </van-field>
  93. </div>
  94. <van-icon name="edit" class="editIcon" @click="editClk(3)" />
  95. </div>
  96. <div v-else class="userInfo l-flex-between">
  97. <span class="userInfoLeft">{{ $t("user.phoneNumber") }}: </span>
  98. <span>{{ accountDetail.phone }}</span>
  99. <van-icon name="edit" class="editIcon" @click="editClk(3)" />
  100. </div>
  101. </div>
  102. <!-- 关联上级 -->
  103. <!-- <div v-if="isInland && user.type == '2'">
  104. <div v-if="!relationType" class="userInfo l-flex-between">
  105. <span class="userInfoLeft">{{ $t("user.associateParent") }}: </span>
  106. <div >
  107. <van-field class="relationClass" v-model="cofficentForm.associateParent"
  108. :placeholder="$t('user.associateParentPlace')">
  109. <template #button>
  110. <van-button type="primary" @click="mailboxChg(cofficentForm.associateParent, 1)">{{
  111. $t("user.confirmLog") }}
  112. </van-button>
  113. </template>
  114. </van-field>
  115. </div>
  116. <van-icon name="edit" class="editIcon" @click="editClk(1)" />
  117. </div>
  118. <div v-else class="userInfo l-flex-between">
  119. <span class="userInfoLeft">{{ $t("user.associateParent") }}: </span>
  120. <span>{{ relationAdminName }}</span>
  121. <van-icon name="edit" class="editIcon" @click="editClk(1)" />
  122. </div>
  123. </div> -->
  124. <!-- 自定义货币符号 -->
  125. <div v-if="!symbolShow" class="userInfo l-flex-between">
  126. <span class="userInfoLeft">{{ $t("user.currencySymbol") }}: </span>
  127. <div>
  128. <van-field class="relationClass" v-model="cofficentForm.currencySymbol"
  129. :placeholder="$t('user.currencySymbolPlace')">
  130. <template #button>
  131. <van-button type="primary" @click="mailboxChg(cofficentForm.currencySymbol, 5)">{{
  132. $t("user.confirmLog") }}
  133. </van-button>
  134. </template>
  135. </van-field>
  136. </div>
  137. <van-icon name="edit" class="editIcon" @click="editClk(5)" />
  138. </div>
  139. <div v-else class="userInfo l-flex-between">
  140. <span class="userInfoLeft">{{ $t("user.currencySymbol") }}: </span>
  141. <span>{{ accountDetail.currencySymbol }}</span>
  142. <van-icon name="edit" class="editIcon" @click="editClk(5)" />
  143. </div>
  144. <!-- 切换支付平台 -->
  145. <div v-if="chaSzPayShow" class="userInfo l-flex-between">
  146. <span class="userInfoLeft">{{ $t("user.szPayType") }}: </span>
  147. <div class="cust_vantBorder o-pl-15">
  148. <van-switch :model-value="sunzeePay" active-color="#0090fa" inactive-color="#30c25c" size="21px"
  149. @update:model-value="changeSunzeePay" />
  150. </div>
  151. <span class="o-pl-50">{{ $t("user.currentChoose") }}: {{ sunzeePay ? "汇付" : "汇聚" }}</span>
  152. </div>
  153. <div v-if="chaScPayShow" class="userInfo l-flex-between">
  154. <span class="userInfoLeft">{{ $t("user.scPayType") }}: </span>
  155. <div class="cust_vantBorder o-pl-15">
  156. <van-switch :model-value="sevencloudPay" active-color="#0090fa" inactive-color="#30c25c" size="21px"
  157. @update:model-value="changeSevenCloudPay" />
  158. </div>
  159. <span class="o-pl-50">{{ $t("user.currentChoose") }}: {{ sevencloudPay ? "汇付" : "汇聚" }}</span>
  160. </div>
  161. </div>
  162. </div>
  163. <div class="lineBox"></div>
  164. <div class="commonOperBox">
  165. <!-- 常用操作 -->
  166. <div class="baseRow flex-row justify-between">
  167. <div class="group2 flex-col"></div>
  168. <span class="baseText">{{ $t("user.commonOperations") }}</span>
  169. </div>
  170. <div class="operListBox">
  171. <!-- 任务消息 -->
  172. <div v-if="roleCheck()" class="taskListRow flex-col" @click="pushPageList('/taskMessage')">
  173. <div class="taskIcon taskMessageIcon"></div>
  174. <div class="taskRight">
  175. <div class="taskTitle">{{ $t("user.taskMessage") }}</div>
  176. </div>
  177. </div>
  178. <!-- 提现帐号 -->
  179. <div v-if="isInland && user.type != '0'" class="taskListRow flex-col" @click="pushPageList('/settlement')">
  180. <div class="taskIcon joinPayMchIcon"></div>
  181. <div class="taskRight">
  182. <div class="taskTitle">{{ $t("user.settlementAccount") }}</div>
  183. </div>
  184. </div>
  185. <!-- 提现帐号 -->
  186. <!-- <div v-if="isInland" class="taskListRow flex-col" @click="pushPageList('/joinpayMch')">
  187. <div class="taskIcon joinPayMchIcon"></div>
  188. <div class="taskRight">
  189. <div class="taskTitle">{{ $t("user.withdrawalAccountNo") }}</div>
  190. </div>
  191. </div> -->
  192. <!-- Airwallex 钱包 -->
  193. <!-- <div v-if="isAbroad && user.companyType != '1'" class="taskListRow flex-col"
  194. @click="pushPageList('/airwallex')">
  195. <div class="taskIcon airwallexIcon"></div>
  196. <div class="taskRight">
  197. <div class="taskTitle">{{ $t("user.airwallex") }}</div>
  198. </div>
  199. </div> -->
  200. <!-- 公告编辑 -->
  201. <div v-if="user.type == '0'" class="taskListRow flex-col" @click="pushPageList('/announcement')">
  202. <div class="taskIcon announcementIcon"></div>
  203. <div class="taskRight">
  204. <div class="taskTitle">
  205. {{ $t("user.announcement") }}
  206. </div>
  207. </div>
  208. </div>
  209. <!-- <div class="taskListRow flex-col" @click="pushPageList('/shandeMch')">
  210. <div class="taskIcon shandeMchIcon"></div>
  211. <div class="taskRight">
  212. <div class="taskTitle">
  213. {{ $t("user.standbyWithdrawalAccountNo") }}
  214. </div>
  215. </div>
  216. </div>-->
  217. <!-- 绑定微信 -->
  218. <div v-if="isInWeChat" class="taskListRow flex-col" @click="pushPageList('/bindWechat')">
  219. <!-- <div class="taskListRow flex-col" @click="pushPageList('/bindWechat')">-->
  220. <div class="taskIcon bindWechatIcon"></div>
  221. <div class="taskRight">
  222. <div class="taskTitle">
  223. {{ $t("user.bindWechat") }}
  224. </div>
  225. </div>
  226. </div>
  227. <!-- 定位修改 -->
  228. <div v-if="user.type <= '1'" class="taskListRow flex-col" @click="pushPageList('/modifyLoc')">
  229. <!-- <div class="taskListRow flex-col" @click="pushPageList('/modifyLoc')"> -->
  230. <div class="taskIcon modifyLocIcon"></div>
  231. <div class="taskRight">
  232. <div class="taskTitle">
  233. {{ $t("user.modifyLoc") }}
  234. </div>
  235. </div>
  236. </div>
  237. <!-- 数据同步 -->
  238. <div v-if="user.type == '0'" class="taskListRow flex-col" @click="pushPageList('/syncOldData')">
  239. <!-- <div class="taskListRow flex-col" @click="pushPageList('/syncOldData')"> -->
  240. <div class="taskIcon syncOldDataIcon"></div>
  241. <div class="taskRight">
  242. <div class="taskTitle">
  243. {{ $t("user.syncOldData") }}
  244. </div>
  245. </div>
  246. </div>
  247. <!-- 修改密码 -->
  248. <div class="taskListRow flex-col" @click="pushPageList('/changepassword')">
  249. <div class="taskIcon changePasswordIcon"></div>
  250. <div class="taskRight">
  251. <div class="taskTitle">{{ $t("user.changePassword") }}</div>
  252. </div>
  253. </div>
  254. <!-- 意见反馈 -->
  255. <!-- <div v-if="user.type > 1" class="taskListRow flex-col" @click="pushPageList('/feedback')"> -->
  256. <div v-if="user.id == 31 || user.id == 34" class="taskListRow flex-col" @click="pushPageList('/feedback')">
  257. <div class="taskIcon feedbackIcon"></div>
  258. <div class="taskRight">
  259. <div class="taskTitle">{{ $t("user.feedback") }}</div>
  260. </div>
  261. </div>
  262. <!-- 自动充值 -->
  263. <!-- <div v-if="isInland" class="taskListRow flex-col" @click="operUnipay()">
  264. <div class="taskIcon selfPayIcon"></div>
  265. <div class="taskRight">
  266. <div class="taskTitle">{{ $t("user.selfRecharging") }}</div>
  267. </div>
  268. </div> -->
  269. <div class="taskListRow flex-col" @click="onperExitSys()">
  270. <div class="taskIcon loginOutIcon"></div>
  271. <div class="taskRight">
  272. <div class="taskTitle">{{ $t("user.logOut") }}</div>
  273. </div>
  274. </div>
  275. </div>
  276. </div>
  277. </div>
  278. <!-- <nav-bar></nav-bar> -->
  279. <!-- 退出登录弹窗 -->
  280. <kDialog :dialogTitle="$t('user.logOutTips')" :cancelBtnTxt="$t('user.cancelLog')"
  281. :confirmBtnTxt="$t('user.confirmLog')" ref="kDialogRef" :dialogContent="$t('user.logOutContent')"
  282. @confirmclk="confirmClk">
  283. </kDialog>
  284. <!-- 地区弹窗 -->
  285. <kCascader @getareaname="getAreaName" :selectId="accountDetail.areaId" @areapopfinish="areaPopFinish"
  286. ref="kCascaderRef"></kCascader>
  287. </div>
  288. </template>
  289. <script>
  290. // 导入地区弹窗
  291. import kCascader from "@/components/commom/kCascader/index.vue";
  292. // 导入接口
  293. import { getAdmin } from "@/service/merchantManage";
  294. import { updateAdmin } from "@/service/merchantManage";
  295. // 引入弹窗
  296. import kDialog from "@/components/commom/kDialog/index.vue";
  297. import { onMounted, reactive, ref } from "vue";
  298. import sHeader from "@/components/SimpleHeader";
  299. // import navBar from "@/components/NavBar";
  300. import {
  301. getLoginUser,
  302. $M_EmailAvailable,
  303. $M_PhoneTest,
  304. } from "@/common/js/utils";
  305. import { useRouter } from "vue-router";
  306. import { tAdminGetRelation, updatePayPlatform } from "@/service/user";
  307. // import { tAdminGetRelation, tAdminSetRelationAdmin, updatePayPlatform } from "@/service/user";
  308. import { showFailToast, showToast, showSuccessToast, showConfirmDialog } from 'vant';
  309. import { useI18n } from "vue-i18n";
  310. import { styleUrl } from "../common/js/utils";
  311. export default {
  312. components: { sHeader, kDialog, kCascader },
  313. setup() {
  314. // 引入语言
  315. const { t } = useI18n();
  316. // 账户信息
  317. const accountDetail = ref({});
  318. // 控制地区显示隐藏
  319. const areaShow = ref(true);
  320. // 控制手机显示隐藏
  321. const phoneNumberShow = ref(true);
  322. // 控制邮箱显示隐藏
  323. const mailboxShow = ref(true);
  324. // 控制货币显示隐藏 货币符号,默认“¥”
  325. const symbolShow = ref(true);
  326. // 控制切换支付平台按钮显示隐藏
  327. const chaSzPayShow = ref(false);
  328. const chaScPayShow = ref(false);
  329. const sunzeePay = ref(false);
  330. const sevencloudPay = ref(false);
  331. const user = getLoginUser();
  332. const router = useRouter();
  333. const relationAdminName = ref("");
  334. const relationType = ref(true);
  335. const sys = ref(null);
  336. // 修改的个人信息
  337. const cofficentForm = reactive({
  338. associateParent: relationAdminName.value,
  339. mailBox: accountDetail.value.email,
  340. phone: accountDetail.value.phone,
  341. area: "",
  342. currencySymbol: accountDetail.value.currencySymbol,
  343. });
  344. //
  345. const params = reactive({
  346. id: '', // 用户ID
  347. payPlatform: '', //支付平台
  348. });
  349. // 点击修改图标
  350. const editClk = (idx) => {
  351. switch (idx) {
  352. case 1:
  353. cofficentForm.associateParent = relationAdminName.value;
  354. relationType.value = !relationType.value;
  355. mailboxShow.value = true;
  356. phoneNumberShow.value = true;
  357. areaShow.value = true;
  358. symbolShow.value = true;
  359. break;
  360. case 2:
  361. cofficentForm.mailBox = accountDetail.value.email;
  362. relationType.value = true;
  363. mailboxShow.value = !mailboxShow.value;
  364. phoneNumberShow.value = true;
  365. areaShow.value = true;
  366. symbolShow.value = true;
  367. break;
  368. case 3:
  369. cofficentForm.phone = accountDetail.value.phone;
  370. relationType.value = true;
  371. mailboxShow.value = true;
  372. phoneNumberShow.value = !phoneNumberShow.value;
  373. areaShow.value = true;
  374. symbolShow.value = true;
  375. break;
  376. case 4:
  377. cofficentForm.area = accountDetail.value.area;
  378. relationType.value = true;
  379. mailboxShow.value = true;
  380. phoneNumberShow.value = true;
  381. areaShow.value = !areaShow.value;
  382. symbolShow.value = true;
  383. break;
  384. case 5:
  385. cofficentForm.currencySymbol = accountDetail.value.currencySymbol;
  386. relationType.value = true;
  387. mailboxShow.value = true;
  388. phoneNumberShow.value = true;
  389. areaShow.value = true;
  390. symbolShow.value = !symbolShow.value;
  391. break;
  392. }
  393. };
  394. // 点击邮箱的确定按钮
  395. const mailboxChg = async (e, idx) => {
  396. switch (idx) {
  397. // case 1:
  398. // if (!e) {
  399. // showToast(t("user.associateParentPlace"));
  400. // } else {
  401. // const { data } = await tAdminSetRelationAdmin({
  402. // adminId: user.id,
  403. // username: e,
  404. // });
  405. // relationType.value = true;
  406. // if (data.code === "00000") {
  407. // showToast(data.message);
  408. // setTimeout(() => {
  409. // gettAdminGetRelation();
  410. // }, 500);
  411. // }
  412. // }
  413. // break;
  414. case 2:
  415. if (!e) {
  416. showToast(t("user.mailboxPlace"));
  417. } else if (!$M_EmailAvailable(e)) {
  418. showToast(t("user.corrEmailPlace"));
  419. } else {
  420. const params = {
  421. id: user.id,
  422. email: e,
  423. };
  424. const { data } = await updateAdmin(params);
  425. mailboxShow.value = true;
  426. if (data.code === "00000") {
  427. showToast(data.message);
  428. setTimeout(() => {
  429. getAcccountDetail();
  430. }, 500);
  431. }
  432. }
  433. break;
  434. case 3:
  435. if (!e) {
  436. showToast(t("user.phoneNumberPlace"));
  437. } else if (!$M_PhoneTest(e)) {
  438. showToast(t("user.corrPhonePlace"));
  439. } else {
  440. const params = {
  441. id: user.id,
  442. phone: e,
  443. };
  444. const { data } = await updateAdmin(params);
  445. phoneNumberShow.value = true;
  446. if (data.code === "00000") {
  447. showToast(data.message);
  448. setTimeout(() => {
  449. getAcccountDetail();
  450. }, 500);
  451. }
  452. }
  453. break;
  454. case 5:
  455. if (!e) {
  456. showToast(t("user.currencySymbolPlace"));
  457. } else {
  458. const params = {
  459. id: user.id,
  460. currencySymbol: e,
  461. };
  462. const { data } = await updateAdmin(params);
  463. symbolShow.value = true;
  464. if (data.code === "00000") {
  465. showToast(data.message);
  466. // 更新本地存储缓存中的currencySymbol的值
  467. user.currencySymbol = e; // 将新的currencySymbol的值赋值给user
  468. localStorage.setItem("loginUser", JSON.stringify(user));
  469. setTimeout(() => {
  470. getAcccountDetail();
  471. }, 500);
  472. }
  473. }
  474. break;
  475. }
  476. };
  477. // 获取账户详情
  478. const getAcccountDetail = () => {
  479. getAdmin({ id: user.id }).then((res) => {
  480. accountDetail.value = res.data.data;
  481. // 查询地址回显
  482. kCascaderRef.value.init(accountDetail.value.areaId);
  483. });
  484. };
  485. // 获取申泽支付平台
  486. const getSunzeeDetail = () => {
  487. getAdmin({ id: 2738 }).then((res) => {
  488. // sunzeePay.value = res.data.data.payPlatform;
  489. if (res.data.data.payPlatform == '1') {
  490. sunzeePay.value = true;
  491. }
  492. console.log("sunzeePay", sunzeePay.value)
  493. });
  494. };
  495. // 获取七云支付平台
  496. const getSevenCloudDetail = () => {
  497. getAdmin({ id: 2739 }).then((res) => {
  498. // sevencloudPay.value = res.data.data.payPlatform;
  499. if (res.data.data.payPlatform == '1') {
  500. sevencloudPay.value = true;
  501. }
  502. console.log("sevencloudPay", sevencloudPay.value)
  503. });
  504. };
  505. // 退出登录弹窗
  506. const kDialogRef = ref(null);
  507. // 点击右侧按钮
  508. const confirmClk = () => {
  509. // 获取缓存的语言
  510. const savedCredentials = localStorage.getItem('savedCredentials');
  511. const curLang = localStorage.getItem("curLang");
  512. // 清空缓存
  513. localStorage.clear();
  514. localStorage.setItem("curLang", curLang);
  515. if (savedCredentials) {
  516. localStorage.setItem('savedCredentials', savedCredentials);
  517. }
  518. if (sys.value) {
  519. setTimeout(() => {
  520. router.push({
  521. path: "login",
  522. query: { relation_admin_id: sys.value.relationAdminId },
  523. });
  524. }, 200);
  525. } else {
  526. setTimeout(() => {
  527. router.push({ path: "login" });
  528. }, 200);
  529. }
  530. };
  531. //切换申泽支付平台
  532. const changeSunzeePay = (value) => {
  533. showConfirmDialog({
  534. title: t('user.tips'),
  535. message: t('user.changeTips'),
  536. }).then(() => {
  537. // checked.value = newValue;
  538. console.log(value);
  539. params.id = 2738;
  540. if (value) {
  541. params.payPlatform = '1';
  542. } else {
  543. params.payPlatform = '0';
  544. }
  545. const { data } = updatePayPlatform(params);
  546. if (data.code) {
  547. showSuccessToast(t('user.changeSuccess'));
  548. sunzeePay.value = value;
  549. } else {
  550. showFailToast(data.message);
  551. }
  552. }).catch((error) => {
  553. console.error(error);
  554. })
  555. }
  556. //切换七云支付平台
  557. const changeSevenCloudPay = (value) => {
  558. showConfirmDialog({
  559. title: t('user.tips'),
  560. message: t('user.changeTips'),
  561. }).then(() => {
  562. // checked.value = newValue;
  563. console.log(value);
  564. params.id = 2739;
  565. if (value) {
  566. params.payPlatform = '1';
  567. } else {
  568. params.payPlatform = '0';
  569. }
  570. const { data } = updatePayPlatform(params);
  571. if (data.code) {
  572. showSuccessToast(t('user.changeSuccess'));
  573. sunzeePay.value = value;
  574. } else {
  575. showFailToast(data.message);
  576. }
  577. }).catch((error) => {
  578. console.error(error);
  579. })
  580. }
  581. // 初始化页面获取列表
  582. onMounted(async () => {
  583. // 加载样式
  584. styleUrl('user');
  585. if (localStorage.getItem("loginSys")) {
  586. const loginSysString = localStorage.getItem("loginSys");
  587. sys.value = JSON.parse(loginSysString);
  588. }
  589. // 获取关联上级
  590. gettAdminGetRelation();
  591. // 获取账户
  592. getAcccountDetail();
  593. if (user.id == 1) {
  594. chaSzPayShow.value = true;
  595. chaScPayShow.value = true;
  596. getSunzeeDetail();
  597. getSevenCloudDetail();
  598. }
  599. // else if (user.id == 2738) {
  600. // chaSzPayShow.value = true;
  601. // getSunzeeDetail();
  602. // } else if (user.id == 2739) {
  603. // chaScPayShow.value = true;
  604. // getSevenCloudDetail();
  605. // }
  606. });
  607. const gettAdminGetRelation = async () => {
  608. const { data } = await tAdminGetRelation({
  609. relationAdminId: user.relationAdminId,
  610. });
  611. if (typeof data === "string") {
  612. relationAdminName.value = data;
  613. }
  614. };
  615. const operUnipay = () => {
  616. router.push({ path: "uniPay" });
  617. };
  618. const onperExitSys = () => {
  619. kDialogRef.value.openDialog();
  620. };
  621. const pushPageList = (url) => {
  622. router.push({ path: url });
  623. };
  624. const roleCheck = () => {
  625. if (user.isAdmined) {
  626. return true;
  627. } else {
  628. const menuList = user.menuCodeList.filter((item) => item === "M6");
  629. return menuList.length > 0;
  630. }
  631. };
  632. // 地区弹窗
  633. const fieldValue = ref("");
  634. const kCascaderRef = ref(null);
  635. // 点击地区输入框
  636. const fieldValueInpClk = () => {
  637. kCascaderRef.value.openPop();
  638. };
  639. // 选择地区完成
  640. const areaPopFinish = async (e) => {
  641. console.log("e", e);
  642. fieldValue.value = e.selectName;
  643. accountDetail.value.areaId = e.selectId;
  644. const params = {
  645. id: user.id,
  646. areaId: e.selectId,
  647. };
  648. const { data } = await updateAdmin(params);
  649. areaShow.value = true;
  650. if (data.code === "00000") {
  651. showToast(data.message);
  652. setTimeout(() => {
  653. getAcccountDetail();
  654. }, 500);
  655. }
  656. };
  657. const isInWeChat = ref(false);
  658. const checkInWechat = () => {
  659. const ua = window.navigator.userAgent.toLowerCase();
  660. // 如果是在微信中打开
  661. if (/MicroMessenger/i.test(ua)) {
  662. isInWeChat.value = true;
  663. }
  664. };
  665. // 是否内陆或海外
  666. const isInland = ref(true);
  667. const isAbroad = ref(false);
  668. // 是否有上级账号
  669. const haveRelation = ref(false);
  670. const haveRelationCheck = () => {
  671. if (user.relationAdminId !== null) {
  672. haveRelation.value = true;
  673. }
  674. }
  675. // const checkIsAbroad = async () => {
  676. // try {
  677. // const { data } = await getIfForeign(user.id);
  678. // console.log("isAbroad >>> ", data);
  679. // if (data.data === '1') {
  680. // // TODO: 这里先把isAbroad设置为fasle,等开发完成再改成true;
  681. // isAbroad.value = false;
  682. // isInland.value = false;
  683. // }
  684. // } catch (error) {
  685. // console.error(error);
  686. // }
  687. // };
  688. const checkIsAbroad = async () => {
  689. try {
  690. const userInfo = localStorage.getItem("loginUser");
  691. const userIfForeign = JSON.parse(userInfo);
  692. // console.log("用户的海内外信息" + userIfForeign.ifForeign);
  693. // console.log("看下user是什么***" + user.menuCodeList);
  694. if (userIfForeign.ifForeign === '1') {
  695. isAbroad.value = true;
  696. isInland.value = false;
  697. }
  698. } catch (error) {
  699. console.error(error);
  700. }
  701. };
  702. onMounted(() => {
  703. checkInWechat();
  704. checkIsAbroad();
  705. haveRelationCheck();
  706. })
  707. // 获取回显的值
  708. const getAreaName = (e) => {
  709. fieldValue.value = e;
  710. };
  711. return {
  712. user,
  713. operUnipay,
  714. onperExitSys,
  715. relationAdminName,
  716. relationType,
  717. pushPageList,
  718. roleCheck,
  719. sys,
  720. kDialogRef,
  721. confirmClk,
  722. mailboxShow,
  723. mailboxChg,
  724. phoneNumberShow,
  725. editClk,
  726. cofficentForm,
  727. params,
  728. areaShow,
  729. accountDetail,
  730. fieldValue,
  731. kCascaderRef,
  732. fieldValueInpClk,
  733. areaPopFinish,
  734. isInWeChat,
  735. getAreaName,
  736. isAbroad,
  737. haveRelation,
  738. checkIsAbroad,
  739. isInland,
  740. symbolShow,
  741. chaSzPayShow,
  742. chaScPayShow,
  743. sunzeePay,
  744. sevencloudPay,
  745. changeSunzeePay,
  746. changeSevenCloudPay,
  747. };
  748. }
  749. };
  750. </script>
  751. <style lang="less" scoped>
  752. @import "../common/style/mixin";
  753. @import "../styles/user/index";
  754. </style>