login.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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="#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. })
  165. },
  166. getPhoneNumber(e) {
  167. uni.showToast({
  168. title: e.detail.code
  169. })
  170. console.log(e.detail.code) // 动态令牌
  171. console.log(e.detail.errMsg) // 回调信息(成功失败都会返回)
  172. console.log(e.detail.errno) // 错误码(失败时返回)
  173. },
  174. // 去找回账号页面
  175. gotoRetieveAccount() {
  176. uni.navigateTo({
  177. url: '/loginPages/login/retrieve-account',
  178. })
  179. },
  180. groupChange(n) {
  181. console.log('groupChange', n);
  182. },
  183. radioChange(n) {
  184. this.radiovalue1 = ""
  185. console.log('radioChange', n);
  186. },
  187. },
  188. };
  189. </script>
  190. <style lang="scss">
  191. page,
  192. body {
  193. background: #fff;
  194. }
  195. .container {
  196. width: 90%;
  197. margin: 0 auto;
  198. font-family: PingFangSC-Semibold, PingFang SC;
  199. .title {
  200. margin-top: 12px;
  201. width: 140px;
  202. font-size: 24px;
  203. font-weight: 600;
  204. color: #333333;
  205. line-height: 38px;
  206. }
  207. .h-logo {
  208. text-align: center;
  209. .logo-img {
  210. width: 160px;
  211. height: 122px;
  212. }
  213. }
  214. .login-wrap {
  215. .account {
  216. display: flex;
  217. }
  218. }
  219. .login-btn {
  220. text-align: center;
  221. color: #333;
  222. width: 70%;
  223. justify-content: center;
  224. margin: 0 auto;
  225. margin-top: 50px;
  226. height: 40px;
  227. line-height: 40px;
  228. border-radius: 8px;
  229. background: #FFE05C;
  230. border-radius: 21px;
  231. font-size: 14px;
  232. display: flex;
  233. .wechat-logo {
  234. height: 12px;
  235. width: 12px;
  236. }
  237. }
  238. .identifying-code {
  239. image {
  240. width: 80px;
  241. height: 30px;
  242. }
  243. }
  244. .remember-acconut {
  245. margin-top: 18px;
  246. display: flex;
  247. justify-content: space-between;
  248. color: #999999;
  249. .forget-acconut-password {
  250. color: rgb(96, 98, 102);
  251. font-size: 15px;
  252. line-height: 25px;
  253. margin-left: 30%;
  254. }
  255. }
  256. .agreement-content {
  257. margin-top: 18px;
  258. display: flex;
  259. // justify-content: space-between;
  260. color: #999999;
  261. align-items: center;
  262. .agreement {
  263. color: rgb(96, 98, 102);
  264. padding-left: 1px;
  265. font-size: 23rpx;
  266. .text-color {
  267. color: red;
  268. }
  269. }
  270. }
  271. }
  272. .h-popo-content {
  273. height: 180px;
  274. padding: 12px;
  275. width: 300px;
  276. text-align: center;
  277. font-size: 14px;
  278. font-family: PingFangSC-Semibold, PingFang SC;
  279. .h-img {
  280. padding: 7px;
  281. display: flex;
  282. justify-content: center;
  283. }
  284. .h-text {
  285. margin-top: 12px;
  286. font-weight: 400;
  287. color: #666666;
  288. }
  289. .text {
  290. margin-top: 6px;
  291. font-weight: 400;
  292. color: #666666;
  293. }
  294. .h-btn-wrap {
  295. display: flex;
  296. justify-content: space-between;
  297. color: #333333;
  298. text-align: center;
  299. margin-top: 14px;
  300. .h-left-btn {
  301. height: 32px;
  302. line-height: 30px;
  303. background: #EEEEEE;
  304. width: 100px;
  305. text-align: center;
  306. border-radius: 16px;
  307. margin: 0 auto;
  308. }
  309. .h-right-btn {
  310. height: 32px;
  311. line-height: 30px;
  312. background: #FFE05C;
  313. width: 100px;
  314. border-radius: 16px;
  315. margin: 0 auto;
  316. }
  317. }
  318. }
  319. </style>