Browse Source

充值功能

shish 1 year ago
parent
commit
49e9bf040e

+ 31 - 12
hdApp/src/admin/member/detail.vue

@@ -124,22 +124,22 @@
           <div class="inp-list-line">
             <div class="line-label">充值金额</div>
             <div class="line-input">
-              <input type="text" placeholder="请输入金额" v-model="rechargeForm.rechargeAmount" :adjust-position="false" class="inp-input" />
+              <input type="text" placeholder="请输入金额" v-model="rForm.rechargeAmount" :adjust-position="false" class="inp-input" />
             </div>
           </div>
           <div class="inp-list-line" style="margin-top:35upx;">
 						<div class="line-label">付款方式</div>
 						<div class="line-input">
-                <button style="margin-right:2upx;" class="admin-button-com middle" :class="[rechargeForm.payWay == 0 ? 'blue' : '']" @click="rechargeForm.payWay = 0">微 信</button>
-                <button style="margin-right:2upx;" class="admin-button-com middle" :class="[rechargeForm.payWay == 1 ? 'blue' : '']" @click="rechargeForm.payWay = 1">支付宝</button>
-                <button style="margin-right:2upx;" class="admin-button-com middle" :class="[rechargeForm.payWay == 4 ? 'blue' : '']" @click="rechargeForm.payWay = 4">现 金</button>
-                <button class="admin-button-com middle" :class="[rechargeForm.payWay == 5 ? 'blue' : '']" @click="rechargeForm.payWay = 5">银行卡</button>
+                <button style="margin-right:2upx;" class="admin-button-com middle" :class="[rForm.rechargePayWay == 0 ? 'blue' : '']" @click="rForm.rechargePayWay = 0">微 信</button>
+                <button style="margin-right:2upx;" class="admin-button-com middle" :class="[rForm.rechargePayWay == 1 ? 'blue' : '']" @click="rForm.rechargePayWay = 1">支付宝</button>
+                <button style="margin-right:2upx;" class="admin-button-com middle" :class="[rForm.rechargePayWay == 4 ? 'blue' : '']" @click="rForm.rechargePayWay = 4">现 金</button>
+                <button class="admin-button-com middle" :class="[rForm.rechargePayWay == 5 ? 'blue' : '']" @click="rForm.rechargePayWay = 5">银行卡</button>
 						</div>
 					</div>
           <div class="inp-list-line">
             <div class="line-label"></div>
             <div class="line-input">
-            <input type="text" style="text-align:center;margin-top:40upx;font-size:32upx;" v-model="rechargeForm.rechargeRemark" class="inp-input" placeholder="这里写备注" />
+            <input type="text" style="text-align:center;margin-top:40upx;font-size:32upx;" v-model="rForm.rechargeRemark" class="inp-input" placeholder="这里写备注" />
             </div>
           </div>
 
@@ -236,6 +236,7 @@ import TuiListCell from "@/components/plugin/list-cell";
 import { getUserDet, remarkAdd, remarkDel, upgrade, resetPassword } from "@/api/member";
 import { changeName } from "@/api/custom"
 import { getWeal } from "@/api/member"
+import {toManRecharge} from "@/api/recharge"
 export default {
   name: "detail",
   components: {
@@ -301,11 +302,6 @@ export default {
       passwordForm: {
         password: ""
       },
-      rechargeForm: {
-        rechargeAmount:'',
-        rechargeRemark:'',
-        payWay:0,
-      },
       levelSelData: {},
       upgradeForm: {
         member: "",
@@ -322,7 +318,12 @@ export default {
       changeShow:false,
       changeFocus:false,
       weal:[],
-      rechargeWeal:0
+      rechargeWeal:0,
+      rForm: {
+        rechargeAmount:'',
+        rechargeRemark:'',
+        rechargePayWay:0,
+      },
     };
   },
   computed: {
@@ -341,10 +342,28 @@ export default {
   },
   methods: {
     toRecharge(e){
+      let that = this
       if(e.index === 0){
         this.rechargeModal = false
         return false
       }
+      if (this.$util.isEmpty(this.rForm.rechargeAmount)){
+        this.$msg('请填写充值金额')
+        return false
+      }
+      if(Number(this.rForm.rechargeAmount)<0){
+        this.$msg('充值金额要大于0')
+        return false
+      }
+      toManRecharge({amount:this.rForm.rechargeAmount,remark:this.rForm.rechargeRemark,payWay:this.rForm.rechargePayWay}).then(res=>{
+        if(res.code == 1){
+          this.rechargeModal = false
+          this.$msg('充值成功')
+          this.rForm.rechargeAmount = ''
+          this.rForm.rechargeRemark = ''
+          this.rForm.rechargePayWay = 0
+        }
+      })
     },
     callMobile() {
       uni.makePhoneCall({ phoneNumber:this.data.mobile })

+ 5 - 0
hdApp/src/api/recharge/index.js

@@ -1,5 +1,10 @@
 import https from '@/plugins/luch-request_0.0.7/request'
 
+//手动给客户充值
+export const toManRecharge = data => {
+	return https.post("/recharge/man-recharge", data);
+};
+
 //充值余额
 export const rechargeBalance = data => {
 	return https.get('/recharge/balance', data)

+ 11 - 0
mallApp/src/api/recharge/index.js

@@ -0,0 +1,11 @@
+import https from '@/plugins/luch-request_0.0.7/request'
+
+//示例,要删除
+export const rechargeBalance = data => {
+    return https.get('/rechage/balance', data)
+}
+
+//示例,要删除
+export const updateShop = data => {
+    return https.post('/shop/update', data)
+}

+ 6 - 0
mallApp/src/pages.json

@@ -20,6 +20,12 @@
                 { "path": "modify", "style": { "navigationBarTitleText": "资料修改" } }
             ]
         },
+        {
+            "root": "pages/member",
+            "pages": [
+                { "path": "recharge", "style": { "navigationBarTitleText": "充值" } }
+            ]
+        },
         {
             "root": "pages/goods",
             "pages": [

+ 22 - 1
mallApp/src/pages/home/recent.vue

@@ -39,6 +39,7 @@
                 <view class="tag_2" @click="getBuyList()"> <text>买花记录</text> </view>
               </view>
               <view class="button_4 flex-col" @click.stop="bug(item)"><text class="text_13">买花</text></view>
+              <view class="button_6 flex-col" @click.stop="recharge(item)" v-if="item.rechargeWeal == 1"><text class="text_13">充值</text></view>
             </view>
 
         </view>
@@ -161,6 +162,9 @@ export default {
     bug(item){
       this.pageTo({ url:'/pages/item/item?account='+item.shopId})
     },
+    recharge(item){
+      this.pageTo({ url:'/pages/member/recharge?account='+item.shopId})
+    },
     init () {
         this.getShopList()
     },
@@ -446,7 +450,7 @@ export default {
         width: 130upx;
         position: absolute;
         left: 570upx;
-        top:90upx;
+        top:100upx;
         border-radius:20upx;
         .text_13 {
           color: rgba(255, 255, 255, 1);
@@ -471,6 +475,23 @@ export default {
           font-weight:bold;
         }
       }
+      .button_6 {
+        height: 80upx;
+        line-height:80upx;
+        text-align:center;
+        background-color:#FF2842;
+        background-size: 137upx 137upx;
+        width: 130upx;
+        position: absolute;
+        left: 380upx;
+        top:100upx;
+        border-radius:20upx;
+        .text_13 {
+          color: rgba(255, 255, 255, 1);
+          font-size: 30upx;
+          font-weight:bold;
+        }
+      }
     }
   }
 }

+ 108 - 0
mallApp/src/pages/member/components/keyboard.vue

@@ -0,0 +1,108 @@
+<template>
+	<div class="keyboard">
+		<bottom-popup class="popup-wrap" :show="show" maskBgcolor="none" @close="comfirm" :mask="false">
+			<div class="ui-keyboard">
+				<ul class="ui-keyboard-numbers">
+					<li :class="{'zero': item == 0}" v-for="(item, index) in keyLeftData" :key="index" @click="clickKeyFn(item)">{{ item }}</li>
+				</ul>
+				<ul class="ui-keyboard-btn">
+					<li class="btn-del" @click="del">
+                        <i class="iconfont iconshanchu"></i>
+                    </li>
+					<li class="btn-ok" @click="comfirm">完成</li>
+				</ul>
+			</div>
+		</bottom-popup>
+	</div>
+</template>
+
+<script>
+import BottomPopup from '@/components/plugin/bottom-popup'
+export default {
+	name: 'keyboard',
+	components: {
+		BottomPopup
+	},
+	props: {
+		show: {
+			type: Boolean,
+			default: false
+		}
+	},
+	data() {
+		return {
+			keyLeftData: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '.']
+		}
+	},
+	methods: {
+		close() {
+			this.$emit('comfirm')
+		},
+		// 点击数字键盘
+		clickKeyFn(val) {
+			this.$emit('clickKey', val)
+		},
+		// 确认
+		comfirm() {
+			this.$emit('comfirm')
+		},
+		// 删除
+		del() {
+			this.$emit('del')
+		}
+	}
+}
+</script>
+
+<style lang="scss" scoped>
+    .popup-wrap {
+        .ui-keyboard {
+            @include disFlex(center, center);
+            padding: 0 20upx 20upx 20upx;
+            background-color: $backColor;
+            box-shadow: 0 -8upx 16upx #ddd;
+            // 左侧键盘
+            .ui-keyboard-numbers {
+                width: 78%;
+                display: flex;
+                align-items: center;
+                flex-wrap: wrap;
+                li {
+                    width: calc(33.33% - 20upx);
+                }
+                li.zero {
+                    width: calc(66.66% - 20upx);
+                }
+            }
+            // 右侧键盘
+            .ui-keyboard-btn {
+                width: 22%;
+                li {
+                    margin-right: 0;
+                }
+                li.btn-ok {
+                    height: 310upx;
+                    color: #fff;
+                    background-color: $mainColor;
+                    // line-height: 310upx
+                }
+            }
+            li {
+                @include disFlex(center, center);
+                height: 90upx;
+                // line-height: 90upx;
+                text-align: center;
+                border-radius: 10upx;
+                background-color: #fff;
+                margin-top: 20upx;
+                margin-right: 20upx;
+                font-size: 38upx;
+                font-weight: bold;
+                box-shadow: 0 2upx 10upx #ddd;
+            }
+            li:active {
+                background-color: rgba(0, 0, 0, 0.1);
+            }
+        }
+    }
+</style>

+ 140 - 0
mallApp/src/pages/member/components/pay-input.vue

@@ -0,0 +1,140 @@
+<template>
+	<div class="pay-module">
+		<div @click="focusFn">
+			<div class="pay-tit">金额(元)</div>
+			<div class="pay-wrap">
+				<span class="money-text">¥</span>
+				<span type="text" class="cashier-text" v-if="val || focus">{{ val }}</span>
+                <span class="cashier-text prompt" v-else>请输入金额</span>
+				<i class="cursor" v-if="focus"></i>
+			</div>
+		</div>
+		<keyboard-module :show="keyShow" @comfirm="hideKeyFn" @clickKey="clickKeyFn" @del="delFn" />
+	</div>
+</template>
+
+<script>
+import keyboardModule from './keyboard'
+export default {
+	name: 'pay-input',
+	components: {
+		keyboardModule
+	},
+	props: {
+		num: {
+			type: String,
+			default: ''
+		},
+		// 输入框动画
+		focus: {
+			type: Boolean,
+			default: false
+		}
+	},
+	data() {
+		return {
+			val: '',
+			keyShow: false
+		}
+	},
+	watch: {
+		num(val) {
+			this.val = val
+		},
+		focus: {
+			deep: true,
+			handler: function(val) {
+				this.keyShow = val
+			},
+			immediate:true
+		}
+	},
+	methods: {
+		focusFn() {
+			this.$emit('focusFn')
+		},
+		hideKeyFn() {
+			this.$emit('blurFn')
+		},
+		// 点击键盘
+		clickKeyFn(e) {
+			let total = this.val + e
+			this.$emit('clickKey', total)
+		},
+		// 键盘删除
+		delFn() {
+			let total = this.val.substr(0, this.val.length - 1)
+			this.$emit('clickKey', total)
+		}
+	}
+}
+</script>
+
+<style lang="scss" scoped>
+	.pay-module {
+		.pay-tit {
+			margin-bottom: 36upx;
+		}
+		.pay-wrap {
+			@include disFlex(flex-end, flex-start);
+			font-weight: bold;
+			border-bottom: 4upx solid $borderColor;
+			padding-bottom: 38upx;
+			font-family: TextaAlt, serif;
+			height: 70upx;
+			.money-text {
+				font-size: 36upx;
+			}
+			.cashier-text {
+				font-size: 70upx;
+				line-height: 1;
+				margin-left: 8upx;
+                margin-right: 6upx;
+                &.prompt {
+					color: $fontColor3;
+					font-weight: 400;
+					font-size: 50upx;
+                }
+            }
+			.cursor {
+				position: relative;
+				top: 1upx;
+				width: 4upx;
+				height: 100%;
+				background: $mainColor;
+				display: inline-block;
+				-webkit-animation: inputCursorAnimation 1s infinite;
+				-moz-animation: inputCursorAnimation 1s infinite;
+				animation: inputCursorAnimation 1s infinite;
+			}
+		}
+	}
+
+	// 输入框动画
+	@-webkit-keyframes inputCursorAnimation {
+		50% {
+			opacity: 0;
+		}
+		100% {
+			opacity: 1;
+		}
+	}
+
+	@-moz-keyframes inputCursorAnimation {
+		50% {
+			opacity: 0;
+		}
+		100% {
+			opacity: 1;
+		}
+	}
+
+	@keyframes inputCursorAnimation {
+		50% {
+			opacity: 0;
+		}
+		100% {
+			opacity: 1;
+		}
+	}
+</style>

+ 381 - 0
mallApp/src/pages/member/recharge.vue

@@ -0,0 +1,381 @@
+<template>
+	<div class="app-content pay-wrap">
+		<div class="delivery-wrap">
+			<div class="shop-logo-wrap">
+				<div class="logo-img">
+					<image class="logo" :src="`${constant.imgUrl}/logo4.png`" alt mode="widthFix" ></image>
+					<div class="title">{{ ghsInfo.name?ghsInfo.name:'' }}</div>
+				</div>
+			</div>
+			<div style="padding:10upx 0 25upx 10upx;font-size:30upx;">
+				{{ customInfo.name?customInfo.name:'' }},
+				<text>您的待结款这里直接付款销账</text>
+			</div>
+			<div class="module-com pay-input-wrap">
+				<pay-input-module :focus="inpFocus" :num="amount" @focusFn="focusFn" @blurFn="blurFn" @clickKey="clickKeyFn" />
+			</div>
+			<div class="btn-wrap">
+				<!-- #ifdef MP-WEIXIN -->
+				<button class="button-com green" @click="wexinPayFn">微信支付</button>
+				<!-- #endif -->
+			</div>
+		</div>
+	</div>
+</template>
+<script>
+	import { mapGetters } from 'vuex'
+	import PayInputModule from './components/pay-input'
+	import wexinPay from '@/utils/pay/wxPay'
+	import ModalModule from '@/components/plugin/modal'
+	import AppCouponSel from '@/components/app-coupon-sel'
+	import { share } from '@/mixins'
+	import { rechargeBalance } from '@/api/recharge'
+	import { postWxCode } from '@/api/mini'
+	export default {
+		name: 'pay',
+		components: {
+			PayInputModule,
+			ModalModule,
+			AppCouponSel
+		},
+		mixins: [share],
+		data() {
+			return {
+				constant: this.$constant,
+				inpFocus: false,
+				amount: '',
+				payWay: 0,
+				payCallData: null,
+				id:0,
+				salt:'',
+				ghsInfo:[],
+				customInfo:[],
+				imgUrl:''
+			}
+		},
+		computed: {},
+		onLoad(option) {
+			// #ifdef H5
+			this.specialInit()
+			// #endif
+		},
+		onShow(){
+			this.specialInit()
+		},
+		mounted(){
+		},
+		methods: {
+			teachPayFn() {
+				this.pageTo({ url: "/admin/ghs/teachPay"})
+			},
+			downloadImg(){
+				let that = this
+				uni.downloadFile({
+					url:that.imgUrl,
+					success: (res) => {
+						if (res.statusCode === 200) {
+							uni.saveImageToPhotosAlbum({
+							filePath: res.tempFilePath,
+							success: function (data) {
+								uni.showToast({title:'下载成功'})
+							}
+							});
+						}
+					}
+				});
+			},
+			init(){
+				this.specialInit();
+			},
+			specialInit() {
+				let that = this
+				let id = 0
+				let salt = ''
+				if(this.option.id && this.option.salt){
+					id = this.option.id?this.option.id:0
+					salt = this.option.salt?this.option.salt:''
+				}else{
+					if(this.option.q){
+						let currentUrl = decodeURIComponent(this.option.q)
+						let str = currentUrl.substring(currentUrl.lastIndexOf("?") + 1)
+						var sceneItem = str.split("&");
+						var arr, name, value;
+						var sceneArray = new Array();
+						for (var i = 0, l = sceneItem.length; i < l; i++) {
+							arr = sceneItem[i].split("=");
+							name = arr[0];
+							value = arr[1];
+							sceneArray[name] = value;
+						}
+						if(sceneArray.id){
+							id =sceneArray.id
+						}
+						if(sceneArray.salt){
+							salt = sceneArray.salt
+						}
+					}
+				}
+				this.id = id
+				this.salt = salt
+				
+				this.inpFocus = true
+				// #ifdef MP-WEIXIN
+				// 设置分享
+				let shareParams = {
+					title: `点击结账付款`,
+					desc: '',
+					imgUrl: '',
+					pagePath: `/admin/ghs/pay?id=${this.id}&salt=${this.salt}`
+				}
+				this.jweixinFn(shareParams)
+				console.log(`/admin/ghs/pay?id=${this.id}&salt=${this.salt}`)
+				// #endif
+			},
+			toPay() {
+				if (!this.amount) {
+					this.$msg('请先输入金额!')
+					return false
+				}
+				let params = {}
+				params = {
+					actPrice: this.amount,
+					payWay: this.payWay,
+				}
+				let currentMiniOpenId = uni.getStorageSync('currentMiniOpenId')
+				params.currentMiniOpenId = currentMiniOpenId
+				params.ghsId = this.id
+				params.salt = this.salt
+				rechargeBalance(params).then(res => {
+					this.payCallData = res.data
+					//错误返回判断
+					if(res.code == 0){
+						this.$msg(res.msg)
+						return false
+					}
+					if (this.payWay == 0) {
+						wexinPay(res.data, this.paySuccess, this.payFail)
+					} else if (this.payWay == 1) {
+						window.location.href = res.data.url;
+					} else {
+						this.paySuccess()
+					}
+				})
+			},
+			focusFn() {
+				this.inpFocus = true
+			},
+			// 失焦
+			blurFn() {
+				this.inpFocus = false
+			},
+			// 点击键盘
+			clickKeyFn(val) {
+				this.amount = val
+			},
+			// 支付宝支付
+			aliPayFn() {
+				this.payWay = 1
+				this.toPay()
+			},
+			// 微信支付
+			wexinPayFn() {
+
+				let platformType = uni.getSystemInfoSync().platform
+				if(platformType == 'windows'){
+					this.$msg('请使用手机小程序付款')
+					return false
+				}
+
+				this.payWay = 0
+				let that = this
+				let currentMiniOpenId = uni.getStorageSync('currentMiniOpenId')
+				if (this.$util.isEmpty(currentMiniOpenId)){
+					uni.showLoading({mask:true})
+					uni.login({
+						provider: 'weixin',
+						success: res => {
+						postWxCode({ code: res.code }).then(subRes => {
+							uni.hideLoading()
+							if(subRes.data.currentMiniOpenId){
+								let thisMiniOpenId = subRes.data.currentMiniOpenId
+								uni.setStorageSync('currentMiniOpenId',thisMiniOpenId)
+								that.toPay()
+							}
+						})
+						}
+					})
+				}else{
+					that.toPay()
+				}				
+			},
+			paySuccess() {
+				this.$util.pageTo({url: '/admin/ghs/result?id='+this.id+'&salt='+this.salt,type: 2})
+			},
+			payFail() {
+			}
+		}
+	}
+</script>
+
+<style lang="scss">
+	.app-content {
+		min-height: calc(100vh - 20upx);
+		padding-top: 20upx;
+	}
+	.tabs-wrap {
+		position: fixed;
+		top: 0;
+		width: 100%;
+		height: 80upx;
+		line-height: 80upx;
+		text-align: center;
+		background-color: #fff;
+		font-size: 30upx;
+		box-shadow: 4upx 4upx 10upx #eee;
+	}
+	.pay-wrap {
+		.pay-input-wrap {
+			background-color: #fff;
+			border-top-left-radius: 20upx;
+			border-top-right-radius: 20upx;
+			padding: 50upx 80upx 28upx;
+			margin-bottom: 0 !important;
+			.balance {
+				margin-top: 30upx;
+				color: $fontColor2;
+			}
+			.btn-wrap {
+				width: 100%;
+				margin-top: 64upx;
+				.button-com {
+					display: block;
+					margin-bottom: 20upx;
+					padding-top: 30upx;
+					padding-bottom: 30upx;
+				}
+			}
+		}
+	}
+
+	// 我要配送
+	.delivery-wrap {
+		.module-com {
+			margin-bottom: 20upx;
+			background-color: #fff;
+			.module-tit {
+				padding: 20upx 18upx;
+				font-size: 28upx;
+				font-weight: 600;
+				border-bottom: 1upx solid $borderColor;
+			}
+			.module-det {
+				padding: 0 30upx;
+			}
+		}
+		// 金额
+		.pay-input-wrap {
+			padding: 50upx 36upx 38upx;
+			.balance {
+				margin-top: 30upx;
+				color: $fontColor2;
+			}
+		}
+		.shop-logo-wrap {
+			padding-bottom: 20upx;
+			@include disFlex(center, center);
+			.logo-img {
+				width: 100%;
+				margin: 10upx auto;
+				align-items: center;
+				.logo {
+					width: 100upx;
+					height:100upx;
+					border-radius: 10upx;
+					margin-left:10upx;
+					float: left;
+				}
+				.title{
+					margin-left:20upx;
+					float:left;
+					width:600upx;
+					height:100upx;
+					line-height:100upx;
+					font-size:38upx;
+					font-weight: bold;
+				}
+			}
+		}
+		// 可选优惠
+		.discount-wrap {
+			.module-det {
+				padding-top: 20upx;
+				padding-bottom: 20upx;
+			}
+		}
+		// 匿名派送
+		.none-name-delivery {
+			// padding-left: 30upx;
+			padding: 26upx 30upx;
+			// margin-top: 40upx;
+			margin-bottom: 20upx;
+			background-color: #fff;
+			.none-name-text {
+				margin-left: 14upx;
+				color: $fontColor2;
+			}
+		}
+		// 按钮
+		.btn-wrap {
+			width: calc(100% - 60upx);
+			margin: 64upx auto 0;
+			padding-bottom: 20upx;
+			.button-com {
+				display: block;
+				margin-bottom: 20upx;
+				padding-top: 30upx;
+				padding-bottom: 30upx;
+				&:last-child {
+					margin-bottom: 0;
+				}
+			}
+		}
+
+		// 查看更多
+		.view-more {
+			width: auto;
+			padding-bottom: 20upx;
+			margin-bottom: 20upx;
+			font-size: 28upx;
+			@include disFlex(center, center);
+			background-color: #fff;
+			color: #666565;
+			justify-content: flex-start;
+			z-index:9999999;
+			.view-more-text {
+				margin-right: 14upx;
+			}
+			padding-left:40upx;
+			i {
+				font-size: 30upx;
+				font-weight: 600;
+			}
+			.fill-get-man{
+				color:red;
+				margin-left:10upx;
+				font-weight:600;
+				text-decoration:underline;
+			}
+			.pack-up{
+				margin-left:20upx;
+				font-weight:600;
+				color:red;
+				text-decoration:underline;
+			}
+			&.open {
+				i {
+					transform: rotate(180deg);
+				}
+			}
+		}
+	}
+</style>