Browse Source

扫码后操作

zhaoxiaohai 3 years ago
parent
commit
f58196c341

+ 2 - 1
app.json

@@ -46,7 +46,8 @@
         "pages/storeMessage/storehomepage",
         "pages/storeMessage/editor/editor",
         "pages/webView/index",
-        "pages/teamManagement/applyFor"
+        "pages/teamManagement/applyFor",
+        "pages/login/QrCode"
     ],
     "usingComponents": {
         "van-button": "@vant/weapp/button/index",

+ 17 - 1
components/My_MultipleChoice/index.js

@@ -29,6 +29,21 @@ Component({
     lifetimes: {
         attached: function () {
             // 在组件实例进入页面节点树时执行
+            //选择合作方式
+            if (this.data.type == 'cooperation') {
+                const res = {
+                    msg: "成功",
+                    data: [{
+                        ftype: "上游"
+                    }, {
+                        ftype: "下游"
+                    }, {
+                        ftype: "双向合作"
+                    }]
+                }
+                console.log(res)
+                return this.returnClassify(res)
+            };
             //默认供需分类
             let data = {
                 "accesstoken": wx.getStorageSync('userData').token,
@@ -84,6 +99,7 @@ Component({
         },
         /* 返回分类 */
         returnClassify(res) {
+            console.log(res)
             if (res.msg != "成功") return wx.showToast({
                 title: '数据加载失败,请重新进入页面',
                 icon: "none",
@@ -96,7 +112,7 @@ Component({
                 if (this.data.type == 'product') {
                     if (res.data[i] == this.data.pitchOnItem) checked = true;
                     value = res.data[i];
-                } else if (this.data.type == 'mr') {
+                } else {
                     if (res.data[i].ftype == this.data.pitchOnItem) checked = true;
                     value = res.data[i].ftype;
                 }

+ 38 - 16
components/My_TwoDimensionalCode/index.js

@@ -1,4 +1,8 @@
 const QR = require('../../miniprogram_npm/qrcode-base64/index.js');
+import {
+    ApiModel
+} from "../../utils/api";
+const _Http = new ApiModel();
 import {
     base64src
 } from './base64src';
@@ -16,24 +20,30 @@ Component({
     },
     lifetimes: {
         attached: function () {
-            const codeText = 'https://www.baidu.com';
-            if (this.data.title == '商户二维码') {
-                console.log('商户二维码')
-            } else {
-                console.log('合作二维码')
-            }
-            // 在组件实例进入页面节点树时执行
-            var imgData = QR.drawImg(codeText, {
-                typeNumber: 4,
-                errorCorrectLevel: 'M',
-                size: 500
-            })
-            base64src(imgData, res => {
-                this.setData({
-                    qrcodeURL: res
+            /* _Http.basic({
+                "accesstoken": wx.getStorageSync('userData').token,
+                "classname": "customer.tagents.tagents",
+                "method": "query_enterpriseAgentsMain",
+                "content": {}
+            }).then(res => {
+                if (res.msg != '成功') return wx.showToast({
+                    title: res.msg,
+                    icon: "none"
                 });
-            });
+                let shopData = {
+                        fbrand: res.data[0].fbrand,
+                        tagentsid: res.data[0].tagentsid,
+                    },
+                    codeText = '';
+                const data = JSON.stringify(shopData);
+                if (this.data.title == '商户二维码') {
+                    codeText = 'https://www.cnd3b.com/qr?type=shop';
+                } else {
+                    codeText = 'https://www.cnd3b.com/qr?type=partner&fbrand=' + res.data[0].fbrand + '&tagentsid=' + res.data[0].tagentsid;
+                };
+                this.qrCode(codeText)
 
+            }); */
         },
         detached: function () {
             // 在组件实例被从页面节点树移除时执行
@@ -50,6 +60,18 @@ Component({
      * 组件的方法列表
      */
     methods: {
+        qrCode(codeText) {
+            var imgData = QR.drawImg(codeText, {
+                typeNumber: 4,
+                errorCorrectLevel: 'M',
+                size: 500
+            })
+            base64src(imgData, res => {
+                this.setData({
+                    qrcodeURL: res
+                });
+            });
+        },
         /* 预览大图 */
         preViewImage() {
             const url = [this.data.qrcodeURL];

+ 240 - 0
pages/login/QrCode.js

@@ -0,0 +1,240 @@
+import {
+    ApiModel
+} from "../../utils/api";
+const _Http = new ApiModel();
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        codeMsg: '', // type: partner-申请合作  shop-加入团队
+        manner: "双向合作",
+        selectType: 3,
+        show: false
+    },
+
+    /**
+     * 生命周期函数--监听页面加载
+     query */
+    onLoad: function () {
+        const query = {
+            q: 'https://www.cnd3b.com/qr?type=shop&fbrand=测试品牌名&tagentsid=34205'
+        };
+        /* const query = {} */
+        if (query.q) {
+            const q = decodeURIComponent(query.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
+                })
+            }
+        } else {
+            this.setData({
+                codeMsg: wx.getStorageSync('qrCodeMsg')
+            })
+        }
+    },
+    /* 确定 */
+    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: "合作申请成功",
+                            });
+                            if (wx.getStorageSync('qrCodeMsg')) wx.removeStorage('qrCodeMsg');
+                            setTimeout(() => {
+                                wx.switchTab({
+                                    url: '/pages/tabbar-pages/home/index',
+                                })
+                            }, 500)
+                        })
+                    }
+                })
+            })
+        } 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,
+                                "fphonenumber": wx.getStorageSync('userData').fphonenumber
+                            }
+                        }).then(res => {
+                            if (res.data != '成功') return wx.showToast({
+                                title: res.data,
+                                icon: "none"
+                            });
+                            wx.showToast({
+                                title: "申请成功",
+                            });
+                            if (wx.getStorageSync('qrCodeMsg')) wx.removeStorage('qrCodeMsg');
+                            setTimeout(() => {
+                                wx.switchTab({
+                                    url: '/pages/tabbar-pages/home/index',
+                                })
+                            }, 500)
+                        })
+                    }
+                })
+            })
+        }
+    },
+    /* 取消 */
+    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',
+                            })
+                            if (wx.getStorageSync('qrCodeMsg')) wx.removeStorage('qrCodeMsg');
+                        }, 500)
+                    }
+                })
+            })
+        } 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',
+                            })
+                            if (wx.getStorageSync('qrCodeMsg')) wx.removeStorage('qrCodeMsg');
+                        }, 500)
+                    }
+                })
+            })
+        }
+    },
+    /* 选择合作方式 */
+    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 () {
+
+    }
+})

+ 5 - 0
pages/login/QrCode.json

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

+ 29 - 0
pages/login/QrCode.wxml

@@ -0,0 +1,29 @@
+<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>

+ 56 - 0
pages/login/QrCode.wxss

@@ -0,0 +1,56 @@
+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;
+}

+ 4 - 1
pages/tabbar-pages/home/index.js

@@ -68,6 +68,9 @@ Page({
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
+        if (wx.getStorageSync('qrCodeMsg').type) return wx.navigateTo({
+            url: '/pages/login/QrCode',
+        });
         const that = this;
         /* 获取最新供需列表 */
         _Http.basic({
@@ -91,7 +94,7 @@ Page({
             });
             const data = handleList.getYTD(res.data);
             this.setData({
-                productList:data
+                productList: data
             })
         });
         /* 获取合作商家 */

+ 14 - 0
project.private.config.json

@@ -184,6 +184,20 @@
                     "name": "",
                     "pathName": "pages/teamManagement/applyFor",
                     "query": "",
+                    "launchMode": "default",
+                    "scene": null
+                },
+                {
+                    "name": "",
+                    "pathName": "pages/businessPartner/applyFor",
+                    "query": "",
+                    "launchMode": "default",
+                    "scene": null
+                },
+                {
+                    "name": "",
+                    "pathName": "pages/login/QrCode",
+                    "query": "",
                     "scene": null,
                     "launchMode": "default"
                 }