index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <view class="container" :style="{paddingTop: navbarHeight + 'rpx'}">
  3. <!-- 顶部渐变背景 -->
  4. <view class="top-gradient"></view>
  5. <!-- 自定义导航栏 -->
  6. <view class="custom-navbar" :style="{paddingTop: statusBarHeight + 'px'}">
  7. <view class="navbar-content">
  8. <view class="navbar-back" @click="handleBack">
  9. <view class="iconfont icon-right back-icon"></view>
  10. </view>
  11. <text class="navbar-title">账号信息</text>
  12. <view class="navbar-placeholder"></view>
  13. </view>
  14. </view>
  15. <!-- 第一个卡片:基本信息 -->
  16. <view class="info-card">
  17. <view class="info-item" @click="handleAvatar">
  18. <view class="item-label">头像</view>
  19. <view class="item-value">
  20. <image v-if="user.avatar" :src="user.avatar" class="avatar-img" mode="aspectFill"></image>
  21. <view v-else class="avatar-placeholder">
  22. <view class="iconfont icon-people"></view>
  23. </view>
  24. <view class="iconfont icon-right arrow-icon"></view>
  25. </view>
  26. </view>
  27. <view class="info-divider"></view>
  28. <view class="info-item" @click="handleEdit('name')">
  29. <view class="item-label">姓名</view>
  30. <view class="item-value">
  31. <text class="value-text">{{ user.nickName || user.userName || '未设置' }}</text>
  32. <view class="iconfont icon-right arrow-icon"></view>
  33. </view>
  34. </view>
  35. <view class="info-divider"></view>
  36. <view class="info-item" @click="handleEdit('intro')">
  37. <view class="item-label">简介</view>
  38. <view class="item-value">
  39. <text class="value-text placeholder">{{ user.intro || '添加一条简介' }}</text>
  40. <view class="iconfont icon-right arrow-icon"></view>
  41. </view>
  42. </view>
  43. <view class="info-divider"></view>
  44. <view class="info-item" @click="handleEdit('phone')">
  45. <view class="item-label">手机号码</view>
  46. <view class="item-value">
  47. <text class="value-text">{{ user.phonenumber || '未设置' }}</text>
  48. <view class="iconfont icon-right arrow-icon"></view>
  49. </view>
  50. </view>
  51. <view class="info-divider"></view>
  52. <view class="info-item">
  53. <view class="item-label">接单状态</view>
  54. <view class="item-value">
  55. <text class="status-text" :class="{ active: orderStatus }">{{ orderStatus ? '接单中' : '暂停接单' }}</text>
  56. <switch :checked="orderStatus" @change="handleOrderStatusChange" color="#007AFF" />
  57. </view>
  58. </view>
  59. </view>
  60. <!-- 第二个卡片:专业和财务信息 -->
  61. <view class="info-card">
  62. <view class="info-item" @click="handleEdit('practiceTime')">
  63. <view class="item-label">从业时间</view>
  64. <view class="item-value">
  65. <text class="value-text">{{ user.practiceTime || '未设置' }}</text>
  66. <view class="iconfont icon-right arrow-icon"></view>
  67. </view>
  68. </view>
  69. <view class="info-divider"></view>
  70. <view class="info-item" @click="handleEdit('professionalField')">
  71. <view class="item-label">专业领域</view>
  72. <view class="item-value">
  73. <text class="value-text">{{ user.professionalField || '未设置' }}</text>
  74. <view class="iconfont icon-right arrow-icon"></view>
  75. </view>
  76. </view>
  77. <view class="info-divider"></view>
  78. <view class="info-item" @click="handleEdit('legalScenarios')">
  79. <view class="item-label">法律场景</view>
  80. <view class="item-value">
  81. <text class="value-text">{{ user.legalScenarios || '未设置' }}</text>
  82. <view class="iconfont icon-right arrow-icon"></view>
  83. </view>
  84. </view>
  85. <view class="info-divider"></view>
  86. <view class="info-item" @click="handleEdit('lawFirm')">
  87. <view class="item-label">所属律所</view>
  88. <view class="item-value">
  89. <text class="value-text">{{ user.lawFirm || '未设置' }}</text>
  90. <view class="iconfont icon-right arrow-icon"></view>
  91. </view>
  92. </view>
  93. <view class="info-divider"></view>
  94. <view class="info-item" @click="handleEdit('receivingAccount')">
  95. <view class="item-label">收款账户</view>
  96. <view class="item-value">
  97. <text class="value-text">{{ user.receivingAccount || '未设置' }}</text>
  98. <view class="iconfont icon-right arrow-icon"></view>
  99. </view>
  100. </view>
  101. <view class="info-divider"></view>
  102. <view class="info-item" @click="handleEdit('address')">
  103. <view class="item-label">联系地址</view>
  104. <view class="item-value">
  105. <text class="value-text">{{ user.address || '未设置' }}</text>
  106. <view class="iconfont icon-right arrow-icon"></view>
  107. </view>
  108. </view>
  109. </view>
  110. <!-- 第三个卡片:账号管理 -->
  111. <view class="info-card">
  112. <view class="info-item" @click="handleDeregister">
  113. <view class="item-label">注销账号</view>
  114. <view class="item-value">
  115. <view class="iconfont icon-right arrow-icon"></view>
  116. </view>
  117. </view>
  118. </view>
  119. </view>
  120. </template>
  121. <script>
  122. import { getLawyerInfo, editLawyerUser } from "@/api/api"
  123. import upload from '@/utils/upload'
  124. import config from '@/config'
  125. export default {
  126. data() {
  127. return {
  128. user: {},
  129. orderStatus: true,
  130. statusBarHeight: 0
  131. }
  132. },
  133. onLoad() {
  134. // 获取状态栏高度
  135. const systemInfo = uni.getSystemInfoSync()
  136. this.statusBarHeight = systemInfo.statusBarHeight || 0
  137. this.getLawyerInfoData()
  138. },
  139. computed: {
  140. navbarHeight() {
  141. // 状态栏高度(px转rpx) + 导航栏高度(88rpx) + 间距(20rpx)
  142. return (this.statusBarHeight * 2) + 88 + 20
  143. }
  144. },
  145. methods: {
  146. getLawyerInfoData() {
  147. getLawyerInfo({ lawyerId: 1 }).then(response => {
  148. // 处理返回的律师信息
  149. if (response.data) {
  150. // 合并律师信息到 user 对象
  151. this.user = { ...this.user, ...response.data }
  152. // 如果有接单状态字段,使用它
  153. if (response.data.orderStatus !== undefined) {
  154. this.orderStatus = response.data.orderStatus
  155. }
  156. }
  157. }).catch(error => {
  158. console.error('获取律师信息失败:', error)
  159. })
  160. },
  161. handleAvatar() {
  162. const _this = this
  163. uni.chooseImage({
  164. count: 1,
  165. sizeType: ['compressed'],
  166. sourceType: ['album'],
  167. success: function(res) {
  168. const tempFilePath = res.tempFilePaths[0]
  169. // 显示上传中提示
  170. uni.showLoading({
  171. title: '上传中...',
  172. mask: true
  173. })
  174. // 使用原本的上传方法
  175. // upload({
  176. // url: '/file/upload',
  177. // name: 'avatarfile',
  178. // filePath: tempFilePath
  179. // }).then(uploadRes => {
  180. // // 上传成功后,获取图片URL
  181. // let headImg = ''
  182. // if (uploadRes.url) {
  183. // headImg = uploadRes.url
  184. // } else if (uploadRes.fileName) {
  185. // headImg = config.baseUrl + uploadRes.fileName
  186. // } else if (uploadRes.data && uploadRes.data.url) {
  187. // headImg = uploadRes.data.url.startsWith('http') ? uploadRes.data.url : config.baseUrl + uploadRes.data.url
  188. // } else if (uploadRes.data) {
  189. // headImg = typeof uploadRes.data === 'string' ? uploadRes.data : uploadRes.data.url || uploadRes.data.imgUrl || ''
  190. // }
  191. // if (!headImg) {
  192. // throw new Error('获取图片URL失败')
  193. // }
  194. // // 调用保存接口
  195. // return editLawyerUser({
  196. // id: 1,
  197. // headImg: headImg
  198. // }).then(saveRes => {
  199. // // 更新本地头像显示
  200. // if (saveRes.data && saveRes.data.headImg) {
  201. // _this.user.avatar = saveRes.data.headImg
  202. // _this.user.headImg = saveRes.data.headImg
  203. // } else {
  204. // // 如果返回数据中没有headImg,使用上传返回的URL
  205. // _this.user.avatar = headImg
  206. // _this.user.headImg = headImg
  207. // }
  208. // return saveRes
  209. // })
  210. // }).then(saveRes => {
  211. // uni.hideLoading()
  212. // _this.$modal.msgSuccess('头像上传成功')
  213. // // 刷新数据
  214. // _this.getLawyerInfoData()
  215. // }).catch(error => {
  216. // uni.hideLoading()
  217. // console.error('上传失败:', error)
  218. // _this.$modal.msgError('头像上传失败,请重试')
  219. // })
  220. },
  221. fail: function(err) {
  222. console.error('选择图片失败:', err)
  223. _this.$modal.msgError('选择图片失败')
  224. }
  225. })
  226. },
  227. handleEdit(field) {
  228. // 跳转到编辑页面或显示编辑弹窗
  229. this.$tab.navigateTo('/pages/mine/info/edit')
  230. },
  231. handleOrderStatusChange(e) {
  232. this.orderStatus = e.detail.value
  233. // 这里可以调用API更新接单状态
  234. // updateOrderStatus(this.orderStatus)
  235. },
  236. handleDeregister() {
  237. this.$modal.confirm('确定要注销账号吗?注销后将无法恢复。').then(() => {
  238. // 调用注销账号API
  239. this.$modal.showToast('注销账号功能开发中')
  240. })
  241. },
  242. handleBack() {
  243. uni.navigateBack()
  244. }
  245. }
  246. }
  247. </script>
  248. <style lang="scss" scoped>
  249. page {
  250. background-color: #f5f5f5;
  251. }
  252. .container {
  253. min-height: 100vh;
  254. padding: 0 30rpx 20rpx 30rpx;
  255. background-color: #f5f5f5;
  256. position: relative;
  257. // 顶部渐变背景
  258. .top-gradient {
  259. position: fixed;
  260. top: 0;
  261. left: 0;
  262. right: 0;
  263. height: 800rpx;
  264. background: linear-gradient(180deg, rgba(59, 130, 246, 0.1) 0%, rgba(147, 197, 253, 0.05) 50%, transparent 100%);
  265. z-index: 0;
  266. pointer-events: none;
  267. }
  268. // 自定义导航栏
  269. .custom-navbar {
  270. position: fixed;
  271. top: 0;
  272. left: 0;
  273. right: 0;
  274. z-index: 999;
  275. background-color: transparent;
  276. pointer-events: none;
  277. .navbar-content {
  278. display: flex;
  279. align-items: center;
  280. justify-content: center;
  281. height: 88rpx;
  282. pointer-events: auto;
  283. position: relative;
  284. .navbar-back {
  285. position: absolute;
  286. left: 30rpx;
  287. width: 60rpx;
  288. height: 60rpx;
  289. display: flex;
  290. align-items: center;
  291. justify-content: center;
  292. .back-icon {
  293. font-size: 36rpx;
  294. color: #000000;
  295. transform: rotate(180deg);
  296. }
  297. }
  298. .navbar-title {
  299. font-size: 36rpx;
  300. font-weight: 500;
  301. color: #000000;
  302. }
  303. .navbar-placeholder {
  304. position: absolute;
  305. right: 30rpx;
  306. width: 60rpx;
  307. height: 60rpx;
  308. }
  309. }
  310. }
  311. }
  312. .info-card {
  313. background-color: #ffffff;
  314. border-radius: 16rpx;
  315. margin-bottom: 20rpx;
  316. overflow: hidden;
  317. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
  318. .info-item {
  319. display: flex;
  320. align-items: center;
  321. justify-content: space-between;
  322. padding: 32rpx 30rpx;
  323. min-height: 100rpx;
  324. .item-label {
  325. font-size: 32rpx;
  326. color: #000000;
  327. font-weight: 400;
  328. }
  329. .item-value {
  330. display: flex;
  331. align-items: center;
  332. flex: 1;
  333. justify-content: flex-end;
  334. .avatar-img {
  335. width: 80rpx;
  336. height: 80rpx;
  337. border-radius: 50%;
  338. margin-right: 20rpx;
  339. }
  340. .avatar-placeholder {
  341. width: 80rpx;
  342. height: 80rpx;
  343. border-radius: 50%;
  344. background-color: #e0e0e0;
  345. display: flex;
  346. align-items: center;
  347. justify-content: center;
  348. margin-right: 20rpx;
  349. .iconfont {
  350. font-size: 40rpx;
  351. color: #999999;
  352. }
  353. }
  354. .value-text {
  355. font-size: 32rpx;
  356. color: #000000;
  357. margin-right: 20rpx;
  358. &.placeholder {
  359. color: #999999;
  360. }
  361. }
  362. .status-text {
  363. font-size: 32rpx;
  364. color: #999999;
  365. margin-right: 20rpx;
  366. &.active {
  367. color: #007AFF;
  368. }
  369. }
  370. .arrow-icon {
  371. font-size: 28rpx;
  372. color: #cccccc;
  373. }
  374. }
  375. }
  376. .info-divider {
  377. height: 1rpx;
  378. background-color: #f0f0f0;
  379. margin: 0 30rpx;
  380. }
  381. }
  382. </style>