【PT.SCC实名制管理系统】24.10.01 -30天,考勤打卡小程序
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.

167 lines
3.4 KiB

1 year ago
1 year ago
  1. <!-- 用户信息 -->
  2. <template>
  3. <view class="login">
  4. <!-- logo -->
  5. <div class="logo">
  6. 打卡系统
  7. </div>
  8. <!-- 标题 -->
  9. <view class="login-title">工程项目打卡系统</view>
  10. <view class="title">
  11. 申请获取你的头像昵称
  12. </view>
  13. <button class="chooseAvatar" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  14. <view class="line">
  15. <view class="">
  16. 头像
  17. </view>
  18. <view class="">
  19. <image :src="userInfo.headImage" v-if="userInfo.headImage"
  20. style="width: 70rpx;height: 70rpx;border-radius: 50%;" mode="widthFix"></image>
  21. <!-- <image src="@/static/login/logo.png" v-else style="width: 70rpx;height: 70rpx;border-radius: 50%;" mode="widthFix"></image> -->
  22. </view>
  23. </view>
  24. </button>
  25. <view class="line">
  26. <view class="">
  27. 昵称
  28. </view>
  29. <view class="">
  30. <input type="nickname" placeholder="请输入昵称" style="text-align: right;" id="nickName"
  31. v-model="userInfo.nickName" />
  32. </view>
  33. </view>
  34. <view class="btn" @click="submit">
  35. 确认
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. data() {
  42. return {
  43. userInfo: {
  44. headImage: '../static/login/user.png', //设置了一个本地默认头像
  45. nickName: '',
  46. name: ''
  47. }
  48. };
  49. },
  50. onShow() {},
  51. computed: {},
  52. methods: {
  53. onChooseAvatar(res) {
  54. let self = this
  55. self.$Oss.ossUpload(res.target.avatarUrl)
  56. .then(url => {
  57. self.userInfo.headImage = url
  58. })
  59. },
  60. submit() {
  61. let self = this
  62. uni.createSelectorQuery().in(this)
  63. .select("#nickName")
  64. .fields({
  65. properties: ["value"],
  66. })
  67. .exec((res) => {
  68. const nickName = res?.[0]?.value
  69. self.userInfo.nickName = nickName
  70. self.userInfo.name = nickName
  71. if (self.$utils.verificationAll(self.userInfo, {
  72. headImage: '请选择头像',
  73. nickName: '请填写昵称',
  74. })) {
  75. return
  76. }
  77. // self.$api('updateInfo', self.userInfo, res => {
  78. // if (res.code == 200) {
  79. // this.replushUserInfo()
  80. // uni.switchTab({
  81. // url: '/pages/repair/repair'
  82. // })
  83. // }
  84. // })
  85. uni.reLaunch({
  86. url: "/pages/team/team"
  87. })
  88. })
  89. },
  90. //刷新存放在vuex的用户信息
  91. replushUserInfo() {
  92. this.$api('getUserInfo', res => {
  93. if (res.code == 200) {
  94. this.$store.commit('setUserInfo', res.result)
  95. }
  96. })
  97. }
  98. }
  99. }
  100. </script>
  101. <style lang="scss" scoped>
  102. .login {
  103. display: flex;
  104. flex-direction: column;
  105. justify-content: center;
  106. align-items: center;
  107. height: 100vh;
  108. // logo
  109. .logo {
  110. display: flex;
  111. align-items: center;
  112. justify-content: center;
  113. padding: 20rpx 0rpx;
  114. width: 40%;
  115. color: white;
  116. background: linear-gradient(180deg, #4C9EEA, #6DB9FF);
  117. border-radius: 45rpx 13rpx 45rpx 13rpx;
  118. font-size: 60rpx;
  119. }
  120. // 标题
  121. .login-title {
  122. font-size: 40rpx;
  123. font-weight: bold;
  124. margin: 20rpx 0rpx;
  125. }
  126. .line {
  127. display: flex;
  128. justify-content: space-between;
  129. align-items: center;
  130. width: 80%;
  131. border-bottom: 1px solid #00000023;
  132. padding: 30rpx 0;
  133. margin: 0 auto;
  134. }
  135. .chooseAvatar {
  136. width: 100%;
  137. padding: 0;
  138. margin: 0;
  139. margin-top: 10vh;
  140. border: none;
  141. }
  142. .btn {
  143. // background: $uni-linear-gradient-btn-color;
  144. background: $main-color;
  145. color: #fff;
  146. width: 80%;
  147. padding: 30rpx 0;
  148. border-radius: 100rpx;
  149. text-align: center;
  150. margin-top: 10vh;
  151. }
  152. }
  153. </style>