酒店桌布为微信小程序
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.

135 lines
2.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
  1. <template>
  2. <view class="login">
  3. <view class="title">
  4. 布周到
  5. </view>
  6. <view class="title">
  7. 申请获取你的头像昵称
  8. </view>
  9. <button class="chooseAvatar" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  10. <view class="line">
  11. <view class="">
  12. 头像
  13. </view>
  14. <view class="">
  15. <image :src="userInfo.headImage" v-if="userInfo.headImage" style="width: 60rpx;height: 60rpx;"
  16. mode=""></image>
  17. <image src="../static/auth/headImage.png" v-else style="width: 50rpx;height: 50rpx;" mode=""></image>
  18. </view>
  19. </view>
  20. </button>
  21. <view class="line">
  22. <view class="">
  23. 昵称
  24. </view>
  25. <view class="">
  26. <input type="nickname" placeholder="请输入昵称" style="text-align: right;" id="nickName"
  27. v-model="userInfo.nickName" />
  28. </view>
  29. </view>
  30. <view class="btn" @click="submit">
  31. 确认
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. data() {
  38. return {
  39. userInfo: {
  40. headImage: '',
  41. nickName: '',
  42. }
  43. };
  44. },
  45. onShow() {},
  46. computed: {},
  47. methods: {
  48. onChooseAvatar(res) {
  49. let self = this
  50. self.$Oss.ossUpload(res.target.avatarUrl)
  51. .then(url => {
  52. self.userInfo.headImage = url
  53. })
  54. },
  55. submit() {
  56. let self = this
  57. uni.createSelectorQuery().in(this)
  58. .select("#nickName")
  59. .fields({
  60. properties: ["value"],
  61. })
  62. .exec((res) => {
  63. const nickName = res?.[0]?.value
  64. self.userInfo.nickName = nickName
  65. if (self.$utils.verificationAll(self.userInfo, {
  66. headImage: '请选择头像',
  67. nickName: '请填写昵称',
  68. })) {
  69. return
  70. }
  71. self.$api('updateInfo', {
  72. headImg : self.userInfo.headImage,
  73. nickname : self.userInfo.nickName,
  74. }, res => {
  75. if (res.code == 200) {
  76. uni.redirectTo({
  77. url:'/pages/index/index'
  78. })
  79. }
  80. })
  81. })
  82. },
  83. }
  84. }
  85. </script>
  86. <style lang="scss" scoped>
  87. .login {
  88. display: flex;
  89. flex-direction: column;
  90. justify-content: center;
  91. align-items: center;
  92. height: 80vh;
  93. .title {
  94. line-height: 45rpx;
  95. font-weight: 900;
  96. }
  97. .line {
  98. display: flex;
  99. justify-content: space-between;
  100. align-items: center;
  101. width: 80%;
  102. border-bottom: 1px solid #00000023;
  103. padding: 30rpx 0;
  104. margin: 0 auto;
  105. }
  106. .chooseAvatar {
  107. width: 100%;
  108. padding: 0;
  109. margin: 0;
  110. margin-top: 10vh;
  111. border: none;
  112. }
  113. .btn {
  114. // background: $uni-linear-gradient-btn-color;
  115. background: $uni-color;
  116. color: #fff;
  117. width: 80%;
  118. padding: 20rpx 0;
  119. text-align: center;
  120. border-radius: 15rpx;
  121. margin-top: 10vh;
  122. }
  123. }
  124. </style>