Commit 3caf02ced3304751e7a00f92daf492ade12d2bfd

Authored by vking
1 parent 261fafa9

taocan-share-pinglun

// components/2.0/common/page.js
Component({
/**
* 组件的属性列表
*/
properties: {
loading:{
type:Number,
value:0,//0|-1|1 加载中|加载失败|加载完成
},
loadtxt:{
type:String,
value:'',
},
hasNav:{
type:Boolean,
value:true,
},
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
retry(){
//刷新当前页面
let pages=getCurrentPages();
let p=pages[pages.length-1];
let param=[];
console.log('page-retry',p);
if(p.options){
for(let key in p.options){
param.push(key+'='+(p.options[key]
.replace(/=/,'%3D').replace(/&/,'%26')))
}
}
wx.redirectTo({
url: '/'+p.route+'?'+param.join('&')
})
},
}
})
... ...
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
... ...
<!--components/2.0/common/page.wxml-->
<view class="view flex flex-direction justify-center align-center"
style="width: 100vw;height: calc(100vh - {{hasNav?'150rpx':'0'}});" wx:if="{{loading<1}}">
<view class="flex flex-direction justify-center align-center" wx:if="{{loading==-1}}">
<image src="http://nosqn.colorcun.com/timeout.png" style="width: 520rpx;height: 348rpx;"></image>
<view class="margin-tb-lg txt-28-h">请求超时啦~重试一下看看</view>
<view class="reflush flex justify-center align-center" bindtap="retry">点击重试</view>
</view>
<view wx:else="" class="flex flex-direction justify-center align-center">
<image src="http://nosqn.colorcun.com/loading.gif" style="width: 40rpx;height: 40rpx;"></image>
<view class="margin-top bg-white txt-24-h">加载中,请稍后…</view>
</view>
</view>
<block wx:else="">
<slot></slot>
</block>
... ...
/* components/2.0/common/page.wxss */
@import "../../../colorui/main.wxss";
... ...
// components/2.0/pinglun/stat.js
const statStr=['','差','有点差','一般','满意','非常满意']
import util from '../../../utils/util'
Component({
/**
* 组件的属性列表
*/
properties: {
value:{
type:Number,
value:5,
},
disabled:{
type:Boolean,
value:false,
},
length:{//星星个数
type:Number,
value:5,
},
allowHalf:{//是否可半星
type:Boolean,
value:false,
},
},
/**
* 组件的初始数据
*/
data: {
},
attached(){
this.statVal=Math.ceil(this.data.value)
this.setData({
statVal:this.statVal,
statStr:statStr[this.statVal]
})
this.triggerEvent('event',{value:this.statVal})
},
/**
* 组件的方法列表
*/
methods: {
stat(e){
if(this.data.disabled) return;
this.statVal=util.attr(e,'val')
this.setData({
statVal:this.statVal,
statStr:statStr[this.statVal]
})
this.triggerEvent('event',{value:this.statVal})
},
}
})
... ...
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
... ...
<!--components/2.0/pinglun/stat.wxml-->
<view class="flex {{cla}} align-center">
<view class="view stat {{statVal>=index+1?'light':''}}" wx:for="{{length}}"
catchtap="stat" data-val="{{index+1}}"></view>
<view class="stat-txt">{{statStr}}</view>
</view>
... ...
/* components/2.0/pinglun/stat.wxss */
@import "../../../colorui/main.wxss";
.stat{
width: 56rpx;
height: 56rpx;
background-image: url("http://nosqn.colorcun.com/pinglun/p%20%284%29.png");
margin-right: 20rpx;
}
.stat.light{
background-image: url("http://nosqn.colorcun.com/pinglun/p%20%283%29.png");
}
.stat-txt{
height: 44rpx;
font-size: 32rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
line-height: 44rpx;
margin-left: 10rpx;
}
\ No newline at end of file
... ...
... ... @@ -13,11 +13,6 @@
"version": "1.3.9",
"resolved": "https://registry.npmjs.org/mta-wechat-analysis/-/mta-wechat-analysis-1.3.9.tgz",
"integrity": "sha512-Q5OiYECoiFqBX9UzXbDPAtBar0MId5LUzf6ourgeSBBILpW1FOc0lp6SfnZlezs2KN3MjY66TOesFdgWNyiTRA=="
},
"wechat-miniprogram-rate": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/wechat-miniprogram-rate/-/wechat-miniprogram-rate-1.0.0.tgz",
"integrity": "sha512-xBFqh/tpoQ/3sTgf37lOGJFEcJ55Vbv0HtyYVFCq3TZr5f1muhX0vRNnI2y6U2boFz+rYkwA9hZC1UTZDWbBzA=="
}
}
}
... ...
... ... @@ -14,7 +14,6 @@
"license": "ISC",
"dependencies": {
"js-sha1": "^0.6.0",
"mta-wechat-analysis": "^1.3.7",
"wechat-miniprogram-rate": "^1.0.0"
"mta-wechat-analysis": "^1.3.7"
}
}
... ...
// 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
... ...
... ... @@ -3,6 +3,7 @@
"navigationBarTextStyle": "black",
"usingComponents": {
"nav":"/components/nav/nav",
"rate": "wechat-miniprogram-rate"
"stat": "/components/2.0/pinglun/stat",
"qnupload": "plugin://vktool/qnupload"
}
}
\ No newline at end of file
... ...
<!--pages/pinglun/create.wxml-->
<nav>{{sellername}}</nav>
<page>
<page loading="1">
<view class="view">
<view class="view padding-lr-lg">
<view class="view flex align-center solid-bottom" style="height: 136rpx;">
<view class="txt-36-h text-bold">评分</view>
<view class="txt-36-h text-bold margin-left-xs margin-right" style="color:#FF7A00;">*</view>
<view class="view">
<view style="transform: scale(1.5);width: 10%;">
<rate disabled="{{true}}" allowHalf="{{false}}" placeholder="..." value="4"></rate>
</view>
<stat value="4" bindevent="statEvent"></stat>
</view>
</view>
<view class="view flex align-start solid-bottom padding-bottom-sm">
<view class="txt-36-h text-bold" style="margin-top: 48rpx; min-width: 72rpx;">标签</view>
<view class="txt-36-h text-bold margin-left-xs margin-right" style="color:#FF7A00;margin-top: 48rpx;">*</view>
<view class="view margin-top-lg flex flex-wrap">
<view class="view solids round padding-lr margin-bottom margin-right flex align-center" style="height: 64rpx;">包间环境好</view>
<view class="view solids round padding-lr margin-bottom margin-right flex align-center" style="height: 64rpx;">包间环境好</view>
<view class="view solids round padding-lr margin-bottom margin-right flex align-center" style="height: 64rpx;">包间环境好</view>
<view class="tag-item view padding-lr margin-bottom margin-right flex align-center">包间环境好</view>
<view class="tag-item active view padding-lr margin-bottom margin-right flex align-center">包间环境好</view>
<view class="tag-item view padding-lr margin-bottom margin-right flex align-center">包间环境好</view>
</view>
</view>
<textarea
class="margin-top-lg" style="height: 294rpx;"
class="margin-top-lg" style="height: 294rpx; font-size: 30rpx;"
placeholder="从包间环境、菜品口味、服务来评价餐厅,可以帮助更多想要订这家餐厅的人哦~"></textarea>
</view>
<scroll-view class="view"
scroll-into-view="{{scrollIntoView}}"
scroll-x="true" style="height: 192rpx;width: 100%;white-space: nowrap;">
<block wx:for="{{files}}" wx:key="fileskey">
<qnupload qnConf="{{qnConf}}" upConf="{{upConf}}"
file="{{item}}" files="{{files}}"
bindevent="qnevent" class="view qnupload">
<view class="view scroll-block flex flex-direction justify-center align-center" catchtap="displayImage" data-path="{{item.path}}">
<image class="view image" src="{{item.path}}"></image>
<view class="view image-delete" catchtap="deleteImage" data-index="{{index}}"></view>
<image class="view image-up" src=""></image>
<view class="view image-text"></view>
</view>
</qnupload>
</block>
<block wx:if="{{hasAddFile}}">
<qnupload
qnConf="{{qnConf}}" upConf="{{upConf}}"
file="{{item}}" files="{{files}}"
bindevent="qnevent" class="view qnupload">
<view class="view scroll-block flex flex-direction justify-center align-center">
<image class="view image-up" src="http://nosqn.colorcun.com/pinglun/p%20%2817%29.png"></image>
<view class="view image-text">上传图片</view>
</view>
</qnupload>
<qnupload
qnConf="{{qnConfVideo}}" upConf="{{upConfVideo}}"
file="{{item}}" files="{{files}}"
bindevent="qnevent" class="view qnupload">
<view class="view scroll-block flex flex-direction justify-center align-center">
<image class="view image" src="{{item.path}}"></image>
<image class="view image-up" src="http://nosqn.colorcun.com/pinglun/p%20%2818%29.png"></image>
<view class="view image-text">上传视频</view>
</view>
</qnupload>
</block>
<view id="scrollIntoView" class="qnupload" style="width: 0;"></view>
</scroll-view>
</view>
<view class="bg-blue-blue submit text-bold txt-36-h round flex align-center justify-center" bindtap="submit">发布评价</view>
</page>
\ No newline at end of file
... ...
/* pages/pinglun/create.wxss */
@import "../../colorui/main.wxss";
\ No newline at end of file
@import "../../colorui/main.wxss";
.qnupload{
display: inline-block;
margin-right: 20rpx;
padding-top: 12rpx;
}
.scroll-block{
width: 180rpx;
height: 180rpx;
background: #F1F1F1;
border-radius: 10rpx;
position: relative;
}
.qnupload:first-child{
margin-left: 40rpx;
}
.scroll-block .image{
width: 180rpx;
height: 180rpx;
border-radius: 10rpx;
position: absolute;
}
.image-up{
width: 52rpx;
height: 52rpx;
}
.image-text{
height: 34rpx;
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #999999;
line-height: 34rpx;
}
.image-delete{
position: absolute;
top:-12rpx;
right: -12rpx;
width: 40rpx;
height: 40rpx;
background-image: url("http://nosqn.colorcun.com/pinglun/p%20%286%29.png");
background-size: 100% 100%;
}
.submit{
position: fixed;
width: calc(100% - 80rpx);
left:40rpx;
bottom: 40rpx;
height: 84rpx;
}
.tag-item{
height: 64rpx;
background: #F1F1F1;
border-radius: 32rpx;
font-size: 28rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
line-height: 64rpx;
}
.tag-item.active{
background: #F4FAFF;
border-radius: 32rpx;
border: 2rpx solid #5EB2FF;
color: #42A5FF;
}
... ...
... ... @@ -31,7 +31,9 @@
"projectname": "c%E7%AB%AF%E9%A2%84%E5%AE%9A",
"isGameTourist": false,
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"simulatorPluginLibVersion": {
"qywx_simulator_plugin": "1.2.0"
},
"skeleton-config": {
"global": {
"loading": "chiaroscuro",
... ...