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

Merge branch 'master' of https://gitee.com/dcloud/base-app

...@@ -14,9 +14,8 @@ module.exports = { ...@@ -14,9 +14,8 @@ module.exports = {
}, },
"router":{ "router":{
"needLogin":[ //配置需要路由拦截的页面地址,在打开这些页面之前会自动检查(不联网)uni_id_token的值是否存在/过期等 "needLogin":[ //配置需要路由拦截的页面地址,在打开这些页面之前会自动检查(不联网)uni_id_token的值是否存在/过期等
"/pages/ucenter/edit/edit",
"/uni_modules/uni-login-page/pages/index/pwd-retrieve",
"/uni_modules/uni-id-users/pages/uni-id-users/edit" "/uni_modules/uni-id-users/pages/uni-id-users/edit"
"/uni_modules/uni-news-favorite/pages/uni-news-favorite/list"
], ],
"login":["univerify","smsCode","username","weixin","apple"] //默认就是短信验证码登陆 "login":["univerify","smsCode","username","weixin","apple"] //默认就是短信验证码登陆
}, },
......
...@@ -6,25 +6,27 @@ ...@@ -6,25 +6,27 @@
unicloud-db 组件文档:https://uniapp.dcloud.net.cn/uniCloud/unicloud-db-component unicloud-db 组件文档:https://uniapp.dcloud.net.cn/uniCloud/unicloud-db-component
DB Schema 规范:https://uniapp.dcloud.net.cn/uniCloud/schema DB Schema 规范:https://uniapp.dcloud.net.cn/uniCloud/schema
--> -->
<view class="article"> <view class="article">
<uni-nav-bar :statusBar="true" :border="false"></uni-nav-bar> <!-- #ifdef APP-PLUS -->
<uni-nav-bar :statusBar="true" :border="false"></uni-nav-bar>
<!-- #endif -->
<view class="article-title">{{ title }}</view>
<unicloud-db v-slot:default="{data, loading, error, options}" :options="formData" :collection="collection" <unicloud-db v-slot:default="{data, loading, error, options}" :options="formData" :collection="collection"
:field="field" :getone="true" :where="where" :manual="true" ref="detail" :field="field" :getone="true" :where="where" :manual="true" ref="detail"
foreignKey="opendb-news-articles.author" @load="loadData"> foreignKey="opendb-news-articles.author" @load="loadData">
<template v-if="!loading && data"> <template v-if="!loading && data">
<view class="article-title">{{title}}</view>
<uni-list :border="false"> <uni-list :border="false">
<uni-list-item thumbSize="lg" :thumb="data.image"> <uni-list-item thumbSize="lg" :thumb="data.image">
<!-- 通过body插槽定义作者信息内容 --> <!-- 通过body插槽定义作者信息内容 -->
<view slot="body" class="header-content"> <view slot="body" class="header-content">
<view class="uni-title">{{data.author && data.author[0].username}}</view> <view class="uni-title">{{data.author && data.author[0].username}}</view>
<view class="uni-note">更新于
<uni-dateformat :date="data.last_modify_date" format="yyyy-MM-dd"
:threshold="[60000, 2592000000]" />
</view>
</view> </view>
<view slot="footer" class="footer"> <view slot="footer" class="footer">
<button @click="followClick" class="footer-button">关注</button> <view class="uni-note">更新于
<uni-dateformat :date="data.last_modify_date" format="yyyy-MM-dd hh:mm"
:threshold="[60000, 2592000000]" />
</view>
<!-- <button @click="followClick" class="footer-button">关注</button> -->
</view> </view>
</uni-list-item> </uni-list-item>
</uni-list> </uni-list>
...@@ -61,7 +63,7 @@ ...@@ -61,7 +63,7 @@
return { return {
// 当前显示 _id // 当前显示 _id
id: "", id: "",
title: '', title: 'title',
// 数据表名 // 数据表名
collection: 'opendb-news-articles,uni-id-users', collection: 'opendb-news-articles,uni-id-users',
// 查询字段,多个字段用 , 分割 // 查询字段,多个字段用 , 分割
...@@ -92,7 +94,7 @@ ...@@ -92,7 +94,7 @@
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: event.title title: event.title
}) })
} }
}, },
onNavigationBarButtonTap(event) { onNavigationBarButtonTap(event) {
if (event.type == 'share') { if (event.type == 'share') {
...@@ -136,7 +138,7 @@ ...@@ -136,7 +138,7 @@
} }
}) })
.then(res=>{ .then(res=>{
console.log(res); // console.log(res);
}) })
.catch(err=>{ .catch(err=>{
console.log(err); console.log(err);
......
...@@ -205,9 +205,11 @@ ...@@ -205,9 +205,11 @@
url: '/uni_modules/uni-login-page/pages/index/index' url: '/uni_modules/uni-login-page/pages/index/index'
}); });
} }
}, },
/**
* 每一项的点击事件
*/
itemClick(item) { itemClick(item) {
console.log(item);
if (item.event) { if (item.event) {
this[item.event](item); this[item.event](item);
} }
......
...@@ -112,9 +112,6 @@ ...@@ -112,9 +112,6 @@
// #endif // #endif
}, },
methods: { methods: {
...mapMutations({
logout: 'user/logout'
}),
toSettings() { toSettings() {
uni.navigateTo({ uni.navigateTo({
url: "/pages/ucenter/settings/settings" url: "/pages/ucenter/settings/settings"
...@@ -175,10 +172,12 @@ ...@@ -175,10 +172,12 @@
uni.showLoading({ uni.showLoading({
mask: true mask: true
}) })
db.collection(dbCollectionName).field('score,balance').get().then((res) => { db.collection(dbCollectionName).where('user_id == $env.uid').field('score,balance').get().then((res) => {
const data = res.result.data[0]; const data = res.result.data[0];
let msg = '';
msg = data ? ('当前积分为' + data.balance) : '当前无积分';
uni.showToast({ uni.showToast({
title: '当前积分为' + data.balance, title: msg,
icon: 'none' icon: 'none'
}); });
}).catch((err) => { }).catch((err) => {
...@@ -333,4 +332,4 @@ ...@@ -333,4 +332,4 @@
/* #endif */ /* #endif */
background-color: #DD524D; background-color: #DD524D;
} }
</style> </style>
...@@ -353,7 +353,8 @@ ...@@ -353,7 +353,8 @@
this.formData[i] = this._getValue(i, this.value[i]) this.formData[i] = this._getValue(i, this.value[i])
} }
} }
} }
console.log(this.formData, this.formRules);
return this.validateAll(this.formData, 'submit', callback) return this.validateAll(this.formData, 'submit', callback)
}, },
......
<template> <template>
<view class="uni-container"> <view class="uni-container">
<uni-forms ref="form" :value="formData" :rules="rules" validate-trigger="submit" err-show-type="toast"> <uni-forms ref="form" :value="formData" :rules="rules" validate-trigger="submit" err-show-type="toast">
<uni-list-item> <uni-forms-item name="avatar">
<template v-slot:body> <template>
<view class="avatar-box"> <view class="avatar-box">
<image class="avatar-img" :src="formData.avatar || '/static/uni-center/logo.png'" @click="chooseImg" mode="aspectFill"></image> <image class="avatar-img" :src="formData.avatar || '/static/uni-center/logo.png'" @click="chooseImg" mode="aspectFill"></image>
</view> </view>
</template> </template>
</uni-list-item> </uni-forms-item>
<uni-forms-item name="gender" label="性别" required> <uni-forms-item name="gender" label="性别" required>
<uni-data-checkbox v-model="formData.gender" :localdata="formOptions.gender_localdata" /> <uni-data-checkbox v-model="formData.gender" :localdata="formOptions.gender_localdata" />
</uni-forms-item> </uni-forms-item>
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
validator validator
} from '../../js_sdk/validator/uni-id-users.js'; } from '../../js_sdk/validator/uni-id-users.js';
import { import {
mapMutations mapMutations,
mapGetters
} from 'vuex'; } from 'vuex';
const db = uniCloud.database(); const db = uniCloud.database();
const dbCollectionName = 'uni-id-users'; const dbCollectionName = 'uni-id-users';
...@@ -71,10 +72,14 @@ ...@@ -71,10 +72,14 @@
...getValidator(["avatar", "gender", "nickname"]) ...getValidator(["avatar", "gender", "nickname"])
} }
} }
},
computed:{
...mapGetters({
userInfo:'user/info'
})
}, },
onLoad(e) { onLoad(e) {
let id = "60795c140983f8000192f235"; let id = uni.getStorageSync('uni_id_uid') || this.userInfo._id;
id = uni.getStorageSync('uni_id_uid');
this.formDataId = id this.formDataId = id
this.getDetail(id) this.getDetail(id)
}, },
...@@ -138,7 +143,6 @@ ...@@ -138,7 +143,6 @@
title: '修改成功' title: '修改成功'
}) })
this.setUserInfo(value); this.setUserInfo(value);
// this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500) setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => { }).catch((err) => {
uni.showModal({ uni.showModal({
......
...@@ -21,7 +21,8 @@ let mixin = { ...@@ -21,7 +21,8 @@ let mixin = {
formData:{ formData:{
phone:'', phone:'',
code:'', code:'',
pwd:'' pwd:'',
pwd2:''
}, },
rules: { rules: {
phone:{ phone:{
...@@ -56,6 +57,26 @@ let mixin = { ...@@ -56,6 +57,26 @@ let mixin = {
errorMessage: '密码应为6到20位', errorMessage: '密码应为6到20位',
} }
] ]
},
pwd2:{
rules:[{
required: true,
errorMessage: '请确认密码',
},
{
pattern: /^.{6,20}$/,
errorMessage: '密码应为6到20位',
},
{
validateFunction:function(rule,value,data,callback){
console.log(value);
if(value!=data.pwd){
callback('两次输入密码不一致')
};
return true
}
}
]
} }
} }
} }
......
...@@ -17,19 +17,21 @@ ...@@ -17,19 +17,21 @@
<!-- </picker> --> <!-- </picker> -->
</template> </template>
</uni-easyinput> </uni-easyinput>
</uni-forms-item>
<uni-forms-item name="pwd">
<uni-easyinput type="password" class="phone-input-box" :inputBorder="false" <uni-easyinput type="password" class="phone-input-box" :inputBorder="false"
v-model="formData.pwd" placeholder="请输入密码"></uni-easyinput> v-model="formData.pwd" placeholder="请输入密码"></uni-easyinput>
</uni-forms-item> </uni-forms-item>
<button class="send-btn-box" type="primary" @click="pwdLogin">登录</button> <button class="send-btn-box" type="primary" @click="pwdLogin">登录</button>
</uni-forms> </uni-forms>
<!-- 忘记密码 --> <!-- 忘记密码 -->
<view class="auth-box"> <view class="auth-box">
<text class="login-text" @click="toRetrievePwd">忘记密码</text> <text class="login-text" @click="toRetrievePwd">忘记密码</text>
<text class="login-text" @click="toRetrievePwd">注册账号</text> <text class="login-text" @click="toRetrievePwd">注册账号</text>
</view> </view>
<!-- <button type="primary" plain class="toRegister" @click="toRegister">注册账号</button> --> <!-- <button type="primary" plain class="toRegister" @click="toRegister">注册账号</button> -->
</view> </view>
</view> </view>
<uni-quick-login ref="uniQuickLogin"></uni-quick-login> <uni-quick-login ref="uniQuickLogin"></uni-quick-login>
</view> </view>
</template> </template>
...@@ -80,7 +82,7 @@ ...@@ -80,7 +82,7 @@
uni.hideLoading() uni.hideLoading()
console.log(e.result); console.log(e.result);
if(e.result.code === 0){ if(e.result.code === 0){
this.loginSuccess(e.result) this.loginSuccess(e.result)
}else{ }else{
uni.showModal({ uni.showModal({
title: '错误', title: '错误',
...@@ -113,13 +115,13 @@ ...@@ -113,13 +115,13 @@
icon: 'none' icon: 'none'
}); });
// this.currenPhoneArea = this.phoneArea[event.detail.value]; // this.currenPhoneArea = this.phoneArea[event.detail.value];
}, },
/* 前往注册 */ /* 前往注册 */
toRegister(e){ toRegister(e){
console.log(e); console.log(e);
uni.navigateTo({ uni.navigateTo({
url:'/uni_modules/uni-login-page/pages/register/register' url:'/uni_modules/uni-login-page/pages/register/register'
}) })
} }
} }
} }
...@@ -136,9 +138,9 @@ ...@@ -136,9 +138,9 @@
} }
.login-text-sub { .login-text-sub {
color: #8a8f8b; color: #8a8f8b;
} }
.toRegister{ .toRegister{
margin-top: 80px; margin-top: 80px;
width: 600rpx; width: 600rpx;
} }
</style> </style>
...@@ -3,22 +3,30 @@ ...@@ -3,22 +3,30 @@
<view class="wrap-content"> <view class="wrap-content">
<view class="content"> <view class="content">
<!-- 顶部文字 --> <!-- 顶部文字 -->
<text class="content-top-title">重置密码</text> <text class="content-top-title">重置密码</text>
<login-ikonw v-show="formData.phone" class="login-iknow" :text="tipText"></login-ikonw> <login-ikonw v-show="isPhone" class="login-iknow" :text="tipText"></login-ikonw>
<!-- 登录框 (选择手机号所属国家和地区需要另行实现) --> <!-- 登录框 (选择手机号所属国家和地区需要另行实现) -->
<uni-forms ref="form" :value="formData" :rules="rules"> <uni-forms ref="form" :value="formData" :rules="rules">
<uni-forms-item name="phone"> <uni-forms-item name="phone">
<uni-easyinput type="number" class="phone-input-box" :inputBorder="false" <uni-easyinput type="number" class="phone-input-box" :inputBorder="false"
v-model="formData.phone" maxlength="11" placeholder="请输入手机号"></uni-easyinput> v-model="formData.phone" maxlength="11" placeholder="请输入手机号"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="code">
<uni-easyinput type="number" class="phone-input-box" :inputBorder="false" <uni-easyinput type="number" class="phone-input-box" :inputBorder="false"
v-model="formData.code" maxlength="6" placeholder="请输入验证码"> v-model="formData.code" maxlength="6" placeholder="请输入验证码">
<template slot="right"> <template slot="right">
<login-short-code ref="shortCode" :phone="formData.phone"></login-short-code> <login-short-code ref="shortCode" :phone="formData.phone"></login-short-code>
</template> </template>
</uni-easyinput> </uni-easyinput>
</uni-forms-item>
<uni-forms-item name="pwd">
<uni-easyinput type="password" class="phone-input-box" :inputBorder="false" <uni-easyinput type="password" class="phone-input-box" :inputBorder="false"
v-model="formData.pwd" placeholder="请输入新密码"></uni-easyinput> v-model="formData.pwd" placeholder="请输入新密码"></uni-easyinput>
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="pwd2">
<uni-easyinput type="password" class="phone-input-box" :inputBorder="false"
v-model="formData.pwd2" placeholder="请确认新密码"></uni-easyinput>
</uni-forms-item>
<button class="send-btn-box" :disabled="!canSubmit" :type="canSubmit?'primary':'default'" <button class="send-btn-box" :disabled="!canSubmit" :type="canSubmit?'primary':'default'"
@click="submit">完成</button> @click="submit">完成</button>
</uni-forms> </uni-forms>
...@@ -52,7 +60,7 @@ import mixin from '../../common/loginPage.mixin.js'; ...@@ -52,7 +60,7 @@ import mixin from '../../common/loginPage.mixin.js';
}, },
onReady() { onReady() {
if(this.formData.phone){ if(this.formData.phone){
this.$refs.shortCode.start(); // this.$refs.shortCode.start();
} }
}, },
methods: { methods: {
...@@ -60,19 +68,22 @@ import mixin from '../../common/loginPage.mixin.js'; ...@@ -60,19 +68,22 @@ import mixin from '../../common/loginPage.mixin.js';
* 完成并提交 * 完成并提交
*/ */
submit(){ submit(){
this.request('user-center/resetPwdBySmsCode',{ this.$refs.form.submit()
"mobile":this.formData.phone, .then(res=>{
"code":this.formData.code, this.request('user-center/resetPwdBySmsCode',{
"password":this.formData.pwd "mobile":this.formData.phone,
},(data,result)=>{ "code":this.formData.code,
console.log(result); "password":this.formData.pwd
uni.showToast({ },(data,result)=>{
title: result.msg, console.log(result);
icon: 'none' uni.showToast({
}); title: result.msg,
if(result.code === 0){ icon: 'none'
uni.navigateBack() });
} if(result.code === 0){
uni.navigateBack()
}
})
}) })
} }
} }
......
<template> <template>
<view class="container"> <view class="container">
<unicloud-db ref="udb" v-slot:default="{data, pagination, loading, hasMore, error}" collection="opendb-news-favorite"> <unicloud-db ref="udb" v-slot:default="{data, pagination, loading, hasMore, error}" where="user_id == $env.uid"
<view v-if="error">{{error.message}}</view> orderby="update_date desc" collection="opendb-news-favorite" @load="isLoading == false" @error="isLoading == false">
<view v-else-if="data"> <view v-if="data && data.length">
<uni-list> <uni-list>
<uni-list-item v-for="(item, index) in data" :key="index" :clickable="true" @click="handleItemClick(item)"> <uni-list-item v-for="(item, index) in data" :key="index" :clickable="true"
<view slot="body"> @click="handleItemClick(item)">
<text>{{item.article_title || item.article_id}}</text> <view slot="body">
<uni-dateformat class="article-date" :date="item.update_date" format="yyyy-MM-dd hh:mm" <text>{{item.article_title || item.article_id}}</text>
:threshold="[0, 0]" /> <uni-dateformat class="article-date" :date="item.update_date" format="yyyy-MM-dd hh:mm"
</view> :threshold="[0, 0]" />
</uni-list-item> </view>
</uni-list> </uni-list-item>
</view> </uni-list>
<uni-load-more :status="loading?'loading':(hasMore ? 'more' : 'noMore')"></uni-load-more> </view>
</unicloud-db> <uni-nodata v-else :isLoading="isLoading" @retry="refreshData"></uni-nodata>
</view> <uni-load-more :status="loading?'loading':(hasMore ? 'more' : 'noMore')"></uni-load-more>
</template> </unicloud-db>
</view>
<script> </template>
export default {
data() { <script>
return { export default {
loadMore: { data() {
contentdown: '', return {
contentrefresh: '', isLoading: true,
contentnomore: '' loadMore: {
} contentdown: '',
} contentrefresh: '',
}, contentnomore: '',
onPullDownRefresh() { }
this.$refs.udb.loadData({ }
clear: true },
}, () => { onPullDownRefresh() {
uni.stopPullDownRefresh() this.refreshData();
}) },
}, onReachBottom() {
onReachBottom() { this.$refs.udb.loadMore()
this.$refs.udb.loadMore() },
}, methods: {
methods: { refreshData() {
handleItemClick(item) { this.$refs.udb.loadData({
console.log(item); clear: true
uni.navigateTo({ }, (res) => {
url: '/pages/list/detail?id='+item.article_id+'&title='+(item.article_title || '') console.log(res);
}) uni.stopPullDownRefresh()
}, })
fabClick() { },
// 打开新增页面 handleItemClick(item) {
uni.navigateTo({ uni.navigateTo({
url: './add', url: '/pages/list/detail?id=' + item.article_id + '&title=' + (item.article_title || '')
events: { })
// 监听新增数据成功后, 刷新当前页面数据 }
refreshData: () => { }
this.$refs.udb.loadData({ }
clear: true </script>
})
} <style>
} .article-date {
}) color: #C8C7CC;
} }
}
}
</script>
<style>
.article-date{
color: #C8C7CC;
}
</style> </style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册