Эх сурвалжийг харах

测试二维码进入小程序功能待完善

忆雪 1 жил өмнө
parent
commit
34c94b3773

+ 231 - 217
src/pages/login/login.vue

@@ -1,217 +1,231 @@
-<template>
-  <view class="container">
-    <view class="t-b">欢迎登录车旅程!</view>
-    <view class="t-b2">欢迎使用车旅程,为你提供便捷服务</view>
-
-    <!-- 中间登录注册按钮 -->
-    <view class="login-btn-wrap">
-      <u-button v-if="!checked" shape="circle" type="primary" :customStyle="buttonStyleTop" @click="checkAgree">
-        微信用户一键登录
-      </u-button>
-      <u-button v-else shape="circle" type="primary" :loading="loading" loadingText="登录中..."
-        :customStyle="buttonStyleTop" open-type="getPhoneNumber" @getphonenumber="login">
-        微信用户一键登录
-      </u-button>
-      <u-button shape="circle" :customStyle="buttonStyleButton" @tap="$Router.push('/pages/login/phoneLogin')">
-        手机号登录/注册
-      </u-button>
-    </view>
-    <br />
-
-    <!-- 底部协议 -->
-    <view class="agree">
-      <u-checkbox-group v-model="agree">
-        <u-checkbox shape="circle" name="1" label="我已阅读并同意" />
-      </u-checkbox-group>
-      <view @click="$Router.push('/pages/webview/index?target=http://8.137.122.65:88/用户协议.html')" class="agreement">
-        《用户协议》</view>
-      <view @click="$Router.push('/pages/webview/index?target=http://8.137.122.65:88/隐私政策.html')" class="agreement">
-        《隐私政策》</view>
-    </view>
-
-    <!-- 第三方 -->
-    <view class="t-f"><text>————— 第三方账号登录 —————</text></view>
-    <view class="t-e cl">
-      <view class="t-g" @click="$Router.push('/pages/login/phoneLogin')">
-        <image src="@/static//icon/phone.png" />
-      </view>
-      <view class="t-g">
-        <image src="@/static//icon/qq.png" />
-      </view>
-    </view>
-  </view>
-</template>
-
-<script>
-  import {
-    getWxLoginCode
-  } from '@/api/login.js';
-
-  export default {
-    data() {
-      return {
-        agree: [],
-        code: '',
-        mobile: '', // 手机号密文并非真实手机号
-        isUserAgreement: false,
-        loading: false,
-        title: '',
-        buttonStyleTop: {
-          'font-size': '28rpx',
-          background: '#5677fc',
-          color: '#fff',
-          height: '90rpx',
-          'line-height': '90rpx',
-          'border-radius': '50rpx',
-          'box-shadow': '0 5px 7px 0 rgba(86, 119, 252, 0.2)',
-          marginTop: '30rpx',
-        },
-        buttonStyleButton: {
-          'font-size': '28rpx',
-          background: '#fff',
-          color: '#333',
-          height: '90rpx',
-          'line-height': '90rpx',
-          'border-radius': '50rpx',
-          'box-shadow': '0 5px 7px 0 rgba(235, 237, 245, 0.2)',
-          marginTop: '30rpx',
-        },
-      };
-    },
-    computed: {
-      checked() {
-        return this.agree && this.agree.length > 0;
-      },
-    },
-    methods: {
-      checkAgree() {
-        if (!this.checked) {
-          return uni.$u.toast('请阅读并勾选底部协议');
-        }
-      },
-      //点击微信用户一键登录
-      async login(e) {
-        if (e.detail.errMsg != 'getPhoneNumber:ok') {
-          return uni.$u.toast('您已取消登录');
-        }
-        this.mobile = e.detail.code;
-        this.code = await getWxLoginCode();
-        if (!this.code || !this.mobile) {
-          this.loading = false;
-          uni.$u.toast('微信授权失败,请稍后重试');
-          return;
-        }
-        this.loading = true;
-        const data = {
-          code: this.code,
-          mobile: this.mobile,
-        };
-        this.$store.dispatch('LoginByWxCode', data).then(() => {
-            // this.$store.dispatch('SwitchIdentity', 'CUSTOMER');
-            this.$Router.pushTab('/pages/tabbar/home');
-            this.loading = false;
-            this.$store.dispatch('GetUserInfo');
-            uni.$u.toast('登录成功');
-          })
-          .catch(err => {
-            this.loading = false;
-            uni.$u.toast(`${err.message}`);
-          });
-      },
-      confirmUserAgreement() {
-        // 确认按钮点击事件处理
-        if (!this.checked.length) {
-          this.showUserAgreementDialog = true;
-        } else {
-          this.showPrivacyPolicyDialog = true;
-        }
-
-        // 在确认按钮点击后执行页面跳转的代码
-        this.$Router.back();
-      },
-
-      //点击用户协议
-      clickAgreement(title) {
-        this.show = true; //打开弹框
-        this.title = title; //赋值标题
-      },
-
-      //点击用户协议弹框内的确定
-      handleConfirm() {
-        this.show = false; //关闭弹框
-      },
-    },
-  };
-</script>
-
-<style scoped lang="scss">
-  .container {
-    height: 100vh;
-    padding: 0 70rpx;
-    background-color: #f2f5f9;
-    background-color: #fff;
-    padding-top: 150rpx;
-    box-sizing: border-box;
-
-    .t-b {
-      text-align: left;
-      font-size: 46rpx;
-      color: #000;
-      padding: 150rpx 0 30rpx 0;
-      font-weight: bold;
-    }
-
-    .t-b2 {
-      text-align: left;
-      font-size: 32rpx;
-      color: #aaaaaa;
-      padding: 0rpx 0 80rpx 0;
-    }
-
-    .login-btn-wrap {
-      margin-top: 50rpx;
-      width: 100%;
-    }
-  }
-
-  .agree {
-    display: flex;
-    justify-content: center;
-    align-items: center;
-    font-size: 27rpx;
-    margin-top: 20rpx;
-
-    .agreement {
-      color: #3c9cff;
-      cursor: pointer;
-    }
-  }
-
-  .t-f {
-    text-align: center;
-    margin: 200rpx 0 0 0;
-    color: #666;
-
-    text {
-      margin-left: 20rpx;
-      color: #aaaaaa;
-      font-size: 27rpx;
-    }
-  }
-
-  .t-e {
-    text-align: center;
-    width: 250rpx;
-    margin: 20rpx auto 0;
-
-    .t-g {
-      float: left;
-      width: 50%;
-    }
-
-    image {
-      width: 50rpx;
-      height: 50rpx;
-    }
-  }
-</style>
+<template>
+	<view class="container">
+		<view class="t-b">欢迎登录车旅程!</view>
+		<view class="t-b2">欢迎使用车旅程,为你提供便捷服务</view>
+
+		<!-- 中间登录注册按钮 -->
+		<view class="login-btn-wrap">
+			<u-button v-if="!checked" shape="circle" type="primary" :customStyle="buttonStyleTop" @click="checkAgree">
+				微信用户一键登录
+			</u-button>
+			<u-button v-else shape="circle" type="primary" :loading="loading" loadingText="登录中..."
+				:customStyle="buttonStyleTop" open-type="getPhoneNumber" @getphonenumber="login">
+				微信用户一键登录
+			</u-button>
+			<u-button shape="circle" :customStyle="buttonStyleButton" @tap="$Router.push('/pages/login/phoneLogin')">
+				手机号登录/注册
+			</u-button>
+		</view>
+		<br />
+
+		<!-- 底部协议 -->
+		<view class="agree">
+			<u-checkbox-group v-model="agree">
+				<u-checkbox shape="circle" name="1" label="我已阅读并同意" />
+			</u-checkbox-group>
+			<view @click="$Router.push('/pages/webview/index?target=http://8.137.122.65:88/用户协议.html')"
+				class="agreement">
+				《用户协议》</view>
+			<view @click="$Router.push('/pages/webview/index?target=http://8.137.122.65:88/隐私政策.html')"
+				class="agreement">
+				《隐私政策》</view>
+		</view>
+
+		<!-- 第三方 -->
+		<view class="t-f"><text>————— 第三方账号登录 —————</text></view>
+		<view class="t-e cl">
+			<view class="t-g" @click="$Router.push('/pages/login/phoneLogin')">
+				<image src="@/static//icon/phone.png" />
+			</view>
+			<view class="t-g">
+				<image src="@/static//icon/qq.png" />
+			</view>
+		</view>
+	</view>
+</template>
+
+<script>
+	import {
+		getWxLoginCode
+	} from '@/api/login.js';
+
+	export default {
+		data() {
+			return {
+				agree: [],
+				code: '',
+				mobile: '', // 手机号密文并非真实手机号
+				isUserAgreement: false,
+				loading: false,
+				title: '',
+				buttonStyleTop: {
+					'font-size': '28rpx',
+					background: '#5677fc',
+					color: '#fff',
+					height: '90rpx',
+					'line-height': '90rpx',
+					'border-radius': '50rpx',
+					'box-shadow': '0 5px 7px 0 rgba(86, 119, 252, 0.2)',
+					marginTop: '30rpx',
+				},
+				buttonStyleButton: {
+					'font-size': '28rpx',
+					background: '#fff',
+					color: '#333',
+					height: '90rpx',
+					'line-height': '90rpx',
+					'border-radius': '50rpx',
+					'box-shadow': '0 5px 7px 0 rgba(235, 237, 245, 0.2)',
+					marginTop: '30rpx',
+				},
+			};
+		},
+		computed: {
+			checked() {
+				return this.agree && this.agree.length > 0;
+			},
+		},
+		methods: {
+
+			onLaunch(options) {
+
+				const launchOptions = uni.getLaunchOptionsSync();
+
+
+				const promoterId = launchOptions.query.promoterId;
+				this.$store.commit('SET_INVITATIONCODE', promoterId)
+
+				console.log('promoterId:', promoterId);
+			},
+
+			checkAgree() {
+				if (!this.checked) {
+					return uni.$u.toast('请阅读并勾选底部协议');
+				}
+			},
+			//点击微信用户一键登录
+			async login(e) {
+				if (e.detail.errMsg != 'getPhoneNumber:ok') {
+					return uni.$u.toast('您已取消登录');
+				}
+				this.mobile = e.detail.code;
+				this.code = await getWxLoginCode();
+				if (!this.code || !this.mobile) {
+					this.loading = false;
+					uni.$u.toast('微信授权失败,请稍后重试');
+					return;
+				}
+				this.loading = true;
+				const data = {
+					code: this.code,
+					mobile: this.mobile,
+				};
+				this.$store.dispatch('LoginByWxCode', data).then(() => {
+						// this.$store.dispatch('SwitchIdentity', 'CUSTOMER');
+						this.$Router.pushTab('/pages/tabbar/home');
+						this.loading = false;
+						this.$store.dispatch('GetUserInfo');
+						uni.$u.toast('登录成功');
+					})
+					.catch(err => {
+						this.loading = false;
+						uni.$u.toast(`${err.message}`);
+					});
+			},
+			confirmUserAgreement() {
+				// 确认按钮点击事件处理
+				if (!this.checked.length) {
+					this.showUserAgreementDialog = true;
+				} else {
+					this.showPrivacyPolicyDialog = true;
+				}
+
+				// 在确认按钮点击后执行页面跳转的代码
+				this.$Router.back();
+			},
+
+			//点击用户协议
+			clickAgreement(title) {
+				this.show = true; //打开弹框
+				this.title = title; //赋值标题
+			},
+
+			//点击用户协议弹框内的确定
+			handleConfirm() {
+				this.show = false; //关闭弹框
+			},
+		},
+	};
+</script>
+
+<style scoped lang="scss">
+	.container {
+		height: 100vh;
+		padding: 0 70rpx;
+		background-color: #f2f5f9;
+		background-color: #fff;
+		padding-top: 150rpx;
+		box-sizing: border-box;
+
+		.t-b {
+			text-align: left;
+			font-size: 46rpx;
+			color: #000;
+			padding: 150rpx 0 30rpx 0;
+			font-weight: bold;
+		}
+
+		.t-b2 {
+			text-align: left;
+			font-size: 32rpx;
+			color: #aaaaaa;
+			padding: 0rpx 0 80rpx 0;
+		}
+
+		.login-btn-wrap {
+			margin-top: 50rpx;
+			width: 100%;
+		}
+	}
+
+	.agree {
+		display: flex;
+		justify-content: center;
+		align-items: center;
+		font-size: 27rpx;
+		margin-top: 20rpx;
+
+		.agreement {
+			color: #3c9cff;
+			cursor: pointer;
+		}
+	}
+
+	.t-f {
+		text-align: center;
+		margin: 200rpx 0 0 0;
+		color: #666;
+
+		text {
+			margin-left: 20rpx;
+			color: #aaaaaa;
+			font-size: 27rpx;
+		}
+	}
+
+	.t-e {
+		text-align: center;
+		width: 250rpx;
+		margin: 20rpx auto 0;
+
+		.t-g {
+			float: left;
+			width: 50%;
+		}
+
+		image {
+			width: 50rpx;
+			height: 50rpx;
+		}
+	}
+</style>

+ 363 - 332
src/pages/tabbar/home.vue

@@ -1,332 +1,363 @@
-<template>
-	<view class="home">
-		<view>
-			<!-- 顶部导航 -->
-			<view class="nav-bar">
-				<u-navbar :bgColor="'#ffffff'" :placeholder="true">
-					<view slot="left" @click.stop="manualGetLocation">
-						<view class="address-text">{{ nowAddress }}</view>
-						<text class="iconfont icon-chevron-down" />
-					</view>
-					<view slot="center" style="width: 350rpx">
-						<u-search placeholder="请输入搜索内容" :showAction="false" v-model="keyword"
-							@click="$Router.push('/pagesHome/homeSearch')" :disabled="true" />
-					</view>
-				</u-navbar>
-			</view>
-			<!-- 轮播图 -->
-			<view class="home-swiper">
-				<u-swiper :list="swiperUrlList" @click="handlerSwiperSkip" indicator imgMode='aspectFit' />
-			</view>
-
-			<!-- 商品分类 -->
-			<view class="home-list">
-				<u-grid :border="false" col="5">
-					<u-grid-item v-for="item in categories" :key="item.id" @tap="handleMenuClick(item)">
-						<u-icon :customStyle="{ paddingTop: 20 + 'rpx' }" :name="item.icon" :size="25"></u-icon>
-						<text class="grid-text">{{ item.name }}</text>
-					</u-grid-item>
-				</u-grid>
-				<u-toast ref="uToast" />
-			</view>
-
-			<!-- 热门推荐 -->
-			<view class="hot">
-				<u-cell :border="false" value="查看更多" isLink @click="$Router.push('/pagesHome/home/popularRecommend')">
-					<view slot="title" class="hot-title"> 热门推荐 </view>
-				</u-cell>
-				<block v-if="homeData.recommends && homeData.recommends.length > 0">
-					<view>
-						<u-grid :border="false" col="2">
-							<u-grid-item @click="$Router.push(`/pagesHome/marketer/index?id=${item.id}`)"
-								v-for="(item,index) in homeData.recommends" :key="item.id">
-								<recommend-item v-if="index < 4" :item="item"></recommend-item>
-							</u-grid-item>
-						</u-grid>
-					</view>
-				</block>
-				<block v-else>
-					<u-empty mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png">
-					</u-empty>
-				</block>
-			</view>
-
-			<!-- 附近商家 -->
-			<view class="near">
-				<u-cell :border="false" value="查看更多" isLink @click="$Router.push('/pagesHome/home/nearbyBusiness')">
-					<view slot="title" class="near-title"> 附近商家 </view>
-				</u-cell>
-				<block v-if="homeData.nears && homeData.nears.length > 0">
-					<view>
-						<u-grid :border="false" col="2">
-							<u-grid-item @click="$Router.push(`/pagesHome/marketer/index?id=${item.id}`)"
-								v-for="(item,index) in homeData.nears" :key="item.id">
-								<hot-item v-if="index < 4" :item="item"></hot-item>
-							</u-grid-item>
-						</u-grid>
-					</view>
-				</block>
-				<block v-else>
-					<u-empty mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png">
-					</u-empty>
-				</block>
-			</view>
-
-			<!-- 询价 -->
-			<!-- <drag-button :isDock="true" :existTabBar="true" @btnClick="btnClick" /> -->
-		</view>
-	</view>
-</template>
-
-<script>
-	import { getCurrentLocation, getHomePageApi, getSwiperListApi } from '@/api/client/home';
-	import RecommendItem from './components/RecommendItem.vue';
-	import HotItem from './components/HotItem.vue';
-	import { getMapLocation } from "@/utils/mapUtil.js"
-	import { mapGetters } from 'vuex';
-	export default {
-		components: {
-			RecommendItem,
-			HotItem,
-		},
-		data() {
-			return {
-				list: [],
-				keyword: '',
-				swiperUrlList: [], // 轮播图url列表
-				swiperList: [],
-				homeData: {
-					categories: [],
-					nears: [],
-					recommends: [],
-				},
-				queryParams: {
-					longitude: '',
-					latitude: '',
-					region: ''
-				},
-				nowAddress: '', //当前地址
-			};
-		},
-
-		computed: {
-			...mapGetters(['location']),
-			categories() {
-				let initData = this.homeData.categories.map(item => {
-					if (!item.icon) {
-						item.icon = 'level';
-					}
-					return item;
-				});
-				let result =
-					initData.length > 14 ?
-					initData.splice(0, 14).concat([{
-						id: 'all',
-						icon: 'grid-fill',
-						name: '全部',
-						type: {
-							code: 'ALL',
-							description: '全部',
-						},
-					}, ]) :
-					initData.push({
-						id: 'all',
-						icon: 'grid-fill',
-						name: '全部',
-					});
-				return result;
-			},
-		},
-		mounted() {
-			this.getSwiperList();
-			// 页面显示时  获取当前零维度
-			uni.getLocation({
-				type: 'gcj02',
-				success: res => {
-					let {
-						longitude,
-						latitude
-					} = res
-					this.queryParams.longitude = longitude;
-					this.queryParams.latitude = latitude;
-					// getCurrentLocation 获取当前编码region
-					this.handlerGetRegion(longitude, latitude)
-				},
-				fail: () => {
-					this.manualGetLocation();
-				},
-			});
-		},
-		methods: {
-			// 获取当前编码region
-			handlerGetRegion(longitude, latitude) {
-				let point = `${latitude},${longitude}`
-				getCurrentLocation({
-					point
-				}).then(res => {
-					let {
-						city,
-						district,
-						id
-					} = res.data
-					this.queryParams.region = res.data.id;
-					if (district) {
-						this.nowAddress = district.name
-					} else if (city) {
-						this.nowAddress = city.name
-					} else {
-						this.nowAddress = '地图'
-					}
-					this.getHomeData(this.queryParams)
-					this.$store.commit('SET_LOCATION', {
-						longitude: longitude,
-						latitude: latitude,
-						region: res.data.id,
-						address: res.data.name
-					});
-				})
-			},
-			/* 轮播图 */
-			getSwiperList() {
-				getSwiperListApi().then(res => {
-					this.swiperList = res.data
-					res.data.map(rs => {
-						this.swiperUrlList.push(rs.viewUrl)
-					})
-				});
-			},
-			// 获取首页数据
-			getHomeData(location) {
-				getHomePageApi(location)
-					.then(res => {
-						this.homeData = res.data;
-						// 将分类数据做缓存处理
-						this.$store.commit('SET_CATEGORIES', this.homeData.categories);
-					})
-			},
-			// 手动选择城市
-			manualGetLocation() {
-				uni.chooseLocation({
-					success: res => {
-						let {
-							longitude,
-							latitude
-						} = res
-						this.queryParams.longitude = longitude.toFixed(5);
-						this.queryParams.latitude = latitude.toFixed(5);
-						this.handlerGetRegion(longitude.toFixed(5), latitude.toFixed(5))
-					},
-					fail: err => {}
-				});
-			},
-			// 点击swiper跳转
-			handlerSwiperSkip(e) {
-				console.log("@@@swiperList", this.swiperList[e])
-			},
-			// 点击菜单
-			handleMenuClick(item) {
-				if (item.id === 'all') {
-					this.$Router.push('/pagesHome/category/categoryStoreList');
-				} else {
-					uni.navigateTo({
-						url: `/pagesHome/category/index?id=${item.id}`,
-					});
-				}
-			},
-
-			/* 询价 */
-			btnClick() {
-				uni.navigateTo({
-					url: `/pages/client/clientUser/inquiry`,
-				});
-			},
-		},
-	};
-</script>
-
-<style lang="scss" scoped>
-	.home {
-		background-color: #f0efef;
-
-		.nav-bar {
-			::v-deep .u-navbar__content {
-				background-color: #ffffff;
-			}
-      .address-text{
-        min-width: 120rpx;
-        overflow: hidden;
-        text-overflow: ellipsis;
-        white-space: nowrap;
-      }
-		}
-	}
-
-	/* 头部搜索栏 */
-	.home-header {
-		display: flex;
-		align-items: center;
-		height: 90rpx;
-		line-height: 90rpx;
-		padding: 0 20rpx;
-		background-color: #ffffff;
-
-		.goto-address {
-			display: flex;
-			align-items: center;
-
-			.icon-sanjiaoxing1 {
-				font-size: 24rpx;
-				margin: 17rpx 10rpx 0 6rpx;
-			}
-		}
-
-		.search-item {
-			flex: 1;
-		}
-	}
-
-	/* 轮播图 */
-	.home-swiper {
-		padding: 20rpx;
-		margin-bottom: 10rpx;
-	}
-
-	/* 商品分类 */
-	.home-list {
-		background-color: #ffffff;
-		height: 360rpx;
-		margin: 0 20rpx 20rpx 20rpx;
-		padding: 20rpx 0 50rpx 0;
-		border-radius: 10rpx;
-
-		.grid-text {
-			font-size: 12px;
-			color: #909399;
-			padding: 10rpx 0 20rpx 0rpx;
-			box-sizing: border-box;
-		}
-	}
-
-	/* 热门推荐 */
-	.hot {
-		::v-deep .u-cell__body {
-			padding: 10rpx 20rpx;
-
-			.hot-title {
-				border-left: 4px solid $uni-color-primary;
-				padding-left: 20rpx;
-			}
-		}
-	}
-
-	.near {
-		::v-deep .u-cell__body {
-			padding: 10rpx 20rpx;
-
-			.near-title {
-				border-left: 4px solid $uni-color-primary;
-				padding-left: 20rpx;
-			}
-		}
-	}
-</style>
+<template>
+	<view class="home">
+		<view>
+			<!-- 顶部导航 -->
+			<view class="nav-bar">
+				<u-navbar :bgColor="'#ffffff'" :placeholder="true">
+					<view slot="left" @click.stop="manualGetLocation">
+						<view class="address-text">{{ nowAddress }}</view>
+						<text class="iconfont icon-chevron-down" />
+					</view>
+					<view slot="center" style="width: 350rpx">
+						<u-search placeholder="请输入搜索内容" :showAction="false" v-model="keyword"
+							@click="$Router.push('/pagesHome/homeSearch')" :disabled="true" />
+					</view>
+				</u-navbar>
+			</view>
+			<!-- 轮播图 -->
+			<view class="home-swiper">
+				<u-swiper :list="swiperUrlList" @click="handlerSwiperSkip" indicator imgMode='aspectFit' />
+			</view>
+
+			<!-- 商品分类 -->
+			<view class="home-list">
+				<u-grid :border="false" col="5">
+					<u-grid-item v-for="item in categories" :key="item.id" @tap="handleMenuClick(item)">
+						<u-icon :customStyle="{ paddingTop: 20 + 'rpx' }" :name="item.icon" :size="25"></u-icon>
+						<text class="grid-text">{{ item.name }}</text>
+					</u-grid-item>
+				</u-grid>
+				<u-toast ref="uToast" />
+			</view>
+
+			<!-- 热门推荐 -->
+			<view class="hot">
+				<u-cell :border="false" value="查看更多" isLink @click="$Router.push('/pagesHome/home/popularRecommend')">
+					<view slot="title" class="hot-title"> 热门推荐 </view>
+				</u-cell>
+				<block v-if="homeData.recommends && homeData.recommends.length > 0">
+					<view>
+						<u-grid :border="false" col="2">
+							<u-grid-item @click="$Router.push(`/pagesHome/marketer/index?id=${item.id}`)"
+								v-for="(item,index) in homeData.recommends" :key="item.id">
+								<recommend-item v-if="index < 4" :item="item"></recommend-item>
+							</u-grid-item>
+						</u-grid>
+					</view>
+				</block>
+				<block v-else>
+					<u-empty mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png">
+					</u-empty>
+				</block>
+			</view>
+
+			<!-- 附近商家 -->
+			<view class="near">
+				<u-cell :border="false" value="查看更多" isLink @click="$Router.push('/pagesHome/home/nearbyBusiness')">
+					<view slot="title" class="near-title"> 附近商家 </view>
+				</u-cell>
+				<block v-if="homeData.nears && homeData.nears.length > 0">
+					<view>
+						<u-grid :border="false" col="2">
+							<u-grid-item @click="$Router.push(`/pagesHome/marketer/index?id=${item.id}`)"
+								v-for="(item,index) in homeData.nears" :key="item.id">
+								<hot-item v-if="index < 4" :item="item"></hot-item>
+							</u-grid-item>
+						</u-grid>
+					</view>
+				</block>
+				<block v-else>
+					<u-empty mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png">
+					</u-empty>
+				</block>
+			</view>
+
+			<!-- 询价 -->
+			<!-- <drag-button :isDock="true" :existTabBar="true" @btnClick="btnClick" /> -->
+		</view>
+	</view>
+</template>
+
+<script>
+	import {
+		getCurrentLocation,
+		getHomePageApi,
+		getSwiperListApi
+	} from '@/api/client/home';
+	import RecommendItem from './components/RecommendItem.vue';
+	import HotItem from './components/HotItem.vue';
+	import {
+		getMapLocation
+	} from "@/utils/mapUtil.js"
+	import {
+		mapGetters
+	} from 'vuex';
+	import {
+		inviteBind
+	} from "@/api/client/mine.js"
+	export default {
+		components: {
+			RecommendItem,
+			HotItem,
+		},
+		data() {
+			return {
+				list: [],
+				keyword: '',
+				swiperUrlList: [], // 轮播图url列表
+				swiperList: [],
+				homeData: {
+					categories: [],
+					nears: [],
+					recommends: [],
+				},
+				queryParams: {
+					longitude: '',
+					latitude: '',
+					region: ''
+				},
+				nowAddress: '', //当前地址
+			};
+		},
+
+		computed: {
+			...mapGetters(['location', 'userId', 'invitationCode']),
+			categories() {
+				let initData = this.homeData.categories.map(item => {
+					if (!item.icon) {
+						item.icon = 'level';
+					}
+					return item;
+				});
+				let result =
+					initData.length > 14 ?
+					initData.splice(0, 14).concat([{
+						id: 'all',
+						icon: 'grid-fill',
+						name: '全部',
+						type: {
+							code: 'ALL',
+							description: '全部',
+						},
+					}, ]) :
+					initData.push({
+						id: 'all',
+						icon: 'grid-fill',
+						name: '全部',
+					});
+				return result;
+			},
+		},
+		onShow() {
+			console.log("执行了没有", this.invitationCode)
+			// 如果 invitationCode 存在且不等于特殊值时执行代码
+			if (this.invitationCode) {
+				console.log("sadsad")
+				let params = {
+					userId: this.userId,
+					targetId: this.invitationCode,
+					type: 1
+				};
+				inviteBind(params).then(res => {
+					console.log("绑定邀请码结果:", res);
+				});
+				this.$store.commit('SET_INVITATIONCODE', '')
+				
+			}else{
+				console.log("执行了一次")
+			}
+		},
+		mounted() {
+			this.getSwiperList();
+			// 页面显示时  获取当前零维度
+			uni.getLocation({
+				type: 'gcj02',
+				success: res => {
+					let {
+						longitude,
+						latitude
+					} = res
+					this.queryParams.longitude = longitude;
+					this.queryParams.latitude = latitude;
+					// getCurrentLocation 获取当前编码region
+					this.handlerGetRegion(longitude, latitude)
+				},
+				fail: () => {
+					this.manualGetLocation();
+				},
+			});
+		},
+		methods: {
+			// 获取当前编码region
+			handlerGetRegion(longitude, latitude) {
+				let point = `${latitude},${longitude}`
+				getCurrentLocation({
+					point
+				}).then(res => {
+					let {
+						city,
+						district,
+						id
+					} = res.data
+					this.queryParams.region = res.data.id;
+					if (district) {
+						this.nowAddress = district.name
+					} else if (city) {
+						this.nowAddress = city.name
+					} else {
+						this.nowAddress = '地图'
+					}
+					this.getHomeData(this.queryParams)
+					this.$store.commit('SET_LOCATION', {
+						longitude: longitude,
+						latitude: latitude,
+						region: res.data.id,
+						address: res.data.name
+					});
+				})
+			},
+			/* 轮播图 */
+			getSwiperList() {
+				getSwiperListApi().then(res => {
+					this.swiperList = res.data
+					res.data.map(rs => {
+						this.swiperUrlList.push(rs.viewUrl)
+					})
+				});
+			},
+			// 获取首页数据
+			getHomeData(location) {
+				getHomePageApi(location)
+					.then(res => {
+						this.homeData = res.data;
+						// 将分类数据做缓存处理
+						this.$store.commit('SET_CATEGORIES', this.homeData.categories);
+					})
+			},
+			// 手动选择城市
+			manualGetLocation() {
+				uni.chooseLocation({
+					success: res => {
+						let {
+							longitude,
+							latitude
+						} = res
+						this.queryParams.longitude = longitude.toFixed(5);
+						this.queryParams.latitude = latitude.toFixed(5);
+						this.handlerGetRegion(longitude.toFixed(5), latitude.toFixed(5))
+					},
+					fail: err => {}
+				});
+			},
+			// 点击swiper跳转
+			handlerSwiperSkip(e) {
+				console.log("@@@swiperList", this.swiperList[e])
+			},
+			// 点击菜单
+			handleMenuClick(item) {
+				if (item.id === 'all') {
+					this.$Router.push('/pagesHome/category/categoryStoreList');
+				} else {
+					uni.navigateTo({
+						url: `/pagesHome/category/index?id=${item.id}`,
+					});
+				}
+			},
+
+			/* 询价 */
+			btnClick() {
+				uni.navigateTo({
+					url: `/pages/client/clientUser/inquiry`,
+				});
+			},
+		},
+	};
+</script>
+
+<style lang="scss" scoped>
+	.home {
+		background-color: #f0efef;
+
+		.nav-bar {
+			::v-deep .u-navbar__content {
+				background-color: #ffffff;
+			}
+
+			.address-text {
+				min-width: 120rpx;
+				overflow: hidden;
+				text-overflow: ellipsis;
+				white-space: nowrap;
+			}
+		}
+	}
+
+	/* 头部搜索栏 */
+	.home-header {
+		display: flex;
+		align-items: center;
+		height: 90rpx;
+		line-height: 90rpx;
+		padding: 0 20rpx;
+		background-color: #ffffff;
+
+		.goto-address {
+			display: flex;
+			align-items: center;
+
+			.icon-sanjiaoxing1 {
+				font-size: 24rpx;
+				margin: 17rpx 10rpx 0 6rpx;
+			}
+		}
+
+		.search-item {
+			flex: 1;
+		}
+	}
+
+	/* 轮播图 */
+	.home-swiper {
+		padding: 20rpx;
+		margin-bottom: 10rpx;
+	}
+
+	/* 商品分类 */
+	.home-list {
+		background-color: #ffffff;
+		height: 360rpx;
+		margin: 0 20rpx 20rpx 20rpx;
+		padding: 20rpx 0 50rpx 0;
+		border-radius: 10rpx;
+
+		.grid-text {
+			font-size: 12px;
+			color: #909399;
+			padding: 10rpx 0 20rpx 0rpx;
+			box-sizing: border-box;
+		}
+	}
+
+	/* 热门推荐 */
+	.hot {
+		::v-deep .u-cell__body {
+			padding: 10rpx 20rpx;
+
+			.hot-title {
+				border-left: 4px solid $uni-color-primary;
+				padding-left: 20rpx;
+			}
+		}
+	}
+
+	.near {
+		::v-deep .u-cell__body {
+			padding: 10rpx 20rpx;
+
+			.near-title {
+				border-left: 4px solid $uni-color-primary;
+				padding-left: 20rpx;
+			}
+		}
+	}
+</style>

+ 172 - 163
src/pages/tabbar/promotionCode.vue

@@ -1,163 +1,172 @@
-<template>
-  <view class="page">
-    <view class="img-box">
-      <!-- <image :src="avatar" class="img" mode="aspectFill"></image> -->
-      <u-avatar :src="avatar" size="55" class="img" />
-      <view class="img-text">
-        <view class="name">{{ nickname }}</view>
-        <view class="address">{{ location.address }}</view>
-      </view>
-    </view>
-
-    <view class="qrcode-box">
-      <view class="qrcode">
-        <uQrcode ref="qr" canvas-id="qr" :value="text" :size="size" @click="remake" @complete="complete($event)">
-        </uQrcode>
-      </view>
-    </view>
-    <view class="scan-text">扫描上方二维码,加入我的团队</view>
-    <tabbar currentTab="promotionCode" />
-  </view>
-</template>
-
-<script>
-  import uQrcode from '@/uni_modules/Sansnn-uQRCode/components/u-qrcode/u-qrcode.vue';
-  import {
-    mapGetters
-  } from 'vuex';
-  export default {
-    data() {
-      return {
-        text: 'https://image.baidu.com/search/index?tn=baiduimage&ps=1&ct=201326592&lm=-1&cl=2&nc=1&ie=utf-8&dyTabStr=MCwxLDMsMiw2LDQsNSw3LDgsOQ%3D%3D&word=giao',
-        size: 200,
-      };
-    },
-    components: {
-      uQrcode,
-    },
-    computed: {
-      ...mapGetters(['location', 'avatar', 'nickname']),
-    },
-    methods: {
-      complete(e) {
-        if (e.success) {
-          console.log('生成成功');
-        } else {
-          console.log('生成失败');
-        }
-      },
-      remake() {
-        // const ref = this.$refs['qr'];
-        // ref.remake();
-      },
-      save() {
-        uni.showLoading({
-          title: '保存中',
-          mask: true,
-        });
-        const ref = this.$refs['qr'];
-        ref.save({
-          success: res => {
-            uni.hideLoading();
-            uni.showToast({
-              icon: 'success',
-              title: '保存成功',
-            });
-          },
-          fail: err => {
-            uni.showToast({
-              icon: 'none',
-              title: JSON.stringify(err),
-            });
-          },
-        });
-      },
-    },
-  };
-</script>
-
-<style lang="scss" scoped>
-  .page {
-    position: fixed;
-    top: 0;
-    left: 0;
-    right: 0;
-    bottom: 0;
-    background: #fff;
-    z-index: -1;
-
-  }
-
-
-
-  .img-box {
-    display: flex;
-    align-items: center;
-    margin: 280rpx auto 0;
-    padding: 20rpx;
-    border-radius: 20rpx;
-    width: 90%;
-    background: linear-gradient(to right, #f3904f, #3b4371);
-    padding-left: 40rpx;
-    .img {
-      width: 160rpx;
-      height: 160rpx;
-      border-radius: 20rpx;
-      margin-left: 12%;
-      margin-right: 30rpx;
-    }
-  }
-
-  .img-text {
-    font-size: 28rpx;
-    font-weight: bold;
-    margin-left: 37rpx;
-    display: flex;
-    flex-direction: column;
-    align-content: space-evenly;
-
-    .name {
-      font-size: 36rpx;
-      color: #fff;
-    }
-
-    .address {
-      // color: #B5B5B5;
-      color: #fff;
-      margin-top: 24rpx;
-    }
-  }
-
-  .qrcode-box {
-    display: flex;
-    flex-direction: column;
-    align-items: center;
-    padding: 0 30px;
-    margin-top: 100rpx;
-  }
-
-  .scan-text {
-    text-align: center;
-    font-size: 28rpx;
-    color: #b7b7b7;
-    margin-top: 40rpx;
-  }
-
-  .qrcode {
-    padding: 16px;
-    background-color: #ffffff;
-    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
-    border-radius: 2px;
-    overflow: hidden;
-  }
-
-  .msg {
-    margin-top: 15px;
-    font-size: 14px;
-    color: #9a9b9c;
-  }
-
-  .save {
-    margin-top: 10px;
-  }
-</style>
+<template>
+	<view class="page">
+		<view class="img-box">
+			<!-- <image :src="avatar" class="img" mode="aspectFill"></image> -->
+			<u-avatar :src="avatar" size="55" class="img" />
+			<view class="img-text">
+				<view class="name">{{ nickname }}</view>
+				<view class="address">{{ location.address }}</view>
+			</view>
+		</view>
+
+		<view class="qrcode-box">
+			<view class="qrcode">
+				<uQrcode ref="qr" canvas-id="qr" :value="text" :size="size" @click="remake"
+					@complete="complete($event)">
+				</uQrcode>
+			</view>
+		</view>
+		<view class="scan-text">扫描上方二维码,加入我的团队</view>
+		<tabbar currentTab="promotionCode" />
+	</view>
+</template>
+
+<script>
+	import uQrcode from '@/uni_modules/Sansnn-uQRCode/components/u-qrcode/u-qrcode.vue';
+	import {
+		mapGetters
+	} from 'vuex';
+	export default {
+		data() {
+			return {
+				text: "https://test.chelvc.com/static/preview?promoterId=123123123",
+				// text:`https://test.chelvc.com/static/preview?promoterId=${this.userId}`,
+				size: 200,
+			};
+		},
+		components: {
+			uQrcode ,
+		},
+		computed: {
+			...mapGetters(['location', 'avatar', 'nickname',"userId"]),
+		},
+		methods: {
+			gotoBaidu() {
+				// 使用 uni.navigateTo 或 uni.redirectTo 跳转到百度的网址
+				uni.navigateTo({
+					url: 'https://test.chelvc.com/static/preview?promoterId=123123123'
+				})
+			},
+			complete(e) {
+				if (e.success) {
+					console.log('生成成功');
+				} else {
+					console.log('生成失败');
+				}
+			},
+			remake() {
+				// const ref = this.$refs['qr'];
+				// ref.remake();
+			},
+			save() {
+				uni.showLoading({
+					title: '保存中',
+					mask: true,
+				});
+				const ref = this.$refs['qr'];
+				ref.save({
+					success: res => {
+						uni.hideLoading();
+						uni.showToast({
+							icon: 'success',
+							title: '保存成功',
+						});
+					},
+					fail: err => {
+						uni.showToast({
+							icon: 'none',
+							title: JSON.stringify(err),
+						});
+					},
+				});
+			},
+		},
+	};
+</script>
+
+<style lang="scss" scoped>
+	.page {
+		position: fixed;
+		top: 0;
+		left: 0;
+		right: 0;
+		bottom: 0;
+		background: #fff;
+		z-index: -1;
+
+	}
+
+
+
+	.img-box {
+		display: flex;
+		align-items: center;
+		margin: 280rpx auto 0;
+		padding: 20rpx;
+		border-radius: 20rpx;
+		width: 90%;
+		background: linear-gradient(to right, #f3904f, #3b4371);
+		padding-left: 40rpx;
+
+		.img {
+			width: 160rpx;
+			height: 160rpx;
+			border-radius: 20rpx;
+			margin-left: 12%;
+			margin-right: 30rpx;
+		}
+	}
+
+	.img-text {
+		font-size: 28rpx;
+		font-weight: bold;
+		margin-left: 37rpx;
+		display: flex;
+		flex-direction: column;
+		align-content: space-evenly;
+
+		.name {
+			font-size: 36rpx;
+			color: #fff;
+		}
+
+		.address {
+			// color: #B5B5B5;
+			color: #fff;
+			margin-top: 24rpx;
+		}
+	}
+
+	.qrcode-box {
+		display: flex;
+		flex-direction: column;
+		align-items: center;
+		padding: 0 30px;
+		margin-top: 100rpx;
+	}
+
+	.scan-text {
+		text-align: center;
+		font-size: 28rpx;
+		color: #b7b7b7;
+		margin-top: 40rpx;
+	}
+
+	.qrcode {
+		padding: 16px;
+		background-color: #ffffff;
+		box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
+		border-radius: 2px;
+		overflow: hidden;
+	}
+
+	.msg {
+		margin-top: 15px;
+		font-size: 14px;
+		color: #9a9b9c;
+	}
+
+	.save {
+		margin-top: 10px;
+	}
+</style>

+ 2 - 1
src/store/getters.js

@@ -14,7 +14,8 @@ const getters = {
   userId: state => state.user.userId,
   gender: state => state.user.gender,
   avatar: state => state.user.avatar,
-  nickname: state => state.user.nickname,
+  nickname: state => state.user.nickname,
+  invitationCode:state => state.user.invitationCode,
 
   location: state => state.data.location
 };

+ 78 - 66
src/store/modules/user.js

@@ -1,66 +1,78 @@
-/**
- * 用户基本信息
- */
-import { getUserInfo, updateUserInfo } from '@/api/user';
-
-export default {
-  state: () => ({
-    userId:  '',
-    gender: '未知',
-    avatar:  'http://gogs.chelvc.com/avatars/6',
-    nickname:  '默认用户'
-  }),
-  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
-    }
-  },
-  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)
-          })
-      });
-    }
-  }
-}
+/**
+ * 用户基本信息
+ */
+import {
+	getUserInfo,
+	updateUserInfo
+} from '@/api/user';
+
+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)
+					})
+			});
+		}
+	}
+}