提交 93a71d4f 编写于 作者: F fancy

修改codereview的问题

上级 f9a5e07c
......@@ -19,7 +19,6 @@ Page({
onLoad: function (options) {
var id = options.id;
var title = decodeURIComponent(options.title);
console.log("进入 cms web页面, id:", id);
if (id && id != '') {
var url = api.cmsWebUrl(id);
var who = wx.getStorageSync('who');
......@@ -30,7 +29,6 @@ Page({
url = url + '&'+tokenName+'=' + token;
}
url = url + '#wechat_redirect';
console.log('信息页码 url', url);
this.setData({
workUrl: url,
navTitle: title
......
......@@ -16,7 +16,6 @@ Page({
//连接中心服务器获取应用连接地址
connectCenterServer: function() {
api.centerServer().then(data => {
console.log('应用服务器信息', data);
api.setDistribute(data);
this.checkIsLogin();
}).catch( err => {
......@@ -31,7 +30,6 @@ Page({
//检查是否过期
api.who().then(data => {
if(data.token && data.token != "") {
console.log('认证信息未过期,当前用户信息:', data);
wx.setStorageSync('who', data);
//跳转到首页
wx.switchTab({
......@@ -96,14 +94,12 @@ Page({
util.toast("请输入密码!");
return;
}
let param = {
const param = {
credential: this.data.name,
password: this.data.password
}
console.log(param);
api.login(param)
.then(data => {
console.log('登录成功', data);
wx.setStorageSync('who', data);
util.toast('登录成功~');
//跳转到首页
......@@ -130,31 +126,20 @@ Page({
// 体验账号登录
demoLogin: function(event) {
let no = event.currentTarget.dataset.no;
var param = {};
const param = {
password: 'o2'
};
if (no == '1') {
param = {
credential: '开发部经理',
password: 'o2'
}
param['credential'] = '开发部经理'
} else if (no == '2') {
param = {
credential:'开发部员工1',
password: 'o2'
}
param['credential'] = '开发部员工1'
} else if (no == '3') {
param = {
credential:'公司领导1',
password: 'o2'
}
param['credential'] = '公司领导1'
} else if (no == '4') {
param = {
credential:'办公室主任',
password: 'o2'
}
param['credential'] = '办公室主任'
}
api.login(param)
.then(data => {
console.log('登录成功', data);
wx.setStorageSync('who', data);
util.toast('登录成功~');
//跳转到首页
......
......@@ -33,18 +33,23 @@ Page({
this.openDraft(options.draft, title);
}
},
// 打开工作表单 草稿
openDraft: function(draft, title = '') {
var url = api.workDraftUrl(draft);
var who = wx.getStorageSync('who');
var tokenName = wx.getStorageSync('tokenName');
var token = ''
// 生成url
_urlWithToken: function(url) {
let newUrl = url;
const who = wx.getStorageSync('who');
const tokenName = wx.getStorageSync('tokenName');
let token = ''
if (who && who.token) {
token = who.token;
url = url + '&'+tokenName+'=' + token;
newUrl = newUrl + '&'+tokenName+'=' + token;
}
url = url + '#wechat_redirect';
console.log('草稿页面 url', url);
return newUrl + '#wechat_redirect';
},
// 打开工作表单 草稿
openDraft: function(draft, title = '') {
let url = api.workDraftUrl(draft);
url = this._urlWithToken(url);
this.setData({
workUrl: url,
navTitle: title
......@@ -52,16 +57,8 @@ Page({
},
// 打开工作表单 未完成的工作
openWorkUrl: function(work, title = '') {
var url = api.workWebUrl(work);
var who = wx.getStorageSync('who');
var tokenName = wx.getStorageSync('tokenName');
var token = ''
if (who && who.token) {
token = who.token;
url = url + '&'+tokenName+'=' + token;
}
url = url + '#wechat_redirect';
console.log('待办页面 url', url);
let url = api.workWebUrl(work);
url = this._urlWithToken(url);
this.setData({
workUrl: url,
navTitle: title
......@@ -69,16 +66,8 @@ Page({
},
// 打开工作表单 已结束的工作
openWorkCompletedUrl: function(workcompletedid, title = '') {
var url = api.workCompletedWebUrl(workcompletedid);
var who = wx.getStorageSync('who');
var tokenName = wx.getStorageSync('tokenName');
var token = ''
if (who && who.token) {
token = who.token;
url = url + '&'+tokenName+'=' + token;
}
url = url + '#wechat_redirect';
console.log('待办页面 url', url);
let url = api.workCompletedWebUrl(workcompletedid);
url = this._urlWithToken(url);
this.setData({
workUrl: url,
navTitle: title
......
......@@ -56,15 +56,14 @@ function request(method, url, param, isShowLoading) {
//设置应用地址到存储中
function setDistribute(distribute) {
wx.removeStorageSync('webServer');
wx.removeStorageSync('assembles');
wx.removeStorageSync('tokenName');
var webServer = distribute.webServer || {}
wx.setStorageSync('webServer', webServer);
var assembles = distribute.assembles || {}
wx.setStorageSync('assembles', assembles);
var tokenName = distribute.tokenName || 'x-token'
wx.setStorageSync('tokenName', tokenName);
['webServer', 'assembles', 'tokenName'].forEach( t => {
wx.removeStorageSync(t);
if (t === 'tokenName') {
wx.setStorageSync(t, distribute[t] || 'x-token');
} else {
ws.setStorageSync(t, distribute[t] || {});
}
});
}
// 获取模块的baseUrl
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册