index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view class="base-container">
  3. <image class="tabbar" src="https://birdseye-img.sysuimars.com/dinggou-mini/tabbar-new.png" mode="" />
  4. </view>
  5. <up-popup :show="showPopup" mode="center" round="10" :overlay="false" :safeAreaInsetBottom="false"
  6. bgColor="transparent">
  7. <view class="popup">
  8. <button class="avatar-none" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
  9. <view class="avatar-wrapper">
  10. <image class="avatar" :src="userData.icon"></image>
  11. <view class="photo-icon">
  12. <up-icon color="#fff" size="20" name="camera-fill"></up-icon>
  13. </view>
  14. </view>
  15. </button>
  16. <view class="tips">设置头像,可以在地图上显示自己守护树的点位哦~</view>
  17. <button class="arrow-icon" open-type="getPhoneNumber" @getphonenumber="onGetPhoneNumber">
  18. <view class="button">微信授权</view>
  19. </button>
  20. </view>
  21. </up-popup>
  22. </template>
  23. <script setup>
  24. import {
  25. ref
  26. } from 'vue';
  27. import {
  28. onLoad
  29. } from '@dcloudio/uni-app'
  30. import USER from '@/api/user.js'
  31. const showPopup = ref(true);
  32. const userData = ref({})
  33. const pageUrl = ref('')
  34. const pageParams = ref(null)
  35. onLoad(({
  36. route_path,
  37. params = "{}"
  38. }) => {
  39. pageUrl.value = route_path
  40. pageParams.value = params
  41. getUserData()
  42. })
  43. const getUserData = () => {
  44. USER.userInfo().then(res => {
  45. const timestamp = res.data.birthDate && Date.parse(res.data.birthDate); // 返回毫秒级时间戳
  46. userData.value = res.data
  47. })
  48. }
  49. const onChooseAvatar = (e) => {
  50. const {
  51. avatarUrl
  52. } = e.detail
  53. // wx.showLoading({title: '上传中'})
  54. // upload(this.data.userInfo.id + "/" + new Date().getTime() + ".png", avatarUrl, (res) => {
  55. // that.setData({
  56. // 'userInfo.icon':BASE_IMG_DIR+res.key,
  57. // })
  58. // wx.hideLoading()
  59. // })
  60. }
  61. const onGetPhoneNumber = (e) => {
  62. if (e.detail.code) {
  63. USER.getPhone({
  64. code: e.detail.code
  65. }).then(res => {
  66. if (res.success) {
  67. userData.value.tel = res.data
  68. saveUserInfo(userData.value)
  69. }
  70. })
  71. } else {
  72. console.log("用户拒绝了授权");
  73. }
  74. }
  75. const saveUserInfo = (params) => {
  76. USER.updateUser(params).then(response => {
  77. uni.hideLoading()
  78. if (response.success) {
  79. uni.showToast({
  80. title: '保存成功',
  81. icon: 'none',
  82. duration: 2000,
  83. mask: true
  84. })
  85. uni.navigateTo({
  86. url: `/pages/tabBar/home/subPages/gardenMap?enterSelectTree=true`
  87. });
  88. } else {
  89. uni.showToast({
  90. title: '保存失败',
  91. icon: 'none',
  92. duration: 2000,
  93. mask: true
  94. })
  95. }
  96. })
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. @import "@/static/style/mixin.scss";
  101. .base-container {
  102. background-image: url('https://birdseye-img.sysuimars.com/dinggou-mini/login-new.png');
  103. background-size: 100% 100%;
  104. background-repeat: no-repeat;
  105. background-position: center center;
  106. .tabbar {
  107. width: 100%;
  108. height: 112rpx;
  109. position: fixed;
  110. bottom: 0;
  111. left: 0;
  112. }
  113. }
  114. .popup {
  115. width: 86vw;
  116. padding: 40rpx;
  117. box-sizing: border-box;
  118. background-image: url('https://birdseye-img.sysuimars.com/dinggou-mini/popup-bg.png');
  119. background-size: 100% 100%;
  120. background-repeat: no-repeat;
  121. background-position: center center;
  122. .avatar-none {
  123. width: auto;
  124. height: auto;
  125. display: contents;
  126. pointer-events: none;
  127. .avatar-wrapper {
  128. display: flex;
  129. justify-content: center;
  130. align-items: center;
  131. margin-bottom: 40rpx;
  132. position: relative;
  133. .avatar {
  134. width: 176rpx;
  135. height: 176rpx;
  136. border-radius: 50%;
  137. object-fit: cover;
  138. pointer-events: auto;
  139. }
  140. .photo-icon {
  141. pointer-events: auto;
  142. position: absolute;
  143. bottom: -6rpx;
  144. right: calc(50% - 64rpx - 40rpx);
  145. width: 64rpx;
  146. height: 64rpx;
  147. border-radius: 50%;
  148. background: #2199F8;
  149. display: flex;
  150. justify-content: center;
  151. align-items: center;
  152. border: 4rpx solid #fff;
  153. }
  154. }
  155. }
  156. .tips {
  157. font-size: 30rpx;
  158. color: #666666;
  159. margin-bottom: 48rpx;
  160. }
  161. .arrow-icon {
  162. width: auto;
  163. height: auto;
  164. text-align: left;
  165. background: transparent;
  166. padding-left: 0;
  167. padding-right: 0;
  168. }
  169. .button {
  170. font-size: 32rpx;
  171. text-align: center;
  172. background: #2199F8;
  173. color: #fff;
  174. border-radius: 16rpx;
  175. }
  176. }
  177. </style>