[baozhangchao] 3 lat temu
rodzic
commit
57edc7354b

+ 7
- 8
src/app.js Wyświetl plik

@@ -1,6 +1,6 @@
1 1
 import { Component } from 'react'
2 2
 import Taro from '@tarojs/taro'
3
-import store, { StoreRoot } from './store'
3
+import store, { StoreRoot, useModel } from './store'
4 4
 
5 5
 import './app.less'
6 6
 
@@ -11,13 +11,18 @@ class App extends Component {
11 11
 
12 12
   componentDidShow () { }
13 13
   onLaunch (options) {
14
+
15
+    const { logins, setUserLocation } = store.getModel('userData').getState()
16
+
17
+    // const { sserLocation, setUserLocation } = useModel('userData')
18
+
14 19
     // 登录获取人员信息
15 20
 
16 21
     Taro.getLocation({
17 22
       type: 'gcj02',
18 23
       success (res) {
19 24
         const location = `${res.longitude},${res.latitude}`
20
-        Taro.setStorageSync('location', location)
25
+        setUserLocation(location)
21 26
 
22 27
       },
23 28
       fail (err) {
@@ -27,15 +32,9 @@ class App extends Component {
27 32
           title: '获取定位失败',
28 33
           icon: 'none',
29 34
         })
30
-        // 默认邓州
31
-        const location = '112.087493,32.687609';
32
-        Taro.setStorageSync('location', location)
33
-
34
-
35 35
       }
36 36
     })
37 37
 
38
-    const { logins } = store.getModel('userData').getState()
39 38
 
40 39
     Taro.login({
41 40
       success: (res) => {

BIN
src/assets/icons/comm/timeImage.png Wyświetl plik


+ 1
- 1
src/components/ButtontWX/style.less Wyświetl plik

@@ -1,7 +1,7 @@
1 1
 .buttont-box {
2 2
   background: #ff703b;
3 3
   display: flex;
4
-  margin: 0 auto;
4
+  margin: 1em auto;
5 5
   > View {
6 6
     margin: 0 auto;
7 7
     font-weight: 600;

+ 9
- 8
src/components/CarsListContent/index.jsx Wyświetl plik

@@ -5,6 +5,7 @@ import Taro, { useReachBottom } from "@tarojs/taro"
5 5
 import ButtontWX from '@/components/ButtontWX'
6 6
 import withLayout from '@/layouts'
7 7
 import addresss from '@/assets/mineImgaes/addresss.png'//地址
8
+import { useModel } from "@/store"
8 9
 
9 10
 import { getMachinery, } from "@/services/homes"
10 11
 
@@ -12,32 +13,32 @@ import { getMachinery, } from "@/services/homes"
12 13
 import './style.less'
13 14
 
14 15
 export default withLayout((props) => {
15
-  const location = Taro.getStorageSync('location')
16
+  const { sserLocation } = useModel('userData')
16 17
   // const { carsList } = props
17 18
 
18 19
   const [carsList, setCarsList] = useState([])
19 20
 
20 21
 
21 22
   useEffect(() => {
22
-    getMachinery(location).then((e) => {
23
+    getMachinery(sserLocation).then((e) => {
23 24
       setCarsList(e.records)
24 25
     })
25 26
 
26
-  }, [location])
27
+  }, [sserLocation])
27 28
 
28 29
 
29 30
 
30 31
 
31
-  const startReserve = () => {
32
-    Taro.navigateTo({ url: `/pages/OrderConfirmation/index?id${1}` })
32
+  const startReserve = (res) => {
33
+    Taro.navigateTo({ url: `/pages/OrderConfirmation/index?id${res}` })
33 34
 
34 35
   }
35 36
   const goCarsInfo = (res) => {
36
-    Taro.navigateTo({ url: `/pages/CheckDetails/index?id=${res}&location=${location}` })
37
+    Taro.navigateTo({ url: `/pages/CheckDetails/index?id=${res}&location=${sserLocation}` })
37 38
 
38 39
   }
39 40
   const goMapInfo = (res) => {
40
-    Taro.navigateTo({ url: `/pages/CheckMap/index?id=${res}&location=${location}` })
41
+    Taro.navigateTo({ url: `/pages/CheckMap/index?id=${res}&location=${sserLocation}` })
41 42
 
42 43
 
43 44
   }
@@ -58,7 +59,7 @@ export default withLayout((props) => {
58 59
                   <View className='carsListImga-bottom-box-flaxBox-liftText-price'>{item.price}/<Text>公顷</Text></View>
59 60
                 </View>
60 61
                 <View className='carsListImga-bottom-box-flaxBox-rightBut'>
61
-                  <ButtontWX onClick={startReserve} butText='预约' butWidth={80} butHeight={34} butFontSize={19} butBorderRadius={0} />
62
+                  <ButtontWX onClick={() => startReserve(item.machineryId)} butText='预约' butWidth={80} butHeight={34} butFontSize={19} butBorderRadius={0} />
62 63
                 </View>
63 64
               </View>
64 65
               <View className='content-header-box-map' onClick={() => goMapInfo(item.machineryId)}>

+ 80
- 0
src/components/pickerTime/dateTimePicker.js Wyświetl plik

@@ -0,0 +1,80 @@
1
+function withData (param) {
2
+  return param < 10 ? '0' + param : '' + param;
3
+}
4
+function getLoopArray (start, end) {
5
+  var start = start || 0;
6
+  var end = end || 1;
7
+  var array = [];
8
+  for (var i = start; i <= end; i++) {
9
+    array.push(withData(i));
10
+  }
11
+  return array;
12
+}
13
+function getMonthDay (year, month) {
14
+  var flag = year % 400 == 0 || (year % 4 == 0 && year % 100 != 0), array = null;
15
+
16
+  switch (month) {
17
+    case '01':
18
+    case '03':
19
+    case '05':
20
+    case '07':
21
+    case '08':
22
+    case '10':
23
+    case '12':
24
+      array = getLoopArray(1, 31)
25
+      break;
26
+    case '04':
27
+    case '06':
28
+    case '09':
29
+    case '11':
30
+      array = getLoopArray(1, 30)
31
+      break;
32
+    case '02':
33
+      array = flag ? getLoopArray(1, 29) : getLoopArray(1, 28)
34
+      break;
35
+    default:
36
+      array = '月份格式不正确,请重新输入!'
37
+  }
38
+  return array;
39
+}
40
+function getNewDateArry () {
41
+  // 当前时间的处理
42
+  var newDate = new Date();
43
+  var year = withData(newDate.getFullYear()),
44
+    mont = withData(newDate.getMonth() + 1),
45
+    date = withData(newDate.getDate()),
46
+    hour = withData(newDate.getHours()),
47
+    minu = withData(newDate.getMinutes()),
48
+    seco = withData(newDate.getSeconds());
49
+
50
+  return [year, mont, date, hour, minu, seco];
51
+}
52
+function dateTimePicker (startYear, endYear, date) {
53
+  // 返回默认显示的数组和联动数组的声明
54
+  var dateTime = [], dateTimeArray = [[], [], [], [], [], []];
55
+  var start = startYear || 1978;
56
+  var end = endYear || 2100;
57
+  // 默认开始显示数据
58
+  var defaultDate = date ? [...date.split(' ')[0].split('-'), ...date.split(' ')[1].split(':')] : getNewDateArry();
59
+  // 处理联动列表数据
60
+  /*年月日 时分秒*/
61
+  dateTimeArray[0] = getLoopArray(start, end);
62
+  dateTimeArray[1] = getLoopArray(1, 12);
63
+  dateTimeArray[2] = getMonthDay(defaultDate[0], defaultDate[1]);
64
+  dateTimeArray[3] = getLoopArray(0, 23);
65
+  dateTimeArray[4] = getLoopArray(0, 59);
66
+  dateTimeArray[5] = getLoopArray(0, 59);
67
+
68
+  dateTimeArray.forEach((current, index) => {
69
+    dateTime.push(current.indexOf(defaultDate[index]));
70
+  });
71
+
72
+  return {
73
+    dateTimeArray: dateTimeArray,
74
+    dateTime: dateTime
75
+  }
76
+}
77
+module.exports = {
78
+  dateTimePicker: dateTimePicker,
79
+  getMonthDay: getMonthDay
80
+}

+ 63
- 0
src/components/pickerTime/index.js Wyświetl plik

@@ -0,0 +1,63 @@
1
+import dateTimePicker from './dateTimePicker.js'
2
+
3
+Page({
4
+  data: {
5
+    date: '2018-10-01',
6
+    time: '12:00',
7
+    dateTimeArray: null,
8
+    dateTime: null,
9
+    dateTimeArray1: null,
10
+    dateTime1: null,
11
+    startYear: 2000,
12
+    endYear: 2050
13
+  },
14
+  onLoad () {
15
+    // 获取完整的年月日 时分秒,以及默认显示的数组
16
+    var obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
17
+    var obj1 = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
18
+    // 精确到分的处理,将数组的秒去掉
19
+    var lastArray = obj1.dateTimeArray.pop();
20
+    var lastTime = obj1.dateTime.pop();
21
+
22
+    this.setData({
23
+      dateTime: obj.dateTime,
24
+      dateTimeArray: obj.dateTimeArray,
25
+      dateTimeArray1: obj1.dateTimeArray,
26
+      dateTime1: obj1.dateTime
27
+    });
28
+  },
29
+  changeDate (e) {
30
+    this.setData({ date: e.detail.value });
31
+  },
32
+  changeTime (e) {
33
+    this.setData({ time: e.detail.value });
34
+  },
35
+  changeDateTime (e) {
36
+    this.setData({ dateTime: e.detail.value });
37
+  },
38
+  changeDateTime1 (e) {
39
+    this.setData({ dateTime1: e.detail.value });
40
+  },
41
+  changeDateTimeColumn (e) {
42
+    var arr = this.data.dateTime, dateArr = this.data.dateTimeArray;
43
+
44
+    arr[e.detail.column] = e.detail.value;
45
+    dateArr[2] = dateTimePicker.getMonthDay(dateArr[0][arr[0]], dateArr[1][arr[1]]);
46
+
47
+    this.setData({
48
+      dateTimeArray: dateArr,
49
+      dateTime: arr
50
+    });
51
+  },
52
+  changeDateTimeColumn1 (e) {
53
+    var arr = this.data.dateTime1, dateArr = this.data.dateTimeArray1;
54
+
55
+    arr[e.detail.column] = e.detail.value;
56
+    dateArr[2] = dateTimePicker.getMonthDay(dateArr[0][arr[0]], dateArr[1][arr[1]]);
57
+
58
+    this.setData({
59
+      dateTimeArray1: dateArr,
60
+      dateTime1: arr
61
+    });
62
+  }
63
+})

+ 4
- 0
src/components/pickerTime/index.json Wyświetl plik

@@ -0,0 +1,4 @@
1
+{
2
+  "component": true,
3
+  "usingComponents": {}
4
+}

+ 8
- 0
src/components/pickerTime/index.wxml Wyświetl plik

@@ -0,0 +1,8 @@
1
+<view class="tui-picker-content">
2
+  <view class="tui-picker-name">日期时间选择器(精确到分)</view>
3
+  <picker mode="multiSelector" value="{{dateTime1}}" bindchange="changeDateTime1" bindcolumnchange="changeDateTimeColumn1" range="{{dateTimeArray1}}">
4
+    <view class="tui-picker-detail">
5
+      选择日期时间: {{dateTimeArray1[0][dateTime1[0]]}}-{{dateTimeArray1[1][dateTime1[1]]}}-{{dateTimeArray1[2][dateTime1[2]]}} {{dateTimeArray1[3][dateTime1[3]]}}:{{dateTimeArray1[4][dateTime1[4]]}}
6
+    </view>
7
+  </picker>
8
+</view>

+ 0
- 0
src/components/pickerTime/index.wxss Wyświetl plik


+ 16
- 17
src/layouts/index.jsx Wyświetl plik

@@ -6,29 +6,28 @@ import { useEffect } from 'react'
6 6
 import { useModel } from '@/store'
7 7
 
8 8
 
9
-export default (Child) => (props) => {
10
-  const { person } = useModel('userData')
11
-  const router = useRouter()
12 9
 
13
-  const { path } = router
10
+import useLogin from '@/utils/hooks/useLogin'
14 11
 
15
-  useEffect(() => {
16
-    if (!person?.phone) {
17
-      if (path != '/pages/index/index' && path !== '/pages/UserLogin/index') {
18
-        Taro.navigateTo({ url: `/pages/UserLogin/index?id${1}` })
19
-      }
20
-    }
21
-    console.log("🚀 ~ file: index.jsx ~ line 11 ~ person", person, path)
22 12
 
23
-    // if (path != '/pages/index/index' && !person?.phone) {
24
-    //   Taro.navigateTo({ url: `/pages/userInfo/index?id${1}` })
25
-    // }
26
-  }, [path, person?.phone])
13
+export default (Child) => (props) => {
14
+  const { person } = useModel('person')
15
+  const router = useRouter()
27 16
 
17
+  const location = Taro.getStorageSync('location')
28 18
 
19
+  const { hasPhone } = useLogin()
29 20
 
30 21
 
22
+  // Taro.useReady(()=>{
23
+  //   useLogin(person,router)
24
+  // })
25
+  // useEffect(()=>{
26
+  //   useLogin(person,router)
27
+  // },[person, person?.phone, router, router?.path])
31 28
 
32
-  return <Child {...props} router={router} />
29
+  // 确保执行过 login 方法,拿到了 person
30
+  const isLoged = useMemo(() => !!person?.personId, [person?.personId])
33 31
 
34
-}
32
+  return isLoged ? <Child {...props} router={router} location={location} /> : <></>
33
+}

+ 8
- 9
src/pages/CheckMap/index.jsx Wyświetl plik

@@ -2,11 +2,13 @@ import { useEffect, useState } from "react"
2 2
 import { Map, View, Image, Text } from "@tarojs/components"
3 3
 import CustomNav from "@/components/CustomNav"
4 4
 import ButtontWX from "@/components/ButtontWX"
5
+import withLayout from '@/layouts'
6
+
5 7
 import Taro from "@tarojs/taro"
6 8
 import locationImage from "@/assets/icons/comm/locationImage.png"
7 9
 import addresss from '@/assets/mineImgaes/addresss.png'//地址
8 10
 import { getMachineryInfo } from "@/services/homes"
9
-
11
+import { useModel } from "@/store"
10 12
 import './style.less'
11 13
 
12 14
 
@@ -16,16 +18,13 @@ export default withLayout((props) => {
16 18
   const $instance = Taro.getCurrentInstance()
17 19
   const { id, location } = $instance.router.params
18 20
 
19
-  const [mapLoca, setMapLoca] = useState('')
20
-  Taro.getStorage({
21
-    key: 'location',
22
-    success: function (res) {
23
-      setMapLoca(res.data)
24
-    }
25
-  })
21
+
22
+  const { sserLocation } = useModel('userData')
23
+
24
+
26 25
 
27 26
 
28
-  const LocationMap = mapLoca.split(",")
27
+  const LocationMap = sserLocation.split(",")
29 28
   console.log("🚀 ~ file: index.jsx ~ line 25 ~ LocationMap", LocationMap)
30 29
 
31 30
 

+ 2
- 8
src/pages/FeedbackText/index.jsx Wyświetl plik

@@ -4,9 +4,9 @@ import CustomNav from "@/components/CustomNav"
4 4
 import ButtontWX from "@/components/ButtontWX"
5 5
 import { feedback } from "@/services/mine"
6 6
 import withLayout from '@/layouts'
7
-
8 7
 import Taro from "@tarojs/taro"
9 8
 
9
+
10 10
 import './style.less'
11 11
 
12 12
 
@@ -25,9 +25,7 @@ export default withLayout((props) => {
25 25
         icon: 'none',
26 26
         duration: 2000
27 27
       })
28
-
29 28
     } else {
30
-
31 29
       feedback({ content: textAreaValue }).then(() => {
32 30
         Taro.showToast({
33 31
           title: '反馈已收到!',
@@ -38,10 +36,7 @@ export default withLayout((props) => {
38 36
             setLoading(true)
39 37
             Taro.navigateBack({
40 38
               delta: 1
41
-            }
42
-
43
-
44
-            )
39
+            })
45 40
           }, 1000)
46 41
 
47 42
         })
@@ -49,7 +44,6 @@ export default withLayout((props) => {
49 44
     }
50 45
 
51 46
 
52
-
53 47
   }
54 48
 
55 49
   return (

+ 1
- 0
src/pages/OrderConfirmation/index.config.js Wyświetl plik

@@ -4,6 +4,7 @@ export default {
4 4
   navigationStyle: 'custom',
5 5
   disableScroll: true,
6 6
   usingComponents: {
7
+    "mp-pickerTime": '../../components/pickerTime/index'
7 8
   }
8 9
 
9 10
 }

+ 84
- 14
src/pages/OrderConfirmation/index.jsx Wyświetl plik

@@ -1,28 +1,70 @@
1
-import { View, Text } from "@tarojs/components"
1
+import { View, Image, Form, Input, Picker } from "@tarojs/components"
2 2
 import Taro from "@tarojs/taro"
3
-import { useState } from "react"
3
+import { useEffect, useState } from "react"
4 4
 import withLayout from '@/layouts'
5
+import { useModel } from "@/store"
6
+import addresss from '@/assets/mineImgaes/addresss.png'//地址
7
+import timeImage from '@/assets/icons/comm/timeImage.png'//日期图片
5 8
 
6 9
 import CustomNav from '@/components/CustomNav'
7 10
 import ButtontWX from '@/components/ButtontWX'
11
+import { generateOrder } from "@/services/order"
8 12
 // import BottomMoadl from '@/components/BottomMoadl/index'
9
-
10
-
11
-
13
+import { getMachineryInfo } from "@/services/homes"
12 14
 
13 15
 
14 16
 
15 17
 import './style.less'
16 18
 
17
-export default withLayout((props) => {
19
+//为了调试,删除了withLayout 记得加上 如果我忘记的话
20
+
21
+export default (props) => {
18 22
   //底部弹窗
19 23
   // const [showFrame, setShowFrame] = useState(false)
20 24
   // const setRecommend = () => {
21 25
   //   setShowFrame(!showFrame)
22 26
   // }
23 27
 
24
-  const okgoPay = () => {
25
-    Taro.navigateTo({ url: `/pages/OrderInfo/index?id${1}` })
28
+  const $instance = Taro.getCurrentInstance()
29
+  const { id } = $instance.router.params
30
+  const { sserLocation, setUserLocation } = useModel('userData')
31
+
32
+  const [timeSel, setTimeSel] = useState('')
33
+  const [carsInfo, setCarsInfo] = useState({})
34
+
35
+
36
+  const formSubmit = (e) => {
37
+    console.log('表单输入', e);
38
+    Taro.navigateTo({ url: `/pages/OrderInfo/index?goOrder=${id}` })
39
+    // generateOrder({
40
+    //   charges: 200,
41
+    //   price: 100,
42
+    //   amount: 20,
43
+    //   machineryId: '7cdf832d7a7af0c19ab33418e10e1a94',
44
+    //   machineryName: '第一台播种机',
45
+    //   machineryType: 'b4d183f684ed1f3d1cb2194c1975ae46',
46
+    //   typeName: '播种机',
47
+    //   address: '我是作业地址:房屋后面',
48
+    //   appontmentDate: new Date(),
49
+    // }).then(() => {
50
+    //   Taro.navigateTo({ url: `/pages/OrderInfo/index?goOrder=${id}` })
51
+
52
+    // })
53
+  }
54
+  useEffect(() => {
55
+    // if (id) {
56
+    //   getMachineryInfo(id, { location: sserLocation, attached: true }).then((e) => {
57
+    //     setCarsInfo(e)
58
+    //     console.log('e', e);
59
+    //   })
60
+    // }
61
+
62
+
63
+  })
64
+  const onTimeChange = (e) => {
65
+    console.log('时间选择器', e);
66
+    setTimeSel(e.detail.value)
67
+
26 68
   }
27 69
   const cancelPay = () => {
28 70
     Taro.navigateBack({
@@ -38,14 +80,42 @@ export default withLayout((props) => {
38 80
         <CustomNav title='订单确认' />
39 81
       </View>
40 82
       {/* <BottomMoadl frameTitle='支付方式' flag={showFrame} onRecommend={setRecommend} /> */}
41
-      <View>
83
+      <View className='pagesBox'>
84
+        <Form onSubmit={formSubmit}  >
85
+          <View className='example-body-WorkingArea'>
86
+            <View>作业面积/公顷</View>
87
+            <Input name='address' placeholder='请输入具体面积(公顷)' />
88
+          </View>
89
+          <View className='example-body-WorkingTime'>
90
+            <View>作业时间:</View>
91
+            <View className='example-body-WorkingTime-TimePicker'>
92
+              <Image src={timeImage} />
42 93
 
43
-      </View>
44
-      <View className='BottomtBut' >
45
-        <ButtontWX butText='取消' onClick={cancelPay} butWidth={123} butHeight={39} butFontSize={16} butBorderRadius={49} />
94
+              <Picker mode='date' onChange={onTimeChange}>
95
+                <View className='picker' >
96
+                  请选择时间 {timeSel}
97
+                </View>
98
+              </Picker>
99
+            </View>
100
+
101
+          </View>
102
+          <View className='example-body-WorkingLocation'>
103
+            <View>作业位置:</View>
104
+            <View className='example-body-WorkingLocation-info'>
105
+              <Image src={addresss} />
106
+              <View>这就是我的地址位置为位置位置位置位置为阿斯顿撒旦</View>
107
+            </View>
108
+          </View>
109
+
110
+          <View className='BottomtBut' >
111
+            <ButtontWX butText='确定' onClick={formSubmit} butWidth={346} butHeight={49} butFontSize={16} butBorderRadius={49} />
112
+
113
+            <ButtontWX butText='取消' onClick={cancelPay} butWidth={346} butHeight={49} butFontSize={16} butBorderRadius={49} />
114
+          </View>
115
+        </Form>
46 116
 
47
-        <ButtontWX butText='确定' onClick={okgoPay} butWidth={123} butHeight={39} butFontSize={16} butBorderRadius={49} />
48 117
       </View>
118
+
49 119
     </View>
50 120
   )
51
-})
121
+}

+ 65
- 2
src/pages/OrderConfirmation/style.less Wyświetl plik

@@ -1,4 +1,67 @@
1
+.pagesBox {
2
+  width: 94vw;
3
+  margin: 0 auto;
4
+  .example-body-WorkingArea {
5
+    font-size: 35px;
6
+    font-weight: 600;
7
+    > Input {
8
+      padding: 10px 0;
9
+      height: 4vh;
10
+      border-bottom: 1px solid rgba(0, 0, 0, 0.2);
11
+      font-weight: 100;
12
+    }
13
+  }
14
+
15
+  .example-body-WorkingTime {
16
+    font-size: 35px;
17
+    font-weight: 600;
18
+    margin-top: 1em;
19
+    &-TimePicker {
20
+      border-bottom: 1px solid rgba(0, 0, 0, 0.2);
21
+
22
+      display: flex;
23
+      align-items: center;
24
+      margin: 1em auto;
25
+      padding-bottom: 1em;
26
+
27
+      > Image {
28
+        width: 34px;
29
+        height: 34px;
30
+        padding-right: 15px;
31
+      }
32
+    }
33
+  }
34
+
35
+  .example-body-WorkingLocation {
36
+    font-size: 35px;
37
+    font-weight: 600;
38
+    margin-top: 1em;
39
+
40
+    &-info {
41
+      display: flex;
42
+      align-items: center;
43
+      border-bottom: 1px solid rgba(0, 0, 0, 0.2);
44
+      margin: 1em auto;
45
+      padding-bottom: 1em;
46
+      > Image {
47
+        width: 34px;
48
+        height: 34px;
49
+        padding-right: 10px;
50
+      }
51
+      > View {
52
+        width: 80vw;
53
+        overflow: hidden;
54
+        text-overflow: ellipsis;
55
+        white-space: nowrap;
56
+        font-weight: 100;
57
+        color: #000;
58
+      }
59
+    }
60
+  }
61
+}
62
+
1 63
 .BottomtBut {
2
-  width: 99vw;
3
-  display: flex;
64
+  padding-top: 2em;
65
+  margin: 0 auto;
66
+  // display: flex;
4 67
 }

+ 2
- 1
src/pages/OrderInfo/index.jsx Wyświetl plik

@@ -19,7 +19,7 @@ import './style.less'
19 19
 export default withLayout((props) => {
20 20
 
21 21
   const $instance = Taro.getCurrentInstance()
22
-  const { orderId } = $instance.router.params
22
+  const { orderId, goOrder } = $instance.router.params
23 23
 
24 24
   const [orderInfos, setOrderInfos] = useState()
25 25
   //底部弹窗
@@ -61,6 +61,7 @@ export default withLayout((props) => {
61 61
         setOrderInfos(res)
62 62
       })
63 63
     } else {
64
+
64 65
       Taro.showToast({
65 66
         title: '暂无订单详情',
66 67
         icon: 'error',

+ 0
- 2
src/pages/index/index.jsx Wyświetl plik

@@ -15,7 +15,6 @@ import './index.less'
15 15
 export default withLayout((props) => {
16 16
   const { router } = props
17 17
   const { person } = useModel('userData')
18
-  console.log("🚀 ~ file: index.jsx ~ line 18 ~ withLayout ~ person", person)
19 18
 
20 19
   const { params, path } = router
21 20
   const { tab } = params || {}
@@ -24,7 +23,6 @@ export default withLayout((props) => {
24 23
 
25 24
   const [isDidShow, setIsDidShow] = useState(0)
26 25
 
27
-
28 26
   useDidShow(() => {
29 27
     setIsDidShow(isDidShow + 1)
30 28
   })

+ 2
- 2
src/pages/index/tabs/Homes.jsx Wyświetl plik

@@ -13,7 +13,7 @@ import { useModel } from "@/store"
13 13
 import './HomesCss/style.less'
14 14
 
15 15
 export default withLayout((props) => {
16
-  const location = Taro.getStorageSync('location')
16
+  const { sserLocation } = useModel('userData')
17 17
   const [bannerHome, setBannerHome] = useState([])
18 18
   const [carsList, setCarsList] = useState([])
19 19
 
@@ -25,7 +25,7 @@ export default withLayout((props) => {
25 25
       console.log('e', e);
26 26
       setBannerHome(e)
27 27
     })
28
-    getMachinery(location).then((e) => {
28
+    getMachinery(sserLocation).then((e) => {
29 29
       setCarsList(e.records)
30 30
     })
31 31
 

+ 3
- 5
src/pages/index/tabs/Mine.jsx Wyświetl plik

@@ -12,11 +12,9 @@ import userMoren from '@/assets/mineImgaes/userMoren.png'//默认头像
12 12
 import userRight from '@/assets/mineImgaes/userRight.png'
13 13
 import { useModel } from "@/store"
14 14
 import withLayout from '@/layouts'
15
-
16 15
 import { getAddress } from "@/services/address"
17 16
 
18 17
 
19
-
20 18
 import './MineCss/style.less'
21 19
 
22 20
 
@@ -117,16 +115,16 @@ export default withLayout((props) => {
117 115
                 <View className='setPassword' onClick={goUserInfo}>修改个人信息</View>
118 116
                 <Image className='User-Avatar-background-trueBox-userImg' src={userInfo?.avatar || userMoren} />
119 117
                 <View className='User-Avatar-background-trueBox-name'>
120
-                  <View >{userInfo?.nickName}</View>
118
+                  <View >{userInfo?.nickName || '请填写姓名'}</View>
121 119
                   <View >{userInfo?.phone}</View>
122 120
                 </View>
123
-
124 121
               </View>
122
+
125 123
               <UserCellBox title='地址信息'>
126 124
                 <View className='addresss-box' onClick={setAddress} >
127 125
                   <Image className='addresss-box-images' src={addresss} />
128 126
                   <View className='addresss-box-contents'>
129
-                    <View className='addresss-box-contents-texts' >{addresInfo}</View>
127
+                    <View className='addresss-box-contents-texts' >{addresInfo || '请填写详细地址'}</View>
130 128
                     <View>》</View>
131 129
                   </View>
132 130
                 </View>

+ 0
- 1
src/pages/index/tabs/Orders.jsx Wyświetl plik

@@ -84,7 +84,6 @@ export default withLayout((props) => {
84 84
   }
85 85
 
86 86
 
87
-
88 87
   return (
89 88
     <scroll-view scrollY style='height: 100%;' >
90 89
 

+ 9
- 1
src/store/userData.js Wyświetl plik

@@ -8,7 +8,12 @@ export default () => {
8 8
   const [sessionKey, setSessionKey] = useState()
9 9
   const [userPhoneInfo, setUserPhoneInfo] = useState()
10 10
 
11
-  console.log("🚀 ~ file: userData.js ~ line 8 ~ person", person)
11
+
12
+  const [sserLocation, setUserLocation] = useState('')
13
+
14
+
15
+  console.log("🚀 来自store的打印 person数据", person)
16
+  console.log("🚀 来自store的打印 sserLocation定位", sserLocation)
12 17
 
13 18
 
14 19
 
@@ -30,6 +35,9 @@ export default () => {
30 35
     userPhoneInfo,
31 36
     setUserPhoneInfo,
32 37
 
38
+    sserLocation,
39
+    setUserLocation,
40
+
33 41
     logins,
34 42
   }
35 43
 }

+ 27
- 0
src/utils/hooks/useLogin.js Wyświetl plik

@@ -0,0 +1,27 @@
1
+import Taro, { useRouter, useDidShow } from "@tarojs/taro";
2
+import { useModel } from '@/store'
3
+import { useEffect, useMemo } from "react";
4
+
5
+const whiteList = [
6
+  "/pages/login/index",
7
+  "/pages/index/index"
8
+]
9
+
10
+export default () => {
11
+  const router = useRouter()
12
+  const { person } = useModel('person')
13
+
14
+  const isInWhiteList = useMemo(() => whiteList.includes(router.path), [router.path])
15
+  const hasPhone = useMemo(() => !!person?.phone, [person?.phone])
16
+
17
+
18
+  useEffect(() => {
19
+    if (!isInWhiteList && !hasPhone) {
20
+      Taro.navigateTo({ url: "/pages/login/index" });
21
+    }
22
+  }, [hasPhone, isInWhiteList])
23
+
24
+
25
+
26
+  return { hasPhone, isInWhiteList }
27
+};