Explorar el Código

feat:今日预约加时间,订阅消息

zhanghui hace 2 años
padre
commit
e89f7d2ab4

+ 16 - 0
common/js/api.js

@@ -3,6 +3,22 @@ import request from '../js/request.js';
 
 export default {
 
+    //更新订阅消息可发送状态
+    updateSubscribe(data) {
+        return request({
+            url: '/order/subscribe/updateSubscribe',
+            method: 'POST',
+            data:data,
+        })
+    },
+    //查询订阅消息列表
+    getTemplateList() {
+        return request({
+            url: '/order/subscribe/getTemplateList',
+            method: 'POST'
+        })
+    },
+
 
     //结束订单
     orderFinish(orderId) {

+ 2 - 2
common/js/env.js

@@ -3,9 +3,9 @@
 // let baseUrl = `https://jje.admin.xinyuekj.com.cn`
 // let baseUrl = `https://jje.xinyuekj.com.cn/prod-api`
 /** 测试环境 */
-let baseUrl = `https://jje.admin.xinyuekj.com.cn/test-api`
+// let baseUrl = `https://jje.admin.xinyuekj.com.cn/test-api`
 /** 开发环境*/
-// let baseUrl = `http://65i1sxopd9qp.ngrok.xiaomiqiu123.top`
+let baseUrl = `http://65i1sxopd9qp.ngrok.xiaomiqiu123.top`
 
 
 

+ 32 - 1
orderPages/bookService/index.vue

@@ -117,7 +117,7 @@
 					<text class="title">待支付</text>
 					<text class="num">¥{{price}}</text>
 				</view>
-				<view class="btnRight" @click="commitOrder">
+				<view class="btnRight" @click="openSetting">
 					<text>提交</text>
 				</view>
 			</view>
@@ -134,6 +134,7 @@
 		},
 		data() {
 			return {
+				templateId:[],
 				//服务对象列表
 				serviceObjectList:[],
 				//服务人员列表
@@ -180,6 +181,7 @@
 			this.orderParam.serviceStoreId = this.store.storeId
 			//获取排班日期
 			this.selectDate()
+			this.getTemplateList()
 
 		},
 		onShow() {
@@ -193,6 +195,35 @@
 		},
 		methods: {
 
+			openSetting(){
+				uni.requestSubscribeMessage({
+					tmplIds: this.templateId,
+					success: (res) =>{
+						let {errMsg,...param} = res
+						console.log('+++++++++++++success+++++++++++++',param)
+						this.$api.updateSubscribe(param).then(res=>{
+							console.log('+++++++++++++updateSubscribe+++++++++++++',res)
+						})
+					},
+					fail:(err)=>{
+						console.log('+++++++++++++fail+++++++++++++',err)
+					},
+					complete:(complete)=>{
+						console.log('+++++++++++++complete+++++++++++++',complete)
+						this.commitOrder()
+					}
+				})
+			},
+
+
+			getTemplateList(){
+				this.$api.getTemplateList().then(res=>{
+					this.templateId=res.data.data.data.map(item=>{
+						return item.priTmplId
+					})
+				})
+			},
+
 			improperClose(){
 				uni.switchTab({
 					url: '/pages/order/index'

+ 42 - 0
orderPages/storeService/index.rpx.scss

@@ -108,3 +108,45 @@
   width: 32rpx;
   height: 32rpx;
 }
+.selectSerobImg{
+  width: 80rpx;
+  height: 80rpx;
+  border-radius: 40rpx;
+  margin-bottom: 32rpx;
+  background: #FFE05C;
+}
+.selectSerobName{
+  font-size: 24rpx;
+  font-weight: 400;
+  color: #666666;
+  line-height: 80rpx;
+  margin-left: 16rpx;
+}
+.serob{
+  font-size: 32rpx;
+  font-weight: bold;
+  color: #333333;
+}
+.timeItem {
+  width: 124rpx;
+  height: 124rpx;
+  background: #FAFAFA;
+  border-radius: 16rpx;
+  margin-top: 16rpx;
+}
+.selectBack {
+  background: rgba(255, 224, 92, 0.1);
+  border: 4rpx solid #FFE05C;
+  box-sizing:border-box
+}
+.time {
+  font-size: 24rpx;
+  color: #333333;
+  line-height: 40rpx;
+}
+
+.price {
+  font-size: 24rpx;
+  color: #ED569F;
+  line-height: 40rpx;
+}

+ 130 - 33
orderPages/storeService/index.vue

@@ -20,9 +20,29 @@
 					</view>
 				</u-grid-item>
 			</u-grid>
-<!--			<view class="serobReminder">-->
-<!--				<text>同一服务对象在同一时间只能有一个服务订单</text>-->
-<!--			</view>-->
+		</view>
+		<view class="flex-col group" v-for="(item,index) in orderParam.childService">
+			<view class="flex-row ">
+				<image class="selectSerobImg" mode="aspectFill" :src="item.facePhotoUrl || '/static/me/ud4.png'"></image>
+				<text class="selectSerobName">{{item.nickName || '未填写'}}</text>
+			</view>
+			<view class="serob" >
+				<text>服务时段以及服务费用</text>
+			</view>
+			<view>
+				<u-grid :border="false" col="5">
+					<u-grid-item v-if="item2.total > 0"  v-for="(item2,index2) in item.periodTimeList" :key="index2">
+						<view class="flex-col justify-center timeItem " :class="{selectBack: item2.select}" @click="selectServiceTime(item.periodTimeList,index,index2)">
+							<view class="flex-row justify-center">
+								<text class="time">{{item2.label}}</text>
+							</view>
+							<view class="flex-row justify-center">
+								<text class="price">¥{{item2.price}}</text>
+							</view>
+						</view>
+					</u-grid-item>
+				</u-grid>
+			</view>
 		</view>
 
 		<view class="flex-col group ">
@@ -42,9 +62,9 @@
 				<text>4.服务费用到店享受相应服务以后在另行收取。</text>
 			</view>
 		</view>
-<!--		<view class="tabBarLineHeight "></view>-->
+		<view class="tabBarLineHeight "></view>
 		<view class="tabBarView">
-			<view class="submitButton " @click="commonGeneralOrder">提交</view>
+			<view class="submitButton " @click="openSetting">提交</view>
 		</view>
 
 	</view>
@@ -57,6 +77,7 @@
 		},
 		data() {
 			return {
+				periodTimeList:[],
 				userInfo: {},
 				store: {},
 				serviceObjectList: [],
@@ -93,43 +114,56 @@
 
 		},
 		onShow() {
-			// 服务对象
-			this.listServiceObject()
+			this.getServicePersonTime()
+			this.getTemplateList()
 		},
 		methods: {
 
+			selectServiceTime(items,index,index2){
+				items.forEach(e=>{
+					e.select=false
+				})
+				let oidTime = this.orderParam.childService[index].serviceStartTime
+				items[index2].select =true // 新选中的时间
+				this.orderParam.childService[index].serviceStartTime = items[index2].label
+				for (let i=0;i<this.orderParam.childService.length;i++){
+					if (index != i){
+						for (const time of this.orderParam.childService[i].periodTimeList) {
+							if (time.label == oidTime){
+								console.log('++++++++++++++++++++',oidTime)
+								time.total = time.total + 1
+							}
+							if (time.label == items[index2].label) {
+								console.log('------------------', items[index2].label)
+								time.total = time.total - 1
+							}
+						}
+					}
+				}
+				this.$forceUpdate()
+			},
+
 			// 查询服务对接信息列表
 			listServiceObject() {
 				this.$api.listServiceObject(this.reqParm).then((res) => {
 					console.log(res)
 					this.serviceObjectList = res.data.data
 					this.getImgUrlByBannerOssId(this.serviceObjectList);
-
-					if (this.orderParam.childService.length === 0) {
-						let selectServiceObject = this.serviceObjectList[0]
-						this.serviceObjectList[0].select = true
-
-						let childService = {
-							periodDate: '',
-							serviceObjectId: selectServiceObject.id,
-							facePhotoUrl: selectServiceObject.facePhotoUrl,
-							nickName: selectServiceObject.nickName,
-							serviceUserId: -1,
-							fee: '',
-							serviceStartTime: '',
-						}
-						this.orderParam.childService.push(childService)
-					} else {
-						for (let selectServiceObject of this.orderParam.childService) {
-							for (let serviceObject of this.serviceObjectList) {
-								if (selectServiceObject.id === serviceObject.id) {
-									serviceObject.select = true
-								}
-							}
-						}
+					this.orderParam.childService = [],
+					this.serviceObjectList[0].select = true
+					let periodTimeList = JSON.parse(JSON.stringify(this.periodTimeList))
+					let childService = {
+						periodDate: '',
+						serviceObjectId: this.serviceObjectList[0].id,
+						facePhotoUrl: this.serviceObjectList[0].facePhotoUrl,
+						nickName: this.serviceObjectList[0].nickName,
+						serviceUserId: -1,
+						fee: '',
+						serviceStartTime: periodTimeList[0].label,
+						periodTimeList:periodTimeList
 					}
-
-
+					periodTimeList[0].select = true
+					this.orderParam.childService.push(childService)
 				})
 			},
 			// 获取图片
@@ -155,12 +189,33 @@
 					url: '/myPages/ServiceObjectManagement/index'
 				})
 			},
+			getServicePersonTime(){
+				this.$api.getServicePersonTime({
+					personId: -1,
+					date: this.orderParam.serviceDate,
+					storeId:this.store.storeId
+				}).then(res=>{
+					console.log("++++++++++++++++++res++++++++++++++++++++",res)
+					this.periodTimeList = res.data.data
+					// 服务对象
+					this.listServiceObject()
+				})
+			},
 
 			selectServiceObject(item) {
 				if (item.select) {
 					this.orderParam.childService = this.orderParam.childService.filter(selectServiceObject =>
 						selectServiceObject.serviceObjectId !== item.id)
 				} else {
+					let periodTimeList = JSON.parse(JSON.stringify(this.periodTimeList))
+					periodTimeList.forEach(i=>{
+						this.orderParam.childService.forEach(i1=>{
+							if (i.label == i1.serviceStartTime){
+								i.total = i.total -1
+							}
+						})
+					})
+
 					let childService = {
 						periodDate: '',
 						serviceObjectId: item.id,
@@ -169,9 +224,25 @@
 						serviceUserId: -1,
 						fee: '',
 						serviceStartTime: '',
+						periodTimeList:periodTimeList
+					}
+					for (const time of periodTimeList) {
+						if (time.total>0){
+							time.select = true
+							childService.serviceStartTime = time.label
+
+							for (const childService of this.orderParam.childService) {
+								for (const periodTime of childService.periodTimeList) {
+									if (time.label == periodTime.label) {
+										periodTime.total = periodTime.total - 1
+									}
+								}
+							}
+							break
+						}
 					}
-					this.orderParam.childService.push(childService)
 
+					this.orderParam.childService.push(childService)
 				}
 				item.select = !item.select
 				this.price = 0
@@ -180,7 +251,33 @@
 				}
 			},
 
+			getTemplateList(){
+				this.$api.getTemplateList().then(res=>{
+					this.templateId=res.data.data.data.map(item=>{
+						return item.priTmplId
+					})
+				})
+			},
 
+			openSetting(){
+				uni.requestSubscribeMessage({
+					tmplIds: this.templateId,
+					success: (res) =>{
+						let {errMsg,...param} = res
+						console.log('+++++++++++++success+++++++++++++',param)
+						this.$api.updateSubscribe(param).then(res=>{
+							console.log('+++++++++++++updateSubscribe+++++++++++++',res)
+						})
+					},
+					fail:(err)=>{
+						console.log('+++++++++++++fail+++++++++++++',err)
+					},
+					complete:(complete)=>{
+						console.log('+++++++++++++complete+++++++++++++',complete)
+						this.commonGeneralOrder()
+					}
+				})
+			},
 
 			commonGeneralOrder() {
 				if (!this.orderParam.childService.length) {