Commit 534c226c2c293f5637e23daab58251093d552748

Authored by yvan.ni
1 parent 4a27cbff

商品详情,添加评论

pages/goods/goodsInfo/goodsInfo.js
... ... @@ -999,6 +999,7 @@ Page({
999 999 }
1000 1000 });
1001 1001 },
  1002 +
1002 1003 previewCommentImgs: function(t) {
1003 1004 var e = this.data.comments[t.currentTarget.dataset.cidx].img;
1004 1005 wx.previewImage({
... ... @@ -1006,6 +1007,17 @@ Page({
1006 1007 urls: e
1007 1008 });
1008 1009 },
  1010 +
  1011 + previewCommentImgs_w: function(t) {
  1012 + var e = this.data.comments[t.currentTarget.dataset.cidx].weapp_img;
  1013 + wx.previewImage({
  1014 + current: e[t.currentTarget.dataset.id],
  1015 + urls: e
  1016 + });
  1017 + },
  1018 +
  1019 +
  1020 +
1009 1021 previewGoodsCommentImgs: function(t) {
1010 1022 var e = this,
1011 1023 a = this.data.data.comment[t.currentTarget.dataset.cidx].img;
... ...
pages/goods/goodsInfo/goodsInfo.wxml
... ... @@ -624,8 +624,8 @@
624 624 </view>
625 625 </block>
626 626 <block wx:if="{{item.source_type==1}}">
627   - <view class="img-li" wx:for="{{item.img}}" wx:if="{{aitem.length>10}}" wx:key="{{index}}" wx:for-item="aitem">
628   - <image bindtap="previewCommentImgs" class="wh100" data-cidx="{{cIdx}}"
  627 + <view class="img-li" wx:for="{{item.weapp_img}}" wx:if="{{aitem.length>10}}" wx:key="{{index}}" wx:for-item="aitem">
  628 + <image bindtap="previewCommentImgs_w" class="wh100" data-cidx="{{cIdx}}"
629 629 data-id="{{index}}" src="{{aitem}}"></image>
630 630 </view>
631 631 </block>
... ...
pages/user/add_comment/add_comment.js
... ... @@ -147,14 +147,16 @@ Page({
147 147 },
148 148 // 上传图片
149 149 chooseImg: function (e) {
  150 + var imgs = that.data.imgs;
  151 + if (imgs.length >= 3){
  152 + if(this.data.lenMore==0){
  153 + this.setData({ lenMore: 1 });
  154 + }
  155 + return false;
  156 + }
150 157 var that = this;
151 158 var imgs = this.data.imgs;
152   - if (imgs.length >= 3) {
153   - this.setData({
154   - lenMore: 1
155   - });
156   - return false;
157   - }
  159 +
158 160 wx.chooseImage({
159 161 // count: 1, // 默认9
160 162 sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
... ... @@ -162,19 +164,21 @@ Page({
162 164 success: function (res) {
163 165 // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
164 166 var tempFilePaths = res.tempFilePaths;
165   - var imgs = that.data.imgs;
166   - // console.log(tempFilePaths + '----');
167   - for (var i = 0; i < tempFilePaths.length; i++) {
168   - if (imgs.length >= 3) {
169   - that.setData({
170   - imgs: imgs
171   - });
172   - return false;
173   - } else {
174   - imgs.push(tempFilePaths[i]);
  167 + imgs.push(tempFilePaths[i]);
  168 +
  169 + e.uploadFile("/api/weshop/comment/uploadCommentImg", {
  170 + filePath: s.data.imgs[a],
  171 + name: "file",
  172 + success: function (e) {
  173 + console.log("uploadPhotos");
  174 + console.log(e.data);
  175 + if(e.data.code==0)
  176 + s.data.uploadPath[a] = e.data.data, s.uploadPhotos(t, a + 1);
175 177 }
176   - }
177   - // console.log(imgs);
  178 + });
  179 +
  180 +
  181 +
178 182 that.setData({
179 183 imgs: imgs
180 184 });
... ...