|
@@ -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 () {
|
|
|
+
|
|
|
+ }
|
|
|
+})
|