blessingsPopup.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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>换一换</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 @click="handleCancel">取消</view>
  27. <view class="send" @click="handleSend">发送</view>
  28. </view>
  29. </view>
  30. </up-popup>
  31. <!-- 祝福成功弹窗 -->
  32. <up-popup :show="sucessPopup" mode="center" @close="handleCancelSucess" bgColor="transparent">
  33. <view class="sucess-popup" @click="handleCancelSucess">
  34. <view class="sucess-bg">
  35. <image class="img" :src="`${config.BASIC_IMG}img/subTreePage/blessing-sucess.png`"></image>
  36. </view>
  37. <view class="button-group" @click="handlePage">
  38. <view class="btn">开心收下</view>
  39. <up-icon class="close" name="close-circle-fill" size="30" color="rgba(255, 255, 255, 0.7)"></up-icon>
  40. </view>
  41. </view>
  42. </up-popup>
  43. </template>
  44. <script setup>
  45. import config from "@/api/config.js"
  46. import {
  47. onActivated,
  48. onMounted,
  49. ref,
  50. watch
  51. } from "vue";
  52. const props = defineProps({
  53. show: {
  54. type: Boolean,
  55. defalut: false,
  56. },
  57. farmBuyId: {
  58. type: [Number, String],
  59. defalut: "",
  60. },
  61. });
  62. const handlePage = () => {
  63. // if (userInfo.value.tel) {
  64. // router.push('/guard_tree')
  65. // } else {
  66. // router.push('/lj_home')
  67. // }
  68. }
  69. const showPopup = ref(false);
  70. const message = ref("");
  71. const activeIndex = ref(null);
  72. const list = ref([]);
  73. const handleCancel = () => {
  74. activeIndex.value = null;
  75. message.value = "";
  76. showPopup.value = false;
  77. };
  78. const handleCancelSucess = () => {
  79. sucessPopup.value = false;
  80. };
  81. const getRandomPick = () => {
  82. list.value = [{
  83. id: 1,
  84. clockinText: '晨曦微露,阳光洒满大地'
  85. },
  86. {
  87. id: 2,
  88. clockinText: '新的一天,新的挑战,新的机会'
  89. },
  90. {
  91. id: 3,
  92. clockinText: '记住,每一次挫折都是成功的垫脚石'
  93. },
  94. {
  95. id: 4,
  96. clockinText: '道阻且长,行则将至,行而不辍,未来可期。'
  97. },
  98. {
  99. id: 5,
  100. clockinText: '每日数据的更替,是日积月累的结果'
  101. },
  102. {
  103. id: 6,
  104. clockinText: '不必在意他人目光与期待'
  105. }
  106. ]
  107. // VE_API.guard_tree.randomPick({
  108. // count: 6
  109. // }).then(({
  110. // data
  111. // }) => {
  112. // list.value = data || [];
  113. // if (activeIndex.value != null) {
  114. // message.value = data[activeIndex.value].clockinText;
  115. // }
  116. // });
  117. };
  118. const handleMsg = (index, item) => {
  119. activeIndex.value = index;
  120. message.value = item.clockinText;
  121. };
  122. const sucessPopup = ref(false);
  123. const handleSend = () => {
  124. const params = {
  125. farmBuyId: props.farmBuyId,
  126. clockinType: 3,
  127. msg: message.value,
  128. };
  129. handleCancel();
  130. sucessPopup.value = true;
  131. // VE_API.guard_tree.clockin(params).then((res) => {
  132. // if (res.code === 0) {
  133. // handleCancel();
  134. // sucessPopup.value = true;
  135. // }
  136. // });
  137. };
  138. onMounted(() => {
  139. getRandomPick();
  140. });
  141. watch(
  142. () => props.show,
  143. () => {
  144. showPopup.value = true;
  145. }
  146. );
  147. </script>
  148. <style scoped lang="scss">
  149. @import "@/static/style/mixin.scss";
  150. .blessings-popup {
  151. width: 90vw;
  152. padding: 40rpx 30rpx;
  153. box-sizing: border-box;
  154. position: relative;
  155. &::before {
  156. content: '';
  157. position: absolute;
  158. bottom: 190rpx;
  159. right: 0;
  160. z-index: 2;
  161. @include ossBg("subTreePage/blessing-bg.png");
  162. width: 336rpx;
  163. height: 336rpx;
  164. }
  165. .blessings-title {
  166. font-size: 48rpx;
  167. text-align: center;
  168. font-family: "PangMenZhengDao";
  169. }
  170. .blessings-cont {
  171. margin: 40rpx 0 48rpx;
  172. .head {
  173. display: flex;
  174. align-items: center;
  175. justify-content: space-between;
  176. .common-title {
  177. display: flex;
  178. align-items: center;
  179. font-weight: 500;
  180. .line {
  181. width: 8rpx;
  182. height: 32rpx;
  183. border-radius: 10rpx;
  184. background: #F3C11D;
  185. margin-right: 14rpx;
  186. }
  187. }
  188. .button {
  189. font-size: 24rpx;
  190. color: #f3c11d;
  191. padding: 8rpx 24rpx;
  192. border-radius: 40rpx;
  193. background: rgba(243, 193, 29, 0.1);
  194. border: 1px solid #f3c11d;
  195. display: flex;
  196. align-items: center;
  197. justify-content: center;
  198. text {
  199. margin-left: 10rpx;
  200. }
  201. }
  202. }
  203. .blessings-list {
  204. display: flex;
  205. align-items: flex-start;
  206. flex-direction: column;
  207. padding-bottom: 24rpx;
  208. margin-bottom: 24rpx;
  209. border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  210. .blessings-item {
  211. font-size: 24rpx;
  212. padding: 8rpx 20rpx;
  213. border-radius: 40rpx;
  214. background: #f4f6f8;
  215. margin-top: 20rpx;
  216. &.active {
  217. background: #fff2c4;
  218. }
  219. }
  220. }
  221. }
  222. .blessings-footer {
  223. display: flex;
  224. view {
  225. text-align: center;
  226. flex: 1;
  227. color: #666666;
  228. font-size: 32rpx;
  229. padding: 16rpx;
  230. border: 1px solid #999999;
  231. border-radius: 50rpx;
  232. }
  233. .send {
  234. margin-left: 26rpx;
  235. color: #fff;
  236. background-image: linear-gradient(120deg, #ffd887, #ed9e1e);
  237. border: none;
  238. }
  239. }
  240. }
  241. .sucess-popup {
  242. width: 100vw;
  243. height: 100vh;
  244. background: rgba(0, 0, 0, 0.6);
  245. .sucess-bg {
  246. width: 100%;
  247. height: 920rpx;
  248. @include ossBg("subTreePage/light-effect-bg.png");
  249. display: flex;
  250. align-items: flex-end;
  251. justify-content: center;
  252. .img {
  253. width: 82%;
  254. height: 410rpx;
  255. }
  256. }
  257. .button-group {
  258. margin: 46rpx auto;
  259. width: 312rpx;
  260. .btn {
  261. font-size: 44rpx;
  262. padding: 20rpx 0;
  263. border-radius: 50rpx;
  264. font-family: "PangMenZhengDao";
  265. color: #954600;
  266. background: linear-gradient(120deg, #FFE6B2, #FFC339);
  267. text-align: center;
  268. }
  269. .close{
  270. margin-top: 80rpx;
  271. justify-content: center;
  272. }
  273. }
  274. }
  275. </style>