提交 1f7019f6 编写于 作者: Z zhaoshuangshi

new页面=》字数限制规范、代码格式化规范

上级 4610d9b5
......@@ -2,163 +2,143 @@ import Page from '../base/login'
// pages/new/new.js
Page({
/**
* 页面的初始数据
*/
data: {
// PageCur:'code'
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
emptyCheck(content,num,language){
console.log('这是调用了')
if(content.length==0){
wx.showModal({
title: '必填项缺失',
content: `${language}内容不能为空`,
showCancel:false,
success: function(res) {
if (res.confirm) {
console.log('用户点击确定')
/**
* 页面的初始数据
*/
data: {
// PageCur:'code'
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
emptyCheck(content, num, language) {
console.log('这是调用了')
if (content.length == 0) {
wx.showModal({
title: '必填项缺失',
content: `${language}内容不能为空`,
showCancel: false,
success: function (res) {
if (res.confirm) {
console.log('用户点击确定')
}
}
}
})
}else if(content.length>num){
wx.showModal({
title: '文字超出了',
content: `${language}内容字数不能超过${num}`,
showCancel:false,
success: function(res) {
if (res.confirm) {
console.log('用户点击确定')
})
} else if (content.length > num) {
wx.showModal({
title: '文字超出了',
content: `${language}内容字数不能超过${num}`,
showCancel: false,
success: function (res) {
if (res.confirm) {
console.log('用户点击确定')
}
}
}
})
}else{
return true
}
},
})
} else {
return true
}
},
submit(e) {
console.log(e);
let title = e.detail.value.title;
let description = e.detail.value.description;
let parter = e.detail.value.parter;
let wechatId = e.detail.value.wechatId;
if (!this.emptyCheck(title, 15, '项目名称') || !this.emptyCheck(description, 140, '项目介绍') || !this.emptyCheck(parter, 140, '种子用户') || !this.emptyCheck(wechatId, 30, '联系方式')) {
return
}
submit(e){
console.log(e);
let title = e.detail.value.title;
let description = e.detail.value.description;
let parter = e.detail.value.parter;
let wechatId = e.detail.value.wechatId;
if(!this.emptyCheck(title,14,'项目名称')||!this.emptyCheck(description,100,'项目介绍')||!this.emptyCheck(parter,100,'种子用户')||!this.emptyCheck(wechatId,30,'联系方式')){
return
}
let createProject = function(userId){
wx.cloud.callFunction({
name: 'project',
data: {
type:'add',
userId:userId,
title:title,
description:description,
parter:parter,
wechatId:wechatId,
projectType:1
}
}).then(res => {
console.log('cloud res:', res)
console.log(res.result.res._id);
wx.navigateTo({
url: '../detail/detail?id='+res.result.res._id,
let createProject = function (userId) {
wx.cloud.callFunction({
name: 'project',
data: {
type: 'add',
userId: userId,
title: title,
description: description,
parter: parter,
wechatId: wechatId,
projectType: 1
}
}).then(res => {
console.log('cloud res:', res)
console.log(res.result.res._id);
wx.navigateTo({
url: '../detail/detail?id=' + res.result.res._id,
})
}).catch(err => {
console.log('err:', err)
})
}).catch(err => {
console.log('err:', err)
})
}
}
// 检查参数是否合格
// 检查参数是否合格
this.isAuthorize(function (res) {
// console.log(res);
if(res){
createProject(res._id);
}
});
},
NavChange(e){
this.setData({
PageCur: e.currentTarget.dataset.cur
})
}
this.isAuthorize(function (res) {
// console.log(res);
if (res) {
createProject(res._id);
}
});
},
NavChange(e) {
this.setData({
PageCur: e.currentTarget.dataset.cur
})
}
})
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册