index.vue 16 KB

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