index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <template>
  2. <view class="container">
  3. <!-- 自定义头部 -->
  4. <view class="custom-header">
  5. <view class="header-left" @click="navBack">
  6. <image class="back-icon" src="/static/icons/chevron_right_dark.svg" style="transform: rotate(180deg);"></image>
  7. </view>
  8. <text class="header-title">个人资料</text>
  9. <view class="header-right"></view>
  10. </view>
  11. <view class="header-placeholder"></view>
  12. <view class="group-card">
  13. <view class="list-item" @click="changeAvatar">
  14. <text class="item-title">头像</text>
  15. <view class="item-right">
  16. <image class="user-avatar" :src="userInfo.avatar" mode="aspectFill"></image>
  17. <image class="arrow-icon" src="/static/icons/chevron_right.svg"></image>
  18. </view>
  19. </view>
  20. <view class="list-item" @click="editName">
  21. <text class="item-title">真实姓名</text>
  22. <view class="item-right">
  23. <text class="item-value">{{ userInfo.name }}</text>
  24. <image class="arrow-icon" src="/static/icons/chevron_right.svg"></image>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="group-card">
  29. <view class="list-item">
  30. <text class="item-title">工作类型</text>
  31. <view class="tag-blue-outline">{{ userInfo.workType }}</view>
  32. </view>
  33. <view class="list-item" @click="showStatusPicker">
  34. <text class="item-title">工作状态</text>
  35. <view class="item-right">
  36. <text class="item-value-black">{{ userInfo.workStatus }}</text>
  37. <image class="arrow-icon" src="/static/icons/chevron_right.svg"></image>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="group-card">
  42. <view class="list-item" @click="showCityPicker">
  43. <text class="item-title">工作城市</text>
  44. <view class="item-right">
  45. <text class="item-value">{{ userInfo.city }}</text>
  46. <image class="arrow-icon" src="/static/icons/chevron_right.svg"></image>
  47. </view>
  48. </view>
  49. <view class="list-item no-border">
  50. <text class="item-title">所属站点</text>
  51. <view class="item-right">
  52. <text class="item-value">深圳市龙华区民治街道第一站</text>
  53. </view>
  54. </view>
  55. </view>
  56. <!-- 工作状态选择弹窗 -->
  57. <view class="popup-mask" v-if="isStatusPickerShow" @click="closeStatusPicker">
  58. <view class="popup-content" @click.stop>
  59. <view class="popup-title">选择工作状态</view>
  60. <view class="popup-item" @click="selectStatus('接单中')">接单中</view>
  61. <view class="popup-item" @click="selectStatus('休息中')">休息中</view>
  62. <view class="popup-cancel" @click="closeStatusPicker">取消</view>
  63. </view>
  64. </view>
  65. <!-- 城市选择弹窗 (模拟) -->
  66. <view class="popup-mask" v-if="isCityPickerShow" @click="closeCityPicker">
  67. <view class="popup-content" @click.stop>
  68. <view class="popup-header-row">
  69. <text class="popup-btn-cancel" @click="closeCityPicker">取消</text>
  70. <text class="popup-title-text">请选择工作城市</text>
  71. <text class="popup-btn-confirm" @click="confirmCity">确定</text>
  72. </view>
  73. <view class="city-tabs">
  74. <view
  75. class="city-tab-item"
  76. :class="{ 'active': cityStep > 0, 'active-red': cityStep === 0 }"
  77. @click="changeCityStep(0)">
  78. {{ selectedProvince || '请选择' }}
  79. </view>
  80. <view
  81. class="city-tab-item"
  82. :class="{ 'active': cityStep > 1, 'active-red': cityStep === 1 }"
  83. v-if="selectedProvince"
  84. @click="changeCityStep(1)">
  85. {{ selectedCity || '请选择' }}
  86. </view>
  87. <view
  88. class="city-tab-item"
  89. :class="{ 'active-red': cityStep === 2 }"
  90. v-if="selectedCity"
  91. @click="changeCityStep(2)">
  92. {{ selectedDistrict || '请选择' }}
  93. </view>
  94. </view>
  95. <scroll-view scroll-y class="city-list">
  96. <view
  97. class="city-item"
  98. v-for="(item, index) in currentList"
  99. :key="index"
  100. @click="selectItem(item)">
  101. {{ item }}
  102. <text v-if="isSelected(item)" style="float: right; color: #FF5722;">✓</text>
  103. </view>
  104. </scroll-view>
  105. </view>
  106. </view>
  107. </view>
  108. </template>
  109. <script>
  110. export default {
  111. data() {
  112. return {
  113. userInfo: {
  114. name: '张*哥',
  115. workType: '全职',
  116. workStatus: '接单中',
  117. city: '广东省 深圳市 龙华区',
  118. avatar: '/static/touxiang.png'
  119. },
  120. isStatusPickerShow: false,
  121. isCityPickerShow: false,
  122. // 城市选择相关
  123. cityStep: 0, // 0: 省, 1: 市, 2: 区
  124. selectedProvince: '',
  125. selectedCity: '',
  126. selectedDistrict: '',
  127. // 模拟数据
  128. provinces: ['广东省', '湖南省', '江西省'],
  129. cities: {
  130. '广东省': ['深圳市', '广州市', '东莞市'],
  131. '湖南省': ['长沙市', '株洲市'],
  132. '江西省': ['南昌市', '九江市']
  133. },
  134. districts: {
  135. '深圳市': ['龙华区', '南山区', '福田区', '宝安区'],
  136. '广州市': ['天河区', '越秀区', '海珠区'],
  137. '东莞市': ['南城区', '东城区'],
  138. '长沙市': ['岳麓区', '芙蓉区'],
  139. '南昌市': ['红谷滩区', '东湖区']
  140. }
  141. }
  142. },
  143. computed: {
  144. currentList() {
  145. if (this.cityStep === 0) {
  146. return this.provinces;
  147. } else if (this.cityStep === 1) {
  148. return this.cities[this.selectedProvince] || [];
  149. } else if (this.cityStep === 2) {
  150. return this.districts[this.selectedCity] || [];
  151. }
  152. return [];
  153. }
  154. },
  155. onLoad() {
  156. // 监听姓名修改
  157. uni.$on('updateName', (newName) => {
  158. this.userInfo.name = newName;
  159. });
  160. },
  161. onUnload() {
  162. uni.$off('updateName');
  163. },
  164. methods: {
  165. navBack() {
  166. uni.navigateBack({
  167. delta: 1
  168. });
  169. },
  170. changeAvatar() {
  171. uni.chooseImage({
  172. count: 1,
  173. success: (res) => {
  174. console.log(res.tempFilePaths);
  175. this.userInfo.avatar = res.tempFilePaths[0];
  176. }
  177. });
  178. },
  179. editName() {
  180. uni.navigateTo({
  181. url: `/pages/mine/settings/profile/edit-name?name=${this.userInfo.name}`
  182. });
  183. },
  184. toggleWorkType() {
  185. // 简单模拟切换
  186. this.userInfo.workType = this.userInfo.workType === '全职' ? '兼职' : '全职';
  187. },
  188. showStatusPicker() {
  189. this.isStatusPickerShow = true;
  190. },
  191. closeStatusPicker() {
  192. this.isStatusPickerShow = false;
  193. },
  194. selectStatus(status) {
  195. this.userInfo.workStatus = status;
  196. this.closeStatusPicker();
  197. },
  198. // 城市选择逻辑
  199. showCityPicker() {
  200. this.isCityPickerShow = true;
  201. // 初始化/重置
  202. this.cityStep = 0;
  203. this.selectedProvince = '';
  204. this.selectedCity = '';
  205. this.selectedDistrict = '';
  206. // 如果已有值,尝试回显 (这里简化处理,只重置)
  207. // 实际开发可解析 this.userInfo.city 进行回显
  208. },
  209. closeCityPicker() {
  210. this.isCityPickerShow = false;
  211. },
  212. changeCityStep(step) {
  213. this.cityStep = step;
  214. },
  215. selectItem(item) {
  216. if (this.cityStep === 0) {
  217. this.selectedProvince = item;
  218. this.cityStep = 1;
  219. this.selectedCity = ''; // 重置下级
  220. this.selectedDistrict = '';
  221. } else if (this.cityStep === 1) {
  222. this.selectedCity = item;
  223. this.cityStep = 2;
  224. this.selectedDistrict = '';
  225. } else if (this.cityStep === 2) {
  226. this.selectedDistrict = item;
  227. }
  228. },
  229. isSelected(item) {
  230. if (this.cityStep === 0) return this.selectedProvince === item;
  231. if (this.cityStep === 1) return this.selectedCity === item;
  232. if (this.cityStep === 2) return this.selectedDistrict === item;
  233. return false;
  234. },
  235. confirmCity() {
  236. if (this.selectedProvince && this.selectedCity && this.selectedDistrict) {
  237. this.userInfo.city = `${this.selectedProvince} ${this.selectedCity} ${this.selectedDistrict}`;
  238. this.closeCityPicker();
  239. } else {
  240. uni.showToast({
  241. title: '请选择完整的省市区',
  242. icon: 'none'
  243. });
  244. }
  245. }
  246. }
  247. }
  248. </script>
  249. <style>
  250. page {
  251. background-color: #F8F8F8;
  252. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  253. }
  254. .custom-header {
  255. position: fixed;
  256. top: 0;
  257. left: 0;
  258. width: 100%;
  259. height: 88rpx;
  260. padding-top: var(--status-bar-height);
  261. background-color: #fff;
  262. display: flex;
  263. align-items: center;
  264. justify-content: space-between;
  265. padding-left: 30rpx;
  266. padding-right: 30rpx;
  267. box-sizing: content-box;
  268. z-index: 100;
  269. }
  270. .header-placeholder {
  271. height: calc(88rpx + var(--status-bar-height));
  272. }
  273. .back-icon {
  274. width: 40rpx;
  275. height: 40rpx;
  276. }
  277. .header-title {
  278. font-size: 28rpx; /* 14pt */
  279. font-weight: bold;
  280. color: #333;
  281. }
  282. .header-right {
  283. width: 40rpx;
  284. }
  285. .container {
  286. padding: 20rpx 30rpx;
  287. }
  288. .group-card {
  289. background-color: #fff;
  290. border-radius: 20rpx;
  291. padding: 0 30rpx;
  292. margin-bottom: 30rpx;
  293. }
  294. .list-item {
  295. display: flex;
  296. justify-content: space-between;
  297. align-items: center;
  298. height: 100rpx;
  299. border-bottom: 1px solid #F5F5F5;
  300. }
  301. .list-item.no-border {
  302. border-bottom: none;
  303. }
  304. .item-title {
  305. font-size: 28rpx;
  306. color: #333;
  307. }
  308. .item-right {
  309. display: flex;
  310. align-items: center;
  311. }
  312. .arrow-icon {
  313. width: 28rpx;
  314. height: 28rpx;
  315. opacity: 0.5;
  316. margin-left: 10rpx;
  317. }
  318. .user-avatar {
  319. width: 64rpx; /* Smaller avatar */
  320. height: 64rpx;
  321. border-radius: 50%;
  322. }
  323. .item-value {
  324. font-size: 28rpx;
  325. color: #999;
  326. }
  327. .item-value-black {
  328. font-size: 28rpx;
  329. color: #333;
  330. font-weight: 500;
  331. }
  332. .tag-blue-outline {
  333. font-size: 24rpx;
  334. color: #2979FF;
  335. border: 1px solid #2979FF;
  336. padding: 4rpx 20rpx;
  337. border-radius: 30rpx;
  338. background-color: #fff;
  339. }
  340. /* Popup Styles */
  341. .popup-mask {
  342. position: fixed;
  343. top: 0;
  344. left: 0;
  345. width: 100%;
  346. height: 100%;
  347. background-color: rgba(0,0,0,0.5);
  348. z-index: 999;
  349. display: flex;
  350. align-items: flex-end;
  351. }
  352. .popup-content {
  353. width: 100%;
  354. background-color: #fff;
  355. border-top-left-radius: 20rpx;
  356. border-top-right-radius: 20rpx;
  357. padding-bottom: 30rpx; /* Safe area */
  358. }
  359. .popup-title {
  360. text-align: center;
  361. font-size: 28rpx;
  362. color: #999;
  363. padding: 30rpx 0;
  364. border-bottom: 1px solid #eee;
  365. }
  366. .popup-item {
  367. text-align: center;
  368. font-size: 32rpx;
  369. color: #333;
  370. padding: 30rpx 0;
  371. border-bottom: 1px solid #eee;
  372. }
  373. .popup-cancel {
  374. text-align: center;
  375. font-size: 32rpx;
  376. color: #333;
  377. padding: 30rpx 0;
  378. margin-top: 20rpx;
  379. border-top: 10rpx solid #f5f5f5;
  380. }
  381. .popup-header-row {
  382. display: flex;
  383. justify-content: space-between;
  384. padding: 30rpx;
  385. border-bottom: 1px solid #eee;
  386. }
  387. .popup-btn-cancel { font-size: 28rpx; color: #666; }
  388. .popup-title-text { font-size: 32rpx; font-weight: bold; color: #333; }
  389. .popup-btn-confirm { font-size: 28rpx; color: #FF5722; font-weight: bold; }
  390. .city-tabs {
  391. display: flex;
  392. padding: 20rpx 30rpx;
  393. border-bottom: 1px solid #eee;
  394. }
  395. .city-tab-item {
  396. font-size: 28rpx;
  397. margin-right: 40rpx;
  398. position: relative;
  399. padding-bottom: 10rpx;
  400. }
  401. .city-tab-item.active { color: #333; }
  402. .city-tab-item.active-red { color: #FF5722; font-weight: bold; }
  403. .city-tab-item.active-red::after {
  404. content: '';
  405. position: absolute;
  406. bottom: 0;
  407. left: 50%;
  408. transform: translateX(-50%);
  409. width: 40rpx;
  410. height: 4rpx;
  411. background-color: #FF5722;
  412. border-radius: 2rpx;
  413. }
  414. .city-list {
  415. height: 400rpx;
  416. }
  417. .city-item {
  418. padding: 30rpx;
  419. font-size: 28rpx;
  420. color: #333;
  421. }
  422. </style>