浏览代码

2023-10-28

cmy 1 年之前
父节点
当前提交
0c3e5c8dcc
共有 2 个文件被更改,包括 73 次插入23 次删除
  1. 1 1
      api/index.js
  2. 72 22
      pages/public/register.vue

+ 1 - 1
api/index.js

@@ -20,7 +20,7 @@ export function getIndex(data) {
 /**
  * 商品分类类版本
  */
-export function getAppVersion() {
+export function getAppVersion(data) {
 	return request({
 		url: '/api/version',
 		method: 'get',

+ 72 - 22
pages/public/register.vue

@@ -46,6 +46,12 @@
 			</view>
 			<view><button class="uni-button uni-button-green uni-button-green-plain" type="green" plain="true"
 					hover-class="none" @click="login">{{$t('login.a4')}}</button></view>
+			<!-- #ifdef H5 -->
+			<view class="flex">
+				<button class="uni-button loadapp" @click="domApp('apk')">APK下载</button>
+				<button class="uni-button loadapp" @click="domApp('ios')">IOS下载</button>
+			</view>
+			<!-- #endif -->
 		</view>
 	</view>
 </template>
@@ -54,6 +60,9 @@
 		register,
 		verify
 	} from '@/api/login.js';
+	import {
+		getAppVersion
+	} from '@/api/index.js'
 	export default {
 		data() {
 			return {
@@ -67,7 +76,7 @@
 				time: '', //保存倒计时对象
 				countDown: 0, //倒计时
 				trade_password: '', // 交易密码
-				isPhone: true,  //是否为手机号,默认为true
+				isPhone: true, //是否为手机号,默认为true
 			};
 		},
 		onLoad(option) {
@@ -87,7 +96,7 @@
 			}
 			// #endif
 			// 获取扫码邀请人id
-			this.spread = option.spread||uni.getStorageSync('spread') || '';
+			this.spread = option.spread || uni.getStorageSync('spread') || '';
 		},
 		watch: {
 			// 监听倒计时
@@ -98,11 +107,36 @@
 			}
 		},
 		methods: {
-			
+			// #ifdef H5
+			domApp(type) {
+				console.log('111');
+				const bool = navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger';
+				if (bool) {
+					uni.showModal({
+						title: '提示',
+						content: '无法在微信中下载,请用浏览器打开下载',
+						showCancel: false,
+					});
+				} else {
+					if (type == 'apk') {
+						getAppVersion().then((res) => {
+							console.log(res, 'res');
+							window.open(res.data.apk);
+						}).catch((err) => {
+							console.log(err, 'err');
+						})
+						return
+					}
+					if(type=="ios"){
+						
+					}
+				}
+			},
+			// #endif
 			checkAccount() {
-				 const regPhone = /^1[3|4|5|7|8][0-9]{9}$/;
-				    const regEmail = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
-				    this.isPhone = regPhone.test(this.account);
+				const regPhone = /^1[3|4|5|7|8][0-9]{9}$/;
+				const regEmail = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
+				this.isPhone = regPhone.test(this.account);
 			},
 			// 注册
 			register() {
@@ -112,16 +146,16 @@
 					return;
 				}
 				if (this.isPhone) {
-				      if (!/^1[3|4|5|7|8][0-9]{9}$/.test(this.account)) {
-				        this.$api.msg(obj.$t("safe.b8"));
-				        return;
-				      }
-				    } else {
-				      if (!/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/.test(this.account)) {
-				        this.$api.msg(obj.$t("login.b9"));
-				        return;
-				      }
-				    }
+					if (!/^1[3|4|5|7|8][0-9]{9}$/.test(this.account)) {
+						this.$api.msg(obj.$t("safe.b8"));
+						return;
+					}
+				} else {
+					if (!/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/.test(this.account)) {
+						this.$api.msg(obj.$t("login.b9"));
+						return;
+					}
+				}
 				// if (!/(^1[3|4|5|7|8][0-9]{9}$)/.test(this.account)) {
 				// 	obj.$api.msg('请输入正确的手机号');
 				// 	return;
@@ -148,12 +182,21 @@
 						duration: 2000,
 						position: 'top'
 					});
-					setTimeout(function() {
-						uni.navigateTo({
-							url: '/pages/public/login'
-						});
-					}, 1000)
-
+					uni.showModal({
+						title: '提示',
+						content: '注册成功是否登录?',
+						cancelText: '取消',
+						confirmText: '登录',
+						success: res => {
+							if(res.confirm){
+								uni.navigateTo({
+									url: '/pages/public/login'
+								});
+							}
+						},
+						fail: () => {},
+						complete: () => {}
+					});
 				});
 				//调用注册接口,成功跳转登录页
 			},
@@ -297,6 +340,13 @@
 			color: #999999;
 		}
 
+		.loadapp {
+			border: 1px solid #feb041;
+			background-color: transparent;
+			color: #feb041;
+			width: 45%;
+		}
+
 		.uni-button-green {
 			color: #ffffff;
 			background-color: #feb041;