tree.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <template>
  2. <view class="base-container">
  3. <member-level :treeData="treeData">
  4. <view class="toogle" @click="handleShow">切换 {{name}}<up-icon class="icon" name="arrow-down" color="#fff"
  5. size="12"></up-icon></view>
  6. </member-level>
  7. <view class="tree-cont">
  8. <image class="drone-icon" :src="`${config.BASIC_IMG}img/treePage/drone-icon.png`"></image>
  9. <view class="tool-wrap">
  10. <view class="tool-left">
  11. <view :class="['tool-item',item.className]" v-for="(item,index) in toolLeftList" :key="index"
  12. @click="handleToolItem(item)">
  13. <image class="icon" :src="`${config.BASIC_IMG}img/treePage/l-tree-icon-${index+1}.png`"></image>
  14. <view class="name">{{item.name}}</view>
  15. </view>
  16. </view>
  17. <view class="tool-right">
  18. <view :class="['tool-item',item.className]" v-for="(item,index) in toolRightList" :key="index"
  19. @click="handleToolItem(item)">
  20. <image class="icon" :src="`${config.BASIC_IMG}img/treePage/r-tree-icon-${index+1}.png`"></image>
  21. <view class="name">{{item.name}}</view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="tree-footer">
  27. <view class="footer-item" v-for="(item,index) in footerList" :key="index">
  28. <image class="icon" :src="`${config.BASIC_IMG}img/treePage/b-tree-icon-${index+1}.png`"></image>
  29. <view class="name">{{item}}</view>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 切换 -->
  34. <up-picker :show="showPicker" :columns="columns" :defaultIndex="[0]" @cancel="handleCancel"
  35. @confirm="handleConfirm"></up-picker>
  36. <!-- 编辑树名称 -->
  37. <editNamePopup></editNamePopup>
  38. <!-- 海报弹窗 -->
  39. <posterPopup :showPoster="showPoster" :farmBuyId="farmBuyId"></posterPopup>
  40. <!-- 果树成功弹窗 -->
  41. <guardSuccessPopup :show="showGuardSuccess"></guardSuccessPopup>
  42. <!-- 果树相册弹窗 -->
  43. <tree-album-popup :show="showAlbum"></tree-album-popup>
  44. <!-- 等级升级成功弹窗 -->
  45. <levelSuccessPopup></levelSuccessPopup>
  46. </template>
  47. <script setup>
  48. import config from "@/api/config.js"
  49. import { onLoad } from '@dcloudio/uni-app'
  50. import memberLevel from "./components/memberLevel.vue"
  51. import treeAlbumPopup from "./components/treeAlbumPopup.vue"
  52. import TREE from '@/api/tree.js'
  53. import {
  54. ref,
  55. reactive,
  56. } from 'vue';
  57. const name = ref('荔枝')
  58. const showPicker = ref(false)
  59. const columns = reactive([
  60. ['荔枝', '香蕉', '苹果']
  61. ]);
  62. const handleShow = () => {
  63. showPicker.value = true
  64. }
  65. const handleCancel = () => {
  66. showPicker.value = false
  67. }
  68. const handleConfirm = (e) => {
  69. name.value = e.value[0]
  70. handleCancel()
  71. }
  72. const toolLeftList = [{
  73. name: "相册",
  74. clickName:'album'
  75. },
  76. {
  77. name: "日记",
  78. path: 'diary'
  79. },
  80. {
  81. name: "海报",
  82. className: 'blue',
  83. clickName:'poster'
  84. },
  85. {
  86. name: "礼物",
  87. className: 'gift',
  88. path: 'gift'
  89. }
  90. ]
  91. const toolRightList = [{
  92. name: "好友",
  93. className: 'friend',
  94. path: 'rank'
  95. },
  96. {
  97. name: "认养",
  98. },
  99. {
  100. name: "果园",
  101. },
  102. {
  103. name: "动态",
  104. className: 'dynamic',
  105. path: 'dynamic',
  106. params:'farmBuyId'
  107. }
  108. ]
  109. const showGuardSuccess = ref(false)
  110. onLoad(({successTree})=>{
  111. if(successTree){
  112. showGuardSuccess.value = true
  113. }
  114. getBySampleId()
  115. })
  116. const treeData = ref({})
  117. const farmBuyId = ref('')
  118. const getBySampleId = () =>{
  119. //81317 88891
  120. TREE.getBySampleId({sampleId:172055}).then(res =>{
  121. treeData.value = res.data || {}
  122. farmBuyId.value = res.data.buyList[0].id
  123. })
  124. }
  125. const showPoster = ref(false)
  126. const showAlbum = ref(false)
  127. const handleToolItem = ({
  128. path,clickName,params
  129. }) => {
  130. if(clickName === 'album'){
  131. showAlbum.value = !showAlbum.value
  132. }else if(clickName === 'poster'){
  133. showPoster.value = !showPoster.value
  134. }else{
  135. uni.navigateTo({
  136. url: `/pages/tabBar/tree/subPages/${path}?farmBuyId=${farmBuyId.value}`
  137. });
  138. }
  139. }
  140. const footerList = ["每日阳光", "送ta祝福", "分享转发", "水果订购"]
  141. </script>
  142. <style lang="scss" scoped>
  143. @import "@/static/style/mixin.scss";
  144. .base-container {
  145. @include ossBg("tree-bg.png");
  146. // background-position: top left;
  147. padding: 22rpx 0;
  148. .toogle {
  149. position: absolute;
  150. right: 0;
  151. top: calc(50% - 32rpx);
  152. font-size: 24rpx;
  153. color: #fff;
  154. border-radius: 50rpx 0 0 50rpx;
  155. background: rgba(0, 0, 0, 0.2);
  156. padding: 12rpx 20rpx;
  157. display: flex;
  158. .icon {
  159. margin-left: 10rpx;
  160. }
  161. }
  162. .tree-cont {
  163. width: 100%;
  164. margin-top: 10rpx;
  165. .drone-icon {
  166. width: 376rpx;
  167. height: 384rpx;
  168. margin-left: 26rpx;
  169. }
  170. .tool-wrap {
  171. width: 100%;
  172. padding: 14rpx;
  173. box-sizing: border-box;
  174. position: absolute;
  175. bottom: calc(50% - 350rpx);
  176. display: flex;
  177. justify-content: space-between;
  178. .tool-left,
  179. .tool-right {
  180. .tool-item {
  181. color: #fff;
  182. font-size: 24rpx;
  183. font-weight: 500;
  184. text-align: center;
  185. width: 100rpx;
  186. margin-bottom: 16rpx;
  187. text-shadow:
  188. 0 0 3rpx #D7660A,
  189. 0 0 3rpx #D7660A,
  190. 0 0 3rpx #D7660A,
  191. 0 0 3rpx #D7660A;
  192. &.blue {
  193. text-shadow:
  194. 0 0 3rpx #2199F8,
  195. 0 0 3rpx #2199F8,
  196. 0 0 3rpx #2199F8,
  197. 0 0 3rpx #2199F8;
  198. }
  199. .icon {
  200. width: 100%;
  201. height: 82rpx;
  202. position: relative;
  203. }
  204. .name {
  205. margin-top: -24rpx;
  206. position: relative;
  207. z-index: 2;
  208. }
  209. &.gift {
  210. .icon {
  211. height: 114rpx;
  212. margin-top: -5rpx;
  213. }
  214. .name {
  215. margin-top: -44rpx;
  216. }
  217. }
  218. &.friend {
  219. .icon {
  220. height: 90rpx;
  221. }
  222. .name {
  223. margin-top: -35rpx;
  224. }
  225. }
  226. &.dynamic {
  227. .icon {
  228. height: 96rpx;
  229. }
  230. .name {
  231. margin-top: -32rpx;
  232. }
  233. }
  234. }
  235. }
  236. }
  237. }
  238. .tree-footer {
  239. position: absolute;
  240. left: 0;
  241. bottom: 76rpx;
  242. width: 100%;
  243. display: flex;
  244. justify-content: center;
  245. .footer-item {
  246. width: 18%;
  247. text-align: center;
  248. .icon {
  249. width: 96rpx;
  250. height: 96rpx;
  251. }
  252. .name {
  253. font-size: 24rpx;
  254. font-weight: 500;
  255. padding: 2rpx 16rpx;
  256. background-image: linear-gradient(0deg, #FFFFFF, #FFE079);
  257. border-radius: 50rpx;
  258. border: 2rpx solid #fff;
  259. }
  260. }
  261. .footer-item+.footer-item {
  262. margin-left: 30rpx;
  263. }
  264. }
  265. }
  266. </style>