Browse Source

fix: tall4点击二级项目没反应

test2
xuesinan 3 years ago
parent
commit
0c3bdb0cb8
  1. 132
      App.vue
  2. 3
      CHANGELOG.md
  3. 14
      common/styles/tailwind.scss
  4. 6
      components/Plugin/Plugin.vue
  5. 20
      components/PrettyExchange/PrettyExchange.vue
  6. 8
      components/Projects/ProjectItem.vue
  7. 6
      components/Projects/Projects.vue
  8. 1
      components/Render/Render.vue
  9. 285
      hooks/user/userMixin - 副本.js
  10. 277
      hooks/user/userMixin - 数字键盘.js
  11. 44
      hooks/user/userMixin.js
  12. 206
      pages/user/login - 数字键盘.vue
  13. 63
      pages/user/login.vue
  14. 32
      store/task/mutations.js

132
App.vue

@ -29,7 +29,7 @@ export default {
uni.$storage.setStorageSync('isOpenApp', true);
this.$store.commit('setIsOpenApp', true);
// App
let firstOpenApp = uni.$storage.getStorageSync('firstOpenApp');
const firstOpenApp = uni.$storage.getStorageSync('firstOpenApp');
this.$store.commit('setFirstOpenApp');
this.getGuide(0);
this.getGuide(1);
@ -74,7 +74,7 @@ export default {
} else {
type === 0 ? this.$store.commit('setGuide', data) : this.$store.commit('setAdvs', data);
}
})
});
},
/**
@ -179,14 +179,14 @@ export default {
},
getLocation() {
let that = this;
const that = this;
uni.getLocation({
type: 'wgs84',
success: function (res) {
type: 'wgs84',
success(res) {
that.$store.commit('setLongitude', res.longitude);
that.$store.commit('setLatitude', res.latitude);
}
},
});
},
@ -234,11 +234,11 @@ page {
}
.uni-swiper-slides {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
}
.statbar {
@ -254,82 +254,82 @@ page {
/* #ifdef H5 */
.uni-modal {
position: fixed;
z-index: 999;
width: 80%;
max-width: 300px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #ffffff;
text-align: center;
border-radius: 3px;
overflow: hidden;
position: fixed;
z-index: 999;
width: 80%;
max-width: 300px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #ffffff;
text-align: center;
border-radius: 3px;
overflow: hidden;
}
.uni-modal__bd {
padding: 1.3em 1.6em 1.3em;
min-height: 40px;
font-size: 15px;
line-height: 1.4;
word-wrap: break-word;
word-break: break-all;
white-space: pre-wrap;
color: #999999;
max-height: 400px;
overflow-x: hidden;
overflow-y: auto;
padding: 1.3em 1.6em 1.3em;
min-height: 40px;
font-size: 15px;
line-height: 1.4;
word-wrap: break-word;
word-break: break-all;
white-space: pre-wrap;
color: #999999;
max-height: 400px;
overflow-x: hidden;
overflow-y: auto;
}
.uni-modal__ft {
position: relative;
line-height: 48px;
font-size: 18px;
display: flex;
position: relative;
line-height: 48px;
font-size: 18px;
display: flex;
}
.uni-modal__btn {
display: block;
flex: 1;
color: #3cc51f;
text-decoration: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
position: relative;
cursor: pointer;
display: block;
flex: 1;
color: #3cc51f;
text-decoration: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
position: relative;
cursor: pointer;
}
.uni-modal__ft:after {
content: ' ';
position: absolute;
left: 0;
top: 0;
right: 0;
height: 1px;
border-top: 1px solid #d5d5d6;
color: #d5d5d6;
transform-origin: 0 0;
transform: scaleY(0.5);
content: ' ';
position: absolute;
left: 0;
top: 0;
right: 0;
height: 1px;
border-top: 1px solid #d5d5d6;
color: #d5d5d6;
transform-origin: 0 0;
transform: scaleY(0.5);
}
.uni-modal__btn:after {
content: ' ';
position: absolute;
left: 0;
top: 0;
width: 1px;
bottom: 0;
border-left: 1px solid #d5d5d6;
color: #d5d5d6;
transform-origin: 0 0;
transform: scaleX(0.5);
content: ' ';
position: absolute;
left: 0;
top: 0;
width: 1px;
bottom: 0;
border-left: 1px solid #d5d5d6;
color: #d5d5d6;
transform-origin: 0 0;
transform: scaleX(0.5);
}
.uni-modal__btn_default {
color: #353535;
color: #353535;
}
.uni-modal__btn_primary {
color: #007aff;
color: #007aff;
}
/* #endif */
</style>

3
CHANGELOG.md

@ -1,4 +1,4 @@
# 1.0.0 (2022-05-23)
# 1.0.0 (2022-07-19)
### 🌟 新功能
范围|描述|commitId
@ -81,6 +81,7 @@
- | 小红点显示逻辑 | [11923f3](https://101.201.226.163:50022/ccsens_tall/TALL-MUI-4/commits/11923f3)
- | 小绿点隐藏 | [31f3dc7](https://101.201.226.163:50022/ccsens_tall/TALL-MUI-4/commits/31f3dc7)
- | 引导页、广告页 | [4aa76ff](https://101.201.226.163:50022/ccsens_tall/TALL-MUI-4/commits/4aa76ff)
- | 隐藏软键盘 | [919a44e](https://101.201.226.163:50022/ccsens_tall/TALL-MUI-4/commits/919a44e)
- | 域名配置 | [b68272d](https://101.201.226.163:50022/ccsens_tall/TALL-MUI-4/commits/b68272d)
- | 增加位置信息并传参给内嵌插件 | [fe5fe4e](https://101.201.226.163:50022/ccsens_tall/TALL-MUI-4/commits/fe5fe4e)
- | 长按改变层级 | [c25319a](https://101.201.226.163:50022/ccsens_tall/TALL-MUI-4/commits/c25319a)

14
common/styles/tailwind.scss

@ -3056,7 +3056,7 @@
.py-1 {
padding-top: 0.25rem;
padding-bottom: 0.25rem;
}
}
.py-2 {
padding-top: 0.5rem;
@ -4535,10 +4535,22 @@
.shadow {
--tw-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
}
.rounded-sm {
border-radius: 0.125rem;
}
.rounded {
border-radius: 0.25rem;
}
.rounded-md {
border-radius: 0.375rem;
}
.rounded-lg {
border-radius: 0.5rem;
}
.shadow-md {

6
components/Plugin/Plugin.vue

@ -20,11 +20,13 @@
<p-wbs-import :task="task" v-if="pluginId === '13' || pluginId === '14'" /> -->
<!-- 交付物插件 -->
<p-deliver v-else-if="pluginId === '15'" />
<p-deliver-second v-else-if="pluginId === '25'" />
<!-- <p-deliver v-else-if="pluginId === '15'" /> -->
<p-deliver-second v-else-if="pluginId === '15'" />
<p-source-manage v-else-if="pluginId === '16'" class="p-2" />
<p-finance-audit v-else-if="pluginId === '17'" class="p-2" />
<p-finance v-else-if="pluginId === '18'" class="p-2" />
<!-- 个人和终端按钮-->
<!-- <p-account-management /> -->
<p-account-management v-else-if="pluginId === '19'" class="p-2" />

20
components/PrettyExchange/PrettyExchange.vue

@ -11,7 +11,7 @@
<view
class="w-full"
@touchend="stops($event, index)"
@touchmove="move"
@touchmove.stop.prevent="move"
@longpress="start($event, index)"
>
@ -36,7 +36,7 @@
</view>
</view>
<view class="workbench-btn" v-if="index === 0" @click="toWorkbench">工作台</view>
<view class="workbench-btn" v-if="item.businessCode === 'ZERO'" @click="toWorkbench">工作台</view>
<view class="remind-box bg-red-500 text-white text-xs" v-if="item.remindNum">{{ item.remindNum > 99 ? '99+' : item.remindNum }}</view>
@ -65,7 +65,7 @@
<view
:id="'cu-' + index + '-' + subIndex"
:key="subIndex"
@touchend.stop.prevent="stops($event, index + '-' + subIndex, item.sonProjectList.length)"
@touchend="stops($event, index + '-' + subIndex, item.sonProjectList.length)"
@touchmove.stop.prevent="move($event, item.sonProjectList.length)"
@longpress.stop.prevent="start($event, index + '-' + subIndex)"
class="cu-item flex-col"
@ -171,7 +171,7 @@ const data = reactive({
timer: null
});
const emit = defineEmits(['changeHeight', 'change']);
const emit = defineEmits(['changeHeight', 'change', 'getProjects']);
//
watch(projects, () => {
@ -568,16 +568,8 @@ function delProject(id, url) {
showCancel: true,
success: async ({ confirm }) => {
if (confirm) {
await uni.$u.api.delProject(id, url);
let flag_index = 0;
data.itemList.forEach((item, index) => {
if (item.id == id) {
flag_index = index;
}
});
data.itemList.splice(flag_index, 1);
store.commit('project/setProjects', data.itemList);
await uni.$u.api.delProject(id, url);
emit('getProjects');
}
},
});

8
components/Projects/ProjectItem.vue

@ -1,7 +1,7 @@
<template>
<view class="w-full" :style="{background: item.styleColor}">
<!-- 有子项目 父项目 -->
<view class="flex items-center justify-between p-3">
<view class="h-65 flex items-center justify-between p-3">
<u-icon @click="openMenu(item, index)" class="mover" name="https://www.tall.wiki/staticrec/drag.svg" size="48"></u-icon>
<view @click="openProject(item)" class="flex-1 px-3">
@ -54,7 +54,7 @@
v-for="(subItem, subIndex) in item.sonProjectList"
>
<!-- <view :key="subItem.id" v-for="subItem in item.sonProjectList"> -->
<view class="flex items-center justify-between p-3">
<view class="h-65 flex items-center justify-between p-3">
<u-icon @click="openMenu(subItem)" class="mover" name="https://www.tall.wiki/staticrec/drag.svg" size="48"></u-icon>
<view @click="openProject(subItem)" class="flex-1 px-3">
@ -189,4 +189,8 @@ function openMenu(project, index) {
border-radius: 8px;
font-weight: 100;
}
.h-65 {
height: 65px;
}
</style>

6
components/Projects/Projects.vue

@ -1,11 +1,15 @@
<template>
<view class="bg-white u-font-15" style="padding: 12px 0; margin-top: 16px;">
<PrettyExchange @change="change" />
<PrettyExchange @change="change" @getProjects="getProjects" />
</view>
</template>
<script setup>
const emit = defineEmits(['getProjects']);
function getProjects() {
emit('getProjects');
}
function change(options) {
if (options instanceof Array) {

1
components/Render/Render.vue

@ -18,6 +18,7 @@
:prop="pluginInfo"
:change:prop="projectRender.renderDom"
:data-url="domain"
:data-tTime="task.planStart"
:data-longitude="longitude"
:data-latitude="latitude"
></view>

285
hooks/user/userMixin - 副本.js

@ -1,285 +0,0 @@
import { ref, computed } from 'vue';
import { useStore } from 'vuex';
import clipboard from "@/common/js/dc-clipboard/clipboard.js"
export default function mixinInit {
const store = useStore();
const user = computed(() => store.state.user.user);
const rules = ref({
phone: [
{
required: true,
message: '请输入手机号',
trigger: ['change','blur'],
},
{
validator: (rule, value, callback) => {
// 调用uView自带的js验证规则,详见:https://www.uviewui.com/js/test.html
return this.$u.test.mobile(value);
},
message: '手机号码不正确',
// 触发器可以同时用blur和change,二者之间用英文逗号隔开
trigger: ['change','blur'],
}
],
verificationCodeValue: [
{
required: true,
message: '请输入图形验证码',
trigger: ['change','blur'],
},
{
type: 'number',
message: '图形验证码只能为数字',
trigger: ['change','blur'],
}
],
smsCode: [
{
required: true,
message: '请输入验证码',
trigger: ['change','blur'],
},
{
type: 'number',
message: '验证码只能为数字',
trigger: ['change','blur'],
}
],
account: [
{
required: true,
message: '请输入用户名',
trigger: ['change','blur'],
},
{
min: 2,
max: 20,
message: '用户名长度在2到20个字符',
trigger: ['change','blur'],
},
{
pattern: /^[a-zA-Z0-9._-]{2,20}$/,
message: '请输入2-20位字母、数字、汉字或字符"_ - ."',
trigger: ['change','blur'],
}
],
password: [
{
required: true,
message: '请输入密码',
trigger: ['change','blur'],
},
{
min: 6,
max: 20,
message: '密码长度在6到20个字符',
trigger: ['change','blur'],
},
{
// 正则不能含有两边的引号
pattern: /^[a-zA-Z0-9._-]{6,20}$/,
message: '请输入6-20位字母、数字、汉字或字符"_ - ."',
trigger: ['change','blur'],
}
],
});
const errorType = ref(['message']);
const labelPosition = ref('left');
const border = ref(false);
const smsCode = ref(''); // 短信验证码
const showInterval = ref(false);
const interval = ref(120);
const codeTimer = ref(null);
const showPaste = ref(false);
// 获取图形验证码
async function getImageCode() {
console.log('5555')
uni.$ui.showLoading();
try {
const data = await uni.$u.api.getImageCode();
const { imageBase64, verificationCodeId } = data;
imageBase64 = imageBase64 || '';
verificationCodeId = verificationCodeId || '';
uni.$ui.hideLoading();
} catch (error) {
uni.$ui.hideLoading();
uni.$ui.showToast(error);
}
}
return {
// errorType,
// rules,
// labelPosition,
// border,
getImageCode,
// hasvalue,
// getCode,
// getCodeInterval,
// checkRules,
// setCode,
// getClipboardContents,
// verifyPhone,
// verifyLoginname,
// handleWxLogin
}
}
// const mixin = {
// computed: mapState('user', ['user']),
// onReady() {
// this.$refs.uForm.setRules(this.rules);
// },
// methods: {
// ...mapActions('user', ['sendCode']),
// 获取图形验证码
// async getImageCode() {
// this.$util.showLoading();
// try {
// const data = await uni.$u.api.getImageCode();
// const { imageBase64, verificationCodeId } = data;
// this.imageBase64 = imageBase64 || '';
// this.verificationCodeId = verificationCodeId || '';
// uni.hideLoading();
// } catch (error) {
// uni.hideLoading();
// uni.$ui.showToast(error);
// }
// },
// //有图片验证码的值
// hasvalue() {
// if(this.model.smsCode || this.model.showPaste) return
// if (!this.verifyPhone(this.model.phone)) {
// uni.$ui.showToast('请输入正确的手机号');
// return;
// }
// if (!this.model.verificationCodeValue) {
// uni.$ui.showToast('请输入图形验证码');
// return;
// }
// this.getCode();
// },
// // 获取验证码
// async getCode() {
// try {
// const { phone, verificationCodeValue } = this.model;
// const { verificationCodeId } = this;
// if (!verificationCodeId || !verificationCodeValue) {
// uni.$ui.showToast('缺少图形验证码参数');
// return;
// }
// const params = {
// phone,
// verificationCodeId,
// verificationCodeValue,
// };
// const date = await store.dispatch('user/sendCode', params);
// getCodeInterval();
// showPaste.value = true;
// } catch (err) {
// throw err;
// }
// },
// // 获取验证码倒计时
// getCodeInterval() {
// this.showInterval = true;
// this.codeTimer = setInterval(() => {
// if (this.interval === 0) {
// clearInterval(this.codeTimer);
// this.codeTimer = null;
// this.showInterval = false;
// this.interval = 120;
// return;
// }
// this.interval = this.interval - 1;
// }, 1000);
// },
// // 验证信息
// checkRules() {
// // const { smsCode, phone, user } = this;
// if (!this.verifyPhone(phone.value)) {
// uni.$ui.showToast('请输入正确的手机号');
// return false;
// }
// if (!smsCode.value) {
// uni.$ui.showToast('验证码无效');
// return false;
// }
// if (phone.value === user.value.phone) {
// uni.$ui.showToast('新手机号不能与旧手机号相同');
// return;
// }
// return true;
// },
// // 粘贴
// setCode() {
// // 获取粘贴板内容
// // 小程序平台
// //#ifdef MP-WEIXIN
// var _this = this
// uni.getClipboardData({
// success (res) {
// _this.smsCode = res.data;
// }
// });
// //#endif
// // 非小程序平台
// //#ifndef MP-WEIXIN
// this.getClipboardContents()
// //#endif
// },
// // 非小程序平台粘贴
// async getClipboardContents() {
// try {
// const text = await navigator.clipboard.readText();
// this.smsCode = text;
// } catch (err) {
// console.error('Failed to read clipboard contents: ', err);
// }
// },
// /**
// * 验证手机号格式
// * @param {string} phone 手机号
// */
// verifyPhone(phone) {
// const phoneExg = /^1\d{10}$/;
// return phoneExg.test(phone);
// },
// /**
// * 验证账号/密码 格式
// * @param {string} account 账号
// */
// verifyLoginname(account) {
// const accountExg = /^[a-zA-Z0-9._-]{2,20}$/;
// return accountExg.test(account);
// },
// // 微信登录
// handleWxLogin() {
// const origin = 'https://test.tall.wiki/pt-mui'; // 测试
// const appid = 'wxd1842e073e0e6d91';
// const state = 'wx_web';
// const href = 'https://open.weixin.qq.com/connect/qrconnect';
// // eslint-disable-next-line
// window.location.href =
// `${href}?appid=${appid}&redirect_uri=${origin}&response_type=code&scope=snsapi_login&state=${state}#wechat_redirect`;
// },
// // }
// };

277
hooks/user/userMixin - 数字键盘.js

@ -0,0 +1,277 @@
import { ref, computed, reactive } from 'vue';
import { useStore } from 'vuex';
import clipboard from "@/common/js/dc-clipboard/clipboard.js";
import Config from '@/common/js/config.js'
export default function userMixin() {
const store = useStore();
const user = computed(() => store.state.user.user);
const rules = {
phone: [{
required: true,
message: '请输入手机号',
trigger: ['change', 'blur'],
},
{
validator: (rule, value, callback) => {
// 调用uView自带的js验证规则,详见:https://www.uviewui.com/js/test.html
return uni.$u.test.mobile(value);
},
message: '手机号码不正确',
// 触发器可以同时用blur和change,二者之间用英文逗号隔开
trigger: ['change', 'blur'],
}
],
verificationCodeValue: [{
required: true,
message: '请输入图形验证码',
trigger: ['change', 'blur'],
},
{
type: 'number',
message: '图形验证码只能为数字',
trigger: ['change', 'blur'],
}
],
smsCode: [{
required: true,
message: '请输入验证码',
trigger: ['change', 'blur'],
},
{
type: 'number',
message: '验证码只能为数字',
trigger: ['change', 'blur'],
}
],
account: [{
required: true,
message: '请输入用户名',
trigger: ['change', 'blur'],
},
{
min: 2,
max: 20,
message: '用户名长度在2到20个字符',
trigger: ['change', 'blur'],
},
{
pattern: /^[a-zA-Z0-9._-]{2,20}$/,
message: '请输入2-20位字母、数字、汉字或字符"_ - ."',
trigger: ['change', 'blur'],
}
],
password: [{
required: true,
message: '请输入密码',
trigger: ['change', 'blur'],
},
{
min: 6,
max: 20,
message: '密码长度在6到20个字符',
trigger: ['change', 'blur'],
},
{
// 正则不能含有两边的引号
pattern: /^[a-zA-Z0-9._-]{6,20}$/,
message: '请输入6-20位字母、数字、汉字或字符"_ - ."',
trigger: ['change', 'blur'],
}
],
};
const smsCode = ref(null); // 短信验证码
// const showInterval = ref(false);
// const interval = ref(120);
const codeTimer = ref(null);
// const showPaste = ref(false);
const dataObj = reactive({
showInterval: false,
interval: 60,
showPaste: false
});
//有图片验证码的值
function hasvalue(form, renderData) {
uni.hideKeyboard();//隐藏软键盘
if(form.smsCode || form.showPaste) return
if (!verifyPhone(form.phone)) {
uni.$ui.showToast('请输入正确的手机号');
return;
}
if (!form.verificationCodeValue) {
uni.$ui.showToast('请输入图形验证码');
return;
}
if (!dataObj.showInterval) {
getCode(form, renderData);
}
}
// 获取验证码
async function getCode(form, renderData) {
try {
if (!renderData.verificationCodeId || !form.verificationCodeValue) {
uni.$ui.showToast('缺少图形验证码参数');
return;
}
const params = {
phone: form.phone,
verificationCodeId: renderData.verificationCodeId,
verificationCodeValue: form.verificationCodeValue,
};
const data = await store.dispatch('user/sendCode', params);
if (data) {
getCodeInterval();
dataObj.showPaste = true;
}
} catch (err) {
dataObj.showPaste = false;
throw err;
}
}
// 获取验证码倒计时
function getCodeInterval() {
dataObj.showInterval = true;
codeTimer.value = setInterval(() => {
if (dataObj.interval === 0) {
clearInterval(codeTimer.value);
codeTimer.value = null;
dataObj.showInterval = false;
dataObj.interval = 60;
return;
}
dataObj.interval = dataObj.interval - 1;
}, 1000);
}
// 粘贴
function setCode(form) {
// 获取粘贴板内容
// 小程序平台
//#ifdef MP-WEIXIN
uni.getClipboardData({
success(res) {
form.smsCode = res.data;
},
});
//#endif
// 非小程序平台
//#ifndef MP-WEIXIN
getClipboardContents(form)
//#endif
}
// 非小程序平台粘贴
async function getClipboardContents(form) {
try {
const text = await navigator.clipboard.readText();
form.smsCode = text;
} catch (err) {
console.error('Failed to read clipboard contents: ', err);
}
}
// 验证信息
// function checkRules() {
// if (!verifyPhone(phone.value)) {
// uni.$ui.showToast('请输入正确的手机号');
// return false;
// }
// if (!smsCode.value) {
// uni.$ui.showToast('验证码无效');
// return false;
// }
// if (phone.value === user.value.phone) {
// uni.$ui.showToast('新手机号不能与旧手机号相同');
// return;
// }
// return true;
// }
/**
* 验证手机号格式
* @param {string} phone 手机号
*/
function verifyPhone(phone) {
const phoneExg = /^1\d{10}$/;
return phoneExg.test(phone);
}
/**
* 验证账号/密码 格式
* @param {string} account 账号
*/
function verifyLoginname(account) {
const accountExg = /^[a-zA-Z0-9._-]{2,20}$/;
return accountExg.test(account);
}
// 微信登录
function handleWxLogin() {
// #ifdef H5
const origin = `${Config.baseUrl}/pt-mui`; // 测试
const appid = 'wxd1842e073e0e6d91';
const state = 'wx_web';
const href = 'https://open.weixin.qq.com/connect/qrconnect';
// eslint-disable-next-line
window.location.href =
`${href}?appid=${appid}&redirect_uri=${origin}&response_type=code&scope=snsapi_login&state=${state}#wechat_redirect`;
// #endif
// #ifdef APP-PLUS
uni.getProvider({
service: 'oauth',
success: function(res) {
console.log(res.provider);
//支持微信、qq和微博等
if (~res.provider.indexOf('weixin')) {
uni.login({
provider: 'weixin',
success: function(loginRes) {
uni.$ui.showToast("App微信获取用户信息成功", loginRes);
console.log("App微信获取用户信息成功", loginRes);
// 获取用户信息
uni.getUserInfo({
provider: 'weixin',
success: function(infoRes) {
uni.$ui.showToast('-------获取微信用户所有-----');
uni.$ui.showToast(infoRes.userInfo.openId);
uni.$ui.showToast(JSON.stringify(infoRes.userInfo));
console.log('-------获取微信用户所有-----');
console.log(infoRes.userInfo.openId);
console.log(JSON.stringify(infoRes.userInfo));
// 提交信息
// that.wxSubmit(infoRes.userInfo.openId)
}
});
// that.getApploginData(loginRes) //请求登录接口方法
},
fail: function(res) {
console.log("App微信获取用户信息失败", res);
}
})
}
}
});
// #endif
}
return {
rules,
// showPaste,
// showInterval,
// interval,
dataObj,
hasvalue,
// checkRules,
setCode,
verifyLoginname,
handleWxLogin
}
}

44
hooks/user/userMixin.js

@ -93,8 +93,6 @@ export default function userMixin() {
//有图片验证码的值
function hasvalue(form, renderData) {
uni.hideKeyboard();//隐藏软键盘
if(form.smsCode || form.showPaste) return
if (!verifyPhone(form.phone)) {
uni.$ui.showToast('请输入正确的手机号');
@ -149,50 +147,50 @@ export default function userMixin() {
}
// 粘贴
function setCode(form) {
function setCode() {
// 获取粘贴板内容
// 小程序平台
//#ifdef MP-WEIXIN
uni.getClipboardData({
success(res) {
form.smsCode = res.data;
smsCode.value = res.data;
},
});
//#endif
// 非小程序平台
//#ifndef MP-WEIXIN
getClipboardContents(form)
getClipboardContents()
//#endif
}
// 非小程序平台粘贴
async function getClipboardContents(form) {
async function getClipboardContents() {
try {
const text = await navigator.clipboard.readText();
form.smsCode = text;
smsCode.value = text;
} catch (err) {
console.error('Failed to read clipboard contents: ', err);
}
}
// 验证信息
// function checkRules() {
// if (!verifyPhone(phone.value)) {
// uni.$ui.showToast('请输入正确的手机号');
// return false;
// }
// if (!smsCode.value) {
// uni.$ui.showToast('验证码无效');
// return false;
// }
function checkRules() {
if (!verifyPhone(phone.value)) {
uni.$ui.showToast('请输入正确的手机号');
return false;
}
if (!smsCode.value) {
uni.$ui.showToast('验证码无效');
return false;
}
// if (phone.value === user.value.phone) {
// uni.$ui.showToast('新手机号不能与旧手机号相同');
// return;
// }
// return true;
// }
if (phone.value === user.value.phone) {
uni.$ui.showToast('新手机号不能与旧手机号相同');
return;
}
return true;
}
/**
* 验证手机号格式
@ -269,7 +267,7 @@ export default function userMixin() {
// interval,
dataObj,
hasvalue,
// checkRules,
checkRules,
setCode,
verifyLoginname,
handleWxLogin

206
pages/user/login - 数字键盘.vue

@ -0,0 +1,206 @@
<template>
<view class="statbar">
<view class="status_bar"></view>
</view>
<view class="u-p-l-50 u-p-r-50 u-p-t-30">
<view class="mt-5 mb-10 text-4xl text-center">登录</view>
<u-form :model="form" ref="phoneLoginForm" :error-type="['message']">
<u-form-item label="手机号码" prop="phone" label-width="160">
<u-input placeholder="请输入手机号" v-model="form.phone" type="number" @focus="handleFocus" @click="handleShowKeyboard(1)"></u-input>
</u-form-item>
<u-form-item label="图形验证码" prop="verificationCodeValue" label-width="160">
<u-input placeholder="请输入计算结果" v-model="form.verificationCodeValue" type="number" @focus="handleFocus" @click="handleShowKeyboard(2)"></u-input>
<image slot="right" :src="renderData.imageBase64" mode="aspectFit" class="code-image" @click="getImageCode"></image>
</u-form-item>
<u-form-item label="验证码" prop="smsCode" label-width="160">
<u-input @focus="mixinInit.hasvalue(form, renderData)" placeholder="请输入验证码" v-model="form.smsCode" type="number" @click="handleShowKeyboard(3)"></u-input>
<u-button slot="right" type="primary" size="mini" v-show="mixinInit.dataObj.showPaste" @click="toPaste" class="u-m-r-20">粘贴</u-button>
<u-button slot="right" size="mini" v-if="mixinInit.dataObj.showInterval">{{ mixinInit.dataObj.interval }}</u-button>
</u-form-item>
<!-- <view class="flex flex-nowrap">
<view class="flex-sub"></view>
<view class="u-m-t-30 u-font-12 text-gray-400" @click="openPage('/pages/user/forgetPassword')">忘记密码</view>
</view> -->
</u-form>
<view class="u-m-t-50">
<u-button @click="submitLogin" type="primary">立即登录</u-button>
</view>
<!-- <view class="flex justify-between">
<view class="u-m-t-30" style="color: #2885ED;" @click="openPage('/pages/user/rigister')">新用户注册</view>
<view class="u-m-t-30" style="color: #2885ED;" @click="openPage('/pages/user/accountLogin')">用户名登录</view>
</view> -->
<!-- <view style="margin-top: 200rpx; text-align: center; color: #999999;font-size: 35rpx;">
快速登录
</view>
<view style="text-align: center; margin-top: 20rpx;" @click="mixinInit.handleWxLogin">
<image src="../../static/weixinIcon.png" mode="" style="width: 85rpx;height: 85rpx;"></image>
</view> -->
</view>
<master-keyboard ref="keyboard" keyboardtype="number" :randomNumber="true" :newCar="false" :defaultValue="title" @keyboardClick="handleClick" @toPaste="toPaste"></master-keyboard>
</template>
<script setup>
import { ref, computed, reactive } from 'vue';
import { useStore } from 'vuex';
import { onReady } from '@dcloudio/uni-app';
import userMixin from '@/hooks/user/userMixin'
const store = useStore();
const mixinInit = userMixin();
const phoneLoginForm = ref(null);
//
const keyboard = ref(null);
const currIndex = ref(null); //
const title = ref('');
const showKeyboard = ref(false);
const numberArr = ref(['1', '2', '3', '4', '5', '6', '7', '8', '9','0']);
const form = reactive({
phone: '',
verificationCodeValue: '', //
smsCode: ''
});
const renderData = reactive({
verificationCodeId: '', // id
imageBase64: '' //
})
onReady(() => {
phoneLoginForm.value.setRules(mixinInit.rules);
});
getImageCode(); //
//
const submitLogin = () => {
phoneLoginForm.value.validate(valid => {
if (valid) {
login()
}
});
}
//
function toPaste() {
uni.getClipboardData({
success(res) {
if (currIndex.value === 1) {
form.phone = res.data;
} else if (currIndex.value === 2) {
form.verificationCodeValue = res.data;
} else if (currIndex.value === 3) {
form.smsCode = res.data;
}
},
});
}
/**
* 登录
*/
async function login() {
uni.$ui.showLoading();
try {
// #ifdef H5
const client = 0;
// #endif
// #ifdef APP-PLUS
const client = 1;
// #endif
const params = reactive({
client: client,
data: {
identifier: form.phone,
credential: form.smsCode,
},
type: 1,
});
let res = await uni.$u.api.signin(params);
store.commit('user/setToken', res.token);
store.commit('user/setUser', res);
uni.$storage.setStorageSync('anyringToken', res.token || '');
uni.$storage.setStorageSync('user', JSON.stringify(res) || '');
store.dispatch('socket/initSocket');
uni.$ui.hideLoading();
uni.navigateTo({
url: '/pages/index/index'
});
} catch (error) {
uni.$ui.hideLoading();
uni.$ui.showToast(error.msg);
}
}
//
async function getImageCode() {
uni.$ui.showLoading();
try {
const data = await uni.$u.api.getImageCode();
renderData.imageBase64 = data.imageBase64 || '';
renderData.verificationCodeId = data.verificationCodeId || '';
uni.$ui.hideLoading();
} catch (error) {
uni.$ui.hideLoading();
uni.$ui.showToast(error);
}
}
//
function openPage(url) {
uni.navigateTo({
url: url
})
}
//
function handleFocus() {
uni.hideKeyboard();//
}
//
function handleShowKeyboard(index) {
keyboard.value.open(true);
currIndex.value = index;
if (currIndex.value === 1) {
title.value = form.phone;
} else if (currIndex.value === 2) {
title.value = form.verificationCodeValue;
} else if (currIndex.value === 3) {
title.value = form.smsCode;
}
}
function handleClick(e) {
title.value = e.value;
if (currIndex.value === 1) {
form.phone = e.value;
} else if (currIndex.value === 2) {
form.verificationCodeValue = e.value;
} else if (currIndex.value === 3) {
form.smsCode = e.value;
}
}
</script>
<style lang="scss" scoped>
.code-image {
width: 200rpx;
height: 70rpx;
}
</style>

63
pages/user/login.vue

@ -8,17 +8,17 @@
<u-form :model="form" ref="phoneLoginForm" :error-type="['message']">
<u-form-item label="手机号码" prop="phone" label-width="160">
<u-input placeholder="请输入手机号" v-model="form.phone" type="number" @focus="handleFocus" @click="handleShowKeyboard(1)"></u-input>
<u-input placeholder="请输入手机号" v-model="form.phone" type="number"></u-input>
</u-form-item>
<u-form-item label="图形验证码" prop="verificationCodeValue" label-width="160">
<u-input placeholder="请输入计算结果" v-model="form.verificationCodeValue" type="number" @focus="handleFocus" @click="handleShowKeyboard(2)"></u-input>
<u-input placeholder="请输入计算结果" v-model="form.verificationCodeValue" type="number"></u-input>
<image slot="right" :src="renderData.imageBase64" mode="aspectFit" class="code-image" @click="getImageCode"></image>
</u-form-item>
<u-form-item label="验证码" prop="smsCode" label-width="160">
<u-input @focus="mixinInit.hasvalue(form, renderData)" placeholder="请输入验证码" v-model="form.smsCode" type="number" @click="handleShowKeyboard(3)"></u-input>
<u-button slot="right" type="primary" size="mini" v-show="mixinInit.dataObj.showPaste" @click="toPaste" class="u-m-r-20">粘贴</u-button>
<u-input @focus="mixinInit.hasvalue(form, renderData)" placeholder="请输入验证码" v-model="form.smsCode" type="number"></u-input>
<u-button slot="right" type="primary" size="mini" v-show="mixinInit.dataObj.showPaste" @click="mixinInit.setCode" class="u-m-r-20">粘贴</u-button>
<u-button slot="right" size="mini" v-if="mixinInit.dataObj.showInterval">{{ mixinInit.dataObj.interval }}</u-button>
</u-form-item>
@ -44,8 +44,6 @@
<image src="../../static/weixinIcon.png" mode="" style="width: 85rpx;height: 85rpx;"></image>
</view> -->
</view>
<master-keyboard ref="keyboard" keyboardtype="number" :randomNumber="true" :newCar="false" :defaultValue="title" @keyboardClick="handleClick" @toPaste="toPaste"></master-keyboard>
</template>
<script setup>
@ -58,13 +56,6 @@
const mixinInit = userMixin();
const phoneLoginForm = ref(null);
//
const keyboard = ref(null);
const currIndex = ref(null); //
const title = ref('');
const showKeyboard = ref(false);
const numberArr = ref(['1', '2', '3', '4', '5', '6', '7', '8', '9','0']);
const form = reactive({
phone: '',
verificationCodeValue: '', //
@ -90,21 +81,6 @@
});
}
//
function toPaste() {
uni.getClipboardData({
success(res) {
if (currIndex.value === 1) {
form.phone = res.data;
} else if (currIndex.value === 2) {
form.verificationCodeValue = res.data;
} else if (currIndex.value === 3) {
form.smsCode = res.data;
}
},
});
}
/**
* 登录
*/
@ -165,37 +141,6 @@
url: url
})
}
//
function handleFocus() {
uni.hideKeyboard();//
}
//
function handleShowKeyboard(index) {
keyboard.value.open(true);
currIndex.value = index;
if (currIndex.value === 1) {
title.value = form.phone;
} else if (currIndex.value === 2) {
title.value = form.verificationCodeValue;
} else if (currIndex.value === 3) {
title.value = form.smsCode;
}
}
function handleClick(e) {
title.value = e.value;
if (currIndex.value === 1) {
form.phone = e.value;
} else if (currIndex.value === 2) {
form.verificationCodeValue = e.value;
} else if (currIndex.value === 3) {
form.smsCode = e.value;
}
}
</script>
<style lang="scss" scoped>

32
store/task/mutations.js

@ -16,15 +16,15 @@ const mutations = {
setUpRealTasks(state, data) {
state.realTasks = [...data, ...state.realTasks];
let arr = [];
state.realTasks.forEach(item => {
const index = arr.findIndex(v => v.id === item.id);
if (index === -1) {
arr.push(item);
}
})
// let arr = [];
// state.realTasks.forEach(item => {
// const index = arr.findIndex(v => v.id === item.id);
// if (index === -1) {
// arr.push(item);
// }
// })
state.realTasks = [...arr];
// state.realTasks = [...arr];
},
/**
@ -35,15 +35,15 @@ const mutations = {
setDownRealTasks(state, data) {
state.realTasks = [...state.realTasks, ...data];
let arr = [];
state.realTasks.forEach(item => {
const index = arr.findIndex(v => v.id === item.id);
if (index === -1) {
arr.push(item);
}
})
// let arr = [];
// state.realTasks.forEach(item => {
// const index = arr.findIndex(v => v.id === item.id);
// if (index === -1) {
// arr.push(item);
// }
// })
state.realTasks = [...arr];
// state.realTasks = [...arr];
},
/**

Loading…
Cancel
Save