Commit b3d61910cd03d1d36bbc87f15b7e9aee30c90453

Authored by yvan.ni
1 parent 38b35286

添加评价

pages/user/add_comment/add_comment.js
1   -var t = getApp(),oo=t.globalData, a = t.globalData.setting,os=a, e = t.request, s = require("../../../utils/util.js"),
2   - i = require("../../../utils/selectFiles.js");
  1 +var t = getApp(), oo = t.globalData, a = t.globalData.setting, os = a, e = t.request, s = require("../../../utils/util.js"),
  2 + i = require("../../../utils/selectFiles.js");
3 3 var regeneratorRuntime = require('../../../utils/runtime.js');
4 4  
5 5 Page({
6   - data: {
7   - url: a.url,
8   - resourceUrl: a.resourceUrl,
9   - iurl: a.imghost,
10   - defaultPhoto: a.resourceUrl + "/static/images/camera.png",
11   - filePaths: [],
12   - uploadPath: [],
13   - maxWord: 0,
14   - is_anonymous: !1,
15   - goods_rank: 0,
16   - service_rank: 0,
17   - deliver_rank: 0,
18   - content: "",
19   - options: null,
20   - isLongPress: !1,
21   - userinfo:null,
22   - },
23   - onLoad:async function(a) {
24   - var th=this;
25   - console.log('onLoad');
26   - console.log(a);
  6 + data: {
  7 + url: a.url,
  8 + resourceUrl: a.resourceUrl,
  9 + iurl: a.imghost,
  10 + defaultPhoto: a.resourceUrl + "/static/images/camera.png",
  11 + filePaths: [],
  12 + uploadPath: [],
  13 + maxWord: 0,
  14 + is_anonymous: !1,
  15 + goods_rank: 0,
  16 + service_rank: 0,
  17 + deliver_rank: 0,
  18 + content: "",
  19 + options: null,
  20 + isLongPress: !1,
  21 + userinfo: null,
  22 + imgs: [],
  23 + lenMore:0
  24 + },
  25 + onLoad: async function (a) {
  26 + var th = this;
  27 + console.log('onLoad');
  28 + console.log(a);
27 29  
28   - await getApp().request.promiseGet("/api/weshop/goods/get/"+os.stoid+"/"+a.goods_id,{1:1}).then(res=>{
29   - a.img=th.data.iurl+res.data.data.original_img
30   - })
  30 + await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + a.goods_id, { 1: 1 }).then(res => {
  31 + a.img = th.data.iurl + res.data.data.original_img
  32 + })
31 33  
32 34  
33   - this.setData({options: a});
34   - t.getUserInfo(function(e){
35   - console.log(e);
36   - th.setData({
37   - userinfo:e
38   - })
39   - })
40   - },
41   - keyUpChangeNum: function(t) {
42   - this.setData({
43   - maxWord: t.detail.value.length
44   - }), this.data.content = t.detail.value;
45   - },
46   - checkAnonymous: function() {
47   - this.setData({
48   - is_anonymous: !this.data.is_anonymous
  35 + this.setData({ options: a });
  36 + t.getUserInfo(function (e) {
  37 + console.log(e);
  38 + th.setData({
  39 + userinfo: e
  40 + })
  41 + })
  42 + },
  43 + keyUpChangeNum: function (t) {
  44 + this.setData({
  45 + maxWord: t.detail.value.length
  46 + }), this.data.content = t.detail.value;
  47 + },
  48 + checkAnonymous: function () {
  49 + this.setData({
  50 + is_anonymous: !this.data.is_anonymous
  51 + });
  52 + },
  53 + checkGoodsRank: function (t) {
  54 + this.setData({
  55 + goods_rank: parseInt(t.currentTarget.dataset.i) + 1
  56 + });
  57 + },
  58 + checkServiceRank: function (t) {
  59 + this.setData({
  60 + service_rank: parseInt(t.currentTarget.dataset.i) + 1
  61 + });
  62 + },
  63 + checkDeliverRank: function (t) {
  64 + this.setData({
  65 + deliver_rank: parseInt(t.currentTarget.dataset.i) + 1
  66 + });
  67 + },
  68 + selectPhotos: function (t) {
  69 + if (this.data.isLongPress) this.data.isLongPress = !1; else {
  70 + var a = this;
  71 + i.selectPhotos(this.data.filePaths, t.currentTarget.dataset.idx, function (t) {
  72 + a.setData({
  73 + filePaths: t
49 74 });
50   - },
51   - checkGoodsRank: function(t) {
52   - this.setData({
53   - goods_rank: parseInt(t.currentTarget.dataset.i) + 1
54   - });
55   - },
56   - checkServiceRank: function(t) {
57   - this.setData({
58   - service_rank: parseInt(t.currentTarget.dataset.i) + 1
59   - });
60   - },
61   - checkDeliverRank: function(t) {
62   - this.setData({
63   - deliver_rank: parseInt(t.currentTarget.dataset.i) + 1
64   - });
65   - },
66   - selectPhotos: function(t) {
67   - if (this.data.isLongPress) this.data.isLongPress = !1; else {
68   - var a = this;
69   - i.selectPhotos(this.data.filePaths, t.currentTarget.dataset.idx, function(t) {
70   - a.setData({
71   - filePaths: t
72   - });
73   - });
  75 + });
  76 + }
  77 + },
  78 + removePhoto: function (t) {
  79 + var a = this;
  80 + this.data.isLongPress = !0, i.removePhoto(this.data.filePaths, t.currentTarget.dataset.idx, function (t) {
  81 + a.setData({
  82 + filePaths: t
  83 + });
  84 + });
  85 + },
  86 + submitComment: function () {
  87 + var a = this;
  88 + if (!a.data.service_rank || !a.data.goods_rank || !a.data.deliver_rank) return t.showWarning("请先打完分~");
  89 + this.uploadPhotos(function () {
  90 + e.post("/api/weshop/comment/savecomment", {
  91 + data: {
  92 + email: ' ',
  93 + is_show: 1,
  94 + goods_rank: a.data.goods_rank,
  95 + service_rank: a.data.service_rank,
  96 + deliver_rank: a.data.deliver_rank,
  97 + content: a.data.content,
  98 + goods_id: a.data.options.goods_id,
  99 + order_id: a.data.options.order_id,
  100 + user_id: oo.user_id,
  101 + store_id: os.stoid,
  102 + username: a.data.userinfo.nickname
  103 + },
  104 + success: function (a) {
  105 + wx.setStorageSync("user:comment:update", !0), t.showSuccess("评论成功", function () {
  106 + wx.navigateBack();
  107 + });
74 108 }
75   - },
76   - removePhoto: function(t) {
77   - var a = this;
78   - this.data.isLongPress = !0, i.removePhoto(this.data.filePaths, t.currentTarget.dataset.idx, function(t) {
79   - a.setData({
80   - filePaths: t
81   - });
82   - });
83   - },
84   - submitComment: function() {
85   - var a = this;
86   - if (!a.data.service_rank || !a.data.goods_rank || !a.data.deliver_rank) return t.showWarning("请先打完分~");
87   - this.uploadPhotos(function() {
88   - e.post("/api/weshop/comment/savecomment", {
89   - data: {
90   - email:' ',
91   - is_show:1,
92   - goods_rank: a.data.goods_rank,
93   - service_rank: a.data.service_rank,
94   - deliver_rank: a.data.deliver_rank,
95   - content: a.data.content,
96   - goods_id: a.data.options.goods_id,
97   - order_id: a.data.options.order_id,
98   - user_id: oo.user_id,
99   - store_id:os.stoid,
100   - username: a.data.userinfo.nickname
101   - },
102   - success: function(a) {
103   - wx.setStorageSync("user:comment:update", !0), t.showSuccess("评论成功", function() {
104   - wx.navigateBack();
105   - });
106   - }
107   - });
108   - });
109   - },
110   - uploadPhotos: function(t, a) {
111   - if (0 == this.data.filePaths.length) return t();
112   - if ("number" != typeof a) a = 0; else if (a >= this.data.filePaths.length) return t();
113   - var s = this;
114   - e.uploadFile("/api/user/upload_comment_img", {
115   - filePath: s.data.filePaths[a],
116   - name: "img_file",
117   - success: function(e) {
118   - s.data.uploadPath[a] = e.data.result, s.uploadPhotos(t, a + 1);
119   - }
120   - });
121   - },
  109 + });
  110 + });
  111 + },
  112 + uploadPhotos: function (t, a) {
  113 + if (0 == this.data.filePaths.length) return t();
  114 + if ("number" != typeof a) a = 0; else if (a >= this.data.filePaths.length) return t();
  115 + var s = this;
  116 + e.uploadFile("/api/user/upload_comment_img", {
  117 + filePath: s.data.filePaths[a],
  118 + name: "img_file",
  119 + success: function (e) {
  120 + s.data.uploadPath[a] = e.data.result, s.uploadPhotos(t, a + 1);
  121 + }
  122 + });
  123 + },
122 124  
123   - //图片失败,默认图片
124   - bind_bnerr2: function (e) {
  125 + //图片失败,默认图片
  126 + bind_bnerr2: function (e) {
125 127 var _errImg = e.target.dataset.errorimg;
126 128 var _errObj = {};
127   - _errObj[_errImg] = a.imghost+"/public/images/default_goods_image_240.gif";
  129 + _errObj[_errImg] = a.imghost + "/public/images/default_goods_image_240.gif";
128 130 this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
129   - }
  131 + },
  132 + // 上传图片
  133 + chooseImg: function (e) {
  134 + var that = this;
  135 + var imgs = this.data.imgs;
  136 + if (imgs.length >= 3) {
  137 + this.setData({
  138 + lenMore: 1
  139 + });
  140 + setTimeout(function () {
  141 + that.setData({
  142 + lenMore: 0
  143 + });
  144 + }, 2500);
  145 + return false;
  146 + }
  147 + wx.chooseImage({
  148 + // count: 1, // 默认9
  149 + sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
  150 + sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
  151 + success: function (res) {
  152 + // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
  153 + var tempFilePaths = res.tempFilePaths;
  154 + var imgs = that.data.imgs;
  155 + // console.log(tempFilePaths + '----');
  156 + for (var i = 0; i < tempFilePaths.length; i++) {
  157 + if (imgs.length >= 3) {
  158 + that.setData({
  159 + imgs: imgs
  160 + });
  161 + return false;
  162 + } else {
  163 + imgs.push(tempFilePaths[i]);
  164 + }
  165 + }
  166 + // console.log(imgs);
  167 + that.setData({
  168 + imgs: imgs
  169 + });
  170 + }
  171 + });
  172 + },
  173 + // 删除图片
  174 + deleteImg: function (e) {
  175 + var imgs = this.data.imgs;
  176 + var index = e.currentTarget.dataset.index;
  177 + imgs.splice(index, 1);
  178 + this.setData({
  179 + imgs: imgs
  180 + });
  181 + },
  182 + // 预览图片
  183 + previewImg: function (e) {
  184 + //获取当前图片的下标
  185 + var index = e.currentTarget.dataset.index;
  186 + //所有图片
  187 + var imgs = this.data.imgs;
  188 + wx.previewImage({
  189 + //当前显示图片
  190 + current: imgs[index],
  191 + //所有图片
  192 + urls: imgs
  193 + })
  194 + },
  195 +
  196 +
130 197 });
131 198 \ No newline at end of file
... ...
pages/user/add_comment/add_comment.json
1 1 {
2   - "navigationBarTitleText": "评价晒单",
  2 + "navigationBarTitleText": "评价宝贝",
3 3 "enablePullDownRefresh": false
4 4 }
5 5 \ No newline at end of file
... ...
pages/user/add_comment/add_comment.wxml
1   -<view class="goods-mes pd-bg-fff">
  1 +<!-- <view class="goods-mes pd-bg-fff">
2 2 <view class="goods-img">
3 3 <image class="wh100" src="{{options.img}}" binderror="bind_bnerr2" data-errorimg="options.img"></image>
4 4 </view>
... ... @@ -22,7 +22,7 @@
22 22 <!-- <view class="anonymous">
23 23 <icon bindtap="checkAnonymous" color="{{is_anonymous?'red':'gray'}}" size="20" type="success"></icon> 匿名评价
24 24 </view> -->
25   -<view class="score-list pd-bg-fff">
  25 +<!-- <view class="score-list pd-bg-fff">
26 26 <view class="score-title">
27 27 <view>评分</view>
28 28 <view>满意请给5分哦</view>
... ... @@ -48,4 +48,134 @@
48 48 </view>
49 49 <view class="btn-wrap">
50 50 <view bindtap="submitComment" class="submit-btn">提 交</view>
  51 +</view> -->
  52 +<view>
  53 + <!-- 商品评价 -->
  54 + <view class='commodity'>
  55 + <!-- 商品信息 -->
  56 + <view class='information flex-vertical'>
  57 + <image src="https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3117916781,836883337&fm=26&gp=0.jpg"></image>
  58 + <view class="goods_name xc-black">
  59 + <!-- 商品名称 -->
  60 + <view class='ellipsis-2 fs32'>{{options.goods_name}}我弄饭v的v哦女v绝我弄饭v的v哦女v绝望愤怒冻死我弄饭v的v哦女v绝望愤怒冻死望愤怒冻死</view>
  61 + <!-- 商品价格,数量 -->
  62 + <view class='flex jc_sb balin'>
  63 + <!-- 价格 -->
  64 + <view class='flex-vertical balin'>
  65 + <view class="fs24">¥</view>
  66 + <view class="fs35">{{options.price}}3333.00</view>
  67 + </view>
  68 +
  69 + <!-- 商品数量 -->
  70 + <view class='sum flex-vertical balin xc-black'>
  71 + <view class="fs24">x</view>
  72 + <view class="fs28">1</view>
  73 + </view>
  74 +
  75 + </view>
  76 +
  77 + </view>
  78 +
  79 + </view>
  80 +
  81 +
  82 + <!-- 商品评价信息 -->
  83 + <view class="addComment">
  84 + <textarea class="fs24" placeholder="已经收到商品,快跟大家分享一下宝贝吧!" placeholder-class="fs24" maxlength="500"></textarea>
  85 + <view class="flex addimages">
  86 + <!-- 评论图片集合 -->
  87 + <view class="images">
  88 + <image class="rel" catchtap="previewImg" data-index="{{index}}" src="{{item}}" wx:for="{{imgs}}">
  89 + <image class="abs" src="../../../images/cancel.png" data-index="{{index}}" bindtap="deleteImg"></image>
  90 + </image>
  91 +
  92 + </view>
  93 +
  94 + <!-- 添加图片按钮框架 -->
  95 + <view class="addimage flex-center xc-ash" bindtap="chooseImg">
  96 + <view>
  97 + <view class="flex-center">
  98 + <image src="../../../images/camera.png"></image>
  99 + </view>
  100 + <view class="flex-center fs20">添加图片</view>
  101 + <view class="flex-center fs20">{{imgs.length>0?imgs.length:0}}/3</view>
  102 + </view>
  103 + </view>
  104 +
  105 + </view>
  106 +
  107 +
  108 +
  109 +
  110 +
  111 +
  112 +
  113 +
  114 + </view>
  115 +
  116 +
  117 +
  118 +
  119 +
  120 +
  121 + </view>
  122 +
  123 + <!-- 评价等级 -->
  124 +
  125 + <view class="Grade">
  126 + <!-- 宝贝评分 -->
  127 + <view class="title flex-vertical">
  128 + <view class="column"></view>
  129 + <view class="fs28">宝贝评分</view>
  130 + </view>
  131 +
  132 + <!-- 服务评级 -->
  133 + <view class="score-items">
  134 + <view class="score-item flex-vertical">
  135 + <view class="fs24">描述相符</view>
  136 + <view class="stars flex-vertical">
  137 + <image data-i="{{index}}" src="{{index<goods_rank?iurl+'/miniapp/images/StarsredCk.png':iurl+'/miniapp/images/StarswhiteUnCk.png'}}" wx:for="{{5}}" wx:key="{{index}}" bindtap="checkGoodsRank"></image>
  138 +
  139 + </view>
  140 + </view>
  141 +
  142 + <view class="score-item flex-vertical">
  143 + <view class="fs24">物流服务</view>
  144 + <view class="stars flex-vertical">
  145 + <image bindtap="checkDeliverRank" data-i="{{index}}" src="{{index<deliver_rank?iurl+'/miniapp/images/StarsredCk.png':iurl+'/miniapp/images/StarswhiteUnCk.png'}}" wx:for="{{5}}" wx:key="{{index}}"></image>
  146 +
  147 + </view>
  148 + </view>
  149 + <view class="score-item flex-vertical">
  150 + <view class="fs24">服务态度</view>
  151 + <view class="stars flex-vertical">
  152 + <image src="{{index<service_rank?iurl+'/miniapp/images/StarsredCk.png':iurl+'/miniapp/images/StarswhiteUnCk.png'}}" bindtap="checkServiceRank" data-i="{{index}}" wx:for="{{5}}" wx:key="{{index}}"></image>
  153 +
  154 +
  155 + </view>
  156 +
  157 + </view>
  158 +
  159 + </view>
  160 +
  161 + </view>
51 162 </view>
  163 +
  164 +<!-- 是否匿名评价 -->
  165 +<view class=" Whether ">
  166 +
  167 + <!-- 选择是否匿名 -->
  168 + <view class="allClick flex-right-vertical ">
  169 + <icon class="radio " bindtap="checkAnonymous " color="{{is_anonymous? 'white': 'red'}} " size="15 " type="success "></icon>
  170 + <view class="fs24 ">匿名评价</view>
  171 + </view>
  172 +
  173 + <view class="Submission flex-level ">
  174 + <view class="fs30 flex-level white " bindtap="submitComment ">
  175 + 提交评价
  176 + </view>
  177 + </view>
  178 +
  179 +
  180 +
  181 +</view>
52 182 \ No newline at end of file
... ...
pages/user/add_comment/add_comment.wxss
1   -.goods-mes {
  1 +/* .goods-mes {
2 2 height: 100rpx;
3 3 display: flex;
4 4 padding: 30rpx;
... ... @@ -119,4 +119,157 @@
119 119 background-color: #f15353;
120 120 color: #fff;
121 121 margin: auto;
122   -}
123 122 \ No newline at end of file
  123 +} */
  124 +
  125 +/* 商品详情和评价 */
  126 +
  127 +.commodity {
  128 + height: 715rpx;
  129 + border-top: 6rpx solid rgb(245, 245, 245);
  130 + border-bottom: 6rpx solid rgb(245, 245, 245);
  131 + padding: 0rpx 30rpx;
  132 +}
  133 +
  134 +.commodity .information {
  135 + height: 286rpx;
  136 +}
  137 +
  138 +.commodity .information image {
  139 + width: 186rpx;
  140 + height: 186rpx;
  141 +}
  142 +
  143 +.information .goods_name {
  144 + width: 480rpx;
  145 + margin-left: 25rpx;
  146 + height: 186rpx;
  147 +}
  148 +
  149 +.information .goods_name .ellipsis-2 {
  150 + line-height: 40rpx;
  151 + height: 80rpx;
  152 +}
  153 +
  154 +.information .goods_name .jc_sb {
  155 + margin-top: 60rpx;
  156 + color: rgb(212, 28, 52);
  157 + margin-right: 7rpx;
  158 +}
  159 +
  160 +.information .goods_name .jc_sb .fs32 {
  161 + line-height: 40rpx;
  162 +}
  163 +
  164 +.information .goods_name .jc_sb .sum {
  165 + margin-right: 5rpx;
  166 +}
  167 +
  168 +.balin {
  169 + align-items: baseline;
  170 +}
  171 +
  172 +.addComment {
  173 + height: 345rpx;
  174 + width: 690rpx;
  175 + background-color: rgb(248, 248, 248);
  176 + padding: 32rpx 0rpx 21rpx 0rpx;
  177 +}
  178 +
  179 +.addComment textarea {
  180 + padding: 0rpx 18rpx;
  181 + height: 175rpx;
  182 + width: 654rpx;
  183 +}
  184 +
  185 +.addComment .addimages {
  186 + padding: 0rpx 18rpx;
  187 + margin-top: 20rpx;
  188 + align-items: flex-end;
  189 + width: 652rpx;
  190 +}
  191 +
  192 +.addComment .addimages .images {
  193 + height: 140rpx;
  194 +}
  195 +
  196 +.addComment .addimages .images .rel {
  197 + width: 140rpx;
  198 + height: 100%;
  199 + overflow: visible;
  200 + margin-right: 15rpx;
  201 +}
  202 +
  203 +.addComment .addimages .images image .abs {
  204 + width: 30rpx;
  205 + height: 30rpx;
  206 + top: -7rpx;
  207 + right: -7rpx;
  208 +}
  209 +
  210 +.addComment .addimage {
  211 + width: 139rpx;
  212 + height: 139rpx;
  213 + border: 2rpx dashed rgb(196, 196, 196);
  214 + font-size: 16rpx;
  215 + margin-left: 6rpx;
  216 +}
  217 +
  218 +.addComment .addimage image {
  219 + width: 60rpx;
  220 + height: 58rpx;
  221 +}
  222 +
  223 +.Grade {
  224 + width: 100%;
  225 + height: 310rpx;
  226 + border-bottom: 6rpx solid rgb(245, 245, 245);
  227 + padding-left: 45rpx;
  228 +}
  229 +
  230 +.Grade .title {
  231 + width: 100%;
  232 + height: 105rpx;
  233 +}
  234 +
  235 +.Grade .title .column {
  236 + height: 30rpx;
  237 + border-left: 6rpx solid rgb(211, 27, 58);
  238 + margin-right: 12rpx;
  239 +}
  240 +
  241 +.Grade .score-item {
  242 + height: 55rpx;
  243 + line-height: 55rpx;
  244 +}
  245 +
  246 +.Grade .score-item .stars {
  247 + margin-left: 83rpx;
  248 +}
  249 +
  250 +.Grade .score-item .stars image {
  251 + width: 35rpx;
  252 + height: 35rpx;
  253 + margin-right: 28rpx;
  254 +}
  255 +
  256 +.Whether .flex-right-vertical {
  257 + height: 67rpx;
  258 + padding-right: 31rpx;
  259 +}
  260 +
  261 +.Whether .flex-right-vertical .radio {
  262 + margin-right: 15rpx;
  263 +}
  264 +
  265 +.Whether .Submission {
  266 + margin-top: 40rpx;
  267 +}
  268 +
  269 +.Whether .white {
  270 + width: 364rpx;
  271 + height: 58rpx;
  272 + background-color: rgb(212, 28, 52);
  273 + border-radius: 40rpx;
  274 + line-height: 58rpx;
  275 +}
  276 +
... ...