Explorar el Código

用户抽奖时带上formid

fenggang hace 5 años
padre
commit
d774831d18
Se han modificado 3 ficheros con 13 adiciones y 6 borrados
  1. 3 2
      pages/award-detail/award-detail.js
  2. 5 1
      pages/award-detail/award-detail.wxml
  3. 5 3
      utils/API.js

+ 3 - 2
pages/award-detail/award-detail.js

@@ -52,12 +52,13 @@ Page({
     }).exec()
     }).exec()
   },
   },
   // 点击抽奖按钮事件处理函数
   // 点击抽奖按钮事件处理函数
-	handleDrawLottery() {
+	handleDrawLottery(e) {
+    const {formId} = e.detail
     const { id } = this.data
     const { id } = this.data
     wx.showLoading({
     wx.showLoading({
       title: '抽奖中'
       title: '抽奖中'
     });
     });
-		drawLottery(id)
+		drawLottery(id, formId)
 			.then(data => {
 			.then(data => {
         const {user_lottery_codes, avatar_url} = data.data
         const {user_lottery_codes, avatar_url} = data.data
         wx.hideLoading()
         wx.hideLoading()

+ 5 - 1
pages/award-detail/award-detail.wxml

@@ -76,14 +76,18 @@
   </view>
   </view>
 
 
   <view class="btn-wrapper" wx:if="{{state !== '0'}}">
   <view class="btn-wrapper" wx:if="{{state !== '0'}}">
-    <button class="btn-draw" wx:if="{{user_draw_state === 0 && state !== '2'}}" bind:tap="handleDrawLottery">点击抽奖
+  <form report-submit="true" bindsubmit="handleDrawLottery">
+    <button class="btn-draw" wx:if="{{user_draw_state === 0 && state !== '2'}}" form-type="submit">点击抽奖
     </button>
     </button>
+  </form>
     <button class="btn-invite" wx:if="{{user_draw_state === 1 && state !== '2'}}" open-type="share">邀请好友
     <button class="btn-invite" wx:if="{{user_draw_state === 1 && state !== '2'}}" open-type="share">邀请好友
     </button>
     </button>
     <view class="aniamte-ring {{user_draw_state === 1 ? 'invite' : 'draw'}}" wx:if="{{state !== '2'}}">
     <view class="aniamte-ring {{user_draw_state === 1 ? 'invite' : 'draw'}}" wx:if="{{state !== '2'}}">
     </view>
     </view>
   </view>
   </view>
 
 
+
+
   <view class="my-code">
   <view class="my-code">
  
  
     <i-alert wx:if="{{user_lottery_codes.length !== 0}}">
     <i-alert wx:if="{{user_lottery_codes.length !== 0}}">

+ 5 - 3
utils/API.js

@@ -1,4 +1,5 @@
-const HOST = 'https://lottery-wxa-api.duowan.com'
+const HOST = 'https://lottery-wxa-api.duowan.com' // prod
+// const HOST = 'https://test-lottery-wxa-api.duowan.com/'  // test
 const HEADER = { 'content-type': 'application/x-www-form-urlencoded' }
 const HEADER = { 'content-type': 'application/x-www-form-urlencoded' }
 
 
 /**
 /**
@@ -95,13 +96,14 @@ function getLotteryDetail(id) {
  * @param {*} id 抽奖ID
  * @param {*} id 抽奖ID
  * @returns
  * @returns
  */
  */
-function drawLottery(id) {
+function drawLottery(id, formId) {
   const { token } = wx.getStorageSync('USER_INFO')
   const { token } = wx.getStorageSync('USER_INFO')
   return new Promise((resolve, reject) => {
   return new Promise((resolve, reject) => {
 		wx.request({
 		wx.request({
       url: HOST + '/lotteries/draw/' + id ,
       url: HOST + '/lotteries/draw/' + id ,
       data: {
       data: {
-        token
+        token,
+        formId 
       },
       },
       header: HEADER,
       header: HEADER,
       method: 'POST',
       method: 'POST',