info.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. <template>
  2. <view style="position: relative;">
  3. <image class="page_bg" :src="form.backGround||defaultBg" mode="widthFix"></image>
  4. <view class="content-header">
  5. <image class="backicon" src="/static/image/liveStream/back_white_icon.png" mode="aspectFill"
  6. @click="$navBack()"></image>
  7. <view class="editinfo x-f">
  8. <image class="es-w-32 es-h-33 es-mr-12" src="/static/image/liveStream/change_bg_icon.png"
  9. mode="aspectFill" @tap="chooseImage('bg')"></image>设置背景
  10. </view>
  11. </view>
  12. <u-sticky offsetTop="0" customNavHeight="0" zIndex="999">
  13. <view class="content-header-sticky"
  14. :style="{height:`calc(${statusBarHeight}px + 44px)`,opacity:opacity,display:showNav? 'flex':'none'}"
  15. @click.stop="">
  16. <image src="/static/image/black_back.png" mode="aspectFill" @click="$navBack()"></image>
  17. </view>
  18. </u-sticky>
  19. <view class="content-body">
  20. <view class="content-box">
  21. <u--form ref="uForm" :rules="rules" :model="form" labelPosition="left" labelWidth="150rpx"
  22. errorType="toast">
  23. <view class="boxtitle">
  24. <text class="es-fw-600 es-fs-40">基础信息</text><text
  25. class="es-fw-400 es-fs-24 es-c-99 es-ml-24">(必填项)</text>
  26. </view>
  27. <u-form-item borderBottom label="头像" prop="avatar">
  28. <view class="x-f es-pe flex">
  29. <image class="head" @tap="chooseImage('avatar')" :src="form.avatar||'/static/images/detault_head.jpg'" mode="aspectFill"></image>
  30. <u-icon class="es-ml-14" name="arrow-right" size="14" bold color="#757575"></u-icon>
  31. </view>
  32. </u-form-item>
  33. <u-form-item borderBottom label="昵称" prop="nickName">
  34. <view class="x-f es-pe flex" @click="openPop('nickName')">
  35. <text class="placeholderClass" :style="{color: form.nickName ?'#222':'#999'}">{{form.nickName}}</text>
  36. <u-icon class="es-ml-14" name="arrow-right" size="14" bold color="#757575"></u-icon>
  37. </view>
  38. </u-form-item>
  39. <u-form-item borderBottom label="简介" prop="title">
  40. <view class="x-f es-pe flex" @click="openPop('title')">
  41. <text class="placeholderClass" :style="{color: form.title ?'#222':'#999'}">{{form.title || '介绍喜好、个性'}}</text>
  42. <u-icon class="es-ml-14" name="arrow-right" size="14" bold color="#757575"></u-icon>
  43. </view>
  44. </u-form-item>
  45. <u-form-item borderBottom label="性别" prop="sex">
  46. <picker class="x-f es-pe flex" @change="bindPickerChange($event)" :value="sexIndex" :range="sexArray">
  47. <view class="x-f es-pe flex">
  48. <text class="placeholderClass" :style="{color: form.sex === 0 || form.sex == 1 || form.sex == 2 ?'#222':'#999'}">
  49. {{form.sex === 0 ? '男' : form.sex == 1 ? '女' : form.sex == 2 ? '未知':'请选择性别'}}
  50. </text>
  51. <u-icon class="es-ml-14" name="arrow-right" size="14" bold color="#757575"></u-icon>
  52. </view>
  53. </picker>
  54. </u-form-item>
  55. <u-form-item borderBottom label="生日" prop="birthDay">
  56. <picker class="x-f es-pe flex" :value="birthDay" mode="date" fields="day" @change="birthdayChange">
  57. <view class="x-f es-pe flex">
  58. <text class="placeholderClass" :style="{color: form.birthDay ?'#222':'#999'}">
  59. {{form.birthDay ? form.birthDay.substring(0,10) : '请选择生日'}}
  60. </text>
  61. <u-icon class="es-ml-14" name="arrow-right" size="14" bold color="#757575"></u-icon>
  62. </view>
  63. </picker>
  64. </u-form-item>
  65. <u-form-item borderBottom label="手机号" prop="phone">
  66. <view class="x-f es-pe flex" @click="openPop('phone')">
  67. <text class="placeholderClass" :style="{color: form.phone ?'#222':'#999'}">{{form.phone || '请填写手机号'}}</text>
  68. <u-icon class="es-ml-14" name="arrow-right" size="14" bold color="#757575"></u-icon>
  69. </view>
  70. </u-form-item>
  71. <u-form-item borderBottom label="所在地" prop="address">
  72. <picker :value="multiIndex" class="x-f es-pe flex" mode="multiSelector" range-key="n" :range="addressList" @change="pickerChangeCity" @columnchange="pickerColumnchange">
  73. <view class="x-f es-pe flex">
  74. <text class="placeholderClass" :style="{color: form.address ?'#222':'#999'}">
  75. {{form.address ? form.address : '请选择所在地'}}
  76. </text>
  77. <u-icon class="es-ml-14" name="arrow-right" size="14" bold color="#757575"></u-icon>
  78. </view>
  79. </picker>
  80. </u-form-item>
  81. </u--form>
  82. </view>
  83. </view>
  84. <uni-popup ref="popup" type="bottom">
  85. <view class="popupbox">
  86. <view class="popupbox-head">
  87. <view class="popupbox-cancel" @tap="close">取消</view>
  88. <text class="popupbox-head-title">{{poptitle}}</text>
  89. <view class="popupbox-confirm" @tap="confirm">确定</view>
  90. </view>
  91. <view class="popupbox-body">
  92. <view class="inpubox" v-show="poptitle">
  93. <uni-easyinput :type="type" v-model="inputVal" :trim="true" :inputBorder="false" :primaryColor="'#c0c4cc'"
  94. placeholderClass="placeholderClass" placeholderStyle="color: #999" :placeholder="placeholder" :styles="inpuStyle" :maxlength="maxlength" />
  95. </view>
  96. </view>
  97. </view>
  98. </uni-popup>
  99. </view>
  100. </template>
  101. <script>
  102. import {
  103. getTalentByToken,
  104. updateTalent
  105. } from "@/api/expert.js"
  106. import {getCitys} from '@/api/common.js'
  107. export default {
  108. data() {
  109. return {
  110. userId: '',
  111. statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
  112. defaultBg: "https://cos.his.cdwjyyh.com/fs/20250509/e5fb40b2b6e640b48e5f055c786dd289.png",
  113. customNavHeight: 22,
  114. showNav: false,
  115. opacity: 1,
  116. form: {
  117. avatar:"",
  118. title: "",
  119. nickName: "",
  120. birthDay:"",
  121. phone:"",
  122. address:"",
  123. sex: 0,
  124. province:"",
  125. city: "",
  126. district: "",
  127. backGround: ""
  128. },
  129. rules: {
  130. // height: [{
  131. // required: true,
  132. // message: '请输入身高',
  133. // // 可以单个或者同时写两个触发验证方式
  134. // trigger: ['change', 'blur'],
  135. // }],
  136. // weight: [{
  137. // required: true,
  138. // message: '请输入体重',
  139. // // 可以单个或者同时写两个触发验证方式
  140. // trigger: ['change', 'blur'],
  141. // }],
  142. // mobile: [{
  143. // required: true,
  144. // message: '请输入联系电话',
  145. // // 可以单个或者同时写两个触发验证方式
  146. // trigger: ['change', 'blur'],
  147. // }],
  148. // isVisit: [{
  149. // required: true,
  150. // message: '请选择是否去医院就诊过',
  151. // // 可以单个或者同时写两个触发验证方式
  152. // trigger: ['change', 'blur'],
  153. // }],
  154. },
  155. user: {},
  156. birthDay: "",
  157. sexArray: ['男', '女','未知'],
  158. sexIndex: 0,
  159. addressList:[[],[],[]],
  160. multiIndex:[0,0,0],
  161. address:[],
  162. poptitle: "",
  163. placeholder: "",
  164. inputVal: "",
  165. type: "text",
  166. maxlength: 300,
  167. }
  168. },
  169. onLoad() {
  170. this.customNavHeight = this.statusBarHeight / 2 + 44;
  171. this.user = this.$getUserInfo()
  172. this.userId = this.user.userId || ''
  173. this.getInfo()
  174. this.getCitys()
  175. },
  176. methods: {
  177. getInfo() {
  178. getTalentByToken().then(res => {
  179. if (res.code == 200) {
  180. const info = res.data.fsUserTalent
  181. this.form = {
  182. avatar: info.avatar,
  183. title: info.title || '',
  184. nickName: info.nickName || '',
  185. birthDay: info.birthDay,
  186. phone: info.phone || '',
  187. address: info.address,
  188. province: info.province,
  189. city: info.city,
  190. district: info.district,
  191. sex: info.sex,
  192. backGround: info.backGround,
  193. }
  194. }
  195. })
  196. },
  197. // 选择照片
  198. async chooseImage(type) {
  199. // #ifdef APP-PLUS
  200. if (!plus.runtime.isAgreePrivacy()) {
  201. uni.showToast({
  202. title: "请同意隐私政策",
  203. icon: "none"
  204. });
  205. return;
  206. }
  207. let result = await premissionCheck("EXTERNAL_STORAGE");
  208. // #endif
  209. // #ifndef APP-PLUS
  210. let result = 1
  211. // #endif
  212. if (result == 1) {
  213. uni.chooseImage({
  214. count: 1, //默认9
  215. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  216. sourceType: ['album', 'camera'], //从相册选择
  217. success: (res) => {
  218. uni.uploadFile({
  219. url: uni.getStorageSync('requestPath') + '/app/common/uploadOSS', //仅为示例,非真实的接口地址
  220. filePath: res.tempFilePaths[0],
  221. name: 'file',
  222. formData: {
  223. 'user': 'test' // 上传附带参数
  224. },
  225. success: (uploadFileRes) => {
  226. console.log(uploadFileRes)
  227. // 根据接口具体返回格式 赋值具体对应url
  228. let data = JSON.parse(uploadFileRes.data)
  229. if(type == 'avatar') {
  230. this.form.avatar = data.url;
  231. } else {
  232. this.form.backGround = data.url;
  233. }
  234. this.submit()
  235. },
  236. fail: res=> {
  237. uni.showToast({
  238. title: "上传头像失败",
  239. icon: "none"
  240. })
  241. }
  242. });
  243. }
  244. });
  245. }
  246. },
  247. openPop(type) {
  248. if(type=="nickName") {
  249. this.poptitle = '昵称'
  250. this.placeholder = '请输入昵称'
  251. this.type = 'text'
  252. this.inputVal = this.form.nickName
  253. this.maxlength = 20
  254. } else if (type=="title") {
  255. this.poptitle = '简介'
  256. this.placeholder = '介绍喜好、个性'
  257. this.type = 'text'
  258. this.inputVal = this.form.title
  259. this.maxlength = 100
  260. } else if (type=="phone") {
  261. this.poptitle = '手机号'
  262. this.placeholder = '请输入手机号'
  263. this.type = 'number'
  264. this.inputVal = this.form.phone
  265. this.maxlength = 11
  266. }
  267. this.$refs.popup.open()
  268. },
  269. confirm() {
  270. if(this.poptitle=="昵称") {
  271. if (!this.inputVal.trim()) {
  272. uni.showToast({
  273. title: '请输入昵称',
  274. icon: "none"
  275. })
  276. return
  277. }
  278. this.form.nickName = this.inputVal
  279. } else if(this.poptitle=="简介") {
  280. if (!this.inputVal.trim()) {
  281. uni.showToast({
  282. title: '请输入简介',
  283. icon: "none"
  284. })
  285. return
  286. }
  287. this.form.title = this.inputVal
  288. } else if (this.poptitle=="手机号") {
  289. const reg = /^1[3-9]\d{9}$/;
  290. if (!reg.test(this.inputVal)) {
  291. uni.showToast({
  292. title: '请输入正确的手机号',
  293. icon: "none"
  294. })
  295. return
  296. }
  297. this.form.phone = this.inputVal
  298. }
  299. this.$refs.popup.close()
  300. this.submit()
  301. },
  302. close() {
  303. this.$refs.popup.close()
  304. },
  305. bindPickerChange(e) {
  306. this.sexIndex = e.detail.value
  307. this.form.sex = this.sexIndex
  308. this.submit()
  309. },
  310. // 生日
  311. birthdayChange(e) {
  312. this.birthDay = e.detail.value
  313. this.form.birthDay = this.birthDay
  314. this.submit()
  315. },
  316. // 地区选择
  317. pickerChangeCity(e) {
  318. this.multiIndex = e.detail.value;
  319. // 数组内的下标
  320. // 获取一级类目
  321. // 获取二级类目
  322. // 获取三级类目
  323. this.form.address=this.addressList[0][this.multiIndex[0]].n+this.addressList[1][this.multiIndex[1]].n+this.addressList[2][this.multiIndex[2]].n
  324. this.form.province=this.addressList[0][this.multiIndex[0]].n
  325. this.form.city=this.addressList[1][this.multiIndex[1]].n
  326. this.form.district=this.addressList[2][this.multiIndex[2]].n
  327. this.submit()
  328. },
  329. pickerColumnchange(e){
  330. // 第一列滑动
  331. if(e.detail.column === 0){
  332. this.multiIndex[0] = e.detail.value
  333. // console.log('第一列滑动');
  334. this.addressList[1] = this.address[this.multiIndex[0]].c;
  335. this.addressList[2] = this.address[this.multiIndex[0]].c[0].c
  336. // 第一列滑动 第二列 和第三列 都变为第一个
  337. this.multiIndex.splice(1, 1, 0)
  338. this.multiIndex.splice(2, 1, 0)
  339. }
  340. // 第二列滑动
  341. if(e.detail.column === 1){
  342. this.multiIndex[1] = e.detail.value
  343. // console.log('第二列滑动');
  344. // console.log(this.multiIndex)
  345. this.addressList[2] = this.address[this.multiIndex[0]].c[this.multiIndex[1]].c
  346. // 第二列 滑动 第三列 变成第一个
  347. this.multiIndex.splice(2, 1, 0)
  348. }
  349. // 第三列滑动
  350. if(e.detail.column === 2){
  351. this.multiIndex[2] = e.detail.value
  352. }
  353. },
  354. getCitys(){
  355. getCitys().then(
  356. res => {
  357. if(res.code==200){
  358. this.address=res.data
  359. for(var i=0; i<this.address.length; i++){
  360. this.addressList[0].push(this.address[i])
  361. }
  362. for(var i=0; i<this.address[0].c.length; i++){
  363. this.addressList[1].push(this.address[0].c[i])
  364. }
  365. for(var i=0; i<this.address[0].c[0].c.length; i++){
  366. this.addressList[2].push(this.address[0].c[0].c[i])
  367. }
  368. }else{
  369. uni.showToast({
  370. icon:'none',
  371. title: "请求失败",
  372. });
  373. }
  374. },
  375. rej => {}
  376. );
  377. },
  378. submit() {
  379. updateTalent(this.form).then(res=>{
  380. if(res.code != 200) {
  381. uni.showToast({
  382. title: res.msg,
  383. icon: 'none'
  384. })
  385. }
  386. })
  387. }
  388. },
  389. onPageScroll(e) {
  390. if (e.scrollTop <= 136) {
  391. this.showNav = false
  392. this.opacity = 0
  393. } else if (e.scrollTop > 136) {
  394. this.opacity = e.scrollTop / 216 * 1 > 1 ? 1 : e.scrollTop / 216 * 1
  395. this.showNav = true
  396. }
  397. }
  398. }
  399. </script>
  400. <style>
  401. page {
  402. background-color: #fff;
  403. }
  404. </style>
  405. <style lang="scss" scoped>
  406. @mixin u-flex($flexD, $alignI, $justifyC) {
  407. display: flex;
  408. flex-direction: $flexD;
  409. align-items: $alignI;
  410. justify-content: $justifyC;
  411. }
  412. ::v-deep {
  413. .u-form-item__body__left__content__label {
  414. font-family: PingFang SC, PingFang SC;
  415. font-weight: 400;
  416. font-size: 32rpx;
  417. color: #757575;
  418. }
  419. .placeholderClass {
  420. font-family: PingFang SC, PingFang SC;
  421. font-weight: 400;
  422. font-size: 32rpx;
  423. color: #999;
  424. }
  425. }
  426. .head{
  427. border-radius: 50%;
  428. width: 96rpx;
  429. height: 96rpx;
  430. }
  431. .page_bg {
  432. width: 100%;
  433. height: auto;
  434. position: absolute;
  435. top: 0;
  436. left: 0;
  437. }
  438. .content-header {
  439. position: relative;
  440. width: 100%;
  441. height: 44px;
  442. padding: 12rpx 24rpx;
  443. padding-top: calc(var(--status-bar-height) + 12rpx);
  444. @include u-flex(row-reverse, center, space-between);
  445. &-sticky {
  446. background-color: #fff;
  447. @include u-flex(row, center, center);
  448. position: absolute;
  449. width: 100%;
  450. image {
  451. width: 64rpx;
  452. height: 64rpx;
  453. position: absolute;
  454. top: calc(var(--status-bar-height) + 12rpx);
  455. left: 24rpx;
  456. }
  457. }
  458. }
  459. .backicon {
  460. width: 64rpx;
  461. height: 64rpx;
  462. position: fixed;
  463. left: 24rpx;
  464. top: calc(var(--status-bar-height) + 12rpx);
  465. z-index: 998;
  466. }
  467. .editinfo {
  468. background: rgba(0, 0, 0, 0.5);
  469. border-radius: 32rpx 32rpx 32rpx 32rpx;
  470. padding: 15rpx 28rpx;
  471. font-family: PingFang SC;
  472. font-weight: 400;
  473. font-size: 24rpx;
  474. color: #FFFFFF;
  475. }
  476. .content-body {
  477. font-family: PingFang SC;
  478. font-weight: 400;
  479. position: relative;
  480. color: #222222;
  481. padding-top: 240rpx;
  482. .content-box {
  483. background: #FFFFFF;
  484. border-radius: 32rpx 32rpx 0rpx 0rpx;
  485. padding: 32rpx;
  486. }
  487. .boxtitle {
  488. font-family: PingFang SC, PingFang SC;
  489. font-weight: 600;
  490. font-size: 40rpx;
  491. color: #222222;
  492. }
  493. .editinfo {
  494. font-family: PingFang SC, PingFang SC;
  495. font-weight: 400;
  496. font-size: 24rpx;
  497. color: #999999;
  498. }
  499. }
  500. .popupbox {
  501. background-color: #f7f7f7;
  502. font-family: PingFang SC, PingFang SC;
  503. font-weight: 500;
  504. font-size: 28rpx;
  505. color: #333333;
  506. &-head {
  507. padding: 24rpx;
  508. @include u-flex(row, center, space-between);
  509. &-title {
  510. font-size: 30rpx;
  511. }
  512. }
  513. &-cancel {
  514. color: #999;
  515. }
  516. &-confirm {
  517. color: #FF7700;
  518. }
  519. &-body {
  520. min-height: 100rpx;
  521. padding: 24px;
  522. box-sizing: border-box;
  523. }
  524. .inpubox {
  525. background-color: #fff;
  526. }
  527. }
  528. </style>