提交 771f294b 编写于 作者: inkwalk's avatar inkwalk

Merge branch 'dev' for snyc for hx3.0

<script>
import { mapState } from 'vuex'
import { mapMutations } from 'vuex'
export default {
onLaunch: function() {
console.log('App Launch');
......@@ -28,7 +28,23 @@
}
}
})
}
}
// 一键登录预登陆,可以显著提高登录速度
uni.preLogin({
provider: 'univerify',
success: (res) => {
// 成功
this.setUniverifyErrorMsg();
console.log("preLogin success: ", res);
},
fail: (res) => {
this.setUniverifyLogin(false);
this.setUniverifyErrorMsg(res.errMsg);
// 失败
console.log("preLogin fail res: ", res);
}
})
// #endif
},
onShow: function() {
......@@ -39,6 +55,9 @@
},
globalData: {
test: ''
},
methods:{
...mapMutations(['setUniverifyErrorMsg','setUniverifyLogin'])
}
}
</script>
......
......@@ -81,7 +81,7 @@
background-color: #f1f1f1;
background-color: transparent;
text-align: center;
font-family: "Helvetica Neue", Helvetica, sans-serif;
font-family: 'Helvetica Neue', Helvetica, sans-serif;
font-size: 12px;
padding: 0px 6px;
}
......
......@@ -136,7 +136,7 @@
/* #ifndef APP-NVUE */
.uni-border:after {
content: "";
content: '';
position: absolute;
bottom: 0;
left: 0;
......@@ -165,7 +165,7 @@
/* #ifndef APP-NVUE */
.uni-border-bottom:after {
content: "";
content: '';
position: absolute;
bottom: 0;
left: 0;
......@@ -193,7 +193,7 @@
/* #ifndef APP-NVUE */
.uni-border-top:after {
content: "";
content: '';
position: absolute;
bottom: 0;
left: 0;
......
......@@ -180,7 +180,7 @@
}
.uni-combox__selector::before {
content: "";
content: '';
position: absolute;
width: 0;
height: 0;
......
......@@ -20,58 +20,6 @@ const attrs = [
]
export default {
props: {
options: {
type: [Object, Array],
default () {
return {}
}
},
collection: {
type: String,
default: ''
},
action: {
type: String,
default: ''
},
field: {
type: String,
default: ''
},
pageData: {
type: String,
default: 'add'
},
pageCurrent: {
type: Number,
default: 1
},
pageSize: {
type: Number,
default: 20
},
getcount: {
type: [Boolean, String],
default: false
},
orderby: {
type: String,
default: ''
},
where: {
type: [String, Object],
default: ''
},
getone: {
type: [Boolean, String],
default: false
},
manual: {
type: Boolean,
default: false
}
},
data() {
return {
loading: false,
......
......@@ -8,7 +8,7 @@
<template v-else>
<checkbox-group v-if="multiple" class="checklist-group" :class="{'is-list':mode==='list','is-wrap':wrap}" @change="chagne">
<label class="checklist-box" :class="item.labelClass" :style="[item.styleBackgroud]" v-for="(item,index) in dataList" :key="index">
<checkbox hidden :disabled="!!item.disable" :value="item.value+''" :checked="item.selected" />
<checkbox class="hidden" hidden :disabled="!!item.disabled" :value="item.value+''" :checked="item.selected" />
<view v-if="(mode !=='tag' && mode !== 'list') || ( mode === 'list' && icon === 'left')" class="checkbox__inner" :class="item.checkboxBgClass" :style="[item.styleIcon]">
<view class="checkbox__inner-icon" :class="item.checkboxClass"></view>
</view>
......@@ -20,7 +20,7 @@
</checkbox-group>
<radio-group v-else class="checklist-group" :class="{'is-list':mode==='list','is-wrap':wrap}" @change="chagne">
<label class="checklist-box" :class="item.labelClass" :style="[item.styleBackgroud]" v-for="(item,index) in dataList" :key="index">
<radio hidden :disabled="item.disable" :value="item.value+''" :checked="item.selected" />
<radio hidden :disabled="item.disabled" :value="item.value+''" :checked="item.selected" />
<view v-if="(mode !=='tag' && mode !== 'list') || ( mode === 'list' && icon === 'left')" class="radio__inner" :class="item.checkboxBgClass" :style="[item.styleBackgroud]">
<view class="radio__inner-icon" :class="item.checkboxClass" :style="[item.styleIcon]"></view>
</view>
......@@ -106,11 +106,63 @@
selectedTextColor: {
type: String,
default: ''
},
// clientDB 相关
options: {
type: [Object, Array],
default () {
return {}
}
},
collection: {
type: String,
default: ''
},
action: {
type: String,
default: ''
},
field: {
type: String,
default: ''
},
pageData: {
type: String,
default: 'add'
},
pageCurrent: {
type: Number,
default: 1
},
pageSize: {
type: Number,
default: 20
},
getcount: {
type: [Boolean, String],
default: false
},
orderby: {
type: String,
default: ''
},
where: {
type: [String, Object],
default: ''
},
getone: {
type: [Boolean, String],
default: false
},
manual: {
type: Boolean,
default: false
}
},
watch: {
localdata: {
handler(newVal) {
this.range = newVal
this.dataList = this.getDataList(this.getSelectedValue(newVal))
},
deep: true
......@@ -119,7 +171,6 @@
listData(newVal) {
this.range = newVal
this.dataList = this.getDataList(this.getSelectedValue(newVal))
// console.log('----listData', this.dataList);
},
value(newVal) {
this.dataList = this.getDataList(newVal)
......@@ -223,7 +274,7 @@
let classes = []
switch (this.mode) {
case 'default':
item.disable && classes.push('disabled-cursor')
item.disabled && classes.push('disabled-cursor')
break
case 'button':
classes.push(...['is-button', ...this.getClasses(item, 'button')])
......@@ -234,7 +285,7 @@
} else {
classes.push('is-list-box')
}
item.disable && classes.push('is-list-disabled')
item.disabled && classes.push('is-list-disabled')
index !== 0 && classes.push('is-list-border')
break
case 'tag':
......@@ -289,6 +340,7 @@
}
}
dataList.forEach((item, index) => {
item.disabled = item.disable || item.disabled || false
if (this.multiple) {
if (value.length > 0) {
let have = value.find(val => val === item.value)
......@@ -317,14 +369,14 @@
if (selectList.length <= min) {
let have = selectList.find(val => val.value === item.value)
if (have !== undefined) {
item.disable = true
item.disabled = true
}
}
if (selectList.length >= max && max !== '') {
let have = selectList.find(val => val.value === item.value)
if (have === undefined) {
item.disable = true
item.disabled = true
}
}
}
......@@ -361,11 +413,11 @@
*/
getClasses(item, name, type = '') {
let classes = []
item.disable && classes.push('is-' + name + '-disabled' + type)
item.disabled && classes.push('is-' + name + '-disabled' + type)
item.selected && classes.push('is-' + name + '-checked' + type)
if (this.mode !== 'button' || name === 'button') {
item.selected && item.disable && classes.push('is-' + name + '-disabled-checked' + type)
item.selected && item.disabled && classes.push('is-' + name + '-disabled-checked' + type)
}
return classes
......@@ -443,6 +495,8 @@
@charset "UTF-8";
.uni-data-checklist {
position: relative;
z-index: 0;
/* min-height: 36px; */
}
......@@ -564,7 +618,7 @@
top: 1px;
width: 3px;
opacity: 0;
transition: transform 0.2s;
transition: transform .2s;
transform-origin: center;
transform: rotate(40deg) scaleY(0.4);
}
......@@ -585,7 +639,7 @@
border-radius: 16px;
background-color: #fff;
z-index: 1;
transition: border-color 0.3s;
transition: border-color .3s;
}
.radio__inner-icon {
......@@ -593,7 +647,7 @@
height: 8px;
border-radius: 10px;
opacity: 0;
transition: transform 0.3s;
transition: transform .3s;
}
.checkobx__list {
......@@ -758,4 +812,10 @@
.is-wrap {
flex-direction: column;
}
.hidden {
/* #ifdef MP-ALIPAY */
display: none;
/* #endif */
}
</style>
\ No newline at end of file
......@@ -304,14 +304,14 @@
}
.uni-datetime-picker-colon::after {
content: ":";
content: ':';
position: absolute;
top: 53px;
right: 0;
}
.uni-datetime-picker-hyphen::after {
content: "-";
content: '-';
position: absolute;
top: 53px;
right: -2px;
......@@ -342,7 +342,7 @@
border-style: solid;
transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
transform-origin: center;
transition: transform 0.3s;
transition: transform .3s;
position: absolute;
top: 50%;
right: 5px;
......
<template>
<view class="uni-easyinput" :class="{'uni-easyinput-error':msg}">
<view class="uni-easyinput__content" :class="{'is-input-border':inputBorder ,'is-input-error-border':inputBorder && msg,'is-textarea':type==='textarea','is-disabled':disabled}">
<uni-icons v-if="prefixIcon" class="content-clear-icon" :type="prefixIcon" color="#c0c4cc"></uni-icons>
<view class="uni-easyinput" :class="{'uni-easyinput-error':msg}" :style="{color:inputBorder && msg?'#dd524d':styles.color}">
<view class="uni-easyinput__content" :class="{'is-input-border':inputBorder ,'is-input-error-border':inputBorder && msg,'is-textarea':type==='textarea','is-disabled':disabled}" :style="{'border-color':inputBorder && msg?'#dd524d':styles.borderColor,'background-color':disabled?styles.disableColor:'#fff'}">
<uni-icons v-if="prefixIcon" class="content-clear-icon" :type="prefixIcon" color="#c0c4cc" @click="onClickIcon('prefix')"></uni-icons>
<textarea v-if="type === 'textarea'" class="uni-easyinput__content-textarea" :class="{'input-padding':inputBorder}" :name="name" :value="val" :placeholder="placeholder" :placeholderStyle="placeholderStyle" :disabled="disabled" :maxlength="inputMaxlength" :focus="focused" :autoHeight="autoHeight" @input="onInput" @blur="onBlur" @focus="onFocus" @confirm="onConfirm"></textarea>
<input v-else :type="type === 'password'?'text':type" class="uni-easyinput__content-input" :style="{
'padding-right':type === 'password' ||clearable || prefixIcon?'':'10px',
'padding-left':prefixIcon?'':'10px',
'color':msg?'#dd524d':''
'padding-left':prefixIcon?'':'10px'
}" :name="name" :value="val" :password="!showPassword && type === 'password'" :placeholder="placeholder" :placeholderStyle="placeholderStyle" :disabled="disabled" :maxlength="inputMaxlength" :focus="focused" @focus="onFocus" @blur="onBlur" @input="onInput" @confirm="onConfirm" />
<template v-if="type === 'password'">
<uni-icons v-if="val != '' " class="content-clear-icon" :class="{'is-textarea-icon':type==='textarea'}" :type="showPassword?'eye-slash-filled':'eye-filled'" :size="18" color="#c0c4cc" @click="onEyes"></uni-icons>
</template>
<template v-else-if="suffixIcon">
<uni-icons v-if="suffixIcon" class="content-clear-icon" :type="suffixIcon" color="#c0c4cc"></uni-icons>
<uni-icons v-if="suffixIcon" class="content-clear-icon" :type="suffixIcon" color="#c0c4cc" @click="onClickIcon('suffix')"></uni-icons>
</template>
<template v-else>
<uni-icons class="content-clear-icon" :class="{'is-textarea-icon':type==='textarea'}" type="clear" :size="clearSize" v-if="clearable && focused && val " color="#c0c4cc" @click="onClear"></uni-icons>
......@@ -26,31 +25,33 @@
* Field 输入框
* @description 此组件可以实现表单的输入与校验,包括 "text" 和 "textarea" 类型。
* @tutorial https://ext.dcloud.net.cn/plugin?id=21001
* @property {String| Number} value 输入内容
* @property {String } type 输入框的类型(默认text) password/text/textarea/..
* @value text 文本输入键盘
* @value textarea 多行文本输入键盘
* @value password 密码输入键盘
* @value number 数字输入键盘,注意iOS上app-vue弹出的数字键盘并非9宫格方式
* @value idcard 身份证输入键盘,信、支付宝、百度、QQ小程序
* @value digit 带小数点的数字键盘 ,App的nvue页面、微信、支付宝、百度、头条、QQ小程序支持
* @property {Boolean} clearable 是否显示右侧清空内容的图标控件(输入框有内容,且获得焦点时才显示),点击可清空输入框内容(默认true)
* @property {Boolean} autoHeight 是否自动增高输入区域,type为textarea时有效(默认true)
* @property {String } placeholder 输入框的提示文字
* @property {String| Number} value 输入内容
* @property {String } type 输入框的类型(默认text) password/text/textarea/..
* @value text 文本输入键盘
* @value textarea 多行文本输入键盘
* @value password 密码输入键盘
* @value number 数字输入键盘,注意iOS上app-vue弹出的数字键盘并非9宫格方式
* @value idcard 身份证输入键盘,信、支付宝、百度、QQ小程序
* @value digit 带小数点的数字键盘 ,App的nvue页面、微信、支付宝、百度、头条、QQ小程序支持
* @property {Boolean} clearable 是否显示右侧清空内容的图标控件(输入框有内容,且获得焦点时才显示),点击可清空输入框内容(默认true)
* @property {Boolean} autoHeight 是否自动增高输入区域,type为textarea时有效(默认true)
* @property {String } placeholder 输入框的提示文字
* @property {String } placeholderStyle placeholder的样式(内联样式,字符串),如"color: #ddd"
* @property {Boolean} focus 是否自动获得焦点(默认false)
* @property {Boolean} disabled 是否不可输入(默认false)
* @property {Number } maxlength 最大输入长度,设置为 -1 的时候不限制最大长度(默认140)
* @property {String } confirmType 设置键盘右下角按钮的文字,仅在type="text"时生效(默认done)
* @property {Number } clearSize 清除图标的大小,单位px(默认15)
* @property {String} prefixIcon 输入框头部图标
* @property {String} suffixIcon 输入框尾部图标
* @property {Boolean} trim 是否自动去除两端的空格
* @property {Boolean} inputBorder 是否显示input输入框的边框(默认false)
* @event {Function} input 输入框内容发生变化时触发
* @event {Function} focus 输入框获得焦点时触发
* @event {Function} blur 输入框失去焦点时触发
* @event {Function} confirm 点击完成按钮时触发
* @property {Boolean} focus 是否自动获得焦点(默认false)
* @property {Boolean} disabled 是否不可输入(默认false)
* @property {Number } maxlength 最大输入长度,设置为 -1 的时候不限制最大长度(默认140)
* @property {String } confirmType 设置键盘右下角按钮的文字,仅在type="text"时生效(默认done)
* @property {Number } clearSize 清除图标的大小,单位px(默认15)
* @property {String} prefixIcon 输入框头部图标
* @property {String} suffixIcon 输入框尾部图标
* @property {Boolean} trim 是否自动去除两端的空格
* @property {Boolean} inputBorder 是否显示input输入框的边框(默认false)
* @property {Object} styles 自定义颜色
* @event {Function} input 输入框内容发生变化时触发
* @event {Function} focus 输入框获得焦点时触发
* @event {Function} blur 输入框失去焦点时触发
* @event {Function} confirm 点击完成按钮时触发
* @event {Function} iconClick 点击图标时触发
* @example <uni-easyinput v-model="mobile"></uni-easyinput>
*/
......@@ -116,6 +117,17 @@
trim: {
type: Boolean,
default: true
},
// 自定义样式
styles: {
type: Object,
default () {
return {
color: '#333',
disableColor: '#eee',
borderColor: '#e5e5e5'
}
}
}
},
data() {
......@@ -141,6 +153,7 @@
},
watch: {
value(newVal) {
if (this.errMsg) this.errMsg = ''
this.val = newVal
if (this.formItem) {
this.formItem.setValue(newVal)
......@@ -176,6 +189,9 @@
*/
init() {
},
onClickIcon(type) {
this.$emit('iconClick', type)
},
/**
* 获取父元素实例
......
此差异已折叠。
......@@ -179,7 +179,6 @@
this.labelPos = this.labelPosition ? this.labelPosition : labelPosition
this.labelWid = this.label ? (this.labelWidth ? this.labelWidth : labelWidth) : 0
this.labelAli = this.labelAlign ? this.labelAlign : labelAlign
console.log(this.labelWid);
// 判断第一个 item
if (!this.form.isFirstBorder) {
this.form.isFirstBorder = true
......
......@@ -8,7 +8,7 @@
<scroll-view :scroll-into-view="scrollViewId" class="uni-indexed-list__scroll" scroll-y>
<view v-for="(list, idx) in lists" :key="idx" :id="'uni-indexed-list-' + idx">
<!-- #endif -->
<uni-indexed-list-item :list="list" :loaded="loaded" :idx="idx" :showSelect="showSelect" @itemClick="onClick"></uni-indexed-list-item>
<indexed-list-item :list="list" :loaded="loaded" :idx="idx" :showSelect="showSelect" @itemClick="onClick"></indexed-list-item>
<!-- #ifndef APP-NVUE -->
</view>
</scroll-view>
......@@ -29,7 +29,7 @@
</template>
<script>
import uniIcons from '../uni-icons/uni-icons.vue'
import uniIndexedListItem from './uni-indexed-list-item.vue'
import indexedListItem from './uni-indexed-list-item.vue'
// #ifdef APP-NVUE
const dom = weex.requireModule('dom');
// #endif
......@@ -85,7 +85,7 @@
name: 'UniIndexedList',
components: {
uniIcons,
uniIndexedListItem
indexedListItem
},
props: {
options: {
......
......@@ -92,7 +92,7 @@
right: 0;
left: 0;
height: 1px;
content: "";
content: '';
-webkit-transform: scaleY(0.5);
transform: scaleY(0.5);
background-color: #e5e5e5;
......
......@@ -244,7 +244,7 @@
right: 0;
left: 0;
height: 1px;
content: "";
content: '';
-webkit-transform: scaleY(0.5);
transform: scaleY(0.5);
background-color: #e5e5e5;
......
......@@ -294,7 +294,7 @@
right: 0;
left: 0;
height: 1px;
content: "";
content: '';
-webkit-transform: scaleY(0.5);
transform: scaleY(0.5);
background-color: #e5e5e5;
......
......@@ -247,8 +247,8 @@
}
/* .transition {
transition: all 0.3s;
} */
transition: all 0.3s;
} */
.movable-view-box {
flex-shrink: 0;
height: 100%;
......
......@@ -117,7 +117,7 @@
<style scoped>
/* .uni-title {
} */
} */
.uni-title__box {
/* #ifndef APP-NVUE */
display: flex;
......
......@@ -77,7 +77,7 @@
<style scoped>
.uni-table-tr {
display: table-row;
transition: all 0.3s;
transition: all .3s;
box-sizing: border-box;
}
......
......@@ -5,19 +5,19 @@
<view style="background:#FFF; padding:40rpx;">
<block v-if="hasUserInfo === false">
<view class="uni-hello-text uni-center">
<text>请点击下方按钮获取用户头像及昵称</text>
<text>请点击下方按钮获取用户头像及昵称或手机号</text>
</view>
</block>
<block v-if="hasUserInfo === true">
<view class="uni-h4 uni-center uni-common-mt">{{userInfo.nickName || userInfo.email}}</view>
<view style="padding:30rpx 0; text-align:center;">
<view class="uni-h4 uni-center uni-common-mt">{{userInfo.nickName || userInfo.email || userInfo.phoneNumber}}</view>
<view v-if="userInfo.avatarUrl" style="padding:30rpx 0; text-align:center;">
<image class="userinfo-avatar" :src="userInfo.avatarUrl"></image>
</view>
</block>
</view>
<view class="uni-btn-v">
<!-- #ifdef APP-PLUS || MP-ALIPAY || MP-TOUTIAO -->
<button type="primary" @click="getUserInfo">获取用户信息</button>
<button type="primary" :loading="btnLoading" @click="getUserInfo">获取用户信息</button>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN || MP-BAIDU || MP-QQ -->
<button type="primary" open-type="getUserInfo" @getuserinfo="mpGetUserInfo">获取用户信息</button>
......@@ -30,7 +30,8 @@
<script>
import {
mapState,
mapMutations
mapMutations,
mapActions
} from 'vuex'
export default {
......@@ -38,21 +39,39 @@
return {
title: 'getUserInfo',
hasUserInfo: false,
userInfo: {}
userInfo: {},
btnLoading: false
}
},
computed: {
...mapState({
loginProvider: state => state.loginProvider
})
...mapState([
'loginProvider',
'isUniverifyLogin'
])
},
methods: {
...mapActions(['getPhoneNumber']),
// 获取用户信息 API 在小程序可直接使用,在 5+App 里面需要先登录才能调用
getUserInfo() {
this.btnLoading = true;
if (this.isUniverifyLogin) {
// 一键登录
this.getPhoneNumber(uni.getStorageSync('univerifyInfo')).then(phoneNumber => {
this.hasUserInfo = true;
this.userInfo = {
phoneNumber
};
}).catch(err => {
console.error('getUserInfo fail:', err);
this.hasUserInfo = false;
}).finally(() => {
this.btnLoading = false;
})
return;
}
uni.getUserInfo({
provider: this.loginProvider,
success: (result) => {
console.log('getUserInfo success', result);
this.hasUserInfo = true;
this.userInfo = result.userInfo;
},
......@@ -62,7 +81,7 @@
if (~content.indexOf('uni.login')) {
content = '请在登录页面完成登录操作';
}
// #ifndef APP-PLUS
// #ifndef APP-PLUS
uni.getSetting({
success: (res) => {
let authStatus = res.authSetting['scope.userInfo'];
......@@ -85,14 +104,17 @@
}
}
})
// #endif
// #ifdef APP-PLUS
uni.showModal({
title: '获取用户信息失败',
content: '错误原因' + content,
showCancel: false
});
// #endif
// #endif
// #ifdef APP-PLUS
uni.showModal({
title: '获取用户信息失败',
content: '错误原因' + content,
showCancel: false
});
// #endif
},
complete: () => {
this.btnLoading = false;
}
});
},
......
......@@ -28,8 +28,8 @@
</button>
<!-- #endif -->
<!-- #ifndef MP-TOUTIAO -->
<button type="primary" class="page-body-button" v-for="(value,key) in providerList" :disabled="value.id === 'univerify' ? univerifyBtnDisabled : false"
@click="tologin(value)" :key="key">{{value.name}}</button>
<button type="primary" class="page-body-button" v-for="(value,key) in providerList" @click="tologin(value)"
:loading="value.id === 'univerify' ? univerifyBtnLoading : false" :key="key">{{value.name}}</button>
<!-- #endif -->
</view>
</view>
......@@ -38,7 +38,8 @@
<script>
import {
mapState,
mapMutations
mapMutations,
mapActions
} from 'vuex'
const univerifyInfoKey = 'univerifyInfo';
......@@ -48,11 +49,11 @@
title: 'login',
providerList: [],
phoneNumber: '',
univerifyBtnDisabled: true
univerifyBtnLoading: false
}
},
computed: {
...mapState(['hasLogin', 'isUniverifyLogin'])
...mapState(['hasLogin', 'isUniverifyLogin', 'univerifyErrorMsg'])
},
onLoad() {
uni.getProvider({
......@@ -86,22 +87,6 @@
providerName = '苹果登录'
break;
case 'univerify':
uni.preLogin({
provider: value,
success: (res) => {
// 成功
console.log("preLogin success: ", res);
this.univerifyBtnDisabled = false;
},
fail: (res) => {
// 失败
console.log("preLogin fail: ", res);
// 失败
console.log("preLogin fail: ", res.errCode)
console.log("preLogin fail: ", res.errMsg)
this.setUniverifyLogin(false);
}
})
providerName = '一键登录'
break;
}
......@@ -117,25 +102,26 @@
}
});
uni.onAuthViewOtherLoginButtonClick(() => {
uni.closeAuthView();
this.Toast({
title: '其他登录方式'
})
})
if (this.hasLogin && this.isUniverifyLogin) {
this.getPhoneNumber(uni.getStorageSync(univerifyInfoKey))
this.getPhoneNumber(uni.getStorageSync(univerifyInfoKey)).then((phoneNumber) => {
this.phoneNumber = phoneNumber
})
}
},
methods: {
...mapMutations(['login', 'setUniverifyLogin']),
...mapActions(['getPhoneNumber']),
Toast(data, duration = 1000) {
uni.showToast(Object.assign({}, data, {
duration
}))
},
tologin(provider) {
if (provider.id === 'univerify') {
this.univerifyBtnLoading = true;
}
// 一键登录已在APP onLaunch的时候进行了预登陆,可以显著提高登录速度。登录成功后,预登陆状态会重置
uni.login({
provider: provider.id,
// #ifdef MP-ALIPAY
......@@ -143,29 +129,38 @@
// #endif
success: (res) => {
console.log('login success:', res);
this.Toast({
title: '登录成功'
})
// 更新保存在 store 中的登录状态
this.login(provider.id);
// #ifdef APP-PLUS
if (provider.id === 'univerify') {
this.setUniverifyLogin(true);
uni.closeAuthView();
const {
access_token,
openid
} = res.authResult
// 注意大小写
const univerifyInfo = {
provider: provider.id,
accessToken: access_token,
openid
...res.authResult,
}
this.getPhoneNumber(univerifyInfo);
this.getPhoneNumber(univerifyInfo).then((phoneNumber) => {
this.phoneNumber = phoneNumber;
uni.setStorageSync(univerifyInfoKey, univerifyInfo)
}).catch(err => {
uni.showModal({
showCancel: false,
title: '手机号获取失败',
content: `${err.errMsg}\n,错误码:${err.code}`
})
console.error(res);
})
} else {
this.setUniverifyLogin(false);
}
// #endif
// #ifdef MP-WEIXIN
console.warn('如需获取openid请参考uni-id: https://uniapp.dcloud.net.cn/uniCloud/uni-id')
uni.request({
......@@ -194,37 +189,57 @@
},
fail: (err) => {
console.log('login fail:', err);
}
});
},
getPhoneNumber(univerifyInfo) {
uni.request({
url: 'https://97fca9f2-41f6-449f-a35e-3f135d4c3875.bspapp.com/http/univerify-login',
method: 'POST',
data: univerifyInfo,
success: (res) => {
console.log(res);
const {
data
} = res;
if (data.success) {
this.phoneNumber = data.phoneNumber;
uni.setStorageSync(univerifyInfoKey, univerifyInfo)
} else {
// 一键登录点击其他登录方式
if (err.code == '30002') {
uni.closeAuthView();
this.Toast({
icon: 'none',
title: `手机号获取失败`
title: '其他登录方式'
})
console.error(res);
return;
}
// 未开通
if (err.code == 1000) {
uni.showModal({
title: '登录失败',
content: `${err.errMsg}\n,错误码:${err.code}`,
confirmText: '开通指南',
cancelText: '确定',
success: (res) => {
if (res.confirm) {
setTimeout(() => {
plus.runtime.openWeb('https://ask.dcloud.net.cn/article/37965')
}, 500)
}
}
});
return;
}
// 一键登录预登陆失败
if (err.code == '30005') {
uni.showModal({
showCancel: false,
title: '预登录失败',
content: this.univerifyErrorMsg || err.errMsg
});
return;
}
// 一键登录用户关闭验证界面
if (err.code != '30003') {
uni.showModal({
showCancel: false,
title: '登录失败',
content: JSON.stringify(err)
});
}
},
fail: (err) => {
this.Toast({
title: '一键登录失败'
})
complete: () => {
this.univerifyBtnLoading = false;
}
})
});
}
}
}
......
......@@ -5,17 +5,21 @@
<view class="example">
<uni-easyinput v-model="value" focus placeholder="请输入内容" @input="input"></uni-easyinput>
</view>
<uni-section title="自定义样式" type="line"></uni-section>
<view class="example">
<uni-easyinput v-model="value" :styles="styles" :placeholderStyle="placeholderStyle" focus placeholder="请输入内容" @input="input"></uni-easyinput>
</view>
<uni-section title="左图标" type="line"></uni-section>
<view class="example">
<uni-easyinput prefixIcon="search" v-model="value" placeholder="请输入内容"></uni-easyinput>
<uni-easyinput prefixIcon="search" v-model="value" placeholder="请输入内容" @iconClick="iconClick"></uni-easyinput>
</view>
<uni-section title="右图标" type="line"></uni-section>
<view class="example">
<uni-easyinput suffixIcon="search" v-model="value" placeholder="请输入内容"></uni-easyinput>
<uni-easyinput suffixIcon="search" v-model="value" placeholder="请输入内容" @iconClick="iconClick"></uni-easyinput>
</view>
<uni-section title="禁用" type="line"></uni-section>
<view class="example">
<uni-easyinput disabled v-model="value" placeholder="请输入内容"></uni-easyinput>
<uni-easyinput disabled value="已禁用" placeholder="请输入内容"></uni-easyinput>
</view>
<uni-section title="密码框" type="line"></uni-section>
<view class="example">
......@@ -39,7 +43,12 @@
data() {
return {
value: '',
password: ''
password: '',
placeholderStyle: "color:#499721;font-size:16px",
styles: {
color: 'blue',
borderColor: '#499721'
}
}
},
......@@ -48,6 +57,12 @@
methods: {
input(e) {
console.log('输入内容:', e);
},
iconClick(type) {
uni.showToast({
title: `点击了${type==='prefix'?'左侧':'右侧'}的图标`,
icon: 'none'
})
}
}
}
......
<template>
<view>
<text class="example-info"> uni-forms 组件一般由输入框、选择器、单选框、多选框等控件组成,用以收集、校验、提交数据。</text>
<uni-forms :value="formData" ref="form" validate-trigger="bind" err-show-type="undertext">
<uni-forms :value="formData" ref="form" validate-trigger="bind" err-show-type="toast">
<uni-group title="基本信息" top="0">
<uni-forms-item name="name" required label="用户名">
<uni-easyinput type="text" :inputBorder="true" v-model="formData.name" placeholder="请输入用户名"></uni-easyinput>
......@@ -16,9 +16,9 @@
<uni-forms-item name="email" label="邮箱">
<uni-easyinput type="text" v-model="formData.email" placeholder="请输入邮箱"></uni-easyinput>
</uni-forms-item>
<!-- <uni-forms-item name="time" label="创建时间">
<uni-forms-item name="time" label="创建时间">
<uni-datetime-picker v-model="formData.time" :min-year="2000" :max-year="2030" :timestamp="true" @change="datetimeChange"></uni-datetime-picker>
</uni-forms-item> -->
</uni-forms-item>
<uni-forms-item name="checked" label="详细信息">
<switch :checked="formData.checked" @change="change('checked',$event.detail.value)" />
</uni-forms-item>
......@@ -185,9 +185,6 @@
this.$refs.form.setRules(this.rules)
},
methods: {
test(e) {
console.log('---', e.detail.value);
},
change(name, value) {
this.formData.checked = value
this.$refs.form.setValue(name, value)
......
......@@ -5,18 +5,19 @@ Vue.use(Vuex)
const store = new Vuex.Store({
state: {
hasLogin: false,
hasLogin: false,
isUniverifyLogin: false,
loginProvider: "",
openid: null,
testvuex:false,
colorIndex: 0,
colorList: ['#FF0000','#00FF00','#0000FF'],
noMatchLeftWindow: true,
active: 'componentPage',
leftWinActive: '/pages/component/view/view',
activeOpen: '',
menu: []
testvuex: false,
colorIndex: 0,
colorList: ['#FF0000', '#00FF00', '#0000FF'],
noMatchLeftWindow: true,
active: 'componentPage',
leftWinActive: '/pages/component/view/view',
activeOpen: '',
menu: [],
univerifyErrorMsg: ''
},
mutations: {
login(state, provider) {
......@@ -30,43 +31,46 @@ const store = new Vuex.Store({
setOpenid(state, openid) {
state.openid = openid
},
setTestTrue(state){
setTestTrue(state) {
state.testvuex = true
},
setTestFalse(state){
setTestFalse(state) {
state.testvuex = false
},
setColorIndex(state, index) {
state.colorIndex = index
},
setMatchLeftWindow(state, matchLeftWindow) {
state.noMatchLeftWindow = !matchLeftWindow
},
setActive(state, tabPage) {
state.active = tabPage
},
setLeftWinActive(state, leftWinActive) {
state.leftWinActive = leftWinActive
},
setActiveOpen(state, activeOpen) {
state.activeOpen = activeOpen
},
setMenu(state, menu) {
state.menu = menu
},
setUniverifyLogin(state, payload) {
typeof payload !== 'boolean' ? payload = !!payload : '';
state.isUniverifyLogin = payload;
},
setColorIndex(state,index){
state.colorIndex = index
},
setMatchLeftWindow(state, matchLeftWindow){
state.noMatchLeftWindow = !matchLeftWindow
},
setActive(state, tabPage){
state.active = tabPage
},
setLeftWinActive(state, leftWinActive){
state.leftWinActive = leftWinActive
},
setActiveOpen(state, activeOpen){
state.activeOpen = activeOpen
},
setMenu(state, menu){
state.menu = menu
},
setUniverifyLogin(state, payload){
typeof payload !== 'boolean' ? payload = !!payload : '';
state.isUniverifyLogin = payload;
setUniverifyErrorMsg(state,payload = ''){
state.univerifyErrorMsg = payload
}
},
getters:{
currentColor(state){
return state.colorList[state.colorIndex]
}
},
},
getters: {
currentColor(state) {
return state.colorList[state.colorIndex]
}
},
actions: {
// lazy loading openid
getUserOpenId: async function ({
getUserOpenId: async function({
commit,
state
}) {
......@@ -77,7 +81,7 @@ const store = new Vuex.Store({
uni.login({
success: (data) => {
commit('login')
setTimeout(function () { //模拟异步请求服务器获取 openid
setTimeout(function() { //模拟异步请求服务器获取 openid
const openid = '123456789'
console.log('uni.request mock openid[' + openid + ']');
commit('setOpenid', openid)
......@@ -91,6 +95,29 @@ const store = new Vuex.Store({
})
}
})
},
getPhoneNumber: function({
commit
}, univerifyInfo) {
return new Promise((resolve, reject) => {
uni.request({
url: 'https://97fca9f2-41f6-449f-a35e-3f135d4c3875.bspapp.com/http/univerify-login',
method: 'POST',
data: univerifyInfo,
success: (res) => {
const data = res.data
if (data.success) {
resolve(data.phoneNumber)
} else {
reject(res)
}
},
fail: (err) => {
reject(res)
}
})
})
}
}
})
......
......@@ -12,7 +12,6 @@
</template>
<script>
import { mapMutations, mapState } from 'vuex'
export default {
data() {
return {
......@@ -38,20 +37,21 @@
}]
}
},
computed: {
...mapState({
active: state => state.active,
hasLeftWin: state => !state.noMatchLeftWindow
})
props: {
matchLeftWindow: {
type: Boolean
},
showLeftWindow: {
type: Boolean
}
},
watch: {
$route: {
immediate: true,
handler(newRoute) {
if ( this.hasLeftWin ) {
if ( this.showLeftWindow ) {
let comp = newRoute.path.split('/')[2]
this.current = this.selected[comp]
for(const item of this.indexPage) {
if (newRoute.path === item.tabBar) {
uni.redirectTo({
......@@ -66,16 +66,7 @@
mounted() {
},
methods: {
...mapMutations(['setActive']),
toSecondMenu(e) {
let component = e.pagePath.split('/')[3]
if (component === 'component') {
component = 'componentPage'
}
if (component === 'template') {
component = 'templatePage'
}
this.setActive(component)
const activeTabBar = '/' + e.pagePath
for(const item of this.indexPage) {
if (activeTabBar === item.tabBar) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册