| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- <template>
- <view class="content">
- <image class="logo" src="/static/bg-home.jpg" mode="widthFix"></image>
- <view class="getPhone-box" :style="{ bottom: bottomCss}">
- <button type="primary" class="custom-btn" open-type="getPhoneNumber" style="margin-right: 5%!important;"
- @getphonenumber="getPhoneNumber($event,'custom')" >观展登录</button>
- <button type="primary" class="custom-btn dealer-btn" open-type="getPhoneNumber"
- @getphonenumber="getPhoneNumber($event,'dealer')" >经销商登录</button>
- </view>
- </view>
- </template>
- <script>
- var md5 = require("../../common/md5.js");
- export default {
- components: {
- },
- data() {
- return {
- title: 'Hello',
- pageInfo:{},
- isAuth:getApp().globalData.isAuth,
- isAuthPhone:getApp().globalData.user_phone,
- productList:[
- ],
- bottomCss:'25%',
- userInfoObj:{},
- }
- },
- onLoad() {
- this.getEquipmentHeight();
- this.loginRequest();
- console.log('onload')
- // getApp().globalData.lastId = options.scene ? options.scene : getApp().globalData.user_id
- },
- onShow() {
- console.log('onshow')
- },
- onShareAppMessage() {
- return {
- title: '科尔卡诺展会入场登记',
- path:'/pages/index/index'
- }
- },
- methods: {
- getEquipmentHeight(){
- let phoneHeight = uni.getSystemInfoSync().windowHeight;
- console.log(phoneHeight)
- this.bottomCss = phoneHeight > 672 ? '35%':'25%';
- if(phoneHeight > 820){
- this.bottomCss = '40%';
- }
- },
- getPhoneNumber(e,type){
- let that = this;
- console.log(type)
- if (e.detail.errMsg == 'getPhoneNumber:ok') { //允许授权执行跳转
- that.phoneRequest(e.detail.iv, e.detail.encryptedData, that.userInfoObj.session_key,type)
- } else { //
- uni.showToast({
- title: '您已拒绝授权登录',
- icon: 'none'
- });
- }
- },
- phoneRequest(myIv,myEncryptedData,sKey,type){
- let that = this;
- uni.request({
- url:getApp().globalData.shareUrl, //需要设置为全局
- method: 'POST',
- header: {
- 'content-type': 'application/x-www-form-urlencoded'
- },
- data: {
- method: 'auth',
- timestamp: getApp().globalData.globalTimestamp, //Date.now()
- sign: md5('auth' + getApp().globalData.globalTimestamp),
- iv:myIv,
- session_key:sKey,
- encryptedData:myEncryptedData,
- },
- success: res => {
- // getApp().globalData.user_phone = res.data.phoneNumber;
- console.log(res)
- if(res.data.code === 200){
- getApp().globalData.userPhone = res.data.msg.phone;
- type === 'dealer' ? uni.navigateTo({
- url: '/pages/index/dealerPage/index',
- success: res => {},
- fail: () => {},
- complete: () => {}
- }) : uni.navigateTo({
- url: '/pages/index/customPage/index',
- success: res => {},
- fail: () => {},
- complete: () => {},
- })
- }else {
- uni.showToast({
- title: res.data.msg,
- icon: 'none'
- });
- }
- }
- });
- },
- judgeUserType(type,pass){
- switch (true){
- case type === 3: //需要授权
- console.log(type,pass)
- break;
- case type === 1 && pass === 1: //普通用户且允许入场
- uni.redirectTo({
- url: '/pages/index/successPage/index?types='+'custom', //游客成功页面
- success: res => {},
- fail: () => {},
- complete: () => {}
- })
- break;
- case type === 2 && pass === 1: //经销商用户且允许入场
- uni.redirectTo({
- url: '/pages/index/successPage/index?types='+'dealer', //经销商成功页面
- success: res => {},
- fail: () => {},
- complete: () => {}
- })
- break;
- case type === (1 || 2) && pass === -1: //禁止入场
- uni.redirectTo({
- url: '/pages/index/failPage/index', //失败页面
- success: res => {},
- fail: () => {},
- complete: () => {}
- });
- break;
- default:
- break;
- }
- },
- loginRequest(){
- let that = this;
- uni.login({
- success: (res) => {
- uni.request({
- url: getApp().globalData.shareUrl, //需要设置为全局
- method: 'POST',
- header: {
- 'content-type': 'application/x-www-form-urlencoded'
- },
- data: {
- method: 'login',
- timestamp: getApp().globalData.globalTimestamp, //Date.now()
- code: res.code,
- sign: md5('login' + getApp().globalData.globalTimestamp)
- },
- success: res => {
- // 通过openid发起会员登录
- //type 1-普通客户 2-经销商客户 3-不存在需授权登录
- //pass 0-未知 1-允许入场 -1 - 禁止入场 ,
- if(res.data.code === 200){
- that.userInfoObj = res.data.msg;
- getApp().globalData.openId = that.userInfoObj.openid;
- getApp().globalData.userCodeNumber = that.userInfoObj.code;
- getApp().globalData.managerPhone = that.userInfoObj.qyjl_phone;
- getApp().globalData.managerName = that.userInfoObj.qyjl_name;
- that.judgeUserType(that.userInfoObj.type,that.userInfoObj.pass)
- }else {
- uni.showToast({
- title: res.data.msg,
- icon: 'none'
- });
- }
- // getApp().globalData.session_key = res.data.msg.session_key;
- }
- });
- }
- });
- },
- }
- }
- </script>
- <style lang="scss">
- .content {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- // background-image: url('/static/bg-home.jpg');
- // background-repeat: no-repeat;
- // background-size: 100% 100%;
- }
- .logo {
- width: 100%;
- position: relative;
- }
- .getPhone-box {
- width: 100%;
- height: 200rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- position: absolute;
- bottom: 25%;
- }
- .custom-btn {
- width: 230rpx;
- height: 80rpx;
- line-height:80rpx;
- color: #fff!important;
- background-color: rgb(136,143,137)!important;
- font-size: 30rpx!important;
- letter-spacing: 2rpx;
- margin: 0!important;
- padding: 0!important;
- }
- .dealer-btn {
- background-color: rgb(202,148,98)!important;
- }
- </style>
|