set-user-sex.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <view class="flex-common-css">
  3. <Nav title="性别设置" titleColor="#333" bgckgroundBox='#fff'></Nav>
  4. <scroll-view :scroll-y="true" class="scroll-view-css">
  5. <view class="content-box">
  6. <view class="list-box box-border-box mb-80 bgc-f">
  7. <view class="item-box flex-justify-space" v-for="(item,index) in sexList" :key="index" @click="setSex(item.id)">
  8. <view class="fs-32 fc-3">
  9. {{item.name}}
  10. </view>
  11. <uni-icons v-show="fromData.sex == item.id" color="#57CAFF" type="checkbox-filled" size="25"></uni-icons>
  12. </view>
  13. </view>
  14. <view class="but-box box-border-box" @click="save()">
  15. <view class="but fs-32 fc-f fw-600 b-rad-200 bgc-41ABF5 text-align-center" >
  16. 保存
  17. </view>
  18. </view>
  19. </view>
  20. </scroll-view>
  21. </view>
  22. </template>
  23. <script>
  24. import {userInfo,userUpdate} from '@/api/member.js';
  25. import tools from '@/service/tools';
  26. export default {
  27. data() {
  28. return {
  29. sexList:[
  30. {name:'保密',id:0},
  31. {name:'男',id:1},
  32. {name:'女',id:2},
  33. ],
  34. fromData:{
  35. nickname:'',
  36. head_img:'',
  37. sex:'',
  38. },
  39. isAJAX:false,
  40. };
  41. },
  42. onShow() {
  43. this.getUserInfo();
  44. },
  45. methods: {
  46. getUserInfo(){
  47. userInfo().then((res)=>{
  48. if(res.code === 1){
  49. this.fromData = res.data;
  50. }
  51. })
  52. },
  53. setSex(id) {
  54. if(this.fromData.sex != id){
  55. this.fromData.sex = id
  56. }
  57. },
  58. save(){
  59. if(this.isAJAX){
  60. return
  61. }
  62. this.isAJAX = true;
  63. userUpdate(this.fromData).then((res)=>{
  64. if(res.code === 1){
  65. this.isAJAX = false;
  66. tools.success(res.msg)
  67. }else{
  68. this.isAJAX = false;
  69. tools.error(res.msg)
  70. }
  71. })
  72. },
  73. },
  74. }
  75. </script>
  76. <style lang="scss" scoped>
  77. .content-box{
  78. padding: 20rpx 0 0 0;
  79. }
  80. .list-box{
  81. padding: 0 32rpx;
  82. }
  83. .item-box{
  84. height: 108rpx;
  85. line-height: 108rpx;
  86. border-bottom: 1rpx solid #EEEEEE;
  87. }
  88. .item-box:last-child {
  89. border: none;
  90. }
  91. .but-box{
  92. padding: 0 40rpx;
  93. }
  94. .but{
  95. width: 100%;
  96. height: 92rpx;
  97. line-height: 92rpx;
  98. }
  99. </style>