login.vue 5.4 KB

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