请教一下 要存点评了几颗星到云数据库并展示出来,请问存哪个字段?
WXML
<view class=‘card’>
<!-- 为方便数据定位,自定义了wx:for-item为i -->
<block wx:for=’{{evaluations}}’ wx:for-item=‘i’ wx:key=’’>
<!-- 单个卡片项 -->
<view class=‘card-item’>
<!-- 卡片上方标题 -->
<view class=‘item-title’>
<view class=‘image-container title-image’>
<image src=’{{i.image}}’></image>
</view>
<view class=‘title-text’>{{i.name}}</view>
</view>
<!-- 卡片下方评价区 -->
<view class=‘item-content’>
<view class=‘image-container content-image’>
<image src=’{{evaluationImgUrl}}’></image>
</view>
<view class=‘contet-text content-body’>
<!-- 为方便数据定位,自定义了wx:for-item为j -->
<block wx:for=’{{starMap}}’ wx:for-item=‘j’ wx:key=’’>
<view class=‘image-container’ data-index=’{{i.id}}’ bindtap=‘chooseStar’>
<image wx:if=’{{i.star >= index + 1}}’ data-star=’{{index + 1}}’ src=’{{starCheckedImgUrl}}’ bin ></image>
<image wx:if=’{{i.star < index + 1}}’ data-star=’{{index + 1}}’ src=’{{starUnCheckedImgUrl}}’></image>
</view>
</block>
<text class=‘note’>{{i.note}}</text>
</view>
</view>
</view>
</block>
</view>
WXSS
// 评价图片
evaluationImgUrl: “https://s1.ax1x.com/2018/08/05/PDM8Bj.png”, //评字图片
starCheckedImgUrl: “https://s1.ax1x.com/2018/08/05/PDQ0it.png”, //点亮时图片
starUnCheckedImgUrl: “https://s1.ax1x.com/2018/08/05/PDQdII.png”, //熄灭时图片
// // 建议内容
// opinion: “”,
starMap: [
‘非常差’,
‘差’,
‘一般’,
‘好’,
‘非常好’,
],
evaluations: [{
id: 0,
name: “服务态度”,
image: “https://s1.ax1x.com/2018/08/05/PDMaCV.png”,
star: 0,
note: “”
},
{
id: 1,
name: “工作效率”,
image: “https://s1.ax1x.com/2018/08/05/PDMd3T.png”,
star: 0,
note: “”
},
{
id: 2,
name: “工作质量”,
image: “https://s1.ax1x.com/2018/08/05/PDMN40.png”,
star: 0,
note: “”
}
]
},
JS
/**
* 评分
*/
chooseStar: function(e) {
const index = e.currentTarget.dataset.index;
const star = e.target.dataset.star;
let evaluations = this.data.evaluations;
let evaluation = evaluations[index];
console.log(evaluation)
evaluation.star = star;
evaluation.note = this.data.starMap[star - 1];
this.setData({
evaluations: evaluations
})
},