Преглед изворни кода

添加抽奖机会的判断

xueyihao пре 4 месеци
родитељ
комит
683db69c31

+ 9 - 0
src/api/index.js

@@ -602,3 +602,12 @@ export function pointDraw(data) {
         data
         data
     })
     })
 }
 }
+
+// 查看是否有抽奖机会
+export function getIsLottery(data) {
+    return request({
+        method: 'post',
+        url: '/lottery/isLottery',
+        data
+    })
+}

+ 110 - 0
src/components/webviewPoint.vue

@@ -0,0 +1,110 @@
+<template>
+  <u-modal :show="show" title="恭喜您,中奖啦!!!" :show-cancel="false">
+    <view slot="default" class="modal-content">
+      <text class="modal-text">恭喜您获得转盘抽奖的机会!</text>
+    </view>
+    <view slot="confirmButton" class="modal-footer">
+      <button class="modal-cancel" @click="show = false">取消</button>
+      <wx-open-launch-weapp
+          id="launch-btn"
+          appid="wxab9634bf98628a03"
+          :path="launchButtonHtml"
+      >
+        <script type="text/wxtag-template">
+          <button style="padding:10px;width:100%;background:#07c160;color:white;">去抽奖</button>
+        </script>
+      </wx-open-launch-weapp>
+    </view>
+  </u-modal>
+</template>
+<script>
+import {handleServiceAdjustMiniProgram} from '@/utils/share.js'
+export default {
+  data() {
+    return {
+      show:false,
+      launchButtonHtml: ''
+    }
+  },
+  methods: {
+    getRow(){
+      let currentPlatform = 'gyy-aB4cD6eF8gH0iJ2kL4';
+      let currentUser = '2049045470263193601';
+      let activityId = '2029805805219950593';
+      let url = '/packageF/pages/activity/lottery/turntable?activityId='+ activityId + '&currentPlatform='+currentPlatform+'&currentUser='+currentUser;
+      this.initLaunchButton(url)
+    },
+    async initLaunchButton(url) {
+      try {
+        await handleServiceAdjustMiniProgram();
+        this.show = true;
+        this.launchButtonHtml = url;
+      } catch (err) {
+        console.error('初始化跳转按钮失败', err)
+        this.launchButtonHtml = '';
+      }
+    },
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+::v-deep .u-modal {
+  .u-modal__title {
+    background: #E8FFFD;
+    height: 92rpx;
+    padding: 0;
+    font-family: PingFang SC, PingFang SC;
+    font-weight: bold;
+    font-size: 32rpx;
+    color: #000000;
+    line-height: 92rpx;
+  }
+
+  .u-modal__content,
+  .u-modal__button-group--confirm-button {
+    padding: 0;
+  }
+}
+// 模态框样式
+.modal-content {
+  padding: 40rpx 32rpx;
+  text-align: center;
+
+  .modal-text {
+    font-family: PingFang SC, PingFang SC;
+    font-weight: 500;
+    font-size: 28rpx;
+    color: #333333;
+    line-height: 39rpx;
+  }
+}
+
+.modal-footer {
+  border-top: 1rpx solid #EEEEEE;
+  display: flex;
+  justify-content: center;
+  padding: 24rpx 58rpx;
+
+  button {
+    width: 225rpx;
+    height: 68rpx;
+    border-radius: 60rpx;
+    font-size: 28rpx;
+    text-align: center;
+    line-height: 68rpx;
+    margin: 0 20rpx;
+    padding: 0;
+  }
+
+  .modal-cancel {
+    border: 1rpx solid #999999;
+    color: #333333;
+  }
+
+  .modal-confirm {
+    width: 129px;
+    height: 38px;
+  }
+}
+</style>

+ 0 - 12
src/pages.json

@@ -512,18 +512,6 @@
 							"titleNView": false
 							"titleNView": false
 						}
 						}
 					}
 					}
-				},
-				{
-					"path": "myNew/webview",
-					"style": {
-						"navigationBarTitleText": "抽奖大转盘",
-						"navigationBarBackgroundColor": "#2cb8d4",
-						"navigationBarTextStyle": "white",
-						"app-plus": {
-							"softinputNavBar": "none",
-							"titleNView": false
-						}
-					}
 				}
 				}
 			]
 			]
 		},
 		},

+ 12 - 12
src/pages/identify/pay_order.vue

@@ -192,14 +192,14 @@ export default {
 			],
 			],
 			// 支付计时
 			// 支付计时
 			remainingTime: '',
 			remainingTime: '',
-			// 支付方式 
-			selectedPayment: null, 
+			// 支付方式
+			selectedPayment: null,
 		}
 		}
 	},
 	},
 	onLoad(query) {
 	onLoad(query) {
 		this.query = query;
 		this.query = query;
 		wx.checkJsApi({
 		wx.checkJsApi({
-			jsApiList: ['chooseImage'], 
+			jsApiList: ['chooseImage'],
 			success: (res) => {
 			success: (res) => {
 				// 以键值对的形式返回,可用的api值true,不可用为false
 				// 以键值对的形式返回,可用的api值true,不可用为false
 				// 如:{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
 				// 如:{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
@@ -228,7 +228,7 @@ export default {
 				openid: uni.getStorageSync('wx_copenid')
 				openid: uni.getStorageSync('wx_copenid')
 			}
 			}
 			getCoupon(params).then(res => {
 			getCoupon(params).then(res => {
-				if (res.data.data.length > 0) {
+				if (res.data.data?.length > 0) {
 					this.couponNum = res.data.data.length
 					this.couponNum = res.data.data.length
 				} else {
 				} else {
 					this.couponNum = 0
 					this.couponNum = 0
@@ -253,7 +253,7 @@ export default {
 					this.dTotalMoney = this.details.dTotalMoney;
 					this.dTotalMoney = this.details.dTotalMoney;
 					this.priceDifference = this.details.priceDifference;
 					this.priceDifference = this.details.priceDifference;
 					// 支付倒计时
 					// 支付倒计时
-          this.$set(this, 'remainingTime', res.data.data.records[0].remainingTime * 1000);          
+          this.$set(this, 'remainingTime', res.data.data.records[0].remainingTime * 1000);
 					// 获取部门车费
 					// 获取部门车费
 					this.fareSetting(res.data.data.records[0].deptId);
 					this.fareSetting(res.data.data.records[0].deptId);
 					// 获取服务时间
 					// 获取服务时间
@@ -334,7 +334,7 @@ export default {
 					icon: 'none'
 					icon: 'none'
 				})
 				})
 			} else if (this.selectedPayment == 1) {
 			} else if (this.selectedPayment == 1) {
-				//微信支付 
+				//微信支付
 				this.weixinPay()
 				this.weixinPay()
 			} else if (this.selectedPayment == 2) {
 			} else if (this.selectedPayment == 2) {
 				//余额支付
 				//余额支付
@@ -360,8 +360,8 @@ export default {
 					wx.config({
 					wx.config({
 						beta: true,
 						beta: true,
 						debug: false,
 						debug: false,
-						appId: this.wxconfig.appId, // 公众号ID 
-						// appId: uni.getAppBaseInfo().host.appId, // 公众号ID 
+						appId: this.wxconfig.appId, // 公众号ID
+						// appId: uni.getAppBaseInfo().host.appId, // 公众号ID
 						timestamp: this.wxconfig.timestamp, // 时间戳,自1970年以来的秒数
 						timestamp: this.wxconfig.timestamp, // 时间戳,自1970年以来的秒数
 						nonceStr: this.wxconfig.nonceStr, // 随机串
 						nonceStr: this.wxconfig.nonceStr, // 随机串
 						signature: this.wxconfig.sign, // 微信签名方式
 						signature: this.wxconfig.sign, // 微信签名方式
@@ -369,9 +369,9 @@ export default {
 					});
 					});
 					var vm = this
 					var vm = this
 					wx.invoke(
 					wx.invoke(
-						'getBrandWCPayRequest', 
+						'getBrandWCPayRequest',
 						// 下面参数内容都是后台返回的
 						// 下面参数内容都是后台返回的
-						{ 
+						{
 							'appId': payConfig.appid, // 公众号名称,由商户传入
 							'appId': payConfig.appid, // 公众号名称,由商户传入
 							'timeStamp': payConfig.timeStamp, // 时间戳
 							'timeStamp': payConfig.timeStamp, // 时间戳
 							'nonceStr': payConfig.nonceStr, // 随机串
 							'nonceStr': payConfig.nonceStr, // 随机串
@@ -528,7 +528,7 @@ export default {
 						title: res.data.msg,
 						title: res.data.msg,
 					})
 					})
 				}
 				}
-			
+
 			})
 			})
 		},
 		},
 		verification() {
 		verification() {
@@ -939,4 +939,4 @@ export default {
 ::v-deep .u-count-down {
 ::v-deep .u-count-down {
   margin-left: 10rpx !important;
   margin-left: 10rpx !important;
 }
 }
-</style>
+</style>

+ 15 - 5
src/pages/order/order.vue

@@ -1,12 +1,13 @@
 <template>
 <template>
 	<view class="page-container">
 	<view class="page-container">
-		<z-paging ref="paging" v-model="dataList" 
+    <webviewPoint ref="webviewRef"/>
+		<z-paging ref="paging" v-model="dataList"
 			:paging-style="{
 			:paging-style="{
 				background: 'linear-gradient(180deg, #C1FFF8 0%, #B8FFF3 34%, #F5FFFF 100%)'
 				background: 'linear-gradient(180deg, #C1FFF8 0%, #B8FFF3 34%, #F5FFFF 100%)'
 			}" @query="queryList">
 			}" @query="queryList">
 			<template #top>
 			<template #top>
 				<view class="tab-box">
 				<view class="tab-box">
-					<view v-for="(item,index) in statusList" :key="index" 
+					<view v-for="(item,index) in statusList" :key="index"
 						:class="{ item: true, active: current === index }"
 						:class="{ item: true, active: current === index }"
 						@click="onTabChange(item.code, index)">
 						@click="onTabChange(item.code, index)">
 						{{item.info}}
 						{{item.info}}
@@ -99,7 +100,8 @@
 
 
 <script>
 <script>
 import {
 import {
-	getStatusList,
+  getIsLottery,
+  getStatusList,
 } from '@/api/index.js';
 } from '@/api/index.js';
 import {
 import {
 	delOrder,
 	delOrder,
@@ -107,7 +109,9 @@ import {
 	cancleApply,
 	cancleApply,
 	orderDeatails,
 	orderDeatails,
 } from '@/api/order.js';
 } from '@/api/order.js';
+import webviewPoint from "@/components/webviewPoint.vue";
 export default {
 export default {
+  components: { webviewPoint },
 	data() {
 	data() {
 		return {
 		return {
 			dataList: [],
 			dataList: [],
@@ -131,6 +135,12 @@ export default {
 		this.isLogin = !!uni.getStorageSync('wx_copenid');
 		this.isLogin = !!uni.getStorageSync('wx_copenid');
 	},
 	},
 	onShow() {
 	onShow() {
+    getIsLottery({type:[1,3]}).then(res=>{
+      console.log(res)
+      if(res.data.data.isLottery === 1){
+        this.$refs.webviewRef?.getRow();
+      }
+    })
 		this.getStatus()
 		this.getStatus()
 	},
 	},
 	methods: {
 	methods: {
@@ -345,7 +355,7 @@ export default {
 			&::after{
 			&::after{
 				content: '';
 				content: '';
 				width: 36rpx;
 				width: 36rpx;
-				height: 4rpx; 
+				height: 4rpx;
 				position: absolute;
 				position: absolute;
 				bottom: 0;
 				bottom: 0;
 				left: 50%;
 				left: 50%;
@@ -457,4 +467,4 @@ export default {
     }
     }
   }
   }
 }
 }
-</style>
+</style>

+ 18 - 3
src/points/order/orderList.vue

@@ -1,6 +1,9 @@
 <script>
 <script>
 import {getPointOrderList} from '@/api/pointOrder'
 import {getPointOrderList} from '@/api/pointOrder'
+import webviewPoint from "@/components/webviewPoint.vue";
+import {getIsLottery} from '@/api/index'
 export default {
 export default {
+  components: { webviewPoint },
   name: "orderList",
   name: "orderList",
   data(){
   data(){
     return {
     return {
@@ -17,6 +20,14 @@ export default {
   onReady() {
   onReady() {
     this.getListOrder();
     this.getListOrder();
   },
   },
+  mounted(){
+    getIsLottery({type:[2]}).then(res=>{
+      console.log(res)
+      if(res.data.data.isLottery === 1){
+        this.$refs.webviewRef?.getRow();
+      }
+    })
+  },
   methods:{
   methods:{
     async getListOrder(isLoadMore = false) {
     async getListOrder(isLoadMore = false) {
       this.loading = true
       this.loading = true
@@ -85,6 +96,7 @@ export default {
 
 
 <template>
 <template>
   <view class="order-box">
   <view class="order-box">
+    <webviewPoint ref="webviewRef"/>
     <u-list @scrolltolower="loadMore" style="height:calc(100vh - 100rpx)">
     <u-list @scrolltolower="loadMore" style="height:calc(100vh - 100rpx)">
       <u-list-item v-for="(item, index) in orderList" :key="`${item.id}-${index}`" class="order-item">
       <u-list-item v-for="(item, index) in orderList" :key="`${item.id}-${index}`" class="order-item">
         <view class="order-header">
         <view class="order-header">
@@ -104,7 +116,7 @@ export default {
       </u-list-item>
       </u-list-item>
       <!-- 空数据状态 -->
       <!-- 空数据状态 -->
       <u-empty
       <u-empty
-          style="margin-top: 30vh"
+          class="emptytop"
         v-if="orderList.length === 0"
         v-if="orderList.length === 0"
         icon="order"
         icon="order"
         text="暂无订单"
         text="暂无订单"
@@ -112,7 +124,7 @@ export default {
       >
       >
       </u-empty>
       </u-empty>
       <!-- 加载更多 -->
       <!-- 加载更多 -->
-      <u-loadmore 
+      <u-loadmore
         v-if="orderList.length > 0"
         v-if="orderList.length > 0"
         :status="loading ? 'loading' : (hasMore ? 'more' : 'nomore')"
         :status="loading ? 'loading' : (hasMore ? 'more' : 'nomore')"
         loading-text="加载中..."
         loading-text="加载中..."
@@ -130,6 +142,9 @@ export default {
   min-height: 100vh;
   min-height: 100vh;
   background: #F5F8F8;
   background: #F5F8F8;
   padding: 32rpx;
   padding: 32rpx;
+  .u-empty{
+    margin-top: 30vh!important;
+  }
   .order-item{
   .order-item{
     width: 686rpx;
     width: 686rpx;
     height: 256rpx;
     height: 256rpx;
@@ -212,4 +227,4 @@ export default {
     }
     }
   }
   }
 }
 }
-</style>
+</style>

+ 75 - 33
src/utils/share.js

@@ -1,37 +1,45 @@
 // 微信服务号分享功能
 // 微信服务号分享功能
 import wx from 'weixin-js-sdk'
 import wx from 'weixin-js-sdk'
 import {getSignature} from "@/api";
 import {getSignature} from "@/api";
-
+import { h5Url } from '@/common/config.js';
 /**
 /**
  * 初始化微信 JS-SDK
  * 初始化微信 JS-SDK
  * @param {Object} config - 微信 JS-SDK 配置参数
  * @param {Object} config - 微信 JS-SDK 配置参数
+ * @returns {Promise} - 初始化成功返回 resolve,失败返回 reject
  */
  */
 export function initWechatSDK(config) {
 export function initWechatSDK(config) {
-  if (typeof wx === 'undefined') {
-    console.error('微信 JS-SDK 未加载');
-    return;
-  }
-  
-  wx.config({
-    debug: false,
-    appId: config.appId,
-    timestamp: config.timestamp,
-    nonceStr: config.nonceStr,
-    signature: config.signature,
-    jsApiList: [
-      'updateAppMessageShareData',
-      'updateTimelineShareData',
-      'onMenuShareAppMessage',
-      'onMenuShareTimeline'
-    ]
-  });
-  
-  wx.ready(function() {
-    console.log('微信 JS-SDK 初始化成功');
-  });
-  
-  wx.error(function(res) {
-    console.error('微信 JS-SDK 初始化失败:', res);
+  return new Promise((resolve, reject) => {
+    if (typeof wx === 'undefined') {
+      console.error('微信 JS-SDK 未加载');
+      reject(new Error('微信 JS-SDK 未加载'));
+      return;
+    }
+
+    wx.config({
+      debug: false,
+      appId: config.appId,
+      timestamp: config.timestamp,
+      nonceStr: config.nonceStr,
+      signature: config.signature,
+      jsApiList: [
+        'updateAppMessageShareData',
+        'updateTimelineShareData',
+        'onMenuShareAppMessage',
+        'onMenuShareTimeline',
+        'launchMiniProgram'
+      ],
+      openTagList: ['wx-open-launch-weapp']
+    });
+
+    wx.ready(function() {
+      console.log('微信 JS-SDK 初始化成功');
+      resolve();
+    });
+
+    wx.error(function(res) {
+      console.error('微信 JS-SDK 初始化失败:', res);
+      reject(res);
+    });
   });
   });
 }
 }
 
 
@@ -48,9 +56,9 @@ export function configWechatShare(options) {
     console.error('微信 JS-SDK 未加载');
     console.error('微信 JS-SDK 未加载');
     return;
     return;
   }
   }
-  
+
   const { title, desc, link, imgUrl } = options;
   const { title, desc, link, imgUrl } = options;
-  
+
   // 分享给朋友
   // 分享给朋友
   wx.updateAppMessageShareData({
   wx.updateAppMessageShareData({
     title: title,
     title: title,
@@ -64,7 +72,7 @@ export function configWechatShare(options) {
       console.log('分享给朋友取消');
       console.log('分享给朋友取消');
     }
     }
   });
   });
-  
+
   // 分享到朋友圈
   // 分享到朋友圈
   wx.updateTimelineShareData({
   wx.updateTimelineShareData({
     title: title,
     title: title,
@@ -77,7 +85,7 @@ export function configWechatShare(options) {
       console.log('分享到朋友圈取消');
       console.log('分享到朋友圈取消');
     }
     }
   });
   });
-  
+
   // 兼容旧版本
   // 兼容旧版本
   wx.onMenuShareAppMessage({
   wx.onMenuShareAppMessage({
     title: title,
     title: title,
@@ -91,7 +99,7 @@ export function configWechatShare(options) {
       console.log('分享给朋友取消(旧版本)');
       console.log('分享给朋友取消(旧版本)');
     }
     }
   });
   });
-  
+
   wx.onMenuShareTimeline({
   wx.onMenuShareTimeline({
     title: title,
     title: title,
     link: link,
     link: link,
@@ -111,7 +119,8 @@ export function configWechatShare(options) {
  */
  */
 export async function handleServiceShare(shareData) {
 export async function handleServiceShare(shareData) {
   // 这里可以根据实际需求,调用后端接口获取微信 JS-SDK 配置
   // 这里可以根据实际需求,调用后端接口获取微信 JS-SDK 配置
-  const res = await getSignature()
+  let url = `${h5Url}/`
+  const res = await getSignature({url:url})
   // 假设已经获取到配置信息
   // 假设已经获取到配置信息
   const wxConfig = {
   const wxConfig = {
     appId: res.data.appId, // 从后端获取
     appId: res.data.appId, // 从后端获取
@@ -137,4 +146,37 @@ export async function handleServiceShare(shareData) {
     icon: 'none',
     icon: 'none',
     duration: 2000
     duration: 2000
   });
   });
-}
+}
+
+/**
+ * 处理微信服务号调整小程序
+ * @param {Object} shareData - 分享数据
+ */
+export async function handleServiceAdjustMiniProgram() {
+  // 这里可以根据实际需求,调用后端接口获取微信 JS-SDK 配置
+  let url = `${h5Url}/`
+  const res = await getSignature();
+  console.log(res)
+  // const res = {
+  //   data:{
+  //     appId:"wx9dc677bd41e82569",
+  //     jsapi_ticket : "xN-5lpdNhLiE7IEBU_UcHiyJbIL_nALi9KlPocS0cgHRtlLg8pID873P8yRAP2bAEy5nvorNMX2FW7F-2eh0gg",
+  //     nonceStr : "50784887-0393-401e-9933-94cd7185093d",
+  //     signature : "855a95d6cefc0496302d05398276c6395a608184",
+  //     timestamp: "1778206207",
+  //     url: "https://city.baoxianzhanggui.com/fragrance/"
+  //   }
+  // }
+  // 假设已经获取到配置信息
+  const wxConfig = {
+    appId: res.data.appId, // 从后端获取
+    timestamp: res.data.timestamp, // 从后端获取
+    nonceStr: res.data.nonceStr, // 从后端获取
+    signature: res.data.signature // 从后端获取
+  };
+
+  // 初始化微信 JS-SDK
+  await initWechatSDK(wxConfig);
+  // 3. 生成抽奖按钮 HTML
+  //return `<wx-open-launch-weapp id="launch-btn" appid="wxab9634bf98628a03" path="${url}"><script type="text/wxtag-template"><style>.btn{padding:12px 24px;background:#07c160;color:#fff;border:none;border-radius:8px;font-size:16px;}</style><button class="btn">打开小程序指定页面</button></script></wx-open-launch-weapp>`;
+}