liujiaxin hai 15 horas
pai
achega
87001c6bf5
Modificáronse 9 ficheiros con 661 adicións e 14 borrados
  1. 4 1
      api/user.js
  2. 2 2
      common/request.js
  3. 7 0
      pages.json
  4. 11 0
      pages/auth/login.vue
  5. 36 0
      pages/home/index.vue
  6. 8 0
      pages/user/index.vue
  7. 62 11
      pages_user/user/coupon.vue
  8. 531 0
      pages_user/user/inviteFriend.vue
  9. BIN=BIN
      static/invite.png

+ 4 - 1
api/user.js

@@ -63,7 +63,10 @@ let request = new Request().http
  
   //查看可领取优惠券
  export function getCouponList(data) {
- 	 return request('/storeCoupon/list',data,'GET');
+ 	 return request('/storeCoupon/list',data,'POST','application/json;charset=UTF-8');
+ }
+ export function receive(data) {
+ 	 return request('/storeCoupon',data,'POST','application/json;charset=UTF-8');
  }
  
  

+ 2 - 2
common/request.js

@@ -8,8 +8,8 @@ export default class Request {
 			// let path ='http://p6c668f9.natappfree.cc/store'//本地
 		// let path ='https://storeuserapp.bjyjbao.com/store'//本地
 		// let path = 'https://userapp.bjyjbao.com/store'//医 健宝
-		// let path = 'http://vef6cbdf.natappfree.cc/store'//张圆圆
-		let path = 'http://yd966f99.natappfree.cc/store'//汪于杰
+		let path = 'http://tad99bfb.natappfree.cc/store'//张圆圆
+		// let path = 'http://yd966f99.natappfree.cc/store'//汪于杰
 
 		let type = 0
 		uni.setStorageSync('requestPath',path)

+ 7 - 0
pages.json

@@ -887,6 +887,13 @@
 						"enablePullDownRefresh": false
 					}
 
+				}, {
+					"path": "user/inviteFriend",
+					"style": {
+						"navigationBarTitleText": "邀请好友",
+						"enablePullDownRefresh": false
+					}
+
 				}
 
 			]

+ 11 - 0
pages/auth/login.vue

@@ -45,6 +45,7 @@ export default {
 		return {
 			code:null,
 			isAgreement:false,
+			inviteUserId: null
 		}
 	},
 	computed: {
@@ -54,6 +55,12 @@ export default {
 	},
 	onLoad(option) 
 	{
+		console.log("登录页option>>>",option)
+		if (option && option.inviteUserId) {
+			this.inviteUserId = option.inviteUserId;
+			uni.setStorageSync('inviteUserId', option.inviteUserId);
+		}
+		
 		// #ifdef MP-WEIXIN
 		uni.$on('refreshLogin', () => {
 			uni.navigateBack({
@@ -171,11 +178,14 @@ export default {
 							console.log(loginRes)
 							let code = loginRes.code // 获取开发code
 							var userCode=uni.getStorageSync('userCode');
+							var inviteUserId=uni.getStorageSync('inviteUserId');
+							console.log("邀请UserId>>>",inviteUserId)
 							loginByMiniApp({
 							   encryptedData: e.mp.detail.encryptedData,
 							   iv: e.mp.detail.iv,
 							   code: code,
 							   userCode:userCode,
+							   inviteUserId:inviteUserId,
 							   appId:wx.getAccountInfoSync().miniProgram.appId,
 							})
 							.then( res => {
@@ -185,6 +195,7 @@ export default {
 										icon:'none',
 										title: "登录成功",
 									});
+									console.log("登录成功",res)
 									uni.setStorageSync('AppToken',res.token);
 									uni.setStorageSync('userInfo',JSON.stringify(res.user));
 									uni.hideLoading()

+ 36 - 0
pages/home/index.vue

@@ -441,6 +441,16 @@
 					this.getUserInfo();
 				}
 			}
+			if (option.inviteUserId) {
+				uni.setStorageSync('inviteUserId', option.inviteUserId);
+				// if (!this.utils.checkLoginState()) {
+				// 	uni.redirectTo({
+				// 		url: `/pages/auth/login?inviteUserId=${option.inviteUserId}`
+				// 	});
+				// } else {
+				// 	this.handleInvite(option.inviteUserId);
+				// }
+			}
 			// this.getStoreActivity()
 		},
 		// 暂停所有音频(一般用于页面切换时停止正在播放的音频)
@@ -568,6 +578,32 @@
 					rej => {}
 				);
 			},
+			handleInvite(inviteUserId) {
+				const data = {
+					inviteUserId: inviteUserId
+				};
+				bindPromoter(data).then(
+					res => {
+						if (res.code == 200) {
+							uni.showToast({
+								title: '绑定邀请关系成功',
+								icon: 'success'
+							});
+						} else {
+							uni.showToast({
+								title: res.msg,
+								icon: 'none'
+							});
+						}
+					},
+					err => {
+						uni.showToast({
+							title: '绑定失败',
+							icon: 'none'
+						});
+					}
+				);
+			},
 			cancleTui(e) {
 				this.tuiModalControl = false
 			},

+ 8 - 0
pages/user/index.vue

@@ -95,6 +95,10 @@
 								<image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/purpleShop/mycoupon.png" mode=""></image>
 								<text class="text">优惠券</text>
 							</view>
+							<view class="item no-marin-bottom"  @click="navgetTo('/pages_user/user/coupon')">
+								<image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/purpleShop/mycoupon.png" mode=""></image>
+								<text class="text">领券中心</text>
+							</view>
 							<view class="item no-marin-bottom" @click="navgetTo('/pages_user/user/storeProductRelation')">
 								<image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/purpleShop/footprint.png" mode=""></image>
 								<text class="text">我的足迹</text>
@@ -133,6 +137,10 @@
 							 	<image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/purpleShop/sale_file.png" mode=""></image>
 							 	<text class="text">销售管理</text>
 							 </view>
+							 <view class="item no-marin-bottom" @click="navgetTo('/pages_user/user/inviteFriend')">
+							 	<image src="/static/invite.png" mode=""></image>
+							 	<text class="text">邀请好友</text>
+							 </view>
 						</view>
 					</view>
 				</view>

+ 62 - 11
pages_user/user/coupon.vue

@@ -29,7 +29,12 @@
           </view>
         </view>
         <view class="tui-btn-box">
-			<view class="btn receive"   @click="show(item)">查看</view>
+            <view class="btn receive" v-if="item.status == 1" :class="{'tui-bg-grey': item.receiveStatus ==1}" @click="receiveCoupon(item)">
+                {{ item.receiveStatus == 0 ? '立即领取' : '已领取' }}
+            </view>
+            <view class="btn receive tui-bg-grey" v-else @click="receiveCoupon(item)">
+                {{ item.status == 0 ? '未开启' : '已无效' }}
+            </view>
         </view>
       </view>
     </view>
@@ -57,6 +62,7 @@ export default {
 		couponsList: [],
 		loading: false,
 		loadend: false,
+		user: JSON.parse(uni.getStorageSync('userInfo')) 
     }
   },
   onLoad(options) {
@@ -66,6 +72,9 @@ export default {
   },
   
   onShow() {
+	this.page = 1
+	this.couponsList = []
+	this.loadend = false
   	this.getCouponList()
   },
   onReachBottom() {
@@ -77,17 +86,59 @@ export default {
 			url: './couponDetails?id=' +item.id
 		})
 	},
+	receiveCoupon(item) {
+		
+		if (!this.user) {
+			uni.showToast({
+				title: '请先登录',
+				icon: 'none'
+			});
+			return;
+		}
+		let data = {
+			userId: this.user.userId,
+			issueId: item.id
+		};
+		uni.showLoading({
+			title: '领取中...'
+		});
+		receive(data).then(res => {
+			uni.hideLoading();
+			if (res.code == 200) {
+				uni.showToast({
+					title: '领取成功',
+					icon: 'success'
+				});
+				this.getCouponList()
+			} else {
+				uni.showToast({
+					title: res.msg || '领取失败',
+					icon: 'none'
+				});
+			}
+		}).catch(err => {
+			uni.hideLoading();
+			uni.showToast({
+				title: '网络错误,请稍后再试',
+				icon: 'none'
+			});
+		});
+	},
     getCouponList() {
-      if (this.loading) return //阻止下次请求(false可以进行请求);
-      if (this.loadend) return //阻止结束当前请求(false可以进行请求);
-      this.loading = true
-      let q = { couponType:1,page: this.page, pageSize: this.limit }
-      getCouponList(q).then(res => {
-        this.loading = false
-        this.couponsList.push.apply(this.couponsList, res.data.list)
-        this.loadend = res.data.list.length < this.limit //判断所有数据是否加载完成;
-        this.page = this.page + 1
-      })
+      if (this.loading) return;
+      if (this.loadend) return;
+      this.loading = true;
+      // let q = { pageNum: this.page, pageSize: this.limit };
+	  let q = { userId:this.user.userId };
+      getCouponList(q ).then(res => {
+        this.loading = false;
+        if (res.code == 200) {
+          let list = res.rows || [];
+          this.couponsList = this.couponsList.concat(list);
+          this.loadend = this.couponsList.length >= (res.total || 0);
+          this.page = this.page + 1;
+        }
+      });
     },
   },
 }

+ 531 - 0
pages_user/user/inviteFriend.vue

@@ -0,0 +1,531 @@
+<template>
+  <view class="invite-link-page">
+    <view class="container">
+      <view class="header">
+        <view class="title">邀请好友</view>
+        <view class="desc">通过微信分享邀请好友,直接打开小程序</view>
+      </view>
+
+      <view class="main-card">
+        <!-- <view class="invite-info">
+          <view class="info-row">
+            <text class="label">邀请人ID</text>
+            <text class="value">{{ userId }}</text>
+          </view>
+          <view class="info-row">
+            <text class="label">邀请参数</text>
+            <text class="value link-text">inviteUserId={{ userId }}</text>
+          </view>
+        </view> -->
+        <view class="invite-info">
+            <view class="info-row">
+            <text class="label">邀请人ID</text>
+            <text class="value">{{ userId }}</text>
+          </view>
+          <view class="info-row">
+            <text class="label">邀请人</text>
+            <text class="value">{{ userInfo.nickname }}</text>
+          </view>
+        </view>
+        <view class="share-btn primary">
+          <button open-type="share" class="share-button">
+            <text class="share-icon"></text>
+            <text>分享给微信好友</text>
+          </button>
+        </view>
+      </view>
+
+      <view class="tips-section">
+        <view class="tip-title">邀请说明</view>
+        <view class="tip-list">
+          <view class="tip-item">
+            <text class="tip-number">1</text>
+            <text class="tip-text">点击分享按钮,选择要邀请的好友</text>
+          </view>
+          <view class="tip-item">
+            <text class="tip-number">2</text>
+            <text class="tip-text">好友点击分享卡片将直接打开小程序登录页</text>
+          </view>
+          <view class="tip-item">
+            <text class="tip-number">3</text>
+            <text class="tip-text">好友登录后自动绑定邀请关系</text>
+          </view>
+        </view>
+      </view>
+
+      <view class="note-section">
+        <text class="note-title">温馨提示</text>
+        <text class="note-content">微信小程序的可复制链接需要通过微信官方API生成,如需此功能请联系后端开发配置。当前推荐使用分享按钮邀请好友。</text>
+      </view>
+    </view>
+  </view>
+</template>
+
+<script>
+export default {
+  name: "InviteFriend",
+  data() {
+    return {
+      userId: '',
+      invitePath: '',
+      userInfo: JSON.parse(uni.getStorageSync('userInfo')) || {}
+    };
+  },
+  mounted() {
+    this.initData();
+  },
+  onShareAppMessage() {
+    return {
+      title: '邀请你加入健康商城',
+      path: `/pages/home/index?inviteUserId=${this.userId}`,
+      imageUrl: '/static/logo.jpg',
+      success(res) {
+        uni.showToast({
+          title: '分享成功',
+          icon: 'success'
+        });
+      },
+      fail(err) {
+        uni.showToast({
+          title: '分享失败',
+          icon: 'none'
+        });
+      }
+    };
+  },
+  methods: {
+    initData() {
+      if (this.userInfo) {
+        this.userId = this.userInfo.userId;
+      } else {
+        uni.showToast({
+          title: '请先登录',
+          icon: 'none'
+        });
+        return;
+      }
+      this.invitePath = `/pages/home/index?inviteUserId=${this.userInfo.userId}`;
+      this.invitePath = `/pages/auth/login?inviteUserId=${this.userInfo.userId}`;
+
+    },
+
+    handleShare() {
+      uni.showShareMenu({
+        withShareTicket: true,
+        menus: ['shareAppMessage']
+      });
+
+      // uni.showToast({
+      //   title: '请点击右上角分享',
+      //   icon: 'none',
+      //   duration: 2000
+      // });
+    }
+  }
+};
+</script>
+
+<style lang="less">
+.invite-link-page {
+  min-height: 100vh;
+  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+}
+
+.container {
+  padding: 60rpx 40rpx;
+}
+
+.header {
+  text-align: center;
+  margin-bottom: 60rpx;
+
+  .title {
+    font-size: 48rpx;
+    font-weight: bold;
+    color: #fff;
+    margin-bottom: 20rpx;
+  }
+
+  .desc {
+    font-size: 28rpx;
+    color: rgba(255, 255, 255, 0.8);
+  }
+}
+
+.main-card {
+  background: #fff;
+  border-radius: 24rpx;
+  padding: 40rpx;
+  box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.15);
+
+  .invite-info {
+    margin-bottom: 30rpx;
+
+    .info-row {
+      display: flex;
+      justify-content: space-between;
+      align-items: center;
+      padding: 20rpx 0;
+      border-bottom: 1rpx solid #f0f0f0;
+
+      &:last-child {
+        border-bottom: none;
+      }
+
+      .label {
+        font-size: 28rpx;
+        color: #999;
+      }
+
+      .value {
+        font-size: 28rpx;
+        color: #333;
+        font-weight: 500;
+
+        &.link-text {
+          color: #4C49E9;
+          word-break: break-all;
+        }
+      }
+    }
+  }
+
+  .share-btn {
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    height: 96rpx;
+    border-radius: 48rpx;
+    font-size: 32rpx;
+    margin-bottom: 20rpx;
+
+    .share-icon {
+      font-family: iconfont;
+      margin-right: 12rpx;
+      font-size: 36rpx;
+    }
+
+    &.primary {
+      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+      color: #fff;
+    }
+
+    &.secondary {
+      background: #f5f5f5;
+      color: #666;
+    }
+  }
+
+  .share-button {
+    width: 100%;
+    height: 100%;
+    background: transparent;
+    border: none;
+    padding: 0;
+    margin: 0;
+    font-size: inherit;
+    color: inherit;
+    line-height: inherit;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+
+    &::after {
+      display: none;
+    }
+  }
+}
+
+.tips-section {
+  margin-top: 40rpx;
+  background: rgba(255, 255, 255, 0.1);
+  border-radius: 24rpx;
+  padding: 30rpx;
+
+  .tip-title {
+    font-size: 30rpx;
+    font-weight: bold;
+    color: #fff;
+    margin-bottom: 24rpx;
+  }
+
+  .tip-list {
+    .tip-item {
+      display: flex;
+      align-items: flex-start;
+      margin-bottom: 20rpx;
+
+      &:last-child {
+        margin-bottom: 0;
+      }
+
+      .tip-number {
+        width: 40rpx;
+        height: 40rpx;
+        border-radius: 50%;
+        background: rgba(255, 255, 255, 0.2);
+        color: #fff;
+        font-size: 24rpx;
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        margin-right: 20rpx;
+        flex-shrink: 0;
+      }
+
+      .tip-text {
+        font-size: 26rpx;
+        color: rgba(255, 255, 255, 0.9);
+        line-height: 1.6;
+      }
+    }
+  }
+}
+
+.note-section {
+  margin-top: 30rpx;
+  background: rgba(255, 255, 255, 0.08);
+  border-radius: 16rpx;
+  padding: 24rpx;
+
+  .note-title {
+    font-size: 26rpx;
+    font-weight: bold;
+    color: rgba(255, 255, 255, 0.9);
+    display: block;
+    margin-bottom: 12rpx;
+  }
+
+  .note-content {
+    font-size: 24rpx;
+    color: rgba(255, 255, 255, 0.7);
+    line-height: 1.6;
+  }
+}
+</style>on-title {
+font-size: 32rpx;
+font-weight: bold;
+color: #333;
+margin-bottom: 24rpx;
+}
+}
+
+.rewards-list {
+.reward-item {
+display: flex;
+align-items: center;
+padding: 20rpx 0;
+border-bottom: 1rpx solid #f5f5f5;
+
+&:last-child {
+border-bottom: none;
+}
+
+.reward-icon {
+width: 48rpx;
+height: 48rpx;
+border-radius: 50%;
+background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+color: #fff;
+font-size: 24rpx;
+display: flex;
+align-items: center;
+justify-content: center;
+margin-right: 20rpx;
+}
+
+.reward-info {
+flex: 1;
+
+.reward-title {
+font-size: 28rpx;
+color: #333;
+margin-bottom: 6rpx;
+}
+
+.reward-desc {
+font-size: 24rpx;
+color: #999;
+}
+}
+
+.reward-value {
+font-size: 28rpx;
+font-weight: bold;
+color: #4C49E9;
+}
+}
+}
+
+.share-list {
+display: flex;
+justify-content: space-around;
+
+.share-item {
+display: flex;
+flex-direction: column;
+align-items: center;
+
+.share-icon {
+width: 100rpx;
+height: 100rpx;
+border-radius: 50%;
+display: flex;
+align-items: center;
+justify-content: center;
+margin-bottom: 16rpx;
+
+.iconfont {
+font-size: 48rpx;
+}
+}
+
+.wechat-icon {
+background: linear-gradient(135deg, #07c160 0%, #10b981 100%);
+color: #fff;
+}
+
+.moments-icon {
+background: linear-gradient(135deg, #e6d5b8 0%, #d4a373 100%);
+color: #fff;
+}
+
+.qq-icon {
+background: linear-gradient(135deg, #1677ff 0%, #096dd9 100%);
+color: #fff;
+}
+
+.link-icon {
+background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+color: #fff;
+}
+
+.share-name {
+font-size: 24rpx;
+color: #666;
+}
+}
+}
+
+.invited-section {
+.invited-count {
+display: flex;
+flex-direction: column;
+align-items: center;
+padding: 30rpx 0;
+border-bottom: 1rpx solid #f5f5f5;
+
+.count-num {
+font-size: 56rpx;
+font-weight: bold;
+color: #4C49E9;
+}
+
+.count-desc {
+font-size: 26rpx;
+color: #999;
+margin-top: 8rpx;
+}
+}
+
+.invited-list {
+padding-top: 20rpx;
+
+.invited-item {
+display: flex;
+align-items: center;
+padding: 20rpx 0;
+border-bottom: 1rpx solid #f5f5f5;
+
+&:last-child {
+border-bottom: none;
+}
+
+.avatar {
+width: 72rpx;
+height: 72rpx;
+border-radius: 50%;
+overflow: hidden;
+margin-right: 20rpx;
+
+image {
+width: 100%;
+height: 100%;
+}
+}
+
+.info {
+flex: 1;
+
+.name {
+font-size: 28rpx;
+color: #333;
+margin-bottom: 6rpx;
+}
+
+.time {
+font-size: 24rpx;
+color: #999;
+}
+}
+
+.status {
+font-size: 22rpx;
+color: #999;
+padding: 6rpx 16rpx;
+border-radius: 20rpx;
+background: #f5f5f5;
+
+&.active {
+color: #4C49E9;
+background: rgba(76, 73, 233, 0.1);
+}
+}
+}
+}
+
+.empty {
+display: flex;
+flex-direction: column;
+align-items: center;
+padding: 40rpx 0;
+
+.empty-icon {
+width: 120rpx;
+height: 120rpx;
+margin-bottom: 20rpx;
+}
+
+.empty-text {
+font-size: 28rpx;
+color: #999;
+margin-bottom: 24rpx;
+}
+
+.empty-btn {
+padding: 16rpx 48rpx;
+background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+color: #fff;
+font-size: 28rpx;
+border-radius: 30rpx;
+}
+}
+}
+
+.bottom-btn {
+position: fixed;
+left: 30rpx;
+right: 30rpx;
+bottom: 30rpx;
+height: 96rpx;
+background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+color: #fff;
+font-size: 32rpx;
+font-weight: bold;
+border-radius: 48rpx;
+display: flex;
+align-items: center;
+justify-content: center;
+box-shadow: 0 8rpx 24rpx rgba(102, 126, 234, 0.4);
+}
+</style>

BIN=BIN
static/invite.png