上传头像问题
Showing
6 changed files
with
273 additions
and
150 deletions
| ... | @@ -141,14 +141,14 @@ export function deptTreeSelect(params) { | ... | @@ -141,14 +141,14 @@ export function deptTreeSelect(params) { |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | // 注册选择协会树 | 143 | // 注册选择协会树 |
| 144 | export function certifiedDeptTreeRegister(params, options = {}) { | 144 | export function certifiedDeptTreeRegister(params, options = {}) { |
| 145 | return request({ | 145 | return request({ |
| 146 | ...options, | 146 | ...options, |
| 147 | url: '/system/user/certifiedDeptTreeWithNoDaoguan2', | 147 | url: '/system/user/certifiedDeptTreeWithNoDaoguan2', |
| 148 | method: 'get', | 148 | method: 'get', |
| 149 | params | 149 | params |
| 150 | }) | 150 | }) |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | const setIdToString = (list) => { | 153 | const setIdToString = (list) => { |
| 154 | for (var l of list) { | 154 | for (var l of list) { |
| ... | @@ -209,14 +209,14 @@ export function reader(query) { | ... | @@ -209,14 +209,14 @@ export function reader(query) { |
| 209 | }) | 209 | }) |
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | export function regionsList(params, options = {}) { | 212 | export function regionsList(params, options = {}) { |
| 213 | return request({ | 213 | return request({ |
| 214 | ...options, | 214 | ...options, |
| 215 | url: '/common/region/regionsList', | 215 | url: '/common/region/regionsList', |
| 216 | method: 'get', | 216 | method: 'get', |
| 217 | params | 217 | params |
| 218 | }) | 218 | }) |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | // 添加会员自动录入 上传图片 | 221 | // 添加会员自动录入 上传图片 |
| 222 | export function carUrl(data, type) { | 222 | export function carUrl(data, type) { |
| ... | @@ -323,7 +323,7 @@ export function uploadImgCorpPhoto(tempFilePath) { | ... | @@ -323,7 +323,7 @@ export function uploadImgCorpPhoto(tempFilePath) { |
| 323 | title: '加载中' | 323 | title: '加载中' |
| 324 | }); | 324 | }); |
| 325 | return uni.uploadFile({ | 325 | return uni.uploadFile({ |
| 326 | url: config.baseUrl_api + '/upload/uploadImgToLocalServerCaiJian', | 326 | url: config.baseUrl_api + '/fileServer/uploadImgToMinioCaiJian', |
| 327 | header: { | 327 | header: { |
| 328 | 'Authorization': uni.getStorageSync('token'), | 328 | 'Authorization': uni.getStorageSync('token'), |
| 329 | }, | 329 | }, |
| ... | @@ -337,18 +337,26 @@ export function uploadImgCorpPhoto(tempFilePath) { | ... | @@ -337,18 +337,26 @@ export function uploadImgCorpPhoto(tempFilePath) { |
| 337 | }); | 337 | }); |
| 338 | } | 338 | } |
| 339 | 339 | ||
| 340 | export function getInfo(perId) { | 340 | export function getInfo(perId) { |
| 341 | return request({ | 341 | return request({ |
| 342 | url: '/person/info/' + perId, | 342 | url: '/person/info/' + perId, |
| 343 | method: 'get' | 343 | method: 'get' |
| 344 | }) | 344 | }) |
| 345 | } | 345 | } |
| 346 | 346 | ||
| 347 | // 查询个人会员信息列表 | 347 | export function updateInfo(data) { |
| 348 | export function selectPageList(query) { | 348 | return request({ |
| 349 | return request({ | 349 | url: '/person/info', |
| 350 | url: '/person/info/selectPageList', | 350 | method: 'put', |
| 351 | method: 'get', | 351 | params: data |
| 352 | }) | ||
| 353 | } | ||
| 354 | |||
| 355 | // 查询个人会员信息列表 | ||
| 356 | export function selectPageList(query) { | ||
| 357 | return request({ | ||
| 358 | url: '/person/info/selectPageList', | ||
| 359 | method: 'get', | ||
| 352 | params: query | 360 | params: query |
| 353 | }) | 361 | }) |
| 354 | } | 362 | } |
| ... | @@ -479,13 +487,13 @@ export function getFeeBillDetail(payId) { | ... | @@ -479,13 +487,13 @@ export function getFeeBillDetail(payId) { |
| 479 | } | 487 | } |
| 480 | 488 | ||
| 481 | // 获取自己团队成员信息 | 489 | // 获取自己团队成员信息 |
| 482 | export function getMyOwnMemberInfo(options = {}) { | 490 | export function getMyOwnMemberInfo(options = {}) { |
| 483 | return request({ | 491 | return request({ |
| 484 | ...options, | 492 | ...options, |
| 485 | url: '/member/info/getMyOwnMemberInfo', | 493 | url: '/member/info/getMyOwnMemberInfo', |
| 486 | method: 'get' | 494 | method: 'get' |
| 487 | }) | 495 | }) |
| 488 | } | 496 | } |
| 489 | 497 | ||
| 490 | // 会员调入 | 498 | // 会员调入 |
| 491 | export function getMobilizelist(params) { | 499 | export function getMobilizelist(params) { |
| ... | @@ -1533,14 +1541,14 @@ export function checkPersonByPersonId(perId) { | ... | @@ -1533,14 +1541,14 @@ export function checkPersonByPersonId(perId) { |
| 1533 | } | 1541 | } |
| 1534 | 1542 | ||
| 1535 | // 获取单位会员优惠政策 | 1543 | // 获取单位会员优惠政策 |
| 1536 | export function canUseDiscount(params, options = {}) { | 1544 | export function canUseDiscount(params, options = {}) { |
| 1537 | return request({ | 1545 | return request({ |
| 1538 | ...options, | 1546 | ...options, |
| 1539 | url: `/system/certifiedNew/canUseDiscount`, | 1547 | url: `/system/certifiedNew/canUseDiscount`, |
| 1540 | method: 'get', | 1548 | method: 'get', |
| 1541 | params | 1549 | params |
| 1542 | }) | 1550 | }) |
| 1543 | } | 1551 | } |
| 1544 | 1552 | ||
| 1545 | // 获取单位会员一年缴费价格 | 1553 | // 获取单位会员一年缴费价格 |
| 1546 | export function getMyMemberCertUnitFee(params) { | 1554 | export function getMyMemberCertUnitFee(params) { |
| ... | @@ -1570,15 +1578,15 @@ export function creditCodeExist(code) { | ... | @@ -1570,15 +1578,15 @@ export function creditCodeExist(code) { |
| 1570 | } | 1578 | } |
| 1571 | 1579 | ||
| 1572 | // 生成单位订单renewYear | 1580 | // 生成单位订单renewYear |
| 1573 | export function certifiedNew(data) { | 1581 | export function certifiedNew(data) { |
| 1574 | let url = '/system/certifiedNew/commit' | 1582 | let url = '/system/certifiedNew/commit' |
| 1575 | const params = [] | 1583 | const params = [] |
| 1576 | if (data.renewYear) params.push(`renewYear=${data.renewYear}`) | 1584 | if (data.renewYear) params.push(`renewYear=${data.renewYear}`) |
| 1577 | params.push(`type=${data.type}`) | 1585 | params.push(`type=${data.type}`) |
| 1578 | if (data.payType) params.push(`payType=${data.payType}`) | 1586 | if (data.payType) params.push(`payType=${data.payType}`) |
| 1579 | if (data.contactPerson) params.push(`contactPerson=${data.contactPerson}`) | 1587 | if (data.contactPerson) params.push(`contactPerson=${data.contactPerson}`) |
| 1580 | if (data.contactTel) params.push(`contactTel=${data.contactTel}`) | 1588 | if (data.contactTel) params.push(`contactTel=${data.contactTel}`) |
| 1581 | if (params.length > 0) { | 1589 | if (params.length > 0) { |
| 1582 | url += '?' + params.join('&') | 1590 | url += '?' + params.join('&') |
| 1583 | } | 1591 | } |
| 1584 | return request({ | 1592 | return request({ |
| ... | @@ -1631,14 +1639,14 @@ export function pcallBack2(orderId) { | ... | @@ -1631,14 +1639,14 @@ export function pcallBack2(orderId) { |
| 1631 | } | 1639 | } |
| 1632 | 1640 | ||
| 1633 | // 优惠政策回显 | 1641 | // 优惠政策回显 |
| 1634 | export function getZtxDiscountPolicy(params, options = {}) { | 1642 | export function getZtxDiscountPolicy(params, options = {}) { |
| 1635 | return request({ | 1643 | return request({ |
| 1636 | ...options, | 1644 | ...options, |
| 1637 | url: '/system/config/getZtxDiscountPolicy', | 1645 | url: '/system/config/getZtxDiscountPolicy', |
| 1638 | method: 'get', | 1646 | method: 'get', |
| 1639 | params | 1647 | params |
| 1640 | }) | 1648 | }) |
| 1641 | } | 1649 | } |
| 1642 | 1650 | ||
| 1643 | // 考官列表 | 1651 | // 考官列表 |
| 1644 | export function listApi(params) { | 1652 | export function listApi(params) { |
| ... | @@ -1690,13 +1698,13 @@ export function commitExamPointApply(params) { | ... | @@ -1690,13 +1698,13 @@ export function commitExamPointApply(params) { |
| 1690 | }) | 1698 | }) |
| 1691 | } | 1699 | } |
| 1692 | 1700 | ||
| 1693 | export function getMyStatus(options = {}) { | 1701 | export function getMyStatus(options = {}) { |
| 1694 | return request({ | 1702 | return request({ |
| 1695 | ...options, | 1703 | ...options, |
| 1696 | url: `/member/examPointApply/getMyStatus`, | 1704 | url: `/member/examPointApply/getMyStatus`, |
| 1697 | method: 'get', | 1705 | method: 'get', |
| 1698 | }) | 1706 | }) |
| 1699 | } | 1707 | } |
| 1700 | 1708 | ||
| 1701 | // 个人会员缴费支付 | 1709 | // 个人会员缴费支付 |
| 1702 | export function goPay(params) { | 1710 | export function goPay(params) { |
| ... | @@ -1789,13 +1797,13 @@ export function createMemberPayRange(data) { | ... | @@ -1789,13 +1797,13 @@ export function createMemberPayRange(data) { |
| 1789 | } | 1797 | } |
| 1790 | 1798 | ||
| 1791 | // 获取最近认证记录 单位会员 | 1799 | // 获取最近认证记录 单位会员 |
| 1792 | export function getMyRecent(options = {}) { | 1800 | export function getMyRecent(options = {}) { |
| 1793 | return request({ | 1801 | return request({ |
| 1794 | ...options, | 1802 | ...options, |
| 1795 | url: '/system/certifiedNew/getMyRecent', | 1803 | url: '/system/certifiedNew/getMyRecent', |
| 1796 | method: 'get' | 1804 | method: 'get' |
| 1797 | }) | 1805 | }) |
| 1798 | } | 1806 | } |
| 1799 | 1807 | ||
| 1800 | 1808 | ||
| 1801 | // 获取最近认证记录 考点 | 1809 | // 获取最近认证记录 考点 | ... | ... |
| 1 | import CryptoJS from 'crypto-js' | 1 | import CryptoJS from 'crypto-js' |
| 2 | import config from '@/config.js' | ||
| 2 | export function szToHz(num) { | 3 | export function szToHz(num) { |
| 3 | const hzArr = ['〇', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十'] | 4 | const hzArr = ['〇', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十'] |
| 4 | return hzArr[parseInt(num)] | 5 | return hzArr[parseInt(num)] |
| ... | @@ -52,3 +53,24 @@ export function reLaunchHomeByRole() { | ... | @@ -52,3 +53,24 @@ export function reLaunchHomeByRole() { |
| 52 | url: isDaoGuanRole() ? '/pages/index/daoGuanPerson' : '/pages/index/home' | 53 | url: isDaoGuanRole() ? '/pages/index/daoGuanPerson' : '/pages/index/home' |
| 53 | }) | 54 | }) |
| 54 | } | 55 | } |
| 56 | |||
| 57 | export function fillImgUrl(url, prefix) { | ||
| 58 | if (!url) return '' | ||
| 59 | const trimmedUrl = String(url).trim() | ||
| 60 | if (!trimmedUrl) return '' | ||
| 61 | if (trimmedUrl.startsWith('msr:')) { | ||
| 62 | return `${trimBaseUrl(config.baseUrl_api)}/fileServer/download?file=${encodeURIComponent(trimmedUrl)}&downFlag=0` | ||
| 63 | } | ||
| 64 | if (/^(data:|https?:\/\/)/.test(trimmedUrl)) { | ||
| 65 | return trimmedUrl | ||
| 66 | } | ||
| 67 | const baseUrl = prefix | ||
| 68 | ? `${trimBaseUrl(config.baseUrl_api)}/${String(prefix).replace(/^\/+|\/+$/g, '')}` | ||
| 69 | : trimBaseUrl(config.baseUrl_api) | ||
| 70 | const path = trimmedUrl.startsWith('/') ? trimmedUrl : `/${trimmedUrl}` | ||
| 71 | return baseUrl + path | ||
| 72 | } | ||
| 73 | |||
| 74 | function trimBaseUrl(url) { | ||
| 75 | return String(url || '').replace(/\/+$/, '') | ||
| 76 | } | ... | ... |
| 1 | // dev | 1 | // dev |
| 2 | // const baseUrl_api = 'http://192.168.1.222:8787' | 2 | const baseUrl_api = 'http://192.168.1.159:8787' |
| 3 | // const baseUrl_api = 'http://47.98.186.233:8787' | 3 | // const baseUrl_api = 'http://47.98.186.233:8787' |
| 4 | const baseUrl_api = 'https://tk001.wxjylt.com/stage-api/' | 4 | // const baseUrl_api = 'https://tk001.wxjylt.com/stage-api/' |
| 5 | const loginImage_api = 'https://tk001.wxjylt.com/stage-api' | 5 | const loginImage_api = 'https://tk001.wxjylt.com/stage-api' |
| 6 | const payUrl = 'https://wxpay.cmbc.com.cn/mobilePlatform/appserver/lcbpPay.do' | 6 | const payUrl = 'https://wxpay.cmbc.com.cn/mobilePlatform/appserver/lcbpPay.do' |
| 7 | 7 | ... | ... |
| ... | @@ -23,12 +23,8 @@ | ... | @@ -23,12 +23,8 @@ |
| 23 | </view> | 23 | </view> |
| 24 | 24 | ||
| 25 | <view class="user-top"> | 25 | <view class="user-top"> |
| 26 | <view class="avatar-wrap" @click="showLogoutConfirm"> | 26 | <view class="avatar-wrap" @click="handleAvatarUpload"> |
| 27 | <!-- <image class="avatar" v-if="perInfo.photo" :src="config.baseUrl_api + perInfo.photo" | 27 | <image :src="avatarUrl" class="avatar" mode="aspectFill"> |
| 28 | mode="aspectFill"> | ||
| 29 | </image> --> | ||
| 30 | <image :src="config.baseUrl_api + '/fs/static/tx@2x.png'" class="avatar" | ||
| 31 | mode="aspectFill"> | ||
| 32 | </image> | 28 | </image> |
| 33 | </view> | 29 | </view> |
| 34 | <!-- <view class="member-id">{{ userInfo?.userName }}</view>--> | 30 | <!-- <view class="member-id">{{ userInfo?.userName }}</view>--> |
| ... | @@ -219,9 +215,13 @@ import to from 'await-to-js' | ... | @@ -219,9 +215,13 @@ import to from 'await-to-js' |
| 219 | import { | 215 | import { |
| 220 | bindUser, | 216 | bindUser, |
| 221 | unbindUser, | 217 | unbindUser, |
| 222 | downStuCertSingle | 218 | downStuCertSingle, |
| 219 | uploadImgCorpPhoto, | ||
| 220 | getInfo, | ||
| 221 | updateInfo | ||
| 223 | } from '@/common/api.js' | 222 | } from '@/common/api.js' |
| 224 | import {onShow} from "@dcloudio/uni-app"; | 223 | import {onShow} from "@dcloudio/uni-app"; |
| 224 | import { fillImgUrl } from '@/common/utils.js' | ||
| 225 | 225 | ||
| 226 | const userStore = useUserStore() | 226 | const userStore = useUserStore() |
| 227 | const userInfo = computed(() => userStore.user ?? {}) | 227 | const userInfo = computed(() => userStore.user ?? {}) |
| ... | @@ -229,6 +229,21 @@ const perInfo = computed(() => userStore.perInfo ?? {}) | ... | @@ -229,6 +229,21 @@ const perInfo = computed(() => userStore.perInfo ?? {}) |
| 229 | console.log(222, userInfo.value) | 229 | console.log(222, userInfo.value) |
| 230 | console.log(333, perInfo.value) | 230 | console.log(333, perInfo.value) |
| 231 | 231 | ||
| 232 | const isValidPhotoValue = (value) => { | ||
| 233 | if (value === undefined || value === null) return false | ||
| 234 | const photo = String(value).trim() | ||
| 235 | return photo !== '' && photo !== 'null' && photo !== 'undefined' | ||
| 236 | } | ||
| 237 | |||
| 238 | const getAvatarPhoto = (info = {}) => { | ||
| 239 | return [info.photo2, info.perPhoto2, info.photo, info.perPhoto].find(isValidPhotoValue) || '' | ||
| 240 | } | ||
| 241 | |||
| 242 | const avatarUrl = computed(() => { | ||
| 243 | const photo = getAvatarPhoto(perInfo.value) | ||
| 244 | return photo ? fillImgUrl(photo) : config.baseUrl_api + '/fs/static/tx@2x.png' | ||
| 245 | }) | ||
| 246 | |||
| 232 | // 是否已绑定学员:绑定非会员时只有姓名,没有会员卡号,也应视为已绑定,避免反复弹绑定框。 | 247 | // 是否已绑定学员:绑定非会员时只有姓名,没有会员卡号,也应视为已绑定,避免反复弹绑定框。 |
| 233 | const isBound = computed(() => { | 248 | const isBound = computed(() => { |
| 234 | const perName = perInfo.value?.perName | 249 | const perName = perInfo.value?.perName |
| ... | @@ -538,6 +553,89 @@ const goToPay = () => { | ... | @@ -538,6 +553,89 @@ const goToPay = () => { |
| 538 | }); | 553 | }); |
| 539 | }; | 554 | }; |
| 540 | 555 | ||
| 556 | const handleAvatarUpload = () => { | ||
| 557 | if (!isBound.value) { | ||
| 558 | uni.showToast({title: '请先绑定学员', icon: 'none'}) | ||
| 559 | return | ||
| 560 | } | ||
| 561 | uni.chooseImage({ | ||
| 562 | count: 1, | ||
| 563 | sizeType: ['compressed'], | ||
| 564 | sourceType: ['album', 'camera'], | ||
| 565 | success: (res) => { | ||
| 566 | const imgUrl = res.tempFilePaths?.[0] | ||
| 567 | if (!imgUrl) { | ||
| 568 | uni.showToast({title: '未获取到图片地址,请重新选择图片', icon: 'none'}) | ||
| 569 | return | ||
| 570 | } | ||
| 571 | if (typeof wx === 'undefined' || typeof wx.cropImage !== 'function') { | ||
| 572 | uploadAvatarPhoto(imgUrl) | ||
| 573 | return | ||
| 574 | } | ||
| 575 | wx.cropImage({ | ||
| 576 | src: imgUrl, | ||
| 577 | cropScale: '4:5', | ||
| 578 | success: (cropRes) => { | ||
| 579 | uploadAvatarPhoto(cropRes.tempFilePath || imgUrl) | ||
| 580 | }, | ||
| 581 | fail: () => { | ||
| 582 | uploadAvatarPhoto(imgUrl) | ||
| 583 | } | ||
| 584 | }) | ||
| 585 | } | ||
| 586 | }) | ||
| 587 | } | ||
| 588 | |||
| 589 | const uploadAvatarPhoto = async (path) => { | ||
| 590 | uni.showLoading({title: '上传中...', mask: true}) | ||
| 591 | const [uploadErr, uploadRes] = await to(uploadImgCorpPhoto(path)) | ||
| 592 | if (uploadErr || uploadRes?.code !== 200 || !uploadRes?.data) { | ||
| 593 | uni.hideLoading() | ||
| 594 | uni.showToast({title: uploadRes?.msg || '头像上传失败,请重新上传', icon: 'none'}) | ||
| 595 | return | ||
| 596 | } | ||
| 597 | |||
| 598 | const photo = uploadRes.data.fang || '' | ||
| 599 | const photo2 = uploadRes.data.yuan || '' | ||
| 600 | if (!photo || !photo2) { | ||
| 601 | uni.hideLoading() | ||
| 602 | uni.showToast({title: '头像上传返回数据异常', icon: 'none'}) | ||
| 603 | return | ||
| 604 | } | ||
| 605 | |||
| 606 | const currentPerInfo = userStore.perInfo || {} | ||
| 607 | const nextPerInfo = { | ||
| 608 | ...currentPerInfo, | ||
| 609 | photo, | ||
| 610 | photo2 | ||
| 611 | } | ||
| 612 | |||
| 613 | const perId = userInfo.value?.perId || currentPerInfo.perId | ||
| 614 | if (!perId) { | ||
| 615 | uni.hideLoading() | ||
| 616 | uni.showToast({title: '未获取到人员信息,请重新登录后再试', icon: 'none'}) | ||
| 617 | return | ||
| 618 | } | ||
| 619 | |||
| 620 | const [detailErr, detailRes] = await to(getInfo(perId)) | ||
| 621 | const saveParams = { | ||
| 622 | ...(detailErr ? currentPerInfo : (detailRes?.data || currentPerInfo)), | ||
| 623 | perId, | ||
| 624 | photo, | ||
| 625 | photo2 | ||
| 626 | } | ||
| 627 | const [saveErr] = await to(updateInfo(saveParams)) | ||
| 628 | uni.hideLoading() | ||
| 629 | |||
| 630 | if (saveErr) { | ||
| 631 | uni.showToast({title: '头像已上传,保存失败请稍后重试', icon: 'none'}) | ||
| 632 | return | ||
| 633 | } | ||
| 634 | userStore.setPerInfo(nextPerInfo) | ||
| 635 | uni.showToast({title: '头像上传成功', icon: 'success'}) | ||
| 636 | await getWebInfo().catch(() => {}) | ||
| 637 | } | ||
| 638 | |||
| 541 | // 下载电子会员证 | 639 | // 下载电子会员证 |
| 542 | const downCert = async () => { | 640 | const downCert = async () => { |
| 543 | if (!isBound.value) { | 641 | if (!isBound.value) { |
| ... | @@ -546,7 +644,12 @@ const downCert = async () => { | ... | @@ -546,7 +644,12 @@ const downCert = async () => { |
| 546 | } | 644 | } |
| 547 | const perId = userInfo.value?.perId | 645 | const perId = userInfo.value?.perId |
| 548 | if (!perId) return | 646 | if (!perId) return |
| 549 | 647 | ||
| 648 | if (!perInfo.value.perPhoto || !perInfo.value.perPhoto2) { | ||
| 649 | uni.hideLoading() | ||
| 650 | uni.showToast({title: '请先上传头像照片', icon: 'none'}) | ||
| 651 | return | ||
| 652 | } | ||
| 550 | uni.showLoading({title: '加载中...', mask: true}) | 653 | uni.showLoading({title: '加载中...', mask: true}) |
| 551 | const [err, res] = await to(downStuCertSingle(perId)) | 654 | const [err, res] = await to(downStuCertSingle(perId)) |
| 552 | uni.hideLoading() | 655 | uni.hideLoading() | ... | ... |
| ... | @@ -109,8 +109,9 @@ | ... | @@ -109,8 +109,9 @@ |
| 109 | import { | 109 | import { |
| 110 | onLoad | 110 | onLoad |
| 111 | } from '@dcloudio/uni-app' | 111 | } from '@dcloudio/uni-app' |
| 112 | import config from '@/config.js' | 112 | import config from '@/config.js' |
| 113 | import * as aes2 from '@/common/utils.js' | 113 | import * as aes2 from '@/common/utils.js' |
| 114 | import { fillImgUrl } from '@/common/utils.js' | ||
| 114 | const current = ref(0) | 115 | const current = ref(0) |
| 115 | const agree = ref(false) | 116 | const agree = ref(false) |
| 116 | const perId = ref() | 117 | const perId = ref() |
| ... | @@ -331,15 +332,16 @@ | ... | @@ -331,15 +332,16 @@ |
| 331 | uni.showLoading({ | 332 | uni.showLoading({ |
| 332 | title: '加载中' | 333 | title: '加载中' |
| 333 | }); | 334 | }); |
| 334 | api.uploadImgCorpPhoto(path).then(data => { | 335 | api.uploadImgCorpPhoto(path).then(data => { |
| 335 | console.log(data) | 336 | console.log(data) |
| 336 | baseFormData.value.photo = data.data.fang; | 337 | const photoData = data.data || {} |
| 337 | baseFormData.value.photo2 = data.data.yuan; | 338 | baseFormData.value.photo = photoData.fang || ''; |
| 338 | photoArr.value = { | 339 | baseFormData.value.photo2 = photoData.yuan || ''; |
| 339 | url: config.baseUrl_api + baseFormData.value.photo, | 340 | photoArr.value = { |
| 340 | name: '头像', | 341 | url: fillImgUrl(baseFormData.value.photo), |
| 341 | extname: 'jpg' | 342 | name: '头像', |
| 342 | } | 343 | extname: 'jpg' |
| 344 | } | ||
| 343 | }).catch(() => { | 345 | }).catch(() => { |
| 344 | photoArr.value = {} | 346 | photoArr.value = {} |
| 345 | baseFormData.value.photo = '' | 347 | baseFormData.value.photo = '' |
| ... | @@ -419,27 +421,17 @@ | ... | @@ -419,27 +421,17 @@ |
| 419 | baseFormData.value.perCode = res.data.perCode ||'' | 421 | baseFormData.value.perCode = res.data.perCode ||'' |
| 420 | baseFormData.value.validityDateRaw = res.data.validityDate || '' | 422 | baseFormData.value.validityDateRaw = res.data.validityDate || '' |
| 421 | baseFormData.value.validityDate = res.data.validityDate?.slice(0,10) //去掉时分秒 | 423 | baseFormData.value.validityDate = res.data.validityDate?.slice(0,10) //去掉时分秒 |
| 422 | if (res.data.photo) { | 424 | if (res.data.photo) { |
| 423 | console.log(res.data.photo) | 425 | console.log(res.data.photo) |
| 424 | if (res.data.photo.indexOf('http') == -1) { | 426 | baseFormData.value.photo = res.data.photo |
| 425 | baseFormData.value.photo = res.data.photo | 427 | let obj = { |
| 426 | let obj = { | 428 | url: fillImgUrl(res.data.photo), |
| 427 | url: config.baseUrl_api + res.data.photo, | 429 | name: '头像', |
| 428 | name: '头像', | 430 | extname: 'jpg' |
| 429 | extname: 'jpg' | 431 | } |
| 430 | } | 432 | photoArr.value = obj |
| 431 | photoArr.value = obj | 433 | |
| 432 | } else { | 434 | } |
| 433 | baseFormData.value.photo = res.data.photo | ||
| 434 | let obj = { | ||
| 435 | url: res.data.photo, | ||
| 436 | name: '头像', | ||
| 437 | extname: 'jpg' | ||
| 438 | } | ||
| 439 | photoArr.value = obj | ||
| 440 | } | ||
| 441 | |||
| 442 | } | ||
| 443 | // baseFormData.value.name = res.data.name | 435 | // baseFormData.value.name = res.data.name |
| 444 | baseFormData.value.perId = res.data.perId | 436 | baseFormData.value.perId = res.data.perId |
| 445 | console.log(res.data.photo, baseFormData.value.photo) | 437 | console.log(res.data.photo, baseFormData.value.photo) |
| ... | @@ -462,7 +454,7 @@ | ... | @@ -462,7 +454,7 @@ |
| 462 | } | 454 | } |
| 463 | 455 | ||
| 464 | 456 | ||
| 465 | function giveBirthDay() { | 457 | function giveBirthDay() { |
| 466 | // 判断身份证正确性/赋值生日 | 458 | // 判断身份证正确性/赋值生日 |
| 467 | if (baseFormData.value.idcType == 0) { | 459 | if (baseFormData.value.idcType == 0) { |
| 468 | if (!(/(^\d{15}$)|(^\d{17}([0-9]|X)$)/.test(baseFormData.value.idcCode))) { | 460 | if (!(/(^\d{15}$)|(^\d{17}([0-9]|X)$)/.test(baseFormData.value.idcCode))) { |
| ... | @@ -492,10 +484,9 @@ | ... | @@ -492,10 +484,9 @@ |
| 492 | // return | 484 | // return |
| 493 | // } | 485 | // } |
| 494 | // } | 486 | // } |
| 495 | } | 487 | } |
| 496 | 488 | ||
| 497 | 489 | function changeIdcType(e) { | |
| 498 | function changeIdcType(e) { | ||
| 499 | console.log(e) | 490 | console.log(e) |
| 500 | // 切换证件照类型把当前页面数据清空 | 491 | // 切换证件照类型把当前页面数据清空 |
| 501 | cardObj.value = {} | 492 | cardObj.value = {} | ... | ... |
| ... | @@ -54,9 +54,9 @@ | ... | @@ -54,9 +54,9 @@ |
| 54 | </view> | 54 | </view> |
| 55 | </template> | 55 | </template> |
| 56 | 56 | ||
| 57 | <script setup> | 57 | <script setup> |
| 58 | import * as api from '@/common/api.js' | 58 | import * as api from '@/common/api.js' |
| 59 | import config from '@/config.js' | 59 | import { fillImgUrl } from '@/common/utils.js' |
| 60 | import { | 60 | import { |
| 61 | onMounted, | 61 | onMounted, |
| 62 | ref | 62 | ref |
| ... | @@ -90,18 +90,14 @@ | ... | @@ -90,18 +90,14 @@ |
| 90 | // 道馆 | 90 | // 道馆 |
| 91 | query.value.multiDeptFlag = null | 91 | query.value.multiDeptFlag = null |
| 92 | query.value.showMyPersonFlag = 1 | 92 | query.value.showMyPersonFlag = 1 |
| 93 | } | 93 | } |
| 94 | api.selectPageList(query.value).then(res => { | 94 | api.selectPageList(query.value).then(res => { |
| 95 | for (var l of res.rows) { | 95 | const rows = formatRows(res.rows || []) |
| 96 | if (l.photo && l.photo.indexOf('http') == -1) { | 96 | list.value = rows |
| 97 | l.photo = config.baseUrl_api + l.photo | 97 | paging.value.complete(rows) |
| 98 | } | 98 | total.value = res.total |
| 99 | } | 99 | }) |
| 100 | list.value = res.rows | 100 | } |
| 101 | paging.value.complete(res.rows) | ||
| 102 | total.value = res.total | ||
| 103 | }) | ||
| 104 | } | ||
| 105 | function getList() { | 101 | function getList() { |
| 106 | uni.showLoading({ | 102 | uni.showLoading({ |
| 107 | title: '加载中' | 103 | title: '加载中' |
| ... | @@ -110,19 +106,22 @@ | ... | @@ -110,19 +106,22 @@ |
| 110 | // 道馆 | 106 | // 道馆 |
| 111 | query.value.multiDeptFlag = null | 107 | query.value.multiDeptFlag = null |
| 112 | query.value.showMyPersonFlag = 1 | 108 | query.value.showMyPersonFlag = 1 |
| 113 | } | 109 | } |
| 114 | api.selectPageList(query.value).then(res => { | 110 | api.selectPageList(query.value).then(res => { |
| 115 | for (var l of res.rows) { | 111 | const rows = formatRows(res.rows || []) |
| 116 | if (l.photo && l.photo.indexOf('http') == -1) { | 112 | list.value = rows |
| 117 | l.photo = config.baseUrl_api + l.photo | 113 | paging.value.complete(rows) |
| 118 | } | 114 | total.value = res.total |
| 119 | } | 115 | uni.hideLoading() |
| 120 | list.value = res.rows | 116 | }) |
| 121 | paging.value.complete(res.rows) | 117 | } |
| 122 | total.value = res.total | 118 | |
| 123 | uni.hideLoading() | 119 | function formatRows(rows) { |
| 124 | }) | 120 | return rows.map(item => ({ |
| 125 | } | 121 | ...item, |
| 122 | photo: fillImgUrl(item.photo) | ||
| 123 | })) | ||
| 124 | } | ||
| 126 | 125 | ||
| 127 | function handleDelete(item) { | 126 | function handleDelete(item) { |
| 128 | uni.showModal({ | 127 | uni.showModal({ | ... | ... |
-
Please register or sign in to post a comment