账号左划删除

master
educoder_weapp 5 years ago
parent 57aa083a00
commit b42f4ca2e5

File diff suppressed because one or more lines are too long

@ -3,7 +3,8 @@ const app = getApp();
Page({ Page({
data: { data: {
eduImgDir: global.config.eduImgDir eduImgDir: global.config.eduImgDir,
buttons:[{text:"删除",type:"warn"}]
}, },
onLoad: function (options) { onLoad: function (options) {
@ -58,7 +59,24 @@ Page({
this.setData({ accounts, user: res.user, currentAccountSaved, currentAccount,loading:0}); this.setData({ accounts, user: res.user, currentAccountSaved, currentAccount,loading:0});
}) })
}, },
removeAccount(e){ deleteAccount({user_id}){
accountManager.removeAccount({user_id});
if(this.data.user.user_id==user_id){
accountManager.clearCurrentAccount();
app.client.session.cookies = "";
app.client.synch = 0;
}
},
removeAccount2(e){
console.log(e);
let { currentTarget: { dataset: { id: user_id } } } = e;
this.deleteAccount({user_id});
setTimeout(()=>{
this.refresh();
},300);
},
removeAccount1(e){
console.log(e); console.log(e);
let { currentTarget: { dataset: { id: user_id } } } = e; let { currentTarget: { dataset: { id: user_id } } } = e;
var info = this.data.user.user_id == user_id?'退出登录并移除':"移除此账号"; var info = this.data.user.user_id == user_id?'退出登录并移除':"移除此账号";
@ -67,12 +85,7 @@ Page({
success:res=>{ success:res=>{
if(res.tapIndex==0){ if(res.tapIndex==0){
console.log(user_id); console.log(user_id);
accountManager.removeAccount({user_id}); this.deleteAccount({user_id});
if(this.data.user.user_id==user_id){
accountManager.clearCurrentAccount();
app.client.session.cookies = "";
app.client.synch = 0;
}
this.refresh(); this.refresh();
} }
} }

@ -1,4 +1,6 @@
{ {
"usingComponents": {}, "usingComponents": {
"mp-slideview": "/weui-miniprogram/slideview/slideview"
},
"navigationBarTitleText": "切换账号" "navigationBarTitleText": "切换账号"
} }

@ -1,12 +1,15 @@
<page-meta> <page-meta>
<navigation-bar loading="{{loading}}"/> <navigation-bar loading="{{loading}}" />
</page-meta> </page-meta>
<view> <view>
<view class="message single-line {{showMessage&&message?'':'hidden'}}"> <view class="message single-line {{showMessage&&message?'':'hidden'}}">
{{message}} {{message}}
</view> </view>
<view wx:for="{{accounts}}" class="account" data-id="{{item.user_id}}" bindtap="switchAccount" bindlongpress="removeAccount" wx:key="user_id"> <mp-slideview wx:for="{{accounts}}" data-id="{{item.user_id}}" buttons="{{buttons}}"
bindtap="switchAccount" bindlongpress="removeAccount1" bindbuttontap="removeAccount2"
wx:key="user_id">
<view class="account" >
<image src="{{eduImgDir}}{{item.image_url}}" class="avatar"></image> <image src="{{eduImgDir}}{{item.image_url}}" class="avatar"></image>
<view class="info"> <view class="info">
<view class="name">{{item.name}}</view> <view class="name">{{item.name}}</view>
@ -16,10 +19,10 @@
<icon type="success_no_circle" color="#00b0f0"></icon> <icon type="success_no_circle" color="#00b0f0"></icon>
</view> </view>
</view> </view>
</mp-slideview>
<view class="empty" wx:if="{{accounts.length==0}}"> <view class="empty" wx:if="{{accounts.length==0}}">
<text>暂无账号</text> <text>暂无账号</text>
</view> </view>
<button class="addAccount" type="main" bindtap="addAccount">添加账号</button> <button class="addAccount" type="main" bindtap="addAccount">添加账号</button>
<button class="nav-back" type="main" plain="1" bindtap="navBack">返回</button> <button class="nav-back" type="main" plain="1" bindtap="navBack">返回</button>
<view class="tip">长按移除</view>
</view> </view>

@ -46,12 +46,6 @@
.nav-back{ .nav-back{
margin-top: 8px; margin-top: 8px;
} }
.tip{
font-size: 12px;
text-align: center;
margin-top: 8px;
color: dimgray;
}
.empty{ .empty{
text-align: center; text-align: center;
color: dimgray; color: dimgray;

@ -35,7 +35,7 @@ Component({
if(!this.checkInput()) if(!this.checkInput())
return; return;
let {remarks, name, school_id} = this.data; let {remarks, name, school_id} = this.data;
let content = name + remarks?""+remarks:''; let content = name + (remarks?""+remarks:'');
wx.showLoading({ wx.showLoading({
title: '检查内容中...' title: '检查内容中...'
}) })

@ -22,7 +22,7 @@
} }
.departments{ .departments{
overflow: scroll; overflow: scroll;
max-height: 36vh; max-height: 210px;
transition: 1px all ease; transition: 1px all ease;
} }
.departments.hidden{ .departments.hidden{
@ -31,4 +31,6 @@
.department{ .department{
padding: 4px; padding: 4px;
padding-left: 22px; padding-left: 22px;
line-height: 20px;
height: 20px;
} }

@ -1,7 +1,7 @@
const app = getApp(); const app = getApp();
Page({ Page({
data: { data: {
current: 1, current: 0,
content:"加载中...", content:"加载中...",
titles: ["任务描述", "代码文件", "测评结果"], titles: ["任务描述", "代码文件", "测评结果"],
can_use_editor:wx.canIUse("editor") can_use_editor:wx.canIUse("editor")
@ -48,10 +48,11 @@ Page({
this.oldLines = this.lines; this.oldLines = this.lines;
this.lines = this.content.split(/\n/g); this.lines = this.content.split(/\n/g);
if(this.oldLines.length+1==this.lines.length){ if(this.oldLines.length+1==this.lines.length){
for(var i=this.oldLines.length;i>=0;i--){ for(var i=this.oldLines.length-1;i>=0;i--){
if(this.lines[i+1]!=this.oldLines[i]){ if(this.lines[i+1]!=this.oldLines[i]){
let indent = this.oldLines[i].length - this.oldLines[i].trimStart().length; let match = this.lines[i].match(/^\s+/);
this.editor.insertText({text:" ".repeat(indent)}); if(match)
this.editor.insertText({text:match[0]});
break; break;
} }
} }

@ -30,7 +30,7 @@
"skeletonGenerateFilesWithoutConfirm": true "skeletonGenerateFilesWithoutConfirm": true
}, },
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "2.10.4", "libVersion": "2.11.0",
"appid": "wxc5c2b711f23f3a1d", "appid": "wxc5c2b711f23f3a1d",
"projectname": "educoder_weapp", "projectname": "educoder_weapp",
"debugOptions": { "debugOptions": {
@ -153,6 +153,20 @@
"pathName": "task/pages/task/task", "pathName": "task/pages/task/task",
"query": "identifier=ji2wy8sqkou5", "query": "identifier=ji2wy8sqkou5",
"scene": null "scene": null
},
{
"id": -1,
"name": "account/pages/profile/school_select/school_select",
"pathName": "account/pages/profile/school_select/school_select",
"query": "course_id=5876",
"scene": null
},
{
"id": -1,
"name": "account/pages/profile/profile",
"pathName": "account/pages/profile/profile",
"query": "course_id=5876",
"scene": null
} }
] ]
} }

Loading…
Cancel
Save