stanley-king il y a 4 ans
Parent
commit
d6d8727eb3

+ 1 - 1
app.js

@@ -147,7 +147,7 @@ App({
         this.mWxAuthor.init(true);
     },
     cardShareInfo() {
-        console.log('index onShareAppMessage')
+        console.log('index cardShareInfo')
         let userid = this.globalData.member_id
         let imageUrl = '/image/xyzshare.png'
         let share_path = `/pages/index/index?relay_id=${userid}`

+ 1 - 1
config.js

@@ -29,7 +29,7 @@ function getReq(app,data, callback, method)
       return;
     }
   }
-
+  
   console.log('act=' + act + '&' + 'op=' + data['op']);
   let header = {
     'content-type': 'application/json', // 默认值

+ 4 - 1
pages/components/auth/auth.js

@@ -24,7 +24,10 @@ Component({
 
   lifetimes: {
     attached: function () {
-      if (!app.globalData.hasmobile) {
+      if(!app.globalData.userInfo) {
+        this.setData({ showAuthName: true, showAuthPhone: false })
+      }
+      else if(!app.globalData.hasmobile) {
         this.setData({ showAuthName: false, showAuthPhone: true })
       }      
     },

+ 94 - 2
pages/components/shareDialog/shareDialog.js

@@ -1,4 +1,7 @@
 // pages/components/shareDialog/shareDialog.js
+const getReq = require('../../../config').getReq;
+let app = getApp();
+
 Component({
   /**
    * 组件的属性列表
@@ -7,6 +10,20 @@ Component({
     showDialog:{
       type:Boolean,
       value:false
+    },
+    goods_id: {
+      type: Number,
+      observer() {
+        console.log('observer goods_id = ', this.properties.goods_id)
+        let goods_id = this.properties.goods_id
+        if(goods_id > 0) {
+          this.requestData(goods_id);
+          this.setData({shareModel: app.cardShareInfo()})
+        }
+        else {
+
+        }
+      } 
     }
   },
 
@@ -14,15 +31,90 @@ Component({
    * 组件的初始数据
    */
   data: {
+    current_goodsid:0,
+    fGoodsRequesting: false,
+    tip:'', 
+    invitess:[],
+    policy:[],
+    tip_title:'',
+    tip_num:0,
+    shareModel:{}
+  },
 
+  pageLifetimes: {
+    // 组件所在页面的生命周期函数
+    show: function () {
+      console.log('pageLifetimes goods_id = ', this.properties.goods_id)
+     },
+    hide: function () { 
+      console.log('pageLifetimes goods_id = ', this.properties.goods_id)
+    },
+    resize: function () { },
+  },
+
+  lifetimes: {
+    attached: function () {
+      console.log('lifetimes attached')
+
+      wx.getSetting({
+        withSubscriptions: true,
+        success(res) {
+          var itemSettings = res.subscriptionsSetting.itemSettings
+          console.log('setting:', itemSettings)
+          if (itemSettings) {
+            if (itemSettings['模版id'] === 'accept') {
+              
+            }
+          }
+        }
+      })
+    },
+    detached: function () {
+    },
   },
 
   /**
    * 组件的方法列表
    */
   methods: {
-    onCloseDialog(){
-      this.triggerEvent('closeDialog',{})
+    onCloseDialog() {
+      wx.requestSubscribeMessage({
+        tmplIds: ['zBNktaey9EM2DcBzUNsjnAan2NvYpj_nKZDY__f9pGA'],
+        success(res) {
+          console.log(res)
+        }
+      })
+      console.log('onCloseDialog');
+      this.triggerEvent('closeDialog', {})
+    },
+    onShareInfo(){
+      console.log('onShareInfo');
+      this.triggerEvent('onShareInfo', {})
+    },
+    requestData(goods_id)
+    {
+      console.log('requestData goods_id=',goods_id)
+      if (this.fGoodsRequesting) return;
+
+      this.fGoodsRequesting = true
+      getReq(app, {
+        act: 'member_invitee',
+        op: 'goods_share',
+        goods_id: goods_id,
+      }, (res) => {
+          console.log('res:', res)
+        if (res.code == 200) {
+          if (res.datas) {
+            let invitess = res.datas.invitess
+            let policy = res.datas.policy 
+            let tip_title = res.datas.tip_title
+            let tip_num = res.datas.tip_num
+            this.setData({ tip_title,tip_num,invitess, policy })
+            
+          }
+        }
+        this.fGoodsRequesting = false
+      })
     }
   }
 })

+ 9 - 7
pages/components/shareDialog/shareDialog.wxml

@@ -3,19 +3,21 @@
     <image src="../../../image/share_bg.png" class="share_bg"></image>
     <image src="../../../image/close_icon.png" class="close_icon" bindtap="onCloseDialog"></image>
 		<view class="shareInfo">
-			<view class="shareInfo___top">邀请5位好友,可以优惠50元</view>
-			<view class="shareInfo___bottom">还有<text class="num">4</text>位好友待邀请</view>
+			<view class="shareInfo___top">{{tip_title}}</view>
+			<view class="shareInfo___bottom">还有<text class="num">{{tip_num}}</text>位好友待邀请</view>
 		</view>
 		<view class="shareList">
 			<block wx:for="{{5}}" wx:key="index">
 				<view class="shareItem">
-					<image src="../../../image/user_placeholder.png" class="user_placeholder"></image>
-					<view class="shareName">补贴{{3+index}}元</view>
+					<image src="{{invitess[index].avatar}}" class="user_placeholder" wx:if="{{invitess.length > index}}"></image>
+					<image src="../../../image/user_placeholder.png" class="user_placeholder" wx:if="{{invitess.length <= index}}"></image>
+					<view class="shareName" wx:if="{{policy.length > index && policy[index].discount > 0}}">补{{policy[index].discount}}元</view>
+					<view class="shareName" wx:if="{{policy.length <= index || policy[index].discount == 0}}"></view>					
 				</view>
-			</block>
+			</block>			
 		</view>
-    <view class="btn-rechargeNow">
+		<button open-type="share" class="btn-rechargeNow" data-shareInfo="{{shareModel}}">
 			<text>去邀请好友</text>
-		</view>
+		</button>
 	</view>
 </view>

+ 1 - 0
pages/components/shareDialog/shareDialog.wxss

@@ -82,6 +82,7 @@
 }
 
 .shareName {
+  height: 25rpx;
   font-size: 24rpx;
   color: #573A0C;
 }

+ 1 - 1
pages/phoneCharges/phoneCharges.wxml

@@ -78,5 +78,5 @@
   </view> -->
 </view>
 
-<shareDialog showDialog="{{showShareDialog}}" bind:closeDialog="onCloseShareDialog"/>
+<shareDialog showDialog="{{showShareDialog}}"  goods_id="{{goods_id}}" bind:closeDialog="onCloseShareDialog"/>
 <termsOfService show="{{showtermsOfServiceDialog}}" bind:close="onShowtermsOfServiceDialog" />

+ 14 - 2
pages/postage/postage.js

@@ -26,18 +26,21 @@ Page({
     member_mobile:'',
 
     tabsData: [
-      { id: 0, icon: '/image/postage/sinopec.png', title: '中国石化',  tips: '选择油卡',   card_type: 'sinopec',    card_no: '' },
+      { id: 0, icon: '/image/postage/sinopec.png', title: '中国石化', tips: '选择油卡', card_type: 'sinopec', card_no: '' },
       { id: 1, icon: '/image/postage/petrochina.png', title: '中国石油', tips: '选择油卡', card_type: 'petrochina', card_no: '' }
     ],
     fromSource: '',
     payInfoChecked:true,
     showShareDialog:false,
+    shareGoodsId:0,
     showtermsOfServiceDialog:false
   },
 
   onShowShareDialog(){
+    var goods_id = this.data.goods_id
     this.setData({
-      showShareDialog:true
+      showShareDialog:true,
+      shareGoodsId: goods_id,
     })
   },
 
@@ -241,9 +244,18 @@ Page({
   onHide: function () {
     this.setData({
       showShareDialog:false,
+      shareGoodsId:0,
       showtermsOfServiceDialog:false
     })
   },
+  onShareInfo: function () {
+    console.log('onShareInfo')
+    wx.getShareInfo({
+      success: function (res) {
+        console.log(res)
+      }
+    })    
+  },
 
   /**
    * 生命周期函数--监听页面卸载

+ 1 - 1
pages/postage/postage.wxml

@@ -77,5 +77,5 @@
 	</view>
 </view>
 
-<shareDialog showDialog="{{showShareDialog}}" bind:closeDialog="onCloseShareDialog"/>
+<shareDialog showDialog="{{showShareDialog}}" goods_id="{{shareGoodsId}}" bind:closeDialog="onCloseShareDialog"/>
 <termsOfService show="{{showtermsOfServiceDialog}}" bind:close="onShowtermsOfServiceDialog" />