index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <view class="content" :style="{ height: heightCss}">
  3. <image class="logo" src="/static/bg-new.jpg" mode="widthFix"></image>
  4. <view class="getPhone-box" :style="{ bottom: bottomCss}">
  5. <button type="primary" class="custom-btn" open-type="getPhoneNumber"
  6. @getphonenumber="getPhoneNumber($event,'custom')" >观展登录</button>
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. var md5 = require("../../common/md5.js");
  12. export default {
  13. components: {
  14. },
  15. data() {
  16. return {
  17. title: 'Hello',
  18. pageInfo:{},
  19. isAuth:getApp().globalData.isAuth,
  20. isAuthPhone:getApp().globalData.user_phone,
  21. productList:[
  22. ],
  23. bottomCss:'-45px',
  24. marginTopCss:'0',
  25. heightCss:'auto',
  26. userInfoObj:{},
  27. // phoneHeight:'',
  28. }
  29. },
  30. onLoad() {
  31. this.getEquipmentHeight();
  32. uni.hideTabBar({})
  33. console.log('onload')
  34. // getApp().globalData.lastId = options.scene ? options.scene : getApp().globalData.user_id
  35. },
  36. onShow() {
  37. this.loginRequest();
  38. console.log('onshow')
  39. },
  40. onShareAppMessage() {
  41. return {
  42. title: '科尔卡诺展会入场登记',
  43. path:'/pages/index/index'
  44. }
  45. },
  46. methods: {
  47. getEquipmentHeight(){
  48. console.log('getHeight')
  49. let phoneHeight = uni.getSystemInfoSync().windowHeight;
  50. console.log(phoneHeight)
  51. this.bottomCss = phoneHeight > 640 ? '50px':'-45px';
  52. this.heightCss = phoneHeight > 640 ? '100%':'auto';
  53. if(phoneHeight > 720){
  54. this.bottomCss = '60px';
  55. }
  56. },
  57. getPhoneNumber(e,type){
  58. let that = this;
  59. console.log(type)
  60. if (e.detail.errMsg == 'getPhoneNumber:ok') { //允许授权执行跳转
  61. that.phoneRequest(e.detail.iv, e.detail.encryptedData, that.userInfoObj.session_key,type)
  62. } else { //
  63. uni.showToast({
  64. title: '您已拒绝授权登录',
  65. icon: 'none'
  66. });
  67. }
  68. },
  69. phoneRequest(myIv,myEncryptedData,sKey,type){
  70. let that = this;
  71. uni.request({
  72. url:getApp().globalData.shareUrl, //需要设置为全局
  73. method: 'POST',
  74. header: {
  75. 'content-type': 'application/x-www-form-urlencoded'
  76. },
  77. data: {
  78. method: 'auth',
  79. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  80. sign: md5('auth' + getApp().globalData.globalTimestamp),
  81. iv:myIv,
  82. session_key:sKey,
  83. encryptedData:myEncryptedData,
  84. },
  85. success: res => {
  86. // getApp().globalData.user_phone = res.data.phoneNumber;
  87. console.log(res)
  88. if(res.data.code === 200){
  89. getApp().globalData.userPhone = res.data.msg.phone;
  90. uni.navigateTo({
  91. url: '/pages/index/customPage/index',
  92. success: res => {},
  93. fail: () => {},
  94. complete: () => {},
  95. })
  96. }else {
  97. uni.showToast({
  98. title: res.data.msg,
  99. icon: 'none'
  100. });
  101. }
  102. }
  103. });
  104. },
  105. judgeUserType(type,pass){
  106. console.log(type,pass)
  107. switch (true){
  108. case type === 3: //需要授权
  109. console.log(type,pass)
  110. break;
  111. case type === 1 : //普通用户且允许入场
  112. uni.redirectTo({
  113. url: '/pages/index/successPage/index?types='+'custom', //游客成功页面
  114. success: res => {},
  115. fail: () => {},
  116. complete: () => {}
  117. })
  118. break;
  119. default:
  120. break;
  121. }
  122. },
  123. loginRequest(){
  124. let that = this;
  125. uni.login({
  126. success: (res) => {
  127. console.log(res.code)
  128. uni.request({
  129. url: getApp().globalData.shareUrl, //需要设置为全局
  130. method: 'POST',
  131. header: {
  132. 'content-type': 'application/x-www-form-urlencoded'
  133. },
  134. data: {
  135. method: 'login',
  136. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  137. code: res.code,
  138. sign: md5('login' + getApp().globalData.globalTimestamp)
  139. },
  140. success: res => {
  141. // 通过openid发起会员登录
  142. //type 1-普通客户 2-经销商客户 3-不存在需授权登录
  143. //pass 0-未知 1-允许入场 -1 - 禁止入场 ,
  144. if(res.data.code === 200){
  145. that.userInfoObj = res.data.msg;
  146. getApp().globalData.openId = that.userInfoObj.openid;
  147. getApp().globalData.userCodeNumber = that.userInfoObj.code;
  148. getApp().globalData.managerPhone = that.userInfoObj.qyjl_phone;
  149. getApp().globalData.managerName = that.userInfoObj.qyjl_name;
  150. getApp().globalData.addTime = that.userInfoObj.addtime;
  151. that.judgeUserType(that.userInfoObj.type,that.userInfoObj.pass)
  152. }else {
  153. uni.showToast({
  154. title: res.data.msg,
  155. icon: 'none'
  156. });
  157. }
  158. getApp().globalData.session_key = res.data.msg.session_key;
  159. }
  160. });
  161. }
  162. });
  163. },
  164. }
  165. }
  166. </script>
  167. <style lang="scss">
  168. .content {
  169. display: flex;
  170. flex-direction: column;
  171. align-items: center;
  172. justify-content: center;
  173. // height: 100%;
  174. background-image: linear-gradient(#000, #22272A);
  175. // background-image: url('/static/bg-home.jpg');
  176. // background-repeat: no-repeat;
  177. // background-size: 100% 100%;
  178. }
  179. .more-height{
  180. height: 100%!important;
  181. }
  182. /* #ifdef MP-WEIXIN */
  183. .relevance {
  184. width: 100%;
  185. // height: 10px;
  186. // position: absolute;
  187. // top: 0;
  188. z-index: 999;
  189. }
  190. /* #endif */
  191. .logo {
  192. // height: 100%!important;
  193. width: 100%;
  194. position: relative;
  195. // margin-top: 75px;
  196. }
  197. .getPhone-box {
  198. width: 100%;
  199. height: 200rpx;
  200. display: flex;
  201. justify-content: center;
  202. align-items: center;
  203. position: absolute;
  204. bottom: 20px;
  205. }
  206. .custom-btn {
  207. width: 230rpx;
  208. height: 80rpx;
  209. line-height:80rpx;
  210. color: #fff!important;
  211. background-color: rgb(136,143,137)!important;
  212. font-size: 30rpx!important;
  213. letter-spacing: 2rpx;
  214. margin: 0!important;
  215. padding: 0!important;
  216. }
  217. .dealer-btn {
  218. background-color: rgb(202,148,98)!important;
  219. }
  220. </style>