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

156 lines
3.3 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
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. if (uni.getStorageSync('shareId')) {
  89. self.userInfo.shareId = uni.getStorageSync('shareId')
  90. }
  91. self.$api('updateInfo', self.userInfo, res => {
  92. console.log(res, self.userInfo);
  93. if (res.code == 200) {
  94. uni.switchTab({
  95. url: '/pages/component/home'
  96. })
  97. }
  98. })
  99. })
  100. },
  101. }
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .img{
  106. width: 20%;
  107. height: 15%;
  108. margin-top: 10%;
  109. }
  110. .login {
  111. display: flex;
  112. flex-direction: column;
  113. justify-content: center;
  114. align-items: center;
  115. height: 80vh;
  116. .title {
  117. line-height: 45rpx;
  118. font-weight: 900;
  119. }
  120. .line {
  121. display: flex;
  122. justify-content: space-between;
  123. align-items: center;
  124. width: 80%;
  125. border-bottom: 1px solid #00000023;
  126. padding: 30rpx 0;
  127. margin: 0 auto;
  128. }
  129. .chooseAvatar {
  130. width: 100%;
  131. padding: 0;
  132. margin: 0;
  133. margin-top: 10vh;
  134. border: none;
  135. }
  136. .btn {
  137. // background: $uni-linear-gradient-btn-color;
  138. background: red;
  139. color: #fff;
  140. width: 80%;
  141. padding: 20rpx 0;
  142. text-align: center;
  143. border-radius: 15rpx;
  144. margin-top: 10vh;
  145. }
  146. }
  147. </style>