zhoupeng 1 жил өмнө
parent
commit
8e14e9ad47

+ 1 - 1
app.json

@@ -5,7 +5,7 @@
   "window": {
     "backgroundTextStyle": "light",
     "navigationBarBackgroundColor": "#fff",
-    "navigationBarTitleText": "考试作答小程序v1.1.4",
+    "navigationBarTitleText": "考试作答小程序v1.1.7",
     "navigationBarTextStyle": "black"
   },
   "sitemapLocation": "sitemap.json"

+ 16 - 7
pages/index/component/PicturePanel/index.js

@@ -83,6 +83,7 @@ Component({
         itemList: ['拍照'],
         success: chooseResult => {
           console.log('showActionSheet',this.data.pictures.length)
+          console.log('chooseResult.tapIndex1',chooseResult.tapIndex)
           if (this.data.pictures.length >= MAX_PICTURE) {
             wx.showToast({
               title: '一次最多只能选择6张',
@@ -91,23 +92,28 @@ Component({
             })
             return
           }
+          console.log('chooseResult.tapIndex2',chooseResult.tapIndex)
           that.setData({
             gridLoading: true
           })
-
-          
+          console.log('chooseResult.tapIndex3',chooseResult.tapIndex)
           switch (chooseResult.tapIndex) {
             case 0:
-              wx.chooseImage({
+              wx.chooseMedia({
                 sourceType: ['camera'],
                 sizeType: ['original'],
+                mediaType: ['image'],
+                camera: 'back',
+                fail: e => {
+                    console.log('chooseMedia:fail:' + e.errMsg)
+                },
                 success: res => {
                   console.log(res);
                   var pictures = that.data.pictures
 
                   res.tempFiles.forEach(function (item, idx) {
                     console.log(idx, item)
-                    item['suffix'] = item.path.substring(item.path.lastIndexOf(".") + 1, item.path.length)
+                    item['suffix'] = item.tempFilePath.substring(item.tempFilePath.lastIndexOf(".") + 1, item.tempFilePath.length)
                     item['err'] = SUFFIX.indexOf(item['suffix'].toLowerCase()) > -1 ? '' : '图片格式错误'
                     if (item['err'] == '') {
                       item['err'] = item.size > 1024 * 1024 * 10 ? '图片超过10M' : ''
@@ -116,6 +122,7 @@ Component({
                   })
                   console.log(res.tempFiles)
                   Array.prototype.push.apply(pictures, res.tempFiles);
+                  console.log('pictures::' + pictures)
                   that.setData({
                     pictures: pictures,
                   })
@@ -128,10 +135,12 @@ Component({
               })
               break;
             case 1:
-              wx.chooseImage({
+              wx.chooseMedia({
                 count: MAX_PICTURE - that.data.pictures.length,
                 sizeType: ['original'],
                 sourceType: ['album'],
+                mediaType: ['image'],
+                camera: 'back',
                 success: res => {
                   console.log(res);
                   var pictures = that.data.pictures
@@ -140,7 +149,7 @@ Component({
                   res.tempFiles.forEach(function (item, idx) {
                     console.log(idx, item)
                     if (that.data.pictures.length + idx + 1 <= MAX_PICTURE) {
-                      item['suffix'] = item.path.substring(item.path.lastIndexOf(".") + 1, item.path.length)
+                      item['suffix'] = item.tempFilePath.substring(item.tempFilePath.lastIndexOf(".") + 1, item.tempFilePath.length)
                       item['err'] = SUFFIX.indexOf(item['suffix'].toLowerCase()) > -1 ? '' : '图片格式错误'
                       if (item['err'] == '') {
                         item['err'] = item.size > 1024 * 1024 * 10 ? '图片超过10M' : ''
@@ -446,7 +455,7 @@ Component({
       const that = this
       if (retry > 0) {
         wx.compressImage({
-          src: img.path,
+          src: img.tempFilePath,
           quality: 80,
           success: function(cf) {
             console.log('uploadImage:compressImage:success',cf)

+ 1 - 1
pages/index/component/PicturePanel/index.wxml

@@ -18,7 +18,7 @@
         <view class="del" bindtap="del" data-index="{{index}}"><image mode="center" src='/assets/del.png' style='width:28px;height:28px;'></image></view>
         <view class="err" wx:if="{{item.err || (item.status == 'FAIL' && item.retry == 0)}}">{{item.err ? item.err : '请删除或点击确认上传重试'}}</view>
         <!--<view class="success" wx:if="{{item.status == 'SUCCESS'}}">上传成功</view>-->
-        <image mode="scaleToFill" src='{{item.path}}' style="width: {{size}}px;height: {{size}}px;border-radius:10px;"></image>
+        <image mode="scaleToFill" src='{{item.tempFilePath}}' style="width: {{size}}px;height: {{size}}px;border-radius:10px;"></image>
         </view>
       </block>
       <block wx:if="{{pictures.length < maxPicture}}">

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 4 - 2
utils/api.js


+ 3 - 1
utils/api.ts

@@ -137,7 +137,8 @@ export class Api implements API {
     }
 
     initBaseUrl(baseUrl: string) {
-        this.configOption.baseUrl = baseUrl
+        this.configOption.baseUrl = baseUrl.replace(':443', '')
+        console.log("initBaseUri:" + this.configOption.baseUrl)
     }
 
     /**
@@ -365,6 +366,7 @@ export class Api implements API {
         } : {
             'Content-Type': 'application/x-www-form-urlencoded',
         }
+        console.log(that.configOption.baseUrl + option.url);
         console.log(option)
         return new Promise(function (resolve, reject) {
             wx.request({

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно