login.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <view class="container">
  3. <view class="login-wrap">
  4. <view class="title">
  5. <text>HI,您好! 欢迎登录</text>
  6. </view>
  7. <view class="h-logo">
  8. <image class="logo-img" src="../../static/logo.png" mode=""></image>
  9. </view>
  10. <!-- <button class="login-btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
  11. <u-icon name="weixin-fill" color="green" size="26"></u-icon>
  12. 微信授权手机号登录
  13. </button> -->
  14. <button class="login-btn" @click="wechatCodeLogin()">
  15. <u-icon name="weixin-fill" color="green" size="26"></u-icon>
  16. 授权微信登录
  17. </button>
  18. <view class="login-form">
  19. <view class="remember-acconut">
  20. <view class="remember-acconut-password">
  21. <u-radio-group
  22. v-model="radiovalue1"
  23. placement="column"
  24. @change="groupChange"
  25. >
  26. <u-radio
  27. :customStyle="{marginBottom: '8px'}"
  28. v-for="(item, index) in radiolist1"
  29. :key="index"
  30. :label="item.name"
  31. :name="item.name"
  32. @change="radioChange"
  33. >
  34. </u-radio>
  35. </u-radio-group>
  36. </view>
  37. <view @click="gotoRetieveAccount()" class="forget-acconut-password">
  38. 找回账号
  39. </view>
  40. </view>
  41. </view>
  42. <view class="login-form">
  43. <text style="color: red;font-size: 22rpx ">*此账号密码可进行交易使用,请保存好您的隐私。</text>
  44. <view class="agreement-content">
  45. <u-icon name="checkmark-circle-fill" color="#2979ff" size="20"></u-icon>
  46. <view class="agreement">
  47. <text>允许我们在必要的场景下合理使用你的相关信息,请阅读并同意协议</text>
  48. <text @click="gotoAgreement('1','会员协议')" class="text-color">《会员协议》、</text>
  49. <text @click="gotoAgreement('2','服务对象协议')" class="text-color">《服务对象协议》、</text>
  50. <text @click="gotoAgreement('3','服务对象协议')" class="text-color">《服务对象协议》</text>等内容
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 判断微信是否绑定账号 -->
  55. <u-popup :show="show" :round="10" mode="center" >
  56. <view class="h-popo-content">
  57. <view class="h-img">
  58. <u-icon name="/static/login/u01.png" color="red" size="60"></u-icon>
  59. </view>
  60. <view class="text">
  61. <text>该微信未绑定账号</text>
  62. </view>
  63. <view class="h-btn-wrap">
  64. <view @click="cancelOption" class="h-left-btn">
  65. <text>取消</text>
  66. </view>
  67. <view @click="gotoBindAccount" class="h-right-btn">
  68. <text>去绑定</text>
  69. </view>
  70. </view>
  71. </view>
  72. </u-popup>
  73. </view>
  74. </view>
  75. </template>
  76. <script>
  77. export default {
  78. data() {
  79. return {
  80. show: false,
  81. userInfo: {
  82. username: 'uview-plus UI',
  83. password: '',
  84. openId: ''
  85. },
  86. // 基本案列数据
  87. radiolist1: [{
  88. name: '自动登录',
  89. disabled: true
  90. }],
  91. radiolist2: [{
  92. name: '允许我们在必要的场景下合理使用你的相关信息,登录且同意',
  93. disabled: true
  94. }],
  95. // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  96. radiovalue1: '自动登录',
  97. radiovalue2: '22222',
  98. };
  99. },
  100. onLoad() {
  101. // this.wechatCodeLogin();
  102. },
  103. methods: {
  104. // 去协议页面
  105. gotoAgreement(type,name){
  106. uni.navigateTo({
  107. url: '/myPages/TermsOfService/index?name='+name + '&type=' + type,
  108. })
  109. },
  110. // 取消操作
  111. cancelOption(){
  112. this.show = false;
  113. },
  114. // 去绑定账号
  115. gotoBindAccount(){
  116. this.show = false;
  117. uni.navigateTo({
  118. url: '/loginPages/login/bind-account',
  119. })
  120. },
  121. // 自动登录不成功,用户手动授权登录
  122. authWechatCodeLogin(){
  123. if(this.userInfo == undefined){
  124. this.show = true;
  125. }
  126. },
  127. // 微信小程序code自动登录
  128. wechatCodeLogin(){
  129. let that = this;
  130. wx.login({
  131. success(re) {
  132. that.$api.wxAuthLogin({code:re.code}).then(res=>{
  133. that.userInfo = res.data.data.userInfo
  134. uni.setStorageSync('userInfoOpenId',res.data.data.openId)
  135. uni.setStorageSync('userInfo',res.data.data.userInfo)
  136. uni.setStorageSync('accessToken',res.data.data.access_token)
  137. uni.setStorageSync('phoneIsBind',res.data.data.phoneIsBind)
  138. if (res.data.data.phoneIsBind){
  139. uni.switchTab({
  140. url: '/pages/index/index',
  141. })
  142. }else {
  143. that.show = true
  144. }
  145. })
  146. },
  147. })
  148. },
  149. getPhoneNumber (e) {
  150. uni.showToast({
  151. title: e.detail.code
  152. })
  153. console.log(e.detail.code) // 动态令牌
  154. console.log(e.detail.errMsg) // 回调信息(成功失败都会返回)
  155. console.log(e.detail.errno) // 错误码(失败时返回)
  156. },
  157. // 去找回账号页面
  158. gotoRetieveAccount(){
  159. uni.navigateTo({
  160. url: '/loginPages/login/retrieve-account',
  161. })
  162. },
  163. groupChange(n) {
  164. console.log('groupChange', n);
  165. },
  166. radioChange(n) {
  167. this.radiovalue1 = ""
  168. console.log('radioChange', n);
  169. },
  170. },
  171. };
  172. </script>
  173. <style lang="scss">
  174. page,body{
  175. background: #fff;
  176. }
  177. .container{
  178. width: 90%;
  179. margin: 0 auto;
  180. font-family: PingFangSC-Semibold, PingFang SC;
  181. .title{
  182. margin-top: 12px;
  183. width: 140px;
  184. font-size: 24px;
  185. font-weight: 600;
  186. color: #333333;
  187. line-height: 38px;
  188. }
  189. .h-logo{
  190. text-align: center;
  191. .logo-img{
  192. width: 160px;
  193. height: 122px;
  194. }
  195. }
  196. .login-wrap {
  197. .account{
  198. display: flex;
  199. }
  200. }
  201. .login-btn{
  202. text-align: center;
  203. color: #333;
  204. width: 70%;
  205. justify-content: center;
  206. margin: 0 auto;
  207. margin-top: 50px;
  208. height: 40px;
  209. line-height: 40px;
  210. border-radius: 8px;
  211. background: #FFE05C;
  212. border-radius: 21px;
  213. font-size: 14px;
  214. display: flex;
  215. .wechat-logo{
  216. height: 12px;
  217. width: 12px;
  218. }
  219. }
  220. .identifying-code{
  221. image{
  222. width: 80px;
  223. height: 30px;
  224. }
  225. }
  226. .remember-acconut{
  227. margin-top: 18px;
  228. display: flex;
  229. justify-content: space-between;
  230. color: #999999;
  231. .forget-acconut-password{
  232. color: rgb(96, 98, 102);
  233. font-size: 15px;
  234. line-height: 25px;
  235. margin-left: 30%;
  236. }
  237. }
  238. .agreement-content{
  239. margin-top: 18px;
  240. display: flex;
  241. // justify-content: space-between;
  242. color: #999999;
  243. align-items: center;
  244. .agreement{
  245. color: rgb(96, 98, 102);
  246. padding-left: 1px;
  247. font-size: 23rpx;
  248. .text-color{
  249. color: blue;
  250. }
  251. }
  252. }
  253. }
  254. .h-popo-content{
  255. height: 180px;
  256. padding: 12px;
  257. width: 300px;
  258. text-align: center;
  259. font-size: 14px;
  260. font-family: PingFangSC-Semibold, PingFang SC;
  261. .h-img{
  262. padding: 7px;
  263. display: flex;
  264. justify-content: center;
  265. }
  266. .h-text{
  267. margin-top: 12px;
  268. font-weight: 400;
  269. color: #666666;
  270. }
  271. .text{
  272. margin-top: 6px;
  273. font-weight: 400;
  274. color: #666666;
  275. }
  276. .h-btn-wrap{
  277. display: flex;
  278. justify-content: space-between;
  279. color: #333333;
  280. text-align: center;
  281. margin-top: 14px;
  282. .h-left-btn{
  283. height: 32px;
  284. line-height: 30px;
  285. background: #EEEEEE;
  286. width: 100px;
  287. text-align: center;
  288. border-radius: 16px;
  289. margin: 0 auto;
  290. }
  291. .h-right-btn{
  292. height: 32px;
  293. line-height: 30px;
  294. background: #FFE05C;
  295. width: 100px;
  296. border-radius: 16px;
  297. margin: 0 auto;
  298. }
  299. }
  300. }
  301. </style>