index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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" @click="toPath">设置头像,可以在地图上显示自己守护树的点位哦~</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. console.log('eeeeeeeeeee', e)
  55. if (e.detail.code) {
  56. // getPhone({code:e.detail.code}).then(res =>{
  57. // if(res.success){
  58. // this.setData({'userInfo.tel':res.data})
  59. // that.saveUserInfo(that.data.userInfo)
  60. // }
  61. // })
  62. uni.navigateTo({
  63. url: `/pages/tabBar/home/subPages/allGardenMap?enterSelectTree=true`
  64. });
  65. }else{
  66. console.log("用户拒绝了授权");
  67. }
  68. }
  69. function toPath() {
  70. uni.navigateTo({
  71. url: '/pages/tabBar/home/subPages/gardenMap?enterSelectTree=true'
  72. });
  73. }
  74. const saveUserInfo = (params) =>{
  75. // saveUser(params).then(response =>{
  76. // wx.hideLoading()
  77. // if(response.success){
  78. // wx.showToast({
  79. // title: '保存成功',
  80. // icon: 'none',
  81. // duration: 2000,
  82. // mask:true
  83. // })
  84. // const params = {
  85. // showPopup:true
  86. // }
  87. // wx.reLaunch({
  88. // url: `/pages/tabBar/home/index?route_path=lj_home&params=${JSON.stringify(params)}`
  89. // })
  90. // }else{
  91. // wx.showToast({
  92. // title: '保存失败',
  93. // icon: 'none',
  94. // duration: 2000,
  95. // mask:true
  96. // })
  97. // }
  98. // })
  99. }
  100. </script>
  101. <style lang="scss" scoped>
  102. @import "@/static/style/mixin.scss";
  103. .base-container {
  104. background-image: url('https://birdseye-img.sysuimars.com/dinggou-mini/login-new.png');
  105. background-size: 100% 100%;
  106. background-repeat: no-repeat;
  107. background-position: center center;
  108. .tabbar {
  109. width: 100%;
  110. height: 112rpx;
  111. position: fixed;
  112. bottom: 0;
  113. left: 0;
  114. }
  115. }
  116. .popup {
  117. width: 86vw;
  118. padding: 40rpx;
  119. box-sizing: border-box;
  120. background-image: url('https://birdseye-img.sysuimars.com/dinggou-mini/popup-bg.png');
  121. background-size: 100% 100%;
  122. background-repeat: no-repeat;
  123. background-position: center center;
  124. .avatar-none {
  125. width: auto;
  126. height: auto;
  127. display: contents;
  128. pointer-events: none;
  129. .avatar-wrapper {
  130. display: flex;
  131. justify-content: center;
  132. align-items: center;
  133. margin-bottom: 40rpx;
  134. position: relative;
  135. .avatar {
  136. width: 176rpx;
  137. height: 176rpx;
  138. border-radius: 50%;
  139. object-fit: cover;
  140. pointer-events: auto;
  141. }
  142. .photo-icon {
  143. pointer-events: auto;
  144. position: absolute;
  145. bottom: -6rpx;
  146. right: calc(50% - 64rpx - 40rpx);
  147. width: 64rpx;
  148. height: 64rpx;
  149. border-radius: 50%;
  150. background: #2199F8;
  151. display: flex;
  152. justify-content: center;
  153. align-items: center;
  154. border: 4rpx solid #fff;
  155. }
  156. }
  157. }
  158. .tips {
  159. font-size: 30rpx;
  160. color: #666666;
  161. margin-bottom: 48rpx;
  162. }
  163. .arrow-icon {
  164. width: auto;
  165. height: auto;
  166. text-align: left;
  167. background: transparent;
  168. padding-left: 0;
  169. padding-right: 0;
  170. }
  171. .button {
  172. font-size: 32rpx;
  173. text-align: center;
  174. background: #2199F8;
  175. color: #fff;
  176. border-radius: 16rpx;
  177. }
  178. }
  179. </style>