index.vue 18 KB

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