Explorar el Código

新增公司码绑定相关代码

XSLu08042 hace 1 semana
padre
commit
4a04e8fc51
Se han modificado 5 ficheros con 378 adiciones y 1 borrados
  1. 8 0
      api/companyUser.js
  2. 19 1
      pages.json
  3. 260 0
      pages_company/bindInfo.vue
  4. 4 0
      pages_company/index.vue
  5. 87 0
      pages_user/bindCompanyUser.vue

+ 8 - 0
api/companyUser.js

@@ -18,6 +18,14 @@ let request = new Request().http
  export function bindCompanyUser(data) {
  	 return request('/app/companyUser/bindCompanyUser',data,'POST','application/json;charset=UTF-8');
  }
+ // 获取绑定
+ export function getBindInfo(data) {
+ 	 return request('/app/companyUser/getBindInfo',data,'GET','application/json;charset=UTF-8');
+ }
+ // 绑定销售
+ export function bindCompanyFsUser(id) {
+ 	 return request('/app/companyCompanyFsUser/bind/'+id,null,'GET','application/json;charset=UTF-8');
+ }
  
  
  

+ 19 - 1
pages.json

@@ -1175,6 +1175,14 @@
 				 	"style": {
 				 		"navigationBarTitleText": "健康管家"
 				 	}
+				 },{
+				 	"path": "bindCompanyUser",
+				 	"style": {
+				 		"navigationBarTitleText": "绑定",
+				 		"enablePullDownRefresh": false,
+				 		"navigationBarBackgroundColor":"#ffffff",
+				 		"navigationBarTextStyle":"black"
+				 	}
 				 }
 			]
 		},
@@ -1298,8 +1306,18 @@
 				        "navigationBarTitleText": "快递信息"
 				    }
 				    
+				},
+				{
+				    "path" : "bindInfo",
+				    "style" :                                                                                    
+				    {
+				        "navigationBarTitleText" : "",
+				        "enablePullDownRefresh": false,
+				        "navigationBarBackgroundColor":"#f7f7f7",
+				        "navigationBarTextStyle":"black"
+				    }
+				    
 				}
-				
 				 
 			]
 		},

+ 260 - 0
pages_company/bindInfo.vue

@@ -0,0 +1,260 @@
+<template>
+	<view class="container" v-if="imageUrl || urlVal">
+		<view class="qrcode-box x-c">
+			<image class="qrcode" :src="imageUrl" mode="aspectFill" show-menu-by-longpress="true"></image>
+		</view>
+		<view class="share-inner">
+			<view class="share-item">
+				<view class="img">
+					<u-icon name="share-square" size="30" color="#222"></u-icon>
+				</view>
+				<text class="text">分享</text>
+				<button class='share-btn' open-type="share"></button>
+			</view>
+			<!-- <view class="share-item" @click="copyUrl()">
+				<image src="/static/images/icon_copy_link.png" mode=""></image>
+				<text class="text">复制链接</text>
+			</view> -->
+			<!-- #ifndef H5 -->
+			<view class="share-item" @click="downImg()">
+				<view class="img">
+					<u-icon name="download" size="30" color="#222"></u-icon>
+				</view>
+				<text class="text">保存图片</text>
+			</view>
+			<!-- #endif -->
+		</view>
+	</view>
+	<u-empty style="padding-top: 20vh;" mode="data" v-else="imgurl"
+		icon="https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png" text="暂无数据"></u-empty>
+</template>
+
+<script>
+	import {
+		getBindInfo
+	} from "@/api/companyUser.js"
+	export default {
+		data() {
+			return {
+				imageUrl: '',
+				urlVal: '',
+				companyUserId: ''
+			}
+		},
+		//发送给朋友
+		onShareAppMessage(res) {
+			console.log("fe===",this.imageUrl)
+			return {
+				title: '立即绑定,享受更多权益',
+				path: '/pages_user/bindCompanyUser?companyUserId=' + this.companyUserId,
+				imageUrl: this.imageUrl
+				// imageUrl: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
+			}
+			
+		},
+		//分享到朋友圈
+		onShareTimeline(res) {
+			return {
+				title: '立即绑定,享受更多权益',
+				query:'companyUserId='+this.companyUserId,//页面参数
+				imageUrl: this.imageUrl
+			}
+			
+		},
+		onLoad() {
+			this.companyUserId = uni.getStorageSync('companyUserId') || '';
+			this.getInfo()
+		},
+		methods: {
+			getInfo() {
+				getBindInfo().then(res => {
+					if (res.code == 200) {
+						this.imageUrl = res.imageUrl
+						this.urlVal = res.url
+					} else {
+						uni.showToast({
+							title: res.msg,
+							icon: 'none'
+						})
+					}
+				})
+			},
+			copyUrl() {
+				uni.setClipboardData({
+					data: this.urlVal,
+					success: () => {
+						uni.showToast({
+							title: '复制成功',
+							icon: 'none'
+						});
+					},
+					fail: () => {
+						uni.showToast({
+							title: '复制失败',
+							icon: 'none'
+						});
+					}
+				});
+			},
+			downImg() {
+				uni.showLoading({
+					title: "图片保存中..."
+				})
+				uni.downloadFile({
+					url: this.imageUrl,
+					fail: function(res) {
+						uni.showModal({
+							title: '提示',
+							content: '保存失败',
+						})
+						uni.hideLoading();
+					},
+					success: function(res) {
+						var tempFilePath = res.tempFilePath;
+						uni.saveImageToPhotosAlbum({
+							filePath: tempFilePath,
+							success: () => {
+								uni.showToast({
+									title: "保存成功",
+									duration: 2000
+								})
+							},
+							fail: () => {
+								console.log("图片失败");
+								uni.showToast({
+									title: "图片失败",
+									duration: 2000,
+									icon: "error"
+								})
+								uni.hideLoading();
+							},
+							complete: function() {
+								uni.hideLoading();
+							}
+						})
+					},
+				})
+			}
+		}
+	}
+</script>
+
+<style scoped lang="scss">
+	.container {
+		padding: 40rpx 0;
+		padding-top: 16vh;
+		box-sizing: border-box;
+		display: flex;
+		flex-direction: column;
+		align-items: center;
+		position: relative;
+	}
+
+	.qrcode-box {
+		width: 480rpx;
+		height: 480rpx;
+		box-sizing: border-box;
+		overflow: hidden;
+		flex-direction: column !important;
+		border-radius: 16rpx;
+		background-color: #fff;
+		font-family: PingFang SC, PingFang SC;
+		font-weight: 400;
+		font-size: 28rpx;
+		color: #222;
+
+		.qrcode {
+			width: 450rpx;
+			height: 450rpx;
+		}
+
+		.qrcode-title {
+			font-weight: bold;
+			font-size: 32rpx;
+			color: #222;
+			margin-bottom: 32rpx;
+		}
+
+		.qrcode-tip {
+			margin: 32rpx;
+			color: #999;
+			text-align: center;
+		}
+	}
+
+	.downbtn {
+		width: 160rpx;
+		min-height: 68rpx;
+		border: 1px solid #FF5C03 !important;
+		color: #FF5C03 !important;
+		background-color: #fff !important;
+		border-radius: 168rpx;
+		font-family: PingFang SC, PingFang SC;
+		font-weight: 400;
+		font-size: 28rpx;
+
+		&::after {
+			border: none;
+		}
+	}
+
+	.share-inner {
+		width: 100%;
+		box-sizing: border-box;
+		padding: 0 10%;
+		display: flex;
+		flex-wrap: wrap;
+		position: absolute;
+		bottom: 0;
+		left: 0;
+
+		.share-item {
+			flex: 1;
+			display: flex;
+			flex-direction: column;
+			align-items: center;
+			justify-content: center;
+			margin-bottom: 66upx;
+			position: relative;
+
+			.img {
+				width: 80upx;
+				height: 80upx;
+				margin-bottom: 20upx;
+				background-color: #fff;
+				display: flex;
+				align-items: center;
+				justify-content: center;
+				border-radius: 50%;
+			}
+
+			image {
+				width: 80upx;
+				height: 80upx;
+				margin-bottom: 20upx;
+			}
+
+			.text {
+				font-size: 28upx;
+				font-family: PingFang SC;
+				font-weight: 500;
+				color: #111111;
+				line-height: 1;
+			}
+		}
+	}
+
+	.share-btn {
+		position: absolute;
+		left: 50%;
+		top: 0;
+		width: 80upx;
+		height: 100%;
+		transform: translateX(-50%);
+		background-color: transparent !important;
+
+		&::after {
+			border: none;
+		}
+	}
+</style>

+ 4 - 0
pages_company/index.vue

@@ -52,6 +52,10 @@
 						<image src="../static/images/icon_company_3.png" mode=""></image>
 						<view class="text">健康档案</view>
 					</view>
+					<view class="item" @click="navTo('/pages_company/bindInfo')">
+					 	<image src="../static/images/icon_company_3.png" mode=""></image>
+					 	<text class="text">公司码</text>
+					</view>
 				</view>
 			</view>
 			<!-- 退出登录按钮 -->

+ 87 - 0
pages_user/bindCompanyUser.vue

@@ -0,0 +1,87 @@
+<template>
+	<view class="content">
+		<view class="bindbox">
+			<image :src="baseUrl + '/images/bindComUser.png'" mode="aspectFill"></image>
+			<view>立即绑定,享受更多权益</view>
+		</view>
+		<button class="bind-btn" :loading="btnLodaing" :disabled="btnLodaing" @click="handleBind">立即绑定</button>
+	</view>
+</template>
+
+<script>
+	import { bindCompanyFsUser } from '@/api/companyUser.js'
+	export default {
+		data() {
+			return {
+				baseUrl:uni.getStorageSync('requestPath'),
+				btnLodaing: false,
+				companyUserId: '',
+			}
+		},
+		onLoad(option) {
+			this.companyUserId = option.companyUserId
+		},
+		methods: {
+			handleBind() {
+				this.btnLodaing = true
+				uni.showLoading({
+					title: '绑定中...'
+				})
+				bindCompanyFsUser(this.companyUserId).then(res=>{
+					this.btnLodaing = false
+					uni.hideLoading()
+					uni.showToast({
+						title: res.msg,
+						icon: 'none'
+					})
+				}).catch(()=>{
+					this.btnLodaing = false
+					uni.hideLoading()
+				})
+			}
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+	.bindbox {
+		display: flex;
+		flex-direction: column;
+		align-items: center;
+		justify-content: center;
+		padding-top: 20vh;
+		font-family: PingFang SC, PingFang SC;
+		font-weight: 400;
+		font-size: 32rpx;
+		color: #757575;
+		image {
+			height: 150rpx;
+			width: 150rpx;
+			margin-bottom: 50rpx;
+		}
+	}
+	.content {
+		width: 100%;
+		display: flex;
+		flex-direction: column;
+		align-items: center;
+		padding-bottom: calc(var(--window-bottom) + 150rpx);
+		
+	}
+	.bind-btn {
+		margin: 20vh auto 20px auto;
+		width: 300px;
+		height: 44px;
+		line-height: 44px;
+		text-align: center;
+		background: #FF5C03 !important;
+		color: #fff !important;
+		font-size: 16px;
+		font-weight: 500;
+		border-radius: 22px;
+		display: block;
+		&:after {
+			border: none;
+		}
+	}
+</style>