friendTree.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view class="base-template">
  3. <view class="sub-base-container">
  4. <member-level :treeData="treeData">
  5. <template #add-btn v-if="userName !== userInfo.name">
  6. <view class="add-btn" @click="handleAddFriend">添加好友</view>
  7. </template>
  8. </member-level>
  9. <view class="tree-cont">
  10. <view class="tree-name">
  11. <view>{{treeName}}</view>
  12. </view>
  13. <image class="drone-icon" :src="`${config.BASIC_IMG}img/treePage/drone-icon.png`"></image>
  14. <view class="tool-wrap">
  15. <view class="tool-left">
  16. <view :class="['tool-item',item.className]" v-for="(item,index) in toolList" :key="index">
  17. <image class="icon" :src="`${config.BASIC_IMG}img/treePage/${item.icon}.png`"></image>
  18. <view class="name">{{item.name}}</view>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="tree-footer">
  24. <view class="blessing" @click="handleBlessing" v-if="userName !== userInfo.name">
  25. <image class="icon" :src="`${config.BASIC_IMG}img/treePage/b-tree-icon-2.png`"></image>
  26. <text>送ta祝福</text>
  27. </view>
  28. <view class="button" @click="handlePage">{{userInfo.tel?'去看看我的树':'开启我的守护'}}</view>
  29. </view>
  30. </view>
  31. <!-- 祝福弹窗 -->
  32. <blessingsPopup :show="showBlessingsPopup" clockinType="3" :farmBuyId="farmBuyId" @clockinCallback="getBySampleId" isFriend></blessingsPopup>
  33. </view>
  34. </template>
  35. <script setup>
  36. import config from "@/api/config.js"
  37. import memberLevel from "../components/memberLevel.vue"
  38. import blessingsPopup from "../components/blessingsPopup.vue"
  39. import {
  40. onLoad
  41. } from '@dcloudio/uni-app'
  42. import TREE from '@/api/tree.js'
  43. import {
  44. ref,
  45. } from 'vue';
  46. const userInfo = uni.getStorageSync('userInfo')
  47. const handlePage = () => {
  48. if (userInfo.tel) {
  49. uni.switchTab({
  50. url: '/pages/tabBar/tree/tree'
  51. })
  52. } else {
  53. uni.navigateTo({
  54. url: `/pages/tabBar/home/subPages/gardenMap?enterSelectTree=true`
  55. });
  56. }
  57. }
  58. const handleAddFriend = () => {
  59. console.log('添加好友')
  60. }
  61. const sampleId = ref('')
  62. onLoad((options) => {
  63. sampleId.value = options.sampleId
  64. getBySampleId()
  65. })
  66. const treeData = ref({})
  67. const treeName = ref('')
  68. const farmBuyId = ref('')
  69. const userName = ref('')
  70. const getBySampleId = () => {
  71. TREE.getBySampleId({
  72. sampleId: sampleId.value
  73. }).then(({
  74. data
  75. }) => {
  76. treeData.value = data || {}
  77. treeName.value = data.buyList[0].treeName || (data.buyList[0].nickname.length ? data.buyList[0]
  78. .nickname.slice(0, 3) + "荔" : data.buyList[0].owner.slice(0, 3) + "荔")
  79. farmBuyId.value = data.buyList[0].id
  80. userName.value = data.buyList[0].owner
  81. })
  82. }
  83. const showBlessingsPopup = ref(false)
  84. const handleBlessing = () => {
  85. if(treeData.value.buyList[0].level.clockinMap['3']){
  86. uni.showToast({
  87. title: '今日已送过祝福',
  88. icon: 'none',
  89. duration: 2000
  90. });
  91. }else{
  92. showBlessingsPopup.value = !showBlessingsPopup.value
  93. }
  94. }
  95. const toolList = [{
  96. name: "相册",
  97. icon: 'l-tree-icon-1'
  98. },
  99. {
  100. name: "日记",
  101. icon: 'l-tree-icon-2'
  102. },
  103. {
  104. name: "果园",
  105. icon: 'r-tree-icon-3'
  106. }
  107. ]
  108. const handleToolItem = ({
  109. path
  110. }) => {
  111. uni.navigateTo({
  112. url: `/pages/tabBar/tree/subPages/${path}`
  113. });
  114. }
  115. </script>
  116. <style lang="scss" scoped>
  117. @import "@/static/style/mixin.scss";
  118. .sub-base-container {
  119. @include ossBg("tree-bg.png");
  120. padding: 22rpx 0;
  121. .add-btn{
  122. margin-left: 14rpx;
  123. font-size: 22rpx;
  124. color: #fff;
  125. border-radius: 40rpx;
  126. padding: 2rpx 16rpx;
  127. border: 2rpx solid #fff;
  128. }
  129. .tree-cont {
  130. width: 100%;
  131. margin-top: 10rpx;
  132. .tree-name {
  133. position: absolute;
  134. top: 60.45%;
  135. left: calc(50% - 32rpx);
  136. z-index: 2;
  137. font-size: 22rpx;
  138. font-family: 'SweiSpringCJKtc';
  139. text-align: center;
  140. width: 88rpx;
  141. }
  142. .drone-icon {
  143. width: 376rpx;
  144. height: 384rpx;
  145. margin-left: 26rpx;
  146. }
  147. .tool-wrap {
  148. width: 100%;
  149. padding: 14rpx;
  150. box-sizing: border-box;
  151. position: absolute;
  152. bottom: calc(50% - 350rpx);
  153. display: flex;
  154. justify-content: space-between;
  155. .tool-left {
  156. .tool-item {
  157. color: #fff;
  158. font-size: 24rpx;
  159. font-weight: 500;
  160. text-align: center;
  161. width: 100rpx;
  162. margin-bottom: 16rpx;
  163. text-shadow:
  164. 0 0 3rpx #D7660A,
  165. 0 0 3rpx #D7660A,
  166. 0 0 3rpx #D7660A,
  167. 0 0 3rpx #D7660A;
  168. .icon {
  169. width: 100%;
  170. height: 82rpx;
  171. position: relative;
  172. }
  173. .name {
  174. margin-top: -24rpx;
  175. position: relative;
  176. z-index: 2;
  177. }
  178. }
  179. }
  180. }
  181. }
  182. .tree-footer {
  183. position: absolute;
  184. left: 0;
  185. bottom: 130rpx;
  186. width: 100%;
  187. display: flex;
  188. flex-direction: column;
  189. align-items: center;
  190. color: #fff;
  191. .blessing {
  192. display: flex;
  193. align-items: center;
  194. background: rgba(0, 0, 0, 0.3);
  195. border-radius: 50rpx;
  196. padding: 6rpx 60rpx;
  197. border: 1rpx solid rgba(255, 255, 255, 0.6);
  198. .icon {
  199. width: 86rpx;
  200. height: 86rpx;
  201. margin-right: 10rpx;
  202. }
  203. }
  204. .button {
  205. padding: 26rpx 80rpx;
  206. border-radius: 50rpx;
  207. border: 2rpx solid #fff;
  208. background-image: linear-gradient(120deg, #FFD887, #ED9E1E);
  209. margin-top: 20rpx;
  210. }
  211. }
  212. }
  213. </style>