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

144 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
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. self.$Oss.ossUpload(res.target.avatarUrl)
  54. .then(url => {
  55. self.userInfo.headImage = url
  56. })
  57. },
  58. submit() {
  59. let self = this
  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 (self.$utils.verificationAll(self.userInfo, {
  69. headImage: '请选择头像',
  70. nickName: '请填写昵称',
  71. })) {
  72. return
  73. }
  74. self.$api('updateInfo', self.userInfo, 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. .logo{
  94. height: 140rpx;
  95. width: 140rpx;
  96. image{
  97. width: 100%;
  98. height: 100%;
  99. }
  100. margin-bottom: 20rpx;
  101. }
  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: $uni-color;
  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>