Ver código fonte

同城店铺新建流程重构

zhujindu 1 ano atrás
pai
commit
9a76a1c127

+ 92 - 84
src/components/uploadImgVStorec.vue

@@ -1,143 +1,150 @@
 <template>
-    <div class="cameraDiv1">
-<!--      <div class="imgPre">-->
-<!--        <van-icon class="photobrowsing" name="expand-o" size="22px" color="#969696" v-if="imgArr!=''" @click="deleteImgs(imgArr)"/>-->
-<!--        <img :src="imgArr" alt="" v-if="imgArr!=''">-->
-<!--      </div>-->
-      <p class="coverImg" @click="uploadImg">
-        <van-icon class="photo ico" name="photograph" size="16px" color="#969696">{{ imgText }}</van-icon>
-      </p>
-    </div>
+  <div class="cameraDiv1">
+    <!--      <div class="imgPre">-->
+    <!--        <van-icon class="photobrowsing" name="expand-o" size="22px" color="#969696" v-if="imgArr!=''" @click="deleteImgs(imgArr)"/>-->
+    <!--        <img :src="imgArr" alt="" v-if="imgArr!=''">-->
+    <!--      </div>-->
+    <p class="coverImg" @click="uploadImg">
+      <van-icon class="photo ico" name="photograph" size="16px" color="#969696">{{
+        imgText
+      }}</van-icon>
+    </p>
+  </div>
 </template>
 
 <script>
-import {ImagePreview} from "vant";
+import { ImagePreview } from 'vant';
 import axios from 'axios';
-import {uploadImagev} from "@/api/index";
+import { uploadImagev } from '@/api/index';
 
 export default {
   name: 'uploadImg',
   props: {
     uploadid: {
       type: String,
-      default: ''
+      default: '',
     },
     imgText: {
       type: String,
-      default: ''
+      default: '',
     },
     visitsId: {
       type: String,
-      default: ''
+      default: '',
     },
     taskId: {
       type: String,
-      default: ''
+      default: '',
     },
     collectionId: {
       type: String,
-      default: ''
+      default: '',
     },
     type: {
       type: Number,
-      default: 1
+      default: 1,
     },
     imgArr: {
       type: String,
-      default: ''
+      default: '',
     },
   },
   data() {
     return {
       shows: false,
-      url: ""
-    }
+      url: '',
+    };
   },
   methods: {
     deleteImgs(val) {
       ImagePreview([val]);
     },
-    uploadImg(){
+    uploadImg() {
       if (localStorage.getItem('chainName') == null) {
-        this.$toast("请输入名称!")
-        return
+        this.$toast('请输入名称!');
+        return;
       }
       let url = window.location.href;
       let that = this;
-      let wx = this.wx
-      let qiyeData
+      let wx = this.wx;
+      let qiyeData;
       const instance = axios.create();
-      instance.defaults.headers.common['userId'] = localStorage.getItem("loginName");
-      instance.get(process.env.VUE_APP_BASE_API + 'mobile/wx/ticket',
-          {
-            params: {
-              url: url
-            }
-          }).then(response => {
-        if (response.status == 200) {
-          qiyeData = response.data.data;
-          wx.config({
-            beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
-            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
-            appId: qiyeData.appId, // 必填,企业微信的corpID
-            timestamp: qiyeData.timestamp, // 必填,生成签名的时间戳
-            nonceStr: qiyeData.nonceStr, // 必填,生成签名的随机串
-            signature: qiyeData.signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法
-            jsApiList: ["ready", "chooseImage","uploadImage"] // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
-          });
-          wx.ready(function () {
-            wx.chooseImage({
-              count: 1,
-              sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
-              sourceType: ['camera'], // 可以指定来源是相册还是相机,默认二者都有
-              defaultCameraMode: "normal", //表示进入拍照界面的默认模式,目前有normal与batch两种选择,normal表示普通单拍模式,batch表示连拍模式,不传该参数则为normal模式。从3.0.26版本开始支持front和batch_front两种值,其中front表示默认为前置摄像头单拍模式,batch_front表示默认为前置摄像头连拍模式。(注:用户进入拍照界面仍然可自由切换两种模式)
-              isSaveToAlbum:0,
-              success: function (res) {
-                var localIds=""
-                if(res.localIds!=undefined){
-                  localIds= res.localIds[0]
-                }else{
-                  localIds=res.localId
-                }
-                // andriod中localId可以作为img标签的src属性显示图片;
-                // iOS应当使用 getLocalImgData 获取图片base64数据,从而用于img标签的显示(在img标签内使用 wx.chooseImage 的 localid 显示可能会不成功)
-                wx.uploadImage({
-                  localId: localIds, // 需要上传的图片的本地ID,由chooseImage接口获得
-                  isShowProgressTips: 1, // 默认为1,显示进度提示
-                  success: function (res) {
-                    that.uploadImagev(res.serverId)
+      instance.defaults.headers.common['userId'] = localStorage.getItem('loginName');
+      instance
+        .get(process.env.VUE_APP_BASE_API + 'mobile/wx/ticket', {
+          params: {
+            url: url,
+          },
+        })
+        .then((response) => {
+          if (response.status == 200) {
+            qiyeData = response.data.data;
+            wx.config({
+              beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
+              debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+              appId: qiyeData.appId, // 必填,企业微信的corpID
+              timestamp: qiyeData.timestamp, // 必填,生成签名的时间戳
+              nonceStr: qiyeData.nonceStr, // 必填,生成签名的随机串
+              signature: qiyeData.signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法
+              jsApiList: ['ready', 'chooseImage', 'uploadImage'], // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
+            });
+            wx.ready(function () {
+              wx.chooseImage({
+                count: 1,
+                sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
+                sourceType: ['camera'], // 可以指定来源是相册还是相机,默认二者都有
+                defaultCameraMode: 'normal', //表示进入拍照界面的默认模式,目前有normal与batch两种选择,normal表示普通单拍模式,batch表示连拍模式,不传该参数则为normal模式。从3.0.26版本开始支持front和batch_front两种值,其中front表示默认为前置摄像头单拍模式,batch_front表示默认为前置摄像头连拍模式。(注:用户进入拍照界面仍然可自由切换两种模式)
+                isSaveToAlbum: 0,
+                success: function (res) {
+                  var localIds = '';
+                  if (res.localIds != undefined) {
+                    localIds = res.localIds[0];
+                  } else {
+                    localIds = res.localId;
                   }
-                });
-              }
+                  // andriod中localId可以作为img标签的src属性显示图片;
+                  // iOS应当使用 getLocalImgData 获取图片base64数据,从而用于img标签的显示(在img标签内使用 wx.chooseImage 的 localid 显示可能会不成功)
+                  wx.uploadImage({
+                    localId: localIds, // 需要上传的图片的本地ID,由chooseImage接口获得
+                    isShowProgressTips: 1, // 默认为1,显示进度提示
+                    success: function (res) {
+                      that.uploadImagev(res.serverId);
+                    },
+                  });
+                },
+              });
             });
-          })
-        }
-      });
+          }
+        });
     },
-    uploadImagev(meidaId){
+    uploadImagev(meidaId) {
       var that = this;
-      var form={
-        mediaId:meidaId,
-        storeName:localStorage.getItem('chainName')
-      }
+      var form = {
+        mediaId: meidaId,
+        storeName: localStorage.getItem('chainName'),
+      };
       var loind1 = that.$toast.loading({
         duration: 0,
         message: '上传中...',
         forbidClick: true,
       });
-      uploadImagev(form).then(res=>{
+      uploadImagev(form).then((res) => {
         if (res.code == 200) {
-          that.imgArr = res.data.url
+          // that.imgArr = res.data.url
+          let imgArr = [];
+          res.data.forEach((item) => {
+            imgArr.push(item.url);
+          });
           loind1.clear();
-          that.$toast("上传成功!")
-          that.$emit('newimgarr', {fileUrl: res.data.url, type: that.type});
+          that.$toast('上传成功!');
+          that.$emit('newimgarr', { fileUrl: imgArr.join(','), type: that.type });
         } else {
-          that.$toast("上传失败!")
+          that.$toast('上传失败!');
         }
-      })
-    }
+      });
+    },
   },
-}
+};
 </script>
 
 <style scoped>
@@ -177,7 +184,7 @@ export default {
   z-index: 99;
   background-color: rgba(255, 255, 255, 0.8);
   border-bottom-left-radius: 3px;
-  border-top-left-radius: 3px
+  border-top-left-radius: 3px;
 }
 
 .coverImg {
@@ -186,7 +193,8 @@ export default {
   top: 0;
   right: 0;
   height: 20px;
-  width: 100%;margin: 0;
+  width: 100%;
+  margin: 0;
 }
 
 .coverImg .ico {

+ 0 - 1
src/views/storeManagement/storeDetail.vue

@@ -1460,7 +1460,6 @@ export default {
               res.data.orderUrl != null &&
               (res.data.orderUrl != '') & (res.data.orderUrl != undefined)
             ) {
-              localStorage.setItem('storeId', res.data.sfaStore.storeId);
               // window.location.replace(res.data.orderUrl);
               that.$dialog
                 .confirm({

+ 3 - 1
src/views/storeManagement/success.vue

@@ -91,7 +91,9 @@ export default {
     },
     // 返回订单详情也
     gobackStoreDetail() {
-      window.location.replace(window.location.origin + '/mobile/storeDetail?id=' + this.fromValue);
+      window.location.replace(
+        window.location.origin + '/mobile/storeDetail?id=' + this.fromValue.storeId
+      );
     },
     visite() {
       var that = this;