|
|
|
// pages/pinglun/create.js
|
|
|
|
import App from '../../utils/api'
|
|
|
|
import util from '../../utils/util'
|
|
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
|
|
|
|
qnConf:{
|
|
|
|
accessKey:'uva-aaonM8dukeR6phc9yuPBrOXk9brrNW_PxLD7',
|
|
|
|
secretKey:'oZMMVN6phk49lG0J1xwmi1Ju0ETT15EnAEWcU9Cs',
|
|
|
|
token:'',
|
|
|
|
bucket:'colorcun-attr',//存储空间
|
|
|
|
fileType:'image',//image|video|audio|file def:file
|
|
|
|
region:'华东',//存储区域
|
|
|
|
domain:'http://nosqn.colorcun.com',//你绑定的域名,非必填项
|
|
|
|
},
|
|
|
|
upConf:{
|
|
|
|
prefixPath:'pinglun/images/', //上传到七牛后有一个路径前缀,可为空
|
|
|
|
loading:'ring',// none|leaf|circle|ring, def leaf 上传的loading效果; none为无,可自行在page wxml中添加
|
|
|
|
group:'image', //一个页面上多个组件的区分标识
|
|
|
|
security:false, // 开启非法检测,默认 false
|
|
|
|
//上传图片
|
|
|
|
count:6, //最多可以选择的图片张数
|
|
|
|
sizeType:['compressed'], //['original', 'compressed'] 所选的图片的尺寸,超大图片 compressed 会引起开卡顿
|
|
|
|
sourceType:['album', 'camera'], //['album', 'camera'] 选择图片的来源
|
|
|
|
},
|
|
|
|
qnConfVideo:{
|
|
|
|
accessKey:'uva-aaonM8dukeR6phc9yuPBrOXk9brrNW_PxLD7',
|
|
|
|
secretKey:'oZMMVN6phk49lG0J1xwmi1Ju0ETT15EnAEWcU9Cs',
|
|
|
|
token:'',
|
|
|
|
bucket:'colorcun-attr',//存储空间
|
|
|
|
fileType:'video',//image|video|audio|file def:file
|
|
|
|
region:'华东',//存储区域
|
|
|
|
domain:'http://nosqn.colorcun.com',//你绑定的域名,非必填项
|
|
|
|
},
|
|
|
|
upConfVideo:{
|
|
|
|
prefixPath:'pinglun/videos/', //上传到七牛后有一个路径前缀,可为空
|
|
|
|
loading:'ring',// none|leaf|circle|ring, def leaf 上传的loading效果; none为无,可自行在page wxml中添加
|
|
|
|
group:'video', //一个页面上多个组件的区分标识
|
|
|
|
security:false, // 开启非法检测,默认 false
|
|
|
|
//上传图片
|
|
|
|
count:6, //最多可以选择的图片张数
|
|
|
|
sizeType:['compressed'], //['original', 'compressed'] 所选的图片的尺寸,超大图片 compressed 会引起开卡顿
|
|
|
|
sourceType:['album', 'camera'], //['album', 'camera'] 选择图片的来源
|
|
|
|
},
|
|
|
|
files:[], //组件数据放入这里展示到页面上
|
|
|
|
hasAddFile:true,//出现上传加号
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -59,11 +100,44 @@ Page({ |
|
|
|
onReachBottom: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
statVal:5,
|
|
|
|
statEvent(e){
|
|
|
|
this.statVal=e.detail.value
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
|
|
}
|
|
|
|
qnevent(e){
|
|
|
|
console.log('qnevent',e.detail);
|
|
|
|
let files=e.detail.data
|
|
|
|
if(e.detail.act=='uploadFail'){
|
|
|
|
files[e.detail.fileCurrent].progress=Math.random().toFixed(2)
|
|
|
|
}
|
|
|
|
files.forEach(f=>{
|
|
|
|
if(f.progress==100){
|
|
|
|
if(!f.remote || !f.remote.url){
|
|
|
|
f.progress=(90+Math.random()*9).toFixed(2)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
files:files,
|
|
|
|
hasAddFile:files.length<this.data.upConf.count,
|
|
|
|
scrollIntoView:'scrollIntoView',
|
|
|
|
})
|
|
|
|
},
|
|
|
|
displayImage(e){
|
|
|
|
let path=util.attr(e,'path')
|
|
|
|
wx.previewImage({
|
|
|
|
urls:[path],
|
|
|
|
})
|
|
|
|
},
|
|
|
|
deleteImage(e){
|
|
|
|
let index=util.attr(e,'index')
|
|
|
|
let files=this.data.files
|
|
|
|
files.splice(index,1)
|
|
|
|
this.setData({
|
|
|
|
files:files,
|
|
|
|
hasAddFile:files.length<6
|
|
|
|
})
|
|
|
|
util.toast('图片已删除','none')
|
|
|
|
},
|
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|