index.vue 12 KB

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