Sfoglia il codice sorgente

个人中心页面微信授权

kk.shi 3 anni fa
parent
commit
6ce34a5049

+ 23 - 13
pages/luckDraw/prize.js

@@ -1,6 +1,7 @@
 // pages/luckDraw/prize.js
 import LuckDraw from '../../api/luck-draw'
 import { parseTime } from '../../utils/util';
+import {getMobileCache, getPhoneNumber as getPhoneNumberSync} from '../../utils/user'
 Page({
 
     /**
@@ -12,6 +13,7 @@ Page({
         lock: false,
         noResult: false,
         noMore: false,
+        isLogin: false,
         couponNum: 0,
         productNum: 0,
         goodsItemList: []
@@ -22,7 +24,10 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-
+    this.setData({
+        isLogin: getMobileCache() != ''
+    })
+    this.getUserPrizeList();
   },
 
   /**
@@ -36,7 +41,7 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
-    this.getUserPrizeList();
+
   },
 
   /**
@@ -61,13 +66,6 @@ Page({
   },
 
   /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom: function () {
-
-  },
-
-  /**
    * 用户点击右上角分享
    */
   onShareAppMessage: function () {
@@ -77,7 +75,7 @@ Page({
       LuckDraw.getUserPrizeList({
           page: this.data.page,
           pageSize: this.data.pageSize,
-          mobile:'16602120168',
+          mobile: getMobileCache(),
           goodsType: 2
       }).then(res => {
           if (res.code == 200) {
@@ -114,7 +112,7 @@ Page({
 
   /**
    * 页面上拉触底事件的处理函数
-   */
+   
   onReachBottom: function () {
       if (this.data.lock || this.data.noMore) {
           return
@@ -122,12 +120,24 @@ Page({
       this.data.lock = true
       this.data.page++
       this.getUserPrizeList()
-  },
+  },*/
 
   toProfile(e) {
     const url = "profile?id=" + e.currentTarget.dataset.id
     wx.redirectTo({
         url
     })
-}
+   },
+    turnPrize: function() {
+        console.log("开始查看")
+        if (this.isLock || !this.data.isLogin) {
+            return
+        }
+    },
+    // 授权手机号
+    getPhoneNumber(e) {
+        getPhoneNumberSync(e, _ => {
+            this.getUserPrizeList()
+        })
+    },
 })

+ 2 - 1
pages/luckDraw/prize.wxml

@@ -19,7 +19,8 @@
         <view class="luck-draw-cjh"><view class="luck-draw-cj"></view></view>
       </view>
     </view>
-    <view class="luck-draw-theme">
+    <view class="luck-draw-theme" catchtap="turnPrize">
+      <button class="luck-draw-cz" wx:if="{{!isLogin}}" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" >请进行用户授权</button>
       <!-- 奖品 -->
       <view class="luck-draw-content" wx:for="{{goodsItemList}}" wx:key="index" data-id="{{item.id}}">
         <view class="luck-draw-words">

+ 3 - 2
pages/luckDraw/profile.js

@@ -75,7 +75,7 @@ Page({
         LuckDraw.getUserPrizeList({
             page: this.data.page,
             pageSize: this.data.pageSize,
-            mobile: getMobileCache(),
+            mobile:  getMobileCache(),
             goodsType: 1
         }).then(res => {
             if (res.code == 200) {
@@ -113,7 +113,7 @@ Page({
 
     /**
      * 页面上拉触底事件的处理函数
-     */
+     
     onReachBottom: function () {
         if (this.data.lock || this.data.noMore) {
             return
@@ -122,6 +122,7 @@ Page({
         this.data.page++
         this.getUserPrizeList()
     },
+    */
 
     toPrize(e) {
         const url = "prize?id=" + e.currentTarget.dataset.id

+ 3 - 2
pages/luckDraw/profile.wxml

@@ -10,7 +10,7 @@
       <!-- 优惠券 -->
       <view class="luck-draw-coupon" catchtap="turnPrize">
         <view class="luck-draw-cn">{{couponNum}}</view>
-        <button class="luck-draw-cz" wx:if="{{!isLogin}}" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" />优惠券
+        <view class="luck-draw-cz">优惠券</view>
         <view class="luck-draw-cjh"><view class="luck-draw-cj"></view></view>
       </view>
       <!-- 奖品 -->
@@ -19,7 +19,8 @@
         <view class="luck-draw-pz">奖品</view>
       </view>
     </view>
-    <view class="luck-draw-theme">
+    <view class="luck-draw-theme" catchtap="turnPrize">
+      <button class="luck-draw-cz" wx:if="{{!isLogin}}" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" >请进行用户授权</button>
       <!-- 折扣券 -->
       <view class="luck-draw-content" wx:for="{{goodsItemList}}" wx:key="index" data-id="{{item.id}}" catchtap="toDetail" wx:if="{{item.couponType == 'D'}}">
         <view class="luck-draw-words">