index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  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.ranksState"
  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>
  184. <view @click="saveUserInfo()" class="sure-btn">
  185. <view class="btn">保存</view>
  186. </view>
  187. <!-- 性别选择 -->
  188. <u-picker :show="genderShow" keyName="gender" @confirm="sureChooseGender" :columns="genderList"></u-picker>
  189. </view>
  190. </template>
  191. <script>
  192. export default {
  193. data() {
  194. return {
  195. userInfo: {
  196. auth: true,
  197. nickName: '',
  198. sex: '1',
  199. birthday: '',
  200. selfPhoto: '',
  201. memberType: '',
  202. facePhotos: '',
  203. facePhoto: '',
  204. ranks: 0,
  205. wardship: '1',
  206. blood: '',
  207. ranksState: '0',
  208. facePhotoUrl: '',
  209. name: '',
  210. authBook: '',
  211. signPhoto: '',
  212. remark:''
  213. },
  214. genderShow: false,
  215. date: Number(new Date()),
  216. // 服务时间
  217. genderList: [
  218. [{gender:'男',id:'0'},
  219. {gender:'女',id:'1'},
  220. {gender:'未知',id:'2'}
  221. ],
  222. ],
  223. imgUrl1: '',
  224. requestStatus : false,
  225. };
  226. },
  227. mounted() {
  228. },
  229. onLoad(option) {
  230. if(option.data){
  231. const data = JSON.parse(option.data);
  232. console.log('+++++++JSON.parse(option.data)++++++',option.data)
  233. this.userInfo.facePhotoUrl = data.facePhotoUrl;
  234. this.userInfo.facePhoto = data.facePhoto;
  235. this.userInfo.facePhotos = data.facePhoto;
  236. this.userInfo.birthday = data.birthday;
  237. this.userInfo.memberType = data.memberType;
  238. this.userInfo.ranks = data.ranks;
  239. this.userInfo.wardship = data.wardship;
  240. this.userInfo.blood = data.blood;
  241. this.userInfo.ranksState = data.ranksState;
  242. this.userInfo.name = data.name;
  243. this.userInfo.authBook = data.authBook;
  244. this.userInfo.signPhoto = data.signPhoto;
  245. this.userInfo.sex = data.sex;
  246. this.userInfo.nickName = data.nickName;
  247. this.userInfo.remark = data.remark;
  248. this.userInfo.id = data.id;
  249. }
  250. },
  251. methods: {
  252. increment() {
  253. this.userInfo.ranks++;
  254. },
  255. decrement() {
  256. if (this.userInfo.ranks > 1) {
  257. this.userInfo.ranks--;
  258. }
  259. },
  260. handleRankChange(value) {
  261. console.log('Rank changed:', value);
  262. this.userInfo.ranks = value;
  263. // 在这里处理值改变事件的逻辑
  264. },
  265. // 选择性别
  266. chooseGender(){
  267. this.genderShow = true;
  268. },
  269. // 选择值
  270. sureChooseGender(e){
  271. this.genderShow = false;
  272. this.userInfo.sex = e.value[0].id;
  273. },
  274. // 确定选择的服务日期
  275. bindDateChange(e){
  276. console.log(e)
  277. this.userInfo.birthday = e.detail.value
  278. },
  279. // 保存用户信息
  280. saveUserInfo(){
  281. if(!this.userInfo.nickName){
  282. uni.showToast({
  283. title: "请认真填写宝贝昵称"
  284. })
  285. return;
  286. }
  287. if(!this.userInfo.blood){
  288. uni.showToast({
  289. title: "请认真填写关系"
  290. })
  291. return;
  292. }
  293. if(!this.userInfo.birthday){
  294. uni.showToast({
  295. title: "请认真填写宝贝生日"
  296. })
  297. return;
  298. }
  299. if(this.requestStatus){
  300. return;
  301. }
  302. this.requestStatus=true
  303. this.userInfo.auth = true;
  304. if (this.userInfo.id){
  305. // 修改数据
  306. this.$api.updateServiceObject(this.userInfo).then((res)=>{
  307. console.log(res)
  308. uni.showToast({
  309. title: "修改成功"
  310. })
  311. setTimeout(()=>{
  312. this.requestStatus=false
  313. // uni.reLaunch({
  314. // url: '/myPages/ServiceObjectManagement/index'
  315. // });
  316. uni.navigateBack({
  317. delta: 1
  318. });
  319. },2000)
  320. }).catch(()=>{
  321. this.requestStatus=false
  322. })
  323. }else{
  324. // 保存数据
  325. this.$api.saveServiceObject(this.userInfo).then((res)=>{
  326. console.log(res)
  327. uni.showToast({
  328. title: "保存成功"
  329. })
  330. setTimeout(()=>{
  331. this.requestStatus=false
  332. // uni.reLaunch({
  333. // url: '/myPages/ServiceObjectManagement/index'
  334. // });
  335. uni.navigateBack({
  336. delta: 1
  337. });
  338. },2000)
  339. }).catch(()=>{
  340. this.requestStatus=false
  341. })
  342. }
  343. },
  344. //头像上传
  345. uploadImg1(imgIndex) {
  346. return //关闭头像上传
  347. let that = this;
  348. uni.chooseImage({
  349. count: 1,
  350. success: (chooseImageRes) => {
  351. const tempFilePaths = chooseImageRes.tempFilePaths;
  352. uni.uploadFile({
  353. url: that.$host + '/resource/oss/upload', //仅为示例,非真实的接口地址
  354. filePath: tempFilePaths[0],
  355. name: 'file',
  356. header: {
  357. // "Content-Type": "multipart/form-data",
  358. // 'X-Access-Token': uni.getStorageSync('token'),
  359. 'Authorization': 'Bearer ' + that.$store.state.loginState.accessToken,
  360. },
  361. success: (uploadFileRes) => {
  362. let res = JSON.parse(uploadFileRes.data)
  363. console.log(res.data)
  364. that.imgUrl1 = res.data.url;
  365. that.userInfo.selfPhoto = res.data.ossId
  366. }
  367. });
  368. }
  369. });
  370. }
  371. }
  372. };
  373. </script>
  374. <style lang="scss">
  375. .user-info-wrap{
  376. margin-left: 12px;
  377. margin-right: 12px;
  378. /* 导航菜单 */
  379. .nav-bar{
  380. background: #fff;
  381. border-radius: 10px;
  382. margin-top: 12px;
  383. /* 商店信息 */
  384. .nav-content{
  385. padding-right: 6px;
  386. padding-top: 10px;
  387. padding-bottom: 6px;
  388. .nav-info{
  389. display: flex;
  390. padding-left: 10px;
  391. align-items: center;
  392. .logo {
  393. width: 12%;
  394. text-align: center;
  395. image{
  396. width: 24px;
  397. height: 24px;
  398. }
  399. }
  400. .nav-desc{
  401. width: 46%;
  402. display: flex;
  403. line-height: 30px;
  404. font-family: PingFangSC-Regular, PingFang SC;
  405. font-weight: 400;
  406. align-items: center;
  407. .custom-input{
  408. font-size: 12px;
  409. }
  410. .nav-name{
  411. width: 60%;
  412. font-size: 14px;
  413. color: #333333;
  414. line-height: 22px;
  415. }
  416. .change-store{
  417. text-align: right;
  418. width: 40%;
  419. font-size: 12px;
  420. color: #333333;
  421. line-height: 22px;
  422. }
  423. }
  424. .arrow-right{
  425. width:64%;
  426. /*text-align: right;*/
  427. margin: 0 auto;
  428. padding-top: 3px;
  429. display: flex;
  430. justify-content: flex-end;
  431. align-items: center;
  432. image{
  433. width: 18px;
  434. height: 18px;
  435. }
  436. .custom-input{
  437. font-size: 12px;
  438. width: 200rpx;
  439. /*border: 1px solid red;*/
  440. }
  441. .head-img {
  442. width: 50px;
  443. height: 50px;
  444. border-radius: 25px;
  445. text-align: center;
  446. padding-right: 20px;
  447. image{
  448. width: 50px;
  449. height: 50px;
  450. border-radius: 25px;
  451. }
  452. }
  453. .change-store{
  454. font-size: 14px;
  455. color: #999;
  456. line-height: 22px;
  457. }
  458. }
  459. }
  460. }
  461. }
  462. .sure-btn{
  463. margin-top: 20px;
  464. width: 100%;
  465. .btn{
  466. text-align: center;
  467. height: 42px;
  468. background: #FFE05C;
  469. border-radius: 27px;
  470. color: #333333;
  471. line-height: 42px;
  472. margin-top: 12px;
  473. font-size: 14px;
  474. }
  475. }
  476. }
  477. .button-group {
  478. display: flex;
  479. align-items: center;
  480. }
  481. .button {
  482. padding: 6px 12px;
  483. font-size: 14px;
  484. background-color: #e6e6e6;
  485. border: none;
  486. border-radius: 4px;
  487. cursor: pointer;
  488. }
  489. .custom-input-ranks{
  490. width: 30px;
  491. font-size: 12px;
  492. text-align: center;
  493. }
  494. .radio-item{
  495. padding-right: 6px;
  496. }
  497. .picker-change-store{
  498. font-size: 14px;
  499. color: #999;
  500. line-height: 22px;
  501. display: flex;
  502. flex-direction: row;
  503. }
  504. </style>