index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <div class="p-invite">
  3. <div class="p-top">
  4. <div class="award">
  5. <p class="award-name">Invite friends to get</p>
  6. <div class="award-worth">
  7. <span class="num">- $10</span>
  8. <span class="txt">COUPON</span>
  9. </div>
  10. <p class="award-instruction">PTC offline store use</p>
  11. </div>
  12. <div class="desc">
  13. <p class="desc-title"><i class="star"></i>Event Description</p>
  14. <p class="desc-content">
  15. Friends who share your link will get a <strong>$10</strong> coupon. If
  16. a friend buys a membership, you will get a
  17. <strong>$10</strong> coupon. after the purchase, which can be used for
  18. the next membership fee payment and electronic accessories products.
  19. </p>
  20. </div>
  21. <div class="methods">
  22. <div class="ptc-inner-md">
  23. <div class="method">
  24. <p class="method-title">Share your exclusive link with friends</p>
  25. <p class="ptc-comboinput">
  26. <input
  27. type="text"
  28. class="ptc-input"
  29. readonly
  30. value="http://www.ptcplis.com/2333453"
  31. />
  32. <button class="ptc-button">Copy Link</button>
  33. </p>
  34. </div>
  35. <div class="method">
  36. <p class="method-title">Email invitation</p>
  37. <textarea
  38. v-model="emails"
  39. placeholder="Enter email addresses, multiple mailboxes are separated by“ ,”"
  40. ></textarea>
  41. </div>
  42. <button class="ptc-button" @click="invite">Send invitation</button>
  43. </div>
  44. </div>
  45. </div>
  46. <div class="p-bottom">
  47. <h3 class="ptc-title">My Reward ${{ totalAmount }}</h3>
  48. <div class="block records">
  49. <div class="ptc-inner-md">
  50. <ul>
  51. <li v-for="(award, index) of awards" :key="index" class="record">
  52. <span class="left">{{ award.title }}</span>
  53. <span class="center">{{ award.created_at }}</span>
  54. <span class="right">${{ award.gift_card_amount }}</span>
  55. </li>
  56. </ul>
  57. </div>
  58. </div>
  59. <h3 class="ptc-title">Activity Details</h3>
  60. <div class="block details">
  61. <div class="ptc-inner-md">
  62. <p>
  63. After a friend places an order, you can get a corresponding coupon
  64. according to the amount of his first order, which can be used for
  65. the purchase of membership services and consumption at PTC's offline
  66. outlets.
  67. </p>
  68. <p class="mt48">1. The invitee is an unregistered new user;</p>
  69. <p class="mt48">
  70. 2. On the 10th of each month/at 23:00 every day, the invitation
  71. rewards will be settled, and the coupons will be issued to the
  72. personal account
  73. </p>
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. </template>
  79. <script lang="ts">
  80. import { defineComponent } from 'vue'
  81. import { string } from 'yup'
  82. import { inviteFriends, getInviteRewards } from '@/service/user'
  83. import Toast from '@/components/toast'
  84. export default defineComponent({
  85. name: 'InviteFriends',
  86. async beforeRouteEnter(to, from, next) {
  87. const { results } = await getInviteRewards()
  88. next((vm: any) => (vm.awards = results))
  89. },
  90. data() {
  91. return {
  92. emails: '',
  93. awards: [] as any[],
  94. }
  95. },
  96. computed: {
  97. totalAmount() {
  98. // @ts-ignore
  99. return this.awards.reduce((sum, award) => sum + award.gift_card_amount, 0)
  100. },
  101. },
  102. methods: {
  103. async invite() {
  104. if (!this.emails) return Toast('Please enter email addresses')
  105. try {
  106. this.emails
  107. .split(',')
  108. .forEach(email =>
  109. string().email('Please check email addresses').validateSync(email)
  110. )
  111. await inviteFriends(this.emails)
  112. Toast('done')
  113. } catch (err) {
  114. Toast(err.message)
  115. }
  116. },
  117. },
  118. })
  119. </script>
  120. <style lang="scss">
  121. .p-invite {
  122. .p-top {
  123. display: flex;
  124. flex-wrap: wrap;
  125. justify-content: center;
  126. align-items: center;
  127. padding: 8px 0 48px;
  128. background: $primary-color;
  129. overflow: hidden;
  130. @include media-breakpoint-up(md) {
  131. padding: 40px 0 64px;
  132. }
  133. }
  134. .p-bottom {
  135. margin: auto;
  136. @include media-breakpoint-up(lg) {
  137. width: 768px * 2;
  138. }
  139. @include media-breakpoint-up(xl) {
  140. width: 999px * 2;
  141. }
  142. }
  143. .award,
  144. .desc,
  145. .methods {
  146. width: 90%;
  147. }
  148. .award {
  149. @include icon('@img/coupon.png', 98%, 370px);
  150. text-align: center;
  151. overflow: hidden;
  152. @include media-breakpoint-up(md) {
  153. margin-left: -40px;
  154. height: 500px;
  155. width: 880px;
  156. }
  157. @include media-breakpoint-up(xl) {
  158. margin-right: 108px;
  159. width: 960px;
  160. }
  161. &-name {
  162. margin-top: 66px;
  163. font-weight: bold;
  164. font-size: 48px;
  165. color: #193059;
  166. }
  167. &-worth {
  168. margin: 32px 0 24px;
  169. line-height: 56px;
  170. font-weight: 500;
  171. color: #193059;
  172. .num {
  173. font-size: 56px;
  174. }
  175. .txt {
  176. margin-left: 20px;
  177. font-size: 40px;
  178. }
  179. }
  180. &-instruction {
  181. font-size: 28px;
  182. color: #9aa8c5;
  183. }
  184. @include media-breakpoint-up(md) {
  185. &-name {
  186. margin-top: 100px;
  187. font-size: 60px;
  188. }
  189. &-worth {
  190. margin: 54px 0 44px;
  191. .num {
  192. font-size: 80px;
  193. }
  194. .txt {
  195. font-size: 56px;
  196. }
  197. }
  198. &-instruction {
  199. font-size: 40px;
  200. }
  201. }
  202. }
  203. .desc {
  204. padding: 52px 26px 26px;
  205. border: 2px solid rgba(218, 225, 239, 0.25);
  206. color: #dae1ef;
  207. @include media-breakpoint-up(md) {
  208. // margin-left: 134px;
  209. width: 680px;
  210. }
  211. &-title {
  212. @include thin-border(bottom, rgba(218, 225, 239, 0.25));
  213. display: flex;
  214. align-items: center;
  215. justify-content: center;
  216. padding-bottom: 48px;
  217. font-size: 32px;
  218. font-weight: bold;
  219. .star {
  220. @include icon('@img/star.png', 40px);
  221. margin-right: 16px;
  222. }
  223. }
  224. &-content {
  225. margin-top: 26px;
  226. font-size: 28px;
  227. line-height: 40px;
  228. }
  229. strong {
  230. font-size: 32px;
  231. }
  232. }
  233. .methods {
  234. margin-top: 36px;
  235. padding: 64px 36px;
  236. background: #fff;
  237. border-radius: 16px;
  238. @include media-breakpoint-up(md) {
  239. border-radius: 0;
  240. }
  241. @include media-breakpoint-up(lg) {
  242. width: 768px * 2;
  243. }
  244. @include media-breakpoint-up(xl) {
  245. width: 999px * 2;
  246. }
  247. }
  248. .method {
  249. &:nth-child(1) {
  250. margin-bottom: 64px;
  251. }
  252. &:nth-child(2) {
  253. margin-bottom: 24px;
  254. }
  255. &-title {
  256. margin-bottom: 24px;
  257. font-size: 32px;
  258. font-weight: bold;
  259. color: #193059;
  260. }
  261. .ptc-input {
  262. height: 88px;
  263. font-size: 24px;
  264. @include media-breakpoint-up(md) {
  265. font-size: 28px;
  266. }
  267. }
  268. }
  269. textarea {
  270. display: block;
  271. padding: 24px;
  272. width: 100%;
  273. height: 182px;
  274. border-radius: 8px;
  275. border: 2px solid #d9d9d9;
  276. font-size: 28px;
  277. line-height: 40px;
  278. }
  279. .block {
  280. background: #fff;
  281. }
  282. .records {
  283. padding: 0 36px;
  284. }
  285. .record {
  286. display: flex;
  287. justify-content: space-between;
  288. align-items: center;
  289. padding: 36px 0;
  290. + .record {
  291. @include thin-border(top);
  292. }
  293. .left {
  294. font-weight: bold;
  295. font-size: 32px;
  296. color: #1a1a1a;
  297. }
  298. .center,
  299. .right {
  300. font-size: 28px;
  301. color: #666;
  302. }
  303. .center {
  304. padding-right: 50px;
  305. }
  306. }
  307. .details {
  308. padding: 36px;
  309. font-size: 32px;
  310. line-height: 44px;
  311. color: #666;
  312. }
  313. @include media-breakpoint-up(md) {
  314. .ptc-comboinput .ptc-button {
  315. width: 322px;
  316. }
  317. }
  318. }
  319. </style>