login.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <template>
  2. <view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='创衡汇教练AI智能体' bgColor="transparent" backUrl="/pages/home"></cus-header>
  4. <image class="topbg" :src="imgBase+'login_top_bg.png'"></image>
  5. <view class="content">
  6. <view class="c_top">
  7. <image :src="imgBase+'logo.png'" mode="heightFix"></image>
  8. <view class="title">Hi,我是创衡团队教练助手</view>
  9. <view class="tip">我能为你提供PERILL团队发展动态评估、报告分析和团队教练督导对话,期待和你的共创~</view>
  10. <view class="item adf">
  11. <view class="qa">
  12. <p>PERILL团队发展动态评估</p>
  13. <p>基于你对相关陈述的评分,从六个关键维度客观呈现团队现状。</p>
  14. </view>
  15. </view>
  16. <view class="item adf">
  17. <view class="qa">
  18. <p>AI教练督导对话</p>
  19. <p>保持正念教练督导心态,对你的PERILL团队发展动态评估或团队教练计划进行启发式沟通。</p>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="c_bottom">
  24. <button class="zt_btn" open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber">手机号一键登录</button>
  25. <view class="qx_btn" style="margin-top: 40rpx;" @tap="codeLogin" v-if="!channelType">授权码登录</view>
  26. <view class="agree adfacjc" @click.prevent="changeAgree">
  27. <image :src="imgBase+'not_select.png'" v-if="!agree"></image>
  28. <image :src="imgBase+'selected.png'" v-else></image>
  29. <view class="text">已阅读并同意我们的<span @click.stop="turnPage('/pagesMy/serviceAgreement')">“服务协议”</span>与<span @click.stop="turnPage('/pagesMy/privacyPolicy')">“隐私政策”</span></view>
  30. </view>
  31. </view>
  32. </view>
  33. <u-popup :show="show" @close="cancel" mode="center" :round="20">
  34. <view class="code">
  35. <p>授权码登录</p>
  36. <u-input v-model="phone" placeholder="请输入手机号"></u-input>
  37. <view style="margin-top: 20rpx;"></view>
  38. <u-input v-model="code" placeholder="请输入授权码"></u-input>
  39. <view class="cbtns adfacjb">
  40. <view class="zt_btn" @tap="toCodeLogin">登录</view>
  41. <view class="qx_btn" @tap="cancel">取消</view>
  42. </view>
  43. </view>
  44. </u-popup>
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. data(){
  50. return {
  51. show:false,
  52. phone:'',
  53. code:'',
  54. agree:false,
  55. channelType:''
  56. }
  57. },
  58. created() {
  59. if(uni.getStorageSync('channelType')) this.channelType = uni.getStorageSync('channelType')
  60. },
  61. methods:{
  62. decryptPhoneNumber(e){
  63. if(!this.agree) return this.$showToast('请勾选协议与政策')
  64. if(uni.getStorageSync('token')){
  65. uni.reLaunch({
  66. url:'/pages/home'
  67. })
  68. return
  69. }
  70. if(e.detail.code) this.wxLogin(e.detail.code);
  71. },
  72. codeLogin(){
  73. if(!this.agree) return this.$showToast('请勾选协议与政策')
  74. this.show = true;
  75. },
  76. toCodeLogin(){
  77. if(!this.$reg.mobile(this.phone)) return this.$showToast('请输入正确的手机号!')
  78. if(!this.code) return this.$showToast('请输入授权码!')
  79. this.$api.get('/wx/login-code',{
  80. checkCode:this.code,
  81. phone:this.phone
  82. }).then(res=>{
  83. if(res.data.code!==0) return this.$showToast(res.data.msg)
  84. this.loginSuccessFn(res);
  85. })
  86. },
  87. cancel(){
  88. this.code = '';
  89. this.show = false;
  90. },
  91. wxLogin(code){
  92. uni.showLoading({ title:'登录中' });
  93. let that = this;
  94. wx.login({
  95. success(res){
  96. that.$api.get('/wx/login',{
  97. code:res.code,
  98. phoneCode:code,
  99. // channelType:that.channelType,
  100. channelType:'Questionnaire',
  101. teamQuestionnaireId:'1993157045939318785',
  102. referrerId:'1986308756413480961',
  103. },false).then(res=>{
  104. if(res.data.code===0){
  105. if(res.data.data.isRegister==1){
  106. if(uni.getStorageSync('newUser')) uni.removeStorageSync('newUser')
  107. that.loginSuccessFn(res);
  108. } else{
  109. uni.setStorageSync('newUser',true)
  110. uni.navigateTo({
  111. url:'/pages/registerInfo?params='+encodeURIComponent(JSON.stringify({
  112. info:{
  113. channelType:that.channelType,
  114. mobile:res.data.data.mobile||'',
  115. isRegister:res.data.data.isRegister,
  116. referrerId:res.data.data.referrerId||'',
  117. teamQuestionnaireId:res.data.data.teamQuestionnaireId||'',
  118. userId:res.data.data.id||'',
  119. openId:res.data.data.openId||'',
  120. },
  121. user:{
  122. token:res.data.data.token,
  123. openId:res.data.data.openId,
  124. id:res.data.data.id,
  125. gender:res.data.data.gender,
  126. realName:res.data.data.realName,
  127. mobile:res.data.data.mobile,
  128. headUrl:res.data.data.headUrl,
  129. teamId:res.data.data.teamId,
  130. enterpriseId:res.data.data.enterpriseId,
  131. enterpriseName:res.data.data.enterpriseName,
  132. teamName:res.data.data.teamName,
  133. referrerId:res.data.data.referrerId,
  134. teamQuestionnaireId:res.data.data.teamQuestionnaireId,
  135. isRegister:res.data.data.isRegister
  136. }
  137. }))
  138. })
  139. }
  140. }else that.$showToast(res.data.msg)
  141. })
  142. }
  143. })
  144. },
  145. loginSuccessFn(res){
  146. uni.setStorageSync('token',res.data.data.token);
  147. uni.setStorageSync('userInfo',JSON.stringify({
  148. id:res.data.data.id,
  149. openId:res.data.data.openId,
  150. gender:res.data.data.gender,
  151. realName:res.data.data.realName,
  152. mobile:res.data.data.mobile,
  153. headUrl:res.data.data.headUrl,
  154. teamId:res.data.data.teamId,
  155. enterpriseId:res.data.data.enterpriseId,
  156. enterpriseName:res.data.data.enterpriseName,
  157. teamName:res.data.data.teamName,
  158. referrerId:res.data.data.referrerId,
  159. teamQuestionnaireId:res.data.data.teamQuestionnaireId,
  160. isRegister:res.data.data.isRegister
  161. }));
  162. uni.hideLoading();
  163. this.$showToast('登录成功');
  164. setTimeout(()=>{
  165. uni.reLaunch({ url:'/pages/home' })
  166. },1500)
  167. },
  168. changeAgree(){
  169. this.agree = !this.agree
  170. },
  171. turnPage(url){
  172. uni.navigateTo({
  173. url
  174. })
  175. },
  176. }
  177. }
  178. </script>
  179. <style scoped lang="scss">
  180. .page{
  181. background: #FFFFFF;
  182. display: flex;
  183. flex-direction: column;
  184. box-sizing: border-box;
  185. .topbg{
  186. width: 100%;
  187. height: 584rpx;
  188. position: fixed;
  189. top: 0;
  190. left: 0;
  191. }
  192. .content{
  193. padding: 0 45rpx;
  194. flex: 1;
  195. overflow-y: auto;
  196. display: flex;
  197. flex-direction: column;
  198. justify-content: space-between;
  199. position: relative;
  200. .c_top{
  201. padding: 0 20rpx;
  202. &>image{
  203. height: 88rpx;
  204. margin-top: 76rpx;
  205. }
  206. .title{
  207. font-family: PingFang-SC, PingFang-SC;
  208. font-weight: bold;
  209. font-size: 48rpx;
  210. color: #002846;
  211. line-height: 67rpx;
  212. margin-top: 36rpx;
  213. }
  214. .tip{
  215. font-family: PingFangSC, PingFang SC;
  216. font-weight: 400;
  217. font-size: 30rpx;
  218. color: #667E90;
  219. line-height: 47rpx;
  220. margin-top: 20rpx;
  221. }
  222. .item{
  223. margin-top: 64rpx;
  224. .qa{
  225. box-sizing: border-box;
  226. p{
  227. font-family: PingFang-SC, PingFang-SC;
  228. font-weight: bold;
  229. font-size: 32rpx;
  230. color: #252525;
  231. line-height: 45rpx;
  232. &:last-child{
  233. font-weight: 400;
  234. font-size: 28rpx;
  235. color: #646464;
  236. line-height: 47rpx;
  237. }
  238. }
  239. }
  240. }
  241. }
  242. .c_bottom{
  243. .qx_btn{
  244. margin-top: 36rpx;
  245. }
  246. .agree{
  247. margin-top: 64rpx;
  248. image{
  249. width: 30rpx;
  250. height: 30rpx;
  251. }
  252. .text{
  253. margin-left: 8rpx;
  254. font-family: PingFangSC, PingFang SC;
  255. font-weight: 400;
  256. font-size: 24rpx;
  257. color: #95A5B1;
  258. line-height: 44rpx;
  259. span{
  260. color: #002846;
  261. }
  262. }
  263. }
  264. }
  265. }
  266. }
  267. .code{
  268. width: 700rpx;
  269. padding: 40rpx 60rpx 40rpx;
  270. border-radius: 32rpx 32rpx 0 0;
  271. box-sizing: border-box;
  272. p{
  273. font-size: 40rpx;
  274. font-weight: bold;
  275. margin-bottom: 50rpx;
  276. }
  277. .cbtns{
  278. margin-top: 50rpx;
  279. &>view{
  280. width: calc(50% - 20rpx);
  281. }
  282. .qx_btn{
  283. background: #f1f1f1;
  284. }
  285. }
  286. }
  287. </style>