zhaoxiaohai 3 lat temu
rodzic
commit
c3adbe0db0

+ 5 - 0
app.js

@@ -4,6 +4,11 @@ import {
 const _Http = new ApiModel();
 App({
   onLaunch() {
+    /* wx.setStorageSync('qrCodeMsg', {
+      type: 'partner',
+      id: 32116,
+      name: '江南布业'
+    }) */
     /* 计算tabbar+iphone安全距离  tabbar页面+100rpx*/
     let safeAreaBottom = 0,
       capsule = wx.getMenuButtonBoundingClientRect(),

+ 0 - 1
app.json

@@ -47,7 +47,6 @@
         "pages/storeMessage/editor/editor",
         "pages/webView/index",
         "pages/teamManagement/applyFor",
-        "pages/login/QrCode",
         "pages/instantMessaging/index"
     ],
     "usingComponents": {

+ 49 - 0
components/My_TwoDimensionalCode/analyze.js

@@ -0,0 +1,49 @@
+import {
+    ApiModel
+} from "../../utils/api";
+const _Http = new ApiModel();
+
+function showModel(data, content) {
+    wx.setStorageSync('qrCodeMsg', data);
+    wx.showModal({
+        title: '提示',
+        content: content,
+        showCancel: false,
+        success: (res => {
+            if (res.confirm) wx.navigateTo({
+                url: '/pages/login/index',
+            })
+        })
+    });
+}
+
+//解析二维码链接
+function setDataUrl(url) {
+    let q = url;
+    console.log("q", q);
+    const data = {
+        type: q.slice(q.indexOf("type=") + 5, q.indexOf('&')),
+        id: q.slice(q.lastIndexOf('=') + 1),
+        name: q.slice(q.lastIndexOf('fbrand=') + 7, q.lastIndexOf('&'))
+    }
+    if (!wx.getStorageSync('userData').token) {
+        return showModel(data, '当前未登录,请登录后进入')
+    } else {
+        _Http.basic({
+            "accesstoken": wx.getStorageSync('userData').token,
+            "classname": "customer.usercenter.usermsg.usermsg",
+            "method": "query_usermsg",
+            "content": {}
+        }).then(res => {
+            if (res.msg != '成功') showModel(data, "登陆状态已过期,请重新登陆!");
+            return data;
+        })
+    }
+}
+
+
+
+
+module.exports = {
+    setDataUrl
+}

+ 2 - 2
components/My_TwoDimensionalCode/index.js

@@ -32,9 +32,9 @@ Component({
                 });
                 let codeText = '';
                 if (this.data.title == '商户二维码') {
-                    codeText = 'https://www.cnd3b.com/qr?type=shop&fbrand=' + res.data[0].fbrand + '&tagentsid=' + res.data[0].tagentsid;
+                    codeText = 'https://www.buwanjia.com/qrcode?type=shop&fbrand=' + res.data[0].fbrand + '&tagentsid=' + res.data[0].tagentsid;
                 } else {
-                    codeText = 'https://www.cnd3b.com/qr?type=partner&fbrand=' + res.data[0].fbrand + '&tagentsid=' + res.data[0].tagentsid;
+                    codeText = 'https://www.buwanjia.com/qrcode?type=partner&fbrand=' + res.data[0].fbrand + '&tagentsid=' + res.data[0].tagentsid;
                 };
                 this.qrCode(codeText)
             });

+ 0 - 246
pages/login/QrCode.js

@@ -1,246 +0,0 @@
-import {
-    ApiModel
-} from "../../utils/api";
-const _Http = new ApiModel();
-Page({
-
-    /**
-     * 页面的初始数据
-     */
-    data: {
-        codeMsg: '', // type: partner-申请合作  shop-加入团队
-        manner: "双向合作",
-        selectType: 3,
-        show: false
-    },
-
-    /**
-     * 生命周期函数--监听页面加载
-     query */
-    onLoad: function (query) {
-        console.log(query)
-        if (query.url) {
-            const q = decodeURIComponent(query.url);
-            return this.setDataUrl(q)
-        } else if (query.q) { // 获取到二维码原始链接内容、
-            const q = decodeURIComponent(query.q);
-            return this.setDataUrl(q)
-        } else {
-            this.setData({
-                codeMsg: wx.getStorageSync('qrCodeMsg')
-            })
-            wx.setStorageSync('qrCodeMsg', "")
-            console.log(wx.getStorageSync('qrCodeMsg'))
-        }
-    },
-    setDataUrl(url) {
-        let q = url;
-        console.log("q", q)
-        const data = {
-            type: q.slice(q.indexOf("type=") + 5, q.indexOf('&')),
-            id: q.slice(q.lastIndexOf('=') + 1),
-            name: q.slice(q.lastIndexOf('fbrand=') + 7, q.lastIndexOf('&'))
-        }
-        if (!wx.getStorageSync('userData').token) {
-            wx.setStorageSync('qrCodeMsg', data);
-            wx.showModal({
-                title: '提示',
-                content: '当前未登录,请登录后进入',
-                showCancel: false,
-                success: (res => {
-                    if (res.confirm) wx.navigateTo({
-                        url: '/pages/login/index',
-                    })
-                })
-            });
-        } else {
-            this.setData({
-                codeMsg: data
-            })
-        }
-    },
-    /* 确定 */
-    confirm() {
-        const that = this;
-        if (this.data.codeMsg.type == 'partner') {
-            wx.showModal({
-                title: "提示",
-                content: "是否确定将“" + this.data.codeMsg.name + "”作为您的" + this.data.manner + "合作伙伴",
-                success: (s => {
-                    if (s.confirm) {
-                        _Http.basic({
-                            "accesstoken": wx.getStorageSync('userData').token,
-                            "classname": "customer.tagents.tagents",
-                            "method": "apply_cooperation",
-                            "content": {
-                                "tcooperationagentsid": that.data.codeMsg.id,
-                                "ftype": that.data.selectType
-                            }
-                        }).then(res => {
-                            if (res.msg != '成功') return wx.showToast({
-                                title: res.data,
-                                icon: "none"
-                            });
-                            wx.showToast({
-                                title: "合作申请成功",
-                            });
-                            setTimeout(() => {
-                                wx.switchTab({
-                                    url: '/pages/tabbar-pages/home/index',
-                                })
-                            }, 500)
-                            wx.removeStorageSync('qrCodeMsg');
-                        })
-                    }
-                })
-            })
-        } else if (this.data.codeMsg.type == 'shop') {
-            wx.showModal({
-                title: "提示",
-                content: "是否确定加入“" + this.data.codeMsg.name + "”成为团队的一份子",
-                success: (s => {
-                    if (s.confirm) {
-                        _Http.basic({
-                            "classname": "publicmethod.users.Users",
-                            "method": "entryTeamApply",
-                            "content": {
-                                "userid": wx.getStorageSync('userData').userid,
-                                "tagentsid": that.data.codeMsg.id
-                            }
-                        }).then(res => {
-                            if (res.data != '成功') return wx.showToast({
-                                title: res.data,
-                                icon: "none"
-                            });
-                            wx.showToast({
-                                title: "申请成功",
-                            });
-                            setTimeout(() => {
-                                wx.switchTab({
-                                    url: '/pages/tabbar-pages/home/index',
-                                })
-                            }, 500)
-                            wx.removeStorageSync('qrCodeMsg');
-                        })
-                    }
-                })
-            })
-        }
-    },
-    /* 取消 */
-    refuse() {
-        if (this.data.codeMsg.type == 'partner') {
-            wx.showModal({
-                title: "提示",
-                content: "是否确定取消与“" + this.data.codeMsg.name + "”建立合作关系",
-                success: (res => {
-                    console.log(res)
-                    if (res.confirm) {
-                        wx.showToast({
-                            title: "取消成功",
-                        });
-                        setTimeout(() => {
-                            wx.switchTab({
-                                url: '/pages/tabbar-pages/home/index',
-                            })
-                        }, 500)
-                        wx.removeStorageSync('qrCodeMsg');
-                    }
-                })
-            })
-        } else if (this.data.codeMsg.type == 'shop') {
-            wx.showModal({
-                title: "提示",
-                content: "是否确定取消加入“" + this.data.codeMsg.name + "”",
-                success: (res => {
-                    if (res.confirm) {
-                        wx.showToast({
-                            title: "取消成功",
-                        });
-                        setTimeout(() => {
-                            wx.switchTab({
-                                url: '/pages/tabbar-pages/home/index',
-                            })
-                        }, 500)
-                        wx.removeStorageSync('qrCodeMsg');
-                    }
-                })
-            })
-        }
-    },
-    /* 选择合作方式 */
-    selectManner() {
-        this.setData({
-            show: !this.data.show
-        })
-    },
-    optionChange({
-        detail
-    }) {
-        let selectType = 3;
-        switch (detail) {
-            case "上游":
-                selectType = 1;
-                break;
-            case "下游":
-                selectType = 2;
-                break;
-            case "双向合作":
-                selectType = 3;
-                break;
-            default:
-                break;
-        }
-        this.setData({
-            manner: detail,
-            selectType,
-            show: false
-        })
-    },
-    /**
-     * 生命周期函数--监听页面初次渲染完成
-     */
-    onReady: function () {
-
-    },
-
-    /**
-     * 生命周期函数--监听页面显示
-     */
-    onShow: function () {},
-
-    /**
-     * 生命周期函数--监听页面隐藏
-     */
-    onHide: function () {
-
-    },
-
-    /**
-     * 生命周期函数--监听页面卸载
-     */
-    onUnload: function () {
-
-    },
-
-    /**
-     * 页面相关事件处理函数--监听用户下拉动作
-     */
-    onPullDownRefresh: function () {
-
-    },
-
-    /**
-     * 页面上拉触底事件的处理函数
-     */
-    onReachBottom: function () {
-
-    },
-
-    /**
-     * 用户点击右上角分享
-     */
-    onShareAppMessage: function () {
-
-    }
-})

+ 0 - 5
pages/login/QrCode.json

@@ -1,5 +0,0 @@
-{
-  "usingComponents": {
-    "My_MultipleChoice": "/components/My_MultipleChoice/index"
-  }
-}

+ 0 - 29
pages/login/QrCode.wxml

@@ -1,29 +0,0 @@
-<view class="box" wx:if="{{codeMsg.type=='partner'}}">
-    <image id="Logo" src="/static/logo.png" mode="widthFix"></image>
-    <view class="textTips">
-        <view class="title">商户名称:</view>
-        <view class="con">{{codeMsg.name}}</view>
-    </view>
-    <view class="textTips" style="margin-top: 60rpx;">
-        <view class="title">合作方式:</view>
-        <view class="con" catchtap="selectManner">{{manner}}
-            <van-icon name="arrow-down" />
-        </view>
-    </view>
-</view>
-<view class="box" wx:if="{{codeMsg.type=='shop'}}">
-    <image id="Logo" src="/static/logo.png" mode="widthFix"></image>
-    <view class="textTips shop">
-        <view class="title"><text style="color: #4DC2D4;">“{{codeMsg.name}}”</text>邀请您加入团队</view>
-    </view>
-</view>
-<!-- 选择合作方式 -->
-<van-action-sheet show="{{ show }}" bind:close="optionChange">
-    <view style="font-size: 32rpx;font-family: PingFangSC-Medium, PingFang SC;font-weight: 550;color: #000000;margin-left: 54rpx;margin-top: 40rpx;">合作方式</view>
-    <My_MultipleChoice type='cooperation' pitchOnItem="{{manner}}" bind:optionChange='optionChange'></My_MultipleChoice>
-</van-action-sheet>
-<!-- 按钮 -->
-<view class="buttom">
-    <van-button color="#3EB5B8" custom-class='but-custom-class' catchtap='refuse'>取 消</van-button>
-    <van-button color="#4DC2D4" custom-class='but-custom-class' catchtap="confirm">确 定</van-button>
-</view>

+ 0 - 56
pages/login/QrCode.wxss

@@ -1,56 +0,0 @@
-page {
-    background-color: #ffffff;
-}
-
-.box {
-    display: flex;
-    flex-direction: column;
-    align-items: center;
-}
-
-#Logo {
-    width: 230rpx;
-    margin: 150rpx 0 80rpx
-}
-
-/* 按钮 */
-.buttom {
-    display: flex;
-    justify-content: space-around;
-    align-items: center;
-    width: 80vw;
-    height: 80rpx;
-    margin: 80rpx auto 0;
-}
-
-.but-custom-class {
-    height: 60rpx !important;
-    width: 160rpx !important;
-    color: #ffffff;
-    border-radius: 30rpx !important;
-    font-weight: 550;
-}
-
-/* 文字 */
-.textTips {
-    display: flex;
-    justify-content: space-between;
-    align-items: center;
-    padding: 0 30rpx;
-    min-height: 80rpx;
-    width: 80vw;
-    font-size: 30rpx;
-    box-sizing: border-box;
-    background-color: rgba(0, 0, 0, .02);
-    border: 1px solid #dbdada;
-    border-radius: 15rpx;
-    color: rgba(0, 0, 0, .7);
-}
-
-.shop {
-    padding: 20rpx 30rpx;
-}
-
-.textTips .select {
-    margin-top: 30rpx;
-}

+ 85 - 7
pages/tabbar-pages/home/index.js

@@ -3,6 +3,8 @@ import {
 } from "../../../utils/api";
 const _Http = new ApiModel();
 const handleList = require("../../../utils/processingData");
+const analyze = require("../../../components/My_TwoDimensionalCode/analyze");
+
 Page({
     /**
      * 页面的初始数据
@@ -24,6 +26,9 @@ Page({
             "兴趣爱好", "关注板块", "最新发布"
         ],
         partnerList: [], //合作商家列表
+        codeMsg: {}, //二维码信息
+        MyModelShow: false, //二维码二次确认
+        MyModelText: "", //提示框文本
     },
     /* tabs切换 */
     /* tabsSelectedIitem(text) {
@@ -67,8 +72,20 @@ Page({
     /**
      * 生命周期函数--监听页面加载
      */
-    onLoad: function (options) {
+    onLoad: function (query) {
         const that = this;
+        // 获取到二维码原始链接内容
+        if (query.q) {
+            //有登录态直接加入
+            this.ifQrCodeType(analyze.setDataUrl(decodeURIComponent(query.q)));
+        } else if (wx.getStorageSync('qrCodeMsg')) {
+            //无登录态判断缓存中是否存在
+            this.ifQrCodeType(wx.getStorageSync('qrCodeMsg'));
+            //返回数据后清空缓存
+            setTimeout(() => {
+                wx.removeStorageSync('qrCodeMsg');
+            }, 500)
+        };
         /* 获取最新供需列表 */
         _Http.basic({
             "accesstoken": wx.getStorageSync('userData').token,
@@ -92,7 +109,7 @@ Page({
             const data = handleList.getYTD(res.data);
             this.setData({
                 productList: data
-            })
+            });
         });
         /* 获取合作商家 */
         _Http.basic({
@@ -121,7 +138,6 @@ Page({
             })
         })
         /* 获取轮播图 */
-        /* getApp().globalData.bannerDataList */
         const bannerList = wx.getStorageSync('bannerDataList').filter(value => value.flocation == 'home_head');
         this.setData({
             swiperBannerList: bannerList[0].banner
@@ -133,10 +149,72 @@ Page({
                 'tabbarList[3].fcount': getApp().globalData.msgFcount
             })
         }, 500)
-        //查看是否有状态邀请
-        if (wx.getStorageSync('qrCodeMsg').type) return wx.navigateTo({
-            url: '/pages/login/QrCode',
-        });
+    },
+    /* 判断二维码类型 */
+    ifQrCodeType(data) {
+        let MyModelText = '';
+        if (data.type == 'partner') {
+            //申请合作
+            MyModelText = '是否向“' + data.name + '”发送合作申请';
+        } else if (data.type == 'shop') {
+            //申请加入团队
+            MyModelText = '申请加入“' + data.name + '”团队';
+        };
+        this.setData({
+            MyModelText,
+            codeMsg: data,
+            MyModelShow: true
+        })
+    },
+    /* 首页模态框回调 */
+    MyShowModelCallBack({
+        detail
+    }) {
+        if (detail == 'true') {
+            if (this.data.codeMsg.type == 'partner') {
+                //申请合作
+                _Http.basic({
+                    "accesstoken": wx.getStorageSync('userData').token,
+                    "classname": "customer.tagents.tagents",
+                    "method": "apply_cooperation",
+                    "content": {
+                        "tcooperationagentsid": this.data.codeMsg.id
+                    }
+                }).then(res => {
+                    if (res.msg != '成功') return wx.showToast({
+                        title: res.data,
+                        icon: "none"
+                    });
+                    wx.showToast({
+                        title: "合作申请成功",
+                    });
+                });
+            } else if (this.data.codeMsg.type == 'shop') {
+                //申请加入团队
+                _Http.basic({
+                    "classname": "publicmethod.users.Users",
+                    "method": "entryTeamApply",
+                    "content": {
+                        "userid": wx.getStorageSync('userData').userid,
+                        "tagentsid": this.data.codeMsg.id
+                    }
+                }).then(res => {
+                    if (res.data != '成功') return wx.showToast({
+                        title: res.data,
+                        icon: "none"
+                    });
+                    wx.showToast({
+                        title: "申请成功",
+                        icon: "none"
+                    });
+                })
+            }
+        } else {
+            this.setData({
+                MyModelShow: false,
+                codeMsg: ''
+            });
+        }
     },
     /* 一键联系 */
     contact() {

+ 3 - 1
pages/tabbar-pages/home/index.wxml

@@ -51,4 +51,6 @@
 <!-- 调用tabbar中的信息查询 -->
 <block>
     <CusTabBar id="gxshuju"></CusTabBar>
-</block>
+</block>
+
+<My_showModel isShow='{{MyModelShow}}' bindcallBack='MyShowModelCallBack' content='{{MyModelText}}' cancel='取消' confirm='确定' ifTabBar></My_showModel>

+ 38 - 5
pages/webView/index.js

@@ -1,20 +1,52 @@
-// pages/webView/index.js
+import {
+    ApiModel
+} from "../../utils/api";
+const _Http = new ApiModel();
 Page({
-
     /**
      * 页面的初始数据
      */
     data: {
-
+        url: {},
     },
 
     /**
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
-
+        //判断是否纯在登录态度
+        if (!wx.getStorageSync('userData').token) {
+            this.toLogin("当前未登录,是否前去登录", options.url);
+        } else {
+            _Http.basic({
+                "accesstoken": "6682a82c96fb72035e6b53f32dab4d7c",
+                "classname": "customer.usercenter.usermsg.usermsg",
+                "method": "query_usermsg",
+                "content": {}
+            }).then(res => {
+                if (res.msg != '成功') this.toLogin("当前登录状态已过期,请重新登录", options.url);
+            })
+        };
+        this.setData({
+            url: options.url
+        })
+    },
+    /* 去登陆 */
+    toLogin(content, url) {
+        console.log(url)
+        wx.showModal({
+            title: "提示",
+            content: content,
+            success: (res) => {
+                if (res.confirm) {
+                    getApp().globalData.liveUrl = url;
+                    wx.reLaunch({
+                        url: '/pages/login/index'
+                    })
+                }
+            }
+        });
     },
-
     /**
      * 生命周期函数--监听页面初次渲染完成
      */
@@ -22,6 +54,7 @@ Page({
 
     },
 
+
     /**
      * 生命周期函数--监听页面显示
      */

+ 1 - 1
pages/webView/index.wxml

@@ -1 +1 @@
-<web-view src="https://www.buwanjia.com/customer/index.html"></web-view>
+<web-view src="{{url}}"></web-view>

+ 7 - 0
project.private.config.json

@@ -142,6 +142,13 @@
                     "name": "信息列表",
                     "pathName": "pages/instantMessaging/index",
                     "query": "",
+                    "launchMode": "default",
+                    "scene": null
+                },
+                {
+                    "name": "",
+                    "pathName": "pages/webView/index",
+                    "query": "",
                     "scene": null,
                     "launchMode": "default"
                 }