index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  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' :disabled="isAuthUpdate ? false : true " range-key="label">
  69. <view class="flex-row justify-end picker-change-store">
  70. <text>{{ userInfo.birthday ? userInfo.birthday.substring(0, 10) : '请选择出生日期' }}</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. <view v-if="userInfo.id" @click="unbindServiceObject" class="sure-btn">
  208. <view class="btn1">解绑</view>
  209. </view>
  210. <!-- 性别选择 -->
  211. <u-picker :show="genderShow" keyName="gender" @confirm="sureChooseGender" :columns="genderList"></u-picker>
  212. <cropper selWidth="660rpx" selHeight="660rpx" ref="cropper" quality="0.5" @uploadImg="uploadCropImg"
  213. @upload="userInfo.facePhotoUrl"/>
  214. </view>
  215. </template>
  216. <script>
  217. import cropper from '@/components/lxiaoxiao-cropper/lxiaoxiao-cropper.vue';
  218. export default {
  219. components: {
  220. cropper
  221. },
  222. data() {
  223. return {
  224. accessToken: null,
  225. isAuthUpdate: true,
  226. serviceProjectList: [],
  227. userInfo: {
  228. auth: true,
  229. nickName: '',
  230. sex: '1',
  231. birthday: '',
  232. selfPhoto: '',
  233. memberType: '',
  234. facePhotos: '',
  235. facePhoto: '',
  236. ranks: 0,
  237. wardship: '1',
  238. blood: '',
  239. ranksState: '0',
  240. facePhotoUrl: '',
  241. name: '',
  242. authBook: '',
  243. signPhoto: '',
  244. remark: '',
  245. serviceProjectId: []
  246. },
  247. genderShow: false,
  248. date: Number(new Date()),
  249. // 服务时间
  250. genderList: [
  251. [{gender: '男', id: '0'},
  252. {gender: '女', id: '1'},
  253. {gender: '未知', id: '2'}
  254. ],
  255. ],
  256. imgUrl1: '',
  257. requestStatus: false,
  258. };
  259. },
  260. mounted() {
  261. },
  262. onLoad(option) {
  263. this.accessToken = uni.getStorageSync("accessToken");
  264. this.getServiceObjectList()
  265. if (option.data) {
  266. const data = JSON.parse(option.data);
  267. console.log('+++++++JSON.parse(option.data)++++++', option.data)
  268. if (data.authServiceIds) {
  269. this.userInfo.serviceProjectId = data.authServiceIds.split(',');
  270. }
  271. this.userInfo.facePhotoUrl = data.facePhotoUrl;
  272. this.userInfo.isSelf = data.isSelf;
  273. this.userInfo.minMainCardStatus = data.minMainCardStatus;
  274. this.userInfo.facePhoto = data.facePhoto;
  275. this.userInfo.facePhotos = data.facePhoto;
  276. this.userInfo.birthday = data.birthday;
  277. this.userInfo.memberType = data.memberType;
  278. this.userInfo.ranks = data.ranks;
  279. this.userInfo.wardship = data.wardship;
  280. this.userInfo.blood = data.blood;
  281. this.userInfo.ranksState = data.ranksState;
  282. this.userInfo.name = data.name;
  283. this.userInfo.authBook = data.authBook;
  284. this.userInfo.signPhoto = data.signPhoto;
  285. this.userInfo.sex = data.sex;
  286. this.userInfo.nickName = data.nickName;
  287. this.userInfo.remark = data.remark;
  288. this.userInfo.id = data.id;
  289. if (this.userInfo.id && this.userInfo.isSelf != 1) {
  290. this.getServiceObjectPhotoRecord(this.userInfo.id)
  291. }
  292. console.log('+++++++JSON.parse(option.data)++++++', this.userInfo)
  293. }
  294. },
  295. methods: {
  296. unbindServiceObject() {
  297. let that = this
  298. uni.showModal({
  299. title: '温馨提示',
  300. content: '解绑后您将无法看到该服务对象的信息!确定解绑?',
  301. success: function (res) {
  302. if (res.confirm) {
  303. console.log('用户点击确定');
  304. that.$api.unbindServiceObject({
  305. id: that.userInfo.id
  306. }).then(res => {
  307. uni.showToast({
  308. icon: 'none',
  309. title: '解绑成功!'
  310. })
  311. })
  312. } else if (res.cancel) {
  313. console.log('用户点击取消');
  314. }
  315. }
  316. })
  317. },
  318. uploadCropImg(e) {
  319. uni.compressImage({
  320. src: e,
  321. success: res => {
  322. uni.uploadFile({
  323. url: this.$baseUrl + '/resource/oss/upload',
  324. filePath: res.tempFilePath,
  325. name: 'file',
  326. header: {
  327. 'Authorization': 'Bearer ' + uni.getStorageInfo('accessToken'),
  328. },
  329. success: (uploadFileRes) => {
  330. let res = JSON.parse(uploadFileRes.data)
  331. console.log(res, '成功回调')
  332. if (res.code !== 200) {
  333. uni.showToast({
  334. icon: 'none',
  335. duration: 3000,
  336. title: res.msg || '系统繁忙,请重试!'
  337. });
  338. }
  339. res.data.url.replace("http", "https");
  340. this.verifyFace(res.data)
  341. this.userInfo.facePhotoUrl = res.data.url.replace("http", "https");
  342. }
  343. });
  344. }
  345. })
  346. },
  347. getServiceObjectPhotoRecord(serviceObjectId) {
  348. this.$api.getServiceObjectPhotoRecord(
  349. {
  350. serviceObjectId: serviceObjectId
  351. }).then(res => {
  352. console.log(res)
  353. if (res.data.data) {
  354. uni.showModal({
  355. title: "温馨提示",
  356. content: "当前服务对象已授权,照片可修改",
  357. showCancel: false,
  358. success: function (res) {
  359. if (res.confirm) {
  360. console.log('用户点击确定');
  361. } else if (res.cancel) {
  362. console.log('用户点击取消');
  363. }
  364. }
  365. })
  366. }
  367. this.isAuthUpdate = res.data.data
  368. })
  369. },
  370. // 验证人象
  371. verifyFace(data) {
  372. let that = this;
  373. uni.showLoading({
  374. title: '人脸识别中'
  375. })
  376. if (this.requestStatus) {
  377. return;
  378. }
  379. this.requestStatus = true
  380. this.$api.verifyFace({
  381. auth: true,
  382. facePath: data.ossId,
  383. businessId: ''
  384. }).then((res) => {
  385. this.requestStatus = false
  386. uni.hideLoading();
  387. console.log(this.userInfo.id,'this.userInfo.id')
  388. console.log(res.data.data.id,'res.data.data.id')
  389. // 判断回调中的 id 是否等于原服务对象 id
  390. if (res.data && this.userInfo.id && res.data.data.id !== this.userInfo.id) {
  391. uni.showModal({
  392. title: '温馨提示',
  393. content: '人脸识别的服务对象与当前服务对象不一致,不允许修改照片!',
  394. showCancel: false,
  395. success: function (modalRes) {
  396. if (modalRes.confirm) {
  397. console.log('用户点击确定');
  398. // 清空人脸照片信息,不允许保存
  399. that.userInfo.facePhoto = '';
  400. that.userInfo.facePhotoUrl = '';
  401. }
  402. }
  403. })
  404. return;
  405. }
  406. this.userInfo.facePhoto = data.ossId
  407. this.userInfo.facePhotoUrl = data.url
  408. }).catch((err) => {
  409. this.requestStatus = false
  410. uni.$u.toast(err.data.msg || '识别失败,请重新上传照片')
  411. });
  412. },
  413. //修改数组属性名
  414. changeKey(arr, newName, oldName) {
  415. arr.forEach(item => {
  416. item[newName] = item[oldName]
  417. delete item[oldName]
  418. })
  419. return arr
  420. },
  421. getServiceObjectList() {
  422. this.$api.serviceProjectList().then(res => {
  423. this.serviceProjectList = res.data.data
  424. console.log()
  425. this.changeKey(this.serviceProjectList, 'value', 'id')
  426. this.changeKey(this.serviceProjectList, 'text', 'serviceName')
  427. })
  428. },
  429. increment() {
  430. this.userInfo.ranks++;
  431. },
  432. decrement() {
  433. if (this.userInfo.ranks > 1) {
  434. this.userInfo.ranks--;
  435. }
  436. },
  437. handleRankChange(value) {
  438. console.log('Rank changed:', value);
  439. this.userInfo.ranks = value;
  440. // 在这里处理值改变事件的逻辑
  441. },
  442. // 选择性别
  443. chooseGender() {
  444. this.genderShow = true;
  445. },
  446. // 选择值
  447. sureChooseGender(e) {
  448. this.genderShow = false;
  449. this.userInfo.sex = e.value[0].id;
  450. },
  451. // 确定选择的服务日期
  452. bindDateChange(e) {
  453. console.log(e)
  454. this.userInfo.birthday = e.detail.value
  455. },
  456. // 保存用户信息
  457. saveUserInfo() {
  458. console.log(this.userInfo)
  459. if (!this.userInfo.nickName) {
  460. uni.showToast({
  461. title: "请认真填写宝贝昵称",
  462. icon: "none"
  463. })
  464. return;
  465. }
  466. if (!this.userInfo.blood) {
  467. uni.showToast({
  468. title: "请认真填写关系",
  469. icon: "none"
  470. })
  471. return;
  472. }
  473. if (!this.userInfo.birthday) {
  474. uni.showToast({
  475. title: "请认真填写宝贝生日",
  476. icon: "none"
  477. })
  478. return;
  479. }
  480. if (this.requestStatus) {
  481. return;
  482. }
  483. this.requestStatus = true
  484. this.userInfo.auth = true;
  485. this.userInfo.authServiceIds = this.userInfo.serviceProjectId.join()
  486. if (this.userInfo.id) {
  487. // 修改数据
  488. this.$api.updateServiceObject(this.userInfo).then((res) => {
  489. console.log(res)
  490. uni.showToast({
  491. title: "修改成功"
  492. })
  493. setTimeout(() => {
  494. this.requestStatus = false
  495. // uni.reLaunch({
  496. // url: '/myPages/ServiceObjectManagement/index'
  497. // });
  498. uni.navigateBack({
  499. delta: 1
  500. });
  501. }, 2000)
  502. }).catch(() => {
  503. this.requestStatus = false
  504. })
  505. } else {
  506. // 保存数据
  507. this.$api.saveServiceObject(this.userInfo).then((res) => {
  508. console.log(res)
  509. uni.showToast({
  510. title: "保存成功"
  511. })
  512. setTimeout(() => {
  513. this.requestStatus = false
  514. // uni.reLaunch({
  515. // url: '/myPages/ServiceObjectManagement/index'
  516. // });
  517. uni.navigateBack({
  518. delta: 1
  519. });
  520. }, 2000)
  521. }).catch(() => {
  522. this.requestStatus = false
  523. })
  524. }
  525. },
  526. //头像上传
  527. uploadImg1(imgIndex) {
  528. console.log(this.isAuthUpdate)
  529. if (!this.isAuthUpdate){
  530. return //关闭头像上传
  531. }
  532. this.$refs.cropper.fSelect();
  533. // let that = this;
  534. // uni.chooseImage({
  535. // count: 1,
  536. // success: (chooseImageRes) => {
  537. // const tempFilePaths = chooseImageRes.tempFilePaths;
  538. // console.log(tempFilePaths)
  539. // uni.uploadFile({
  540. // url: that.$baseUrl + '/resource/oss/upload',
  541. // filePath: tempFilePaths[0],
  542. // name: 'file',
  543. //
  544. // header: {
  545. // // "Content-Type": "multipart/form-data",
  546. // // 'X-Access-Token': uni.getStorageSync('token'),
  547. // 'Authorization': 'Bearer ' + this.accessToken,
  548. // },
  549. // success: (uploadFileRes) => {
  550. // let res = JSON.parse(uploadFileRes.data)
  551. // console.log(res)
  552. // this.verifyFace(res.data)
  553. // },
  554. // fail: (err)=> {
  555. // console.log(err)
  556. // }
  557. // });
  558. // }
  559. // });
  560. }
  561. }
  562. };
  563. </script>
  564. <style lang="scss">
  565. .user-info-wrap {
  566. margin-left: 12px;
  567. margin-right: 12px;
  568. /* 导航菜单 */
  569. .nav-bar {
  570. background: #fff;
  571. border-radius: 10px;
  572. margin-top: 12px;
  573. /* 商店信息 */
  574. .nav-content {
  575. padding-right: 6px;
  576. padding-top: 10px;
  577. padding-bottom: 6px;
  578. .nav-info {
  579. display: flex;
  580. padding-left: 10px;
  581. align-items: center;
  582. .logo {
  583. width: 12%;
  584. text-align: center;
  585. image {
  586. width: 24px;
  587. height: 24px;
  588. }
  589. }
  590. .nav-desc {
  591. width: 46%;
  592. display: flex;
  593. line-height: 30px;
  594. font-family: PingFangSC-Regular, PingFang SC;
  595. font-weight: 400;
  596. align-items: center;
  597. .custom-input {
  598. font-size: 12px;
  599. }
  600. .nav-name {
  601. width: 60%;
  602. font-size: 14px;
  603. color: #333333;
  604. line-height: 22px;
  605. }
  606. .change-store {
  607. text-align: right;
  608. width: 40%;
  609. font-size: 12px;
  610. color: #333333;
  611. line-height: 22px;
  612. }
  613. }
  614. .arrow-right {
  615. width: 64%;
  616. /*text-align: right;*/
  617. margin: 0 auto;
  618. padding-top: 3px;
  619. display: flex;
  620. justify-content: flex-end;
  621. align-items: center;
  622. image {
  623. width: 18px;
  624. height: 18px;
  625. }
  626. .custom-input {
  627. font-size: 12px;
  628. width: 200rpx;
  629. /*border: 1px solid red;*/
  630. }
  631. .head-img {
  632. width: 50px;
  633. height: 50px;
  634. border-radius: 25px;
  635. text-align: center;
  636. padding-right: 20px;
  637. image {
  638. width: 50px;
  639. height: 50px;
  640. border-radius: 25px;
  641. }
  642. }
  643. .change-store {
  644. font-size: 14px;
  645. color: #999;
  646. line-height: 22px;
  647. }
  648. }
  649. }
  650. }
  651. }
  652. .sure-btn {
  653. margin-top: 20px;
  654. width: 100%;
  655. .btn {
  656. text-align: center;
  657. height: 42px;
  658. background: #FFE05C;
  659. border-radius: 27px;
  660. color: #333333;
  661. line-height: 42px;
  662. margin-top: 12px;
  663. font-size: 14px;
  664. }
  665. .btn1 {
  666. text-align: center;
  667. height: 42px;
  668. background: red;
  669. border-radius: 27px;
  670. color: #ffffff;
  671. line-height: 42px;
  672. margin-top: 12px;
  673. font-size: 14px;
  674. }
  675. }
  676. }
  677. .button-group {
  678. display: flex;
  679. align-items: center;
  680. }
  681. .button {
  682. padding: 6px 12px;
  683. font-size: 14px;
  684. background-color: #e6e6e6;
  685. border: none;
  686. border-radius: 4px;
  687. cursor: pointer;
  688. }
  689. .custom-input-ranks {
  690. width: 30px;
  691. font-size: 12px;
  692. text-align: center;
  693. }
  694. .radio-item {
  695. padding-right: 6px;
  696. }
  697. .picker-change-store {
  698. font-size: 14px;
  699. //color: #999;
  700. line-height: 22px;
  701. display: flex;
  702. flex-direction: row;
  703. }
  704. </style>