Explorar o código

Merge branch 'deploy' of http://git.chelingzhu.com/chelingzhu-web/qhsxKx-mini-html into deploy

lilei %!s(int64=4) %!d(string=hai) anos
pai
achega
55c24a8af1

+ 9 - 1
api/coupon.js

@@ -7,8 +7,16 @@ export const receivesCoupon = (params) => {
   })
   })
 }
 }
 
 
+// 查询要领取的优惠券
+export const couponData = (params) => {
+  return axios.request({
+    url: `couponReceives/receivesCoupon/${params.couponCode}`,
+    method: 'get'
+  })
+}
+
 // 优惠券领取明细查询
 // 优惠券领取明细查询
-export const couponList = (params) => {
+export const couponListFind = (params) => {
   return axios.request({
   return axios.request({
     url: `couponReceives/findPage`,
     url: `couponReceives/findPage`,
     method: 'post',
     method: 'post',

+ 46 - 10
pages/coupon/getCoupon/getCoupon.vue

@@ -20,25 +20,61 @@
 </template>
 </template>
 
 
 <script>
 <script>
+	import {couponData, receivesCoupon} from '@/api/coupon.js'
 	export default{
 	export default{
 		name: 'getCoupon',
 		name: 'getCoupon',
 		data () {
 		data () {
 			return {
 			return {
-				
+				couponInfo: {}, // 领取优惠券信息
+			}
+		},
+		onLoad(options) {
+			// 存储当前扫码的券码
+			if (options.scene) {
+				let scene = decodeURIComponent(options.scene);
+				//&是我们定义的参数链接方式
+				let couponCode = scene;
+				//其他逻辑处理。。。。。
+				this.$store.state.vuex_couponCode = couponCode
+				// 获取要领取的优惠券
+				this.getCoupon(couponCode)
+			} else {
+				// 判断是否扫码过
+				if (this.$store.state.vuex_couponCode != '') {
+					let couponCode = this.$store.state.vuex_couponCode
+					this.getCoupon(couponCode)
+				} else {
+					// 返回首页
+					uni.reLaunch({
+						url: "/pages/index/index"
+					})
+				}
 			}
 			}
 		},
 		},
 		methods: {
 		methods: {
-			// 选中优惠卷
-			checked(item) {
-				if(this.showCheck){
-					let has = this.list.find(item=>item.checked)
-					if(has){
-						has.checked = false
+			// 获取要领取的优惠券
+			getCoupon (code) {
+				couponData({couponCode:code}).then(res=>{
+					if (res.status == 200) {
+						this.couponInfo = res.data
 					}
 					}
-					item.checked = true
-					this.$emit('checkOk',item)
-				}
+				})
 			},
 			},
+			// 确认领取优惠券
+			handleSubmit () {
+				let couponCode = this.$store.state.vuex_couponCode
+				receivesCoupon({couponCode:couponCode}).then(res =>{
+					if (res.status == 200) {
+						this.toashMsg('领取成功')
+						setTimeout(()=>{
+							uni.navigateTo({
+								url: '/pages/coupon/index/index'
+							})
+						},500)
+					}
+				})
+			}
+			
 		},
 		},
 	}
 	}
 </script>
 </script>

+ 44 - 25
pages/coupon/index/index.vue

@@ -6,7 +6,7 @@
 		</view>
 		</view>
 		<swiper style="height: calc(100% - 40px);" :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish">
 		<swiper style="height: calc(100% - 40px);" :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish">
 			<swiper-item class="swiper-item" v-for="(item, index) in tabsList" :key="index">
 			<swiper-item class="swiper-item" v-for="(item, index) in tabsList" :key="index">
-				<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="onreachBottom">
+				<scroll-view scroll-y style="height: 100%;width: 100%;">
 					<couponTpl :list="couponList"></couponTpl>
 					<couponTpl :list="couponList"></couponTpl>
 					<u-empty :text="noDataText" img-width="120" v-if="couponList.length==0 && status!='loading'" mode="list"></u-empty>
 					<u-empty :text="noDataText" img-width="120" v-if="couponList.length==0 && status!='loading'" mode="list"></u-empty>
 					<view style="padding: 20upx;">
 					<view style="padding: 20upx;">
@@ -20,6 +20,7 @@
 
 
 <script>
 <script>
 	import couponTpl from '@/pages/coupon/couponTpl.vue'
 	import couponTpl from '@/pages/coupon/couponTpl.vue'
+	import {couponListFind} from '@/api/coupon.js'
 	export default {
 	export default {
 		components: {
 		components: {
 			couponTpl
 			couponTpl
@@ -27,51 +28,54 @@
 		data() {
 		data() {
 			return {
 			return {
 				noDataText: '暂无数据',
 				noDataText: '暂无数据',
-				status: 'loadmore',
+				status: 'loading',
 				tabsList: [{
 				tabsList: [{
-					name: '未使用'
+					name: '未使用',
+					status: 0
 				}, {
 				}, {
-					name: '已使用'
+					name: '已使用',
+					status: 1
 				}, {
 				}, {
-					name: '已过期'
+					name: '已过期',
+					status: -1
 				}],
 				}],
 				couponList: [{
 				couponList: [{
 						id: 23432445,
 						id: 23432445,
-						name: "满100减50",
-						price: 100,
-						yxTime: "2020-05-16",
+						couponTitle: "满100减50",
+						couponAmount: 100,
+						validEndTime: "2020-05-16",
 						remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
 						remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
 						checked: false
 						checked: false
 					},
 					},
 					{
 					{
 						id: 3544355,
 						id: 3544355,
-						name: "满100减50",
-						price: 100,
-						yxTime: "2020-05-16",
+						couponTitle: "满100减50",
+						couponAmount: 100,
+						validEndTime: "2020-05-16",
 						remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
 						remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
 						checked: false
 						checked: false
 					},
 					},
 					{
 					{
 						id: 234234234,
 						id: 234234234,
-						name: "满100减50",
-						price: 100,
-						yxTime: "2020-05-16",
+						couponTitle: "满100减50",
+						couponAmount: 100,
+						validEndTime: "2020-05-16",
 						remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
 						remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
 						checked: false
 						checked: false
 					},
 					},
 					{
 					{
 						id: 66264646,
 						id: 66264646,
-						name: "满100减50",
-						price: 100,
-						yxTime: "2020-05-16",
+						couponTitle: "满100减50",
+						couponAmount: 100,
+						validEndTime: "2020-05-16",
 						remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
 						remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
 						checked: false
 						checked: false
 					},
 					},
 					{
 					{
 						id: 9794694698,
 						id: 9794694698,
-						name: "满100减50",
-						price: 100,
-						yxTime: "2020-05-16",
+						couponTitle: "满100减50",
+						couponAmount: 100,
+						validEndTime: "2020-05-16",
 						remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
 						remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
 						checked: false
 						checked: false
 					}
 					}
@@ -84,10 +88,19 @@
 				count:0
 				count:0
 			};
 			};
 		},
 		},
+		onLoad() {
+			this.pageInit()			
+		},
 		methods: {
 		methods: {
+			pageInit () {
+				this.current = 0 // tabs组件的current值,表示当前活动的tab选项
+				this.swiperCurrent = 0
+				this.getList()
+			},
 			// tabs通知swiper切换
 			// tabs通知swiper切换
 			tabsChange(index) {
 			tabsChange(index) {
 				this.swiperCurrent = index;
 				this.swiperCurrent = index;
+				this.getList()
 			},
 			},
 			// swiper-item左右移动,通知tabs的滑块跟随移动
 			// swiper-item左右移动,通知tabs的滑块跟随移动
 			transition(e) {
 			transition(e) {
@@ -101,14 +114,20 @@
 				this.$refs.uTabs.setFinishCurrent(current);
 				this.$refs.uTabs.setFinishCurrent(current);
 				this.swiperCurrent = current;
 				this.swiperCurrent = current;
 				this.current = current;
 				this.current = current;
-			},
-			// scroll-view到底部加载更多
-			onreachBottom() {
-				
+				this.getList()
 			},
 			},
 			// 获取优惠卷列表
 			// 获取优惠卷列表
 			getList(){
 			getList(){
-				
+				this.status = 'loading'
+				let item = this.tabsList[this.swiperCurrent]
+				couponListFind({status:item.status}).then(res=>{
+					this.status = 'loadmore'
+					if (res.status == 200) {
+						this.couponList = res.data
+					} else {
+						this.couponList = []
+					}
+				})
 			}
 			}
 		}
 		}
 	};
 	};

+ 17 - 1
pages/getOrder/getOrder.vue

@@ -90,6 +90,7 @@
 </template>
 </template>
 
 
 <script>
 <script>
+	import {couponEnable} from '@/api/coupon.js'
 	import uniSteps from '@/components/uni-steps/uni-steps.vue'
 	import uniSteps from '@/components/uni-steps/uni-steps.vue'
 	import {
 	import {
 		getUserInfo
 		getUserInfo
@@ -283,7 +284,22 @@
 			},
 			},
 			// 获取用户可用优惠券
 			// 获取用户可用优惠券
 			getCouponList() {
 			getCouponList() {
-
+				let params = {
+					consumAmount: this.amount, //订单金额
+					couponScopeList: [
+						{
+							
+						}
+					],
+					goodsType: 'ORDER'  // 	string消费商品类型 ORDER 工单/ORDER_BUNDLE套餐订单
+				}
+				couponEnable(params).then(res=> {
+					if (res.status == 200) {
+						this.couponList = res.data
+					} else {
+						this.couponList = []
+					}
+				})
 			},
 			},
 			// 格式化优惠券数据 获取优惠金额最大的优惠券 couponType 优惠券类型:FULLSUB满减/DISCOUNT折扣券/VOUCHER代金券
 			// 格式化优惠券数据 获取优惠金额最大的优惠券 couponType 优惠券类型:FULLSUB满减/DISCOUNT折扣券/VOUCHER代金券
 			formatCouponData() {
 			formatCouponData() {

+ 5 - 5
pages/store/storeList.vue

@@ -24,7 +24,7 @@
 					</view>
 					</view>
 				</view>
 				</view>
 				<view class="list-right">
 				<view class="list-right">
-					<u-image width="100rpx" height="44rpx" :border-radius="10" :src="getStoreStatus(item)"></u-image>
+					<u-image width="110rpx" height="110rpx" mode="aspectFit" :src="getStoreStatus(item)"></u-image>
 					<u-icon size="30" color="#999" name="arrow-right"></u-icon>
 					<u-icon size="30" color="#999" name="arrow-right"></u-icon>
 				</view>
 				</view>
 			</view>
 			</view>
@@ -131,18 +131,18 @@
 				endTimeStamp = endTimeStamp <=beginTimeStamp ? (endTimeStamp+24*60*60*1000) : endTimeStamp
 				endTimeStamp = endTimeStamp <=beginTimeStamp ? (endTimeStamp+24*60*60*1000) : endTimeStamp
 				switch (item.businessStatus) {
 				switch (item.businessStatus) {
 					case 'CLOSED':
 					case 'CLOSED':
-						return '/static/img/ygb.png'
+						return '/static/img/ztyy.jpg'
 						break;
 						break;
 					case 'OPEN':
 					case 'OPEN':
 						// 根据当前时间判断目前是否在营业时间范围内
 						// 根据当前时间判断目前是否在营业时间范围内
 						if (nowTimeStamp>=beginTimeStamp && nowTimeStamp<=endTimeStamp) {
 						if (nowTimeStamp>=beginTimeStamp && nowTimeStamp<=endTimeStamp) {
-							return '/static/img/yyz.png'
+							return '/static/img/yyz.jpg'
 						} else {
 						} else {
-							return '/static/img/ygb.png'
+							return '/static/img/ztyy.jpg'
 						}
 						}
 						break;
 						break;
 					case 'TO_BE_OPENED':
 					case 'TO_BE_OPENED':
-						return '/static/img/dky.png'
+						return '/static/img/dky.jpg'
 						break;
 						break;
 					default:
 					default:
 						break;
 						break;

BIN=BIN
static/img/dky.jpg


BIN=BIN
static/img/yyz.jpg


BIN=BIN
static/img/ztyy.jpg


+ 48 - 39
store/index.js

@@ -4,17 +4,17 @@ Vue.use(Vuex)
 
 
 let lifeData = {};
 let lifeData = {};
 
 
-try{
+try {
 	// 尝试获取本地是否存在lifeData变量,第一次启动APP时是不存在的
 	// 尝试获取本地是否存在lifeData变量,第一次启动APP时是不存在的
 	lifeData = uni.getStorageSync('lifeData');
 	lifeData = uni.getStorageSync('lifeData');
-}catch(e){
-	
+} catch (e) {
+
 }
 }
 
 
 // 需要永久存储,且下次APP启动需要取出的,在state中的变量名
 // 需要永久存储,且下次APP启动需要取出的,在state中的变量名
 let saveStateKeys = [
 let saveStateKeys = [
-	'vuex_user', 
-	'vuex_token', 
+	'vuex_user',
+	'vuex_token',
 	'vuex_userData',
 	'vuex_userData',
 	'vuex_payType',
 	'vuex_payType',
 	'vuex_payStatus',
 	'vuex_payStatus',
@@ -26,9 +26,9 @@ let saveStateKeys = [
 ];
 ];
 
 
 // 保存变量到本地存储中
 // 保存变量到本地存储中
-const saveLifeData = function(key, value){
+const saveLifeData = function(key, value) {
 	// 判断变量名是否在需要存储的数组中
 	// 判断变量名是否在需要存储的数组中
-	if(saveStateKeys.indexOf(key) != -1) {
+	if (saveStateKeys.indexOf(key) != -1) {
 		// 获取本地存储的lifeData对象,将变量添加到对象中
 		// 获取本地存储的lifeData对象,将变量添加到对象中
 		let tmp = uni.getStorageSync('lifeData');
 		let tmp = uni.getStorageSync('lifeData');
 		// 第一次打开APP,不存在lifeData变量,故放一个{}空对象
 		// 第一次打开APP,不存在lifeData变量,故放一个{}空对象
@@ -43,7 +43,10 @@ const store = new Vuex.Store({
 	state: {
 	state: {
 		// 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量
 		// 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量
 		// 加上vuex_前缀,是防止变量名冲突,也让人一目了然
 		// 加上vuex_前缀,是防止变量名冲突,也让人一目了然
-		vuex_user: lifeData.vuex_user ? lifeData.vuex_user : {account:'',password:''},
+		vuex_user: lifeData.vuex_user ? lifeData.vuex_user : {
+			account: '',
+			password: ''
+		},
 		vuex_token: lifeData.vuex_token ? lifeData.vuex_token : '',
 		vuex_token: lifeData.vuex_token ? lifeData.vuex_token : '',
 		vuex_userData: lifeData.vuex_userData ? lifeData.vuex_userData : '',
 		vuex_userData: lifeData.vuex_userData ? lifeData.vuex_userData : '',
 		vuex_payType: lifeData.vuex_payType ? lifeData.vuex_payType : [], // 支付方式数据字典
 		vuex_payType: lifeData.vuex_payType ? lifeData.vuex_payType : [], // 支付方式数据字典
@@ -61,12 +64,14 @@ const store = new Vuex.Store({
 			bizId: '', // 设备编号
 			bizId: '', // 设备编号
 			itemCode: '', // 服务类型
 			itemCode: '', // 服务类型
 			duration: 0, // 不同服务的机器运行时间
 			duration: 0, // 不同服务的机器运行时间
-			orderNo: '',// 订单编号
+			orderNo: '', // 订单编号
 			orderStatus: '' // 订单状态
 			orderStatus: '' // 订单状态
 		},
 		},
 		// 设备运行页面的计时器
 		// 设备运行页面的计时器
 		orderDjs: 0, // 订单完成倒计时
 		orderDjs: 0, // 订单完成倒计时
-		loadingDjs: 0 // 进度条倒计时
+		loadingDjs: 0, // 进度条倒计时
+		// 优惠券码
+		vuex_couponCode: ''
 	},
 	},
 	mutations: {
 	mutations: {
 		$uStore(state, payload) {
 		$uStore(state, payload) {
@@ -74,9 +79,9 @@ const store = new Vuex.Store({
 			let nameArr = payload.name.split('.');
 			let nameArr = payload.name.split('.');
 			let saveKey = '';
 			let saveKey = '';
 			let len = nameArr.length;
 			let len = nameArr.length;
-			if(nameArr.length >= 2) {
+			if (nameArr.length >= 2) {
 				let obj = state[nameArr[0]];
 				let obj = state[nameArr[0]];
-				for(let i = 1; i < len - 1; i ++) {
+				for (let i = 1; i < len - 1; i++) {
 					obj = obj[nameArr[i]];
 					obj = obj[nameArr[i]];
 				}
 				}
 				obj[nameArr[len - 1]] = payload.value;
 				obj[nameArr[len - 1]] = payload.value;
@@ -94,60 +99,64 @@ const store = new Vuex.Store({
 			let _this = this
 			let _this = this
 			let token = getApp().globalData.token
 			let token = getApp().globalData.token
 			let url = getApp().globalData.baseUrl
 			let url = getApp().globalData.baseUrl
-			let wsBaseUrl = url.indexOf("https:")>=0 ? url.replace("https:","wss:") : url.replace("http:","ws:")
+			let wsBaseUrl = url.indexOf("https:") >= 0 ? url.replace("https:", "wss:") : url.replace("http:", "ws:")
 			let wsUrl = wsBaseUrl + 'websocket/weixin/' + state.vuex_orderInfo.bizId
 			let wsUrl = wsBaseUrl + 'websocket/weixin/' + state.vuex_orderInfo.bizId
 			// 开始连接
 			// 开始连接
 			state.vuex_socket = uni.connectSocket({
 			state.vuex_socket = uni.connectSocket({
-				header: {'X-AUTH-TOKEN':token},
-			    url: wsUrl, // ws 请求地址
-			    complete: ()=> {
+				header: {
+					'X-AUTH-TOKEN': token
+				},
+				url: wsUrl, // ws 请求地址
+				complete: () => {
 					console.log('连接complete回调!')
 					console.log('连接complete回调!')
 				}
 				}
 			});
 			});
 			// 打开连接
 			// 打开连接
-			state.vuex_socket.onOpen(function(e){
+			state.vuex_socket.onOpen(function(e) {
 				console.log('连接成功!')
 				console.log('连接成功!')
 			})
 			})
 			// 连接关闭
 			// 连接关闭
-			state.vuex_socket.onClose(function(e){
+			state.vuex_socket.onClose(function(e) {
 				console.log('ws关闭!')
 				console.log('ws关闭!')
 			})
 			})
 			// 连接错误
 			// 连接错误
-			state.vuex_socket.onError(function(e){
+			state.vuex_socket.onError(function(e) {
 				console.log('ws错误!', JSON.stringify(e))
 				console.log('ws错误!', JSON.stringify(e))
 			})
 			})
 			// 接受消息
 			// 接受消息
-			state.vuex_socket.onMessage(function(e){
-				if (typeof(e.data) == 'object'){
-				  let ret = JSON.parse(e.data)
-				  console.log('ws接收消息!', ret)
-				  uni.$emit('wsMessage',ret)
+			state.vuex_socket.onMessage(function(e) {
+				if (typeof(e.data) == 'object') {
+					let ret = JSON.parse(e.data)
+					console.log('ws接收消息!', ret)
+					uni.$emit('wsMessage', ret)
 				}
 				}
-				if(typeof(e.data) == 'string'){
-					uni.$emit('wsMessage',e.data)
+				if (typeof(e.data) == 'string') {
+					uni.$emit('wsMessage', e.data)
 				}
 				}
 			})
 			})
 			// 发送心跳包
 			// 发送心跳包
-			state.vuex_heartInterId = setInterval(function () {
+			state.vuex_heartInterId = setInterval(function() {
 				console.log(state.vuex_socket.readyState)
 				console.log(state.vuex_socket.readyState)
-				if(state.vuex_socket.readyState != 1){
+				if (state.vuex_socket.readyState != 1) {
 					state.vuex_socket = uni.connectSocket({
 					state.vuex_socket = uni.connectSocket({
-						header: {'X-AUTH-TOKEN':token},
-					    url: wsUrl, // ws 请求地址
-					    complete: ()=> {
+						header: {
+							'X-AUTH-TOKEN': token
+						},
+						url: wsUrl, // ws 请求地址
+						complete: () => {
 							console.log('连接complete回调!')
 							console.log('连接complete回调!')
 						}
 						}
 					});
 					});
-				}else{
-					_this.commit("$sendWebsocket","ping")
+				} else {
+					_this.commit("$sendWebsocket", "ping")
 				}
 				}
 			}, 10000)
 			}, 10000)
 		},
 		},
 		// 关闭websocket
 		// 关闭websocket
-		$closeWebsocket(state){
-			if(state.vuex_socket){
+		$closeWebsocket(state) {
+			if (state.vuex_socket) {
 				state.vuex_socket.close({
 				state.vuex_socket.close({
-					complete: function(e){
+					complete: function(e) {
 						console.log('关闭websocket完成', e)
 						console.log('关闭websocket完成', e)
 						// 停止心跳
 						// 停止心跳
 						clearInterval(state.vuex_heartInterId)
 						clearInterval(state.vuex_heartInterId)
@@ -157,9 +166,9 @@ const store = new Vuex.Store({
 		},
 		},
 		// 发送消息
 		// 发送消息
 		$sendWebsocket(state, msg) {
 		$sendWebsocket(state, msg) {
-		    state.vuex_socket.send({
+			state.vuex_socket.send({
 				data: msg,
 				data: msg,
-				complete: function(e){
+				complete: function(e) {
 					console.log('ws发送完成', e)
 					console.log('ws发送完成', e)
 				}
 				}
 			})
 			})
@@ -167,4 +176,4 @@ const store = new Vuex.Store({
 	}
 	}
 })
 })
 
 
-export default store
+export default store