鸿宇研学生前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

157 lines
3.2 KiB

1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="page__view">
  3. <navbar title="选择角色" leftClick @leftClick="$utils.navigateBack" bgColor="transparent" color="#191919" />
  4. <view class="main">
  5. <view class="card">
  6. <view class="card-header">角色信息</view>
  7. <view class="card-content">
  8. <uv-radio-group
  9. v-model="role"
  10. placement="column"
  11. size="36rpx"
  12. iconSize="36rpx"
  13. activeColor="#00A9FF"
  14. >
  15. <view class="flex option" v-for="item in roleOptions" :key="item.id" @click="onSelect(item.value)">
  16. <view>
  17. <uv-radio :name="item.value"></uv-radio>
  18. </view>
  19. <view>{{ item.label }}</view>
  20. </view>
  21. </uv-radio-group>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="flex bottom">
  26. <view class="flex bar">
  27. <button class="btn" @click="onConfirm">确定</button>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. data() {
  35. return {
  36. role: null,
  37. roleOptions: [],
  38. }
  39. },
  40. onLoad() {
  41. this.roleOptions = [
  42. { id: '001', label: '家长', value: '0' },
  43. { id: '002', label: '学生', value: '1' },
  44. ]
  45. this.role = this.roleOptions[0].value
  46. },
  47. methods: {
  48. onSelect(val) {
  49. this.role = val
  50. },
  51. async onConfirm() {
  52. try {
  53. const {
  54. nickName,
  55. phone,
  56. } = this.userInfo
  57. const params = {
  58. nickName,
  59. phone,
  60. role: this.role
  61. }
  62. await this.$fetch('updateInfo', params, false)
  63. uni.showToast({
  64. icon: 'success',
  65. title: '保存成功',
  66. });
  67. this.$store.commit('getUserInfo')
  68. setTimeout(() => {
  69. uni.reLaunch({
  70. url:'/pages/index/index'
  71. })
  72. }, 800)
  73. } catch (err) {
  74. }
  75. },
  76. },
  77. }
  78. </script>
  79. <style scoped lang="scss">
  80. .page__view {
  81. background-image: linear-gradient(#DAF3FF, #F3F3F3 200rpx, #F3F3F3);
  82. }
  83. .main {
  84. padding: 24rpx 40rpx;
  85. }
  86. .card {
  87. width: 100%;
  88. height: 100%;
  89. padding: 32rpx 32rpx 450rpx 32rpx;
  90. box-sizing: border-box;
  91. background: #FFFFFF;
  92. border-radius: 24rpx;
  93. &-header {
  94. font-size: 32rpx;
  95. font-weight: 500;
  96. color: #181818;
  97. }
  98. }
  99. .option {
  100. margin-top: 32rpx;
  101. width: 100%;
  102. height: 252rpx;
  103. justify-content: flex-start;
  104. column-gap: 24rpx;
  105. padding: 24rpx;
  106. box-sizing: border-box;
  107. background: #F5F8FF;
  108. border-radius: 24rpx;
  109. &:nth-child(2n) {
  110. background: #F9F9F9;
  111. }
  112. }
  113. .bottom {
  114. position: fixed;
  115. left: 0;
  116. bottom: 0;
  117. width: 100vw;
  118. height: 146rpx;
  119. padding-bottom: env(safe-area-inset-bottom);
  120. background: #FFFFFF;
  121. .bar {
  122. width: 100%;
  123. padding: 0 40rpx;
  124. box-sizing: border-box;
  125. }
  126. .btn {
  127. width: 100%;
  128. padding: 16rpx 0;
  129. box-sizing: border-box;
  130. font-size: 36rpx;
  131. color: #FFFFFF;
  132. background-image: linear-gradient(to right, #21FEEC, #019AF9);
  133. border: 2rpx solid $uni-color;
  134. border-radius: 42rpx;
  135. }
  136. }
  137. </style>