diff --git a/app.json b/app.json index 38f0062..19ee4a2 100644 --- a/app.json +++ b/app.json @@ -29,7 +29,8 @@ "pages/team/team_ping/team_ping", "pages/cart/cart2_pt/cart2_pt", "pages/cart/cart_wk/cart_wk", - + "pages/qy/contactMe/contactMe", + "pages/user/userqy/userqy", "pages/user/user_spsy/user_spsy", diff --git a/pages/qy/contactMe/contactMe.js b/pages/qy/contactMe/contactMe.js new file mode 100644 index 0000000..d034b14 --- /dev/null +++ b/pages/qy/contactMe/contactMe.js @@ -0,0 +1,486 @@ +var t = require("../../../utils/common.js"); +const app = getApp(); +var os = app.globalData.setting; +var regeneratorRuntime = require('../../../utils/runtime.js'); + +Page({ + data: { + user: null, + show_bind: 0, + imghots: os.imghost, + store_logo: '', + first_leader: '', //-- 邀请人 -- + config2: null, + sub: 0, + phone:'', + id:"", + }, + onLoad: function (tt) { + // tt.scene="0_0_14" + if (tt && tt.scene) { + var first_leader_str = decodeURIComponent(tt.scene); + var f_arr = first_leader_str.split("_"); + // first_leader = f_arr[0] && parseFloat(f_arr[0]) > 0 ? f_arr[0] : null; + //注册门店 + // if (f_arr[1] && parseFloat(f_arr[1]) > 0) { + // getApp().globalData.store_number = f_arr[1]; + // } + //企业微信群id + if (f_arr && f_arr[2] && parseFloat(f_arr[2]) > 0) { + this.setData({ + id:f_arr[2] + }) + // this.getopenuserid(f_arr[2]) + // getApp().globalData.groupchat_id = f_arr[2]; + } + + } + // if (wx.getUserProfile) { + // this.setData({ + // canIUseGetUserProfile: true + // }) + // } + // getApp().globalData.isLoad_ad = 1; + //--判断是否有接受到邀请人的ID-- + // if (options.first_leader) { + // this.setData({ first_leader: options.first_leader }); + // } else if (getApp().globalData.first_leader) { + // this.setData({ first_leader: getApp().globalData.first_leader }); + // } + var th = this; + app.getConfig(function (e) { + var logo = th.data.imghots + e.store_logo; + th.setData({ store: e, store_logo: logo }); + }) + + //判断注册的条件 + // app.getConfig2(function (e) { + // if (e.reg_type == 1) { + // var arr = JSON.parse(e.reg_info); + // if (arr['name_state'] == 1) th.data.name_need_go = 1; + // if (arr['birthday_state'] == 1) th.data.birth_need_go = 1; + // if (arr['idcard_state'] == 1) th.data.idcard_need_go = 1; + // if (arr['address_state'] == 1) th.data.address_need_go = 1; + // if (arr['pick_state'] == 1) th.data.pick_need_go = 1; + // if (arr['sex_state'] == 1) th.data.sex_need_go = 1; + // if (arr['introducer_state'] == 1) th.data.introducer_need_go = 1; + // } + // var json_d = JSON.parse(e.switch_list); + // if (json_d.user_label_set == 1) { + // th.data.is_lable_set = 1 + // } + // }, 1) + + // getApp().promiseGet("/api/wx/weappSendlist/page", { + // data: { + // store_id: os.stoid, + // typeid: "1007" + // } + // }).then(res => { + // if (res.data.code == 0 && res.data.data.pageData.length > 0) { + // var template_id = res.data.data.pageData[0].template_id; + // th.setData({ template_id: template_id }); + // } + // }) + }, + + getopenuserid(id){ + getApp().request.promiseGet("/api/weshop/qyWeChat/qywxStaffcode", { data: {id} }).then(res => { + console.log(res); + if (res.data.code == 0) { + let resdata=JSON.parse(res.data.data); + + } + }) + }, + + //绑定手机号 + getphone: function (e) { + //接下来写业务代码登录 + console.log(e); + // return + e = e.detail; + if (e.code == undefined) { + this.setData({ show_bind: 0 }) + return app.my_warnning("登录需要授权手机号码!", 0, this); + return false; + } + // var sessionKey = getApp().globalData.sessionKey; + var req_data = { + js_code: e.code, + store_id: getApp().globalData.setting.stoid, + } + //-- 获取一下手机 --/api/weshop/users/getCodeMobile?store_id=1&js_code=b8451556dd98b2eebec5aa6775625bce192a68fc1a4b15b0c6bf3ed046f90da4 + getApp().request.promiseGet("/api/weshop/users/getCodeMobile", { data: req_data }).then(res => { + // console.log('手机号码'); + // console.log(res); + if (res.data.code == 0) { + let resdata=JSON.parse(res.data.data); + this.setData({ + phone:resdata.phoneNumber + }) + // getApp().globalData.zc_dd = dd; + // wx.redirectTo({ + // url: "/packageA/pages/profile/profile?is_back=1" + // }) + } + }) + + // var sessionKey = getApp().globalData.sessionKey; + // var openid = getApp().globalData.openid; + // var r = getApp().globalData.getu; + // this.save_the_data(r, e, sessionKey, openid) + }, + + + //-- 会员授权 -- + bindGetUserInfo: function (ee) { + if (!this.data.isAgree) { + wx.showToast({ + title: '请您先阅读和勾选指定的内容', + icon: 'none', + }); + return false; + } + var that = this; + //-- 点击授权 -- + that.getUserProfile(function (res) { + var user = res; + //--拿下code-- + wx.login({ + success: function (o) { + var dd = { + js_code: o.code, + store_id: os.stoid, + nickname: app.clear_word(app.globalData.getu.nickName), + head_pic: app.clear_word(app.globalData.getu.avatarUrl) + }; + //-- 导购会员ID -- + if (getApp().globalData.guide_id) { + dd.guide_id = getApp().globalData.guide_id; + } + + getApp().request.get("/api/weshop/users/openidandkey", { + data: dd, + success: function (e) { + if (e.data.code == 0) { + that.setData({ user: user }) + //如果有会员的话,没有sessionKey + if (!e.data.data.sessionKey) { + // getApp().showWarning("登录成功"); + wx.showToast({ + title: '登录成功', + icon: 'success', + duration: 2000 + }); + getApp().globalData.userInfo = e.data.data; + getApp().globalData.user_id = e.data.data.user_id; + getApp().globalData.openid = e.data.data.weapp_openid; + //把会员的信息存在内存 + wx.setStorageSync("userinfo", e.data.data); + + //调用接口判断是不是会员 + app.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + e.data.data.user_id, {}).then(res => { + if (res.data.code == 0) { + getApp().globalData.guide_id = res.data.data.id; + } + }) + + + setTimeout(function () { + getApp().globalData.login_back = 1; + wx.navigateBack({ delta: 1 }) //返回上一页 + }, 1000) + } else { + getApp().globalData.sessionKey = e.data.data.sessionKey; + getApp().globalData.openid = e.data.data.openid; + that.setData({ show_bind: 1 }); + } + } else { + getApp().confirmBox(e.data.msg); + } + } + }); + } + }) + + }) + }, + + //-- 调整后的获取会员信息 -- + getUserProfile: function (func) { + var that = this; + wx.getUserProfile({ + desc: '获取用户相关信息', + success: res => { + console.log("getUserProfile", res); + //此处授权得到userInfo + getApp().globalData.getu = res.userInfo; + func(res.userInfo); + } + }); + }, + + //暂不登录,返回上一页 + cancle_bind: function () { + wx.navigateBack({ delta: 1 }) + }, + + close_pop: function () { + this.setData({ show_bind: 0 }) + }, + show_bind_mobile: function () { + let th = this; + th.sendsm(function () { + th.setData({ show_bind: 1 }) + }) + }, + + + save_the_data: async function (r, e, sessionKey, openid) { + var app = getApp(), a = app, th = this; + var dd = { + oauth: "miniapp", + nickname: a.clear_word(r.nickName), + head_pic: r.avatarUrl, + sex: r.gender, + terminal: "miniapp", + sessionKey: sessionKey, + openid: openid, + encryptedData: e.encryptedData, + iv: e.iv, + store_id: getApp().globalData.setting.stoid, + }; + //--如果有邀请人的时候-- + if (th.data.first_leader) { + dd.first_leader = th.data.first_leader; + } + //-- 导购会员ID -- + if (getApp().globalData.guide_id) { + dd.guide_id = getApp().globalData.guide_id; + } + + //门店的扫描识别码 + if (getApp().globalData.store_number) { + dd.SunCode = encodeURIComponent(getApp().globalData.store_number.trim()); + } + + console.log("-----会员注册的信息-------"); + console.log(dd); + + + var need_go = 0; + //如果有需要完善的信息没有完善,就需要跳转 + if (th.data.name_need_go) { need_go = 1; } + if (th.data.birth_need_go) { need_go = 1; } + if (th.data.idcard_need_go) { need_go = 1; } + if (th.data.address_need_go) { need_go = 1; } + if (th.data.pick_need_go) { need_go = 1; } + if (th.data.sex_need_go) { need_go = 1; } + if (th.data.introducer_need_go) { need_go = 1; } + + if (need_go) { + + var req_data = { + sessionKey: sessionKey, + encryptedData: e.encryptedData, + iv: e.iv, + store_id: getApp().globalData.setting.stoid, + } + //-- 获取一下手机 -- + getApp().request.promiseGet("/api/weshop/users/getmobile", { data: req_data }).then(res => { + if (res.data.code == 0) { + dd.mobile = res.data.data; + getApp().globalData.zc_dd = dd; + wx.redirectTo({ + url: "/packageA/pages/profile/profile?is_back=1" + }) + } + }) + + } else { + if (th.data.is_lable_set) { + var req_data = { + sessionKey: sessionKey, + encryptedData: e.encryptedData, + iv: e.iv, + store_id: getApp().globalData.setting.stoid, + } + //-- 获取一下手机 -- + getApp().request.promiseGet("/api/weshop/users/getmobile", { data: req_data }).then(res => { + if (res.data.code == 0) { + dd.mobile = res.data.data; + getApp().globalData.zc_dd = dd; + wx.redirectTo({ + url: "/packageE/pages/user/labels/labels?pageType=1" + }) + } + }) + } else { + this.setData({ sub: 1 }); + wx.showLoading({ + title: '处理中.', + mask: true + }) + this.zu_ce(dd); //调用注册的函数 + } + } + + }, + + zu_ce: function (dd) { + var th = this; + app.request.get("/api/weshop/users/thirdLogin", { + data: dd, + success: function (e) { + if (e.data.code == 0) { + app.globalData.user_id = e.data.data.user_id; + } else { + return app.showWarning("授权登入失败!" + e.data.msg); + } + getApp().globalData.login_back = 1; + wx.setStorageSync("userinfo", e.data.data); + wx.setStorageSync("isAuth", !0), app.globalData.userInfo = e.data.data, app.globalData.userInfo.head_pic = t.getFullUrl(app.globalData.userInfo.head_pic); + //调用接口判断是不是会员 + app.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + e.data.data.user_id, {}).then(res => { + if (res.data.code == 0) { + getApp().globalData.guide_id = res.data.data.id; + } + }) + + }, + failStatus: function (t) { + th.setData({ sub: 0 }); + return app.my_warnning("授权登入失败,请稍后再试!", 0, th); + }, + fail: function (t) { + th.setData({ sub: 0 }); + return i.clearAuth(), i.alertLoginErrorAndGoHome(), !1; + } + }); + }, + + + bind_bnerr: function (e) { + var _errImg = e.target.dataset.errorimg; + var _errObj = {}; + _errObj[_errImg] = this.data.imghots + "/miniapp/images/logo.png"; + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; + }, + + //-- 会员授权 -- + bindUserInfo: function (ee) { + var that = this; + var user = ee.detail.userInfo; + //此处授权得到userInfo + getApp().globalData.getu = user; + + //--拿下code-- + wx.login({ + success: function (o) { + var dd = { + js_code: o.code, + store_id: os.stoid, + nickname: app.clear_word(app.globalData.getu.nickName), + head_pic: app.clear_word(app.globalData.getu.avatarUrl) + }; + //-- 导购会员ID -- + if (getApp().globalData.guide_id) { + dd.guide_id = getApp().globalData.guide_id; + } + + getApp().request.get("/api/weshop/users/openidandkey", { + data: dd, + success: function (e) { + if (e.data.code == 0) { + that.setData({ user: user }) + //如果有会员的话,没有sessionKey + if (!e.data.data.sessionKey) { + // getApp().showWarning("登录成功"); + wx.showToast({ + title: '登录成功', + icon: 'success', + duration: 2000 + }); + + getApp().globalData.userInfo = e.data.data; + getApp().globalData.user_id = e.data.data.user_id; + getApp().globalData.openid = e.data.data.weapp_openid; + //把会员的信息存在内存 + wx.setStorageSync("userinfo", e.data.data); + + //调用接口判断是不是会员 + app.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + e.data.data.user_id, {}).then(res => { + if (res.data.code == 0) { + getApp().globalData.guide_id = res.data.data.id; + } + }) + + + setTimeout(function () { + getApp().globalData.login_back = 1; + wx.navigateBack({ delta: 1 }) //返回上一页 + }, 1000) + } else { + getApp().globalData.sessionKey = e.data.data.sessionKey; + getApp().globalData.openid = e.data.data.openid; + that.setData({ show_bind: 1 }); + } + } else { + getApp().confirmBox(e.data.msg); + } + } + }); + } + }) + + + }, + + + close_pop_back: function () { + this.close_pop(); + wx.navigateBack({ delta: 1 }) + }, + + + // 是否同意协议 + isAgree(e) { + let isAgree = null; + if (e.detail.value[0]) { + isAgree = true; + } else { + isAgree = false; + }; + // this.data.isAgree = isAgree; + this.setData({ + isAgree, + }); + }, + + + //通过路径跳转到其他页面 + goto: function (e) { + console.log('xxxx', e); + var url = e.currentTarget.dataset.url; + getApp().goto(url); + }, + + //订阅消息提醒 + sendsm: function (func) { + var template_id = this.data.template_id; + // //授权订阅 + wx.requestSubscribeMessage({ + tmplIds: [template_id], + success(res) { + func(); + }, + fail(res) { + func(); + } + }) + + }, + + +}) diff --git a/pages/qy/contactMe/contactMe.json b/pages/qy/contactMe/contactMe.json new file mode 100644 index 0000000..3f01b7c --- /dev/null +++ b/pages/qy/contactMe/contactMe.json @@ -0,0 +1,7 @@ +{ + "usingComponents": { + "warn": "/components/long_warn/long_warn" + }, + "navigationBarTitleText": "联系我", + "enablePullDownRefresh": false +} \ No newline at end of file diff --git a/pages/qy/contactMe/contactMe.wxml b/pages/qy/contactMe/contactMe.wxml new file mode 100644 index 0000000..a6ad5bc --- /dev/null +++ b/pages/qy/contactMe/contactMe.wxml @@ -0,0 +1,80 @@ + + + + + + + + + {{store.store_name}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 长按识别二维码 + 添加我是企业微信 + + + + + diff --git a/pages/qy/contactMe/contactMe.wxss b/pages/qy/contactMe/contactMe.wxss new file mode 100644 index 0000000..ebb9fb7 --- /dev/null +++ b/pages/qy/contactMe/contactMe.wxss @@ -0,0 +1,87 @@ +page{ + border-top: 3rpx solid #EAEAEC; + background-color: #fff; +} +.logins { + width: 100%; + /* padding-bottom: 130rpx; */ + background-position: center; + background-repeat: no-repeat; + background-size: cover +} + +.login_img { + width: 192rpx; + height: 192rpx; + border-radius: 50%; +} +.phones{ + margin-bottom: 48rpx; +} +.getPhoneNumber { + width: 600rpx; + height: 94rpx; + line-height: 94rpx; + background-color: #57b837; + border-radius: 48rpx; + color: rgb(255,255,255); + font-size: 32rpx; + margin-top: 40rpx; +} +.we_chat{ + width: 55rpx; + height: 45rpx; + margin-right: 15rpx; +} +.userlongin{ + color: #767f8e; +} +button{ + border:none; +} +.login_img_back{ width: 100%;} +.p_content{ + margin: 10%; + width: 80%; + height:340rpx; + top:50%; + margin-top: -180rpx; + background-color: #fff; + z-index: 12; + position: fixed; +} + +.btn_view { height: 120rpx; line-height: 120rpx; border-top:1rpx solid #e9e9e9;} +.p_title{ height:220rpx; padding: 0 40rpx; line-height: 50rpx;} +.g_mobile{ background: none;line-height: normal;} +.b_right{border-right:1rpx solid #e9e9e9;} + +.ali-c{align-items: center;} +.flex-center2{ justify-content: center;} +.f2 { + flex: 2 0; +} + +.middle_view{ + position: absolute; left: 0; width: 100%; text-align: center; +} + +/*checkbox 选项框大小 */ +checkbox .wx-checkbox-input { + width: 30rpx; + height: 30rpx; +} + +.gray { + color: #767f8e; +} + +.meBox{ + color: rgb(127, 128, 132); + font-size: 50rpx; + height: 100vh; + display: flex; + align-items: center; + flex-direction: column; + justify-content: center; +} \ No newline at end of file