提交 001ce67b 编写于 作者: DCloud_JSON's avatar DCloud_JSON

新增绑定手机号码页面前端校验

上级 78a1788c
...@@ -5,36 +5,36 @@ ...@@ -5,36 +5,36 @@
globalData: { globalData: {
searchText: '', searchText: '',
appVersion: {}, appVersion: {},
config:{} config: {}
}, },
onLaunch: function() { onLaunch: function() {
console.log('App Launch') console.log('App Launch')
initApp(); initApp();
// #ifdef APP-PLUS // #ifdef APP-PLUS
//checkIsAgree(); APP端暂时先用原生默认生成的。目前,自定义方式启动vue界面时,原生层已经请求了部分权限这并不符合国家的法规 //checkIsAgree(); APP端暂时先用原生默认生成的。目前,自定义方式启动vue界面时,原生层已经请求了部分权限这并不符合国家的法规
// #endif
// #ifdef H5
// checkIsAgree(); 默认不开启。目前全球,仅欧盟国家有网页端同意隐私权限的需要。如果需要
// #endif // #endif
// #ifdef H5
// checkIsAgree(); 默认不开启。目前全球,仅欧盟国家有网页端同意隐私权限的需要。如果需要
// #endif
// #ifdef APP-PLUS // #ifdef APP-PLUS
//idfa有需要的用户在应用首次启动时自己获取存储到storage中 //idfa有需要的用户在应用首次启动时自己获取存储到storage中
//https://ask.dcloud.net.cn/article/36107 //https://ask.dcloud.net.cn/article/36107
/*if(~plus.storage.getItem('idfa')){ /*if(~plus.storage.getItem('idfa')){
plus.device.getInfo({//需要勾选IDFA plus.device.getInfo({//需要勾选IDFA
success:function(e){ success:function(e){
console.log('idfa = '+JSON.stringify(e.idfa)); console.log('idfa = '+JSON.stringify(e.idfa));
}, },
fail:function(e){ fail:function(e){
console.log('getDeviceInfo failed: '+JSON.stringify(e)); console.log('getDeviceInfo failed: '+JSON.stringify(e));
} }
}); });
}*/ }*/
// #endif // #endif
}, },
onShow: function() { onShow: function() {
console.log('App Show') console.log('App Show')
}, },
onHide: function() { onHide: function() {
console.log('App Hide') console.log('App Hide')
...@@ -44,4 +44,4 @@ ...@@ -44,4 +44,4 @@
<style> <style>
/*每个页面公共css */ /*每个页面公共css */
</style> </style>
...@@ -78,6 +78,9 @@ uni-starter + uniCloud admin,提供了用户端和管理端的基础模板, ...@@ -78,6 +78,9 @@ uni-starter + uniCloud admin,提供了用户端和管理端的基础模板,
"login": ["username","smsCode","univerify", "weixin", "apple"], "login": ["username","smsCode","univerify", "weixin", "apple"],
} }
``` ```
*** 注意:首页需要强制登陆才能访问的场景
- 这种情况不由路由控制。而是uni-starter的callFunction拦截器,根据响应体决定是否跳转到登陆页。
- uni-starter框架不能将登陆页面设置为首页,否则由拦截器实现的路由管理将生效。
#### 2.登录配置详解 #### 2.登录配置详解
- 使用方式:在 `uni-starter.config.js`->`router`->`login`下完全列举你需要的登录方式。这里支持用[条件编译](https://uniapp.dcloud.io/platform?id=%e6%9d%a1%e4%bb%b6%e7%bc%96%e8%af%91)因此你可以配置在不同平台下拥有的登录方式。 - 使用方式:在 `uni-starter.config.js`->`router`->`login`下完全列举你需要的登录方式。这里支持用[条件编译](https://uniapp.dcloud.io/platform?id=%e6%9d%a1%e4%bb%b6%e7%bc%96%e8%af%91)因此你可以配置在不同平台下拥有的登录方式。
......
## 1.0.42(2021-07-29)
新增绑定手机号码页面前端校验
## 1.0.41(2021-07-27) ## 1.0.41(2021-07-27)
1. 支持vue3.0 1. 支持vue3.0
2. 去掉App.vue全局样式,避免与非flex布局的页面样式冲突 2. 去掉App.vue全局样式,避免与非flex布局的页面样式冲突
......
...@@ -298,7 +298,8 @@ export default async function() { ...@@ -298,7 +298,8 @@ export default async function() {
visitor, visitor,
login login
} }
} = uniStarterConfig //需要登录的页面 } = uniStarterConfig //需要登录的页面
let list = ["navigateTo", "redirectTo", "reLaunch", "switchTab"]; let list = ["navigateTo", "redirectTo", "reLaunch", "switchTab"];
list.forEach(item => { //用遍历的方式分别为,uni.navigateTo,uni.redirectTo,uni.reLaunch,uni.switchTab这4个路由方法添加拦截器 list.forEach(item => { //用遍历的方式分别为,uni.navigateTo,uni.redirectTo,uni.reLaunch,uni.switchTab这4个路由方法添加拦截器
uni.addInterceptor(item, { uni.addInterceptor(item, {
...@@ -310,7 +311,7 @@ export default async function() { ...@@ -310,7 +311,7 @@ export default async function() {
//获取要跳转的页面路径(url去掉"?"和"?"后的参数) //获取要跳转的页面路径(url去掉"?"和"?"后的参数)
url = e.url.split('?')[0], url = e.url.split('?')[0],
//获取要前往的页面路径(即url去掉"?"和"?"后的参数) //获取要前往的页面路径(即url去掉"?"和"?"后的参数)
pages = getCurrentPages(), pages = getCurrentPages(),
fromUrl = pages[pages.length - 1].route; fromUrl = pages[pages.length - 1].route;
...@@ -341,7 +342,7 @@ export default async function() { ...@@ -341,7 +342,7 @@ export default async function() {
} }
return url != item return url != item
}) })
console.log({pass}) // console.log({pass})
} }
if (visitor&&!inLoginPage) { if (visitor&&!inLoginPage) {
pass = visitor.some((item) => { pass = visitor.some((item) => {
...@@ -350,7 +351,7 @@ export default async function() { ...@@ -350,7 +351,7 @@ export default async function() {
} }
return url == item return url == item
}) })
console.log({pass}) // console.log({pass})
} }
if (!pass && (token == '' || tokenExpired)) { if (!pass && (token == '' || tokenExpired)) {
...@@ -377,7 +378,8 @@ export default async function() { ...@@ -377,7 +378,8 @@ export default async function() {
} }
} }
}) })
}) })
// #ifdef APP-PLUS // #ifdef APP-PLUS
// 监听并提示设备网络状态变化 // 监听并提示设备网络状态变化
uni.onNetworkStatusChange(res => { uni.onNetworkStatusChange(res => {
......
import App from './App' import App from './App'
import store from './store' import store from './store'
// #ifndef VUE3
import Vue from 'vue' // #ifndef VUE3
Vue.config.productionTip = false import Vue from 'vue'
Vue.prototype.$store = store Vue.config.productionTip = false
App.mpType = 'app' Vue.prototype.$store = store
const app = new Vue({ App.mpType = 'app'
store, const app = new Vue({
...App store,
}) ...App
app.$mount() })
// #endif app.$mount()
// #endif
// #ifdef VUE3
import { createApp } from 'vue' // #ifdef VUE3
const app = createApp(App,{}) import {
app.use(store) createSSRApp
app.mount('#app') } from 'vue'
// #endif
\ No newline at end of file export function createApp() {
const app = createSSRApp(App)
app.use(store)
return {app}
}
// #endif
{ {
"id": "uni-starter", "id": "uni-starter",
"displayName": "uni-starter", "displayName": "uni-starter",
"version": "1.0.41", "version": "1.0.42",
"description": "云端一体应用快速开发基本项目模版", "description": "云端一体应用快速开发基本项目模版",
"keywords": [ "keywords": [
"login", "login",
......
...@@ -158,8 +158,8 @@ ...@@ -158,8 +158,8 @@
} }
}, { }, {
"path": "pages/ucenter/invite/invite", "path": "pages/ucenter/invite/invite",
"style": { "style": {
"navigationStyle":"custom", "navigationStyle": "custom",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
......
...@@ -2,21 +2,26 @@ ...@@ -2,21 +2,26 @@
<view class="warp"> <view class="warp">
<!-- #ifdef APP-PLUS --> <!-- #ifdef APP-PLUS -->
<status-bar /> <status-bar />
<!-- #endif --> <!-- #endif -->
<!-- banner -->
<unicloud-db ref="bannerdb" v-slot:default="{data, loading, error, options}" collection="opendb-banner" <!-- banner -->
field="_id,bannerfile,open_url,title" @load="load"> <unicloud-db ref="bannerdb" v-slot:default="{data, loading, error, options}" collection="opendb-banner"
<uni-swiper-dot class="uni-swiper-dot-box" @clickItem="clickItem" :info="data || bannerFormate(data, loading)" field="_id,bannerfile,open_url,title" @load="onqueryload">
:current="current" field="content"> <!-- 当无banner数据时显示占位图 -->
<swiper class="swiper-box" @change="changeSwiper" :current="swiperDotIndex"> <image v-if="!(loading||data.length)" class="banner-image" src="/static/grid/empty.png" mode="aspectFill" :draggable="false" />
<swiper-item v-for="(item, index) in (data || bannerFormate(data, loading))" :key="item._id"> <uni-swiper-dot v-else class="uni-swiper-dot-box" @clickItem="clickItem" :info="data"
<view :draggable="false" class="swiper-item" @click="clickBannerItem(item)"> :current="current" field="content">
<image class="swiper-image" :src="item.bannerfile.url" mode="aspectFill" :draggable="false" /> <swiper class="swiper-box" @change="changeSwiper" :current="swiperDotIndex">
</view> <swiper-item v-for="(item, index) in data" :key="item._id">
</swiper-item> <view class="swiper-item" @click="clickBannerItem(item)">
</swiper> <image class="banner-image" :src="item.bannerfile.url" mode="aspectFill" :draggable="false" />
</uni-swiper-dot> </view>
</unicloud-db> </swiper-item>
</swiper>
</uni-swiper-dot>
</unicloud-db>
<!-- 宫格 --> <!-- 宫格 -->
<uni-section title="宫格组件" style="margin: 0;" type="line"></uni-section> <uni-section title="宫格组件" style="margin: 0;" type="line"></uni-section>
<view class="example-body"> <view class="example-body">
...@@ -67,8 +72,7 @@ ...@@ -67,8 +72,7 @@
/** /**
* banner加载后触发的回调 * banner加载后触发的回调
*/ */
load(data) { onqueryload(data) {
}, },
changeSwiper(e) { changeSwiper(e) {
this.current = e.detail.current this.current = e.detail.current
...@@ -90,21 +94,6 @@ ...@@ -90,21 +94,6 @@
}); });
} }
// 其余业务处理 // 其余业务处理
},
/**
* banner数据过滤
*/
bannerFormate(bannerList, loading) {
if (loading) return [];
if (bannerList.length > 0) return bannerList;
// 无数据添加默认值
let list = [{
"_id": -1,
"bannerfile": "/static/grid/empty.png",
"open_url": "https://www.dcloud.io/",
"title": "内容 A",
}]
return list;
} }
} }
} }
...@@ -176,7 +165,7 @@ ...@@ -176,7 +165,7 @@
padding: 15px 0; padding: 15px 0;
} }
.swiper-image { .banner-image {
width: 750rpx; width: 750rpx;
height: 400rpx; height: 400rpx;
} }
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
<uni-search-bar class="uni-search-box" v-model="keyword" ref="searchBar" radius="100" <uni-search-bar class="uni-search-box" v-model="keyword" ref="searchBar" radius="100"
cancelButton="none" /> cancelButton="none" />
</view> </view>
<unicloud-db ref='udb' v-slot:default="{data,pagination,hasMore, loading, error, options}" @error="onqueryerror" <unicloud-db ref='udb' v-slot:default="{data,pagination,hasMore, loading, error, options}" @error="onqueryerror"
:where="where" collection="opendb-news-articles,uni-id-users" :page-size="10" :where="where" collection="opendb-news-articles,uni-id-users" :page-size="10"
field="avatar,title,last_modify_date,user_id.username"> field="avatar,title,last_modify_date,user_id.username">
......
<template> <template>
<view class="center"> <view class="center">
<uni-sign-in ref="signIn"></uni-sign-in> <uni-sign-in ref="signIn"></uni-sign-in>
<view class="userInfo" @click.capture="toUserInfo"> <view class="userInfo" @click.capture="toUserInfo">
<uni-file-picker v-if="userInfo.avatar_file&&userInfo.avatar_file.url" v-model="userInfo.avatar_file" <uni-file-picker v-if="userInfo.avatar_file&&userInfo.avatar_file.url" v-model="userInfo.avatar_file"
fileMediatype="image" :del-icon="false" return-type="object" :image-styles="listStyles" disablePreview fileMediatype="image" :del-icon="false" return-type="object" :image-styles="listStyles" disablePreview
disabled /> disabled />
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<uni-send-sms-code ref="shortCode" code-type="bind" :phone="formData.phone"></uni-send-sms-code> <uni-send-sms-code ref="shortCode" code-type="bind" :phone="formData.phone"></uni-send-sms-code>
</template> </template>
</uni-easyinput> </uni-easyinput>
<button class="send-btn-box" type="primary" @click="submit">提交</button> <button class="send-btn-box" :disabled="!canSubmit" :type="canSubmit?'primary':'default'" @click="submit">提交</button>
</view> </view>
</template> </template>
<script> <script>
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
return `验证码已通过短信发送至${this.currenPhoneArea} ${this.formData.phone}。密码为6 - 20位` return `验证码已通过短信发送至${this.currenPhoneArea} ${this.formData.phone}。密码为6 - 20位`
}, },
canSubmit() { canSubmit() {
return this.isPhone && this.isPwd && this.isCode; return true//this.isPhone() && this.isCode();
} }
}, },
onLoad(event) { onLoad(event) {
...@@ -69,6 +69,16 @@ ...@@ -69,6 +69,16 @@
} }
} }
}) })
},
isPhone() {
let reg_phone = /^1\d{10}$/;
let isPhone = reg_phone.test(this.formData.phone);
return isPhone;
},
isCode() {
let reg_code = /^\d{6}$/;
let isCode = reg_code.test(this.formData.code);
return isCode;
} }
} }
} }
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
</uni-list-item> </uni-list-item>
<uni-list-item class="item" @click="setNickname('')" title="昵称" :rightText="userInfo.nickname||'未设置'" link> <uni-list-item class="item" @click="setNickname('')" title="昵称" :rightText="userInfo.nickname||'未设置'" link>
</uni-list-item> </uni-list-item>
<uni-list-item class="item" @click="bindMobile" title="手机号" :rightText="userInfo.mobile||'未绑定'" link> <uni-list-item class="item" @click="bindMobileBySmsCode" title="手机号" :rightText="userInfo.mobile||'未绑定'" link>
</uni-list-item> </uni-list-item>
</uni-list> </uni-list>
<uni-popup ref="dialog" type="dialog"> <uni-popup ref="dialog" type="dialog">
<uni-popup-dialog mode="input" :value="userInfo.nickname" @confirm="setNickname" title="设置昵称" <uni-popup-dialog mode="input" :value="userInfo.nickname" @confirm="setNickname" title="设置昵称"
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
} }
} }
}, },
methods: { methods: {
...mapMutations({ ...mapMutations({
setUserInfo: 'user/login' setUserInfo: 'user/login'
}), }),
......
...@@ -10,7 +10,7 @@ class Gps { ...@@ -10,7 +10,7 @@ class Gps {
}) { }) {
return new Promise(async (callback) => { return new Promise(async (callback) => {
if (this.lock) { if (this.lock) {
console.log('已锁,已有另一个请求正在执行。无需重复请求'); // console.log('已锁,已有另一个请求正在执行。无需重复请求');
callback(false); callback(false);
return false return false
} }
......
## 1.1.4(2021-07-29)
- 修复 去掉 nvue 不支持css 的 align-self 属性,nvue 下不暂支持 absolute 属性
## 1.1.3(2021-06-24) ## 1.1.3(2021-06-24)
- 优化 示例项目 - 优化 示例项目
## 1.1.1(2021-05-12) ## 1.1.1(2021-05-12)
- 新增 组件示例地址 - 新增 组件示例地址
## 1.1.0(2021-05-12) ## 1.1.0(2021-05-12)
- 新增 uni-badge 的 absolute 属性,支持定位 - 新增 uni-badge 的 absolute 属性,支持定位
- 新增 uni-badge 的 offset 属性,支持定位偏移 - 新增 uni-badge 的 offset 属性,支持定位偏移
- 新增 uni-badge 的 is-dot 属性,支持仅显示有一个小点 - 新增 uni-badge 的 is-dot 属性,支持仅显示有一个小点
- 新增 uni-badge 的 max-num 属性,支持自定义封顶的数字值,超过 99 显示99+ - 新增 uni-badge 的 max-num 属性,支持自定义封顶的数字值,超过 99 显示99+
- 优化 uni-badge 属性 custom-style, 支持以对象形式自定义样式 - 优化 uni-badge 属性 custom-style, 支持以对象形式自定义样式
## 1.0.7(2021-05-07) ## 1.0.7(2021-05-07)
- 修复 uni-badge 在 App 端,数字小于10时不是圆形的bug - 修复 uni-badge 在 App 端,数字小于10时不是圆形的bug
- 修复 uni-badge 在父元素不是 flex 布局时,宽度缩小的bug - 修复 uni-badge 在父元素不是 flex 布局时,宽度缩小的bug
- 新增 uni-badge 属性 custom-style, 支持自定义样式 - 新增 uni-badge 属性 custom-style, 支持自定义样式
## 1.0.6(2021-02-04) ## 1.0.6(2021-02-04)
- 调整为uni_modules目录规范 - 调整为uni_modules目录规范
...@@ -155,9 +155,6 @@ ...@@ -155,9 +155,6 @@
$bage-height: 20px; $bage-height: 20px;
.uni-badge--x { .uni-badge--x {
/* #ifdef APP-NVUE */
align-self: flex-start;
/* #endif */
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: inline-block; display: inline-block;
/* #endif */ /* #endif */
......
{ {
"id": "uni-badge", "id": "uni-badge",
"displayName": "uni-badge 数字角标", "displayName": "uni-badge 数字角标",
"version": "1.1.3", "version": "1.1.4",
"description": "数字角标(徽章)组件,在元素周围展示消息提醒,一般用于列表、九宫格、按钮等地方。", "description": "数字角标(徽章)组件,在元素周围展示消息提醒,一般用于列表、九宫格、按钮等地方。",
"keywords": [ "keywords": [
"", "",
"badge", "badge",
"uni-ui", "uni-ui",
"uniui", "uniui",
"数字角标", "数字角标",
"徽章" "徽章"
], ],
"repository": "https://github.com/dcloudio/uni-ui", "repository": "https://github.com/dcloudio/uni-ui",
"engines": { "engines": {
"HBuilderX": "" "HBuilderX": ""
}, },
"directories": { "directories": {
"example": "../../temps/example" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"category": [ "category": [
"前端组件", "前端组件",
"通用组件" "通用组件"
], ],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
}, },
"sourcecode": { "sourcecode": {
"price": "0.00" "price": "0.00"
} }
}, },
"contact": { "contact": {
"qq": "" "qq": ""
}, },
"declaration": { "declaration": {
"ads": "无", "ads": "无",
"data": "无", "data": "无",
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui"
}, },
"uni_modules": { "uni_modules": {
"dependencies": [], "dependencies": [],
"encrypt": [], "encrypt": [],
"platforms": { "platforms": {
"cloud": { "cloud": {
"tcb": "y", "tcb": "y",
"aliyun": "y" "aliyun": "y"
}, },
"client": { "client": {
"App": { "App": {
"app-vue": "y", "app-vue": "y",
"app-nvue": "y" "app-nvue": "y"
}, },
"H5-mobile": { "H5-mobile": {
"Safari": "y", "Safari": "y",
"Android Browser": "y", "Android Browser": "y",
"微信浏览器(Android)": "y", "微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y" "QQ浏览器(Android)": "y"
}, },
"H5-pc": { "H5-pc": {
"Chrome": "y", "Chrome": "y",
"IE": "y", "IE": "y",
"Edge": "y", "Edge": "y",
"Firefox": "y", "Firefox": "y",
"Safari": "y" "Safari": "y"
}, },
"小程序": { "小程序": {
"微信": "y", "微信": "y",
"阿里": "y", "阿里": "y",
"百度": "y", "百度": "y",
"字节跳动": "y", "字节跳动": "y",
"QQ": "y" "QQ": "y"
}, },
"快应用": { "快应用": {
"华为": "y", "华为": "y",
"联盟": "y" "联盟": "y"
} }
} }
} }
} }
} }
\ No newline at end of file
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
|max-num |String/Numbuer|99 |展示封顶的数字值,超过 99 显示99+ | |max-num |String/Numbuer|99 |展示封顶的数字值,超过 99 显示99+ |
|custom-style |Object | {} |自定义 Badge 样式, 样式对象语法 | |custom-style |Object | {} |自定义 Badge 样式, 样式对象语法 |
|inverted |Boolean|false |是否无需背景颜色,为 true 时,背景颜色将变为文字的字体颜色 | |inverted |Boolean|false |是否无需背景颜色,为 true 时,背景颜色将变为文字的字体颜色 |
|absolute |String| rightTop|开启绝对定位, 角标将定位到其包裹的标签的四个角上,可选值: rightTop(右上角)、rightBottom(右下角)、leftBottom(左下角) 、leftTop(左上角) | |absolute (不支持 nvue) |String| rightTop|开启绝对定位, 角标将定位到其包裹的标签的四个角上,可选值: rightTop(右上角)、rightBottom(右下角)、leftBottom(左下角) 、leftTop(左上角) |
|offset |Array[number]| [0, 0]|距定位角中心点的偏移量,[-10, -10] 表示向 absolute 指定的方向偏移 10px,[10, 10] 表示向 absolute 指定的反方向偏移 10px,只有存在 absolute 属性时有效,与absolute 的值一一对应(例如:值为rightTop, 对应 offset 为 [right, Top])| |offset |Array[number]| [0, 0]|距定位角中心点的偏移量,[-10, -10] 表示向 absolute 指定的方向偏移 10px,[10, 10] 表示向 absolute 指定的反方向偏移 10px,只有存在 absolute 属性时有效,与absolute 的值一一对应(例如:值为rightTop, 对应 offset 为 [right, Top])|
### Badge Events ### Badge Events
......
...@@ -151,11 +151,6 @@ exports.main = async (event, context) => { ...@@ -151,11 +151,6 @@ exports.main = async (event, context) => {
} }
break; break;
case 'bindMobileBySms': case 'bindMobileBySms':
// console.log({
// uid: params.uid,
// mobile: params.mobile,
// code: params.code
// });
res = await uniID.bindMobile({ res = await uniID.bindMobile({
uid: params.uid, uid: params.uid,
mobile: params.mobile, mobile: params.mobile,
......
...@@ -162,7 +162,8 @@ export default { ...@@ -162,7 +162,8 @@ export default {
default: true default: true
} }
}, },
// inject: ['list'], // inject: ['list'],
emits:['click'],
data() { data() {
return { return {
isFirstChild: false isFirstChild: false
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册