Browse Source

维修接口相关

冯诚 2 years ago
parent
commit
208c8ea23a

+ 3 - 2
src/pages/repaire/appointment.vue

@@ -19,9 +19,10 @@ const Component = computed(
   () => [StepOne, StepTwo, StepThree, StepFive][state.step]
 )
 const fromPath = history.state.back
-const { query } = useRoute()
+const { id, right_id } = useRoute().query as any
 
-if (query.id) state.repairId = query.id as string
+id && (state.repairId = id)
+right_id && (state.rightId = right_id)
 
 onBeforeRouteLeave((to, from) => {
   if (to.path === fromPath && to.path !== '/' && state.step > 0) {

+ 10 - 5
src/pages/repaire/steps/StepOne.vue

@@ -29,14 +29,14 @@
               v-for="(item, index) of list"
               :key="index"
               class="shop-item border-bottom"
-              @click="!item.can_appointment && selectShop(item)"
+              @click="item.can_appointment && selectShop(item)"
             >
               <div class="shop-name">
                 <span>{{ item.name }}</span>
-                <span>3.5KM</span>
+                <!-- <span>3.5KM</span> -->
               </div>
               <div class="shop-address">
-                {{ item.shop_detail }},{{ item.address }}
+                {{ item.centre_name }},{{ item.address }}
               </div>
               <div class="shop-mark" :class="{ danger: !item.can_appointment }">
                 <i class="icon"></i
@@ -66,7 +66,7 @@ const loading = ref(false)
 const hasMore = ref(true)
 const list = ref<any[]>()
 let pageNo = 1
-let coords: any = null
+let coords: GeolocationCoordinates | undefined
 
 async function fetchData() {
   loading.value = true
@@ -76,7 +76,12 @@ async function fetchData() {
       const res = await getLocation({ timeout: 2000 })
       coords = res?.coords
     }
-    const { results, pageBean } = await getShopList({})
+    const { results, pageBean } = await getShopList({
+      page: pageNo,
+      size: 10,
+      lat: coords?.latitude,
+      lng: coords?.longitude,
+    })
     list.value.push(...results)
     pageNo++
     hasMore.value = list.value.length === pageBean.totalCount

+ 4 - 4
src/pages/repaire/steps/StepThree.vue

@@ -4,7 +4,7 @@
     <div class="ptc-inner">
       <div class="shop-name">{{ state.shop.name }}</div>
       <div class="shop-address">
-        {{ state.shop.address }}
+        {{ state.shop.centre_name }},{{ state.shop.address }}
       </div>
       <div class="shop-action">
         <span class="modify" @click="state.step = 0">Modify ></span>
@@ -71,7 +71,7 @@ onMounted(async () => {
 })
 
 async function submit() {
-  if (!state.phoneNumber) return Toast('Please enter a phone number')
+  if (!state.phoneNumber) return Toast('Please enter your phone number')
   const commonParams = {
     igeektek_id: state.shop.igeektek_id,
     pickup_time: state.date + ' ' + state.period,
@@ -79,8 +79,8 @@ async function submit() {
     remark: state.remark || '',
   }
   const request = state.repairId
-    ? rescheduleRepair({ id: +state.repairId, ...commonParams })
-    : applyRepair({ ...commonParams })
+    ? rescheduleRepair({ id: state.repairId, ...commonParams })
+    : applyRepair({ right_id: state.rightId, ...commonParams })
   await request
   state.step++
 }

+ 2 - 9
src/pages/repaire/steps/StepTwo.vue

@@ -2,10 +2,9 @@
   <h3 class="ptc-title">Appointment</h3>
   <div class="ptc-block">
     <div class="ptc-inner">
-      <div class="shop-name">PTC Browns Plains Kiosk</div>
+      <div class="shop-name">{{ state.shop.name }}</div>
       <div class="shop-address pr">
-        Browns Plains Grand Plaza Shopping Centre, Shop K007 27-49 Browns Plains
-        Road, Browns Plains, QLD, 4118 (07) 3059 1014
+        {{ state.shop.centre_name }},{{ state.shop.address }}
       </div>
       <div class="shop-action">
         <span class="modify" @click="state.step--">Modify ></span>
@@ -83,11 +82,6 @@ const nex7Days = (function getNext7Days() {
     })
 })()
 
-// watch(
-//   () => state.period,
-//   val => state.date && val && setTimeout(() => state.step++, 200)
-// )
-
 async function onDateChange(date: string) {
   state.period = ''
   state.periods = (
@@ -103,7 +97,6 @@ async function onDateChange(date: string) {
 }
 
 function onPeriodChange(val: string) {
-  state.period = val
   state.uiPeriod = state.periods.find(item => item.interface_time === val)!.time
   state.date && setTimeout(() => state.step++, 200)
 }

+ 1 - 0
src/pages/repaire/store.ts

@@ -3,6 +3,7 @@ import { reactive } from 'vue'
 const initialState = {
   step: 0,
   repairId: '',
+  rightId: '',
   shop: null as any,
   periods: [] as any[],
   uiDate: '',

+ 1 - 1
src/service/repair.ts

@@ -2,7 +2,7 @@ import request from './request'
 
 /** 获取零售店列表 */
 export function getShopList(params: any) {
-  return request.get('/shop/list', { params })
+  return request.get('/shop/list', { params, baseURL: '/v2' })
 }
 
 /** 获取店铺可预约的时间段 */

+ 5 - 0
vite.config.ts

@@ -28,6 +28,11 @@ export default defineConfig(({ command }) => ({
         changeOrigin: true,
         rewrite: path => path.replace(/^\/api/, ''),
       },
+      '/v2': {
+        target: 'http://t.ptcrepair.com.au',
+        changeOrigin: true,
+        rewrite: path => path.replace(/^\/v2/, ''),
+      },
     },
   },
 }))