<em id="09ttv"></em>
    <sup id="09ttv"><pre id="09ttv"></pre></sup>
    <dd id="09ttv"></dd>

        • 九宮格方式上傳圖片(預覽并刪除)

          2020-1-20    前端達人

          <view class="gallery">

              <view class="item" wx:for="{{images}}" wx:key="">

                  <image src="{{item}}" data-src="{{item}}" bindtap="previewImage" mode="aspectFill" />



                  <!-- 刪除按鈕 -->

                  <view class="delete" bindtap="delete" data-index="{{index}}">X</view>

              </view>

              <view class="item" bindtap="chooseImage">

                  <view class='addIcon'>+</view>

              </view>

          </view>

          <button type="primary" bindtap="submit">提交</button>

          ————————————————



          /* pages/index/index.wxss */
          /*畫廊*/
          .gallery {    
            width:630rpx;
            margin: 0 auto;
            display: flex;    
            justify-content: flex-start;    
            flex-wrap: wrap;
          }
          /*每張圖片所占容器*/
          .item {    
            position: relative;    
            margin:10rpx 5rpx;
            width: 200rpx;
            height: 200rpx;
          }
          .item image{
            width: 100%;
            height: 100%;
          }
          /*add按鈕*/
          .item .addIcon{
            position:relative;
            width:200rpx;
            height:200rpx;
            text-align:center;
            line-height:200rpx;
            font-size:80rpx;
            background: #f2f2f2;
            color: #555;
          }
          /*刪除按鈕*/
          .delete {    
            position:absolute;
            right:0;
            top:0;
            /* background:#ccc; */
            opacity:1;
            height: 36rpx;
            font-size:22rpx;
            font-weight:700;
            padding:0 8rpx 0 10rpx;
          }
          ————————————————


          var that;
          Page({
            data: {
              images: [],
              uploadedImages: [],
              //imageWidth: getApp().screenWidth / 4 - 10
            },
            onLoad: function (options) {
              that = this; var objectId = options.objectId; console.log(objectId);
            },
            chooseImage: function () {
              // 選擇圖片
              wx.chooseImage({
                count: 3, // 默認9
                sizeType: ['compressed'],
                sourceType: ['album', 'camera'],
                // 可以指定來源是相冊還是相機,默認二者都有
                success: function (res) {
                  // 返回選定照片的本地文件路徑列表,tempFilePath可以作為img標簽的src屬性顯示圖片
                  var tempFilePaths = res.tempFilePaths;
                  console.log(tempFilePaths);
                  that.setData({
                    images: that.data.images.concat(tempFilePaths)
                  });
                }
              })
            },
            // 圖片預覽
            previewImage: function (e) {
              //console.log(this.data.images);
              var current = e.target.dataset.src
              wx.previewImage({
                current: current,
                urls: this.data.images
              })
            },
            // submit: function () {        
            //   // 提交圖片,事先遍歷圖集數(shù)組
            //   that.data.images.forEach(function (tempFilePath) {
            //     new AV.File('file-name', {
            //       blob: {
            //         uri: tempFilePath,
            //       },
            //     }).save().then(                
            //       // file => console.log(file.url())
            //     function (file) {                    
            //       // 先讀取
            //       var uploadedImages = that.data.uploadedImages;
            //       uploadedImages.push(file.url());                    
            //       // 再寫入
            //       that.setData({
            //         uploadedImages: uploadedImages
            //       }); console.log(uploadedImages);
            //     }
            //     ).catch(console.error);
            //   });
            //   wx.showToast({
            //     title: '評價成功', success: function () {
            //       wx.navigateBack();
            //     }
            //   });
            // }, 
            delete: function (e) {
              var index = e.currentTarget.dataset.index; var images = that.data.images;
              images.splice(index, 1);
              that.setData({
                images: images
              });
            }
          })
          ————————————————


          日歷

          鏈接

          個人資料

          藍藍設計的小編 http://www.sdgs6788.com

          存檔

          国产成人精品久久亚洲| 久久久久亚洲AV成人网人人网站| 国产精品久久成人影院| 18岁日韩内射颜射午夜久久成人| 久久夜色撩人精品国产| 囯产精品久久久久久久久蜜桃 | 一级做a爱片久久毛片| 国产精品无码久久四虎| 久久综合88熟人妻| 久久久久国产一级毛片高清板| 成人久久免费网站| 久久精品人妻一区二区三区| 国产精品久久久久AV福利动漫| 久久亚洲国产成人影院网站 | 狠狠色综合网站久久久久久久| 久久久久青草线蕉综合超碰| 国产精品九九久久精品女同亚洲欧美日韩综合区 | 一级做a爰片久久毛片16| 日韩精品久久久肉伦网站| 要久久爱在线免费观看| 国产伊人久久| 国产精品亚洲美女久久久| 狠狠色婷婷综合天天久久丁香| 7777久久久国产精品消防器材| 亚洲国产精品嫩草影院久久| 久久e热在这里只有国产中文精品99| 久久婷婷五月综合97色 | 日韩人妻无码一区二区三区久久 | 国产精品成人精品久久久 | 久久国产免费直播| 99久久亚洲综合精品网站| 久久精品国产91久久综合麻豆自制| 一本色道久久88精品综合| 国产成人无码精品久久久性色| 欧美亚洲国产精品久久高清 | 国内精品久久久久影院一蜜桃| 亚洲狠狠婷婷综合久久蜜芽| 久久久久久久久久久精品尤物| 国产精品一区二区久久精品涩爱 | 中文字幕久久亚洲一区| 性高湖久久久久久久久AAAAA|