console.uvue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. <template>
  2. <view class="container">
  3. <!-- 背景图改为absolute,避免fixed在scroll-view内的问题 -->
  4. <image class="bg-image" src="@/static/imagesInfo/bg-color.png" mode="aspectFill" />
  5. <scroll-view style="flex: 1" scroll-y>
  6. <view class="page">
  7. <!-- 城市信息 -->
  8. <view class="city-info">
  9. <text class="city-text-box">当前城市:{{ state.cityInfo }}</text>
  10. <u-icon name="notification" :size="24" />
  11. </view>
  12. <!-- 用户卡片 -->
  13. <view class="user-card">
  14. <image class="user-bg" src="@/static/imagesInfo/bg-icon.png" mode="scaleToFill" />
  15. <view class="user-content" style="padding: 20rpx;">
  16. <!-- 左侧信息 -->
  17. <view class="user-left">
  18. <view class="user-row">
  19. <text class="user-name">{{ coachInfo.nickname }}</text>
  20. <view class="tags">
  21. <text class="tag-new">新人实习</text>
  22. </view>
  23. <u-icon name="edit" :size="18" @click="jumpMasterInfo" />
  24. <text class="tag">编辑</text>
  25. </view>
  26. <view class="user-row">
  27. <u-icon name="customer-interests" :size="18" />
  28. <text class="user-role">{{ coachInfo.role_name }}</text>
  29. <u-icon name="store" :size="18" />
  30. <text class="user-shop">{{ coachInfo.shop_name }}</text>
  31. </view>
  32. <view class="online-switch">
  33. <u-switch :checked="state.isOnline" @change="toggleOnline" />
  34. </view>
  35. </view>
  36. <!-- 右侧头像 -->
  37. <view class="user-right" @click="jumpMasterInfo">
  38. <text class="time-text">入驻时间</text>
  39. <text class="time-text" style="margin-top: 5rpx;">{{ displayCreatedAt }}</text>
  40. <image class="avatar-img" :src="coachInfo.avatar" mode="aspectFit" />
  41. </view>
  42. </view>
  43. <!-- 定位栏 -->
  44. <view class="location-bar">
  45. <u-icon name="navigation" :size="18" />
  46. <text class="location-text">当前定位:{{ userLocation }}</text>
  47. <text class="location-btn" @click="updateLocation">手动更新</text>
  48. </view>
  49. </view>
  50. <!-- 本月数据 -->
  51. <view class="stats-row">
  52. <view class="stat-item" v-for="(item, index) in monthStats" :key="index">
  53. <text class="stat-label">{{ item.label }}</text>
  54. <text class="stat-value">{{ item.value }}</text>
  55. </view>
  56. </view>
  57. <!-- 功能按钮 -->
  58. <view class="func-grid">
  59. <view class="func-item" v-for="(item, index) in funcList" :key="index"
  60. @click="jumpSetProject(item.label)">
  61. <image class="func-icon" :src="item.iconUrl" mode="aspectFit" />
  62. <text class="func-label">{{ item.label }}</text>
  63. </view>
  64. </view>
  65. <!-- 数据统计 -->
  66. <view class="data-section">
  67. <view class="section-header">
  68. <text class="section-title">数据统计</text>
  69. <text class="section-more">查看全部 ></text>
  70. </view>
  71. <view class="data-grid">
  72. <view class="data-item" v-for="(item, index) in dataStats" :key="index">
  73. <text class="data-value">{{ item.value }}</text>
  74. <text class="data-label">{{ item.label }}</text>
  75. </view>
  76. </view>
  77. </view>
  78. <!-- 客户评价 -->
  79. <view class="eval-section">
  80. <view class="section-header">
  81. <text class="section-title">客户评价</text>
  82. <text class="section-more">查看全部 ></text>
  83. </view>
  84. <scroll-view class="eval-tags" scroll-x>
  85. <text class="eval-tag" v-for="(tag, index) in evalTags" :key="index">
  86. {{ tag.text }} {{ tag.count > 0 ? tag.count : '' }}
  87. </text>
  88. </scroll-view>
  89. <view class="eval-item">
  90. <image class="eval-avatar" src="/static/testInfo/boy-nickname.png" mode="aspectFill" />
  91. <view class="eval-content">
  92. <view class="eval-top">
  93. <text class="eval-name">匿名评价</text>
  94. <text class="eval-date">2025-04-24</text>
  95. </view>
  96. <view class="eval-stars">
  97. <text>⭐⭐⭐⭐☆</text>
  98. <text class="eval-service">泰式松骨</text>
  99. </view>
  100. <text class="eval-comment">服务到位</text>
  101. </view>
  102. </view>
  103. </view>
  104. <!-- 底部留白,避免悬浮球遮挡 -->
  105. <view style="height: 100rpx;"></view>
  106. </view>
  107. </scroll-view>
  108. <!-- 悬浮球移到scroll-view外 -->
  109. <u-floating @click="callPolice" />
  110. </view>
  111. </template>
  112. <script setup lang="uts">
  113. import { ref, computed, reactive, } from 'vue'
  114. import { getCoachDetaile } from '@/utils/api/masterInfoApi'
  115. // ==================== 类型定义 ====================
  116. type CoachInfo = {
  117. nickname : string
  118. role_name : string
  119. shop_name : string
  120. created_at : string
  121. avatar : string
  122. coach : string
  123. }
  124. type State = {
  125. isOnline : boolean
  126. cityInfo : string
  127. }
  128. type FuncItem = {
  129. label : string
  130. iconUrl : string
  131. }
  132. type EvalTag = {
  133. text : string
  134. count : number
  135. }
  136. // ==================== 响应式数据(全部使用reactive/ref,避免shallowRef)====================
  137. const state = ref<State>({
  138. isOnline: true,
  139. cityInfo: '定位中...'
  140. })
  141. const coachInfo = reactive<CoachInfo>({
  142. nickname: '',
  143. role_name: '小丁理疗师',
  144. shop_name: '未绑定门店',
  145. created_at: '',
  146. avatar: '/static/testInfo/boy-nickname.png',
  147. coach: ''
  148. })
  149. const userLocation = ref<string>('')
  150. const displayCreatedAt = computed(() : string => {
  151. const date = coachInfo.created_at
  152. if (date == null || date.length == 0) {
  153. return '--'
  154. }
  155. return date
  156. })
  157. // ==================== 静态数据 ====================
  158. const monthStats = [
  159. { label: '本月收益(元)', value: '2234.88' },
  160. { label: '本月接单量(单)', value: '2234.88' },
  161. { label: '本月退单率', value: '30%' }
  162. ]
  163. const funcList : FuncItem[] = [
  164. { iconUrl: '/static/imagesInfo/cx-shop.png', label: '接单时间' },
  165. { iconUrl: '/static/imagesInfo/item-icon.png', label: '服务项目' },
  166. { iconUrl: '/static/imagesInfo/jied-time.png', label: '重选店铺' },
  167. { iconUrl: '/static/imagesInfo/gengxin-wz.png', label: '位置更新' }
  168. ]
  169. const dataStats = [
  170. { value: '456', label: '接单量' },
  171. { value: '10%', label: '加钟率' },
  172. { value: '70%', label: '好评率' },
  173. { value: '3%', label: '复购率' },
  174. { value: '19%', label: '退单率' }
  175. ]
  176. const evalTags : EvalTag[] = [
  177. { text: '不良引导', count: 0 },
  178. { text: '手法不好', count: 101 },
  179. { text: '性格温柔', count: 198 },
  180. { text: '服务到位', count: 10 }
  181. ]
  182. // ==================== 方法 ====================
  183. const toggleOnline = () => {
  184. state.value.isOnline = !state.value.isOnline
  185. console.log('Status changed:', state.value.isOnline)
  186. }
  187. const httpGetCoachDetail = async () => {
  188. // response.data.nickname
  189. // coachInfo.created_at = response.data.created_at
  190. // coachInfo.avatar = response.data.avatar
  191. try {
  192. const response = await getCoachDetaile() as UTSJSONObject
  193. console.log('Coach detail:', response)
  194. const code = response["code"] as number
  195. const dataObj = response["data"] as UTSJSONObject | null
  196. if (code != 200 || dataObj == null) {
  197. return
  198. }
  199. const coach = dataObj["coach"] as UTSJSONObject | null
  200. if (coach == null) {
  201. uni.navigateTo({
  202. url: '/pages/login/merchantRecuitment'
  203. })
  204. return
  205. }
  206. coachInfo.nickname = dataObj["nickname"] as string
  207. coachInfo.created_at = dataObj["created_at"] as string
  208. } catch (err : any) {
  209. console.error('获取技师详情失败:', err)
  210. }
  211. }
  212. const updateLocation = async () => {
  213. // try {
  214. // const location = await new Promise<UniApp.GetLocationSuccess>((resolve, reject) => {
  215. // uni.getLocation({
  216. // type: 'gcj02',
  217. // success: resolve,
  218. // fail: reject
  219. // })
  220. // })
  221. // console.log('Location:', location)
  222. // // 简化处理,实际需要逆地理编码
  223. // userLocation.value = `${location.latitude.toFixed(2)}, ${location.longitude.toFixed(2)}`
  224. // } catch (e) {
  225. // console.error('定位错误:', e)
  226. // uni.showToast({ title: '定位失败', icon: 'none' })
  227. // userLocation.value = '定位失败'
  228. // }
  229. }
  230. const jumpMasterInfo = () => {
  231. uni.navigateTo({
  232. url: '/pages/myEdit/myEdit'
  233. });
  234. }
  235. const jumpSetProject = (label : string) => {
  236. console.log('Navigate to:', label)
  237. switch (label) {
  238. case '接单时间':
  239. uni.navigateTo({ url: '/pages/console/setOrderTime' })
  240. break
  241. case '服务项目':
  242. uni.navigateTo({ url: '/pages/console/serviceProject' })
  243. break
  244. }
  245. }
  246. const callPolice = () => {
  247. console.log('Emergency call triggered')
  248. }
  249. onLoad(() => {
  250. // httpGetCoachDetail()
  251. })
  252. onReady(() => {
  253. // httpGetCoachDetail();
  254. })
  255. </script>
  256. <style>
  257. /* 修复8:外层容器使用flex布局 */
  258. .container {
  259. flex: 1;
  260. position: relative;
  261. }
  262. /* 修复9:背景图改为absolute,避免fixed在scroll-view内的问题 */
  263. .bg-image {
  264. position: absolute;
  265. top: 0;
  266. left: 0;
  267. width: 750rpx;
  268. height: 900rpx;
  269. z-index: 0;
  270. }
  271. .page {
  272. padding: 20rpx;
  273. position: relative;
  274. z-index: 1;
  275. }
  276. .city-info {
  277. flex-direction: row;
  278. justify-content: space-between;
  279. align-items: center;
  280. margin-bottom: 16rpx;
  281. }
  282. .city-text-box {
  283. font-size: 28rpx;
  284. color: #333;
  285. }
  286. /* 用户卡片 */
  287. .user-card {
  288. border-radius: 16rpx;
  289. margin-bottom: 32rpx;
  290. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
  291. position: relative;
  292. overflow: hidden;
  293. background-color: #fff;
  294. }
  295. .user-bg {
  296. position: absolute;
  297. top: 0;
  298. left: 0;
  299. width: 100%;
  300. height: 100%;
  301. z-index: 0;
  302. }
  303. .user-content {
  304. flex-direction: row;
  305. justify-content: space-between;
  306. position: relative;
  307. z-index: 1;
  308. }
  309. .user-left {
  310. flex: 1;
  311. flex-direction: column;
  312. }
  313. .user-row {
  314. flex-direction: row;
  315. align-items: center;
  316. margin-bottom: 16rpx;
  317. }
  318. .user-name {
  319. font-size: 40rpx;
  320. font-weight: bold;
  321. color: #333;
  322. }
  323. .tags {
  324. flex-direction: row;
  325. margin-left: 16rpx;
  326. }
  327. .tag-new {
  328. background: linear-gradient(180deg, rgba(207, 221, 62, 0.69) 0%, rgba(162, 184, 29, 1) 100%);
  329. color: #fff;
  330. border-radius: 24rpx;
  331. font-size: 24rpx;
  332. padding: 6rpx 16rpx;
  333. }
  334. .tag {
  335. font-size: 24rpx;
  336. color: #666;
  337. margin-left: 8rpx;
  338. }
  339. .user-role,
  340. .user-shop {
  341. font-size: 26rpx;
  342. color: #999;
  343. margin-left: 8rpx;
  344. margin-right: 24rpx;
  345. }
  346. .online-switch {
  347. margin-top: 24rpx;
  348. }
  349. .user-right {
  350. width: 180rpx;
  351. align-items: center;
  352. flex-direction: column;
  353. }
  354. .time-text {
  355. font-size: 24rpx;
  356. color: #fff;
  357. text-align: center;
  358. margin-top: 10rpx;
  359. }
  360. .avatar-img {
  361. width: 138rpx;
  362. height: 138rpx;
  363. border-radius: 69rpx;
  364. margin-top: 15rpx;
  365. border: 4rpx solid #fff;
  366. }
  367. .location-bar {
  368. flex-direction: row;
  369. align-items: center;
  370. background: linear-gradient(to right, rgba(255, 249, 225, 1), rgba(255, 241, 191, 1));
  371. padding: 16rpx 20rpx;
  372. border-radius: 18rpx;
  373. margin: 20rpx;
  374. position: relative;
  375. z-index: 1;
  376. }
  377. .location-text {
  378. flex: 1;
  379. font-size: 26rpx;
  380. color: #333;
  381. margin-left: 8rpx;
  382. }
  383. .location-btn {
  384. font-size: 24rpx;
  385. color: #333;
  386. border: 2rpx solid #333;
  387. padding: 8rpx 16rpx;
  388. border-radius: 16rpx;
  389. }
  390. /* 本月数据 */
  391. .stats-row {
  392. flex-direction: row;
  393. background-color: #fff;
  394. margin-bottom: 32rpx;
  395. border-radius: 24rpx;
  396. padding: 32rpx 0;
  397. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.05);
  398. }
  399. .stat-item {
  400. flex: 1;
  401. align-items: center;
  402. border-right-width: 2rpx;
  403. border-right-color: #eee;
  404. border-right-style: solid;
  405. }
  406. .stat-item:last-child {
  407. border-right-width: 0;
  408. }
  409. .stat-label {
  410. font-size: 24rpx;
  411. color: #999;
  412. margin-bottom: 12rpx;
  413. }
  414. .stat-value {
  415. font-size: 36rpx;
  416. font-weight: bold;
  417. color: #333;
  418. }
  419. /* 功能网格 */
  420. .func-grid {
  421. flex-direction: row;
  422. justify-content: space-around;
  423. background-color: #fff;
  424. margin-bottom: 32rpx;
  425. border-radius: 24rpx;
  426. padding: 32rpx 0;
  427. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.1);
  428. }
  429. .func-item {
  430. align-items: center;
  431. }
  432. .func-icon {
  433. width: 92rpx;
  434. height: 92rpx;
  435. }
  436. .func-label {
  437. font-size: 24rpx;
  438. color: #666;
  439. margin-top: 16rpx;
  440. }
  441. /* 数据统计 */
  442. .data-section,
  443. .eval-section {
  444. background-color: #fff;
  445. margin-bottom: 32rpx;
  446. border-radius: 24rpx;
  447. padding: 32rpx;
  448. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.1);
  449. }
  450. .section-header {
  451. flex-direction: row;
  452. justify-content: space-between;
  453. align-items: center;
  454. margin-bottom: 24rpx;
  455. }
  456. .section-title {
  457. font-size: 32rpx;
  458. font-weight: bold;
  459. color: #333;
  460. }
  461. .section-more {
  462. font-size: 26rpx;
  463. color: #999;
  464. }
  465. .data-grid {
  466. flex-direction: row;
  467. justify-content: space-between;
  468. }
  469. .data-item {
  470. align-items: center;
  471. }
  472. .data-value {
  473. font-size: 32rpx;
  474. font-weight: bold;
  475. color: #333;
  476. margin-bottom: 8rpx;
  477. }
  478. .data-label {
  479. font-size: 24rpx;
  480. color: #999;
  481. }
  482. /* 评价 */
  483. .eval-tags {
  484. flex-direction: row;
  485. margin-bottom: 24rpx;
  486. }
  487. .eval-tag {
  488. font-size: 24rpx;
  489. padding: 8rpx 20rpx;
  490. background-color: #f5f5f5;
  491. border-radius: 24rpx;
  492. margin-right: 16rpx;
  493. color: #666;
  494. }
  495. .eval-item {
  496. flex-direction: row;
  497. }
  498. .eval-avatar {
  499. width: 80rpx;
  500. height: 80rpx;
  501. border-radius: 40rpx;
  502. margin-right: 20rpx;
  503. }
  504. .eval-content {
  505. flex: 1;
  506. flex-direction: column;
  507. }
  508. .eval-top {
  509. flex-direction: row;
  510. justify-content: space-between;
  511. margin-bottom: 8rpx;
  512. }
  513. .eval-name {
  514. font-size: 28rpx;
  515. color: #333;
  516. }
  517. .eval-date {
  518. font-size: 24rpx;
  519. color: #999;
  520. }
  521. .eval-stars {
  522. flex-direction: row;
  523. align-items: center;
  524. margin-bottom: 8rpx;
  525. }
  526. .eval-service {
  527. font-size: 24rpx;
  528. color: #999;
  529. margin-left: 16rpx;
  530. }
  531. .eval-comment {
  532. font-size: 26rpx;
  533. color: #333;
  534. }
  535. </style>