login.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='创衡汇教练AI智能体' :showback="false"></cus-header>
  4. <div class="content">
  5. <image src="@/static/logo2.png" mode="heightFix"></image>
  6. <div class="title">Hi,我是企业教练~</div>
  7. <div class="tip">很高兴遇见你!作为你的AI教练,我随时可以回答您的问题</div>
  8. <div class="item adf">
  9. <image src="@/static/qa.png"></image>
  10. <div class="qa">
  11. <p>智能问答</p>
  12. <p>正念修己 教练达人,知识推理整合,要点清晰呈现,助力企业打造高价值团队</p>
  13. </div>
  14. </div>
  15. <div class="item adf">
  16. <image src="@/static/qs.png"></image>
  17. <div class="qa">
  18. <p>PERILL模型问题库</p>
  19. <p>作为团队成员,您可以对所在团队相关描述的体验进行评分,帮助团队有效评估团队的现状</p>
  20. </div>
  21. </div>
  22. <button class="zt_btn" open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber">手机号一键登录</button>
  23. <button class="zt_btn" style="margin-top: 20rpx;" @tap="codeLogin">授权码登录</button>
  24. <div class="qx_btn" @click="cancelLogin">取消登录</div>
  25. </div>
  26. <u-popup :show="show" @close="cancel" mode="center" :round="20">
  27. <div class="code">
  28. <p>授权码登录</p>
  29. <u-input v-model="phone" placeholder="请输入手机号"></u-input>
  30. <div style="margin-top: 20rpx;"></div>
  31. <u-input v-model="code" placeholder="请输入授权码"></u-input>
  32. <div class="cbtns adfacjb">
  33. <div class="zt_btn" @tap="toCodeLogin">登录</div>
  34. <div class="qx_btn" @tap="cancel">取消</div>
  35. </div>
  36. </div>
  37. </u-popup>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data(){
  43. return {
  44. show:false,
  45. phone:'',
  46. code:''
  47. }
  48. },
  49. methods:{
  50. decryptPhoneNumber(e){
  51. if(uni.getStorageSync('token')){
  52. uni.reLaunch({
  53. url:'/pages/home'
  54. })
  55. return
  56. }
  57. if(e.detail.code) this.wxLogin(e.detail.code);
  58. },
  59. codeLogin(){
  60. this.show = true;
  61. },
  62. toCodeLogin(){
  63. if(!this.$reg.mobile(this.phone)) return this.$showToast('请输入正确的手机号!')
  64. if(!this.code) return this.$showToast('请输入授权码!')
  65. this.$api.get('/wx/login-code',{
  66. checkCode:this.code,
  67. phone:this.phone
  68. }).then(res=>{
  69. if(res.data.code!==0) return this.$showToast(res.data.msg)
  70. this.loginSuccessFn(res);
  71. })
  72. },
  73. cancel(){
  74. this.code = '';
  75. this.show = false;
  76. },
  77. wxLogin(code){
  78. uni.showLoading({ title:'登录中' });
  79. let that = this;
  80. wx.login({
  81. success(res){
  82. that.$api.get('/wx/login',{
  83. code:res.code,
  84. phoneCode:code
  85. },false).then(res=>{
  86. if(res.data.code===0){
  87. that.loginSuccessFn(res);
  88. }else that.$showToast(res.data.msg)
  89. })
  90. }
  91. })
  92. },
  93. loginSuccessFn(res){
  94. uni.setStorageSync('token',res.data.data.token);
  95. uni.setStorageSync('userInfo',JSON.stringify({
  96. id:res.data.data.id,
  97. gender:res.data.data.gender,
  98. realName:res.data.data.realName,
  99. mobile:res.data.data.mobile,
  100. headUrl:res.data.data.headUrl,
  101. teamId:res.data.data.teamId,
  102. enterpriseId:res.data.data.enterpriseId,
  103. enterpriseName:res.data.data.enterpriseName,
  104. teamName:res.data.data.teamName
  105. }));
  106. uni.hideLoading();
  107. this.$showToast('登录成功');
  108. setTimeout(()=>{
  109. uni.reLaunch({ url:'/pages/home' })
  110. },1500)
  111. },
  112. cancelLogin(){
  113. // uni.exitMiniProgram();
  114. uni.reLaunch({ url:'/pages/home' })
  115. }
  116. }
  117. }
  118. </script>
  119. <style scoped lang="scss">
  120. .page{
  121. background: #FFFFFF;
  122. display: flex;
  123. flex-direction: column;
  124. box-sizing: border-box;
  125. .content{
  126. padding: 0 45rpx;
  127. flex: 1;
  128. overflow-y: auto;
  129. &>image{
  130. height: 88rpx;
  131. margin-top: 100rpx;
  132. }
  133. .title{
  134. font-family: PingFang-SC, PingFang-SC;
  135. font-weight: bold;
  136. font-size: 48rpx;
  137. color: #252525;
  138. line-height: 67rpx;
  139. margin-top: 36rpx;
  140. }
  141. .tip{
  142. font-family: PingFangSC, PingFang SC;
  143. font-weight: 400;
  144. font-size: 30rpx;
  145. color: #646464;
  146. line-height: 47rpx;
  147. margin-top: 20rpx;
  148. }
  149. .item{
  150. margin-top: 64rpx;
  151. &>image{
  152. width: 64rpx;
  153. height: 64rpx;
  154. }
  155. .qa{
  156. width: calc(100% - 64rpx);
  157. padding-left: 24rpx;
  158. box-sizing: border-box;
  159. p{
  160. font-family: PingFang-SC, PingFang-SC;
  161. font-weight: bold;
  162. font-size: 32rpx;
  163. color: #252525;
  164. line-height: 45rpx;
  165. &:last-child{
  166. font-weight: 400;
  167. font-size: 28rpx;
  168. color: #646464;
  169. line-height: 47rpx;
  170. }
  171. }
  172. }
  173. }
  174. .zt_btn{
  175. margin-top: 176rpx;
  176. }
  177. .qx_btn{
  178. margin-top: 36rpx;
  179. }
  180. }
  181. }
  182. .code{
  183. width: 700rpx;
  184. padding: 40rpx 60rpx 40rpx;
  185. border-radius: 32rpx 32rpx 0 0;
  186. box-sizing: border-box;
  187. p{
  188. font-size: 40rpx;
  189. font-weight: bold;
  190. margin-bottom: 50rpx;
  191. }
  192. .cbtns{
  193. margin-top: 50rpx;
  194. &>div{
  195. width: calc(50% - 20rpx);
  196. }
  197. .qx_btn{
  198. background: #f1f1f1;
  199. }
  200. }
  201. }
  202. </style>