index.vue 8.0 KB

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