Sfoglia il codice sorgente

fix:加个二维码生成时间

zhanghui 2 anni fa
parent
commit
2dc5685386

+ 53 - 0
common/js/utils/commonUtils.js

@@ -0,0 +1,53 @@
+// commonUtils.js
+const http = uni.$u.http
+
+// 判断数据是否为空
+function isDataEmpty(data) {
+  if (data === null || data === undefined) {
+    return true;
+  }
+
+  if (typeof data === 'string' && data.trim() === '') {
+    return true;
+  }
+
+  if (Array.isArray(data) && data.length === 0) {
+    return true;
+  }
+
+  if (typeof data === 'object' && Object.keys(data).length === 0) {
+    return true;
+  }
+
+  return false;
+}
+
+// 日期转换
+function formatDate(timestamp) {
+	const date = new Date(timestamp);
+	const year = date.getFullYear();
+	const month = (date.getMonth() + 1).toString().padStart(2, '0');
+	const day = date.getDate().toString().padStart(2, '0');
+	const hour = date.getHours().toString().padStart(2,'0');
+	const minutes = date.getMinutes().toString().padStart(2,'0');
+	const secoonds = date.getSeconds().toString().padStart(2,'0');
+	return `${year}-${month}-${day} ${hour}:${minutes}:${secoonds}`;
+}
+
+// 日期转换
+function dateFormatYmd(dateStr) {
+	const timestamp = new Date(dateStr).getTime();
+	const date = new Date(timestamp);
+	const year = date.getFullYear();
+	const month = (date.getMonth() + 1).toString().padStart(2, '0');
+	const day = date.getDate().toString().padStart(2, '0');
+	return `${year}-${month}-${day}`;
+}
+
+
+// 导出工具类方法
+export default {
+  isDataEmpty,
+  formatDate,
+  dateFormatYmd,
+};

+ 1 - 1
manifest.json

@@ -88,7 +88,7 @@
 	"quickapp": {},
 	/* 小程序特有相关 */
 	"mp-weixin": {
-		"appid": "",
+		"appid": "wx0c80b1524229c640",
 		"setting": {
 			"urlCheck": false
 		},

+ 17 - 2
pages/index/attach/attach.vue

@@ -52,7 +52,7 @@
 			<text>生成二维码</text>
 		</view>
 
-		<uni-popup ref="createQrCodePopup" type="center">
+		<uni-popup ref="createQrCodePopup" type="center" @change="createQrCodePopupChange">
 			<view class="createQrCodePopup">
 				<view class="flex-row justify-center">
 					<text class="popupTitle">拓客二维码</text>
@@ -63,12 +63,16 @@
 				<view class="flex-row justify-center">
 					<uv-qrcode ref="qrcode" size="540rpx" :value="qrcodeUrl" :options="options"></uv-qrcode>
 				</view>
+				<view class="flex-row justify-center qrCreateTime">
+					<text>生成时间:{{qrCreateTime}}</text>
+				</view>
 			</view>
 		</uni-popup>
 	</view>
 </template>
 
 <script>
+	import commonUtils from '../../../common/js/utils/commonUtils'
 	export default {
 		props:{
 			height: {
@@ -80,6 +84,7 @@
 		},
 		data() {
 			return {
+				qrCreateTime:'',
 				roleBindRuleList:[],
 				userInfo:{},
 				qrcodeUrl:this.$xcxUrl+'?expandUserId={expandUserId}&ruleId={ruleId}&timestamp={timestamp}',
@@ -97,6 +102,10 @@
 		},
 		methods: {
 
+			formatDate(){
+				this.qrCreateTime = commonUtils.formatDate(new Date())
+			},
+
 			selectRule(item,index){
 				this.roleBindRuleList.forEach(i=>{
 					i.select=false
@@ -141,10 +150,16 @@
 				}
 				console.log('++++data+++++',data)
 				console.log('++++qrcodeUrl+++++',this.qrcodeUrl)
+				this.formatDate()
 				this.$refs.createQrCodePopup.open()
 			},
+			createQrCodePopupChange(e){
+				console.log(e)
+				if (!e.show){
+					this.qrcodeUrl=this.$xcxUrl+'?expandUserId={expandUserId}&ruleId={ruleId}&timestamp={timestamp}'
+				}
+			},
 			closePopup(){
-				this.qrcodeUrl=this.$xcxUrl+'?expandUserId={expandUserId}&ruleId={ruleId}&timestamp={timestamp}',
 				this.$refs.createQrCodePopup.close()
 			},
 		}

+ 6 - 1
pages/index/attach/index.rpx.css

@@ -47,7 +47,7 @@
 }
 .createQrCodePopup{
     width: 638rpx;
-    height: 714rpx;
+    height: 750rpx;
     background: #FFFFFF;
     border-radius: 24rpx;
     position: relative;
@@ -102,3 +102,8 @@
 .roleName{
     color: #007aff;
 }
+.qrCreateTime{
+    margin-top: 24rpx;
+    font-size: 24rpx;
+    color: #999999;
+}

+ 6 - 1
pages/index/manager/index.rpx.css

@@ -99,7 +99,7 @@
 }
 .createQrCodePopup{
     width: 638rpx;
-    height: 714rpx;
+    height: 750rpx;
     background: #FFFFFF;
     border-radius: 24rpx;
     position: relative;
@@ -165,3 +165,8 @@
 .roleHint{
     color: #999999;
 }
+.qrCreateTime{
+    margin-top: 24rpx;
+    font-size: 24rpx;
+    color: #999999;
+}

+ 19 - 3
pages/index/manager/manager.vue

@@ -65,7 +65,7 @@
 		</view>
 
 		<!--邀请专员二维码-->
-		<uni-popup ref="createQrCodePopup" type="center">
+		<uni-popup ref="createQrCodePopup" type="center" @change="createQrCodePopupChange">
 			<view class="createQrCodePopup">
 				<view class="flex-row justify-center">
 					<text class="popupTitle">邀请专员二维码</text>
@@ -76,6 +76,9 @@
 				<view class="flex-row justify-center">
 					<uv-qrcode ref="qrcode" size="540rpx" :value="qrcodeUrl" :options="options"></uv-qrcode>
 				</view>
+				<view class="flex-row justify-center qrCreateTime">
+					<text>生成时间:{{qrCreateTime}}</text>
+				</view>
 			</view>
 		</uni-popup>
 		<!--选择规则-->
@@ -159,6 +162,8 @@
 </template>
 
 <script>
+	import commonUtils from "../../../common/js/utils/commonUtils";
+
 	export default {
 		props:{
 			height: {
@@ -170,6 +175,7 @@
 		},
 		data() {
 			return {
+				qrCreateTime:'',
 				selectRoleIndex:0, //正在选择的角色下标
 				confirmRoleIndex:0, //当前选中的角色下标
 				roleList:[],
@@ -192,6 +198,10 @@
 		},
 		methods: {
 
+			formatDate(){
+				this.qrCreateTime = commonUtils.formatDate(new Date())
+			},
+
 			deleteRule(item){
 
 				let  that =this
@@ -260,7 +270,7 @@
 				}
 			},
 			closePopup(){
-				this.qrcodeUrl=this.$tkUrl+'?roleId={roleId}&parentId={parentId}&timestamp={timestamp}',
+
 				this.$refs.rolePopup.close()
 				this.$refs.createQrCodePopup.close()
 				this.$refs.rulePopup.close()
@@ -290,9 +300,15 @@
 					this.qrcodeUrl = this.qrcodeUrl.replace(regexp, data[key]); // 执行替换操作
 				}
 				console.log('++++qrcodeUrl+++++',this.qrcodeUrl)
-
+				this.formatDate()
 				this.$refs.createQrCodePopup.open()
 			},
+			createQrCodePopupChange(e){
+				console.log(e)
+				if (!e.show){
+					this.qrcodeUrl=this.$tkUrl+'?roleId={roleId}&parentId={parentId}&timestamp={timestamp}'
+				}
+			},
 			addRule(){
 				this.$refs.rulePopup.open()
 			},