login.vue 7.8 KB

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