info.vue 18 KB

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