A 支持选取微信头像

master
educoder_weapp 5 years ago
parent 9d1cbbeee4
commit 26ddc8d992

@ -1,3 +1,11 @@
## v0.16.5
* A 头像安全检查
* U 信息安全检查速度
## v0.16.4
* A 试卷答题时网络不好情况处理
* A 课堂界面兼容iphone X
## v0.16.3
* U 优化项目结构,主包压缩一半

@ -0,0 +1,6 @@
{
"permissions": {
"openapi": [
]
}
}

@ -0,0 +1,18 @@
const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
let {name, data} = event;
const wxContext = cloud.getWXContext()
switch (name) {
case 'getOpenData': {
return cloud.getOpenData(data);
}
default: {
return
}
}
}

@ -0,0 +1,14 @@
{
"name": "cloudapi",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"wx-server-sdk": "~2.0.2"
}
}

@ -14,8 +14,6 @@ exports.main = (event, context) => {
const wxContext = cloud.getWXContext()
return {
event,
context,
openid: wxContext.OPENID,
appid: wxContext.APPID,
unionid: wxContext.UNIONID,

@ -4,7 +4,9 @@
"wxacode.get",
"wxacode.getUnlimited",
"security.msgSecCheck",
"security.imgSecCheck"
"security.imgSecCheck",
"search.siteSearch",
"search.submitPages"
]
}
}

@ -49,7 +49,10 @@ exports.main = async (event, context) => {
}
}
case 'getOpenData': {
return getOpenData(event)
return cloud.getOpenData(data);
}
case "search.siteSearch":{
return cloud.openapi.search.siteSearch(data);
}
default: {
return
@ -87,8 +90,3 @@ async function getWXACode(data) {
});
}
async function getOpenData(event) {
return cloud.getOpenData({
list: event.openData.list,
})
}

@ -1,6 +1,7 @@
const app = getApp();
import {throttle} from "../../../../js/utils";
const risk_message = "检测到内容含有敏感词汇";
function msgSecCheck({name="", remarks=""}){
let content = name+","+ remarks;
console.log("msgsecCheck", content);
@ -11,7 +12,7 @@ function msgSecCheck({name="", remarks=""}){
this.tmp_promise.then(res=>{
if(res.errCode==87014){
wx.showToast({
title: risk_message,icon:"none",duration:4000
title: risk_message,icon:"none",duration:2600
})
}
})

@ -13,7 +13,7 @@ function msgSecCheck({name, nickname}){
this.tmp_promise.then(res=>{
if(res.errCode==87014){
wx.showToast({
title: risk_message,icon:"none",duration:4000
title: risk_message,icon:"none",duration:2600
})
}
})
@ -52,6 +52,9 @@ Page({
this.setData({name: value});
this.throttledMsgSecCheck(this.data);
},
onGetUserInfo(e){
console.log(e);
},
setInfo(res){
let locations = Object.keys(locationData);
let location_index = locations.indexOf(res.location);
@ -230,9 +233,13 @@ Page({
},
saveInfo(value){
wx.showLoading({
title: '提交中'
});
value.gender = parseInt(value.gender);
this.msgSecCheck(value).then(res=>{
if(res.errCode==87014){
wx.hideLoading();
wx.showModal({
content: risk_message,showCancel:false
})
@ -241,6 +248,7 @@ Page({
.then(res => {
app.syncUser({refresh:1});
res.message = "更新成功";
wx.hideLoading();
app.showMsg(res);
setTimeout(() => {
wx.navigateBack({
@ -248,10 +256,12 @@ Page({
})
}, 420);
}).catch(e => {
wx.hideLoading();
this.showError(e);
})
}
}).catch(e=>{
wx.hideLoading();
wx.showToast({
title: '出错了\n︿',icon:"none"
});
@ -260,7 +270,6 @@ Page({
},
onTap(e){
;
let { target: { id } } = e;
if (id) {
if ((id == 'name' || id == "gender") && this.data.authen)

@ -67,4 +67,5 @@
<text>*我们确保您所提供的信息均处于严格保密状态,不会泄露</text>
</view>
</view>
<button wx:if="{{false}}" open-type="getUserInfo" bindgetuserinfo="onGetUserInfo" lang="zh_CN" type="secondary">使用微信信息</button>
<add-department bindsuccess="refreshDepartments" school_id="{{school_id}}" school_name="{{school_name}}" show="{{showAddDepartment}}"/>

@ -9,18 +9,31 @@ wx.cloud.init({
App({
globalData: {
versionCode: config.versionCode,
debug: config.debug
debug: config.debug,
openid:wx.getStorageSync('openid')
},
client,
openapi(name){
return ({success, fail, complete, ...data})=>{
return ({success, fail, complete, ...data}={})=>{
return this.callOpenapi({name, data, success,fail, complete});
}
},
cloudapi(name){
return ({success, fail, complete, ...data})=>{
return this.callCloudfunction({
name:"cloudapi", data:{name, data}, success, fail, complete
});
}
},
callOpenapi({name, data, success, fail, complete}){
return this.callCloudapi({name:"openapi", data:{name, data}, success, fail, complete});
return this.callCloudfunction({name:"openapi", data:{name, data}, success, fail, complete});
},
cloudfunction(name){
return ({success, fail, complete, ...data}={})=>{
return this.callCloudfunction({name, data, success, fail, complete});
}
},
callCloudapi({name, data, success, fail, complete}){
callCloudfunction({name, data, success, fail, complete}){
return new Promise((resolve, reject)=>{
return wx.cloud.callFunction({name, data,
success:res=>{
@ -42,15 +55,15 @@ App({
syncUser(options) { return client.syncUser(options) },
updateUserInfo(info){return client.updateUserInfo(info)},
onLaunch: function (options) {
if(options.scene==1129){
if(options.scene==1129||options["user-agent"]=="mpcrawler"){
this.api("accounts.login")(global.accountManager.testAccount)
.then(res=>{
let account = { ...res, ...global.accountManager.testAccount};
global.accountManager.setCurrentAccount(account);
});
wx.reportMonitor('1', 1);
global.realTimeLog.info("爬虫访问");
global.realTimeLog.setFilterMsg("wxcrawl");
global.realTimeLog.info("爬虫访问", options);
global.realTimeLog.setFilterMsg("mpcrawl");
}
if (options.referrerInfo && options.referrerInfo.appId) {
var db = wx.cloud.database();
@ -83,6 +96,16 @@ App({
})
}
}).catch(e=>{});
if(!this.globalData.openid){
this.cloudfunction("login")()
.then(res=>{
this.globalData.openid = res.openid;
wx.setStorage({
data: res.openid,
key: 'openid',
})
})
}
},
onShow() {
@ -156,3 +179,4 @@ function toAbsPath(current, path) {
return path;
}
*/

@ -106,10 +106,8 @@ Component({
},
update_identities: function ({ detail: { value } }) {
var data = {assistant_professor:"", professor:"",student:""}
;
for(var identity of value)
data[identity] = 1
;
this.setData(data)
},
join_course () {
@ -130,8 +128,10 @@ Component({
this.triggerEvent("success");
this.onCancel();
})
.catch(app.showError)
.catch(e=>{
e.message =e.message||'未知错误';
app.showError(e);
})
}
}
})

@ -16,7 +16,7 @@ Component({
}
},
attached(){
this.refresh().finally(()=>{
this.refresh().then(()=>{
this.loaded = true;
})
},

@ -5,11 +5,9 @@ const developUrl = "https://test-newweb.educoder.net";
const trialUrl = "https://pre-newweb.educoder.net";
const releaseUrl = "https://www.educoder.net";
let _version = "0.16.4";
let _version = "0.16.5";
var eduUrl = releaseUrl;
/**
* A 试卷答题时网络不好情况处理
* A 课堂界面兼容iphone X
*/
export function switchEnv(env) {

@ -26,10 +26,8 @@ Component({
methods: {
onChoose(e){
;
},
onChange(e){
;
let {detail:{value}} = e;
this.sort_type = value?'id':'';
this.refresh();
@ -39,7 +37,6 @@ Component({
let {sort_type=''} = this;
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});
if(!this.imageMap)
@ -53,17 +50,19 @@ Component({
else
app.api("courses.students")({course_id, limit:10000})
.then(res=>{
;
var students;
if(this.imageMap)
students = res.students.map(i=>{
i.image_url = this.imageMap.get(i.user_id);
return i;
})
if(res.students.length>0)
students = [{letter:"#", items:res.students}];
else
students = [];
var {students_count} = res;
this.setData({ students, students_count});
})
});
let ext = {course_id, course_identity};
this.setData({ext});
}

@ -7,7 +7,7 @@
<view class="switch-wrp">
<switch color="#00b0f0" bindchange="onChange">按学号排序</switch>
</view>
<navigator wx:if="{{course_identity&&course_identity<5}}" class='invite' hover-class="none" url="/course/pages/course_invite/course_invite?course_id={{course_id}}"><button class="invite-button" size="mini" type="main">邀请学生</button></navigator>
<navigator wx:if="{{course_identity&&course_identity<5}}" class='invite' hover-class="none" url="/course/pages/course_invite/course_invite?course_id={{course_id}}"><button class="invite-button" size="mini" type="secondary">邀请学生</button></navigator>
</view>
</mp-index-list>

@ -4,8 +4,8 @@
<text>教师人数:</text>
<text class="count">{{teacher_list_size}}</text>
</view>
<navigator hover-class="none" url="/course/pages/teacher_apply/teacher_apply?course_id={{course_id}}" wx:if="{{course_identity&&course_identity<=2}}">
<mp-badge wx:if="{{apply_size>0}}"/>
<navigator hover-class="none" url="/course/pages/teacher_apply/teacher_apply?course_id={{course_id}}" wx:if="{{course_identity&&course_identity<=2&&apply_size>0}}">
<mp-badge />
<text class="apply-text">待审批({{apply_size}})</text>
</navigator>
</view>

@ -37,6 +37,7 @@
display: flex;
justify-content: center;
align-items: center;
line-height: 22px;
}
.tips{
display: flex;

@ -176,10 +176,14 @@ Page({
attendance({ show = 1 }) {
app.api("users.attendance")()
.then(res => {
this.refresh();
res.message = "签到成功";
if (show)
app.showMsg(res);
}).catch(e=>{
if(show)
app.showError(e);
}).finally(()=>{
this.refresh();
})
},
enterUserinfo(){

@ -4,7 +4,7 @@
"add-tips": "/components/add-tips/add-tips",
"my-course":"./my_course/my_course",
"my-shixun":"./my_shixun/my_shixun",
"my-path":"../my_path/my_path"
"my-path":"./my_path/my_path"
},
"navigationBarTextStyle": "white",
"navigationBarTitleText": "我的",

@ -64,7 +64,7 @@ Component({
addCourse() {
if(app.user().user_id==2)
return wx.showToast({
title: '请先登录'
title: '请先登录',icon:"none"
});
return this.setData({ showModal: 1 });
/*

@ -14,7 +14,7 @@
</form>
<nav-bar list="{{list}}" current="{{current}}" bindchange="onTapNav"/>
<scroll-view class="body" scroll-y="1" lower-threshold="160" bindscrolltolower="_onReachBottom" scroll-top="{{scrollTop}}">
<view wx:for="{{results}}" class="search-item-wrap">
<view wx:for="{{results}}" class="search-item-wrap" wx:key="id">
<search-item data="{{item}}"/>
</view>
</scroll-view>

@ -8,21 +8,34 @@ Page({
},
touchStart(e) {
if(!this.mycropper)
return wx.showToast({
title: '请先选取图片',icon:"none"
})
this.mycropper.touchStart(e)
},
touchMove(e) {
this.mycropper.touchMove(e)
},
touchEnd(e) {
this.mycropper.touchEnd(e)
},
onGetUserInfo(e){
console.log(e);
let {detail:{userInfo}} = e;
if(userInfo.avatarUrl){
let path = userInfo.avatarUrl;
this.mycropper.pushOrign(path);
}else{
wx.showToast({
title: '微信头像获取失败',icon:"none"
})
}
},
async _checkImg({path}){
let cloudPath = "images/avatars/"+ path.replace(/[\/\\:]/g, "_");
let match = path.match(/(\.[^\.]*?)$/)
if(match)
var ext = match[0];
else
var ext = ".jpg";
let cloudPath = "images/temp/"+ app.globalData.openid + "-" + Date.now() + ext;
let res = await wx.cloud.uploadFile({
cloudPath,
filePath: path
@ -33,7 +46,6 @@ Page({
checkImg({path}){
if(this.promise&&path==this.tmp_path)
return this.promise;
let buffer = wx.getFileSystemManager().readFileSync(path);
this.promise = this._checkImg({path});
this.tmp_path = path;
this.promise.then(res=>{
@ -47,35 +59,49 @@ Page({
return this.promise;
},
onConfirm(){
this.setData({submitting:1});
if(!this.mycropper||!this.mycropper.src)
return wx.showToast({
title: '请先选取图片',icon:"none"
})
let {src} = this.mycropper;
let {croperTarget} = this.mycropper;
wx.showLoading({
title: '检查图片中...',
})
this.checkImg({path: src}).then(res=>{
this.checkImg({path: croperTarget}).then(res=>{
if(res.errCode==0)
this.startUpload();
else if(res.errCode==87014){
wx.hideLoading();
wx.showModal({
content:rich_message,showCancel: false
})
});
this.setData({submitting:0});
}else{
wx.showToast({
title: '发生了未知错误',icon:"none"
title: '发生了未知错误,请重试',icon:"none"
});
this.promise = null;
let {croperTarget} = this.mycropper;
this.checkImg({path:croperTarget});
this.setData({submitting:0});
wx.reportMonitor('2', 1);
global.realTimeLog.error("未知错误 checkImg1");
global.realTimeLog.error("未知错误 checkImg1", res);
global.realTimeLog.setFilterMsg("unexpected");
}
}).catch(e=>{
wx.hideLoading();
app.showError(e);
wx.showToast({
title: '请求超时,请重试',icon:"none"
});
this.promise = null;
let {croperTarget} = this.mycropper;
this.checkImg({path:croperTarget});
this.setData({submitting:0});
wx.reportMonitor('2', 1);
global.realTimeLog.error("未知错误 checkImg2");
global.realTimeLog.error("未知错误 checkImg2", e);
global.realTimeLog.setFilterMsg("unexpected");
})
},
@ -93,10 +119,11 @@ Page({
});
},
startUpload() {
this.setData({submitting:1});
this.mycropper.getCropperImage((avatar) => {
if (avatar) {
wx.showLoading({
title: '上传中',
title: '上传头像中',
});
this.uploadAvartar(avatar)
.then(res => {
@ -104,6 +131,7 @@ Page({
wx.showToast({
title: '更改成功',
});
this.setData({submitting:0});
setTimeout(()=>{
wx.navigateBack({
delta: 1
@ -115,12 +143,14 @@ Page({
icon: "none"
});
wx.hideLoading();
this.setData({submitting:0});
});
} else {
wx.showToast({
title: '图片截取失败',
icon: "none"
});
this.setData({submitting:0});
}
})
},
@ -165,11 +195,11 @@ Page({
this.mycropper = new WeCropper(cropperOpt);
this.mycropper
.on('beforeImageLoad', (ctx) => {
wx.showLoading({title: '上传中'})
wx.showLoading({title: '图片加载中'})
})
.on('imageLoad', (ctx) => {
let {src} = this.mycropper;
this.checkImg({path:src});
let {croperTarget} = this.mycropper;
this.checkImg({path:croperTarget});
wx.hideLoading();
})
.updateCanvas();

@ -8,8 +8,11 @@
<button class="upload" type="main" plain="1" bindtap="chooseImage">
重选图片
</button>
<button type="main" class="getCropperImage" bindtap="onConfirm">
<button type="main" disabled="{{submitting}}" class="getCropperImage" bindtap="onConfirm">
确认
</button>
<button type="main" plain open-type="getUserInfo" bindgetuserinfo="onGetUserInfo">
微信头像
</button>
</view>
</block>

@ -25,5 +25,9 @@ height: 100%
.operations>button{
flex: auto;
border-radius: 0;
white-space: nowrap;
display: flex;
justify-content: center;
align-items: center;
}

@ -3,7 +3,7 @@
"rules": [
{
"action":"allow",
"page":"path/pages/path/path",
"page":"markdown/path/path/path",
"params":[
"subject_id"
],
@ -11,7 +11,7 @@
},
{
"action": "allow",
"page": "shixun/pages/shixun/shixun",
"page": "markdown/shixun/shixun/shixun",
"params": [
"identifier"
],
@ -23,12 +23,20 @@
},
{
"action":"disallow",
"page":"task/pages/task/task"
"page":"markdown/task/task/task"
},
{
"action":"disallow",
"page":"account/pages/accounts/accounts"
},
{
"action":"disallow",
"page":"course/pages/course/course"
},
{
"action":"disallow",
"page":"pages/my_courses/my_courses"
},
{
"action": "allow",
"page": "*"

@ -6,7 +6,7 @@
"ignore": []
},
"setting": {
"urlCheck": true,
"urlCheck": false,
"es6": true,
"enhance": true,
"postcss": true,

Loading…
Cancel
Save