景徳镇旅游微信小程序
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.

148 lines
2.8 KiB

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