冯诚 2 years ago
parent
commit
81342c6546

+ 2 - 0
.env

@@ -0,0 +1,2 @@
+VITE_ORIGIN=https://test.ptcrepair.com.au
+VITE_API_BASE=/api

+ 0 - 1
.env.development

@@ -1 +0,0 @@
-VITE_API_BASE=/api

+ 0 - 1
.env.production

@@ -1 +0,0 @@
-VITE_API_BASE=/api

+ 3 - 0
.env.release

@@ -0,0 +1,3 @@
+NODE_ENV=production
+VITE_ORIGIN=https://www.ptc.net.au
+VITE_API_BASE=/api

+ 1 - 4
src/env.d.ts

@@ -8,14 +8,11 @@ declare module '*.vue' {
 }
 
 interface ImportMetaEnv {
+  VITE_ORIGIN: string
   VITE_API_BASE: string
 }
 
 declare module 'nprogress'
 
-interface Window {
-  fbAsyncInit(): void
-}
-
 declare const FB: any
 declare const google: any

+ 1 - 5
src/pages/gift-card/index.vue

@@ -62,11 +62,7 @@ export default defineComponent({
   async beforeRouteEnter(to, from, next) {
     const { results } = await getGiftCardList(0)
     next(vm => {
-      vm.list = results.items.map(item => {
-        const threshold = item.gift_card_threshold
-        item.gift_card_threshold = threshold ? +threshold : 0
-        return item
-      })
+      vm.list = results.items
       vm.stat = results.stat
     })
   },

+ 10 - 7
src/pages/invite/index.vue

@@ -82,7 +82,7 @@
   </div>
 </template>
 
-<script lang="ts">
+<script>
 import { defineComponent } from 'vue'
 import { string } from 'yup'
 import { inviteFriends, getInviteRewards } from '@/service/user'
@@ -94,22 +94,25 @@ export default defineComponent({
   name: 'InviteFriends',
   async beforeRouteEnter(to, from, next) {
     const { results } = await getInviteRewards()
-    next((vm: any) => (vm.awards = results))
+    next(vm => (vm.awards = results))
   },
   data() {
     return {
       emails: '',
-      awards: [] as any[],
+      /** @type {any[]} */
+      awards: [],
       inviteUrl:
         location.origin +
         '/fill-order?from=member&invitee=' +
-        state.userInfo!.id,
+        state.userInfo.id,
     }
   },
   computed: {
     totalAmount() {
-      // @ts-ignore
-      return this.awards.reduce((sum, award) => sum + award.gift_card_amount, 0)
+      return this.awards.reduce(
+        (sum, award) => sum + +award.gift_card_amount,
+        0
+      )
     },
   },
   methods: {
@@ -127,7 +130,7 @@ export default defineComponent({
         Toast(err.message)
       }
     },
-    copy(content: string) {
+    copy(content) {
       copy(content)
       Toast('copy success')
     },

+ 7 - 1
src/service/order.ts

@@ -30,7 +30,13 @@ export function getPostInfo(member_right_id: string) {
  * @param status 状态:0未使用;1已使用;2已失效
  */
 export function getGiftCardList(status: 0 | 1 | 2) {
-  return request.get('/gift-card/list', { params: { status } })
+  return request.get('/gift-card/list', { params: { status } }).then(res => {
+    res.results.items.forEach((item: any) => {
+      const threshold = item.gift_card_threshold
+      item.gift_card_threshold = threshold ? +threshold : 0
+    })
+    return res
+  })
 }
 
 export function getProductList() {

+ 1 - 1
src/utils/clipboard.ts

@@ -1,6 +1,6 @@
 export default function copyToClipboard(content: string) {
   const input = document.createElement('input')
-  input.style.position = 'absolute'
+  input.style.position = 'fixed'
   input.style.left = '9999px'
   input.value = content
   document.body.appendChild(input)

+ 3 - 3
src/utils/third-login.ts

@@ -37,7 +37,7 @@ export function FBLogin() {
 }
 
 export function AppleLogin() {
-  location.href = 'https://test.ptcrepair.com.au/api/user/apple/login'
+  location.href = '/api/user/apple/login'
 }
 
 export async function renderGoogleLoginButton(parent: HTMLElement) {
@@ -53,8 +53,8 @@ export async function renderGoogleLoginButton(parent: HTMLElement) {
 window.addEventListener('load', () => {
   google.accounts.id.initialize({
     client_id:
-      '745604014349-1dthf8ni49l7313opmcicak5978evvfi.apps.googleusercontent.com',
-    login_uri: 'https://test.ptcrepair.com.au/api/user/google/callback',
+      '393349837160-3opoqoo9l0gk9uimu212gp9uvm72406m.apps.googleusercontent.com',
+    login_uri: import.meta.env.VITE_ORIGIN + '/api/user/google/callback',
     ux_mode: 'redirect',
   })
   gTask.done()