index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <view class="permission">
  3. <Nav :leftShow='false' title="君子校园"></Nav>
  4. <view class="user-permission">
  5. <view class="head">
  6. <view class="head-button" >
  7. <image src="@/static/img/logo/logo.png" class="head-img" mode=""></image>
  8. <view class="head-text">君子校园</view>
  9. </view>
  10. </view>
  11. <view class="hint-box">
  12. <view class="hint-title">该程序将获取以下授权:</view>
  13. <view class="hint-info">获取你的公开信息(昵称,头像等)</view>
  14. <view class="hint-info">获取你的小程序唯一标示用于账户授权登陆</view>
  15. </view>
  16. <view class="hint">
  17. <view class="hint-left-circle" @click.stop="isFlag = !isFlag">
  18. <view v-if="!isFlag" class="hint-circle"></view>
  19. <image v-else class="hint-img" src="@/static/img/common/y-select.png" mode=""></image>
  20. </view>
  21. <view class="hint-text-1" @click.stop="isFlag = !isFlag">我已阅读并同意</view>
  22. <view class="hint-text-2" @click="isPop = true;html = member_agreement">《用户服务》</view>
  23. <view class="hint-text-2" @click="isPop = true;html = privacy_protocol">《隐私协议》</view>
  24. </view>
  25. <view class="button">
  26. <view class="common permission-login" @click="login">微信授权登录</view>
  27. <view class="common permission-cancel" @click="noLogin">暂不登录</view>
  28. </view>
  29. </view>
  30. <view v-if="isPop" class="pop-view">
  31. <view class="pop-view-box">
  32. <view class="pop-info" v-html="html"></view>
  33. <view class="pop-botton">
  34. <view style="background-color: #3169FA;color: white;" class=" " @click="setCheck(1)">确定</view>
  35. <view style="color: #3169FA;" class="" @click="setCheck()">取消</view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import tools from "@/service/tools";
  43. import { appletLogin } from "@/api/member";
  44. import {getAgreement} from "@/api/common.js";
  45. export default {
  46. data() {
  47. return {
  48. isFlag: false,
  49. isAjax: false,
  50. from: {
  51. code: "",
  52. },
  53. isPop:false,
  54. html:'',
  55. member_agreement:'',//用户协议
  56. privacy_protocol:'',//隐私协议
  57. };
  58. },
  59. onLoad() {
  60. },
  61. mounted() {
  62. this.getPrivacyInfo()
  63. },
  64. methods: {
  65. getPrivacyInfo(){
  66. getAgreement().then((res)=>{
  67. if(res.code === 1){
  68. this.member_agreement = res.data.member_agreement;
  69. this.privacy_protocol = res.data.privacy_protocol;
  70. }
  71. })
  72. },
  73. setCheck(type){
  74. if(type === 1){
  75. this.isFlag = false
  76. }
  77. this.isPop = false
  78. },
  79. login() {
  80. if(!this.isFlag){
  81. return tools.error("请先勾选协议");
  82. }
  83. if (this.isAjax) {
  84. return false;
  85. }
  86. this.isAjax = true;
  87. uni.login({
  88. provider: "weixin",
  89. success: (loginRes) => {
  90. this.from.code = loginRes.code;
  91. this.getUserInfo();
  92. },
  93. fail: (loginRes) => {
  94. this.isAjax = false;
  95. tools.error("获取授权信息失败");
  96. },
  97. });
  98. },
  99. noLogin() {
  100. uni.switchTab({
  101. url: "/pages/index/index",
  102. });
  103. },
  104. async getUserInfo() {
  105. const res = await appletLogin(this.from);
  106. if (res.code == 1) {
  107. uni.setStorageSync('token',res.data.token)
  108. uni.setStorageSync('m_id',res.data.m_id)
  109. tools.success("授权成功");
  110. setTimeout(() => {
  111. uni.switchTab({
  112. url: "/pages/index/index",
  113. });
  114. }, 1000);
  115. } else {
  116. this.isAjax = false;
  117. tools.error(res.msg);
  118. }
  119. },
  120. },
  121. };
  122. </script>
  123. <style scoped lang="scss">
  124. .permission {
  125. width: 100vw;
  126. height: 100vh;
  127. background-color: #fff;
  128. position: relative;
  129. .hint {
  130. margin-top: 20rpx;
  131. display: flex;
  132. height: 34rpx;
  133. .hint-left-circle{
  134. width: 32rpx;
  135. height: 32rpx;
  136. margin-right: 18rpx;
  137. .hint-circle{
  138. width: 30rpx;
  139. height: 30rpx;
  140. border-radius: 50%;
  141. background-color: #fff;
  142. border: 2rpx solid #D9D9D9;
  143. }
  144. .hint-img{
  145. width: 32rpx;
  146. height: 32rpx;
  147. border-radius: 50%;
  148. }
  149. }
  150. .hint-text-1,.hint-text-2{
  151. font-size: 24rpx;
  152. font-weight: 400;
  153. }
  154. .hint-text-1{
  155. color: #999999;
  156. }
  157. .hint-text-2{
  158. color: #ED301D;
  159. }
  160. }
  161. .hint-box {
  162. margin-top: 140rpx;
  163. margin-bottom: 20rpx;
  164. .hint-title {
  165. font-size: 28rpx;
  166. }
  167. .hint-info {
  168. font-size: 24rpx;
  169. color: #6f6f6f;
  170. margin-top: 12rpx;
  171. }
  172. }
  173. .pop-view{
  174. width: 100%;
  175. height: 100vh;
  176. position: absolute;
  177. top:0;
  178. left: 0;
  179. background: rgba(0, 0, 0, 0.5);
  180. .pop-view-box{
  181. display: flex;
  182. flex-direction: column;
  183. margin: 400rpx auto;
  184. width: 80vw;
  185. height: 50vh;
  186. overflow: scroll;
  187. background-color: #fff;
  188. border-radius: 10rpx;
  189. box-sizing: border-box;
  190. padding: 20rpx 40rpx;
  191. .pop-info{
  192. flex: 1;
  193. overflow: auto;
  194. }
  195. .pop-botton{
  196. display: flex;
  197. justify-content: space-between;
  198. margin-top: 20rpx;
  199. box-sizing: border-box;
  200. padding: 0 130rpx;
  201. view{
  202. width: 100rpx;
  203. height: 50rpx;
  204. line-height: 50rpx;
  205. text-align: center;
  206. font-size: 30rpx;
  207. border:2rpx solid #3169FA;
  208. border-radius: 10rpx;
  209. margin: 0 10rpx;
  210. }
  211. }
  212. }
  213. }
  214. .user-permission {
  215. position: absolute;
  216. top: 40%;
  217. left: 50%;
  218. transform: translate(-50%, -50%);
  219. width: 100%;
  220. padding: 0 36rpx;
  221. box-sizing: border-box;
  222. .head {
  223. display: flex;
  224. flex-direction: column;
  225. align-items: center;
  226. button::after{
  227. border-color: #fff !important;
  228. }
  229. .head-button{
  230. background-color: #fff;
  231. padding: 0;
  232. }
  233. .head-text{
  234. text-align: center;
  235. margin-top: 16rpx;
  236. font-weight: 400;
  237. color: #333333;
  238. font-size: 28rpx;
  239. }
  240. .head-img {
  241. width: 120rpx;
  242. height: 120rpx;
  243. border-radius: 50%;
  244. margin: 0 auto;
  245. }
  246. }
  247. .user-name-view{
  248. display: flex;
  249. margin-top: 100rpx;
  250. .user-name{
  251. font-weight: 400;
  252. color: #333333;
  253. font-size: 32rpx;
  254. }
  255. .user-input{
  256. width: 568rpx;
  257. border-bottom: 1rpx solid #D9D9D9;
  258. font-size: 32rpx;
  259. padding-bottom: 16rpx;
  260. }
  261. }
  262. .button {
  263. margin-top: 60rpx;
  264. .common {
  265. width: 100%;
  266. height: 88rpx;
  267. line-height: 88rpx;
  268. text-align: center;
  269. border-radius: 200rpx;
  270. }
  271. .permission-login {
  272. background: #41ABF5;
  273. color: #fff;
  274. &:active {
  275. background-color: #41ABF5;
  276. }
  277. }
  278. .permission-cancel {
  279. margin-top: 40rpx;
  280. background: rgb(247, 247, 247);
  281. &:active {
  282. background-color: rgb(238, 238, 238);
  283. }
  284. }
  285. }
  286. }
  287. }
  288. </style>