* A 支持填入微信个人信息

master
educoder_weapp 5 years ago
parent 946a2e57a7
commit deb3c86769

@ -1,3 +1,7 @@
## v0.16.8
* A 支持填入微信个人信息
* F 使用用户名登录时账号判断错误而无法登录
## v0.16.7
* F 用户信息未完善时加入课堂bug

@ -69,7 +69,7 @@ async function getWXACodeUnlimited(data){
const fileExtension = (fileExtensionMatches && fileExtensionMatches[1]) || 'jpg'
return cloud.uploadFile({
cloudPath: `images/wxacode/${(page+"?"+scene).replace(/[\/?&]/g, "_")}.${fileExtension}`,
cloudPath: `images/wxacode/${(page+"?"+scene).replace(/[\/?=&]/g, "_")}.${fileExtension}`,
fileContent: wxacodeResult.buffer,
})
}
@ -85,7 +85,7 @@ async function getWXACode(data) {
const fileExtension = (fileExtensionMatches && fileExtensionMatches[1]) || 'jpg'
return cloud.uploadFile({
cloudPath: `images/wxacode/${path.replace(/[\/?&]/g,"_")}.${fileExtension}`,
cloudPath: `images/wxacode/${path.replace(/[\/?=&]/g,"_")}.${fileExtension}`,
fileContent: wxacodeResult.buffer,
});
}

@ -22,6 +22,9 @@ Page({
return this.setData({showtip:0});
}
let {action} = this.data;
if(action=="login")
// some use login to login, this case judge can be wrong
return this.setData({hasError:0});
let type = action=="register"?1:2;
if(this.cache.login==login&&this.cache.type==type) return;
app.api("accounts.valid_email_and_phone")({
@ -32,7 +35,7 @@ Page({
}
})
.then(res=>{
this.setData({hasError:0,error:""});
this.setData({hasError:0});
})
.catch(e=>{
var hasError = e.message.indexOf("网络")!=-1?2:1;

@ -1,6 +1,7 @@
{
"usingComponents": {
"iconfont":"/components/iconfont/iconfont"
"iconfont":"/components/iconfont/iconfont",
"mp-toptips":"/weui-miniprogram/toptips/toptips"
},
"navigationBarTitleText": "账号",
"navigationBarBackgroundColor": "#ffffff"

@ -1,9 +1,7 @@
<page-meta>
<navigation-bar title="{{action_text[action]}}" />
</page-meta>
<view class="head-error {{error?'':'hidden'}}">
<text class="single-line">{{error}}</text>
</view>
<mp-toptips msg="{{error}}" type="error" show="{{hasError}}" delay="0"/>
<view class="container">
<image class="logo {{logoLoaded?'':'hidden'}}" bindlongpress="login_test" src="{{attachDir}}751571" mode="aspectFit" bindload="onLogoLoad"></image>
<form class="account-form" bindsubmit="onSubmit">

@ -1,31 +1,14 @@
page{
min-height: 100%;
overflow: hidden;
position: relative;
background: white;
}
.head-error{
position: fixed;
background: #cb3b6a;
color: white;
top: 0;
left: 0;
right: 0;
transition: 0.6s all ease;
height: 28px;
display: flex;
font-size: 14px;
justify-content: center;
align-items: center;
}
view.head-error.hidden{
opacity: 0;
max-height: auto;
min-height: 100vh;
}
.logo{
width:64px;
height: 64px;
width:54px;
height: 54px;
display: block;
margin: 30px auto 8px auto;
padding: 48px 0 4px 0;
margin: 0 auto;
transition: 1s all ease;
}
.checkbox-wrap,.input-wrap{
@ -73,7 +56,8 @@ switch.no-login{
}
.actions{
position: relative;
margin: 0 26px
margin: 0 26px;
height: 160px;
}
.actions button{
transition: 1s all ease;
@ -84,18 +68,18 @@ switch.no-login{
transition: 1s all ease;
}
.actions>.pos1{
top: 22px;
top: 26px;
}
.pos1>button{
background: #00b0f0;
color:white;
}
.pos1>button[disabled]{
background-color: #00b0f0aa!important;
background-color: #00b0f096!important;
color: white!important;
}
.actions>.pos2{
top:64px;
top:74px;
}
.pos2>button{
color: #00b0f0;
@ -116,7 +100,7 @@ switch.no-login{
border: none!important;
}
.foot{
position: fixed;
position: absolute;
bottom:0px;
width: 100%;
display: flex;

@ -53,7 +53,45 @@ Page({
this.throttledMsgSecCheck(this.data);
},
onGetUserInfo(e){
// 填入微信个人信息
console.log(e);
let {detail:{userInfo}} = e;
if(!userInfo)
return wx.showToast({
title: '获取信息失败',icon:"none"
})
let {nickName:nickname, gender, province:location, city:location_city, avatarUrl} = userInfo;
if(gender)
gender = 1 - gender;
let location_index = this.data.locations.indexOf(location);
let cities = locationData[location] || locationData['北京'];
let city_index = cities.indexOf(location_city);
this.setData({nickname, gender, cities, location, location_city, city_index, location_index});
avatarUrl = "" //@todo
if(avatarUrl){
wx.showModal({
title:"提示",
content:"是否使用微信头像",
confirmText:"使用",
success: res=>{
if(res.confirm)
this.updateWechatAvatar({avatarUrl});
},
complete: ()=>{
wx.showToast({
title: '填入成功'
});
}
});
}else{
wx.showToast({
title: '填入成功'
});
}
},
updateWechatAvatar({avatarUrl}){
// @todo
},
setInfo(res){
let locations = Object.keys(locationData);
@ -146,6 +184,10 @@ Page({
this.pullDepartments({school_id,department_id});
},
catchAvatar(){
/*wx.showActionSheet({
itemList: ["更改头像", "使用微信头像"],
})*/
app.navigateTo({url:"{image_crop}"});
},
addDepartment(){
@ -273,7 +315,7 @@ Page({
let { target: { id } } = e;
if (id) {
if ((id == 'name' || id == "gender") && this.data.authen)
this.showError({ message: `重新实名认证以更改${id == "name" ? "姓名" : id == 'gender' ? "性别" : '此信息'}`, during: 1400 });
this.showError({ message: `到官网重新实名认证以更改${id == "name" ? "姓名" : id == 'gender' ? "性别" : '此信息'}`, during: 1400 });
this.setData({edited:1});
}
},

@ -2,5 +2,5 @@
"usingComponents": {
"add-department":"./add-department/add-department"
},
"navigationBarTitleText": "基本信息"
"navigationBarTitleText": "个人信息"
}

@ -1,14 +1,17 @@
<view class="profile">
<form bindtap="onTap" bindsubmit="onSubmit" bindreset="refresh">
<view class="sticky">
<view class="header">
<view class="error {{showError?'show':''}}"><text class="single-line">{{error}}</text></view>
<view wx:if="{{!edited}}">点击相应项编辑信息</view>
<button wx:else form-type="reset" size="mini" type="main">重置信息</button>
<button wx:if="{{!base_info_completed}}" open-type="getUserInfo" bindgetuserinfo="onGetUserInfo" type="main" size="mini" lang="zh_CN">填入微信个人信息</button>
<view wx:elif="{{!edited}}">点击相应项编辑信息</view>
<button wx:else form-type="reset" size="mini" type="main">重置修改</button>
<button class="submit" form-type="submit" size="mini" type="main">
<icon type="success_no_circle" color="white"></icon>
<text>保存</text>
</button>
</view>
</view>
<view class="form-item">
<text class="key">昵称头像</text>
<input class="value" id="nickname" placeholder="输入昵称" name="nickname" value="{{nickname}}" bindinput="updateNickName"></input>
@ -32,9 +35,9 @@
</view>
<view class="form-item">
<text>所在地</text>
<picker class="value" id="location-city" bindcolumnchange="onCitiesChange" bindchange="onLocationChange" range="{{[locations,cities]}}" value="{{[location_index, city_index]}}" mode="multiSelector">{{locations[location_index]}} {{cities[city_index]||'请选择'}}</picker>
<input hidden="1" disabled="1" name="location" value="{{locations[location_index]}}"></input>
<input hidden="1" disabled="1" name="location_city" value="{{cities[city_index]}}"></input>
<picker class="value" id="location-city" bindcolumnchange="onCitiesChange" bindchange="onLocationChange" range="{{[locations,cities]}}" value="{{[location_index, city_index]}}" mode="multiSelector">{{locations[location_index]||location||''}} {{cities[city_index]||location_city||'请选择'}}</picker>
<input hidden="1" disabled="1" name="location" value="{{locations[location_index]||location||''}}"></input>
<input hidden="1" disabled="1" name="location_city" value="{{cities[city_index]||location_city||''}}"></input>
</view>
<view class="gap"></view>
<view class="form-item">
@ -64,7 +67,7 @@
</view>
</form>
<view class="footer">
<text>*我们确保您所提供的信息均处于严格保密状态,不会泄露</text>
<text>*EduCoder将确保您所提供的信息均处于严格保密状态,不会泄露</text>
</view>
</view>
<button wx:if="{{false}}" open-type="getUserInfo" bindgetuserinfo="onGetUserInfo" lang="zh_CN" type="secondary">使用微信信息</button>

@ -5,7 +5,11 @@
.profile, page {
height: 100%;
}
.sticky{
top: 0;
position: sticky;
z-index: 10000;
}
.header {
display: flex;
align-items: center;
@ -23,7 +27,7 @@
bottom: 0;
right: 0;
transition: 0.72s all ease;
background: orange;
background: #fa5151;
color: white;
padding: 0 20px;
display: flex;
@ -58,6 +62,6 @@
.footer {
font-size: 24rpx;
text-align: center;
margin-top: 12px;
margin: 12px 0;
color: grey;
}

@ -3,7 +3,9 @@ import { client } from "./js/client";
wx.cloud.init({
traceUser: true,
env: "educoder"
env: "educoder",
success:console.log,
fail: console.error
});
App({
@ -60,7 +62,7 @@ App({
this.globalData.scene = options.scene;
if(options.scene==1129){
this.globalData.isCrawl = true;
this.cloudfunction("login")({mpcrawl: true});
// this.cloudfunction("login")({mpcrawl: true});
this.api("accounts.login")(global.accountManager.testAccount)
.then(res=>{
let account = { ...res, ...global.accountManager.testAccount};

@ -7,6 +7,7 @@
"backgroundColor": "#f5f5f5"
},
"usingComponents": {
"iconfont":"/components/iconfont/iconfont",
"require-login": "/components/require-login/require-login"
},
"pages": [

@ -1,11 +1,11 @@
@font-face {
font-family: 'iconfont'; /* project id 1656783 */
src: url('//at.alicdn.com/t/font_1656783_1qepxw56cybi.eot');
src: url('//at.alicdn.com/t/font_1656783_1qepxw56cybi.eot?#iefix') format('embedded-opentype'),
url('//at.alicdn.com/t/font_1656783_1qepxw56cybi.woff2') format('woff2'),
url('//at.alicdn.com/t/font_1656783_1qepxw56cybi.woff') format('woff'),
url('//at.alicdn.com/t/font_1656783_1qepxw56cybi.ttf') format('truetype'),
url('//at.alicdn.com/t/font_1656783_1qepxw56cybi.svg#iconfont') format('svg');
src: url('//at.alicdn.com/t/font_1656783_wv69r0ez2j.eot');
src: url('//at.alicdn.com/t/font_1656783_wv69r0ez2j.eot?#iefix') format('embedded-opentype'),
url('//at.alicdn.com/t/font_1656783_wv69r0ez2j.woff2') format('woff2'),
url('//at.alicdn.com/t/font_1656783_wv69r0ez2j.woff') format('woff'),
url('//at.alicdn.com/t/font_1656783_wv69r0ez2j.ttf') format('truetype'),
url('//at.alicdn.com/t/font_1656783_wv69r0ez2j.svg#iconfont') format('svg');
}
.iconfont {
display: inline-block;
@ -121,4 +121,10 @@
}
.icon-shezhi:before{
content: "\e625";
}
.icon-dengji:before{
content: "\e606";
}
.icon-chengyuan:before{
content: "\e62a";
}

@ -1,6 +1,6 @@
const cloudDir = "cloud://educoder.6564-educoder-1300855313/";
let _version = "0.16.7";
let _version = "0.16.8";
/**
*/
let { miniProgram:{ envVersion="release", version=_version}={}} = wx.getAccountInfoSync();

@ -11,6 +11,7 @@ Component({
type: Array,
value: [],
observer: function observer(newVal) {
console.log("observer list change", newVal)
var _this = this;
if (newVal.length === 0) return;
@ -30,6 +31,10 @@ Component({
ext:{
type:Object
},
key:{
type:String,
value:"user_id"
},
vibrated: {
type: Boolean,
value: true

@ -12,7 +12,8 @@
<view class="index_list_item" wx:for="{{list}}" wx:key="alpha" id="{{item.letter=='#'?'hash':item.letter}}">
<view class="index-group__title">{{item.letter}}</view>
<view class="index-group__list">
<view wx:for="{{item.items}}" wx:key="name"
<!--@todo wx:key-->
<view wx:for="{{item.items}}" wx:key="user_id"
class="index-group__item"
data-item="{{item}}"
bindtap="choose">

@ -35,10 +35,13 @@ Component({
refresh(){
let {course_id, course_identity} = this.data;
let {sort_type=''} = this;
wx.showLoading({
title: '加载中',
});
if(sort_type!='id')
app.api("weapps.courses.students")({course_id, limit:1000}).then(res=>{
var {students,students_count} = res;
this.setData({students,students_count});
this.setData({students,students_count}, wx.hideLoading);
if(!this.imageMap)
this.imageMap = new Map();
for(var item of students){
@ -61,7 +64,7 @@ Component({
else
students = [];
var {students_count} = res;
this.setData({ students, students_count});
this.setData({ students, students_count}, wx.hideLoading);
});
let ext = {course_id, course_identity};
this.setData({ext});

@ -57,7 +57,7 @@ class Client{
});
this.on("success","accounts.login", res=>{
this.synch=0;
this.user = {};
this.user = res;
this.save_cookies();
});
this.on("success", "accounts.register", res => {

@ -136,7 +136,7 @@ class AccountManager{
}
setCurrentAccount(account,sync=1){
this.currentAccount = account;
this.currentAccount.active = account.active||1; //登录保存 登录不保存 保存不登录 不保存不登录
this.currentAccount.active = account.active||1;
if (sync)
this.setStorage();
}
@ -211,7 +211,7 @@ export const accountManager = global.accountManager = new AccountManager();
export function getWXACodeUrl({url, scene}){
return global.config.imgDir + "wxacode/" + (url + "?" + scene).replace(/[\/?&]/g, "_") + ".jpeg";
return global.config.imgDir + "wxacode/" + (url + "?" + scene).replace(/[\/?=&]/g, "_") + ".jpeg";
}
//https://www.educoder.net/shixuns/ac46rzbw/challenges/3481
export function parseUrl({url}){

@ -18,6 +18,10 @@ Component({
key,
success: res=>{
this.setData({_nodes:res.data});
wx.setStorage({
data: {},
key,
})
},
});
return key;
@ -47,6 +51,7 @@ Component({
methods: {
handleTap(e){
console.log("onTap", e);
var {target:{dataset:{data}},currentTarget:{dataset:{data:_data}}} = e;
let {tag, attr} = _data;
if(tag=='navigator'&&attr.href){
@ -63,7 +68,8 @@ Component({
if(data&&data._e.tag=="code")
data={attr:{class:"h2w__pre"},child:[data],tag:"view",type:"tag",_e:{type:"tag",attr:{},tag:"pre", child:[data]}}
if(data&&data._e.tag=='pre'){
data = {theme:'light',child:[data],_e:{child:[data]}}
data = {theme:'light',child:[data],_e:{child:[data]}};
var key = "RICH_MD_STORAGE"
wx.setStorage({
key,data,success:res=>{
wx.navigateTo({

@ -260,7 +260,8 @@ Page({
this.checkTime();
},
onHide: function () {
this.updateFile();
if(this.content)
this.updateFile();
},
onShareAppMessage: function () {

@ -1,4 +1,6 @@
{
"component": true,
"usingComponents": {}
"usingComponents": {
}
}

@ -2,7 +2,10 @@
<image class="image" lazy-load src="{{eduUrl}}/{{data.pic}}"></image>
<view class="detail">
<view class="name"><rich-text nodes="{{data.title}}"/></view>
<view class="level">初级</view>
<view class="data-detail">
<view class="level"><iconfont type="dengji" size="17" fontsize="14" color="dimgrey"/>{{data.level}}</view>
<view class="level"><iconfont type="chengyuan" size="17" fontsize="14" color="dimgrey"/>{{data.study_count}}</view>
</view>
</view>
<view class="radio-wrp">
<view class="icon-wrp" catchtap="onTapRadio" >

@ -17,8 +17,12 @@
justify-content: space-between;
flex: auto;
}
.data-detail{
display: flex;
}
.level{
font-size: 12px;
margin-right: 10px;
}
.highlight{
color: #00b0f0;

@ -2,7 +2,6 @@
"navigationBarTitleText": "个人中心",
"enablePullDownRefresh": false,
"usingComponents": {
"iconfont":"/components/iconfont/iconfont",
"mp-icon":"/weui-miniprogram/icon/icon"
}
}

@ -53,6 +53,7 @@
<button open-type="feedback" class="nav" style="width:auto">
<iconfont class="icon" type="fankui" size="21" />小程序反馈
<text class="tip">有问题,来反馈</text>
<iconfont type="jinru" color="dimgrey" size="15" class="enter"></iconfont>
</button>
<button open-type="contact" class="nav" style="width:auto">

@ -1,7 +1,7 @@
<navigator class="bg{{data.id%7}} course" url="/course/pages/course/course?course_id={{data.id}}" bindlongpress="showAction">
<view wx:if="{{data.sticky}}" class="sticky"></view>
<view class="header">
<mp-icon class="action" icon="more" catchtap="showAction" type="field" color="white"/>
<view class="operations" catchtap="showAction">
<mp-icon icon="more" type="field" color="white"/>
</view>
<view class="body">
<image class="avatar" src="{{eduImgDir}}{{data.avatar_url}}" />

@ -19,19 +19,19 @@
.bg6{
background-image: linear-gradient(to bottom right, #3a1c71, #d76d77, #ffaf7b);/*#3a1c71, #d76d77, #ffaf7b*/
}
.header{
text-align: end;
}
.action{
width: 22px;
height: 18px;
padding: 1px 9px 0 0;
.operations{
position: absolute;
top: 0;
right: 0;
height: 30px;
width: 32px;
text-align: center;
}
.course{
color: white;
font-size:13px;
border-radius: 5px;
padding: 0px 2px 12px 8px;
padding: 17px 2px 11px 8px;
position: relative;
overflow: hidden;
}
@ -43,11 +43,12 @@
background: orange;
top: -6px;
left: -16px;
border-bottom: #f0f0f0 2px solid;
border-bottom: #f0f0f0 3px solid;
}
.body{
display: flex;
padding-right: 6px;
align-items: center;
}
.avatar{
@ -56,7 +57,7 @@
border-radius: 50%;
overflow: hidden;
flex: none;
margin: 0 16px 0 8px;
margin: 0 16px 4px 8px;
background: #eee; /*for out of network*/
}
.course-info{

@ -86,7 +86,16 @@ Component({
url: "/course/pages/course/course?course_id=" + id + "&course_name=" + course_name,
})
},
pullCourses: function ({ refresh = 0, showError=1} = {}) {
pullCourses: async function ({ refresh = 0, showError=1} = {}) {
if(refresh&&app.user().user_id==2){
// mock
this.setData({courses:[], status: 401, loading: false});
/*if(showError)
wx.showToast({
title: '请先登录哦',icon:"none"
})*/
return {courses:[]};
}
if (refresh) {
if (refresh == 1) {
this.options.page = 1;

@ -7,7 +7,7 @@
</view>
<view wx:if="{{courses.length==0&&!loading}}" class="none-content">
<image class="none-image" src="{{attachDir}}908959" mode="aspectFit"></image>
<text class="none-text">暂时没有课堂</text>
<text class="none-text">{{user_id==2?'登陆后查看课堂':'暂时没有课堂'}}</text>
<button bindtap="onTapButton" wx:if="{{user_id==2||current_cate==0}}" type="main" class="login-button">{{user_id==2?'登录':'加入课堂'}}</button>
</view>
<view wx:for="{{courses}}" wx:key="id" class="course-wrap">

@ -189,7 +189,7 @@ Page({
}
})
},
initCanvas(src) {
initCanvas(src="") {
const { cropperOpt } = this.data;
Object.assign(cropperOpt, { src });
this.mycropper = new WeCropper(cropperOpt);
@ -225,11 +225,8 @@ Page({
},
onLoad(option) {
this.setCanvasOptions();
const { src } = option;
if (src) {
this.initCanvas(src);
} else {
this.chooseImage({navback:1})
}
const { src="" } = option;
this.initCanvas(src);
this.chooseImage({navback:1})
}
})
Loading…
Cancel
Save