index.vue 18 KB

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