| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- <template>
- <view class="content" :style="{ height: heightCss}">
- <image class="logo" src="/static/bg-new.jpg" mode="widthFix"></image>
- <view class="getPhone-box" :style="{ bottom: bottomCss}">
- <button type="primary" class="custom-btn" open-type="getPhoneNumber"
- @getphonenumber="getPhoneNumber($event,'custom')" >观展登录</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:'-45px',
- marginTopCss:'0',
- heightCss:'auto',
- userInfoObj:{},
- // phoneHeight:'',
- }
- },
- onLoad() {
- this.getEquipmentHeight();
- uni.hideTabBar({})
- console.log('onload')
- // getApp().globalData.lastId = options.scene ? options.scene : getApp().globalData.user_id
- },
- onShow() {
- this.loginRequest();
- console.log('onshow')
- },
- onShareAppMessage() {
- return {
- title: '科尔卡诺展会入场登记',
- path:'/pages/index/index'
- }
- },
- methods: {
- getEquipmentHeight(){
- console.log('getHeight')
- let phoneHeight = uni.getSystemInfoSync().windowHeight;
- console.log(phoneHeight)
- this.bottomCss = phoneHeight > 640 ? '50px':'-45px';
- this.heightCss = phoneHeight > 640 ? '100%':'auto';
- if(phoneHeight > 720){
- this.bottomCss = '60px';
- }
- },
- 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;
- uni.navigateTo({
- url: '/pages/index/customPage/index',
- success: res => {},
- fail: () => {},
- complete: () => {},
- })
- }else {
- uni.showToast({
- title: res.data.msg,
- icon: 'none'
- });
- }
- }
- });
- },
- judgeUserType(type,pass){
- console.log(type,pass)
- switch (true){
- case type === 3: //需要授权
- console.log(type,pass)
- break;
- case type === 1 : //普通用户且允许入场
- uni.redirectTo({
- url: '/pages/index/successPage/index?types='+'custom', //游客成功页面
- success: res => {},
- fail: () => {},
- complete: () => {}
- })
- break;
- default:
- break;
- }
- },
- loginRequest(){
- let that = this;
- uni.login({
- success: (res) => {
- console.log(res.code)
- 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;
- getApp().globalData.addTime = that.userInfoObj.addtime;
- 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;
- // height: 100%;
- background-image: linear-gradient(#000, #22272A);
- // background-image: url('/static/bg-home.jpg');
- // background-repeat: no-repeat;
- // background-size: 100% 100%;
- }
- .more-height{
- height: 100%!important;
- }
- /* #ifdef MP-WEIXIN */
- .relevance {
- width: 100%;
- // height: 10px;
- // position: absolute;
- // top: 0;
- z-index: 999;
- }
- /* #endif */
- .logo {
- // height: 100%!important;
- width: 100%;
- position: relative;
- // margin-top: 75px;
- }
- .getPhone-box {
- width: 100%;
- height: 200rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- position: absolute;
- bottom: 20px;
- }
- .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>
|