订单评论

This commit is contained in:
Kiyan 2017-05-16 17:11:21 +08:00
parent cb5efbc0ec
commit 8c5764a172
11 changed files with 363 additions and 12 deletions

View File

@ -1,11 +1,12 @@
{
"pages": [
"pages/order/list",
"pages/order/show",
"pages/order/review",
"pages/index/index",
"pages/index/search",
"pages/index/category",
"pages/shop/show",
"pages/order/list",
"pages/order/show",
"pages/mine/mine",
"pages/address/select",
"pages/order/quasi",

View File

@ -16,9 +16,9 @@
<view class="">{{item.add_time_format}}</view>
</view>
</navigator>
<view wx:if="{{item.state == 1 || item.state == 4}}" class="order-item__ft">
<view wx:if="{{item.state == 1 || (item.state == 4 && item.is_reviews == 0)}}" class="order-item__ft">
<button id="{{index}}" bindtap="onPayTap" wx:if="{{item.state == 1}}" class="weui-btn_primary weui-btn_mini">立即付款</button>
<navigator wx:elif="{{item.state == 4}}" url="url" class="weui-btn_primary weui-btn_mini">去评论</navigator>
<navigator wx:elif="{{item.state == 4 && item.is_reviews == 0}}" url="/pages/order/review?id={{item.order_id}}" class="weui-btn_primary weui-btn_mini">去评论</navigator>
</view>
</view>
</view>

196
app/pages/order/review.js Normal file
View File

@ -0,0 +1,196 @@
// pages/order/review.js
import {
getOrderInfo, reviewsOrder
} from '../../utils/apis'
import dateFormat from '../../utils/dateformat'
import {
datetimeFormat,
alert, getPrevPage
} from '../../utils/util'
var RATE_LABELS = {
1: '非常差',
2: '很差',
3: '一般',
4: '很好',
5: '非常好'
}
Page({
/**
* 页面的初始数据
*/
data: {
RATE_LABELS,
limitLength: 8,
content: '',
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.id = options.id || 1468
this.loadData()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
loadData() {
var that = this
var order_id = this.id
wx.showNavigationBarLoading()
this.setData({
loading: true
})
getOrderInfo({
order_id,
success(data) {
var [reach_date, reach_time] = datetimeFormat(data.receive_time).split(' ')
that.setData({
reach_date, reach_time,
info: data,
loading: false,
})
wx.hideNavigationBarLoading()
},
error() {
that.setData({
loading: false
})
wx.hideNavigationBarLoading()
}
})
},
onChangeTime(e) {
var reach_time = e.detail.value
this.setData({
reach_time
})
},
onServiceChange(e) {
var {id: service} = e.currentTarget
this.setData({
service
})
},
onQualityChange(e) {
var {id: quality} = e.currentTarget
this.setData({
quality
})
},
onContentInput(e) {
var {value: content} = e.detail
this.setData({
content
})
},
onSubmit(e) {
var that = this
var {id: order_id} = this
var {
limitLength,
service, quality, content,
info: {receive_time}
} = this.data
if (!service) {
return alert('请为配送打分')
}
if (!quality) {
return alert('请为商家打分')
}
if (content.length < limitLength) {
return alert(`评论内容不能小于${limitLength}个字`)
}
this.setData({
loading: true
})
reviewsOrder({
order_id,
service, quality, content,
success(data) {
that.setData({
loading: false
})
alert('评论成功', function () {
var callback = getPrevPage()['callback']
callback && callback()
wx.navigateBack()
})
},
error(data) {
that.setData({
loading: false
})
}
})
}
})

View File

@ -0,0 +1,3 @@
{
"navigationBarTitleText": "评论"
}

View File

@ -0,0 +1,38 @@
<!--pages/order/review.wxml-->
<import src="templates/rate.wxml" />
<view class="review">
<view class="review-box">
<view class="review-box__hd">
<view class="">爱跑腿专送</view>
<view class="text-small">
{{reach_date}} {{reach_time}} 左右到达
<!--<picker bindchange="onChangeTime" mode="time" value="{{reach_time}}" class="correct trangle">更正</picker>-->
</view>
</view>
<view class="review-box__bd">
<view class="">{{RATE_LABELS[service]?RATE_LABELS[service]: '为配送打分'}}</view>
<view class="">
<template is="rate" data="{{value: service, onItemTap: 'onServiceChange'}}"></template>
</view>
</view>
</view>
<view class="review-box">
<view class="review-box__hd">
<view class="">{{info.seller_name}}</view>
</view>
<view class="review-box__bd">
<view class="">{{RATE_LABELS[quality]?RATE_LABELS[quality]: '为商家打分'}}</view>
<view class="">
<template is="rate" data="{{value: quality, onItemTap: 'onQualityChange'}}"></template>
</view>
<view class="review-content">
<textarea bindinput="onContentInput" class="review-content__textarea" placeholder="写下您对配送和商家的评价吧~" />
<view wx:if="{{content.length < limitLength}}" class="review-content__tips">还需输入{{limitLength - content.length}}个字</view>
</view>
</view>
</view>
<view class="button-sp-area">
<button bindtap="onSubmit" loading="{{loading}}" disabled="{{loading}}" type="primary">提交</button>
</view>
</view>

View File

@ -0,0 +1,51 @@
/* pages/order/review.wxss */
@import './templates/rate.wxss';
.review {
margin: 15px;
}
.review-box {
padding: 0 10px;
background-color: #fff;
}
.review-box:not(:first-child) {
margin-top: 15px;
}
.review-box__hd {
padding: 10px 0;
border-bottom: 1rpx solid #e8e8e8;
}
.review-box__bd {
padding: 10px 0;
text-align: center;
}
.correct {
float: right;
color: #ff5801;
}
.review-content{
position: relative;
margin-top: 10px;
}
.review-content__textarea {
padding: 5px 8px;
width: 100%;
text-align: left;
border: 1rpx solid #e8e8e8;
box-sizing: border-box;
}
.review-content__tips {
position: absolute;
bottom: 8px;
right: 8px;
font-size: 0.8em;
color: #999;
}

View File

@ -24,7 +24,7 @@ Page({
},
onLoad: function (options) {
// 页面初始化 options为页面跳转所带来的参数
this.id = options.id || 1413
this.id = options.id || 1468
this.loadData()
},
onReady: function () {
@ -107,18 +107,24 @@ Page({
onPhoneTap(e) {
var that = this
var {info: {seller_phone, localphone}} = this.data
var {info: {seller_phone, localphone, delivery_phone}} = this.data
var phones = [
`商家电话: ${seller_phone}`,
`客服电话: ${localphone}`
]
if(delivery_phone) {
phones.push(`跑腿电话: ${delivery_phone}`)
}
wx.showActionSheet({
itemList: [
`商家电话: ${seller_phone}`,
`客服电话: ${localphone}`
],
itemList: phones,
success: function (res) {
var {tapIndex} = res
if (tapIndex == 0) {
makePhoneCall(seller_phone)
} else if (tapIndex == 1) {
makePhoneCall(localphone)
} else if(tapIndex == 2) {
makePhoneCall(delivery_phone)
}
},
fail: function (res) {
@ -181,4 +187,8 @@ Page({
})
},
callback() {
this.loadData()
}
})

View File

@ -23,10 +23,10 @@
<text wx:elif="{{info.state == 2}}">等待商家接单</text>
<text class="primary-color order-show__left-time-label">{{countLabel}}</text>
</view>
<view wx:if="{{info.state <= 2 || info.state == 4}}" class="actionbar">
<view wx:if="{{info.state <= 2 || (info.state == 4 && info.is_reviews == 0)}}" class="actionbar">
<button bindtap="onCancelTap" wx:if="{{info.state <= 2}}" class="weui-btn actionbar-btn actionbar-btn_action">取消订单</button>
<button loading="{{loading}}" disabled="{{loading}}" bindtap="onPayTap" wx:if="{{info.state == 1}}" class="weui-btn actionbar-btn actionbar-btn_action actionbar-btn_primary" type="primary">立即付款</button>
<view wx:if="{{info.state == 4}}" class="actionbar-btn actionbar-btn_action actionbar-btn_primary">评价</view>
<navigator url="/pages/order/review?id={{info.order_id}}" wx:if="{{info.state == 4 && info.is_reviews == 0}}" class="actionbar-btn actionbar-btn_action actionbar-btn_primary">评价</navigator>
</view>
</swiper-item>
<swiper-item class="tab__swiper-item tab__swiper-item_detail">

View File

@ -0,0 +1,5 @@
<template name="rate">
<view class="rate">
<view id="{{item + 1}}" bindtap="{{onItemTap}}" wx:for="{{count || 5}}" wx:key="*this" class="rate__item {{value > item ? 'rate__item_active': ''}}">★</view>
</view>
</template>

View File

@ -0,0 +1,18 @@
.rate {
margin-top: 10px;
}
.rate__item {
display: inline-block;
margin: 0 5px;
width: 30px;
height: 30px;
line-height: 30px;
font-size: 18px;
color: #fff;
background-color: #e8e8e8;
border-radius: 5px;
}
.rate__item_active {
background-color: #ff5801;
}

View File

@ -464,6 +464,33 @@ export function getOrderInfo(options) {
})
}
// 订单评论
export function reviewsOrder(options) {
var {
order_id,
service, quality, content,
reach_time,
success, error
} = options
getApp().getLoginInfo(loginInfo => {
if (!loginInfo.user_info) {
return alert('用户未登录')
}
var {user_id, user_token} = loginInfo.user_info
fetch({
url: 'index.php?m=Mall&c=Order&a=reviewsOrder',
data: {
user_id, user_token,
order_id,
service, quality, content,
reach_time
},
success, error
})
})
}
// 获取支付参数
export function getPayment(options) {
var {
@ -547,3 +574,5 @@ export function search(options) {
})
}