zhaoxiaohai %!s(int64=2) %!d(string=hai) anos
pai
achega
f359157db7

+ 43 - 33
pages/promotional/details.js

@@ -1,7 +1,6 @@
 const _Http = getApp().globalData.http,
     MFT = require("../../utils/matchingFeilType"),
     checkFile = require("../../utils/checkFile");
-import Dialog from '@vant/weapp/dialog/dialog';
 Page({
     /**
      * 页面的初始数据
@@ -9,7 +8,9 @@ Page({
     data: {
         sat_sharematerialid: null,
         detailsData: {},
-        dataType: 0
+        dataType: 0,
+        addNewCount: 0,
+        popupShow: false
     },
 
     /**
@@ -35,17 +36,13 @@ Page({
             this.setData({
                 detailsData: res.data
             });
-
             //分享进入
-            if (wx.getLaunchOptionsSync().scene == 1154) {
-                this.addNew(false)
-            } else if ([1007, 1008].includes(wx.getLaunchOptionsSync().scene)) Dialog.confirm({
-                    title: '提示',
-                    message: '请帮助完善信息',
-                })
-                .then(this.addNew)
-                .catch(this.addNew)
-
+            if ([1007, 1008, 1155].includes(wx.getLaunchOptionsSync().scene)) this.setData({
+                "shareData.userid": options.userid,
+                "shareData.systemclient": "wechatsaletool",
+                "shareData.sat_sharematerialid": options.id,
+                popupShow: true
+            })
         } else {
             wx.showToast({
                 title: res.msg,
@@ -53,9 +50,21 @@ Page({
             })
         }
     },
+    /* 获取手机号 */
+    getphonenumber({
+        detail
+    }) {
+        this.setData({
+            "shareData.code_phone": detail.code ? detail.code : '',
+            addNewCount: this.data.addNewCount + 1
+        })
+        this.handleAddNew();
+    },
     /* 新增拉新用户 */
     async addNew(gain = true) {
-        let name = '微信用户';
+        let name = '微信用户',
+            channel = null,
+            that = this;
         if (gain) name = await new Promise((res, rej) => {
             wx.getUserProfile({
                 desc: '用于完善用户资料',
@@ -69,9 +78,6 @@ Page({
                 }
             })
         })
-
-        let channel = null,
-            that = this;
         switch (wx.getLaunchOptionsSync().scene) {
             case 1007:
                 channel = '单人会话分享'
@@ -79,30 +85,34 @@ Page({
             case 1008:
                 channel = '群聊会话分享'
                 break;
-            case 1154:
+            case 1155:
                 channel = '朋友圈分享'
                 break;
             default:
                 channel = '其他方式'
                 break;
-        }
-
+        };
         wx.login({
             success(res) {
-                _Http.base({
-                    "classname": "saletool.sharematerial.sharematerial",
-                    "method": "addNew",
-                    "content": {
-                        "sat_sharematerialid": that.data.sat_sharematerialid,
-                        "fname": name,
-                        "channel": channel,
-                        "code": res.code,
-                        "systemclient": "wechatsaletool"
-                    }
-                }, false).then(res => {
-                    console.log("记录分享", res)
+                that.setData({
+                    "shareData.fname": name,
+                    "shareData.channel": channel,
+                    "shareData.code_login": res.code,
+                    addNewCount: that.data.addNewCount + 1
                 })
+                that.handleAddNew();
             }
+        });
+    },
+    handleAddNew() {
+        if (this.data.addNewCount != 2) return;
+        _Http.base({
+            "classname": "saletool.sharematerial.sharematerial",
+            "method": "addNew",
+            "content": this.data.shareData
+        }, false)
+        this.setData({
+            popupShow: false
         })
     },
     openFile(e) {
@@ -127,7 +137,7 @@ Page({
             this.updateShareLog(data.sat_sharematerialid);
             resolve({
                 title: data.title,
-                path: `/pages/promotional/details?id=${data.sat_sharematerialid}&type=${data.type}`,
+                path: `/pages/promotional/details?id=${data.sat_sharematerialid}&type=${data.type}&userid=${wx.getStorageSync('userMsg').userid}`,
                 imageUrl: data.cover
             })
         })
@@ -139,7 +149,7 @@ Page({
         let data = this.data.detailsData;
         return {
             title: data.title,
-            path: `/pages/promotional/details?id=${data.sat_sharematerialid}&type=${data.type}`,
+            path: `/pages/promotional/details?id=${data.sat_sharematerialid}&type=${data.type}&userid=${wx.getStorageSync('userMsg').userid}`,
             imageUrl: data.cover
         }
     }

+ 1 - 2
pages/promotional/details.json

@@ -1,7 +1,6 @@
 {
     "navigationBarTitleText": "素材详情",
     "usingComponents": {
-        "mp-html": "/components/mp-html/index",
-        "van-dialog": "@vant/weapp/dialog/index"
+        "mp-html": "/components/mp-html/index"
     }
 }

+ 27 - 0
pages/promotional/details.scss

@@ -80,4 +80,31 @@
         font-weight: bold;
         color: #FFFFFF;
     }
+}
+
+/* 弹出层 */
+.popup-style {
+    width: 80vw !important;
+    height: 300rpx;
+
+    .title {
+        width: 100%;
+        text-align: center;
+        font-size: 32rpx;
+        font-weight: 550;
+        line-height: 120rpx;
+    }
+
+    .content {
+        width: 100%;
+        text-align: center;
+    }
+
+    .button {
+        position: absolute;
+        width: 100%;
+        bottom: 0;
+        color: var(--assist) !important;
+        font-weight: 550;
+    }
 }

+ 7 - 1
pages/promotional/details.wxml

@@ -32,4 +32,10 @@
 </view>
 
 <!-- 弹窗 -->
-<van-dialog id="van-dialog" confirm-button-color='var(--assist)' />
+<van-popup show="{{ popupShow }}" custom-class='popup-style' zIndex='9999999999999999999' round bind:close="onClose">
+    <view class="title">提示</view>
+    <view class="content">帮助完善用户信息</view>
+    <view bindtap="addNew">
+        <van-button custom-class='button' open-type='getPhoneNumber' bindgetphonenumber='getphonenumber'>确认</van-button>
+    </view>
+</van-popup>

+ 1 - 1
pages/promotional/index.js

@@ -228,7 +228,7 @@ Page({
                 })
                 resolve({
                     title: data.title,
-                    path: `/pages/promotional/details?id=${data.sat_sharematerialid}&type=${data.type}`,
+                    path: `/pages/promotional/details?id=${data.sat_sharematerialid}&type=${data.type}&userid=${wx.getStorageSync('userMsg').userid}`,
                     imageUrl: data.cover
                 })
             }, 50)