Sfoglia il codice sorgente

fix(client): 优化首页代码

yizhiyang 10 mesi fa
parent
commit
1fa16732c4

+ 63 - 0
src/mixin/list.js

@@ -84,3 +84,66 @@ module.exports = {
     },
     },
   },
   },
 };
 };
+
+// module.exports = {
+// 	data() {
+// 		return {
+// 			pageLoading: false, // 加载页面
+// 			scrollBackTop: 0,
+// 			total: 0,
+// 			listInfo: [],
+// 			loadingType: 'more',
+// 			listApiName: '',
+// 			page: {
+// 				page: 1,
+// 				size: 10
+// 			}
+// 		}
+// 	},
+// 	// 上拉加载
+// 	onReachBottom() {
+// 		this.loadData()
+// 	},
+// 	// 返回顶部
+// 	onPageScroll(e) {
+// 		this.scrollBackTop = e.scrollTop
+// 	},
+// 	created() {},
+// 	methods: {
+// 		// 初始化数据
+// 		initDataList(apiName = 'list', isUp) {
+// 			this.listApiName = apiName
+// 			this.pageLoading = true
+// 			uni.y.showLoading()
+// 			if (!isUp) this.page.page = 1
+// 			uni.api[apiName]({
+// 				search: this.search,
+// 				page: this.page
+// 			}).then(res => {
+// 				if (isUp) {
+// 					this.listInfo = this.listInfo.concat(res.data)
+// 				} else {
+// 					this.listInfo = res.data
+// 					this.loadingType = 'no-more'
+// 				}
+// 				this.total = res.page.total
+// 			}).catch(err => {
+// 				throw err
+// 			}).finally(() => {
+// 				uni.hideLoading()
+// 				this.pageLoading = false
+// 			})
+// 		},
+// 		//加载列表,上滑加载
+// 		loadData() {
+// 			this.loadingType = 'loading'
+// 			if (this.listInfo.length < this.total) {
+// 				this.page.page++
+// 				this.initDataList(this.listApiName, true)
+// 			} else {
+// 				this.page.page = 1
+// 				this.loadingType = 'no-more'
+// 			}
+// 		}
+// 	}
+// }

+ 2 - 6
src/pages.json

@@ -16,20 +16,19 @@
     {
     {
       "path": "pages/login/index",
       "path": "pages/login/index",
       "style": {
       "style": {
-        "navigationBarTitleText": "登录",
         "navigationStyle": "custom"
         "navigationStyle": "custom"
       }
       }
     },
     },
     {
     {
       "path": "pages/phoneLogin/index",
       "path": "pages/phoneLogin/index",
       "style": {
       "style": {
-        "navigationBarTitleText": "账号登录"
+        "navigationStyle": "custom"
       }
       }
     },
     },
     {
     {
       "path": "pages/webview/index",
       "path": "pages/webview/index",
       "style": {
       "style": {
-        "navigationBarTitleText": ""
+        "navigationStyle": "custom"
       }
       }
     },
     },
     {
     {
@@ -43,14 +42,12 @@
     {
     {
       "path": "pages/message/index",
       "path": "pages/message/index",
       "style": {
       "style": {
-        "navigationBarTitleText": "",
         "navigationStyle": "custom"
         "navigationStyle": "custom"
       }
       }
     },
     },
     {
     {
       "path": "pages/mine/index",
       "path": "pages/mine/index",
       "style": {
       "style": {
-        "navigationBarTitleText": "",
         "navigationStyle": "custom"
         "navigationStyle": "custom"
       }
       }
     },
     },
@@ -324,7 +321,6 @@
         {
         {
           "path": "index",
           "path": "index",
           "style": {
           "style": {
-            "navigationBarTitleText": "",
             "navigationStyle": "custom"
             "navigationStyle": "custom"
           }
           }
         },
         },

+ 3 - 2
src/pages/home/index.vue

@@ -113,7 +113,7 @@ export default {
         latitude: '',
         latitude: '',
         region: '',
         region: '',
       },
       },
-      nowAddress: '', //当前地址
+      nowAddress: '地址', //当前地址
     };
     };
   },
   },
   computed: {
   computed: {
@@ -160,6 +160,7 @@ export default {
       getCurrentLocation({
       getCurrentLocation({
         point,
         point,
       }).then(res => {
       }).then(res => {
+        console.log(res.data, '获取当前经纬度');
         let { city, district, id } = res.data;
         let { city, district, id } = res.data;
         this.queryParams.region = res.data.id;
         this.queryParams.region = res.data.id;
         if (district) {
         if (district) {
@@ -197,7 +198,7 @@ export default {
     },
     },
     // 手动选择城市
     // 手动选择城市
     manualGetLocation() {
     manualGetLocation() {
-      this.$Router.push('/pagesHome/homeAddress/index');
+      uni.$u.route('/pagesHome/homeAddress/index');
       // uni.chooseLocation({
       // uni.chooseLocation({
       //   success: res => {
       //   success: res => {
       //     let { longitude, latitude } = res;
       //     let { longitude, latitude } = res;

+ 2 - 0
src/pages/login/index.vue

@@ -1,5 +1,7 @@
 <template>
 <template>
   <view class="container">
   <view class="container">
+    <page-navbar bgColor="#fff" title="登录"></page-navbar>
+
     <view class="t-b">欢迎登录车旅程!</view>
     <view class="t-b">欢迎登录车旅程!</view>
     <view class="t-b2">欢迎使用车旅程,为你提供便捷服务</view>
     <view class="t-b2">欢迎使用车旅程,为你提供便捷服务</view>
 
 

+ 2 - 0
src/pages/phoneLogin/index.vue

@@ -1,5 +1,7 @@
 <template>
 <template>
   <view class="t-login">
   <view class="t-login">
+    <page-navbar bgColor="#fff" title="验证码登录"></page-navbar>
+
     <view class="t-b">欢迎登录车旅程!</view>
     <view class="t-b">欢迎登录车旅程!</view>
     <view class="t-b2">欢迎使用车旅程,为你提供便捷服务</view>
     <view class="t-b2">欢迎使用车旅程,为你提供便捷服务</view>
     <!-- 表单数据 -->
     <!-- 表单数据 -->

+ 5 - 5
src/store/getters.js

@@ -1,7 +1,7 @@
 const getters = {
 const getters = {
   // app 系统信息
   // app 系统信息
   app: state => state.app,
   app: state => state.app,
-  currentTab: state =>state.app.currentTab,
+  currentTab: state => state.app.currentTab,
   // auth 信息
   // auth 信息
   id: state => state.auth.id,
   id: state => state.auth.id,
   accessToken: state => state.auth.accessToken,
   accessToken: state => state.auth.accessToken,
@@ -14,10 +14,10 @@ const getters = {
   userId: state => state.user.userId,
   userId: state => state.user.userId,
   gender: state => state.user.gender,
   gender: state => state.user.gender,
   avatar: state => state.user.avatar,
   avatar: state => state.user.avatar,
-  nickname: state => state.user.nickname,
-  invitationCode:state => state.user.invitationCode,
-
-  location: state => state.data.location
+  nickname: state => state.user.nickname,
+  invitationCode: state => state.user.invitationCode,
+  // 经纬度信息
+  location: state => state.data.location,
 };
 };
 
 
 export default getters;
 export default getters;

+ 3 - 3
src/store/modules/app.js

@@ -5,7 +5,7 @@ export default {
   }),
   }),
   mutations: {
   mutations: {
     SET_APP_SYSTEM(state, info) {
     SET_APP_SYSTEM(state, info) {
-      state.system = info
+      state.system = info;
     },
     },
     // SET_CURRENT_TAB(state, currentTab) {
     // SET_CURRENT_TAB(state, currentTab) {
     //   state.currentTab = currentTab
     //   state.currentTab = currentTab
@@ -13,7 +13,7 @@ export default {
   },
   },
   actions: {
   actions: {
     getAppSystemInfo({ commit }) {
     getAppSystemInfo({ commit }) {
-      commit('SET_APP_SYSTEM', uni.getSystemInfoSync())
+      commit('SET_APP_SYSTEM', uni.getSystemInfoSync());
     },
     },
     UpdateMiniVersion() {
     UpdateMiniVersion() {
       const updateManager = wx.getUpdateManager();
       const updateManager = wx.getUpdateManager();
@@ -35,6 +35,6 @@ export default {
       updateManager.onUpdateFailed(function () {
       updateManager.onUpdateFailed(function () {
         // 新版本下载失败
         // 新版本下载失败
       });
       });
-    }
+    },
   },
   },
 };
 };

+ 12 - 12
src/store/modules/auth.js

@@ -47,7 +47,7 @@ export default {
         secret: 'chelvc@secret#2023!',
         secret: 'chelvc@secret#2023!',
         code: payload.code,
         code: payload.code,
         mobile: payload.mobile,
         mobile: payload.mobile,
-      }
+      };
       return new Promise((resolve, reject) => {
       return new Promise((resolve, reject) => {
         loginByWxLoginCode(data)
         loginByWxLoginCode(data)
           .then(res => {
           .then(res => {
@@ -61,7 +61,7 @@ export default {
               // commit('SET_SCOPE', res.data.scope);
               // commit('SET_SCOPE', res.data.scope);
               resolve();
               resolve();
             } else {
             } else {
-              reject(res)
+              reject(res);
             }
             }
           })
           })
           .catch(err => {
           .catch(err => {
@@ -76,8 +76,8 @@ export default {
         secret: 'chelvc@secret#2023!',
         secret: 'chelvc@secret#2023!',
         code: payload.code,
         code: payload.code,
         mobile: payload.mobile,
         mobile: payload.mobile,
-        captcha: payload.captcha
-      }
+        captcha: payload.captcha,
+      };
       return new Promise((resolve, reject) => {
       return new Promise((resolve, reject) => {
         loginByPhoneAndSmsCode(data)
         loginByPhoneAndSmsCode(data)
           .then(res => {
           .then(res => {
@@ -93,10 +93,10 @@ export default {
               resolve();
               resolve();
             } else {
             } else {
               uni.showToast({
               uni.showToast({
-              	title:res.message,
-				icon:'none'
-              })
-			  return
+                title: res.message,
+                icon: 'none',
+              });
+              return;
             }
             }
           })
           })
           .catch(err => {
           .catch(err => {
@@ -124,7 +124,7 @@ export default {
       const data = {
       const data = {
         id: 'chelvc_client',
         id: 'chelvc_client',
         secret: 'chelvc@secret#2023!',
         secret: 'chelvc@secret#2023!',
-      }
+      };
       return new Promise((resolve, reject) => {
       return new Promise((resolve, reject) => {
         logout(data)
         logout(data)
           .then(res => {
           .then(res => {
@@ -138,13 +138,13 @@ export default {
               commit('SET_DURATION', 0);
               commit('SET_DURATION', 0);
               resolve();
               resolve();
             } else {
             } else {
-              reject()
+              reject();
             }
             }
           })
           })
           .catch(err => {
           .catch(err => {
             reject(err);
             reject(err);
           });
           });
       });
       });
-    }
-  }
+    },
+  },
 };
 };

+ 24 - 11
src/store/modules/data.js

@@ -1,16 +1,14 @@
-
-
 export default {
 export default {
   state: () => ({
   state: () => ({
-    location:  {
+    location: {
       longitude: 0,
       longitude: 0,
       latitude: 0,
       latitude: 0,
-      region:null,
-	  address:null
+      region: null,
+      address: null,
     },
     },
-    categories:  [],
-    storeInfo:  {},  //店铺信息
-    legalInfo:  {},  //法人信息
+    categories: [],
+    storeInfo: {}, //店铺信息
+    legalInfo: {}, //法人信息
     aptitudeInfo: {}, //资质信息
     aptitudeInfo: {}, //资质信息
     merchantInfo: {}, // 商家个人信息
     merchantInfo: {}, // 商家个人信息
   }),
   }),
@@ -31,10 +29,25 @@ export default {
     SET_APTITUDEINFO(state, data) {
     SET_APTITUDEINFO(state, data) {
       state.aptitudeInfo = data;
       state.aptitudeInfo = data;
     },
     },
-    SET_MERCHANTINFO(state, data) {
-		console.log("商家信息存储了")
+    SET_MERCHANTINFO(state, data) {
       state.merchantInfo = data;
       state.merchantInfo = data;
     },
     },
   },
   },
-  actions: {},
+  actions: {
+    // 首页接口 - 获取当前位置
+    getLocationNow({ commit }, payload) {
+      let location = {
+        latitude: payload.latitude,
+        longitude: payload.longitude,
+      };
+
+      let point = `${location.latitude},${location.longitude}`;
+
+      return new Promise((resolve, reject) => {
+        getCurrentLocation({ point }).then(res => {
+          console.log(res, '11111111111111');
+        });
+      });
+    },
+  },
 };
 };

+ 16 - 16
src/store/modules/order.js

@@ -1,16 +1,16 @@
-export default{
-	namespaced:true,
-	state:{
-		order_list:null,
-    skip_order_type:{}
-	},
-	mutations:{
-		// 获取订单信息
-		GET_ORDER_LIST(state,value){
-			state.order_list = value
-		},
-    GET_ORDER_TYPE(state,value){
-      state.skip_order_type = value
-    }
-	}
-}
+export default {
+  namespaced: true,
+  state: {
+    order_list: null,
+    skip_order_type: {},
+  },
+  mutations: {
+    // 获取订单信息
+    GET_ORDER_LIST(state, value) {
+      state.order_list = value;
+    },
+    GET_ORDER_TYPE(state, value) {
+      state.skip_order_type = value;
+    },
+  },
+};

+ 65 - 73
src/store/modules/user.js

@@ -1,78 +1,70 @@
 /**
 /**
  * 用户基本信息
  * 用户基本信息
  */
  */
-import {
-	getUserInfo,
-	updateUserInfo
-} from '@/api/user';
+import { getUserInfo, updateUserInfo } from '@/api/user';
 
 
 export default {
 export default {
-	state: () => ({
-		userId: '',
-		gender: '未知',
-		avatar: 'http://gogs.chelvc.com/avatars/6',
-		nickname: '默认用户',
-		invitationCode: '', //邀请码
-	}),
-	mutations: {
-		SET_USER_ID(state, userId) {
-			state.userId = userId
-		},
-		SET_GENDER(state, gender) {
-			state.gender = gender
-		},
-		SET_AVATAR(state, avatar) {
-			state.avatar = avatar
-		},
-		SET_NICKNAME(state, nickname) {
-			state.nickname = nickname
-		},
-		SET_INVITATIONCODE(state, invitationCode) {
-			state.invitationCode = invitationCode;
-		},
-	},
-	actions: {
-		// 获取用户基本信息
-		GetUserInfo({
-			commit
-		}) {
-			return new Promise((resolve, reject) => {
-				getUserInfo()
-					.then(res => {
-						commit('SET_USER_ID', res.data.id);
-						commit('SET_GENDER', res.data.gender);
-						commit('SET_AVATAR', res.data.avatar);
-						commit('SET_NICKNAME', res.data.nickname);
-						resolve(res);
-					})
-					.catch(err => {
-						reject(err);
-					});
-			});
-		},
-		// 更新用户基本信息
-		UpdateUserInfo({
-			dispatch,
-			commit
-		}, payload) {
-			return new Promise((resolve, reject) => {
-				updateUserInfo(payload)
-					.then(async res => {
-						await dispatch('GetUserInfo')
-						uni.showToast({
-							title: '修改成功',
-							icon: 'success',
-						})
-						resolve(res)
-					})
-					.catch(err => {
-						uni.showToast({
-							title: '修改失败',
-							icon: 'error',
-						})
-						reject(err)
-					})
-			});
-		}
-	}
-}
+  state: () => ({
+    userId: '',
+    gender: '未知',
+    avatar: 'http://gogs.chelvc.com/avatars/6',
+    nickname: '默认用户',
+    invitationCode: '', //邀请码
+  }),
+  mutations: {
+    SET_USER_ID(state, userId) {
+      state.userId = userId;
+    },
+    SET_GENDER(state, gender) {
+      state.gender = gender;
+    },
+    SET_AVATAR(state, avatar) {
+      state.avatar = avatar;
+    },
+    SET_NICKNAME(state, nickname) {
+      state.nickname = nickname;
+    },
+    SET_INVITATIONCODE(state, invitationCode) {
+      state.invitationCode = invitationCode;
+    },
+  },
+  actions: {
+    // 获取用户基本信息
+    GetUserInfo({ commit }) {
+      return new Promise((resolve, reject) => {
+        getUserInfo()
+          .then(res => {
+            commit('SET_USER_ID', res.data.id);
+            commit('SET_GENDER', res.data.gender);
+            commit('SET_AVATAR', res.data.avatar);
+            commit('SET_NICKNAME', res.data.nickname);
+            resolve(res);
+          })
+          .catch(err => {
+            reject(err);
+          });
+      });
+    },
+    // 更新用户基本信息
+    UpdateUserInfo({ dispatch, commit }, payload) {
+      return new Promise((resolve, reject) => {
+        updateUserInfo(payload)
+          .then(async res => {
+            await dispatch('GetUserInfo');
+            uni.showToast({
+              title: '修改成功',
+              icon: 'success',
+            });
+            resolve(res);
+          })
+          .catch(err => {
+            uni.showToast({
+              title: '修改失败',
+              icon: 'error',
+            });
+            reject(err);
+          });
+      });
+    },
+  },
+};