login.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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="/static/order/isCheck.png" color="#2979ff" size="20" @click="changeChoose"></u-icon>
  46. <u-icon v-else name="/static/order/notCheck.png" color="#FFE05C" 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('3','隐私政策')" 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:false,
  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.$u.toast('请阅读条款并勾选注册')
  136. return
  137. }
  138. wx.login({
  139. success(re) {
  140. that.$api.wxLogin({code:re.code}).then(res=>{
  141. uni.setStorageSync('userInfo',res.data.data.userInfo)
  142. uni.setStorageSync('accessToken',res.data.data.access_token)
  143. uni.setStorageSync('phoneIsBind',res.data.data.phoneIsBind)
  144. uni.removeStorageSync('parent_member_id');
  145. // if (!res.data.data.phoneIsBind){
  146. // uni.showModal({
  147. // title:'温馨提示',
  148. // content:'请绑定手机号,以便为你提供服务',
  149. // success:res=>{
  150. // if (res.confirm){
  151. // uni.navigateTo({
  152. // url: '/myPages/setting/setting-telphone',
  153. // })
  154. // }
  155. // }
  156. // })
  157. // }else {
  158. uni.switchTab({
  159. url: '/pages/index/index',
  160. })
  161. // }
  162. })
  163. },
  164. fail(err){
  165. console.log('出错了++++++++++++++++',err)
  166. }
  167. })
  168. },
  169. getPhoneNumber(e) {
  170. uni.showToast({
  171. title: e.detail.code
  172. })
  173. console.log(e.detail.code) // 动态令牌
  174. console.log(e.detail.errMsg) // 回调信息(成功失败都会返回)
  175. console.log(e.detail.errno) // 错误码(失败时返回)
  176. },
  177. // 去找回账号页面
  178. gotoRetieveAccount() {
  179. uni.navigateTo({
  180. url: '/loginPages/login/retrieve-account',
  181. })
  182. },
  183. groupChange(n) {
  184. console.log('groupChange', n);
  185. },
  186. radioChange(n) {
  187. this.radiovalue1 = ""
  188. console.log('radioChange', n);
  189. },
  190. },
  191. };
  192. </script>
  193. <style lang="scss">
  194. page,
  195. body {
  196. background: #fff;
  197. }
  198. .container {
  199. width: 90%;
  200. margin: 0 auto;
  201. font-family: PingFangSC-Semibold, PingFang SC;
  202. .title {
  203. margin-top: 12px;
  204. width: 140px;
  205. font-size: 24px;
  206. font-weight: 600;
  207. color: #333333;
  208. line-height: 38px;
  209. }
  210. .h-logo {
  211. text-align: center;
  212. .logo-img {
  213. width: 160px;
  214. height: 122px;
  215. }
  216. }
  217. .login-wrap {
  218. .account {
  219. display: flex;
  220. }
  221. }
  222. .login-btn {
  223. text-align: center;
  224. color: #333;
  225. width: 70%;
  226. justify-content: center;
  227. margin: 0 auto;
  228. margin-top: 50px;
  229. height: 40px;
  230. line-height: 40px;
  231. border-radius: 8px;
  232. background: #FFE05C;
  233. border-radius: 21px;
  234. font-size: 14px;
  235. display: flex;
  236. .wechat-logo {
  237. height: 12px;
  238. width: 12px;
  239. }
  240. }
  241. .identifying-code {
  242. image {
  243. width: 80px;
  244. height: 30px;
  245. }
  246. }
  247. .remember-acconut {
  248. margin-top: 18px;
  249. display: flex;
  250. justify-content: space-between;
  251. color: #999999;
  252. .forget-acconut-password {
  253. color: rgb(96, 98, 102);
  254. font-size: 15px;
  255. line-height: 25px;
  256. margin-left: 30%;
  257. }
  258. }
  259. .agreement-content {
  260. margin-top: 18px;
  261. display: flex;
  262. // justify-content: space-between;
  263. color: #999999;
  264. align-items: center;
  265. .agreement {
  266. color: rgb(96, 98, 102);
  267. padding-left: 1px;
  268. font-size: 28rpx;
  269. .text-color {
  270. color: red;
  271. }
  272. }
  273. }
  274. }
  275. .h-popo-content {
  276. height: 180px;
  277. padding: 12px;
  278. width: 300px;
  279. text-align: center;
  280. font-size: 14px;
  281. font-family: PingFangSC-Semibold, PingFang SC;
  282. .h-img {
  283. padding: 7px;
  284. display: flex;
  285. justify-content: center;
  286. }
  287. .h-text {
  288. margin-top: 12px;
  289. font-weight: 400;
  290. color: #666666;
  291. }
  292. .text {
  293. margin-top: 6px;
  294. font-weight: 400;
  295. color: #666666;
  296. }
  297. .h-btn-wrap {
  298. display: flex;
  299. justify-content: space-between;
  300. color: #333333;
  301. text-align: center;
  302. margin-top: 14px;
  303. .h-left-btn {
  304. height: 32px;
  305. line-height: 30px;
  306. background: #EEEEEE;
  307. width: 100px;
  308. text-align: center;
  309. border-radius: 16px;
  310. margin: 0 auto;
  311. }
  312. .h-right-btn {
  313. height: 32px;
  314. line-height: 30px;
  315. background: #FFE05C;
  316. width: 100px;
  317. border-radius: 16px;
  318. margin: 0 auto;
  319. }
  320. }
  321. }
  322. </style>