瀏覽代碼

完成赠品申请

zzp 2 年之前
父節點
當前提交
d833856e72
共有 2 個文件被更改,包括 157 次插入36 次删除
  1. 4 0
      config/api.js
  2. 153 36
      pagesMain/giftApply.vue

+ 4 - 0
config/api.js

@@ -116,4 +116,8 @@ module.exports = {
 	findVenueGiftOneList: API_BASE + '/v2/sale/center/findVenueGiftOneList',
 	// 获取二级礼物
 	findVenueGiftTwoList: API_BASE + '/v2/sale/center/findVenueGiftTwoList',
+	// 赠送
+	giveGiftStudent: API_BASE + '/v2/sale/center/giveGiftStudent',
+	// 不送
+	giveGiftRefuse:  API_BASE + '/v2/sale/center/giveGiftRefuse'
 }

+ 153 - 36
pagesMain/giftApply.vue

@@ -19,16 +19,15 @@
 									<text class="info-name">{{ site.venueName }}</text>
 								</view>
 								<view class="info-phone">{{ site.className }}</view>
+								<template v-if="site.giftList.length">
+									<view class="info-phone" v-for="(iten, index3) in site.giftList" :key="index3">{{ iten.name }}</view>
+								</template>
 								<view class="info-phone">{{ getStatus(site.approvalStatus) }}</view>
-								<view style="width: 100%;" v-if="site.giftType == 1">
-									<text class="info-phone" style="margin-right: 10px;">{{ site.giftTypeName }}</text>
-									<text class="info-phone">{{ site.giftName }}</text>
-								</view>
 							</view>
 						</view>
-						<view slot="foot" style="text-align: right;"v-if="site.giftType == 0" >
-							<u-button type="warning" :ripple="true" shape="circle" :custom-style="{...handleCustomStyle, marginRight: '5px'}" size="mini" @click="handleGiveClick(site.venueId)">赠送</u-button>
-							<u-button type="warning" :ripple="true" shape="circle" :custom-style="handleCustomStyle" size="mini" @click="handleNoGiveClick">不送</u-button>
+						<view slot="foot" style="text-align: right;" v-if="site.giftType == 0 && site.approvalStatus == 2" >
+							<u-button type="warning" :ripple="true" shape="circle" :custom-style="{...handleCustomStyle, marginRight: '5px'}" size="mini" @click="handleGiveClick(site.id,site.venueId)">赠送</u-button>
+							<u-button type="warning" :ripple="true" shape="circle" :custom-style="handleCustomStyle" size="mini" @click="handleNoGiveClick(site.id)">不送</u-button>
 						</view>
 					</u-card>
 					<u-divider v-if="item.isOver" bg-color="transparent" :style="{paddingTop : item.tableList.length == 0 ? '10px' : ''}">没有更多了</u-divider>
@@ -39,15 +38,30 @@
 		<u-popup v-model="giftShow" mode="center" border-radius="30" width="600rpx" height="500px" >
 			<view class="common-title">礼物</view>
 			<view class="menber-box" style="overflow-y: auto;height:390px;">
-				<view @click="handleOneClick"></view>
+				<u-form :model="form" ref="giftForm" label-width="80">
+					<view style="display:flex;justify-content: space-between;" v-for="(item,index) in formInfo" :key="index">
+						<u-form-item label="商品" :prop="item.signOne" required right-icon="arrow-right" style="width:44%;"  @click.native="handleShowProductClick(index)">
+							<text>{{ item.signOne }}</text>
+						</u-form-item>
+						<u-form-item label="规格" :prop="item.two" required right-icon="arrow-right" style="width:44%;" @click.native="handleShowSpecClick(index)">
+							<text>{{ item.signTwo }}</text>
+						</u-form-item>
+						<u-icon v-if="formInfo.length != 1" name="minus-circle" size="34" @click="handleGiftDelClick(index)"></u-icon>
+					</view>
+					<view style="width:100;display:flex;justify-content: flex-end;">
+						<u-button type="warning"  :ripple="true" size="mini" :custom-style="{ backgroundColor: mainColor }"  @click="handleGiftAddClick">添加</u-button>
+					</view>
+				</u-form>
 			</view>
 			<view class="button-box">
-				<u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="recordShow = false">确定</u-button>
+				<u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="handleSubmitClick">确定</u-button>
 			</view>
 		</u-popup>
-		<!-- 一级礼物 -->
-		<u-action-sheet :list="oneList" v-model="oneShow" @click="handleSetOneClick"></u-action-sheet>
-		<u-top-tips ref="uTips"></u-top-tips>
+		<!-- 商品 -->
+		<u-picker mode="selector" v-model="productShow" :range="productList" @confirm="handleSetProductClick" title="礼物" range-key="text"></u-picker>
+		<!-- 规格 -->
+		<u-picker mode="selector" v-model="specShow" :range="specList" @confirm="handleSetSpecClick" title="规格" range-key="text"></u-picker>
+		<u-top-tips ref="uTips" z-index="12000"></u-top-tips>
 	</view>
 </template>
 
@@ -58,19 +72,20 @@
 	const NET = require('@/utils/request')
 	const API = require('@/config/api')
 	export default {
-		computed: {
-			...mapGetters([
-				'mainColor',
-				'customStyle',
-				'handleCustomStyle',
-				'handleDefaultCustomStyle',
-			])
-		},
 		data() {
 			return {
-				venueId: '',
+				listId: 0,
+				venueId: 0,
 				// filterText: '',
 				triggered: false,
+				formInfo: [
+					{
+						signOneId: '',
+						signOne: '',
+						signTwoId: '',
+						signTwo: ''
+					}
+				],
 				tabList: [
 				{
 					name: '未赠送',
@@ -93,16 +108,24 @@
 				}],
 				current: 0,
 				swiperCurrent: 0,
+				giftIndex: 0,
 				giftShow: false,
-				oneShow: false,
-				oneList: [],
-				
+				productShow: false,
+				productList: [],
+				specShow: false,
+				specList: [],
 			}
 		},
 		onShow() {
 			this.getData()
 		},
 		computed: {
+			...mapGetters([
+				'mainColor',
+				'customStyle',
+				'handleCustomStyle',
+				'handleDefaultCustomStyle',
+			]),
 			getStatus() {
 				return function(index) {
 					switch (index) {
@@ -123,26 +146,120 @@
 				this.getTableList(1)
 				this.getTableList(2)
 			},
-			handleGiveClick(id) {
+			handleGiveClick(id,venueId) {
 				this.giftShow = true
-				this.venueId = id
+				this.listId = id
+				this.venueId = venueId
 			},
-			handleOneClick() {
-				NET.request(API.findVenueGiftOneListudentPage, {
-					id: thisvenueId
+			handleShowProductClick(index) {
+				this.giftIndex = index
+				NET.request(API.findVenueGiftOneList, {
+					id: this.venueId
 				}, 'POST').then(res => {
-					console.log(res);
+					this.productList = res.data
+					this.productShow = true
 				})
 			},
-			// 赠送
-			handleJumpGiftInfoClick(id) {
-				uni.navigateTo({
-					url: `/pagesMain/giftInfo?id=${id}`
+			handleSetProductClick(index) {
+				this.formInfo[this.giftIndex].signOneId = this.productList[index].id
+				this.formInfo[this.giftIndex].signOne = this.productList[index].text
+			},
+			handleShowSpecClick(index) {
+				this.giftIndex = index
+				if(!this.formInfo[this.giftIndex].signOneId) {
+					this.$refs.uTips.show({
+						title: '请先选择商品',
+						type: 'warning',
+					})
+					return
+				}
+				const giftId = this.formInfo[this.giftIndex].signOneId
+				const venueId = this.venueId
+				NET.request(API.findVenueGiftTwoList, {
+					giftId, venueId
+				}, 'POST').then(res => {
+					this.specList = res.data
+					this.specShow = true
+				})
+			},
+			handleSetSpecClick(index) {
+				this.formInfo[this.giftIndex].signTwoId = this.specList[index].id
+				this.formInfo[this.giftIndex].signTwo = this.specList[index].text
+			},
+			handleGiftAddClick() {
+				this.formInfo.push({
+					signOneId: '',
+					signOne: '',
+					signTwoId: '',
+					signTwo: ''
 				})
 			},
+			handleGiftDelClick(index) {
+				this.formInfo.splice(index,1)
+			},
+			handleSubmitClick() {
+				let flag = true
+				this.formInfo.forEach( item => {
+					if(!item.signOneId) {
+						this.$refs.uTips.show({
+							title: '请选择要赠送的礼物',
+							type: 'warning',
+						})
+						flag = false
+						return 
+					}
+					if(item.signOneId && !item.signTwoId) {
+						this.$refs.uTips.show({
+							title: `请选择商品${item.signOne}的规格`,
+							type: 'warning',
+						})
+						flag = false
+						return 
+					}
+				})
+				if(flag) {
+					const id = this.listId
+					const venueId = this.venueId
+					const giftIds = this.formInfo.filter(item => item.signTwoId != '').map( item => {
+						return item.signTwoId
+					})
+					NET.request(API.giveGiftStudent, {
+						id, venueId, giftIds
+					}, 'POST').then(res => {
+						if(res.status == 10000) {
+							this.$refs.uTips.show({
+								title: res.message,
+								type: 'success',
+							})
+						} else {
+							this.$refs.uTips.show({
+								title: res.message,
+								type: 'warning',
+							})
+						}
+						this.getData()
+						this.giftShow = false
+					})
+				}
+			},
 			// 不送
-			handleNoGiveClick() {
-				console.log('不送');
+			handleNoGiveClick(id) {
+				NET.request(API.giveGiftRefuse, {
+					id
+				}, 'POST').then(res => {
+					if(res.status == 10000) {
+						this.$refs.uTips.show({
+							title: res.message,
+							type: 'success',
+						})
+					} else {
+						this.$refs.uTips.show({
+							title: res.message,
+							type: 'warning',
+						})
+					}
+					this.getData()
+				})
 			},
 			//  获取列表数据
 			getTableList(index) {