爱简收旧衣按件回收前端代码仓库
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.

143 lines
2.9 KiB

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