index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. <template>
  2. <view class="user-info-wrap">
  3. <view class="nav-bar">
  4. <view class="nav-content">
  5. <view class="nav-info">
  6. <view class="nav-desc">
  7. <view class="nav-name">
  8. <!-- <view class="">宝贝头像</view>-->
  9. </view>
  10. </view>
  11. <view class="arrow-right">
  12. <view class="head-img" @click="uploadImg1(1)">
  13. <image v-if="userInfo.facePhotoUrl" :src="userInfo.facePhotoUrl" mode="aspectFill"></image>
  14. <image v-else src="../../static/me/u1796.png" mode=""></image>
  15. </view>
  16. <!-- <u-icon name="arrow-right" color="#666" size="26"></u-icon> -->
  17. </view>
  18. </view>
  19. </view>
  20. <view class="custom-line"></view>
  21. <view class="nav-content">
  22. <view class="nav-info">
  23. <view class="nav-desc">
  24. <view class="nav-name">
  25. <view class="">宝贝昵称</view>
  26. </view>
  27. </view>
  28. <view class="arrow-right">
  29. <input class="custom-input" v-model="userInfo.nickName" type="text" placeholder="请输入昵称">
  30. </view>
  31. </view>
  32. </view>
  33. <view class="custom-line"></view>
  34. <view class="nav-content">
  35. <view class="nav-info">
  36. <view class="nav-desc">
  37. <view class="nav-name">
  38. <view class="">宝贝性别</view>
  39. </view>
  40. </view>
  41. <view @click="chooseGender()" class="arrow-right">
  42. <view class="change-store">
  43. <text v-if="userInfo.sex == 0">男</text>
  44. <text v-else-if="userInfo.sex == 1">女</text>
  45. <text v-else-if="userInfo.sex == 2">未知</text>
  46. <text v-else>请选择性别</text>
  47. </view>
  48. <u-icon name="arrow-right" color="#666" size="16"></u-icon>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="custom-line"></view>
  53. <view class="nav-content">
  54. <view class="nav-info">
  55. <view class="nav-desc">
  56. <view class="nav-name">
  57. <view class="">宝贝生日</view>
  58. </view>
  59. </view>
  60. <view class="arrow-right">
  61. <!-- <picker mode="date" :value="date" :start="date" @change="bindDateChange">-->
  62. <!-- <view class="picker-change-store">-->
  63. <!-- <text v-if="userInfo.birthday">{{ userInfo.birthday }}</text>-->
  64. <!-- <text v-else>请选择生日</text>-->
  65. <!-- <u-icon name="arrow-right" color="#666" size="16"></u-icon>-->
  66. <!-- </view>-->
  67. <!-- </picker>-->
  68. <picker @change="bindDateChange" mode='date' range-key="label" >
  69. <view class="flex-row justify-end picker-change-store">
  70. <text>{{userInfo.birthday || '请选择出生日期' }}</text>
  71. <u-icon name="arrow-right" color="#666" size="16"></u-icon>
  72. </view>
  73. </picker>
  74. </view>
  75. </view>
  76. </view>
  77. <view class="custom-line"></view>
  78. <view class="nav-content">
  79. <view class="nav-info">
  80. <view class="nav-desc">
  81. <view class="nav-name">
  82. <view class="">是否双胞胎</view>
  83. </view>
  84. </view>
  85. <view class="arrow-right">
  86. <view class="change-store">
  87. <u-radio-group
  88. v-model="userInfo.ranks"
  89. size="14"
  90. @change="handleRankChange"
  91. placement="row">
  92. <u-radio activeColor="#eac00f" name="0" label="否"></u-radio>
  93. <u-radio activeColor="#eac00f" name="1" label="是"></u-radio>
  94. </u-radio-group>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. <view v-if="userInfo.ranksState == '1'" class="custom-line"></view>
  100. <view v-if="userInfo.ranksState == '1'" class="nav-content">
  101. <view class="nav-info">
  102. <view class="nav-desc">
  103. <view class="nav-name">
  104. <view class="">宝贝排行</view>
  105. </view>
  106. </view>
  107. <view class="arrow-right button-group">
  108. <text class="button" @click="decrement">-</text>
  109. <input class="custom-input-ranks" v-model="userInfo.ranks" type="number">
  110. <text class="button" @click="increment">+</text>
  111. </view>
  112. <!-- <view @click="gotoRealNameAuth()" class="arrow-right">
  113. <view class="change-store">
  114. <u-radio-group
  115. v-model="userInfo.ranks"
  116. size="14"
  117. placement="row">
  118. <u-radio activeColor="#eac00f" name="1" label="老大"></u-radio>
  119. <u-radio activeColor="#eac00f" name="2" label="老二"></u-radio>
  120. <u-radio activeColor="#eac00f" name="3" label="老三"></u-radio>
  121. <u-radio activeColor="#eac00f" name="4" label="老四"></u-radio>
  122. </u-radio-group>
  123. </view>
  124. </view> -->
  125. </view>
  126. </view>
  127. <view class="custom-line"></view>
  128. <!-- <view class="nav-content">
  129. <view class="nav-info">
  130. <view class="nav-desc">
  131. <view class="nav-name">
  132. <view class="">服务对象编号</view>
  133. </view>
  134. </view>
  135. <view @click="gotoRealNameAuth()" class="arrow-right">
  136. <view class="change-store">
  137. <text>NTML0801</text>
  138. </view>
  139. </view>
  140. </view>
  141. </view>
  142. <view class="custom-line"></view> -->
  143. <view class="nav-content">
  144. <view class="nav-info">
  145. <view class="nav-desc">
  146. <view class="nav-name">
  147. <view class="">关系</view>
  148. </view>
  149. </view>
  150. <view class="arrow-right">
  151. <input class="custom-input" v-model="userInfo.blood" type="text" placeholder="请输入关系">
  152. </view>
  153. </view>
  154. </view>
  155. <view class="custom-line"></view>
  156. <view class="nav-content">
  157. <view class="nav-info">
  158. <view class="nav-desc">
  159. <view class="nav-name">
  160. <view class="">是否监护人</view>
  161. </view>
  162. </view>
  163. <view class="arrow-right">
  164. <view class="change-store">
  165. <u-radio-group
  166. size="14"
  167. v-model="userInfo.wardship"
  168. placement="row">
  169. <u-radio class="radio-item" activeColor="#eac00f" name="2" label="否"></u-radio>
  170. <u-radio class="radio-item" activeColor="#eac00f" name="1" label="是"></u-radio>
  171. </u-radio-group>
  172. </view>
  173. </view>
  174. </view>
  175. </view>
  176. <view class="custom-line"></view>
  177. <view class="nav-content">
  178. <view class="nav-info">
  179. <view class="nav-desc">
  180. <view class="nav-name">
  181. <view class="">备注</view>
  182. </view>
  183. </view>
  184. <view class="arrow-right">
  185. <input class="custom-input" v-model="userInfo.remark" type="text" placeholder="请输入备注">
  186. </view>
  187. </view>
  188. </view>
  189. <view class="custom-line"></view>
  190. <view class="nav-content" v-if="userInfo.minMainCardStatus">
  191. <view class="nav-info" style="align-items: normal">
  192. <view class="nav-desc">
  193. <view class="nav-name">
  194. <view class="">服务项目</view>
  195. </view>
  196. </view>
  197. <view class="arrow-right">
  198. <uni-data-checkbox mode="button" multiple v-model="userInfo.serviceProjectId"
  199. :localdata="serviceProjectList"/>
  200. </view>
  201. </view>
  202. </view>
  203. </view>
  204. <view @click="saveUserInfo()" class="sure-btn">
  205. <view class="btn">保存</view>
  206. </view>
  207. <!-- 性别选择 -->
  208. <u-picker :show="genderShow" keyName="gender" @confirm="sureChooseGender" :columns="genderList"></u-picker>
  209. </view>
  210. </template>
  211. <script>
  212. export default {
  213. data() {
  214. return {
  215. serviceProjectList: [],
  216. userInfo: {
  217. auth: true,
  218. nickName: '',
  219. sex: '1',
  220. birthday: '',
  221. selfPhoto: '',
  222. memberType: '',
  223. facePhotos: '',
  224. facePhoto: '',
  225. ranks: 0,
  226. wardship: '1',
  227. blood: '',
  228. ranksState: '0',
  229. facePhotoUrl: '',
  230. name: '',
  231. authBook: '',
  232. signPhoto: '',
  233. remark: '',
  234. serviceProjectId: []
  235. },
  236. genderShow: false,
  237. date: Number(new Date()),
  238. // 服务时间
  239. genderList: [
  240. [{gender: '男', id: '0'},
  241. {gender: '女', id: '1'},
  242. {gender: '未知', id: '2'}
  243. ],
  244. ],
  245. imgUrl1: '',
  246. requestStatus: false,
  247. };
  248. },
  249. mounted() {
  250. },
  251. onLoad(option) {
  252. this.getServiceObjectList()
  253. if (option.data) {
  254. const data = JSON.parse(option.data);
  255. console.log('+++++++JSON.parse(option.data)++++++', option.data)
  256. if(data.authServiceIds){
  257. this.userInfo.serviceProjectId = data.authServiceIds.split(',');
  258. }
  259. this.userInfo.facePhotoUrl = data.facePhotoUrl;
  260. this.userInfo.minMainCardStatus = data.minMainCardStatus;
  261. this.userInfo.facePhoto = data.facePhoto;
  262. this.userInfo.facePhotos = data.facePhoto;
  263. this.userInfo.birthday = data.birthday;
  264. this.userInfo.memberType = data.memberType;
  265. this.userInfo.ranks = data.ranks;
  266. this.userInfo.wardship = data.wardship;
  267. this.userInfo.blood = data.blood;
  268. this.userInfo.ranksState = data.ranksState;
  269. this.userInfo.name = data.name;
  270. this.userInfo.authBook = data.authBook;
  271. this.userInfo.signPhoto = data.signPhoto;
  272. this.userInfo.sex = data.sex;
  273. this.userInfo.nickName = data.nickName;
  274. this.userInfo.remark = data.remark;
  275. this.userInfo.id = data.id;
  276. console.log('+++++++JSON.parse(option.data)++++++', this.userInfo)
  277. }
  278. },
  279. methods: {
  280. //修改数组属性名
  281. changeKey(arr, newName, oldName) {
  282. arr.forEach(item => {
  283. item[newName] = item[oldName]
  284. delete item[oldName]
  285. })
  286. return arr
  287. },
  288. getServiceObjectList() {
  289. this.$api.serviceProjectList().then(res => {
  290. this.serviceProjectList = res.data.data
  291. console.log()
  292. this.changeKey(this.serviceProjectList, 'value', 'id')
  293. this.changeKey(this.serviceProjectList, 'text', 'serviceName')
  294. })
  295. },
  296. increment() {
  297. this.userInfo.ranks++;
  298. },
  299. decrement() {
  300. if (this.userInfo.ranks > 1) {
  301. this.userInfo.ranks--;
  302. }
  303. },
  304. handleRankChange(value) {
  305. console.log('Rank changed:', value);
  306. this.userInfo.ranks = value;
  307. // 在这里处理值改变事件的逻辑
  308. },
  309. // 选择性别
  310. chooseGender() {
  311. this.genderShow = true;
  312. },
  313. // 选择值
  314. sureChooseGender(e) {
  315. this.genderShow = false;
  316. this.userInfo.sex = e.value[0].id;
  317. },
  318. // 确定选择的服务日期
  319. bindDateChange(e) {
  320. console.log(e)
  321. this.userInfo.birthday = e.detail.value
  322. },
  323. // 保存用户信息
  324. saveUserInfo() {
  325. if (!this.userInfo.nickName) {
  326. uni.showToast({
  327. title: "请认真填写宝贝昵称"
  328. })
  329. return;
  330. }
  331. if (!this.userInfo.blood) {
  332. uni.showToast({
  333. title: "请认真填写关系"
  334. })
  335. return;
  336. }
  337. if (!this.userInfo.birthday) {
  338. uni.showToast({
  339. title: "请认真填写宝贝生日"
  340. })
  341. return;
  342. }
  343. if (this.requestStatus) {
  344. return;
  345. }
  346. this.requestStatus = true
  347. this.userInfo.auth = true;
  348. this.userInfo.authServiceIds = this.userInfo.serviceProjectId.join()
  349. if (this.userInfo.id) {
  350. // 修改数据
  351. this.$api.updateServiceObject(this.userInfo).then((res) => {
  352. console.log(res)
  353. uni.showToast({
  354. title: "修改成功"
  355. })
  356. setTimeout(() => {
  357. this.requestStatus = false
  358. // uni.reLaunch({
  359. // url: '/myPages/ServiceObjectManagement/index'
  360. // });
  361. uni.navigateBack({
  362. delta: 1
  363. });
  364. }, 2000)
  365. }).catch(() => {
  366. this.requestStatus = false
  367. })
  368. } else {
  369. // 保存数据
  370. this.$api.saveServiceObject(this.userInfo).then((res) => {
  371. console.log(res)
  372. uni.showToast({
  373. title: "保存成功"
  374. })
  375. setTimeout(() => {
  376. this.requestStatus = false
  377. // uni.reLaunch({
  378. // url: '/myPages/ServiceObjectManagement/index'
  379. // });
  380. uni.navigateBack({
  381. delta: 1
  382. });
  383. }, 2000)
  384. }).catch(() => {
  385. this.requestStatus = false
  386. })
  387. }
  388. },
  389. //头像上传
  390. uploadImg1(imgIndex) {
  391. return //关闭头像上传
  392. let that = this;
  393. uni.chooseImage({
  394. count: 1,
  395. success: (chooseImageRes) => {
  396. const tempFilePaths = chooseImageRes.tempFilePaths;
  397. uni.uploadFile({
  398. url: that.$host + '/resource/oss/upload', //仅为示例,非真实的接口地址
  399. filePath: tempFilePaths[0],
  400. name: 'file',
  401. header: {
  402. // "Content-Type": "multipart/form-data",
  403. // 'X-Access-Token': uni.getStorageSync('token'),
  404. 'Authorization': 'Bearer ' + that.$store.state.loginState.accessToken,
  405. },
  406. success: (uploadFileRes) => {
  407. let res = JSON.parse(uploadFileRes.data)
  408. console.log(res.data)
  409. that.imgUrl1 = res.data.url;
  410. that.userInfo.selfPhoto = res.data.ossId
  411. }
  412. });
  413. }
  414. });
  415. }
  416. }
  417. };
  418. </script>
  419. <style lang="scss">
  420. .user-info-wrap {
  421. margin-left: 12px;
  422. margin-right: 12px;
  423. /* 导航菜单 */
  424. .nav-bar {
  425. background: #fff;
  426. border-radius: 10px;
  427. margin-top: 12px;
  428. /* 商店信息 */
  429. .nav-content {
  430. padding-right: 6px;
  431. padding-top: 10px;
  432. padding-bottom: 6px;
  433. .nav-info {
  434. display: flex;
  435. padding-left: 10px;
  436. align-items: center;
  437. .logo {
  438. width: 12%;
  439. text-align: center;
  440. image {
  441. width: 24px;
  442. height: 24px;
  443. }
  444. }
  445. .nav-desc {
  446. width: 46%;
  447. display: flex;
  448. line-height: 30px;
  449. font-family: PingFangSC-Regular, PingFang SC;
  450. font-weight: 400;
  451. align-items: center;
  452. .custom-input {
  453. font-size: 12px;
  454. }
  455. .nav-name {
  456. width: 60%;
  457. font-size: 14px;
  458. color: #333333;
  459. line-height: 22px;
  460. }
  461. .change-store {
  462. text-align: right;
  463. width: 40%;
  464. font-size: 12px;
  465. color: #333333;
  466. line-height: 22px;
  467. }
  468. }
  469. .arrow-right {
  470. width: 64%;
  471. /*text-align: right;*/
  472. margin: 0 auto;
  473. padding-top: 3px;
  474. display: flex;
  475. justify-content: flex-end;
  476. align-items: center;
  477. image {
  478. width: 18px;
  479. height: 18px;
  480. }
  481. .custom-input {
  482. font-size: 12px;
  483. width: 200rpx;
  484. /*border: 1px solid red;*/
  485. }
  486. .head-img {
  487. width: 50px;
  488. height: 50px;
  489. border-radius: 25px;
  490. text-align: center;
  491. padding-right: 20px;
  492. image {
  493. width: 50px;
  494. height: 50px;
  495. border-radius: 25px;
  496. }
  497. }
  498. .change-store {
  499. font-size: 14px;
  500. color: #999;
  501. line-height: 22px;
  502. }
  503. }
  504. }
  505. }
  506. }
  507. .sure-btn {
  508. margin-top: 20px;
  509. width: 100%;
  510. .btn {
  511. text-align: center;
  512. height: 42px;
  513. background: #FFE05C;
  514. border-radius: 27px;
  515. color: #333333;
  516. line-height: 42px;
  517. margin-top: 12px;
  518. font-size: 14px;
  519. }
  520. }
  521. }
  522. .button-group {
  523. display: flex;
  524. align-items: center;
  525. }
  526. .button {
  527. padding: 6px 12px;
  528. font-size: 14px;
  529. background-color: #e6e6e6;
  530. border: none;
  531. border-radius: 4px;
  532. cursor: pointer;
  533. }
  534. .custom-input-ranks {
  535. width: 30px;
  536. font-size: 12px;
  537. text-align: center;
  538. }
  539. .radio-item {
  540. padding-right: 6px;
  541. }
  542. .picker-change-store {
  543. font-size: 14px;
  544. color: #999;
  545. line-height: 22px;
  546. display: flex;
  547. flex-direction: row;
  548. }
  549. </style>