Browse Source

用户抽奖时带上formid

fenggang 5 years ago
parent
commit
d774831d18
3 changed files with 13 additions and 6 deletions
  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()
   },
   // 点击抽奖按钮事件处理函数
-	handleDrawLottery() {
+	handleDrawLottery(e) {
+    const {formId} = e.detail
     const { id } = this.data
     wx.showLoading({
       title: '抽奖中'
     });
-		drawLottery(id)
+		drawLottery(id, formId)
 			.then(data => {
         const {user_lottery_codes, avatar_url} = data.data
         wx.hideLoading()

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

@@ -76,14 +76,18 @@
   </view>
 
   <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>
+  </form>
     <button class="btn-invite" wx:if="{{user_draw_state === 1 && state !== '2'}}" open-type="share">邀请好友
     </button>
     <view class="aniamte-ring {{user_draw_state === 1 ? 'invite' : 'draw'}}" wx:if="{{state !== '2'}}">
     </view>
   </view>
 
+
+
   <view class="my-code">
  
     <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' }
 
 /**
@@ -95,13 +96,14 @@ function getLotteryDetail(id) {
  * @param {*} id 抽奖ID
  * @returns
  */
-function drawLottery(id) {
+function drawLottery(id, formId) {
   const { token } = wx.getStorageSync('USER_INFO')
   return new Promise((resolve, reject) => {
 		wx.request({
       url: HOST + '/lotteries/draw/' + id ,
       data: {
-        token
+        token,
+        formId 
       },
       header: HEADER,
       method: 'POST',