shish 4 лет назад
Родитель
Сommit
064486a162

+ 17 - 35
ghsApp/src/admin/home/me.vue

@@ -1,7 +1,7 @@
 <template>
   <view class="me-content_box app-content">
     <image :src="`${constant.imgUrl}/ghs/me/bg.png`" class="me-content_bg" ></image>
-    <template v-if="!$util.isEmpty(shopInfo)">
+    <template>
       <view class="me-user_box">
         <view class="user-info_item">
           <view v-if="shopInfo.shopAdminId > 0">
@@ -20,32 +20,30 @@
             <view class="shop-top_left">
               <image :src="shopInfo.shopImg" style="width:110upx;border-radius:100upx;" mode="widthFix"></image>
 
-              <view class="top-info_box" style="font-size:38upx;" v-if="!$util.isEmpty(shopInfo)" @click="pageTo({url:'/admin/home/login'})">
-                <view> 登录/注册 </view>
-              </view>
-
-              <view class="top-info_box" v-else>
+              <view class="top-info_box" v-if="!$util.isEmpty(getLoginInfo.admin) && getLoginInfo.admin.currentShopId > 0">
                 <view> {{ shopInfo.shopName }} </view>
                 <view> <text>{{ shopInfo.sjName }} | SID {{shopInfo.shopId}}</text> </view>
               </view>
+              <view class="top-info_box" style="font-size:38upx;" @click="pageTo({url:'/admin/home/login'})" v-else>
+                <view> 登录/注册 </view>
+              </view>
 
             </view>
             <button v-if="getLoginInfo.switchShop" @click="showAllShop" class="admin-button-com default chang-shop_btn" >
-              <i class="iconfont iconqiehuan1"></i>
-              切换店铺
+              <i class="iconfont iconqiehuan1"></i> 切换店铺
             </button>
           </view>
-          <view @click="pageTo({ url: '/pagesClient/official/renewal' })" class="image-box" >
-            <view class="dec"> 店铺服务期至: {{ shopInfo.deadline.substr(0,11) }} </view>
+          <view class="image-box" >
+            <view class="dec"></view>
             <image :src="`${constant.imgUrl}/ghs/me/upgrade.png`"></image>
           </view>
         </view>
         <view class="account-info_box content_box">
           <view class="info-lf_box">
             <view> 账户余额(元) </view>
-            <view> <text>¥ </text> {{ shopInfo.balance }} </view>
+            <view> <text>¥ </text> {{ shopInfo.balance||0 }} </view>
             <view>
-              可提现余额 ¥ {{ shopInfo.txBalance }}
+              可提现余额 ¥ {{ shopInfo.txBalance||0 }}
               <text v-if="shopInfo.txBalance > 0" @click="checkToApplyCash" class="to-cash" >提现</text>
             </view>
           </view>
@@ -100,10 +98,10 @@
               <div class="tui-title">快递设置</div>
             </tui-list-cell>
             <!-- #ifdef APP-PLUS -->
-            <tui-list-cell @click="closeApp()" class="line-cell" :hover="false" :arrow="true">
+            <tui-list-cell @click="closeApp()" class="line-cell" :hover="false" :arrow="true" v-if="!$util.isEmpty(getLoginInfo.admin) && getLoginInfo.admin.currentShopId > 0">
               <div class="tui-title">关闭APP</div>
             </tui-list-cell>
-            <tui-list-cell @click="loginOut()" class="line-cell" :hover="false" :arrow="true">
+            <tui-list-cell @click="loginOut()" class="line-cell" :hover="false" :arrow="true" v-if="!$util.isEmpty(getLoginInfo.admin) && getLoginInfo.admin.currentShopId > 0">
               <div class="tui-title">退出登陆</div>
             </tui-list-cell>
             <!-- #endif -->
@@ -144,26 +142,16 @@ export default {
     this.init()
   },
   onShow () {
-    if(uni.getStorageSync('switchTabQuery').refresh == '1') {
       this.init()
-      uni.removeStorageSync('switchTabQuery')
-    }
   },
   methods: {
     showAllShop () {
       this.$refs.shopSelectComponent.dropdownShow = true;
     },
     async init () {
-      if(!this.no_shop_show_model) {
-        try {
-          const { data } = await mainMy();
-          this.shopInfo = data;
-          //不要删除此输出,方便查看 shish 20210512
-          console.log('商家ID',data.sjId,'门店ID',data.shopId)
-          uni.stopPullDownRefresh();
-        } finally {
-        }
-      }
+      const { data } = await mainMy();
+      this.shopInfo = data;
+      uni.stopPullDownRefresh()      
     },
     // #ifdef APP-PLUS
     loginOut(){
@@ -176,7 +164,7 @@ export default {
     },
     closeApp(){
         let that = this
-        that.$util.confirmModal({content:'确认退出?'},() => {
+        that.$util.confirmModal({content:'确认关闭?'},() => {
           let type = uni.getSystemInfoSync().platform
           switch(type){
             case 'android':
@@ -235,7 +223,6 @@ export default {
   },
 };
 </script>
-
 <style lang="scss" scoped>
 .me-content_box {
   position: relative;
@@ -305,16 +292,11 @@ export default {
           }
         }
         & .chang-shop_btn {
-          // padding: 20upx 13upx;
-          // width: 176upx;
-          // height: 50upx;
-          // border: 1upx solid #DDDDDD;
           border-radius: 25upx;
           color: #666666;
           position: absolute;
           right: 20upx;
           top: 40upx;
-          // text-align: center;
           & .iconqiehuan1 {
             margin-right: 10upx;
           }
@@ -361,7 +343,7 @@ export default {
         font-weight: bold;
         margin: 30upx 0;
         & > text {
-          font-size: 24upx;
+          font-size: 38upx;
         }
       }
       & > view:nth-child(3) {

+ 7 - 8
ghsApp/src/admin/home/member.vue

@@ -84,20 +84,19 @@ export default {
         },
         {
           name: "消费排行",
-          value: 1
+          value: 0
         },
         {
           name: "欠款排行",
-          value: 2
+          value: 0
         },
       ]
     };
   },
   onPullDownRefresh() {
     this.resetList();
-    this._list().then((res) => {
-      uni.stopPullDownRefresh();
-    });
+    this._list()
+    uni.stopPullDownRefresh()
   },
   onReachBottom() {
     if (!this.list.finished) {
@@ -134,9 +133,9 @@ export default {
           if (this.$util.isEmpty(res.data)){
             return false;
           }
-          this.tabs[0].value = res.data.totalUser;
-          this.tabs[1].value = res.data.totalUser;
-          this.tabs[2].value = res.data.mayGatheringNum;
+          this.tabs[0].value = res.data.totalUser || 0;
+          this.tabs[1].value = res.data.totalUser || 0;
+          this.tabs[2].value = res.data.mayGatheringNum || 0;
         });
     },
     change(e) {

+ 2 - 3
ghsApp/src/admin/home/order.vue

@@ -122,9 +122,8 @@ export default {
   },
   onPullDownRefresh() {
     this.resetList();
-    this._list().then((res) => {
-      uni.stopPullDownRefresh();
-    });
+    this._list()
+    uni.stopPullDownRefresh()
   },
   onReachBottom() {
     if (!this.list.finished) {

+ 14 - 31
ghsApp/src/admin/home/workbench.vue

@@ -82,7 +82,7 @@
 			<div class="total-tit">总览</div>
 			<div class="total-blo">
 				<div class="total-list" v-for="(item, index) in totalData" :key="index" @click="pageTo(item)">
-					<div class="list-num">{{ $util.numberFormat(item.value) }}</div>
+					<div class="list-num">{{ item.value }}</div>
 					<div class="app-color-3">{{ item.name }}</div>
 				</div>
 			</div>
@@ -96,16 +96,12 @@ import { mapGetters,mapActions } from "vuex";
 import FabModule from "@/components/plugin/fab";
 import AppAvatarModule from "@/components/module/app-avatar";
 import ModalModule from "@/components/plugin/modal";
-import { getUser,uniLoginFn } from "@/utils/auth";
+import { getUser } from "@/utils/auth";
 import { consoleIndex } from "@/api/workbench";
 import { closeBook } from "@/api/book";
 import loginModel from "@/components/login-model";
-import {appLogin} from '@/api/common'
-import { getDictionaries } from '@/api/mini'
 import productMins from "@/mixins/product";
 import { allProduct } from '@/api/product'
-import { replaceClientId } from '@/api/admin'
-import { phoneLogin } from "@/api/auth";
 export default {
 	name: "admin-workbench",
 	components: {
@@ -125,11 +121,6 @@ export default {
 				notice: {},
 				todayData: { income:0.00, order:0, custom:0, expend:0.00 }
 			},
-			orderData: [
-				{ name: "待付款", url: "/admin/home/order", type: 4, query: { tabIndex: 1 }, value: 0 },
-				{ name: "待配送", value: 0, url: "/admin/home/order", type: 4, query: { tabIndex: 2 } },
-				{ name: "配送中", value: 0, url: "/admin/home/order", type: 4, query: { tabIndex: 3 } }
-			],
 			tabsData: [
 				{ name: "商城", img: 'ghs/home/shop.png', url: "/admin/home/mall" },
 				{ name: "改价", img: 'ghs/home/gj.png', url: "/admin/changePrice/list" },
@@ -231,10 +222,12 @@ export default {
 		},
 		init() {
 			getUser().then(res => {
-				uni.setNavigationBarTitle({
-					title: res.name
-				});
-			});
+				if(res.name){
+					uni.setNavigationBarTitle({ title: res.name })
+				}else{
+					uni.setNavigationBarTitle({ title: '店铺' })
+				}
+			})
 			this.setIndex()
 		},
 		setIndex(){
@@ -243,31 +236,21 @@ export default {
 				const { asset,menu } = res.data;
 				this.tabsData = menu
 				if (!this.$util.isEmpty(asset)) {
-					// 订单总览
-					this.orderData[0].value = asset.unPayOrder;
-					this.orderData[1].value = asset.unSendOrder;
-					this.orderData[2].value = asset.sendingOrder;
-					// 总览数据
-					this.totalData[0].value = asset.totalUser;
-					this.totalData[1].value = asset.totalVisit;
-					this.totalData[2].value = asset.finishOrder;
-					this.totalData[3].value = asset.totalIncome;
-					this.totalData[4].value = asset.totalExpend;
-					this.totalData[5].value = asset.totalPurchase;
+					this.totalData[0].value = asset.totalUser || '-';
+					this.totalData[1].value = asset.totalVisit || '-';
+					this.totalData[2].value = asset.finishOrder || '-';
+					this.totalData[3].value = asset.totalIncome || '-';
+					this.totalData[4].value = asset.totalExpend || '-';
+					this.totalData[5].value = asset.totalPurchase || '-';
 				}
 			})
 		},
 		goPage (item) {
 			this.$util.pageTo(item)
 		},
-		// 跳转
 		pageToFn(item) {
 			this.$util.pageTo({url: item.page})
 		},
-		// 续费
-		renewFn() {
-			this.$util.pageTo({url: "/pagesClient/official/index",query: {pay: 1},type: 2})
-		},
 		getMyMall(){
 			console.log('pagesPurchase/ghsProduct?shopId='+ this.loginInfo.shopId+'&id=0&ghsShopAdminId='+this.loginInfo.shopAdminId)
 			uni.navigateToMiniProgram({

+ 3 - 3
ghsApp/src/components/login-model.vue

@@ -15,13 +15,13 @@
         <view style="margin-top:50upx;">
         <button class="admin-button-com small default buttonText" @click="loginClick">登陆</button>
         </view>
-
+        <!-- #ifdef APP-PLUS -->
         <view style="margin-top:35upx;">
           <button class="admin-button-com small blue buttonText" @click="mobileLogin">本机号码一键登录</button>
         </view>
-
+        <!-- #endif -->
         <view style="margin-top:60upx;color:#999999;width:88%;font-size:30upx;">
-          <text style="float:right;" @click="pageTo({ url: '/pagesClient/official/apply'})">注册帐号</text>
+          <text style="float:right;" @click="pageTo({url: '/pagesClient/official/apply',type:2})">注册帐号</text>
         </view>
 
       </view>

+ 16 - 11
ghsApp/src/mixins/globalMixins.js

@@ -1,7 +1,7 @@
 import store from '@/store'
 import { mapGetters,mapActions } from 'vuex'
 import { pageTo, isLogin } from '@/utils/util.js'
-import { getUser, uniLoginFn } from '@/utils/auth'
+import { getUser, wxMiniLogin } from '@/utils/auth'
 import { postWxCode, getDictionaries } from '@/api/mini'
 import { getStaffApi,appReGetLoginInfo } from '@/api/common'
 import { allProduct } from '@/api/product'
@@ -55,14 +55,21 @@ export default {
 		if(this.$util.isEmpty(this.getLoginInfo)){
 
       // #ifdef MP-WEIXIN
-			uniLoginFn(true,1).then(res => {
-				getUser(true)
-				//获取门店信息
-				this.setUserShopAll()
-				if (this.init) {
-					this.init()
-				}
-			})
+      //微信小程序第一次打开小程序时尝试登录一次
+      var pages = getCurrentPages()
+			let currentRoute  = pages[pages.length-1].route;
+      if(currentRoute == 'admin/home/workbench'){
+        wxMiniLogin(true).then(res => {
+          let token = res.token || ''
+          if (!this.$util.isEmpty(token)) {
+            getUser(true)
+            this.setUserShopAll()
+          }
+          if (this.init) {
+            this.init()
+          }
+        })
+      }
       // #endif
 
       //#ifdef APP-PLUS
@@ -110,8 +117,6 @@ export default {
     //监听pda扫码开单
     listenPDAkd(){
 
-          var pages = getCurrentPages()
-          let currentRoute  = pages[pages.length-1].route;
           //PDA扫码开单前准备好所有花材,首页已经有加载不再需要
           allProduct().then(res=>{
             this.allProduct = res.data.list

+ 1 - 1
ghsApp/src/pages.json

@@ -50,7 +50,7 @@
 				{"path": "member/bind","style": {"navigationBarTitleText": "绑定微信"}},
 				{"path": "official/index","style": {"navigationBarTitleText": "销花宝"}},
 				{"path": "official/pay","style": {"navigationBarTitleText": "支付"}},
-				{"path": "official/apply","style": {"navigationBarTitleText": "申请"}},
+				{"path": "official/apply","style": {"navigationBarTitleText": "完善店铺信息"}},
 				{"path": "official/clientApply","style": {"navigationBarTitleText": "结果"}},
 				{"path": "official/clientResult","style": {"navigationBarTitleText": "提交审核"}},
 				{"path": "official/renewal","style": {"navigationBarTitleText": "续期"}},

+ 651 - 0
ghsApp/src/pagesClient/components/htz-image-upload/htz-image-upload.vue

@@ -0,0 +1,651 @@
+<template>
+	<view class="htz-image-upload-list">
+		<view class="htz-image-upload-Item" v-for="(item,index) in uploadLists" :key="index">
+			<view class="htz-image-upload-Item-video" v-if="(!/.(gif|jpg|jpeg|png|gif|jpg|png)/i.test(item))">
+				<video :disabled="false" :controls="false" :src="item">
+					<cover-view class="htz-image-upload-Item-video-fixed" @click="previewVideo(item)"></cover-view>
+
+					<cover-view class="htz-image-upload-Item-del-cover" v-if="remove && previewVideoSrc==''"
+						@click="imgDel(index)">×</cover-view>
+
+				</video>
+
+			</view>
+
+			<image v-else :src="item" @click="imgPreview(item)"></image>
+
+			<view class="htz-image-upload-Item-del" v-if="remove" @click="imgDel(index)">×</view>
+		</view>
+		<view class="htz-image-upload-Item htz-image-upload-Item-add" v-if="uploadLists.length<max && add"
+			@click="chooseFile">
+			+
+		</view>
+		<view class="preview-full" v-if="previewVideoSrc!=''">
+			<video :autoplay="true" :src="previewVideoSrc" :show-fullscreen-btn="false">
+				<cover-view class="preview-full-close" @click="previewVideoClose"> × </cover-view>
+			</video>
+		</view>
+
+
+		<!--  -->
+	</view>
+</template>
+
+<style>
+	.ceshi {
+		width: 100%;
+		height: 100%;
+		position: relative;
+		top: 0;
+		left: 0;
+		bottom: 0;
+		right: 0;
+		background-color: #FFFFFF;
+		color: #2C405A;
+		opacity: 0.5;
+		z-index: 100;
+	}
+</style>
+
+<script>
+	export default {
+		name: 'htz-image-upload',
+		props: {
+			max: { //展示图片最大值
+				type: Number,
+				default: 1,
+			},
+			chooseNum: { //选择图片数
+				type: Number,
+				default: 9,
+			},
+			name: { //发到后台的文件参数名
+				type: String,
+				default: 'file',
+			},
+			remove: { //是否展示删除按钮
+				type: Boolean,
+				default: true,
+			},
+			add: { //是否展示添加按钮
+				type: Boolean,
+				default: true,
+			},
+			disabled: { //是否禁用
+				type: Boolean,
+				default: false,
+			},
+			sourceType: { //选择照片来源 【ps:H5就别费劲了,设置了也没用。不是我说的,官方文档就这样!!!】
+				type: Array,
+				default: () => ['album', 'camera'],
+			},
+			action: { //上传地址
+				type: String,
+				default: '',
+			},
+			headers: { //上传的请求头部
+				type: Object,
+				default: () => {},
+			},
+			formData: { //HTTP 请求中其他额外的 form data
+				type: Object,
+				default: () => {},
+			},
+			compress: { //是否需要压缩
+				type: Boolean,
+				default: true,
+			},
+			quality: { //压缩质量,范围0~100
+				type: Number,
+				default: 80,
+			},
+			value: { //受控图片列表
+				type: Array,
+				default: () => [],
+			},
+			uploadSuccess: {
+				default: (res) => {
+					return {
+						success: false,
+						url: ''
+					}
+				},
+			},
+			mediaType: { //文件类型 image/video/all
+				type: String,
+				default: 'image',
+			},
+			maxDuration: { //拍摄视频最长拍摄时间,单位秒。最长支持 60 秒。 (只针对拍摄视频有用)
+				type: Number,
+				default: 60,
+			},
+			camera: { //'front'、'back',默认'back'(只针对拍摄视频有用)
+				type: String,
+				default: 'back',
+			},
+
+		},
+		data() {
+			return {
+				uploadLists: [],
+				mediaTypeData: ['image', 'video', 'all'],
+				previewVideoSrc: '',
+			}
+		},
+		mounted: function() {
+			let that = this
+			this.$nextTick(function() {
+				this.uploadLists = this.value;
+				if (this.mediaTypeData.indexOf(this.mediaType) == -1) {
+					that.$util.confirmModal({content:'mediaType参数不正确'},() => {
+						//console.log('用户点击确定');
+					})
+				}
+			});
+			console.log(this.action)
+		},
+		watch: {
+			value(val, oldVal) {
+				//console.log('value',val, oldVal)
+				this.uploadLists = val;
+			},
+		},
+		methods: {
+			previewVideo(src) {
+				this.previewVideoSrc = src;
+				// this.previewVideoSrc =
+				// 	'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-fbd63a76-dc76-485c-b711-f79f2986daeb/ba804d82-860b-4d1a-a706-5a4c8ce137c3.mp4'
+			},
+			previewVideoClose() {
+				this.previewVideoSrc = ''
+				console.log('previewVideoClose', this.previewVideoSrc)
+			},
+			imgDel(index) {
+				let that = this
+				that.$util.confirmModal({content:'确认删除?'},() => {
+					// that.uploadLists.splice(index, 1)
+					// that.$emit("input", that.uploadLists);
+					// that.$emit("imgDelete", that.uploadLists);
+					let delUrl = that.uploadLists[index]
+					that.uploadLists.splice(index, 1)
+					that.$emit("input", that.uploadLists);
+					that.$emit("imgDelete", {
+						del: delUrl,
+						tempFilePaths: that.uploadLists,
+						index:index
+					});					
+				})
+			},
+			imgPreview(index) {
+
+				var imgData = this.uploadLists.filter(item => /.(gif|jpg|jpeg|png|gif|jpg|png)/i.test(item)) //只预览图片的
+				uni.previewImage({
+					urls: imgData,
+					current: index,
+					loop: true,
+				});
+
+
+			},
+			chooseFile() {
+				if (this.disabled) {
+					return false;
+				}
+				switch (this.mediaTypeData.indexOf(this.mediaType)) {
+					case 1: //视频
+						this.videoAdd();
+						break;
+					case 2: //全部
+						uni.showActionSheet({
+							itemList: ['相册', '视频'],
+							success: (res) => {
+								if (res.tapIndex == 1) {
+									this.videoAdd();
+								} else if (res.tapIndex == 0) {
+									this.imgAdd();
+								}
+							},
+							fail: (res) => {
+								console.log(res.errMsg);
+							}
+						});
+						break;
+					default: //图片
+						this.imgAdd();
+						break;
+				}
+
+
+				//if(this.mediaType=='image'){
+
+
+			},
+			videoAdd() {
+				console.log('videoAdd')
+				let nowNum = Math.abs(this.uploadLists.length - this.max);
+				let thisNum = (this.chooseNum > nowNum ? nowNum : this.chooseNum) //可选数量
+				uni.chooseVideo({
+					compressed: this.compress,
+					sourceType: this.sourceType,
+					camera: this.camera,
+					maxDuration: this.maxDuration,
+					success: (res) => {
+						console.log('videoAdd', res)
+						console.log(res.tempFilePath)
+						this.chooseSuccessMethod([res.tempFilePath], 1)
+						//this.imgUpload([res.tempFilePath]);
+						//console.log('tempFiles', res)
+						// if (this.action == '') { //未配置上传路径
+						// 	this.$emit("chooseSuccess", res.tempFilePaths);
+						// } else {
+						// 	if (this.compress && (res.tempFiles[0].size / 1024 > 1025)) { //设置了需要压缩 并且 文件大于1M,进行压缩上传
+						// 		this.imgCompress(res.tempFilePaths);
+						// 	} else {
+						// 		this.imgUpload(res.tempFilePaths);
+						// 	}
+						// }
+					}
+				});
+			},
+			imgAdd() {
+				console.log('imgAdd')
+				let nowNum = Math.abs(this.uploadLists.length - this.max);
+				let thisNum = (this.chooseNum > nowNum ? nowNum : this.chooseNum) //可选数量
+				console.log('nowNum', nowNum)
+				console.log('thisNum', thisNum)
+				// #ifdef APP-PLUS
+				if (this.sourceType.length > 1) {
+					uni.showActionSheet({
+						itemList: ['拍摄', '从手机相册选择'],
+						success: (res) => {
+							if (res.tapIndex == 1) {
+								this.appGallery(thisNum);
+							} else if (res.tapIndex == 0) {
+								this.appCamera();
+							}
+						},
+						fail: (res) => {
+							console.log(res.errMsg);
+						}
+					});
+				}
+				if (this.sourceType.length == 1 && this.sourceType.indexOf('album') > -1) {
+					this.appGallery(thisNum);
+				}
+
+				if (this.sourceType.length == 1 && this.sourceType.indexOf('camera') > -1) {
+					this.appCamera();
+				}
+				// #endif
+				//#ifndef APP-PLUS
+				uni.chooseImage({
+					count: thisNum,
+					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
+					sourceType: this.sourceType,
+					success: (res) => {
+						this.chooseSuccessMethod(res.tempFilePaths, 0)
+						//console.log('tempFiles', res)
+						// if (this.action == '') { //未配置上传路径
+						// 	this.$emit("chooseSuccess", res.tempFilePaths);
+						// } else {
+						// 	if (this.compress && (res.tempFiles[0].size / 1024 > 1025)) { //设置了需要压缩 并且 文件大于1M,进行压缩上传
+						// 		this.imgCompress(res.tempFilePaths);
+						// 	} else {
+						// 		this.imgUpload(res.tempFilePaths);
+						// 	}
+						// }
+					}
+				});
+				// #endif
+			},
+			appCamera() {
+				var cmr = plus.camera.getCamera();
+				var res = cmr.supportedImageResolutions[0];
+				var fmt = cmr.supportedImageFormats[0];
+				//console.log("Resolution: " + res + ", Format: " + fmt);
+				cmr.captureImage((path) => {
+						//alert("Capture image success: " + path);
+						this.chooseSuccessMethod([path], 0)
+					},
+					(error) => {
+						//alert("Capture image failed: " + error.message);
+						console.log("Capture image failed: " + error.message)
+					}, {
+						resolution: res,
+						format: fmt
+					}
+				);
+			},
+			appGallery(maxNum) {
+				plus.gallery.pick((res) => {
+					this.chooseSuccessMethod(res.files, 0)
+				}, function(e) {
+					//console.log("取消选择图片");
+				}, {
+					filter: "image",
+					multiple: true,
+					maximum: maxNum
+				});
+			},
+			chooseSuccessMethod(filePaths, type) {
+				if (this.action == '') { //未配置上传路径
+					this.$emit("chooseSuccess", filePaths, type); //filePaths 路径 type 0 为图片 1为视频
+				} else {
+					if (type == 1) {
+						this.imgUpload(filePaths);
+					} else {
+						if (this.compress) { //设置了需要压缩
+						console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1')
+							this.imgCompress(filePaths);
+						} else {
+							console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2')
+							this.imgUpload(filePaths);
+						}
+					}
+
+				}
+			},
+			imgCompress(tempFilePaths) {
+				uni.showLoading({
+					title: '压缩中...'
+				});
+
+				let compressImgs = [];
+				let results = [];
+				tempFilePaths.forEach((item, index) => {
+					compressImgs.push(new Promise((resolve, reject) => {
+						// #ifndef H5
+						uni.compressImage({
+							src: item,
+							quality: this.quality,
+							success: res => {
+								//console.log('compressImage', res.tempFilePath)
+								results.push(res.tempFilePath);
+								resolve(res.tempFilePath);
+							},
+							fail: (err) => {
+								//console.log(err.errMsg);
+								reject(err);
+							},
+							complete: () => {
+								//uni.hideLoading();
+							}
+						})
+						// #endif
+						// #ifdef H5
+						this.canvasDataURL(item, {
+							quality: this.quality / 100
+						}, (base64Codes) => {
+							//this.imgUpload(base64Codes);
+							results.push(base64Codes);
+							resolve(base64Codes);
+						})
+						// #endif
+					}))
+				})
+				Promise.all(compressImgs) //执行所有需请求的接口
+					.then((results) => {
+						uni.hideLoading();
+						console.log('imgUpload', results)
+						console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa3')
+						this.imgUpload(results);
+					})
+					.catch((res, object) => {
+						uni.hideLoading();
+					});
+			},
+			imgUpload(tempFilePaths) {
+				// if (this.action == '') {
+				// 	uni.showToast({
+				// 		title: '未配置上传地址',
+				// 		icon: 'none',
+				// 		duration: 2000
+				// 	});
+				// 	return false;
+				// }
+				uni.showLoading({
+					title: '上传中'
+				});
+				console.log('imgUpload', tempFilePaths)
+				let uploadImgs = [];
+				tempFilePaths.forEach((item, index) => {
+					uploadImgs.push(new Promise((resolve, reject) => {
+						console.log(index, item)
+						const uploadTask = uni.uploadFile({
+							url: this.action, //仅为示例,非真实的接口地址
+							filePath: item,
+							name: this.name,
+							fileType: 'image',
+							formData: this.formData,
+							header: this.headers,
+							success: (uploadFileRes) => {
+								//uni.hideLoading();
+								//console.log(typeof this.uploadSuccess)
+								//console.log('')
+								console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4')
+								if (typeof this.uploadSuccess == 'function') {
+									if (this.uploadSuccess(uploadFileRes).success) {
+										this.value.push(this.uploadSuccess(uploadFileRes)
+											.url)
+											console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa5')
+										this.$emit("input", this.uploadLists);
+									}
+								}
+								resolve(uploadFileRes);
+								console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa6')
+								this.$emit("uploadSuccess", uploadFileRes);
+							},
+							fail: (err) => {
+								console.log(err);
+								//uni.hideLoading();
+								reject(err);
+								this.$emit("uploadFail", err);
+							},
+							complete: () => {
+								//uni.hideLoading();
+							}
+						});
+					}))
+				})
+				Promise.all(uploadImgs) //执行所有需请求的接口
+					.then((results) => {
+						uni.hideLoading();
+					})
+					.catch((res, object) => {
+						uni.hideLoading();
+						this.$emit("uploadFail", res);
+					});
+				// uploadTask.onProgressUpdate((res) => {
+				// 	//console.log('',)
+				// 	uni.showLoading({
+				// 		title: '上传中' + res.progress + '%'
+				// 	});
+				// 	if (res.progress == 100) {
+				// 		uni.hideLoading();
+				// 	}
+				// });
+			},
+			canvasDataURL(path, obj, callback) {
+				var img = new Image();
+				img.src = path;
+				img.onload = function() {
+					var that = this;
+					// 默认按比例压缩
+					var w = that.width,
+						h = that.height,
+						scale = w / h;
+					w = obj.width || w;
+					h = obj.height || (w / scale);
+					var quality = 0.8; // 默认图片质量为0.8
+					//生成canvas
+					var canvas = document.createElement('canvas');
+					var ctx = canvas.getContext('2d');
+					// 创建属性节点
+					var anw = document.createAttribute("width");
+					anw.nodeValue = w;
+					var anh = document.createAttribute("height");
+					anh.nodeValue = h;
+					canvas.setAttributeNode(anw);
+					canvas.setAttributeNode(anh);
+					ctx.drawImage(that, 0, 0, w, h);
+					// 图像质量
+					if (obj.quality && obj.quality <= 1 && obj.quality > 0) {
+						quality = obj.quality;
+					}
+					// quality值越小,所绘制出的图像越模糊
+					var base64 = canvas.toDataURL('image/jpeg', quality);
+					// 回调函数返回base64的值
+					callback(base64);
+				}
+			},
+		}
+	}
+</script>
+
+<style>
+	.preview-full {
+		position: fixed;
+		top: 0;
+		left: 0;
+		bottom: 0;
+		width: 100%;
+		height: 100%;
+		z-index: 1002;
+	}
+
+	.preview-full video {
+		width: 100%;
+		height: 100%;
+		z-index: 1002;
+	}
+
+	.preview-full-close {
+		position: fixed;
+		right: 32rpx;
+		top: 25rpx;
+		width: 80rpx;
+		height: 80rpx;
+		line-height: 60rpx;
+		text-align: center;
+		z-index: 1003;
+		/* 	background-color: #808080; */
+		color: #fff;
+		font-size: 65rpx;
+		font-weight: bold;
+		text-shadow: 1px 2px 5px rgb(0 0 0);
+	}
+
+
+
+	/* .preview-full-close-before,
+	.preview-full-close-after {
+		position: absolute;
+		top: 50%;
+		left: 50%;
+		content: '';
+		height: 60rpx;
+		margin-top: -30rpx;
+		width: 6rpx;
+		margin-left: -3rpx;
+		background-color: #FFFFFF;
+		z-index: 20000;
+	}
+
+	.preview-full-close-before {
+		transform: rotate(45deg);
+
+	}
+
+	.preview-full-close-after {
+		transform: rotate(-45deg);
+
+	} */
+
+	.htz-image-upload-list {
+		display: flex;
+		flex-wrap: wrap;
+	}
+
+	.htz-image-upload-Item {
+		width: 160rpx;
+		height: 160rpx;
+		margin: 13rpx;
+		border-radius: 10rpx;
+		position: relative;
+	}
+
+	.htz-image-upload-Item image {
+		width: 100%;
+		height: 100%;
+		border-radius: 10rpx;
+	}
+
+	.htz-image-upload-Item-video {
+		width: 100%;
+		height: 100%;
+		border-radius: 10rpx;
+		position: relative;
+
+	}
+
+	.htz-image-upload-Item-video-fixed {
+		position: absolute;
+		top: 0;
+		left: 0;
+		bottom: 0;
+		width: 100%;
+		height: 100%;
+		border-radius: 10rpx;
+		z-index: 996;
+
+	}
+
+	.htz-image-upload-Item video {
+		width: 100%;
+		height: 100%;
+		border-radius: 10rpx;
+
+	}
+
+	.htz-image-upload-Item-add {
+		font-size: 105rpx;
+		/* line-height: 160rpx; */
+		text-align: center;
+		border: 1px dashed #d9d9d9;
+		color: #d9d9d9;
+	}
+
+	.htz-image-upload-Item-del {
+		background-color: #f5222d;
+		font-size: 24rpx;
+		position: absolute;
+		width: 35rpx;
+		height: 35rpx;
+		line-height: 35rpx;
+		text-align: center;
+		top: 0;
+		right: 0;
+		z-index: 997;
+		color: #fff;
+	}
+
+	.htz-image-upload-Item-del-cover {
+		background-color: #f5222d;
+		font-size: 24rpx;
+		position: absolute;
+		width: 35rpx;
+		height: 35rpx;
+		text-align: center;
+		top: 0;
+		right: 0;
+		color: #fff;
+		/* #ifdef APP-PLUS */
+		line-height: 25rpx;
+		/* #endif */
+		/* #ifndef APP-PLUS */
+		line-height: 35rpx;
+		/* #endif */
+		z-index: 997;
+
+	}
+</style>

+ 65 - 21
ghsApp/src/pagesClient/official/apply.vue

@@ -21,6 +21,19 @@
           <input v-model="form.floor" type="text" placeholder-class="phcolor" placeholder-style="color:#CCCCCC" class="tui-input" name="floor" placeholder="选填" />
         </tui-list-cell>
       </view>
+
+      <view class="module-com">
+        <view class="module-tit">
+          <span>门店照片</span>
+          <span class="app-color-3">(必填)</span>
+        </view>
+        <view class="module-det">
+          <htz-image-upload :max="1" :compress="true" v-model="currentImgData" :headers="headers" :quality="95"
+           @uploadSuccess="imgUploadSuccess" @imgDelete="imgDeleteFn" :action="uploadImgUrl">
+          </htz-image-upload>
+        </view>
+      </view>
+
       <view class="module-com">
           <tui-list-cell class="line-cell" :hover="false">
               <div class="tui-title required">姓名</div>
@@ -71,8 +84,12 @@ import AppUploader from "@/components/app-uploader";
 const form = require("@/utils/formValidation.js");
 import {getIntroduce,applyRegister} from "@/api/official";
 import {getAuthCode} from "@/api/apply";
+import { mapGetters } from "vuex"
+//图片上传插件来源:https://ext.dcloud.net.cn/plugin?id=2922 已改造,不能再升级 shish 20211228
+import htzImageUpload from '../components/htz-image-upload/htz-image-upload.vue'
 import { mapResolve } from "@/api/map";
 import util from '@/utils/util';
+import { APIHOST } from '@/config'
 export default {
   name: "apply-data",
   components: {
@@ -80,7 +97,8 @@ export default {
     AppAreaSel,
     SimpleAddress,
     AppAvatarModule,
-    AppUploader
+    AppUploader,
+    htzImageUpload
   },
   data () {
     return {
@@ -100,7 +118,8 @@ export default {
         longitude: "",
         latitude: "",
         showAddress:"",
-        authCode:""
+        authCode:"",
+        cover:''
       },
       showRegion: false,
       // 省市联动
@@ -110,10 +129,18 @@ export default {
       logo: '',
       hasGet:false,
       count:120,
-      INT:false
+      INT:false,
+      headers:{token:''},
+      currentImgData: [],
+      uploadImgUrl:APIHOST+'/upload/save-file'
     };
   },
+	computed:{
+		...mapGetters(["getLoginInfo"])
+	},
   onLoad () {
+    const token = uni.getStorageSync('token')
+    this.headers.token = token
   },
   onUnload(){
     clearInterval(this.INT)
@@ -185,23 +212,6 @@ export default {
         this.merchantData = res.data.introduce
       });
     },
-    confirmFn () {
-      applyRegister({
-        hdShopAdminId: this.option.hdShopAdminId,
-        ghsShopAdminId: this.option.ghsShopAdminId,
-        ...this.form,
-        style: this.option.style || 0,
-        from: this.option.from || 0
-      }).then(res => {
-        this.$util.pageTo({
-          url: "/pagesClient/official/result",
-          type: 2,
-          query: {
-            pagestatus: 3
-          }
-        });
-      });
-    },
     // 选择地址
     selRegionFn () {
       if (!this.form.city) {
@@ -225,9 +235,20 @@ export default {
       this.form.province = e.provinceName;
       this.form.city = e.cityName;
     },
+    imgUploadSuccess(res) {
+      var _res = JSON.parse(res.data)
+      if(_res.code == 1){
+        this.currentImgData.push(_res.data.smallUrl)
+        this.form.cover = _res.data.shortUrl
+      }
+    },
+    imgDeleteFn(res){
+      const index = res.index
+      this.form.cover.splice(index,1)
+    },
     formSubmit (e) {
       let rules = [
-        { name: "name", rule: ["required"], msg: ["请填写花店名称"] },
+        { name: "name", rule: ["required"], msg: ["请填写名称"] },
         { name: "city", rule: ["required"], msg: ["请选择城市"] },
         { name: "address", rule: ["required"], msg: ["请填写地址"] },
         { name: "adminName", rule: ["required"], msg: ["请填写姓名"] },
@@ -235,6 +256,12 @@ export default {
       ];
       let formData = this.form;
       let checkRes = form.validation(formData, rules);
+
+      if(this.$util.isEmpty(this.form.cover)){
+        this.$msg('请上传照片')
+        return false
+      }
+
       if (!checkRes) {
         uni.showLoading({mask:true})
         setTimeout(() => {
@@ -244,6 +271,23 @@ export default {
       } else {
         this.$msg(checkRes);
       }
+    },
+    confirmFn () {
+      applyRegister({
+        hdShopAdminId: this.option.hdShopAdminId,
+        ghsShopAdminId: this.option.ghsShopAdminId,
+        ...this.form,
+        style: this.option.style || 0,
+        from: this.option.from || 0
+      }).then(res => {
+        this.$util.pageTo({
+          url: "/pagesClient/official/result",
+          type: 2,
+          query: {
+            pagestatus: 3
+          }
+        });
+      });
     }
   },
   watch: {

+ 67 - 85
ghsApp/src/utils/auth.js

@@ -58,106 +58,88 @@ export async function getSelfInfo(update) {
 /**
  * 微信小程序登录
  * update为true时会重新触发请求,重置vuex的数据
- * type 1 微信 2 帐号密码登陆
  */
-export async function uniLoginFn(update,type) {
+export async function wxMiniLogin(update) {
 	let loginInfo = store.state.login.loginInfo
 	if (!util.isEmpty(loginInfo) && !update) {
 		return loginInfo
 	}
 	//有几个地方涉及登陆,需要统一方法,请搜索关键词 uni_login
-	if(type == 2){
+	return new Promise((resolve,reject) => {
+		uni.login({
+			provider: 'weixin',
+			success: res => {
+				uni.setStorageSync('code', res.code)
+				postWxCode({ code: res.code }).then(subRes => {
+					if (util.isEmpty(subRes)) {
+						return false
+					}
+					var pages = getCurrentPages();
+					var page = (pages[pages.length - 1]).route;
+					resolve({ redirectPage: page, ...subRes })
+					let token = subRes.data.token || '';
+					if (util.isEmpty(token)) {
+						return false
+					}
 
-	}else{
-		return new Promise((resolve,reject) => {
-			uni.login({
-				provider: 'weixin',
-				success: res => {
-					uni.setStorageSync('code', res.code)
-					postWxCode({ code: res.code }).then(subRes => {
-						if (util.isEmpty(subRes)) {
+					uni.setStorageSync('token', subRes.data.token)
+					uni.setStorageSync('shopId', subRes.data.admin.currentShopId)
+					getDictionaries({ token: subRes.data.token }).then(res => {
+						if (util.isEmpty(res)) {
 							return false
 						}
-						var pages = getCurrentPages();
-						var page = (pages[pages.length - 1]).route;
-						resolve({ redirectPage: page, ...subRes })
+						store.commit('setDictionariesInfo', { ...res.data.dict, ...res.data })
+						store.commit('setMyShopInfo', { ...res.data.shop, ...res.data })
+					})
+					store.commit('setLoginInfo', { ...subRes.data.admin, ...subRes.data })
+					//启动更新逻辑 shish 2020.5.18
+					if (subRes.data.update == 1) {
 
-						uni.setStorageSync('token', subRes.data.token)
-						uni.setStorageSync('shopId', subRes.data.admin.currentShopId)
-						getDictionaries({ token: subRes.data.token }).then(res => {
-									if (util.isEmpty(res)) {
-										return false
-									}
-									store.commit('setDictionariesInfo', {
-										...res.data.dict,
-										...res.data
+						// #ifdef MP-WEIXIN
+						const updateManager = uni.getUpdateManager();
+						updateManager.onCheckForUpdate(function(res) {
+							// 请求完新版本信息的回调
+							if (res.hasUpdate) {
+								updateManager.onUpdateReady(function(res2) {
+									uni.showModal({
+										title: '更新提示',
+										content: '发现新版本,请更新应用',
+										cancelColor:'#DDDDDD',
+										confirmColor:'#FF0000',
+										success(res2) {
+											if (res2.confirm) {
+												// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
+												updateManager.applyUpdate()
+											}
+										}
 									})
-								store.commit('setMyShopInfo', {
-									...res.data.shop,
-									...res.data
 								})
-							})
-						store.commit('setLoginInfo', {
-							...subRes.data.admin,
-							...subRes.data
+							}
 						})
-
-						//启动更新逻辑 shish 2020.5.18
-						if (subRes.data.update == 1) {
-
-							// #ifdef MP-WEIXIN
-							const updateManager = uni.getUpdateManager();
-							updateManager.onCheckForUpdate(function(res) {
-								// 请求完新版本信息的回调
-								if (res.hasUpdate) {
-									updateManager.onUpdateReady(function(res2) {
-										uni.showModal({
-											title: '更新提示',
-											content: '发现新版本,请更新应用',
-											cancelColor:'#DDDDDD',
-											confirmColor:'#FF0000',
-											success(res2) {
-												if (res2.confirm) {
-													// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
-													updateManager.applyUpdate()
-												}
-											}
-										})
-									})
-								}
-							})
-				
-							updateManager.onUpdateFailed(function(res) {
-								// 新的版本下载失败
-								uni.showModal({
-									title: '提示',
-									content: '检查到有新版本,但下载失败,请检查网络连接',
-									success(res) {
-										if (res.confirm) {
-											// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
-											updateManager.applyUpdate()
-										}
+			
+						updateManager.onUpdateFailed(function(res) {
+							// 新的版本下载失败
+							uni.showModal({
+								title: '提示',
+								content: '检查到有新版本,但下载失败,请检查网络连接',
+								success(res) {
+									if (res.confirm) {
+										// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
+										updateManager.applyUpdate()
 									}
-								})
+								}
 							})
-							// #endif
+						})
+						// #endif
 
-						}
+					}
 
-					})
-				},
-				fail:err=>{
-					reject(err)
-				}
-			})
+				})
+			},
+			fail:err=>{
+				reject(err)
+			}
 		})
-	}
-}
-
-// export default {
-// 	getSelfInfo,
-// 	getUser,
-// 	resetAllUser,
-// 	getRoleReal
-// }
-
+	})
+	
+}