index.vue 19 KB

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