index.vue 12 KB

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