diff --git a/pages/user/add_comment/add_comment.js b/pages/user/add_comment/add_comment.js index a7af5d9..2ebc35a 100644 --- a/pages/user/add_comment/add_comment.js +++ b/pages/user/add_comment/add_comment.js @@ -1,130 +1,197 @@ -var t = getApp(),oo=t.globalData, a = t.globalData.setting,os=a, e = t.request, s = require("../../../utils/util.js"), - i = require("../../../utils/selectFiles.js"); +var t = getApp(), oo = t.globalData, a = t.globalData.setting, os = a, e = t.request, s = require("../../../utils/util.js"), + i = require("../../../utils/selectFiles.js"); var regeneratorRuntime = require('../../../utils/runtime.js'); Page({ - data: { - url: a.url, - resourceUrl: a.resourceUrl, - iurl: a.imghost, - defaultPhoto: a.resourceUrl + "/static/images/camera.png", - filePaths: [], - uploadPath: [], - maxWord: 0, - is_anonymous: !1, - goods_rank: 0, - service_rank: 0, - deliver_rank: 0, - content: "", - options: null, - isLongPress: !1, - userinfo:null, - }, - onLoad:async function(a) { - var th=this; - console.log('onLoad'); - console.log(a); + data: { + url: a.url, + resourceUrl: a.resourceUrl, + iurl: a.imghost, + defaultPhoto: a.resourceUrl + "/static/images/camera.png", + filePaths: [], + uploadPath: [], + maxWord: 0, + is_anonymous: !1, + goods_rank: 0, + service_rank: 0, + deliver_rank: 0, + content: "", + options: null, + isLongPress: !1, + userinfo: null, + imgs: [], + lenMore:0 + }, + onLoad: async function (a) { + var th = this; + console.log('onLoad'); + console.log(a); - await getApp().request.promiseGet("/api/weshop/goods/get/"+os.stoid+"/"+a.goods_id,{1:1}).then(res=>{ - a.img=th.data.iurl+res.data.data.original_img - }) + await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + a.goods_id, { 1: 1 }).then(res => { + a.img = th.data.iurl + res.data.data.original_img + }) - this.setData({options: a}); - t.getUserInfo(function(e){ - console.log(e); - th.setData({ - userinfo:e - }) - }) - }, - keyUpChangeNum: function(t) { - this.setData({ - maxWord: t.detail.value.length - }), this.data.content = t.detail.value; - }, - checkAnonymous: function() { - this.setData({ - is_anonymous: !this.data.is_anonymous + this.setData({ options: a }); + t.getUserInfo(function (e) { + console.log(e); + th.setData({ + userinfo: e + }) + }) + }, + keyUpChangeNum: function (t) { + this.setData({ + maxWord: t.detail.value.length + }), this.data.content = t.detail.value; + }, + checkAnonymous: function () { + this.setData({ + is_anonymous: !this.data.is_anonymous + }); + }, + checkGoodsRank: function (t) { + this.setData({ + goods_rank: parseInt(t.currentTarget.dataset.i) + 1 + }); + }, + checkServiceRank: function (t) { + this.setData({ + service_rank: parseInt(t.currentTarget.dataset.i) + 1 + }); + }, + checkDeliverRank: function (t) { + this.setData({ + deliver_rank: parseInt(t.currentTarget.dataset.i) + 1 + }); + }, + selectPhotos: function (t) { + if (this.data.isLongPress) this.data.isLongPress = !1; else { + var a = this; + i.selectPhotos(this.data.filePaths, t.currentTarget.dataset.idx, function (t) { + a.setData({ + filePaths: t }); - }, - checkGoodsRank: function(t) { - this.setData({ - goods_rank: parseInt(t.currentTarget.dataset.i) + 1 - }); - }, - checkServiceRank: function(t) { - this.setData({ - service_rank: parseInt(t.currentTarget.dataset.i) + 1 - }); - }, - checkDeliverRank: function(t) { - this.setData({ - deliver_rank: parseInt(t.currentTarget.dataset.i) + 1 - }); - }, - selectPhotos: function(t) { - if (this.data.isLongPress) this.data.isLongPress = !1; else { - var a = this; - i.selectPhotos(this.data.filePaths, t.currentTarget.dataset.idx, function(t) { - a.setData({ - filePaths: t - }); - }); + }); + } + }, + removePhoto: function (t) { + var a = this; + this.data.isLongPress = !0, i.removePhoto(this.data.filePaths, t.currentTarget.dataset.idx, function (t) { + a.setData({ + filePaths: t + }); + }); + }, + submitComment: function () { + var a = this; + if (!a.data.service_rank || !a.data.goods_rank || !a.data.deliver_rank) return t.showWarning("请先打完分~"); + this.uploadPhotos(function () { + e.post("/api/weshop/comment/savecomment", { + data: { + email: ' ', + is_show: 1, + goods_rank: a.data.goods_rank, + service_rank: a.data.service_rank, + deliver_rank: a.data.deliver_rank, + content: a.data.content, + goods_id: a.data.options.goods_id, + order_id: a.data.options.order_id, + user_id: oo.user_id, + store_id: os.stoid, + username: a.data.userinfo.nickname + }, + success: function (a) { + wx.setStorageSync("user:comment:update", !0), t.showSuccess("评论成功", function () { + wx.navigateBack(); + }); } - }, - removePhoto: function(t) { - var a = this; - this.data.isLongPress = !0, i.removePhoto(this.data.filePaths, t.currentTarget.dataset.idx, function(t) { - a.setData({ - filePaths: t - }); - }); - }, - submitComment: function() { - var a = this; - if (!a.data.service_rank || !a.data.goods_rank || !a.data.deliver_rank) return t.showWarning("请先打完分~"); - this.uploadPhotos(function() { - e.post("/api/weshop/comment/savecomment", { - data: { - email:' ', - is_show:1, - goods_rank: a.data.goods_rank, - service_rank: a.data.service_rank, - deliver_rank: a.data.deliver_rank, - content: a.data.content, - goods_id: a.data.options.goods_id, - order_id: a.data.options.order_id, - user_id: oo.user_id, - store_id:os.stoid, - username: a.data.userinfo.nickname - }, - success: function(a) { - wx.setStorageSync("user:comment:update", !0), t.showSuccess("评论成功", function() { - wx.navigateBack(); - }); - } - }); - }); - }, - uploadPhotos: function(t, a) { - if (0 == this.data.filePaths.length) return t(); - if ("number" != typeof a) a = 0; else if (a >= this.data.filePaths.length) return t(); - var s = this; - e.uploadFile("/api/user/upload_comment_img", { - filePath: s.data.filePaths[a], - name: "img_file", - success: function(e) { - s.data.uploadPath[a] = e.data.result, s.uploadPhotos(t, a + 1); - } - }); - }, + }); + }); + }, + uploadPhotos: function (t, a) { + if (0 == this.data.filePaths.length) return t(); + if ("number" != typeof a) a = 0; else if (a >= this.data.filePaths.length) return t(); + var s = this; + e.uploadFile("/api/user/upload_comment_img", { + filePath: s.data.filePaths[a], + name: "img_file", + success: function (e) { + s.data.uploadPath[a] = e.data.result, s.uploadPhotos(t, a + 1); + } + }); + }, - //图片失败,默认图片 - bind_bnerr2: function (e) { + //图片失败,默认图片 + bind_bnerr2: function (e) { var _errImg = e.target.dataset.errorimg; var _errObj = {}; - _errObj[_errImg] = a.imghost+"/public/images/default_goods_image_240.gif"; + _errObj[_errImg] = a.imghost + "/public/images/default_goods_image_240.gif"; this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; - } + }, + // 上传图片 + chooseImg: function (e) { + var that = this; + var imgs = this.data.imgs; + if (imgs.length >= 3) { + this.setData({ + lenMore: 1 + }); + setTimeout(function () { + that.setData({ + lenMore: 0 + }); + }, 2500); + return false; + } + wx.chooseImage({ + // count: 1, // 默认9 + sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 + sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 + success: function (res) { + // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片 + var tempFilePaths = res.tempFilePaths; + var imgs = that.data.imgs; + // console.log(tempFilePaths + '----'); + for (var i = 0; i < tempFilePaths.length; i++) { + if (imgs.length >= 3) { + that.setData({ + imgs: imgs + }); + return false; + } else { + imgs.push(tempFilePaths[i]); + } + } + // console.log(imgs); + that.setData({ + imgs: imgs + }); + } + }); + }, + // 删除图片 + deleteImg: function (e) { + var imgs = this.data.imgs; + var index = e.currentTarget.dataset.index; + imgs.splice(index, 1); + this.setData({ + imgs: imgs + }); + }, + // 预览图片 + previewImg: function (e) { + //获取当前图片的下标 + var index = e.currentTarget.dataset.index; + //所有图片 + var imgs = this.data.imgs; + wx.previewImage({ + //当前显示图片 + current: imgs[index], + //所有图片 + urls: imgs + }) + }, + + }); \ No newline at end of file diff --git a/pages/user/add_comment/add_comment.json b/pages/user/add_comment/add_comment.json index 1387a9a..54834f9 100644 --- a/pages/user/add_comment/add_comment.json +++ b/pages/user/add_comment/add_comment.json @@ -1,4 +1,4 @@ { - "navigationBarTitleText": "评价晒单", + "navigationBarTitleText": "评价宝贝", "enablePullDownRefresh": false } \ No newline at end of file diff --git a/pages/user/add_comment/add_comment.wxml b/pages/user/add_comment/add_comment.wxml index 8c24cca..083ac03 100644 --- a/pages/user/add_comment/add_comment.wxml +++ b/pages/user/add_comment/add_comment.wxml @@ -1,4 +1,4 @@ - + - + + + + + + + + + + {{options.goods_name}}我弄饭v的v哦女v绝我弄饭v的v哦女v绝望愤怒冻死我弄饭v的v哦女v绝望愤怒冻死望愤怒冻死 + + + + + + {{options.price}}3333.00 + + + + + x + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + 添加图片 + {{imgs.length>0?imgs.length:0}}/3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + 宝贝评分 + + + + + + 描述相符 + + + + + + + + 物流服务 + + + + + + + 服务态度 + + + + + + + + + + + + + + + + + + + 匿名评价 + + + + + 提交评价 + + + + + + \ No newline at end of file diff --git a/pages/user/add_comment/add_comment.wxss b/pages/user/add_comment/add_comment.wxss index c6f31b8..8fb7f14 100644 --- a/pages/user/add_comment/add_comment.wxss +++ b/pages/user/add_comment/add_comment.wxss @@ -1,4 +1,4 @@ -.goods-mes { +/* .goods-mes { height: 100rpx; display: flex; padding: 30rpx; @@ -119,4 +119,157 @@ background-color: #f15353; color: #fff; margin: auto; -} \ No newline at end of file +} */ + +/* 商品详情和评价 */ + +.commodity { + height: 715rpx; + border-top: 6rpx solid rgb(245, 245, 245); + border-bottom: 6rpx solid rgb(245, 245, 245); + padding: 0rpx 30rpx; +} + +.commodity .information { + height: 286rpx; +} + +.commodity .information image { + width: 186rpx; + height: 186rpx; +} + +.information .goods_name { + width: 480rpx; + margin-left: 25rpx; + height: 186rpx; +} + +.information .goods_name .ellipsis-2 { + line-height: 40rpx; + height: 80rpx; +} + +.information .goods_name .jc_sb { + margin-top: 60rpx; + color: rgb(212, 28, 52); + margin-right: 7rpx; +} + +.information .goods_name .jc_sb .fs32 { + line-height: 40rpx; +} + +.information .goods_name .jc_sb .sum { + margin-right: 5rpx; +} + +.balin { + align-items: baseline; +} + +.addComment { + height: 345rpx; + width: 690rpx; + background-color: rgb(248, 248, 248); + padding: 32rpx 0rpx 21rpx 0rpx; +} + +.addComment textarea { + padding: 0rpx 18rpx; + height: 175rpx; + width: 654rpx; +} + +.addComment .addimages { + padding: 0rpx 18rpx; + margin-top: 20rpx; + align-items: flex-end; + width: 652rpx; +} + +.addComment .addimages .images { + height: 140rpx; +} + +.addComment .addimages .images .rel { + width: 140rpx; + height: 100%; + overflow: visible; + margin-right: 15rpx; +} + +.addComment .addimages .images image .abs { + width: 30rpx; + height: 30rpx; + top: -7rpx; + right: -7rpx; +} + +.addComment .addimage { + width: 139rpx; + height: 139rpx; + border: 2rpx dashed rgb(196, 196, 196); + font-size: 16rpx; + margin-left: 6rpx; +} + +.addComment .addimage image { + width: 60rpx; + height: 58rpx; +} + +.Grade { + width: 100%; + height: 310rpx; + border-bottom: 6rpx solid rgb(245, 245, 245); + padding-left: 45rpx; +} + +.Grade .title { + width: 100%; + height: 105rpx; +} + +.Grade .title .column { + height: 30rpx; + border-left: 6rpx solid rgb(211, 27, 58); + margin-right: 12rpx; +} + +.Grade .score-item { + height: 55rpx; + line-height: 55rpx; +} + +.Grade .score-item .stars { + margin-left: 83rpx; +} + +.Grade .score-item .stars image { + width: 35rpx; + height: 35rpx; + margin-right: 28rpx; +} + +.Whether .flex-right-vertical { + height: 67rpx; + padding-right: 31rpx; +} + +.Whether .flex-right-vertical .radio { + margin-right: 15rpx; +} + +.Whether .Submission { + margin-top: 40rpx; +} + +.Whether .white { + width: 364rpx; + height: 58rpx; + background-color: rgb(212, 28, 52); + border-radius: 40rpx; + line-height: 58rpx; +} +