index.vue 4.6 KB

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