blessingsPopup.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <up-popup :show="showPopup" round="8" mode="center" closeable @close="handleCancel">
  3. <view class="blessings-popup">
  4. <view class="blessings-title">每日祝福</view>
  5. <view class="blessings-cont">
  6. <view class="head">
  7. <view class="common-title">
  8. <view class="line"></view>
  9. <text>随机祝福</text>
  10. </view>
  11. <view class="button" @click="getRandomPick">
  12. <icon name="exchange" />
  13. <text class="text">换一换</text>
  14. </view>
  15. </view>
  16. <view class="blessings-list">
  17. <view v-for="(item, index) in list" :key="index" class="blessings-item"
  18. :class="{ active: activeIndex === index }" @click="handleMsg(index, item)">
  19. {{ item.clockinText }}
  20. </view>
  21. </view>
  22. <up-textarea class="message-field" v-model="message" placeholder="给 TA 一份暖心的祝福吧~"
  23. autoHeight></up-textarea>
  24. </view>
  25. <view class="blessings-footer">
  26. <view class="btn" @click="handleCancel">取消</view>
  27. <view class="send btn" @click="handleSend">发送</view>
  28. </view>
  29. </view>
  30. </up-popup>
  31. <!-- 祝福成功弹窗 -->
  32. <up-popup :show="sucessPopup" mode="center" @close="handleCancelSucess" bgColor="transparent" overlayOpacity="0.8">
  33. <view class="sucess-popup" @click="handleCancelSucess">
  34. <view class="sucess-bg">
  35. <image v-if="isFriend" class="img" :src="`${config.BASIC_IMG}img/subTreePage/blessing-sucess.png`">
  36. </image>
  37. <image v-else class="img" :style="{width:clockinType == 4?'90%':'81%'}"
  38. :src="`${config.BASIC_IMG}img/subTreePage/blessing-sucess-${clockinType}.png`"></image>
  39. </view>
  40. <view class="button-group">
  41. <view class="btn">开心收下</view>
  42. <view class="close">
  43. <up-icon name="close-circle-fill" size="30" color="rgba(255, 255, 255, 0.7)"></up-icon>
  44. </view>
  45. </view>
  46. </view>
  47. </up-popup>
  48. </template>
  49. <script setup>
  50. import config from "@/api/config.js"
  51. import {
  52. onMounted,
  53. ref,
  54. watch
  55. } from "vue";
  56. import TREE from '@/api/tree.js'
  57. const props = defineProps({
  58. show: {
  59. type: Boolean,
  60. defalut: false,
  61. },
  62. showSuccess: {
  63. type: Boolean,
  64. defalut: false,
  65. },
  66. farmBuyId: {
  67. type: [Number, String],
  68. defalut: '',
  69. },
  70. isFriend: {
  71. type: Boolean,
  72. defalut: false,
  73. },
  74. clockinType: {
  75. type: [Number, String],
  76. defalut: "1",
  77. },
  78. });
  79. const showPopup = ref(false);
  80. const message = ref("");
  81. const activeIndex = ref(null);
  82. const list = ref([]);
  83. const handleCancel = () => {
  84. activeIndex.value = null;
  85. message.value = "";
  86. showPopup.value = false;
  87. };
  88. const handleCancelSucess = () => {
  89. sucessPopup.value = false;
  90. emit("closeBlessings")
  91. emit('clockinCallback')
  92. };
  93. const getRandomPick = () => {
  94. TREE.randomPick({
  95. count: 6
  96. }).then(({
  97. data
  98. }) => {
  99. list.value = data || [];
  100. if (activeIndex.value != null) {
  101. message.value = data[activeIndex.value].clockinText;
  102. }
  103. });
  104. };
  105. const handleMsg = (index, item) => {
  106. activeIndex.value = index;
  107. message.value = item.clockinText;
  108. };
  109. const sucessPopup = ref(false);
  110. const emit = defineEmits(['clockinCallback', "closeBlessings"])
  111. const handleSend = () => {
  112. const params = {
  113. farmBuyId: props.farmBuyId,
  114. clockinType: props.clockinType,
  115. msg: message.value,
  116. };
  117. if(props.clockinType!=4){
  118. TREE.clockin(params).then((res) => {
  119. if (res.code === 0) {
  120. handleCancel();
  121. sucessPopup.value = true;
  122. }
  123. });
  124. }else{
  125. sucessPopup.value = true;
  126. }
  127. };
  128. function handleUpgrade() {
  129. // 是否有200积分弹窗
  130. TREE.fetchLevelAwardInfo({buyId: props.farmBuyId}).then(({data}) => {
  131. console.log('da获取200积分ta', data)
  132. })
  133. }
  134. onMounted(() => {
  135. getRandomPick();
  136. });
  137. watch(
  138. () => props.show,
  139. () => {
  140. showPopup.value = true;
  141. }
  142. );
  143. watch(
  144. () => props.showSuccess,
  145. () => {
  146. handleSend()
  147. }
  148. );
  149. </script>
  150. <style scoped lang="scss">
  151. @import "@/static/style/mixin.scss";
  152. .blessings-popup {
  153. width: 90vw;
  154. padding: 40rpx 30rpx;
  155. box-sizing: border-box;
  156. position: relative;
  157. &::before {
  158. content: '';
  159. position: absolute;
  160. bottom: 190rpx;
  161. right: 0;
  162. z-index: 2;
  163. @include ossBg("subTreePage/blessing-bg.png");
  164. width: 336rpx;
  165. height: 336rpx;
  166. }
  167. .blessings-title {
  168. font-size: 48rpx;
  169. text-align: center;
  170. font-family: "PangMenZhengDao";
  171. }
  172. .blessings-cont {
  173. margin: 40rpx 0 48rpx;
  174. .head {
  175. display: flex;
  176. align-items: center;
  177. justify-content: space-between;
  178. .common-title {
  179. display: flex;
  180. align-items: center;
  181. font-weight: 500;
  182. .line {
  183. width: 8rpx;
  184. height: 32rpx;
  185. border-radius: 10rpx;
  186. background: #F3C11D;
  187. margin-right: 14rpx;
  188. }
  189. }
  190. .button {
  191. font-size: 24rpx;
  192. color: #f3c11d;
  193. padding: 8rpx 24rpx;
  194. border-radius: 40rpx;
  195. background: rgba(243, 193, 29, 0.1);
  196. border: 1px solid #f3c11d;
  197. display: flex;
  198. align-items: center;
  199. justify-content: center;
  200. .text {
  201. margin-left: 10rpx;
  202. }
  203. }
  204. }
  205. .blessings-list {
  206. display: flex;
  207. align-items: flex-start;
  208. flex-direction: column;
  209. padding-bottom: 24rpx;
  210. margin-bottom: 24rpx;
  211. border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  212. .blessings-item {
  213. font-size: 24rpx;
  214. padding: 8rpx 20rpx;
  215. border-radius: 40rpx;
  216. background: #f4f6f8;
  217. margin-top: 20rpx;
  218. &.active {
  219. background: #fff2c4;
  220. }
  221. }
  222. }
  223. }
  224. .blessings-footer {
  225. display: flex;
  226. .btn {
  227. text-align: center;
  228. flex: 1;
  229. color: #666666;
  230. font-size: 32rpx;
  231. padding: 16rpx;
  232. border: 1px solid #999999;
  233. border-radius: 50rpx;
  234. }
  235. .send {
  236. margin-left: 26rpx;
  237. color: #fff;
  238. background-image: linear-gradient(120deg, #ffd887, #ed9e1e);
  239. border: none;
  240. }
  241. }
  242. }
  243. .sucess-popup {
  244. width: 100vw;
  245. min-height: 100vh;
  246. .image {
  247. width: 570rpx;
  248. height: 480rpx;
  249. }
  250. .sucess-bg {
  251. width: 100%;
  252. height: 830rpx;
  253. @include ossBg("subTreePage/light-effect-bg.png");
  254. display: flex;
  255. align-items: flex-end;
  256. justify-content: center;
  257. .img {
  258. width: 81%;
  259. height: 410rpx;
  260. }
  261. }
  262. .button-group {
  263. margin: 46rpx auto;
  264. width: 312rpx;
  265. .btn {
  266. font-size: 44rpx;
  267. padding: 20rpx 0;
  268. border-radius: 50rpx;
  269. font-family: "PangMenZhengDao";
  270. color: #954600;
  271. background: linear-gradient(120deg, #FFE6B2, #FFC339);
  272. text-align: center;
  273. }
  274. .close {
  275. margin-top: 80rpx;
  276. display: flex;
  277. justify-content: center;
  278. }
  279. }
  280. }
  281. </style>