index.vue 18 KB

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