register.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view>
  3. <view class="regbox">
  4. <view class="flex1">
  5. <image :src="headimg" class="headimg"></image>
  6. <image :src="mzimg" class="mzimg"></image>
  7. <view class="mt50">
  8. <!-- 注册学校账号 -->
  9. <view class="rbtn mb24" @click="getRegister">申请注册</view>
  10. <!-- <button type="primary" class="rbtn mb24 mt50" open-type="getUserInfo" @getuserinfo="getuserinfo">
  11. <view class="rbtn mb24" >申请注册</view>
  12. </button> -->
  13. <view class="rtxt" @click="getlogin">已有账号,去登录</view>
  14. </view>
  15. </view>
  16. <view class="apllytxt flex0" @click="getQuery" >已注册,去查询</view>
  17. </view>
  18. <phone-btn :type="typeflag" @getPhoneNumber='getPhoneNumber' @getClose="getClose"></phone-btn>
  19. <pop-up :type='type' :regdat="regdat" @getregfn="getregfn" @getClose="getClose"></pop-up>
  20. </view>
  21. </template>
  22. <script>
  23. import popUp from "@/components/popup/popup.vue"
  24. import phoneBtn from "@/components/toptab/phonebtn.vue"
  25. import {getweChatOpenid} from "@/api/login.js"
  26. import {getqueryFn} from "@/api/mine/register.js"
  27. export default {
  28. components:{
  29. phoneBtn,popUp
  30. },
  31. data(){
  32. return{
  33. headimg:require('@/static/images/lricon.png'),
  34. mzimg:require('@/mine/static/mine/mzicon.png'),
  35. typeflag:false,
  36. type:0,
  37. wxInfo:{},
  38. regdat:{},
  39. typereg:'register'
  40. }
  41. },
  42. onLoad: function() {
  43. if(uni.getStorageSync('wxInfo')){
  44. this.wxInfo=JSON.parse(JSON.stringify(uni.getStorageSync('wxInfo')))
  45. }
  46. uni.removeStorageSync('nopasslist')
  47. },
  48. methods:{
  49. getlogin(){
  50. this.$tab.reLaunch(`/pages/login`)
  51. },
  52. getClose() {
  53. this.typeflag = false;
  54. this.type=0;
  55. },
  56. getregfn(data){
  57. if(data==2){
  58. this.type = 0;
  59. this.$tab.reLaunch(`/pages/login`)
  60. }else{
  61. this.type = 0
  62. }
  63. },
  64. getRegister(){
  65. this.$tab.navigateTo(`/mine/pages/mine/auth`)
  66. },
  67. getPhoneNumber(data){
  68. var that=this;
  69. getweChatOpenid(data).then(res=>{
  70. if(res.code==200){
  71. that.typeflag=false;
  72. that.wxInfo =res.data
  73. uni.setStorageSync('wxInfo', JSON.parse(JSON.stringify(res.data)));
  74. // 判断是从哪来的
  75. if(that.typereg=='query'){
  76. that.getQuery()
  77. }else{
  78. that.$tab.navigateTo(`/mine/pages/mine/auth`)
  79. }
  80. }
  81. })
  82. },
  83. async getuserinfo(e) {
  84. const {iv,encryptedData} = e.detail
  85. const {nickName, avatarUrl, ...userInfo} = e.detail.userInfo
  86. try{
  87. uni.login({
  88. provider: 'weixin',
  89. success: (res) => {
  90. // 获取用户信息
  91. if(res.code){
  92. if(this.wxInfo.openId){
  93. this.$tab.navigateTo(`/mine/pages/mine/auth`)
  94. }else{
  95. this.typeflag=true;
  96. this.typereg="register"
  97. }
  98. }
  99. }
  100. })
  101. } catch(e){
  102. //TODO handle the exception
  103. }
  104. },
  105. getQuery(){
  106. this.$tab.navigateTo('/mine/pages/login/query')
  107. return
  108. // 原来的获取授权
  109. if(!this.wxInfo.openId){
  110. // 授权
  111. uni.getUserProfile({
  112. desc: "获取你的昵称、头像、地区及性别",
  113. success: (res) => {
  114. if(!res.encryptedData || !res.iv){
  115. return false;
  116. }else{
  117. this.typeflag=true;
  118. this.typereg="query"
  119. return
  120. }
  121. },
  122. fail() {
  123. }
  124. })
  125. return
  126. }
  127. var params={
  128. phonenumber:''
  129. }
  130. var that=this;
  131. getqueryFn(params).then(res=>{
  132. if(res.code==200){
  133. that.typeflag=false;
  134. var a,b,c,isPass;
  135. var dat=res.data;
  136. if(dat.parents||dat.school||dat.teacher){
  137. Object.keys(dat).some((key) => {
  138. if(dat[key]&&dat[key].isPass){
  139. if (dat[key].isPass == 2) {
  140. a=1
  141. }
  142. if (dat[key].isPass == 3) {
  143. b=1
  144. }
  145. if (dat[key].isPass == 1) {
  146. c=1
  147. }
  148. }
  149. })
  150. // uni.setStorageSync("nopasslist",JSON.parse(JSON.stringify(dat)))
  151. // that.$tab.navigateTo('/mine/pages/login/query')
  152. // return
  153. if(b){
  154. //只要有一个拒绝 就展示列表
  155. // var regdat={
  156. // tit:'注册失败',txt:'您提交的注册申请未通过 请重新注册',btn:'去注册',type:3,
  157. // }
  158. // that.regdat=regdat;
  159. // that.type=4;
  160. // 走列表页面
  161. uni.setStorageSync("nopasslist",JSON.parse(JSON.stringify(dat)))
  162. that.$tab.navigateTo('/mine/pages/login/query')
  163. }else if(a){
  164. // 通过
  165. var regdat={
  166. tit:'注册成功',txt:'您提交的注册申请已通过 可前去登录',btn:'去登录',type:2
  167. }
  168. that.regdat=regdat;
  169. that.type=4;
  170. }else if(c){
  171. var regdat={
  172. tit:'注册审核',txt:'您提交的注册申请待审核 请耐心等待',btn:'取消',type:1
  173. }
  174. that.regdat=regdat;
  175. that.type=4;
  176. }else{
  177. this.$toast("您还未申请,请先去申请")
  178. }
  179. // this.$tab.navigateTo(`/mine/pages/login/query?isPass=${isPass}`)
  180. // console.log(a,b,c,isPass)
  181. }else{
  182. this.$toast("您还未申请,请先去申请")
  183. }
  184. }
  185. })
  186. }
  187. },
  188. }
  189. </script>
  190. <style lang="scss" scoped>
  191. .regbox{padding: 160rpx 56rpx 100rpx;display: flex;flex-direction: column;}
  192. .headimg{width: 136rpx;height: 136rpx;margin:0 auto 36rpx;}
  193. .mzimg{width: 100rpx;height: 44rpx;margin: 0 auto ;}
  194. .rtxt{font-size: 32rpx;font-weight: 500;
  195. color: #4775EA;text-align: center;}
  196. </style>