index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="login-main">
  3. <!-- Logo区域 -->
  4. <view class="logo-wrap">
  5. <image class="logo-img" src="../../static/images/logo.png" mode="aspectFit"></image>
  6. <text class="logo-title">天枢云</text>
  7. </view>
  8. <view>
  9. <!-- 授权说明区域 -->
  10. <view class="auth-info-wrap">
  11. <text class="auth-title">请确认以下信息并授权登录</text>
  12. <text class="auth-desc">获取您的信息(你的头像、信息等)</text>
  13. </view>
  14. <!-- 按钮区域 -->
  15. <view class="btn-wrap">
  16. <button class="auth-btn" @click="login">授权登录</button>
  17. </view>
  18. <!-- 协议单选框 -->
  19. <view class="agreement-wrap">
  20. <u-radio-group v-model="radiovalue">
  21. <u-radio value="1" size="30" name="1" iconSize="25" activeColor="#409EFF">
  22. <text class="agreement-text">授权同意 <text @click="toAgreement" style="color: #1677FF;">《用户服务协议》</text> 和 <text
  23. @click="toPolicy" style="color: #1677FF;">《隐私协议》</text></text>
  24. </u-radio>
  25. </u-radio-group>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import ap from "../../static/zfb.js"
  32. import {
  33. requestConfig
  34. } from "@/app.config.js";
  35. export default {
  36. data() {
  37. return {
  38. ap: ap,
  39. // 默认勾选协议,匹配参考图
  40. radiovalue: 1,
  41. shopId: "",
  42. uid: "",
  43. userInfo: {}
  44. };
  45. },
  46. onLoad(options) {
  47. this.shopId = options.shopId;
  48. this.uid = options.uid || '';
  49. let alipayuserinfo = localStorage.getItem("aliPayUserInfo")
  50. let wechatuserinfo = localStorage.getItem("weChatUserInfo")
  51. if (alipayuserinfo) {
  52. this.zfbLink()
  53. } else if (wechatuserinfo) {
  54. this.wxLink()
  55. }
  56. },
  57. methods: {
  58. toAgreement() {
  59. uni.navigateTo({
  60. url: '/pages/index/agreement'
  61. })
  62. },
  63. toPolicy() {
  64. uni.navigateTo({
  65. url: '/pages/index/policy'
  66. })
  67. },
  68. login() {
  69. console.log(this.radiovalue);
  70. var userAgent = window.navigator.userAgent.toUpperCase();
  71. if (this.radiovalue == 1) {
  72. if (userAgent.indexOf('MICROMESSENGER') > 0) {
  73. this.wxLink()
  74. }
  75. if (userAgent.indexOf('ALIPAYCLIENT') > 0) {
  76. this.zfbLink()
  77. }
  78. } else {
  79. uni.$u.toast('请先同意用户授权!');
  80. }
  81. },
  82. zfbLink() {
  83. let url =
  84. `${requestConfig.zfb_request_url}?app_id=${requestConfig.zfb_appid}
  85. &scope=${requestConfig.zfb_scope}
  86. &redirect_uri=${encodeURIComponent(requestConfig.zfb_redirect_uri)}
  87. &state=STATE
  88. &shopId=${this.shopId}
  89. ${this.uid ? '&uid=' + this.uid : ''}
  90. &type=zfb`
  91. console.log(url);
  92. window.location = url;
  93. },
  94. wxLink() {
  95. /*微信授权登录*/
  96. let redirect_uri = encodeURIComponent(requestConfig.wx_redirect_uri + '?shopId=' + this.shopId + '&uid=' +
  97. this.uid)
  98. let url = `https://open.weixin.qq.com/connect/oauth2/authorize?
  99. appid=${requestConfig.wx_appid}
  100. &redirect_uri=${redirect_uri}
  101. &response_type=code
  102. &scope=snsapi_userinfo
  103. &state=STATE
  104. #wechat_redirect`;
  105. window.location = url;
  106. },
  107. },
  108. };
  109. </script>
  110. <style scoped lang="scss">
  111. /* 全局页面容器 */
  112. .login-main {
  113. width: 100%;
  114. min-height: 100vh;
  115. background-color: #ffffff;
  116. display: flex;
  117. flex-direction: column;
  118. align-items: center;
  119. padding: 0 40rpx;
  120. box-sizing: border-box;
  121. justify-content: space-around;
  122. }
  123. /* Logo区域 */
  124. .logo-wrap {
  125. margin-top: 180rpx;
  126. display: flex;
  127. flex-direction: column;
  128. align-items: center;
  129. margin-bottom: 160rpx;
  130. .logo-img {
  131. width: 160rpx;
  132. height: 160rpx;
  133. margin-bottom: 30rpx;
  134. }
  135. .logo-title {
  136. font-size: 48rpx;
  137. font-weight: 500;
  138. color: #333333;
  139. line-height: 64rpx;
  140. }
  141. }
  142. /* 授权说明区域 */
  143. .auth-info-wrap {
  144. display: flex;
  145. flex-direction: column;
  146. align-items: center;
  147. margin-bottom: 60rpx;
  148. .auth-title {
  149. font-size: 32rpx;
  150. font-weight: 500;
  151. color: #333333;
  152. line-height: 44rpx;
  153. margin-bottom: 16rpx;
  154. }
  155. .auth-desc {
  156. font-size: 28rpx;
  157. color: #999999;
  158. line-height: 40rpx;
  159. }
  160. }
  161. /* 按钮区域 */
  162. .btn-wrap {
  163. width: 100%;
  164. margin-bottom: 40rpx;
  165. .auth-btn {
  166. width: 100%;
  167. height: 90rpx;
  168. line-height: 90rpx;
  169. background: linear-gradient(90deg, #66B1FF 0%, #1677FF 100%);
  170. border-radius: 45rpx;
  171. border: none;
  172. color: #ffffff;
  173. font-size: 32rpx;
  174. font-weight: 500;
  175. padding: 0;
  176. }
  177. }
  178. /* 协议区域 */
  179. .agreement-wrap {
  180. display: flex;
  181. align-items: center;
  182. justify-content: center;
  183. .agreement-text {
  184. font-size: 28rpx;
  185. color: #999999;
  186. line-height: 40rpx;
  187. }
  188. }
  189. /* 单选框样式适配 */
  190. .u-radio-group--row {
  191. justify-content: center;
  192. }
  193. </style>