【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.

171 lines
3.6 KiB

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