Преглед изворни кода

优化运营需求,修复粘贴回车问题 -zzx

zouzexu пре 6 месеци
родитељ
комит
9ea3a4f4d1
2 измењених фајлова са 20 додато и 10 уклоњено
  1. 19 9
      my/vipActivation/index.vue
  2. 1 1
      pages/my/index.vue

+ 19 - 9
my/vipActivation/index.vue

@@ -14,8 +14,8 @@
 				</view>
 			</view>
 			<view class="inputBox">
-				<input type="text" v-model="vipQuery.activationCode" placeholder="请输入激活码"
-					placeholder-class="activationIpt" />
+				<input type="text" v-model="vipQuery.activationCode" @input="handleInput" @paste="handlePaste"
+					placeholder="请输入激活码" placeholder-class="activationIpt" />
 				<u-button type="error " :loading="redeemload" loadingSize="20" shape="circle" text="立即兑换"
 					@click="confirmActivation"></u-button>
 			</view>
@@ -84,6 +84,16 @@
 		},
 
 		methods: {
+			// 修复android粘贴出现回车问题
+			handleInput() {
+				this.vipQuery.activationCode = this.vipQuery.activationCode.replace(/\s/g, '');
+			},
+			handlePaste(event) {
+				let pasteData = event.clipboardData.getData('text');
+				pasteData = pasteData.replace(/\r?\n|\r/g, '');
+				this.vipQuery.activationCode = this.vipQuery.activationCode + pasteData;
+			},
+
 			// 用户信息
 			get_userinfo() {
 				refreshVip().then(res => {
@@ -107,10 +117,10 @@
 
 			// 二次确认
 			confirmActivation() {
-				if(this.vipQuery.activationCode=='') {
+				if (this.vipQuery.activationCode == '') {
 					uni.showToast({
-						title:'请输入激活码',
-						icon:'none'
+						title: '请输入激活码',
+						icon: 'none'
 					})
 					return
 				}
@@ -137,9 +147,9 @@
 						});
 						this.vipQuery.activationCode = ''
 						this.get_activationList()
-					} else{
+					} else {
 						this.$refs.uToast.show({
-							message:res.content
+							message: res.content
 						})
 					}
 				})
@@ -220,8 +230,8 @@
 				margin-top: 20rpx;
 
 				&>input {
-					margin-left: 8rpx;
-					width: 1800rpx;
+					margin-left: 16rpx;
+					width: 1600rpx;
 				}
 
 				.activationIpt {

+ 1 - 1
pages/my/index.vue

@@ -86,7 +86,7 @@
 		<!-- 	<u-cell title="研学MBTI测试"  @click="jump('../../study/test')" :border="false" :isLink="true" arrow-direction="right">
 				<image slot="icon" class="cell-icon" src="../../static/icon8.png" mode=""></image>
 			</u-cell> -->
-			<u-cell title="会员激活"  @click="jump('../../my/vipActivation/index')" :border="false" :isLink="true" arrow-direction="right">
+			<u-cell title="激活码兑换"  @click="jump('../../my/vipActivation/index')" :border="false" :isLink="true" arrow-direction="right">
 				<image slot="icon" class="cell-icon" src="../../static/vip-icon.png" mode=""></image>
 			</u-cell>
 			<u-cell title="设置"  @click="jump('../../my/edit/edit')" :border="false" :isLink="true" arrow-direction="right">