info.vue 18 KB

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