鸿宇研学生前端代码
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.

144 lines
3.0 KiB

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