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

153 lines
3.2 KiB

2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
  1. <template>
  2. <view class="login">
  3. <image :src='logoImage' mode="" class="img"></image>
  4. <view class="title">
  5. {{logoName}}
  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.avatarUrl" v-if="userInfo.avatarUrl" 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. avatarUrl: '',
  42. nickName: '',
  43. },
  44. configData: [],
  45. };
  46. },
  47. onShow() { },
  48. computed: {
  49. logoImage() {
  50. console.log(getApp().globalData.configData,'getApp().globalData.configData')
  51. const item = getApp().globalData.configData.find(i => i.keyName === 'logo_image')
  52. return item ? item.keyContent : ''
  53. },
  54. logoName() {
  55. const item = getApp().globalData.configData.find(i => i.keyName === 'logo_name')
  56. return item ? item.keyContent : ''
  57. }
  58. },
  59. methods: {
  60. onChooseAvatar(res) {
  61. let self = this
  62. self.$Oss.ossUpload(res.target.avatarUrl)
  63. .then(url => {
  64. console.log(url);
  65. self.userInfo.avatarUrl = url
  66. })
  67. },
  68. submit() {
  69. let self = this
  70. console.log(self.userInfo.avatarUrl, '111');
  71. uni.createSelectorQuery().in(this)
  72. .select("#nickName")
  73. .fields({
  74. properties: ["value"],
  75. })
  76. .exec((res) => {
  77. const nickName = res?.[0]?.value
  78. self.userInfo.nickName = nickName
  79. if (getApp().globalData.phone) {
  80. self.userInfo.phone = getApp().globalData.phone
  81. }
  82. if (self.$utils.verificationAll(self.userInfo, {
  83. avatarUrl: '请选择头像',
  84. nickName: '请填写昵称',
  85. })) {
  86. return
  87. }
  88. self.$api('updateInfo', self.userInfo, res => {
  89. console.log(res, self.userInfo);
  90. if (res.code == 200) {
  91. uni.switchTab({
  92. url: '/pages/component/home'
  93. })
  94. }
  95. })
  96. })
  97. },
  98. }
  99. }
  100. </script>
  101. <style lang="scss" scoped>
  102. .img{
  103. width: 20%;
  104. height: 15%;
  105. margin-top: 10%;
  106. }
  107. .login {
  108. display: flex;
  109. flex-direction: column;
  110. justify-content: center;
  111. align-items: center;
  112. height: 80vh;
  113. .title {
  114. line-height: 45rpx;
  115. font-weight: 900;
  116. }
  117. .line {
  118. display: flex;
  119. justify-content: space-between;
  120. align-items: center;
  121. width: 80%;
  122. border-bottom: 1px solid #00000023;
  123. padding: 30rpx 0;
  124. margin: 0 auto;
  125. }
  126. .chooseAvatar {
  127. width: 100%;
  128. padding: 0;
  129. margin: 0;
  130. margin-top: 10vh;
  131. border: none;
  132. }
  133. .btn {
  134. // background: $uni-linear-gradient-btn-color;
  135. background: red;
  136. color: #fff;
  137. width: 80%;
  138. padding: 20rpx 0;
  139. text-align: center;
  140. border-radius: 15rpx;
  141. margin-top: 10vh;
  142. }
  143. }
  144. </style>