lhl 11 months ago
parent
commit
8d8ec59eb2

+ 4 - 0
api/three.js

@@ -19,3 +19,7 @@ export function getCzList(data) {
 export function computedCz(data) {
 	return request.post("recharge/orderCompute", data);
 }
+
+export function getCity(data) {
+	return request.get("recharge/screen_list", data);
+}

+ 41 - 2
pages/goods/three/index.vue

@@ -18,7 +18,7 @@
 		</view>
 		<template v-if="ctype == 2 || ctype == 3">
 			<picker @change="bindPickerChange" :value="chooseId" :range="provinces" range-key="label">
-				<view class="search-box sf-wrap flex">
+				<view class="search-box sf-wrap flex" v-if="ctype == 3">
 					<view class="">
 						省份
 					</view>
@@ -26,6 +26,15 @@
 				</view>
 
 			</picker>
+			<view class="search-box sf-wrap flex" v-if="ctype == 2">
+				<view class="">
+					省市
+				</view>
+				<view class="" style="width: 150px;height: 100%;text-align: right;">
+				 <qiaoSelect :keyId="1" :dataList="dataList" phText="选择省市" phColor="#999999" showField="name" searchKey="name"
+				        :showObj="showObj" :showBorder="false" :disabled="false" @change="selectChange" @input='inputChange'></qiaoSelect>
+				</view>
+			</view>
 			<view class="search-box sf-wrap flex">
 				<view class="">
 					姓名
@@ -132,11 +141,13 @@
 </template>
 
 <script>
+	import qiaoSelect from '@/uni_modules/qiao-select/components/qiao-select/qiaoSelect.vue'
 	import payment from '@/components/payment';
 	import {
 		getCzList,
 		createCz,
-		computedCz
+		computedCz,
+		getCity
 	} from '@/api/three'
 	import {
 		getUserInfo
@@ -148,9 +159,11 @@
 	export default {
 		components: {
 			payment,
+			qiaoSelect
 		},
 		data() {
 			return {
+				dataList: [],
 				jfjg: '',
 				sbjzt: 0,
 				rechargeno: '',
@@ -212,6 +225,7 @@
 			this.getUserInfo()
 			this.getCzList()
 			this.getCityData()
+			this.getCity()
 		},
 		onShow() {},
 		onReachBottom() {
@@ -229,6 +243,31 @@
 			}
 		},
 		methods: {
+			getCity() {
+				getCity().then(res => {
+					console.log(res)
+					let arr = []
+					res.data.forEach((item,index) => {
+						arr.push({
+							name: item,
+							id: index
+						})
+					})
+					this.dataList = arr
+					console.log(this.dataList)
+				})
+			},
+			selectChange(e) {
+				console.log(e,'selectChange')
+				if(e) {
+					this.province = e.name
+				}else {
+					this.province = ''
+				}
+			},
+			inputChange(e) {
+				console.log(e,'inputChange')
+			},
 			changePayType(type) {
 				console.log(type)
 				// this.payType = type

+ 1 - 1
pages/users/user_payment/index.vue

@@ -25,7 +25,7 @@
 						<view class="pic-number-pic">
 							{{ item.price }}<span class="pic-number"> 元</span>
 						</view>
-						<view class="pic-number">赠送:{{ item.give_money }} 元</view>
+						<view class="pic-number">赠送请客金:{{ item.give_money }} 元</view>
 					</view>
 					<view class="pic-box pic-box-color acea-row row-center-wrapper"
 						:class="activePic == picList.length ? 'pic-box-color-active' : ''"

+ 22 - 0
uni_modules/qiao-select/changelog.md

@@ -0,0 +1,22 @@
+## 1.0.8(2023-12-26)
+修改h5端样式报错
+## 1.0.7(2023-07-04)
+优化宽度太窄的时候显示效果;
+## 1.0.6(2023-06-16)
+优化;
+## 1.0.5(2023-06-16)
+新增支持禁用;
+## 1.0.4(2023-06-16)
+优化;
+## 1.0.3(2023-06-15)
+1、可设置展示字段;
+2、可设置默认值;
+## 1.0.0(2023-06-15)
+1、可设置默认值;
+2、可设置展示字段;
+## 1.0.2(2023-06-15)
+优化
+## 1.0.1(2023-06-15)
+修改问题;
+## 1.0.0(2023-06-15)
+初版提交

+ 315 - 0
uni_modules/qiao-select/components/qiao-select/qiaoSelect.vue

@@ -0,0 +1,315 @@
+<template>
+	<view class="qiaoSelect" :class="{'ban':disabled}">
+		<input type="text" class="input" :class="{'input-border':showBorder}" @input="watchInput" @focus="focus"
+			@blur="blur" :placeholder="phText" :placeholder-style="'color:'+phColor" @tap="open" :disabled="disabled"
+			v-model="inputText" />
+		<view class="icon">
+			<uni-icons type="close" size="15" color="#515151" class="img-close" @click="clickClear"
+				v-if="inputText!==''&&!disabled"></uni-icons>
+			<uni-icons v-show="popupShow" type="bottom" size="15" color="#515151"></uni-icons>
+			<uni-icons v-show="!popupShow" type="right" size="15" color="#515151"></uni-icons>
+		</view>
+		<view class="select" v-show="popupShow">
+			<view class="box">
+				<view style="color: #515151;font-size: 30rpx;" v-if="dataList.length==0">暂无数据</view>
+				<view style="color: #515151;font-size: 30rpx;" v-if="filPersons.length==0&&dataList.length!=0">
+					暂无数据
+				</view>
+				<view @touchstart="touchst" v-for="(item,index) in filPersons" :key="index">
+					<view @click.stop="Check(item)" style="text-align: left;" class="li"
+						:class="item.qiaoSelectKey==inputText?'blue':''">
+						{{item[showField]}}
+					</view>
+				</view>
+			</view>
+		</view>
+		<view class="popup" v-show="popupShow" @click="close">
+			<view>
+
+			</view>
+		</view>
+	</view>
+</template>
+
+<script>
+	export default {
+		props: {
+			//下拉数据
+			dataList: {
+				type: Array,
+				default () {
+					return []
+				}
+			},
+			//唯一键,用于多个关闭
+			keyId: Number | String,
+			//提示语
+			phText: String,
+			//提示语颜色
+			phColor: {
+				type: String,
+				default: '#999999',
+			},
+			//指定搜索的属性
+			searchKey: {
+				type: String,
+				default: 'name'
+			},
+			//是否显示边框
+			showBorder: {
+				type: Boolean,
+				default: true,
+			},
+			//默认显示的条目
+			showObj: {
+				type: Object,
+				default: null,
+			},
+			//展示的字段
+			showField: {
+				type: String,
+				default: 'name'
+			},
+			//是否禁用
+			disabled: {
+				type: Boolean,
+				default: false,
+			},
+		},
+		data() {
+			return {
+				timer: '', //定时器
+				popupShow: false,
+				inputText: '',
+				isInput: true, //是否输入,如果输入开始模糊查询
+			}
+		},
+		onLoad() {},
+		computed: {
+			filPersons: {
+				get() {
+					if (!this.isInput) {
+						return this.dataList
+					} else {
+						return this.dataList.filter((item) => {
+							if (item.qiaoSelectKey) {
+								return item.qiaoSelectKey.indexOf(this.inputText) != -1
+							} else {
+								return []
+							}
+						})
+					}
+				},
+				set(val) {}
+			}
+
+		},
+		watch: {
+			inputText: {
+				immediate: true,
+				handler(val) {
+					this.filPersons = this.dataList.filter((item) => {
+						if (!item.qiaoSelectKey) return
+						return item.qiaoSelectKey.indexOf(val) != -1
+					})
+				}
+			},
+			dataList: {
+				immediate: true,
+				handler(val) {
+					if (this.dataList.length > 0) {
+						this.dataList.forEach(item => {
+							Object.keys(item).map((key) => {
+								if (item[this.searchKey]) {
+									item.qiaoSelectKey = item[this.searchKey].toString()
+								} else if (item[this.showField]) { //没有指定搜索字段,默认搜索展示字段
+									item.qiaoSelectKey = item[this.showField].toString()
+								}
+							})
+						})
+						this.inputText = ''
+					}
+				}
+			},
+			//监听赋值
+			showObj: {
+				handler(val) {
+					if (val) {
+						this.inputText = val[this.showField]
+						this.$emit('input', [val])
+						this.$emit('change', val)
+					} else {
+						this.inputText = ''
+						this.$emit('input', [])
+						this.$emit('change', null)
+					}
+				},
+				deep: true,
+				immediate: true,
+			},
+		},
+		methods: {
+			clickClear() {
+				this.inputText = ''
+				this.$emit('input', [])
+				this.$emit('change', null)
+			},
+			touchst() {
+				if (this.disabled) return;
+				this.popupShow = true
+			},
+			focus() {
+				this.isInput = false
+			},
+			watchInput(e) { //键盘输入
+				this.isInput = true
+				if (this.inputText) {
+					this.$emit('input', this.filPersons)
+				}
+				if (this.inputText === '') {
+					this.$emit('input', [])
+					this.$emit('change', null)
+				}
+			},
+			Check(i) { //选择选项
+				this.inputText = i[this.showField]
+				this.isInput = false
+				this.close()
+				this.$emit('change', i)
+			},
+			open() {
+				if (this.disabled) return;
+				uni.setStorageSync('keyId', this.keyId)
+				this.popupShow = true
+			},
+			close() { //关闭
+				this.popupShow = false
+			},
+			blur() {
+				this.timer = setInterval(() => {
+					if (this.popupShow && uni.getStorageSync('keyId') != this.keyId) {
+						this.popupShow = false
+					}
+					setTimeout(() => {
+						clearInterval(this.timer)
+					}, 100)
+				}, 200)
+			},
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+	$height: 60rpx;
+
+	.ban {
+		background: #F7F7F6;
+	}
+
+	.qiaoSelect {
+		margin: 0;
+		padding: 0;
+		position: relative;
+		height: $height;
+		display: flex;
+		align-items: center;
+
+		.img-close {
+			margin: 0 10rpx;
+		}
+
+		.icon {
+			z-index: 99;
+		}
+
+		.input {
+			flex: 1;
+			border-radius: 10rpx;
+			height: $height;
+			padding: 0;
+			font-size: 30rpx;
+			word-break: break-all;
+			text-overflow: ellipsis;
+			display: -webkit-box;
+			-webkit-box-orient: vertical;
+			-webkit-line-clamp: 1;
+			overflow: hidden;
+		}
+
+		.input-border {
+			border: 1rpx solid #ECECEC;
+			padding-left: 20rpx;
+		}
+
+		.select {
+			padding: 20rpx;
+			color: #515151;
+			position: absolute;
+			top: 90rpx;
+			left: 0;
+			right: 0;
+			z-index: 100;
+			background-color: white;
+			border: 2px #f3f3f3 solid;
+			font-size: 30rpx;
+			background-color: #fff;
+			border-radius: 10rpx;
+
+			.box {
+				max-height: 300rpx;
+				overflow: scroll;
+			}
+
+			.li {
+				padding: 10rpx 0;
+			}
+
+			.blue {
+				color: #55aaff;
+			}
+		}
+
+		.select::after {
+			width: 0px;
+			height: 0px;
+			position: absolute;
+			bottom: 100%;
+			left: 10%;
+			padding: 0;
+			border: 16rpx solid transparent;
+			border-color: transparent transparent #fff transparent;
+			content: '';
+		}
+
+		.select::before {
+			width: 0px;
+			height: 0px;
+			position: absolute;
+			bottom: 100%;
+			left: 10%;
+			padding: 0;
+			border: 20rpx solid transparent;
+			border-color: transparent transparent #f3f3f3 transparent;
+			transform: translate(-4rpx, 0);
+			content: '';
+		}
+
+		.popup {
+			position: absolute;
+			z-index: 9;
+			left: 0;
+			top: 0;
+			right: 0;
+			bottom: 0;
+
+			view {
+				position: fixed;
+				left: 0;
+				top: 0;
+				right: 0;
+				bottom: 0;
+			}
+		}
+
+	}
+</style>

+ 66 - 0
uni_modules/qiao-select/introduce.md

@@ -0,0 +1,66 @@
+示例代码:
+
+1、引入:
+
+	import qiaoSelect from '@/uni_modules/qiao-select/components/qiao-select/qiaoSelect.vue'
+
+2、添加:
+
+	components: {
+		qiaoSelect
+	},
+
+3、使用:
+
+	组件默认展示的是【name】字段,可通过showField设置,最终@change返回整个选择的对象
+	
+	如果需要设置初始默认值,通过showObj设置,赋值要展示的条目对象
+	
+	组件外层View可以给个宽度
+
+	<view style="width: 300rpx;">
+		<qiaoSelect :keyId="1" :dataList="orgArray" phText="选择机构名称" phColor="#999999" showField="name" searchKey="name"
+			:showObj="showObj" :showBorder="false" :disabled="false" @change="selectChange" @input='inputChange'></qiaoSelect>
+	</view>
+					
+	selectChange(e) {//返回选择的对象,如果输入框清空,返回null
+		if (e) {
+			this.mechId = e.id
+		} else {
+			this.mechId = ''
+		}
+	},
+	inputChange(e) {//返回搜索结果集合,一般用不到
+		console.log(e)
+	},
+	
+	可以通过以下2种方法清空指定的组件:
+	1、加上 showObj 字段,然后将它设置为null,就清空了
+	2、给组件加一个ref='xxx',然后通过this.$refs.xxx.clickClear()清空
+					
+					
+【属性介绍】:
+
+	dataList:			下拉数据
+
+	keyId:				唯一键,用于多个关闭
+	
+	showField:		要展示的字段,默认name
+	
+	showObj:			设置展示的条目对象,可用来设置默认值
+
+	phText:				提示语
+
+	phColor:			提示语颜色
+
+	searchKey:		指定搜索的字段,不设置使用展示字段showField搜索
+
+	showBorder:		是否显示边框
+	
+	disabled:			是否禁用
+
+	@change:			返回选择的对象,如果输入框清空,返回null
+
+	@input:				返回搜索结果集合
+	
+	

+ 27 - 0
uni_modules/qiao-select/package.json

@@ -0,0 +1,27 @@
+{
+	"id": "qiao-select",
+	"name": "搜索下拉选择器",
+	"displayName": "qiao-select带input模糊搜索的下拉选择框",
+	"version": "1.0.8",
+	"description": "搜索下拉选择器,支持输入框模糊搜索下拉数据,支持小程序,h5,可自行配置搜索项",
+	"keywords": [
+        "select",
+        "下拉搜索",
+        "选择器",
+        "选择框",
+        "搜索下拉"
+    ],
+	"dcloudext": {
+		"contact": {
+			"qq": "1450294898"
+		},
+		"declaration": {
+			"ads": "无",
+			"data": "无",
+			"permissions": "无"
+		},
+		"npmurl": "",
+		"type": "component-vue"
+	},
+	"repository": ""
+}