index.vue 8.0 KB

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